From patchwork Thu Oct 15 13:26:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382665 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=q37+JwHv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=NCHZglxo; 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=boi75oAR; 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 4CBqpR2W2Dz9sV1 for ; Fri, 16 Oct 2020 00:27: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=q37+JwHv20KfzCX0EE3c583S9 kQbccw0MNctaWXOo4LYZx4D+/Pax9hMicAPW5BrDYqRaBKG4GgldLtXprDuQz2bDTONlZBLg8H+6z G9k/hRmZxBdMJvLmR+56opLNf7m9FQaghQU7mLIXjMXi+qsPFIFWfXTUesGk8JXmUOPAZTpdAy22J mGlIJjKzLAQjn7z6TXX8yN4RPADJ/iwEfSUj65UP6ZhE1M2aBXgnnrqg6pNR1N7Vpbt5+70G1b78o uNRbREItrCTqpXLNsH5bQrrPzK3IsVd3+ASL6U1Uso4x/nKntL7mmRPTCaycSrLgcKcLVd3iiWUE8 zoAHr1jRQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3I9-0004FG-8u; Thu, 15 Oct 2020 13:27:37 +0000 Received: from esa3.hgst.iphmx.com ([216.71.153.141]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3I6-0004DJ-HE for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:35 +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=1602768454; x=1634304454; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=sbvNykyZ+6H7Fy1xTRek6AfInkDQagsF50UczhsTOKA=; b=NCHZglxoXklRP6C154vOd1cXcd3k2brIRj+zQ1kuZlokWJ/NL57wy873 h2yKYX2bM5tU5klOl36baIXt5pKI1/lpddsvtRNGIWAegYyj7RZc/igyr 7kj1xlFvzZCBY8Hi+rBNsuhacaO6u7ldf1uKTaDw+xkpcW1WCFrp22ljC IncTVZoB6csD+iaSHdtFBX6NBC/L4/dcasWMmXCA4HMxmcex7nonuenuc TExpdhDXAFJDjc77JRd3xmQWkagly7rVQJrz9J4hLuvxiiSzE+8055H9m OIz8PwyDbb5F+bEabtx87zO1X5DrOojFDdQTNGFN2kdqZ6IS/KKphES2h Q==; IronPort-SDR: piO/v95NtTAyf52HkuFvw15G0ZCKWDrWl62Pq7r7X66l2VN1NMntMf1gMi0ExtMLUZMmcAxGRJ B4Wjf2wbKGxR0N/DDMeSoWfVqI+h8kPuTnhGef3+LrpcyiW1p3ABAzAO3sS9gRxMjtpUGX/ie4 MaJ3a2nHHssekV19Bj9lNKw/B4NFKqB5tneTn4iWsJrFSmLd51e0lOD7kqPqWGDCCIy5xyaJng sYrN5IGRhlJCZgbWy7E12+Dxz/Q9j0N4r1kGu/YYYPvdwTW2IUwQL4KOIQxR2CMAmXx5DOV//9 Le0= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457428" Received: from mail-cys01nam02lp2053.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.53]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:34 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=doTjVU9YN+qNjGS7CEorAuVAb/IDQyrg/lHdnURHNHLN/uZXPHvk0C+K8WeSmeNWZvETcW83rlM9bRxPhdtnWsYR3HTDsCOxQqkQMecRRNOLEgZqhTkeR1DR6R/1muXPuXR3Er42atW2AaJgIzvMs683F5JWx6nNH86/9CqnCVPBJxO5i8QbPgobW/Q94SCGFtIoOTKB9Z7m6JaebWdAMIrVIUliX1RSfbSKgqapu9TgrjuRa9qYN0e1Flsk+AyPILfXcksLM9uAzsSRQCpEmLubwBQYkpEmVSWVm+rApY98MWwzEY2rlYFlCd37jDnG1J3UD88v7ZbhawLE1XyVxQ== 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=gRngk2CjowpPLFbrOBsImDBMUNlhwI0gEQuMlQqAJqtt/987RVmxl/UEzm5Oq/VaIjwf/pDosSEIdNID0urdDjqd1Rg31WqiK1xmTNxZTVQOlAq7zbsWhYyuZnDggVGH8f61jOfai8DLbRFopKgdCj8YPQvVaxwOmXOxQ/Jy5tnY7aekWkchKWAFYfuk6uOs9nB8tdKTzLsMFEuY30CT1Y7hCWks8iH8nIHydlUwtf4spGs5DnHPJ8VUlVu9eAzHi8Uw/gv290+g+j3DZK/Hs7J4QQIeOI4j5uq+hWQp+PJQfCMjSdrwvsAi3WuLU6bodgyQYesQzTKdlTtOenIhjg== 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=boi75oARmYbD7LbiNGHKn3WAFJAoWqxEv9N+9iCQDSztpL5dPwkjwU+rxe2YLPXW0K/33qHNkOmn7YMt/CFaxB5hbC5p/rvS9o+FCez5vUfTD2aYL5DvUefYAfK03BFUMY10FulLQHv9jkhwidp/edR2lJa6zMIXYa8nLzMLwG4= 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 DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:33 +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.021; Thu, 15 Oct 2020 13:27:33 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 03/16] lib: sbi: Configure PMP late in coldboot and warmboot path Date: Thu, 15 Oct 2020 18:56:47 +0530 Message-Id: <20201015132700.2232820-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) 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.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ef6fea36-23e8-4900-ff12-08d8710e1224 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: v9irrk6n1PJ7D13yNllATqLbhHxF5Mk+bY4Eazefz5DpaQRNNPb5H40+5NXZtF8n9xlbhzXkzkyqcPSU8DEuSrZwQwFzrvhp9KsdQYYeUa0QqFKPciChh8/hkaoAop71ea2YG56LuvYz9w3XAbwi5YayIym2+CxoxHf6kHo9fmnARe7sdS5bt8YyElwmvCRj6ykM0YPwsTbyjmSGbqR3OSFoseNaGX6CDVIVxga9lujZIfGFfk5MbU0aelVaYDGYzj7cwGNGTP94nkRHzGx1knfeRisvzoPYEwxhrnZWg5Q8VyeRMFOlMLs76/eW8i+bXoWsJST4c9UFLysNFuZgTD+Op8Qs6/X+gRDI6DZNQW5nDO2mZTdqLKJuJp5mAcTI 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)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: iPOzcYISnXJI+R3LQgHsQKmvmqZsTRPLBPzozLNjHtqxmXU5v2pQ7mXKVuGbJiisJXDpM66ewj8VRSIsqMY6xydyhiU8R2ZXkjhSYmGa+x49dXvkA4X8SIy2QDr93qZwpSrbneQ5HZBPmGLdT5oxq5yL1LXq/oPxkdSf+OIlSb4qOioKLC+oZ/q7e9w+7gmyPHVNZPG6i2p8Q6tnYuoTw1ZzjEOmiPin7Uyi7LJPBfFQ6i5zSH9g/qHuTcBcaiLgt1Sf4/LAZq7kBINl0KEwVOEkNb/K+/yl8YLusu6UEO2tYUXeL+qs3bHyfmORGYhHa/EIzVemhB49hlfoW+WEmuxOQ2YrGty99LqhwaS5uLLRr8bDP4/88LyIUBw+dPfb8iwkL0sQvtUEnwhJkg9Q66GEcf8qF9lyJY+3GC96bc27OJhFTFRxk5Gh47vDaiQ3Xd0YSXQ+JNjYcX9eaux6zsYpxheecFRuHZQ9t+FE0XIH8o5eShNm0p5FJrXLEkZhplCeOnY8tEbZyklPBSO4adfdqReloptG1HO7XQr1WkgH5kHl0zTQtMsDw6CSVLAgVVD+W6Hlk4dHLoxm6TehIxjn25Yd+dqUsj4E4nuZ5Lzz8qs0lTnNJlUUPHgGKGZ0aXV6lYhXPxe9jBM+g/wXLQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef6fea36-23e8-4900-ff12-08d8710e1224 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:32.8685 (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: RyGL19a/wsGYAATV8dhVT0QMMpRzRH53JgweGHMD5MJKcOhhEzddpFra17pPFL8NXkRim4pKFuZhltQ4rkgjqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092734_872698_7CE978EB X-CRM114-Status: GOOD ( 16.18 ) 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 [216.71.153.141 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_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.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 --- 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();