From patchwork Mon Oct 19 12:54:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1384280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=Vkqprz0S; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=FjUbfHqs; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=oy1tLEyB; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CFGvg4LfCz9sV0 for ; Mon, 19 Oct 2020 23:55:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/UpQ4mFPEcUTkwmnkoci0/O7u5QcAqTa01xBYk2iKiI=; b=Vkqprz0S3f9u57E0OXFJcaJWO rw1/aa6i6j2lKf85YAZ8O/EfQ6uFgj1EqMporm36GheeCTuQWjWRJIvhc56sUAQK+AtL91RJeF1L7 fhaw/xVUCWfD0M2R1DcsN3uJUlw5iIud4KIyeTjkWRknRYxyB1JtaFDhaEqkAdT9vMOxZp1pBF0W0 r4GmZ7EXdagRDKNax6XyIubIYcPI7AD9rfl6fWZRRL69VwRKoeWVVEaSTeDnwP1w6mP45S2ap1vVr 2ykN3NgjulvEZO4nRnCzEZLJMdk9WSalbc0EBjtBXNEinr0XnNhg0fVkL5SkByxBVJ6/VoCAuQB6B y4Hmx6tEQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUUhK-0004st-Ep; Mon, 19 Oct 2020 12:55:34 +0000 Received: from esa2.hgst.iphmx.com ([68.232.143.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUUhI-0004rH-4V for opensbi@lists.infradead.org; Mon, 19 Oct 2020 12:55:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1603112801; x=1634648801; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=sbvNykyZ+6H7Fy1xTRek6AfInkDQagsF50UczhsTOKA=; b=FjUbfHqsfzoxlS6DtWRYQP86rFgRNJjVF6QH2RHfVwyst454d5HcXoZd h0VXCup0nMtts79J2vpQP4cVXVP6ppHlwAGGbcI/JxPQOvvRaH43or9LU 6GYX5VCsdb4mF+bNdxmBrJdVmlEdwhYnRj3sFW6x8vJl6GWyT3Z7KkcEp 0ekr1GMmPE5BDlM2q84zw7+maKes2B6DoR7fTSgwHQ1czfJw6qRvcOzl5 L5DRTUVhx+EoA5dwFO7uQYzY1/kjdDIwXWPNUk8r7wnQykalN/FvHJxy/ rf0lReCdj8cxa6X9EYllQowwjQDkf8wXnclvQT43Go3iszstF+A+XVvp6 w==; IronPort-SDR: jtSdJhiLsS71jTAuNftuW85lojc4+XH4++4u71K5LPVodcUriiDePAtkSBGbsIp4SgOAA9jx4N seLzzTSq1XfHMSDp7Gcrt9qF0ijVuEFhrmCf7kPvAkBCcDfOOo7KBflwDXnOlKS0x3DNt0Ejou teEsPpt7q4v77ATZT9RYGyXbV0SJHEupaaSolf2KiAoFT/jLlld9alLPNl9KiDLgN1hCEyWUEZ nrF3ZEldP9ZXvhZg3vmWKl9q96NZRbOz02zBZvttlHJUcn5TjG0ZDXmH8xaA+/aEOy3W6GxHoa OK8= X-IronPort-AV: E=Sophos;i="5.77,394,1596470400"; d="scan'208";a="253808586" Received: from mail-cys01nam02lp2052.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.52]) by ob1.hgst.iphmx.com with ESMTP; 19 Oct 2020 21:06:40 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PtZNLDfrv3qnb1NDZAlD3I05F+Z62l+d1W0IoGvf7hlJIjiTCRi+RtB5uCK3GD+AOfC6ySGo/bNJbNI+bRwAXsHvPPZmqQ7jc0Kp1gcXRAAeMBXV8c3s/E5fHSqxordDj2VGMAQ9kA6VO68AS1KKILrUoMuZTGtpnqysJ7b4T0OMfwk1UqkKV7feX7ScpK6JHPc5ZhYDlm55EBr0exrKiqZZnA0b20GlHTBi6BqBqRRzLLytW9LC4cnqVOTe87ucnIsUT+i38pbb+YjOC1p82ySy516JGaxQC44YWOZk0x3rg5muW0XFklpIjli2Wc+O25srdhG4jntdTy/4O7GDlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=28Z932hgLMY6IQA7KSmGIy1OaJaT7Jn1uWkSC3dvqo0=; b=nUD5xyp5OCm/1fasZSPtv/wAE0fDjiP+qUYtkuu6lA9bdexz404JZQt85MgzW03AgKbtA7opDTVFYIjpJ2E3eDpcto7Q7RDiqMkoPD0OugFw4LGh0wS9+rObfC81fPAFxHbuqDN7+W1IZkjmMV8uUPr+E/zakJkEOJ92b2ezvZVmD13dWX2aPUp7oeeCdgkc+Kkley8dqcWGEjwg3lSlSMBEpIrQVPY+SS+jistfUuAFuhpTP1VmVHfE7h8Jn9r29NE8qg24Csv9U7aQo80ywqFsbEfDhJyN5GjnTq5/jJd+KYYvAlQ/g58ylspLyRZ98wOa580wsP4XzHX+zEuEGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=28Z932hgLMY6IQA7KSmGIy1OaJaT7Jn1uWkSC3dvqo0=; b=oy1tLEyBGSmMQYgp5RpcTYTUSuZX14R84VmAKioxgpf6XL8hveqP3nO/Ike8NNqQdXRHCj9M3bIQhSRqq5UMGgOPh5eNrBsfHTDUxJKEgDRImYSKg1xgR6mgljDPL31TP4P7DcsEncIf9gToa8PLWljOyko6WmyZqGWdEwnd7CM= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB5548.namprd04.prod.outlook.com (2603:10b6:5:12a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.27; Mon, 19 Oct 2020 12:55:29 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.028; Mon, 19 Oct 2020 12:55:29 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v3 03/16] lib: sbi: Configure PMP late in coldboot and warmboot path Date: Mon, 19 Oct 2020 18:24:40 +0530 Message-Id: <20201019125453.2460105-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201019125453.2460105-1-anup.patel@wdc.com> References: <20201019125453.2460105-1-anup.patel@wdc.com> X-Originating-IP: [122.172.253.92] X-ClientProxiedBy: MAXPR0101CA0060.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::22) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.172.253.92) by MAXPR0101CA0060.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Mon, 19 Oct 2020 12:55:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9c4b84ae-204f-4d6a-28cc-08d8742e414e X-MS-TrafficTypeDiagnostic: DM6PR04MB5548: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j9yICxVstYyg94X+fayhnM27g94ofIZor62qC3yXVPA2uYdQpeTo4a/OJMeOjrY3NvSXrhnoG9A8OxPNddhdbtigZ8vJlE0VZ2g0E111N3kU1WxvZfIIL1FWnoGFHv5f0Tw3jzkQURplyNpwmznW9y3yHViQtEvpI839JDPtlHEao3O8sLoSwEeo1qSDzxcXnNxMVOROoyHf6JVpIVAWJKAisQHbo/wdizmWJhEUFgdkfKOUQx/qv6DrQTxBOLZRYv2xzqwCWDYMlFe4rcdVHpF/I8iYeqg/WeRRit05FG30kdOkzphJy2MzWxHxfLVLFEM4FUJWkGLISfmduPAj+A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(6636002)(55016002)(6666004)(8886007)(66946007)(66476007)(8936002)(8676002)(66556008)(2906002)(86362001)(44832011)(83380400001)(2616005)(956004)(16526019)(5660300002)(186003)(54906003)(110136005)(52116002)(7696005)(55236004)(1076003)(4326008)(478600001)(316002)(36756003)(26005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Q59c8/hif/cJ8DXz7mZQOX5fGfarq5dm/c+OiXW7gdzdwKD8Nd0Bny69EfocLDl7aajZvx1WMPI7AaINCKnIZyBFLpVCeqn0YHfdycWXMo9LMhyt2twbT89lTPX344VoHasMSONsHpm25HjSbyRsm5mrv3t98/5p29R6ZMbb6KrVA+NHApAw5yxtuMlKW1xwmvS58opCM+O0QOqDQpZHleLaByxCfmOhJP88XZQhtY4hzFERvP6BAu1GX9FBGVO+nHap9ecMWbePWHryVko+1G1dQthlr86lZJM9vW5kaT529TgaFJB9Rj36JgeiKHUjFhHKEMvOjIUnFTdU+PNqKefAtT+G/3zYYDJOl0uYaWCb4m1/YHI5ZdzO0S18J/TArRRZqqq299BO0N+UaNkIWF2drvrDJCfTH83WR0V7UFAMO5Nw5Xksn/6d3okn7bBVfvCCnRaq3BOiYYvEeK1wEQBsi57F/nEYCj9g2EXmhCPAy2v69o3yeneK/G5gyUVhEsZ8z6MegXCOeNdtv8ksBeLpIm337rlT241IwMCsT1MKN2H5FqdU5stv/c85A9DZjJOoTTtIFri80DM1/NTB4HwG7fXEJnfCsbUZOMxoy1Yrsd2Tg3goZm9l4eptiNVfuBrAqXNpQI87ldEN9GvKKw== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c4b84ae-204f-4d6a-28cc-08d8742e414e X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2020 12:55:29.0181 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mJEwXxYqQC/DsTS63ULLGnRyeRFl1ch0vl48B8ZcJchUl5kSEx49NoViAieKvDwQVMX9yUQd4yn+Dz3f54y6mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB5548 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201019_085532_307031_AE6C1961 X-CRM114-Status: GOOD ( 16.51 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We factor-out PMP configuration from sbi_hart_init() as a separate sbi_hart_pmp_configure() function and do the PMP configuration very late in coldboot and warmboot path just before platform_final_init(). Eventually, this enable us to configure PMP totally based on OpenSBI domain where OpenSBI domains can be parsed from device-tree in any of the platform operations except platform_final_init(). Signed-off-by: Anup Patel Reviewed-by: Atish Patra Reviewed-by: Alistair Francis --- include/sbi/sbi_hart.h | 1 + lib/sbi/sbi_hart.c | 4 ++-- lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 0ba68f0..9207f4c 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -45,6 +45,7 @@ void sbi_hart_pmp_dump(struct sbi_scratch *scratch); int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, unsigned long daddr, unsigned long mode, unsigned long attr); +int sbi_hart_pmp_configure(struct sbi_scratch *scratch); bool sbi_hart_has_feature(struct sbi_scratch *scratch, unsigned long feature); void sbi_hart_get_features_str(struct sbi_scratch *scratch, char *features_str, int nfstr); diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index edf79b7..7244f1c 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -224,7 +224,7 @@ int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, return SBI_OK; } -static int pmp_init(struct sbi_scratch *scratch, u32 hartid) +int sbi_hart_pmp_configure(struct sbi_scratch *scratch) { u32 pmp_idx = 0; unsigned long fw_start, fw_size_log2; @@ -462,7 +462,7 @@ int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) if (rc) return rc; - return pmp_init(scratch, hartid); + return 0; } void __attribute__((noreturn)) sbi_hart_hang(void) diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 65d81ba..85a5f13 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -210,6 +210,10 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); + rc = sbi_hart_pmp_configure(scratch); + if (rc) + sbi_hart_hang(); + rc = sbi_platform_final_init(plat, TRUE); if (rc) sbi_hart_hang(); @@ -266,6 +270,10 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); + rc = sbi_hart_pmp_configure(scratch); + if (rc) + sbi_hart_hang(); + rc = sbi_platform_final_init(plat, FALSE); if (rc) sbi_hart_hang();