From patchwork Fri Sep 25 11:28:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371183 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=3ZDv2vsD; 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=N0ngi7hH; 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=AqAwLkDZ; 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 4ByV7j5s9wz9sSf for ; Fri, 25 Sep 2020 21:29:53 +1000 (AEST) 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=9O8RyLQXrieQeKrHlP0LoXzniHPrTI0AGk4EzxagDWQ=; b=3ZDv2vsDDGxd2A7wdVUtLaNdy Fhf2FAmbjr2nulqw8UbNdiP8Nd/walYtct09+f49d6tkzTo9FzvJ/fXpD/p2LSj5w7ojZrdZCVDuv Jzq2xBzJsiyszUVU8SSvin9NyOcSpCC77ec64XdGruYsFSU+HHpRHgu+huHsAbMLh9ElKZ3h/jwmu Rn7P/UiXiBRPBhCBP/df9Dlc2FS3smXW1sBT0BUy8UDq7+KgjtFtcFokyuY+3Abo3gAMotnIUZ/Zx tYvR+yvJSldwR+ZOMK/P9SUkiagB9vaijhR52rKL6fkROLFfmt7iARLcTRMevRwHGensus1K0Ip09 oelOUmGtQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvA-000487-MI; Fri, 25 Sep 2020 11:29:48 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlv8-00046H-Cx for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:29:47 +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=1601033386; x=1632569386; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=sG6AvCxOBBcgRw/qJs37lQesLFXiTlDOfGXez33UV4Y=; b=N0ngi7hHb8JY4/DgA8aCPfleLtoG7b6ZNJ1q7FaSpNKk58pswmiVitex /x/CzkrAPo8Z2LkpWarJfcOL8RBWU1JUhzeLJMwCWgXBs0vUJ9/PF2E1q TdfSlWyNqHdeCcnMnB3gJCtb9l9ElrekJa/mICmMwrQhTrb4wptgulVwn m1BMFb3cPV22L4Y00VGJxsOnBrN6Dmxfd1tJ38BHQdXKnTtVnqbS/93xF jBUlGbyyMh1Lxmb0pKmL5tFDD53KjfEHUZ721gBqGpc+Qkc7MoeG5iwyi 3BZDDvxkp6bRLaAnJ3LTj+SQT06AFBQ9xZkMeP0wLq6ElJY4PhPfJQpP2 Q==; IronPort-SDR: zgotxxb4nOUnBe4UVAWTtgtgoWB4WuGDE3RQXcn90fwadj0HKiPvTJ0Px3HaInTxQkWrnpalW2 ikr6Pu6u8wWNAGG576QMKFtUP9G2nPw5oEZ7iN12e1Zi1Oo5K1GMbynXQVIBZWxCK09rbFq8JU V/5UsVX6L8mjvTz6BjtcTCC1Adta1FcKaxPRcj8btSHo94+FTAC/HjD2mp3sSrrC4QMxFl1Y9s g92UBoU5edkpGOVuT0vl9zeEfppWzhWA4mqHUMzehuI3h4FUDjpNwgn3Ry71/250qjTtRvXmNc c/Y= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="148192072" Received: from mail-co1nam04lp2052.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.52]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:29:44 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X37Y6vY15PDYSWjgl4XI+kaPwfdteY8PzKvFdG/dEcgwEbr98hu3e7NCFh2fpvQVvN/mNpCkeKfnIXFyfJFTaHroewcWz0Xp60Pp7LDcwQh5ZxutWiOQ9+dwCpT/RcnHmM8qFlXFXvWWAZ/mEz53C7zE8bqB3LKCVgEW+X0M9f9/pSguUzkT/EnwVsgJxtipKThQuW1uC6UgA8CE0aYjA3kMa6e/YKnpaNbxfPUhLLkdeYBgCHyoysWJ5PJBx32d5amuWhDoYXiTPnkSOgdXSLK358S0LkQP1ut8lhUQi9hd+AJGsCN2OoGB68jl+J9sd3oTRqEeflAOpy7dQmSP9Q== 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=dNWNcfgpA7JCqLjYmNDINxC+E0rHsIjBnjTd8lQqicA=; b=e0Nki6X9CcIjNhy91ZX7DR1Ix3Nm7hgtzyPPIuKHpIK3H3eS7PM3/nrEBNB4xdSXWj2ABz+y35tV0364FD37NVXLqgFPxLKJnasAbirsVu1Z0egW771TKNzBgL5QXx8OQp36hVUORWQNW5tYWMjf6VcQxXmsukMdg8KOghXJO5nJuxxnF7h1ena09aqAqI/pXQDYN9GDRbGyc05rbw9qxzoQ9JEsIIq3WZvMlAc+SGQJ5j7xqdl04cg4U3jN3JjRvK/bAUl3GtmO3T+7BP5Pavbq7oTfM8vP6LO1wHA2xuHqqtSN4M/nKGJV0I4kUUQ8bGPKDaMaTXolqDvpmWyI0A== 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=dNWNcfgpA7JCqLjYmNDINxC+E0rHsIjBnjTd8lQqicA=; b=AqAwLkDZ6xUDfr6sATYJLOAtVXtiImB459dPD1L9qZut/6KsYtK4EE+jgujIe29Ckm2b+0HuA3aGHvyBKDuiPEnpj8u9b4EleNUsB0lgknZR0LVZ2T0F3kly9bPxq+uFHIjY3GWp5/yIztAqXKcSiEcGhKniQhVCmS9tNJVOQDY= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:29:44 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:29:44 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 01/16] include: sbi: Remove redundant includes from sbi_platform.h Date: Fri, 25 Sep 2020 16:58:59 +0530 Message-Id: <20200925112914.725846-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:41 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: a4f6ba54-9620-4e10-8bdb-08d861464cbf X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tr1ap7jQB04561ncJLLVJX2TfE9VDukb/tNUx1uiRJRVIa07BdOL3otkzrE/FVsp8j3GJVUODvxvZzaoEq7p88tGhVm0Kjca3WEgQhGfbh5gCCro1nt/GaZF4xIG/jZtqAt1bnYOKLQZSaMBPeeJlbHD0rDf106wje8kmutVU8b1QXfIWwDtU5kbrxYxlmUjZjQK7GtamHPDvkeCn8WWg/dC4eRNAPi/gGxPrlz2JR3ixZ+rgSRnGGR2sR1u848MxMjhcyL0aV5XhxS1Zp8KBLWuLFHpem2xqGvmusEH5iWn/kNHdUV9Vlw2iP71lXoupI3/pnpUPbUDbUlf3UnRAxpdHLWezdJ/6qSm7O8nwWebHQwMHUHsFlAGu6EoKaVW 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: x6XDaId161MOv7Y3YqSrHoVdJ458FBA5day9kG+X4N7dx7mZa8TYsnTUjkkMOmGQR5gi4oPxp2KhcMv2LENaAOZNjwat9AfFY2lGuoAOY0EN3jgQv5qSDR1ESb5EReOV4172f5azClOwU2lTxp82Jg2K17tZDHuUkUuTMywkbsTj/dEK7gDCq4sRxrLUvTSXnWtUlYNuobrbtIU90UD03xP3nh5zwNIoW7c5H5tsmkhF9HE/HDMz8Uv2EpLCfGzEGcUFhLImcBLVEoskq0oDBYJFEXEmhmb8w8dkORT9XgChdbvUL3Tt3mCg8HAyNyhhjkR69kGPepfmRgv8rRHqnO0f8wFa1YKvrNpDj8FpkKi6Dam+HDWcimep0lwdr1oN6d8Qy5ZYi7jNKgcj9id8xN7cvXBOi/4KCSRWE++QENj8G/eEdUudNy+0aPJX6y2+XJw615+eYl8yK1ZmetNLjDUQKkEATD6EvOhobWUCLBDt/XF5+8jo/2tj4IoQXaeZjDT3mk2rRU2VPjvFEBgzsqwie3hKWT/r2rcWmwyFheOTQPqNQbB/ZJBSHB3ZQ2bKXOvgqHTAi4iXxvDrnPHNd6Un6ujPcPqd7TON0mAWtgLJgDKIEBV/wP1uavvPTgafONR87o/J0Du4Y4DqnxZhLA== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4f6ba54-9620-4e10-8bdb-08d861464cbf X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:29:44.0918 (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: I7fr09T/IPdK8HSd29UhdhndkJYOyxgasSm20IFhB771EcuMnTtrsrVvItCp3k7MLGKjdzlFQ5Ekx0zD7U9SNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_072946_549765_ED8EC723 X-CRM114-Status: GOOD ( 13.60 ) 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.154.42 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The sbi_ecall.h and sbi_trap.h are not required to be included in sbi_platform.h hence we remove it. This way sources requiring these headers will have to explicitly include it thereby reducing implicit includes. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_platform.h | 4 ++-- lib/sbi/sbi_hart.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 8087148..f51e36a 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -40,12 +40,12 @@ #ifndef __ASSEMBLY__ -#include #include #include -#include #include +struct sbi_trap_info; + /** Possible feature flags of a platform */ enum sbi_platform_features { /** Platform has timer value */ diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 6413194..55a04da 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -19,6 +19,7 @@ #include #include #include +#include extern void __sbi_expected_trap(void); extern void __sbi_expected_trap_hext(void); From patchwork Fri Sep 25 11:29:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371184 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=a+E3Usrc; 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=NOiAMg+z; 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=qSBIiFvo; 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 4ByV7m6qxwz9sSJ for ; Fri, 25 Sep 2020 21:29:56 +1000 (AEST) 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=GSaX+HlIQF+QNSzlCnFwdjnKSSKvzsLqhOfj2RqBNTY=; b=a+E3Usrc0y2h6foPHpYLKEWO6 51cPqDtRnJrfLQRK+9FG92hbVCEMZNkPoMocnhx2lLT3NM1SM9cQ/IeO97A+7Ti5TXJxouc5cFKuQ HzQSUUkRdrSIsrQ9v3KZozIyhNsLbd5wUkaUCl5nAEyMWQSeNHex4f+1FA/N1S244Przd2yHS4d4k CjUXg2J5Mq7Bmu2mmJJRXGNX+/LRHO/Lxjd0RnV9EexUr3HCn7dY/h2uqFJtr4v0BC9WXdkBVt6tK 8CyxespnVCBIvqL0OL0yJwAQKEu9OzAzmbCgbz3hK8fiKiTs2JITMJd+k1d9XmFUJ5BonoS6iTSIY /8gybx7FQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvD-00049Q-8D; Fri, 25 Sep 2020 11:29:51 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlv9-00046H-Rg for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:29:48 +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=1601033387; x=1632569387; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=dd4YRZajknSvMeYUCOMDUCKNu1WYxppMYm9wJgrljfs=; b=NOiAMg+z7mu3CZzRQ72P6qLTpy6ziItABTltMP4aNoR1UrDcPAgBBJga /j7IHrEVwlYgv944g8J7H7hlPnJ0/J7IQAsOKMZfDJVmMSuABdKbSWq5s YKS+e6EbN7S5nLUbAy5xOT/k/wVG/b31Xf/gqFDzB40T24NrtJG70csK0 nd2pCJwMyrHk0y3nmyjdI5r8OKz7ILDLT2D54H4saIyQpawBFsxVt7+0V HCAIIu0HDDgyMr57uc/4oUdMr2HwazDZGcKM/cm+j3W+oG4RZsU9pQUcY PEiFc4UTvRnz9aTeIdWhZf3tc89gPNIws2O2Q4M6AXwDgpn5qp8ZQc+6D g==; IronPort-SDR: pkOe85WiFPpDh6is82950GJqWtr9CGKJD4cVO8WqWB5zJapFf9vXqGJWgGp+9tXXrHwxXTkl8v BhKWaPWHFokNCMGFWCzeAzD/XJ1TUdvLNTfRwkhd/7gYzlzwu9Uv0YDKzpSzbo22tXRECN6XT/ UK5VFDunN9Jqtf2ngpNtx/thiWvNFh+UIz47qxybz+cfn+IZR5j/ogQuYT9hmHgDweBk6GeOeO rzqSLPxRAED+7CvLxlZ/YOx7b6KNcXn+qIBSVZX18XrRU4lD+202xHdpDgGSXPaz0T27u0+yXg AAc= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="148192080" Received: from mail-co1nam04lp2055.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.55]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:29:47 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xut2XRhbgGHUTmQycta03UM7hG07iTxH/z/PUfTVCknJlvMZp+PP2w/tqP58n2CZiaQajcJGGqt3uQGMZjDT0WDbLIYjrsqttg6W17KkkYU0wS9KMzcNIpqpPu2bC5cna7o2mjI90YBsrTBOZLhgyvqMyrs+u4sJQiFtNMGqjGRE2+4i1SW+CApZP+5eHs9l6FdnTuAk74/7PHf4ryR3ww3M+lD9pn+DuavqoCuovk/ayBOdx4icySVYwSDsbpMXqHIJXkLIzP5SCALbN7fzGfxnZ+2if5CPVMc9HmUGgyGWOjC79uubAQjnyTE/2VYO6kH0hrdN0XFesUnHtDhT2A== 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=FMwCk0DvpyZkJZeGDN1nGtxaOKTxS30NCITJTrf4a/U=; b=B8sH1utbZ6998IwmFy9qNTW+LCqhj7EJHB/ZsWM5+aUFd+BWNpi00ZuMUuT7aOe+8xi+ghKLwCz/q09q9TrLXm8zUFxOZYV5DG8l+kYLCUJosZGnUrLkviPyPLONZkx5QHIL5oQP8G86HjAgQOfo1zVDkfWmvgXrd4y67cxd0FhO03YOm8HX/nEIxwmlh51meVeYbAh5l44fj+v7nzLykG1P+hEuK3tUcYirTmDL2tu9QDx0vRvMoMPocyl8fOUaCS3gEeNNl0E10JpnLCzjKbJgm4r5w+y6nU6PP6fSDXBlJonmf39i/eIkIzYXSZY9oU6igSalPEhzxqR4Spm+6w== 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=FMwCk0DvpyZkJZeGDN1nGtxaOKTxS30NCITJTrf4a/U=; b=qSBIiFvogtHR0z77sYDxEesNbpkfuhODbR9+rc0PinWIaXPAAJ72DYKmEAdWJHfuHQWfW402lljTZihXu9ySUjBRYh3Q667zzWA9eKh9mllo0HoYPcVQ3WcmRyvVmXHOrBQgb93CigzPVNW5CwNfK+DPC4Qc1M/6U/k5tz709j0= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:29:46 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:29:46 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 02/16] include: sbi: Remove pmp_region callbacks from sbi_platform_operations Date: Fri, 25 Sep 2020 16:59:00 +0530 Message-Id: <20200925112914.725846-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:44 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 542a1108-1840-41b5-0ca6-08d861464e5a X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UZTcDYG8xHe97QoanlUcfQNu+QXtkWAIsY5RPZw2Za3SCV2FbF9upOkTiOgXhoEXq1GsZ62mDAhS+mzJ2bI/0QAaGZ8+rPcptt2GQzLnMVQPcmmkEPO0VJQYIfgPmHsc3uoWHxNr54OJiNzG/JV0P42NNQZH1UvQItkhZEaoHmS0cZLpsZFQiQJjdaP8fzrE34Sks4iVvEyTnk5Tl++eHiheXK/8BKSJ+e49dQbrBgk6dUl5ke7Y5pcxEmMvZyZCiMpdqB3w/WhTW8w4lu054jHSZTJtuvkMw0CarCUMR4NmpuuavQBfALZhO1iHRFO13ehp3O5sXa+Hk5bG5qbBClS8ck8IQNeyE9m/zprdP0TShwuXbC6arFotHi5Y5TSW 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: S/meBjbaZE9ul1pb6fQ3eDhAtkslwkhcZZFGguA6kqJ9VHBxBEjuoKr3XPLHkSZbfK0vFwI3VMnH54LWyVRn9/fMhwWay6eJ0t1Dylts5Cp43ofMCbUa1dNKHMORt5/1GPW7cSY+KQ/DH1GYJXRYK/3110C2mMABxhH1QCM75BrAvxEtyF1qUeaMKuCIdDkGdrHkb4PLWmKQ9z2GPJSP8slejDEc2JyozXT9gqKk6ng6p7XzJ/g2GPqisDSgB1qYijgE/D5blZnSjNL1RW5g+DRSzLEJOqzrxCt9/49O3ZIdqf3Fw0fo93P+JtCui+P/U/3EE44MTCjHi+0M0B/cIJTc9zoABWXQGCTD3j3OhWprQwV2WdVVXqOvR+ThVFsxxq8w9Mwmzrk+tgbpMcoSXA+Ey/gCHYhJWa3xKn+b+KtA37HSu274gIVL6/JkCyL5+abim4g9566NnJWqZaxEY7JcCa3grb0bNqGIzqxnoegzsiOe23OyBzt2gDJSURQmBn7qbUnXb1gF/ocv9cgwJRc+xkhaptDKo2Virqc9zLfZpRWnrrvAE+E/9QslS3WX+Syb9eUQRbnZt1t7uLFNon0OQqh2ugh77JHEbzjuGLE8+2W/cfegKX2Y8+GZUqpY7/aemeUJ7AxzHcJR88q6hQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 542a1108-1840-41b5-0ca6-08d861464e5a X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:29:46.5173 (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: Yb8aNH07AcRkJWkh5zJ9bIo+X/7kkppxX9PP2p+P3t9k5qAkan92WqGzrtv+MyUMIFXkzd8vtoyz59cThjUfxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_072948_099370_E156F53E X-CRM114-Status: GOOD ( 17.83 ) 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.154.42 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The pmp_region_xyz() callbacks are not required in sbi_platform_operations because we will be using OpenSBI domain memory regions to program the PMP CSRs. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_platform.h | 50 -------------------------------------- lib/sbi/sbi_hart.c | 14 +---------- 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index f51e36a..f2c3237 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -89,15 +89,6 @@ struct sbi_platform_operations { */ int (*misa_get_xlen)(void); - /** Get number of PMP regions for given HART */ - u32 (*pmp_region_count)(u32 hartid); - /** - * Get PMP regions details (namely: protection, base address, - * and size) for given HART - */ - int (*pmp_region_info)(u32 hartid, u32 index, ulong *prot, ulong *addr, - ulong *log2size); - /** Write a character to the platform console output */ void (*console_putc)(char ch); /** Read a character from the platform console input */ @@ -456,47 +447,6 @@ static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat) return -1; } -/** - * Get the number of PMP regions of a HART - * - * @param plat pointer to struct sbi_platform - * @param hartid HART ID - * - * @return number of PMP regions - */ -static inline u32 sbi_platform_pmp_region_count(const struct sbi_platform *plat, - u32 hartid) -{ - if (plat && sbi_platform_ops(plat)->pmp_region_count) - return sbi_platform_ops(plat)->pmp_region_count(hartid); - return 0; -} - -/** - * Get PMP regions details (namely: protection, base address, - * and size) of a HART - * - * @param plat pointer to struct sbi_platform - * @param hartid HART ID - * @param index index of PMP region for which we want details - * @param prot output pointer for PMP region protection - * @param addr output pointer for PMP region base address - * @param log2size output pointer for log-of-2 PMP region size - * - * @return 0 on success and negative error code on failure - */ -static inline int sbi_platform_pmp_region_info(const struct sbi_platform *plat, - u32 hartid, u32 index, - ulong *prot, ulong *addr, - ulong *log2size) -{ - if (plat && sbi_platform_ops(plat)->pmp_region_info) - return sbi_platform_ops(plat)->pmp_region_info(hartid, index, - prot, addr, - log2size); - return 0; -} - /** * Write a character to the platform console output * diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 55a04da..edf79b7 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -226,10 +226,8 @@ int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, static int pmp_init(struct sbi_scratch *scratch, u32 hartid) { - u32 i, pmp_idx = 0, pmp_count, count; + u32 pmp_idx = 0; unsigned long fw_start, fw_size_log2; - ulong prot, addr, log2size; - const struct sbi_platform *plat = sbi_platform_ptr(scratch); if (!sbi_hart_pmp_count(scratch)) return 0; @@ -239,16 +237,6 @@ static int pmp_init(struct sbi_scratch *scratch, u32 hartid) fw_start = scratch->fw_start & ~((1UL << fw_size_log2) - 1UL); pmp_set(pmp_idx++, 0, fw_start, fw_size_log2); - /* Platform specific PMP regions */ - count = sbi_platform_pmp_region_count(plat, hartid); - pmp_count = sbi_hart_pmp_count(scratch); - for (i = 0; i < count && pmp_idx < (pmp_count - 1); i++) { - if (sbi_platform_pmp_region_info(plat, hartid, i, &prot, &addr, - &log2size)) - continue; - pmp_set(pmp_idx++, prot, addr, log2size); - } - /* * Default PMP region for allowing S-mode and U-mode access to * memory not covered by: From patchwork Fri Sep 25 11:29:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371185 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=pyDy5X2g; 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=AIFAnJTg; 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=HUSjTf2y; 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 4ByV7s6vpKz9sSf for ; Fri, 25 Sep 2020 21:30:01 +1000 (AEST) 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=3MDDMcNiLJ9sx/48WqxQn1R4T7YKF97V+eDmLBVEDE8=; b=pyDy5X2gfJsQXy6BHsQL3yKn/ dTSjoqMhjXs1MQ/M1RByr1012X4DVkWD3wMUsTZRO9ZmtOoVXaRAGQCY4mRwFiD/AvQyFMvsG/xLx 8hVxFTTLLcig2Ta4EQUPzOwiK4WHHi+BRoHWrdzSImo1DTogKRKL0MhAittjpax32SRoU9oiuG5eX S1INtV74IKUgDQt6lfecm+1+vsoDSJCKFrClp5G8qn6ACbwrZq9/6RF4rBlZtr/DufPTrsjINW2AY MUHR2d5EHOGcjZ3bYaCpj53h9eQGdUi2JETnSlei2zzNcKnj0FxdxwiO2TmbFYLsUd0Jvu4NfT9PW fF1ZSm1/w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvH-0004Bm-PA; Fri, 25 Sep 2020 11:29:55 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvC-00046H-Mc for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:29:52 +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=1601033390; x=1632569390; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=TiPexT3Rcxe8zrmQxGTMlsgoFz4iQoCxgjN40/I9Wwo=; b=AIFAnJTgMpnHeCG9M1Qi8xLH5HANj+IIMmmx4MiJOZE+nGI+1GTigIHm qUGB6Nf5e7lUBnGWw4DjIOquPsBTjpjJXA8UVFck1o/Avg45Y2358UGmr h4WFbJ9C4fy6xQbEKoNpyZP36d3UBrNpt/W5Fu8QIuBxx0clC1g8Rf8GW JwYcg/7hbAd0wgjtBVr7+WWcCrn5Z4j3SB3ACGB8mKuoEtFOF3IC1B3UW TGLdbso/c+9P3tEvK2Xi8Ri7vdr7vm62Uxm5FvQTObGbC8j19RbtkkSdP +Ge/8/M1/5fYoU9GZMYjim5OV+AAtlGSpXLNBO6Xti1tDGD/fUKHqtLHC g==; IronPort-SDR: hhCgabmn0m7/5DR+HJ7+g9dJ+cL//IQ4zJHsAqhsypFXiHgrrvPw5TFKn4piXkmdNZtC99ggb9 M+QQButUZ1ZvFmOXjkMJpZhIq5OPrGdx2X9VOWBbFtrh/GHUOMH93qaM/7c3mnXStyBz3foxyx 8iNEWAsgDNs9vnqqDpxrCb0ldEvL1E4bnl8g1sf5gHdkB434SQVG4XTAJX1X7TxWcHSqiHV5cS aBS4BBykO7Ru0CMHSnGTYBlEUtbC9eFqM0iMFO2dwmidkxGjTSnZFkDCjE2JiOHkrPvlGGj0JU yyE= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="148192085" Received: from mail-co1nam04lp2057.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.57]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:29:50 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FmMAOsFJfkrmnU/RYrCnpYBqk23nS3gM/YrenZLIFoODhVJlaP1C5mp//PKHfdeo3zk7p+hDaCSZpB9gXSiLPYNBxD9kxsLN2qhvHH/TdKnf21zCYpcPPbl3mTkW+vlIF+X2+QKj4k9QKLedPSD17pmIgJJwYH6yXGorw1/noy9bDLiX1684OTmfC58GPie4RqoEt4yTWibRTL0dCijmzSuDSaQerq0cfhN1HGgCfjy+ZDGKWASm0G/zjCxbfZHdozFoh/SnCNIZMmRnxkPw6vG1cO7uQIpex/dHPgvQWOQOiZIEl/1dx/aTcbrb0DwK28Hb9byoAzxAtQTtxcS9Bw== 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=9SRY70LmwQAZgR/m/XK2UOOdR/SyYR5o3S+cawZFGCA=; b=A9OEfj0q2+SlxpvLHiT8LpDp0UJ3olRhH/krFZg7m/Ow1uTSYjFijXBj3h7e1A3H3J09fXALKPeJkPiQOFZPHf4pqv8xNt1OxwrxkYTcWUrVf6ei3tqgvrobHYFFwZh2vngL7K0UHhviD6yLNZweJ3Sc3rhWetyBzA3BmyPn57Jbvje+bs8qvQXsGUxhaU2AbTMyxbzeeR50E4UEPtNeQIW/90+ZHFBCffCt9mwIxd3/rp6mIJV3C3vidWHxfhD3Nm76YAJix4QI5JaEeiLSuaVqptuZqYg96lC7Ba8XwKZLE0R1E9jvcfdHOxzDj0+kJphnXt9AAoEDQzrPZVomuA== 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=9SRY70LmwQAZgR/m/XK2UOOdR/SyYR5o3S+cawZFGCA=; b=HUSjTf2y8vS30Jd70thwpsYyIwLRcWxWt4hMWHo+JAzbUHwhQOC6kXS5xyAAdXZvqZ08TkJtOxMAo93j+wp4v7i4QzBesVT1oz3x3PqzHqTyemiwkS4aGrzuMRWfrihoONM5+nw6M7rRFkiyIFMgOxjCr532cOoMF8vY8xY7oO8= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:29:49 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:29:49 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 03/16] lib: sbi: Configure PMP late in coldboot and warmboot path Date: Fri, 25 Sep 2020 16:59:01 +0530 Message-Id: <20200925112914.725846-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:46 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1a721b15-56cb-4255-e7ba-08d861464fcc X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: 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: Hv3uGA57xh01K/YIajwGQOT+rdLFz2k77R0FCX5yDNFiaqeWEFJNLWQYEMvOr8ipWnoU2mlgzP8gLKsGmny2+dHJ+TSdspLxDrCisaRoC5xrJS4F8bl+a+lOAhCdmR4YkSKCmhvMjWp3AAMCkgrPAmvhAgcGDFwNsy2o8LMjiJS2e4pkxrmUlitnu6eZumSLdt7ydBZ/mzY/9AcNmLRZ9GGoa/cAEoaXLmAndEOCl82syfHVy9MwRqHq9+P80e09FWqz9rwCfUOMEqWZ74yPaaXJXGXB8TvGhDo1WZXTXA/jDyGmYC6vlCQXGX3NsGrBB1aMkhSeRbdW6NxL1GtqApF1ngz1oOzDcYHHCk+lc85LXwxvXrbLddHfZbGTml5g 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 66RC7AdSxbTo3OukdSXb/124tjNlwSFf22Icv9Rsn1k801n+iHnr8B7GA7tmU//G59IjhF4bq+nP3Ue8KtRytwJ93eGAxAWFXfhha1Bjg7F5NLa7T4/B+tcGG1QGbGmVKXKAC0pPuq0MguIApEwyEnsvWwmqvv1fwu4z8IOVFCYb0qypvfon7D8SQhjBFnsEtuWetVKqK6bKBj2y+ZD2VbKEOeFDngKKNqoIT/MqnDTiu7yO1rD9E2llGug89yyh5/SZ/S7Alg1/R/M+0MXNqWFYw+KsTa9HBFYWavm4GwcT+Xi+L8WX1EUAfAmkdzEWl282bGqEicGzN+j72CmjO70EtQKsfk+tO2edMuv5SQZ/igy1cSY5TNNaBAKzKMsjvenUwEHjv0P15COMJvX+cJ5mqX06OXslGgylSICavfHVcRGDkIEdacWAWo/+Ny3ELbYVr+yzBWGFxEBZCsYjoeE1Qslbaukwyt9pztxGS4ZAjDUOopMPitMg4Dy8fju0tMQVwMftLDVdURDUcYB5iPc+rYkPKABQLMn591kE/PB5Y26nvvpeiCKvWEwaOIfx1sXcfPlkzP8iSlH0ATnVXaKdtHpH2rVYHm1Zi91gfjJb36p/j/sbyEgh/lhoSAWsQoZQstx2hMck/Lx/BEw5cQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a721b15-56cb-4255-e7ba-08d861464fcc X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:29:48.9487 (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: 0q1eq/42/gdUsZT24mZ1urfTJHzsb18Zf2+y9yWd93IrcDqm1wH3tyQePvXRNnt8SEHkguOFanyoCew+bREDkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_072950_922063_B52C3F0A X-CRM114-Status: GOOD ( 15.47 ) 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.154.42 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 --- 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(); From patchwork Fri Sep 25 11:29:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371186 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=uVk7J1cz; 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=bqGaFLIu; 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=E9N106wZ; 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 4ByV7w704Dz9sSf for ; Fri, 25 Sep 2020 21:30:04 +1000 (AEST) 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=iV8Drwi/ztBSY8E/+ucEBT68fK1a5hYbdYq+M7BkASU=; b=uVk7J1czLeOXdRKKsCStpFLk9 W+qrCiclPQdni+DUaeNzCuFfufBRwM7Qlmj2ClTTjIEyJNCyd9LlDdcHtaJjJEmHoTwzb8sSx8ZEm fctjyZSTTnUB/tovY5MsEjY+R1skvBPG3Uop8fhY0qYZpYSkTIRNYXWLGCU21sa/8Cxlp1E9Uvpeo ZU+ZzMRfPplTCXMibOt9KCFiKvuHcVeJB0r8Okj95q0TgkpUb12sSJI3M0n2iOaTdYR4g3yJwS4Hd hk6Ras3IZJH5Mv++mCElInJHXfWuCY3QIJoHzGvAL3hE8Avyj0qriKgYnShfc4wPQIQlKqo0ULBWy wMrGhXVnA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvJ-0004Cq-W8; Fri, 25 Sep 2020 11:29:58 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvE-00046H-Oc for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:29:55 +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=1601033392; x=1632569392; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=9gL85DLUJAO4aeyPKupvV++nCR6k5/EeIx4NwFreYoo=; b=bqGaFLIuGhpdCJpVNyJ6Ti+sXGztavGy0oZFbsJDXkgPHDDpBMZaCfJq JNVxGov0dPteOBg2shgWPPvpOujuZAzD9c4eth3974EO/+GK4Ac2pk+dn foHXt/jx5Q/Bp5vrCF7XrpbHGuRCm9Ii0yMeMaCUc5cAYjBxh2b6VvvrV G/71HEh1rj8uBpIglK3kq6If/jIVm9/A1uiQLkU0hx7CLChYUFr7pU5UE ES50R5MioQhX+jzno67g2mHkPoNG4JpC/qmXXbaK0amdcRV7Fu1c4r6ww Lj4pvtXJht0iCo8Fk+JDlMwCBbbi/r02MLvyEz6JW+GYoMAroR4Q77qBy g==; IronPort-SDR: SCPtzPcXUIAYe8ziiEJm7T4pGyiJClN27yzLxoDXpR7kEWXiailzK3EJcBMyUg3L6zoyiyziGT qNTeGlpIXKgocajPZqi1IXH+dConEqc5HjEBfBl5ihUs52DAz3znbRfvIXfOL0adSaOC9o0ZAb 2Hr+hC1l5NMXP1ICQ/HTmIDV0yrT6FpmZ/usRZN+ZPc629aeiMSjyWSOBSuovU9GULhDMNY4rh vy19xzZ0PRGNZNj1MMqERXwVe3+t9GOx5RrH8hsCgIhxLIoVLwAxEyhQuyM0JGdR5WxcwurPd5 zVM= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="148192089" Received: from mail-co1nam04lp2051.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.51]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:29:52 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SVS1IhqrToXS6t08iT69nGEGbA+rHQ6oJqGquoUZV3XrTfULZYjNL1Yvwf0EohoBNKUAaUjzD2AhdHdPYPwHJhiz3P5rNL91uTqs3nLmKGVYC7lbrB+73Sk/5Oq+Df9l7ppUnlwlYcn5/Mzkkneh02/0nJ4BpvjrbWQxfW0lrAcKdw3f6Ny9k/2peNBnxfmZ8epYsADjAOjtl27YBXYBKgfB6rT0eOc15NTwvQ1QcEXf5x0rDdfulb7VkVWHCoUK2nQ2uZpfX9jAG7NMD67WGO96wMph09/S6N36efW2Lof7tD9h4KmYBlM2es5mphpLUPArWKNBDN+LZ2qx0jI4hA== 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=amb9bbexjCb+mwYdNsw/7GcnU+rUPxyOB1+B+Y7UXPc=; b=jjDezf21Vc1VxxFb0Lx241AEfkHtsZeW5v9/SCAGc8FV0FG9PYHjH8MhS8wnWrXcPj3WRaPkZ0PhE8cwNHWTTbDBsR4f/ZV9sNu0Pi1MrZTggeEMHD6GfL/mZFOrACWvnPiVMBvcACLsGv2mvQcYBE7o2es+04q4DAIYSCySm9sK9Ez57Evlopv/pwAW3Q2OvWnSeBbzwB9m8A4SkVYC7CPsELoErB4t95wvg2ihBkqkgLRh3ARVY45BPp99EIgw8qWnUxia0oPtFtHEU08wJQ8F261flkvw4tAuMQsik0KP95V1YvyXb+wbKKCpgWAANiF+PaNU8mtjUWRaqICO3w== 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=amb9bbexjCb+mwYdNsw/7GcnU+rUPxyOB1+B+Y7UXPc=; b=E9N106wZbl0/+qwKVo1Q7EMyrZhm5uOHqEWIhR1r2yZr3mkhDjLmBhF4REz/Pr6uuzpl7HsAfw7OMFCqqlBrmRtPUXru830ZdxyapnQHYkfaxXlv+9Wg5YFtn/rAHLzvrU/spHk+yOktAMmIW47IG7eq+6cJVPQcNACgMv6GNJY= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:29:51 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:29:51 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 04/16] lib: sbi: Remove redundant hartid parameter from sbi_hart_init() Date: Fri, 25 Sep 2020 16:59:02 +0530 Message-Id: <20200925112914.725846-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:49 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 054a1c61-8119-4939-8a7e-08d86146513e X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: shA9FuZXlpWJYEzy2ZwhnvLBOozapYOaidQp4yhhLbwjlNJlNE1yF/Zm0cJg6ih8/H26a9Qqo6udiGNFMyEs19jDMQZcBW0cLKlDOSx82IomObbUL8V0n5XBRkx6eNywJ6eLOa+WMau3Tgf9nf5zaT7Ie6CGO5XwziszDh3pIWh4hUsj0C0OXOOx4bRUKMTcomxcXXeOdoWgPrp1PS74Hf+qFUruFpCmLE4oxkjf+fQvsyYr0nZX/Zp27ARfu5iDbvAUeSFye2z3AAsnH1RcOW3cTJmOXvpjBcjEXznnnQjga7rCsszSc6pOgFTiIyYxgmNjA2vUDZEEsiLaWwdTeg2MabMFdOD6uIP9Bgi2Z/Gxtan1LTN7sllehxq3VAh+ 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 0H/fOELeg1y9bOFmsDcReK8wXSfyXLCQA3eQViS3Y/Cgri5UaidBV3qylE7wm9WunQIIVxtNHbpHsVEZfafln/bSDT4qjCsTxl3rWwVWPq4D5u2M+/B20HVWPhsRI7JWmNxGqKd9tXkFWWsb+Lk05aZT9mNXKO5vuHPcIASKrZ9jCHwLwOccsLk7+vOCFNam+ssJCY6mcDpppsIRTYjU4z4Tlv4d3bM07keqb5Mzy4MBTbiM4p5dhwpt7eyRxKJ0FyvrRR40FlG3yiJMHV3eBN+t0IWt9BkBRok9pQpI9qH1v4jiiVrst2Wnkm8/MB5rYmnJPHbauoT4uwpr4byaBhu8odMLGyGy+A1ca6npiewRFg59K5wMJ3sZKxdpV9XFllLZ0IjCNHPmL+c6/T0WjQYJnyXOA5vfyXTG+SohQdT58Td7y1M1Z4cEl3t8p3QJ0wiiSOk1Jhq1p1vJLncWZJw9VdH82daeJnZ0wR1DMA8R8FtXthqkwbtWyufycqPJQMyxDxrQ5QiZn8+D1cWJMGjSIsRyiFO94ivgnotprjZeRdNpFi1TKqBy3KEHzjHLMk7TbPSnsbezfgrmT3+hxol9Iv7u9uuM71vYouhT9c7Q5WMtK8xzwszb3v8MZyDZjWc9m4uGtWtCWQRjbt4Zgw== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 054a1c61-8119-4939-8a7e-08d86146513e X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:29:51.3741 (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: qka0mNhpdTUK/0YxZ8mKHhzzodg+7Ic993BP4at/pT8/dsK0MzIoqCzWdlaniXw2lmEMTNwUAJaX3HzgOqXa9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_072952_966520_3C00C9A5 X-CRM114-Status: GOOD ( 14.72 ) 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.154.42 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The hartid parameter of sbi_hart_init() is not used anywhere in sbi_hart_init() implementation so let's remove it. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_hart.h | 2 +- lib/sbi/sbi_hart.c | 14 +++++++------- lib/sbi/sbi_init.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 9207f4c..2efe44d 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -27,7 +27,7 @@ enum sbi_hart_features { struct sbi_scratch; -int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot); +int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot); extern void (*sbi_hart_expected_trap)(void); static inline ulong sbi_hart_expected_trap_addr(void) diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 7244f1c..88ffab0 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -33,7 +33,7 @@ struct hart_features { }; static unsigned long hart_features_offset; -static void mstatus_init(struct sbi_scratch *scratch, u32 hartid) +static void mstatus_init(struct sbi_scratch *scratch) { unsigned long mstatus_val = 0; @@ -62,7 +62,7 @@ static void mstatus_init(struct sbi_scratch *scratch, u32 hartid) csr_write(CSR_SATP, 0); } -static int fp_init(u32 hartid) +static int fp_init(struct sbi_scratch *scratch) { #ifdef __riscv_flen int i; @@ -83,7 +83,7 @@ static int fp_init(u32 hartid) return 0; } -static int delegate_traps(struct sbi_scratch *scratch, u32 hartid) +static int delegate_traps(struct sbi_scratch *scratch) { const struct sbi_platform *plat = sbi_platform_ptr(scratch); unsigned long interrupts, exceptions; @@ -435,7 +435,7 @@ __mhpm_skip: hfeatures->features |= SBI_HART_HAS_TIME; } -int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) +int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot) { int rc; @@ -452,13 +452,13 @@ int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) hart_detect_features(scratch); - mstatus_init(scratch, hartid); + mstatus_init(scratch); - rc = fp_init(hartid); + rc = fp_init(scratch); if (rc) return rc; - rc = delegate_traps(scratch, hartid); + rc = delegate_traps(scratch); if (rc) return rc; diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 85a5f13..5cedb15 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -182,7 +182,7 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); - rc = sbi_hart_init(scratch, hartid, TRUE); + rc = sbi_hart_init(scratch, TRUE); if (rc) sbi_hart_hang(); @@ -250,7 +250,7 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); - rc = sbi_hart_init(scratch, hartid, FALSE); + rc = sbi_hart_init(scratch, FALSE); if (rc) sbi_hart_hang(); From patchwork Fri Sep 25 11:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371187 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=wOaW6ZXo; 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=Nz7MLtSf; 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=gDp/iPl0; 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 4ByV8073gPz9sSn for ; Fri, 25 Sep 2020 21:30:08 +1000 (AEST) 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=9gCFhVXXM/1SmYfUA8LrMp3JUyNyHfhabu75Vlj+XAs=; b=wOaW6ZXooW+vsQ0m3KZCEmKWH nYTZunEbr37fvOayqELLNTS28eJIscofpUdQbwPlfCAH4DdEqxbx0wx3hLzF105TrnnTVlaxEuJGD bNatMFDqIHQHjFaoRhybQsQQ7qaAoJe4tcTwY3htzFRbmON6tZ6qI2fQpC4gsqlUXbbI/+nib302i phK4noURcbDcMZVOtskqIIt7Qzg5dJFwTqlUayT9WX8jHMIiczIGMuXo74X3bOOtO2v4AzmRnvI/M 6E6firHRLIULQy56bZiZPkG7DDXxEFZyVCDGzuCoMHm5S/6Z3d8LmV+Giuwc5T5D5dUylXXgrGjcl RtTUgpJBw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvO-0004Er-4A; Fri, 25 Sep 2020 11:30:02 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvH-00049q-MY for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:29:57 +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=1601033395; x=1632569395; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3CnLDsUXZJFTcw6wRMhYUUETa5tvhEl3FyZbIpEZQPs=; b=Nz7MLtSfzW0zTmi19Gq5HkMx4MuTsc3rhquRHsGHMjmSHBpHlMfPfePT Aylq/x8sWuTzaMZaxECYtefwC330wqgWQsfGlVoRpoF/84emQEZo8YBZj CWyhjG87JS5mPSlunmKSb70jX4eFpNjASH9YKE/BslCktk43vKAhy8fNp Si5FW6kPkisqzYvtwoF+kYktplEVwIst/ohSZbN7kQfUJ+kNojenkqN8g vB8q4pT0hc31270Fz5dpTC4Aiu0pLdG/YXBdbaEbcnO3AERUvdvPW6QfP sHDSW1E8GBHhBCa4mn3l94PpVckP+SSiLan1n98NtkD9brCfQ4u0sMT/q A==; IronPort-SDR: iaNDLPmcLK5pWpZ8OzbR3pUPqCEmp8OO+vM614hU9w0/3vWZlbVvM2ZJvX7ofvgPR9Mc1P4Q+l su2y9tx+doLrFtq0mEkT0+MaNCEf6eboQiapS+5e4MyInOXSr0+8EEoEj7XlKQ71Yd4tRZtw0A ZQxRCWU1RduIx8tQrrkylUjTD5ZxIoAP/JmktrKi1a/Q6wSjefPDnmb+pE1XpsMG/aqybOqRZX zfKLvg7CuMnHw/LwGRqhv2DlL8630zw8/q51asMCMH85BR0+N/nJ41QHp7E8RB9bph7Gilf/Tg ml0= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="148192093" Received: from mail-co1nam04lp2058.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.58]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:29:55 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fo7sr6rHsruzBtW3Ov+w0VQoQrrZWxvkXXY0kafpLHjaj8zz1ymE26SRMb21YFswYHuc+DhDqZhGSp1PSacgyJnV1g+ab8OQKixnykDB5RnNKgb0jbF4BFVGiAuJmdVspBw1Bhh3qs01D8FNzJBWNaN+SXPTynm6zRFwgc2Ks8EEopw0j+jU/+KsX1xYw2k24zEuYCIq88P0HB3By82P9s9qZM2DVC56QFCIvqB1cappnnDM7b2JBMu1YGKvLi5GYQwiX5vOWftZl8vLA+Qqcf3E0Xkj2SprkuqMZoyr7gFmth7FQsXSlj42LVvEvkw4fe1eafZ7RmXJfPK37gBkeg== 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=L1/SV2bLUTLZSQ1ijAk/tWOFyGtsgz3S+uTSjU++hrU=; b=eHcmQyjRpv8jnx2pqf0FlAJZGiWHNcpbttGcV/rjEdYl2GKpwmA7FGZ+LHPFhJAXZvG+29apRqkV4HS1OYfldIx25+cuT1EBrrCjQQ8BP7chwqCpG/ixz+LmaCeN0N5dgsLfPDgESB1zGa3mrzm93uRSQn9gaSs1tXKivyadRsRLA+ZuHpVesc+rpUcu0kve3DXvWHZpDeHVB+5tgRAFatwotDk6EOkjybdWSZWwhDSzqo5946p3pe3Ayr8ca5lDLNAND2Uwcns1DDRb6mV5riCwczwQhT4gYK7FAKa6MlcL/yxH7yMekzhf60oIBr3qZqY1OudSAKi8gFodgg0r6g== 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=L1/SV2bLUTLZSQ1ijAk/tWOFyGtsgz3S+uTSjU++hrU=; b=gDp/iPl053IhccUOaQ8/RzV7fH9UBq3fihzIUhSX4HZQGJ+RcS5iImi9YJ0Q/IIMqD57CRdpWf9NAp3z5PrSFBLz8tIkpi/ektwvuHFbItP49xF9BfnyEYyuHZl2GtW1ZPnP+knviGbDh6EyCyFZfOwyeo+o9cdf6u9NuBx06eQ= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:29:54 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:29:54 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 05/16] include: sbi: Make hartmask pointer as const in sbi_hartmask_test_hart() Date: Fri, 25 Sep 2020 16:59:03 +0530 Message-Id: <20200925112914.725846-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:51 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f7c0745f-4d53-4457-5124-08d8614652d4 X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V5iWBf9fNJkC62s52vJbTI9YnMXe5liD2oriZvhUPP1VvdT3bZFhPP5UE+PGGl4rro7Je/3hMW6HchOG6imh/HgBVSJSNtM+zB/ei45ZyuuxlpynEauUEO7LZmHFZWUAyxeEoEXAtXWrNWpNyIyw+pz9eYbXuaSCWTkiYaAIaeeERr/ETIm1rHdgSzzVqVmTjPIcxMqNG3IfttmAtiJwHmaEoKbmOqACjZmUZSRQfwSYiJinls4jtzT4QjRblm90DE17ilzQHyGQ+WaXAiNTN4K4ix35fG3FGoF9dsgCM3xog5rIdRnWHyhw4jaF7C060pE7vXxbkMsXCKNM7jprQzx2HaLkuBTNNxBQJp4PeXEEMUwlmDW0dSoWRbC6tq75 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(4744005)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: JDriLMJ/rS2FpPY2se38ZtkqVheNXFqcxxYWgd1D0OIDz8ey+H9EUNNb4N4IvoM2cqkpcWCuYf3L68orBD/PEAZCoayiupLkYjF4BVe4UZpE+n5CS+eKx4eGSVooRiFmVEICJM9va8G9lWYzj6LIYctQgebpmvEKsD+xk5r2GX/RpBHTjPCYDAEMx1FSeD2yOmaAKs0QznZK1uwhYRl2+sp4a/zq6vIY4TnAiVg6dpSgdNYvQV8JrBUK2L9vjycyKmH9096PFNjJg75yjoES85ySya2htKCUSLiE4bMloFmONX6S3Juk/6GP32p2Z2q7gk0pmvqk6Q9dv90nFUfgrI1JGAPubfl8c2uiAPmv61tdeXUZVxE6Rn5VMnS5CHjq2IkhxLAwvPr7hHAjR8O+9W6ti/nzHEuMhkQvBENM0mGN+kKAnMw3sogMAMsNoJUNrFjG+q2RiNkSxSc2LSVBWbcG0u+us2JsxROe2119VD4dg6jgsYH3ditgTKaHf6UPpx6qHiOelywHfssFSEQYyvAN/kYGd3CBHZKTAPEjG9T0swGaRBzQVQSQpxIT8e3X6ULwjhk+P0mbzekgtI+8AykJ2X0JK/Y54E6VYZQr0iGxt4fDxuMTEvagV/pagzvaw+9sfLPNYbAYeBsySSfssQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7c0745f-4d53-4457-5124-08d8614652d4 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:29:54.2803 (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: uFtsmo7GERrVcn4g5ltlXo7bbHDI73V40Lt7EJy0LMOxB8jzYTNrfBlYn32h18typ1L81BcOjYp1I+5h0aST6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_072955_955580_ECCB9B62 X-CRM114-Status: GOOD ( 14.79 ) 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.154.42 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The sbi_hartmask_test_hart() does not modify hartmask so the hartmask pointer parameter should be declared const. Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_hartmask.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sbi/sbi_hartmask.h b/include/sbi/sbi_hartmask.h index 77e42cb..f1cef0c 100644 --- a/include/sbi/sbi_hartmask.h +++ b/include/sbi/sbi_hartmask.h @@ -67,7 +67,7 @@ static inline void sbi_hartmask_clear_hart(u32 h, struct sbi_hartmask *m) * @param h HART id to test * @param m the hartmask pointer */ -static inline int sbi_hartmask_test_hart(u32 h, struct sbi_hartmask *m) +static inline int sbi_hartmask_test_hart(u32 h, const struct sbi_hartmask *m) { if (h < SBI_HARTMASK_MAX_BITS) return __test_bit(h, m->bits); From patchwork Fri Sep 25 11:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371188 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=2tzYwEJ5; 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=lRr2Bug5; 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=eyRX1T8J; 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 4ByV872B8cz9sSf for ; Fri, 25 Sep 2020 21:30:15 +1000 (AEST) 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=kKleV/VpWHUhkLDrAOtMJFWshd1JsBdgFYtPo6h59sQ=; b=2tzYwEJ5xAjn3bM0CIxjKpQ2C mjhx522H5fN/sS4QoHE0eerLZQO5TfF4TtS2Tj6f3fXMQz5CFQ+J25jGlaXxEMDPT48gsSzHu5+t8 IyAKLgijqK+zpu4W8Tu2LXoXKxhd9uJ3PcZBWQ1q5YIMCaBSX/Rfm6HFb3N8c0HfYvshr/V19CH6K rfYAZtoOulPAyvoH+LBBSBCgeOBGFcZt5Y/MXnL+wpTdVoVPI4HoNT4d1q1w37DGEM8PKGf0WLWUu eFoMQDQDEtOTRVv2uNNWGMORH22+8MaWMNHd7a4fIiYaXAvzXeWv0P770P0t23stk1PklOfCRZgAF V/1B0xafQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvV-0004Iu-0N; Fri, 25 Sep 2020 11:30:09 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvM-0004DS-8b for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:06 +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=1601033400; x=1632569400; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=7i9JOM2STg9KJZI6/VTfk18GQHi3jbhlal0KS8xHc58=; b=lRr2Bug5GSRZEEPlovcUr3C+Kdbqpc6EfJHq1hl460ZQIVERICDWjCJM xSZy9rd82Y6y2MdepPHwqzBfoOXLnq3B9MmBbiY8mmY/UOS+HoRb7XvTq DcesALGtldis/ZiTauuEcOSLegLYZisxowHOYbXMrepw71Fga6O/ik3qw XpFkeV788fv1kySGy+q9bVB9fMOaTtHzqLogduzmGyTuC0jUM5HM1V46s oXX3HLVl4qVioklOkb7sCw1OGhIyGVlOj7OII7z9ALPt/Lup/7Gn+fDN0 T8Mj1QM3K2ZiYfc4TGMbq8kShm0/VcuD4U1trdAX1zfvusnWeRpceRwKb w==; IronPort-SDR: g9eYyXTDhqbfuL4XXf4P7rHvj30n4Gq35tN5gQlaxx10bYDKmzUbOIuG383B/FGRLseN/cMtL7 tnzI1KBHISWTDX8vxUqYBdKoTcqKYqyAmf9Dq1POCz4Lk+dElpwqEDwgpLwIhMueg6Qg6JwYgB staJUQtXrvx/77lOBR285SxvN0PrvAi3BhvAuDffbs1jwUhgGLEs56odutQfsYF6u1e4sxqGJV xSXeBFCkURfozvN7ET7PWDdw92RTcxxKR7is9xyQI1rErQah0Zr4aVCSorLAWM1a8Uqk6zNX20 RPA= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="257984171" Received: from mail-dm6nam12lp2173.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.173]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:29:57 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ToRne0fRiPCDwmHQ7ioS99e+fe+fyj6ComzQAbk/0ZBkPyS8r16RK99Cjs8TzkTXMRsycxHd6gKmztF4fCrplGkhOBWVShveXVM6x5LgdNCz4UFUUhxCLPBSBRvdtx/npfEcCzNQdHD42MbeBuZRE+Fh1oTKEJ8FjiNYv21A0i41+4ueTLbvUSDmiIEE26Vd6EB5jodQvXflfA+lZvO7+1wsWUry2fvjbLM0Zf9Ifodd0uxBGXoY3GVlG3mGHbYhOmN7AM15Z8/XFgKChjr7Esus1RauNXvelo0dJIKDhgE1skcXU0jQQ96e9sqwvEtyYVAU3Dsa/qOuOoSm2dNL8A== 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=EWmiq1FAVFQZdvMWufhfAoZeQ/UF0vqZUEYm1R75nA4=; b=Ec/DOHoUeYsCRjqyjbjGRsRnTqvEuShS6Okm2fOqk8jnDGS9yMdDI406eWja/0hnvjSRzf5h597s4UNo1APTdbTlV+lQ+cWl9stiDOw72bzSAtkTTqKWL6UEHwc2dXm1J4L66mvQBYiZWkElUCKT1rPk3mA7ugvA8WT8PSB1zxVdX+NMNLkVI+Ey/TMpVCCxA87W37K7F6X3nomxyR5dXLquNNohXxlNNNvm3LYgFXJUHGTObQAOzLAMSFOeow6QJZUVvqrowyhdMDlvv6/jT9lzpWg2gziuLrVm8DOYOuaQ2fXb3p4PqlEiZqcG6QMc3M6SCvLM082WzWYagXfErA== 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=EWmiq1FAVFQZdvMWufhfAoZeQ/UF0vqZUEYm1R75nA4=; b=eyRX1T8JPFd+69mhiK/j0UgvWuFuEXitf7U/SqdFz/H4gYOA9WRuaFnnuZKFsPO3Aje8jXXVF+URKCVqemJbOA+7HqR+PrxaLMzL5lMaZUn7GiU45D6N+NCxVt2Y+XXmC6/k4roks7on/x3xVIbeYPlVbL5TAAre8TJ3LUa7o8Y= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:29:57 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:29:56 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 06/16] lib: sbi: Add initial domain support Date: Fri, 25 Sep 2020 16:59:04 +0530 Message-Id: <20200925112914.725846-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:54 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fc163546-5db5-43c6-68cf-08d86146547a X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CuNQ1g0gdf4SoaZOIrWqJAj+9/IIv7RJTlB5FbfdEqNQKIaxCG7mmSrkQy/EqD3qHXQ8VIwezJShvV6e/UdgBWdpBkXCp5EE40po2NjOuEid9xmICvo/kLMQMvPCqCsMzpyA0AcWG75u+p+m0n/za40gKGHl8aNMiWe+DfG/fgqgijCYO5tuPwLPu009arGDGeM+sM/fvYaevWkw2Na5lUb3PskholNmbW6h8tOOUxk2Nf36+scRxwTO39e0GmpZiP8W0KBI8s3wADaxG0S5QsfPndLpvwu/stUKvN5OTGpX+2lVAFWFfBAgHmRHQ4Gi/Jf+1a5Bkf9tvBKnwKdOlZviHyP7NbVc6Vm70veFgpvznhSHK1YijhGpM4sD+IU9 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(30864003)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: p7ZxJ29tMuxETzxYfpqwhWCD9hZFYCph56K/97TUByDqsU7vvq/wSYCQ4fKj2lzH5FnrEpkZPq6KRzVNgtSgc8xhO0nTKGSgt+UXut+MvK6B2lfGhOYl2ColNg1JQkDU9ZWS4pA23s5HsWVoFjJOz7X6J5qcKKqeii/W69g5FnZJy9J+f5XQjA3JEO42l5UY3KwfHGiedj72k63xTwM2t0/A1h0tIGLakhFsa7vDjnRvvqDt42+vgf8NDIgZAeK+1sy6Ehmc/F8LanrgWVw/7QnAfA0PKmz+W0maN7zewppBa23drM7V2pZJUsOQxSELJ2Tv5rdhwGRPvC5d2Rn8hgGJVTRKJaTcztWPGVsBE5HS+2uxPGuvkkdR/BekpDXYA3K4xGX6/yiQsYR0JUJADdDZ8u5TuOiki0o19qMpliEfFCNSbxJI68bzqRElbhJ7VftNMnTarTV7BkdydDPylQjMyoGYKYNHojKvLC1e3a6rz6utZqdTqiAqgdllEAJL3H3NbATZ4zhu9lkzfyhDfYWt0q9F6+xhIabGssqrF8OYZOPgNQ/d8zudwesGxs6n9XxCXPWOzWFOTMETDy9+qZh8wQlpeh49p30G2TM6LrNJzWowq0yJoHsF0eVmj3GvVWKtA+lARU3s/rMXjFbUIg== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc163546-5db5-43c6-68cf-08d86146547a X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:29:56.8576 (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: MYFIPasumDfjoHChWgSAboDRkIvbHA8TzxCFUPD3AbdmmFgv6TtEDLlmLGFCUUyb9Zo0Yr5LvlFjIygz2JTjDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073000_550059_893A7318 X-CRM114-Status: GOOD ( 29.08 ) 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.141.245 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 An OpenSBI domain is a logical entity representing a set of HARTs and a set of memory regions for these HARTs. The OpenSBI domains support will allow OpenSBI platforms and previous booting stage (i.e. U-Boot SPL, Coreboot, etc) to partition a system into multiple domains where each domain will run it's own software. For inter-domain isolation, OpenSBI will eventually use various HW features such as PMP, ePMP, IOPMP, SiFive shield, etc but initial implementation only use HW PMP support. This patch provides initial implementation of OpenSBI domains where we have a root/default domain and OpenSBI platforms can provide non-root/custom domains using domain_get() callback. Signed-off-by: Anup Patel --- include/sbi/sbi_domain.h | 138 ++++++++++++++ include/sbi/sbi_platform.h | 20 ++ lib/sbi/objects.mk | 1 + lib/sbi/sbi_domain.c | 365 +++++++++++++++++++++++++++++++++++++ lib/sbi/sbi_init.c | 20 ++ 5 files changed, 544 insertions(+) create mode 100644 include/sbi/sbi_domain.h create mode 100644 lib/sbi/sbi_domain.c diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h new file mode 100644 index 0000000..a3f174c --- /dev/null +++ b/include/sbi/sbi_domain.h @@ -0,0 +1,138 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#ifndef __SBI_DOMAIN_H__ +#define __SBI_DOMAIN_H__ + +#include +#include + +struct sbi_scratch; + +/** Representation of OpenSBI domain memory region */ +struct sbi_domain_memregion { + /** + * Size of memory region as power of 2 + * It has to be minimum 3 and maximum __riscv_xlen + */ + unsigned long order; + /** + * Base address of memory region + * It must be 2^order aligned address + */ + unsigned long base; + /** Access flags of memory region */ +#define SBI_DOMAIN_MEMREGION_READABLE (1UL << 0) +#define SBI_DOMAIN_MEMREGION_WRITEABLE (1UL << 1) +#define SBI_DOMAIN_MEMREGION_EXECUTABLE (1UL << 2) +#define SBI_DOMAIN_MEMREGION_MMIO (1UL << 3) +#define SBI_DOMAIN_MEMREGION_MMODE (1UL << 4) + unsigned long flags; +}; + +/** Representation of OpenSBI domain */ +struct sbi_domain { + /** + * Logical index of this domain + * Note: This set by sbi_domain_finalize() in the coldboot path + */ + u32 index; + /** + * HARTs assigned to this domain + * Note: This set by sbi_domain_init() and sbi_domain_finalize() + * in the coldboot path + */ + struct sbi_hartmask assigned_harts; + /** Name of this domain */ + char name[64]; + /** Possible HARTs in this domain */ + const struct sbi_hartmask *possible_harts; + /** Array of memory regions terminated by a region with order zero */ + struct sbi_domain_memregion *regions; + /** HART id of the HART booting this domain */ + u32 boot_hartid; + /** Arg1 (or 'a1' register) of next booting stage for this domain */ + unsigned long next_arg1; + /** Address of next booting stage for this domain */ + unsigned long next_addr; + /** Priviledge mode of next booting stage for this domain */ + unsigned long next_mode; + /** Is domain allowed to reset the system */ + bool system_reset_allowed; +}; + +/** HART id to domain table */ +extern struct sbi_domain *hartid_to_domain_table[]; + +/** Get pointer to sbi_domain from HART id */ +#define sbi_hartid_to_domain(__hartid) \ + hartid_to_domain_table[__hartid] + +/** Get pointer to sbi_domain for current HART */ +#define sbi_domain_thishart_ptr() \ + sbi_hartid_to_domain(current_hartid()) + +/** Index to domain table */ +extern struct sbi_domain *domidx_to_domain_table[]; + +/** Get pointer to sbi_domain from index */ +#define sbi_index_to_domain(__index) \ + domidx_to_domain_table[__index] + +/** Iterate over each domain */ +#define sbi_domain_for_each(__i, __d) \ + for ((__i) = 0; ((__d) = sbi_index_to_domain(__i)); (__i)++) + +/** Iterate over each memory regon of a domain */ +#define sbi_domain_for_each_memregion(__d, __r) \ + for ((__r) = (__d)->regions; (__r)->order; (__r)++) + +/** + * Check whether given HART is assigned to specified domain + * @param dom pointer to domain + * @param hartid the HART ID + * @return TRUE if HART is assigned to domain otherwise FALSE + */ +bool sbi_domain_assigned_hart(const struct sbi_domain *dom, u32 hartid); + +/** + * Get ulong assigned HART mask for given domain and HART base ID + * @param dom pointer to domain + * @param hbase the HART base ID + * @return ulong possible HART mask + * Note: the return ulong mask will be set to zero on failure. + */ +ulong sbi_domain_assigned_hartmask(const struct sbi_domain *dom, ulong hbase); + +/** Initialize a domain memory region as firmware region */ +void sbi_domain_memregion_initfw(struct sbi_domain_memregion *reg); + +/** + * Check whether we can access specified address for given mode and + * memory region flags under a domain + * @param dom pointer to domain + * @param addr the address to be checked + * @param mode the privilege mode of access + * @param mmio the memory type of access is MMIO + * @param read the access is read + * @param write the access is write + * @param execute the access is instruction execute + * @return TRUE if access allowed otherwise FALSE + */ +bool sbi_domain_check_addr(const struct sbi_domain *dom, + unsigned long addr, unsigned long mode, bool mmio, + bool read, bool write, bool execute); + +/** Finalize domain tables and startup non-root domains */ +int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid); + +/** Initialize domains */ +int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid); + +#endif diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index f2c3237..e1355d8 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -44,6 +44,7 @@ #include #include +struct sbi_domain; struct sbi_trap_info; /** Possible feature flags of a platform */ @@ -89,6 +90,9 @@ struct sbi_platform_operations { */ int (*misa_get_xlen)(void); + /** Get domain pointer for given HART id */ + struct sbi_domain *(*domain_get)(u32 hartid); + /** Write a character to the platform console output */ void (*console_putc)(char ch); /** Read a character from the platform console input */ @@ -447,6 +451,22 @@ static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat) return -1; } +/** + * Get domain pointer for given HART + * + * @param plat pointer to struct sbi_platform + * @param hartid shorthand letter for CPU extensions + * + * @return non-NULL domain pointer on success and NULL on failure + */ +static inline struct sbi_domain *sbi_platform_domain_get( + const struct sbi_platform *plat, u32 hartid) +{ + if (plat && sbi_platform_ops(plat)->domain_get) + return sbi_platform_ops(plat)->domain_get(hartid); + return NULL; +} + /** * Write a character to the platform console output * diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk index fa808a0..6f2c06f 100644 --- a/lib/sbi/objects.mk +++ b/lib/sbi/objects.mk @@ -15,6 +15,7 @@ libsbi-objs-y += riscv_locks.o libsbi-objs-y += sbi_bitmap.o libsbi-objs-y += sbi_bitops.o libsbi-objs-y += sbi_console.o +libsbi-objs-y += sbi_domain.o libsbi-objs-y += sbi_ecall.o libsbi-objs-y += sbi_ecall_base.o libsbi-objs-y += sbi_ecall_hsm.o diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c new file mode 100644 index 0000000..8d5dae1 --- /dev/null +++ b/lib/sbi/sbi_domain.c @@ -0,0 +1,365 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Western Digital Corporation or its affiliates. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +struct sbi_domain *hartid_to_domain_table[SBI_HARTMASK_MAX_BITS] = { 0 }; +struct sbi_domain *domidx_to_domain_table[SBI_HARTMASK_MAX_BITS + 1] = { 0 }; + +static u32 domain_count = 0; + +static struct sbi_hartmask root_hmask = { 0 }; + +#define ROOT_FW_REGION 0 +#define ROOT_ALL_REGION 1 +#define ROOT_END_REGION 2 +static struct sbi_domain_memregion root_memregs[ROOT_END_REGION + 1] = { 0 }; + +static struct sbi_domain root = { + .name = "root", + .possible_harts = &root_hmask, + .regions = root_memregs, + .system_reset_allowed = TRUE, +}; + +bool sbi_domain_assigned_hart(const struct sbi_domain *dom, u32 hartid) +{ + if (dom) + return sbi_hartmask_test_hart(hartid, &dom->assigned_harts); + + return FALSE; +} + +ulong sbi_domain_assigned_hartmask(const struct sbi_domain *dom, ulong hbase) +{ + ulong ret, bword, boff; + + if (!dom) + return 0; + + bword = BIT_WORD(hbase); + boff = BIT_WORD_OFFSET(hbase); + + ret = sbi_hartmask_bits(&dom->assigned_harts)[bword++] >> boff; + if (boff && bword < BIT_WORD(SBI_HARTMASK_MAX_BITS)) { + ret |= (sbi_hartmask_bits(&dom->assigned_harts)[bword] & + (BIT(boff) - 1UL)) << (BITS_PER_LONG - boff); + } + + return ret; +} + +void sbi_domain_memregion_initfw(struct sbi_domain_memregion *reg) +{ + if (!reg) + return; + + sbi_memcpy(reg, &root_memregs[ROOT_FW_REGION], sizeof(*reg)); +} + +bool sbi_domain_check_addr(const struct sbi_domain *dom, + unsigned long addr, unsigned long mode, bool mmio, + bool read, bool write, bool execute) +{ + struct sbi_domain_memregion *reg; + unsigned long rstart, rend, rflags, rwx = 0; + + if (!dom) + return FALSE; + + if (read) + rwx |= SBI_DOMAIN_MEMREGION_READABLE; + if (write) + rwx |= SBI_DOMAIN_MEMREGION_WRITEABLE; + if (execute) + rwx |= SBI_DOMAIN_MEMREGION_EXECUTABLE; + + sbi_domain_for_each_memregion(dom, reg) { + rflags = reg->flags; + if (mode == PRV_M && !(rflags & SBI_DOMAIN_MEMREGION_MMODE)) + continue; + + rstart = reg->base; + rend = (reg->order < __riscv_xlen) ? + rstart + ((1UL << reg->order) - 1) : -1UL; + if (rstart <= addr && addr <= rend) { + if ((mmio && !(rflags & SBI_DOMAIN_MEMREGION_MMIO)) || + (!mmio && (rflags & SBI_DOMAIN_MEMREGION_MMIO))) + return FALSE; + return ((rflags & rwx) == rwx) ? TRUE : FALSE; + } + } + + return (mode == PRV_M) ? TRUE : FALSE; +} + +/* Check if region comply with constraints */ +static bool is_region_valid(const struct sbi_domain_memregion *reg) +{ + if (reg->order < 3 || __riscv_xlen < reg->order) + return FALSE; + + if (reg->base & (BIT(reg->order) - 1)) + return FALSE; + + return TRUE; +} + +/** Check if regionA is sub-region of regionB */ +static bool is_region_subset(const struct sbi_domain_memregion *regA, + const struct sbi_domain_memregion *regB) +{ + ulong regA_start = regA->base; + ulong regA_end = regA->base + (BIT(regA->order) - 1); + ulong regB_start = regB->base; + ulong regB_end = regB->base + (BIT(regA->order) - 1); + + if ((regB_start <= regA_start) && + (regA_start < regB_end) && + (regB_start < regA_end) && + (regA_end <= regB_end)) + return TRUE; + + return FALSE; +} + +/** Check if regionA conflicts regionB */ +static bool is_region_conflict(const struct sbi_domain_memregion *regA, + const struct sbi_domain_memregion *regB) +{ + if ((is_region_subset(regA, regB) || is_region_subset(regB, regA)) && + regA->flags == regB->flags) + return TRUE; + + return FALSE; +} + +/** Check if regionA should be placed before regionB */ +static bool is_region_before(const struct sbi_domain_memregion *regA, + const struct sbi_domain_memregion *regB) +{ + if (regA->order < regB->order) + return TRUE; + + if ((regA->order == regB->order) && + (regA->base < regB->base)) + return TRUE; + + return FALSE; +} + +static int sanitize_domain(const struct sbi_platform *plat, + struct sbi_domain *dom) +{ + u32 i, j, count; + bool have_fw_reg; + struct sbi_domain_memregion treg, *reg, *reg1; + + /* Check possible HARTs */ + if (!dom->possible_harts) + return SBI_EINVAL; + sbi_hartmask_for_each_hart(i, dom->possible_harts) { + if (sbi_platform_hart_invalid(plat, i)) + return SBI_EINVAL; + }; + + /* Check memory regions */ + if (!dom->regions) + return SBI_EINVAL; + sbi_domain_for_each_memregion(dom, reg) { + if (!is_region_valid(reg)) + return SBI_EINVAL; + } + + /* Count memory regions and check precense of firmware region */ + count = 0; + have_fw_reg = FALSE; + sbi_domain_for_each_memregion(dom, reg) { + if (reg->order == root_memregs[ROOT_FW_REGION].order && + reg->base == root_memregs[ROOT_FW_REGION].base && + reg->flags == root_memregs[ROOT_FW_REGION].flags) + have_fw_reg = TRUE; + count++; + } + if (!have_fw_reg) + return SBI_EINVAL; + + /* Sort the memory regions */ + for (i = 0; i < (count - 1); i++) { + reg = &dom->regions[i]; + for (j = i + 1; j < count; j++) { + reg1 = &dom->regions[j]; + + if (is_region_conflict(reg1, reg)) + return SBI_EINVAL; + + if (!is_region_before(reg1, reg)) + continue; + + sbi_memcpy(&treg, reg1, sizeof(treg)); + sbi_memcpy(reg1, reg, sizeof(treg)); + sbi_memcpy(reg, &treg, sizeof(treg)); + } + } + + /* + * We don't need to check boot HART id of domain because if boot + * HART id is not possible/assigned to this domain then it won't + * be started at boot-time by sbi_domain_finalize(). + */ + + /* Check next mode */ + if (dom->next_mode != PRV_M && + dom->next_mode != PRV_S && + dom->next_mode != PRV_U) + return SBI_EINVAL; + + /* Check next address and next mode*/ + if (!sbi_domain_check_addr(dom, dom->next_addr, dom->next_mode, + FALSE, FALSE, FALSE, TRUE)) + return SBI_EINVAL; + + return 0; +} + +int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid) +{ + int rc; + u32 i, j, dhart; + bool dom_exists; + struct sbi_domain *dom, *tdom; + const struct sbi_platform *plat = sbi_platform_ptr(scratch); + + /* Discover domains */ + for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) { + /* Ignore invalid HART */ + if (sbi_platform_hart_invalid(plat, i)) + continue; + + /* Get domain assigned to HART */ + dom = sbi_platform_domain_get(plat, i); + if (!dom) + continue; + + /* Check if domain already discovered */ + dom_exists = FALSE; + sbi_domain_for_each(j, tdom) { + if (tdom == dom) { + dom_exists = TRUE; + break; + } + } + + /* Newly discovered domain */ + if (!dom_exists) { + /* Sanitize discovered domain */ + rc = sanitize_domain(plat, dom); + if (rc) + return rc; + + /* Assign index to domain */ + dom->index = domain_count++; + domidx_to_domain_table[dom->index] = dom; + + /* Clear assigned HARTs of domain */ + sbi_hartmask_clear_all(&dom->assigned_harts); + } + + /* Assign domain to HART if HART is a possible HART */ + if (sbi_hartmask_test_hart(i, dom->possible_harts)) { + tdom = hartid_to_domain_table[i]; + if (tdom) + sbi_hartmask_clear_hart(i, + &tdom->assigned_harts); + hartid_to_domain_table[i] = dom; + sbi_hartmask_set_hart(i, &dom->assigned_harts); + } + } + + /* Startup boot HART of domains */ + sbi_domain_for_each(i, dom) { + /* Domain boot HART */ + dhart = dom->boot_hartid; + + /* Ignore if boot HART not possible for this domain */ + if (!sbi_hartmask_test_hart(i, dom->possible_harts)) + continue; + + /* Ignore if boot HART assigned different domain */ + if (sbi_hartid_to_domain(dhart) != dom || + !sbi_hartmask_test_hart(i, &dom->assigned_harts)) + continue; + + /* Startup boot HART of domain */ + if (dhart == cold_hartid) { + scratch->next_addr = dom->next_addr; + scratch->next_mode = dom->next_mode; + scratch->next_arg1 = dom->next_arg1; + } else { + rc = sbi_hsm_hart_start(scratch, dhart, dom->next_addr, + dom->next_mode, dom->next_arg1); + if (rc) + return rc; + } + } + + return 0; +} + +int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid) +{ + u32 i; + const struct sbi_platform *plat = sbi_platform_ptr(scratch); + + /* Root domain firmware memory region */ + root_memregs[ROOT_FW_REGION].order = log2roundup(scratch->fw_size); + root_memregs[ROOT_FW_REGION].base = scratch->fw_start & + ~((1UL << root_memregs[0].order) - 1UL); + root_memregs[ROOT_FW_REGION].flags = 0; + + /* Root domain allow everything memory region */ + root_memregs[ROOT_ALL_REGION].order = __riscv_xlen; + root_memregs[ROOT_ALL_REGION].base = 0; + root_memregs[ROOT_ALL_REGION].flags = (SBI_DOMAIN_MEMREGION_READABLE | + SBI_DOMAIN_MEMREGION_WRITEABLE | + SBI_DOMAIN_MEMREGION_EXECUTABLE); + + /* Root domain memory region end */ + root_memregs[ROOT_END_REGION].order = 0; + + /* Root domain boot HART id is same as coldboot HART id */ + root.boot_hartid = cold_hartid; + + /* Root domain next booting stage details */ + root.next_arg1 = scratch->next_arg1; + root.next_addr = scratch->next_addr; + root.next_mode = scratch->next_mode; + + /* Select root domain for all valid HARTs */ + for (i = 0; i < SBI_HARTMASK_MAX_BITS; i++) { + if (sbi_platform_hart_invalid(plat, i)) + continue; + sbi_hartmask_set_hart(i, &root_hmask); + hartid_to_domain_table[i] = &root; + sbi_hartmask_set_hart(i, &root.assigned_harts); + } + + /* Set root domain index */ + root.index = domain_count++; + domidx_to_domain_table[root.index] = &root; + + return 0; +} diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 5cedb15..406cb3f 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -169,6 +170,11 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); + /* Note: This has to be second thing in coldboot init sequence */ + rc = sbi_domain_init(scratch, hartid); + if (rc) + sbi_hart_hang(); + init_count_offset = sbi_scratch_alloc_offset(__SIZEOF_POINTER__, "INIT_COUNT"); if (!init_count_offset) @@ -210,10 +216,24 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); + /* + * Note: Finalize domains after HSM initialization so that we + * can startup non-root domains. + * Note: Finalize domains before HART PMP configuration so + * that we use correct domain for configuring PMP. + */ + rc = sbi_domain_finalize(scratch, hartid); + if (rc) + sbi_hart_hang(); + rc = sbi_hart_pmp_configure(scratch); if (rc) sbi_hart_hang(); + /* + * Note: Platform final initialization should be last so that + * it sees correct domain assignment and PMP configuration. + */ rc = sbi_platform_final_init(plat, TRUE); if (rc) sbi_hart_hang(); From patchwork Fri Sep 25 11:29:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371190 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=xmcMEyC1; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=nXTeKUIj; 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=MjWNCms8; 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 4ByV895cCWz9sSf for ; Fri, 25 Sep 2020 21:30:17 +1000 (AEST) 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=z8mSaSvZdgRdVNCtEUG9TDIzi38u6VMMs76GYZWgJC0=; b=xmcMEyC1DZ4reAC38eRuxwAiU 1dO7GEN3gUCVEBoLktY1ZtOA11a0bCu1RqO8H9Y2O9Lbl9LzmaSvv+PcCMCby2cYw9ORzeLVKpFBM AfpSZeHYzPJAcdJ440n8YLU/z8aK3WjF7F//4ISGOARMeI6IXOdrdbdrbjl1G78U6UdQOjN7cyVV1 6fK1Bl0cM4uvBIbBRIsibZPRYzLxV7B7Icw29LZNLCt6D3HNbP/dj4vmXB+nJyKdyO3b7JbeWbM6s o848+QNOQSWiw5D1WFjafIZnosj/kSpIhNS59T4blQrrGlsO9kQxf+hTE8aCYTTlSx937P0JIrdkn 65rvdoPng==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvY-0004Kx-3p; Fri, 25 Sep 2020 11:30:12 +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 1kLlvP-0004F6-Rq for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:08 +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=1601034558; x=1632570558; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Lv6lG5KgUWGUMeR7+fW1x8mip/fFM3kG3SsJ701dGJc=; b=nXTeKUIj7tA4HrLVPA4MOqCpsaEWUMZ+hQcYyTRGzI+nTWTrp8izfrsw q2BIeCgsX3N4q1nKgwG8Du5l1038wLjH3xT8wFRGYWKtiZqcaoxI539Uq h2Vv0wtA21F6chaQl2Ju8MtTnK/7pB/7d430BgEdSET5AC0jQaqud70c4 Ej//xx1QpDenPpSW1uMHrj3SX4yJqoou8tyE6CFuBTzVzqer236v4wric NlCtdKKXN2L8G9oAKecjCRD/8fkmzYH07oANBSxiHzG61t6fpLdTJr+rl HbUWOllfBN2jIjGTi/7Oiwlq/CHwwob+mIstXHxsBe+Pk08jo89GFDetW g==; IronPort-SDR: xNmRoAU6QZAMSQ21TzVjemcV5KElNTcZY4wPtrnjMqOPoLWcnKLOZCVc0Ym/kw/tUIXaTubvrn dNSYz1U7y4LtTI8KCyhYLjB4O2tZWbKgcVGreABaABH5pqKNHA8hOVba8gX6HZo34LWg6sQPpa Ic3t3E2+2X/jCkvaZ5/hTYupk6TMXc0KRDwQp7t0mykw5V4b2brMEC5l66KuOxROaiIGe8Zo32 3CMuqFvDyrlf6C5azAudUWgFcBxMiJ/75WVWAfMqjExGUIeqkDFb1I4CWEO2oaSQliiZX6eWXf EAY= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="251658584" Received: from mail-co1nam04lp2050.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.50]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:49:13 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JsXKYBxq5bjWMGLbfeJnZqlaNm0N54AOmrJZF8RgaMdKqT9Y9OkbOLiJdTDcSaGKqW50JE958arKQOj33ARmhQgkMwBavh2a9IM7TOfzkzpYV6+ocP8910KFSDwUd0syrweowK8NfzuDnjNAxIRi6WxPb1H68ldAcqi72oKn77XqZlbS4rTw60Oha56c8OLikoerFhiV6WNCpTQ8rTpF33DvdFWUthcPQecx7iM98uyvesj7U5pFJCFtT8dDOPssaIKl1KsFnmHt0vHb+i8Q7SFc714Qna7rfv55TElLGXnqx20rRE4aYuh687FGMFR4v2493EDZ3Dbq/+LNXBeT0w== 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=B39AE+amfgwmsDO4JbHr+Ohph07JIiul+zInoTrqimk=; b=lc2SpgoXtRBpXVUteaHFlw59y54iN1nICs520abN6g+TTMQvBNw89AiFZYTAOcEx91FDHpwB9rxE8L7e+2ZaOKnYz8yj2w29JHAJHrsEFaH8pE1tzdF4uAszfrW0A9iIXjHJUrw47WPl/+PSVtBPzTPt6QQ5lJGu6uvMk9eme6uIvV7gZtCZB/3TVzsHVrOfUEpr6QGtZvtE9BrlOWl7Xu3LYDKM/CwoNBKvwf92YkWApuGwUGcadhRTBHZfMZkhNYVMCEZdWJ3GlCq9GVyJ01CNAORrr9ZFU7AdlI35yQhSvoICU71NXKJBsXKvHDgSlrulDkHBHFaiSMvzPITpcw== 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=B39AE+amfgwmsDO4JbHr+Ohph07JIiul+zInoTrqimk=; b=MjWNCms8CVKxHDyAEk4ymd+5mOHKt4IUZeG27HdJzDDvGBCQE4Toc6xxndgQTw7280IRkmXfaHF5yK5WKpkyxIrtQLseJUEqQZv6beqetRRGGa+l2tkqt12/DJX6fk5jxL7kmHcb0SYUOT9GTKPqf3OwFcinwEnYIqjSj31gC8U= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:29:59 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:29:59 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 07/16] lib: sbi: Extend sbi_hsm_hart_started_mask() for domains Date: Fri, 25 Sep 2020 16:59:05 +0530 Message-Id: <20200925112914.725846-8-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:57 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 71398339-c0c3-4e36-b2ef-08d861465601 X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1284; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ztE4szYGeGwajMYJ7ldluzD/9Uzih+DVCuqJaa988mgTfy6nmzeiSXqXbkH3jKS8KX8ekeMLgXeOywvAWqltbWr9yV0Nn8XZ+HaXGl5tfZqPfIOWciblp0ZQSX05Mx0jWpuNmxKy1OcWrHGWyNHNoDUXn0j2Q1g9t2xS3+GNFm4DyQaDVD2i+zTINZ9DWOJuasjjjLCndLPwyyz1Jsxgkz3362dBbMNjELpcn2P2djgQ4WutPXZT4w0mfWFNuU7sbviIRUugKOu3PsZHIjin/byvwGTPNRuDqOPj+qBdji7A+EKImRkUAq8zRv7EF8aXJhl/LZ0y89xho3vfRmmFlDwCpgL10Mdh/pc649FA7c3O3mhgu/OL4/WOIYjChtXz 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: HPU+le5ZlhVmdY2OAmkGzg3eHyQiCD70VrLguptNQH+d/032WGJzWcM0p312bHj7CU80FnaoBQjswLvw1RU5oAAVdPWmMj57GeH8CjPIKXzTEvvTIuenzu/F4zFS3gidW/ESxJMbYkV3MzrF7xbltsyTZcxRO4m+0lwbL+EHFr8lcoVABz9FuUd3A5OYK8XyqlP+LD3FaMvvDJRXfKrUIzFWeFE2iSBdOAjRgTVvXCvni8eQLmLuCQAR/BjIlTb89SbZeHzkRNDLwBtYyuUlYArQIVcmrTqO41DrS0QfbFumzstji8JKhIwIUC54gRZfOJ8IDc37vAk0w6kxMBght8r4ffUtESrDkf3nHM5C1ylSqrRPo/923NKyk5o389vjzxsAUDLfFApakkyxz2oNlq85HeoSD1kc9M9/0DIqRyBfbTBfJOHyxM1H9n4aDOSHQFPbhuuW3g5AU8MTzDMUm/Z60zm2Y6pV6NopKRy6OQkPMFaS3UoUQwT3EQ91wwbGLFrzwkWuT5ud6Lgt293kmo1mknTmVCMx+a0MxqLcgFpKaFg8UXEYL1a/SnfuE28XvvTYuJwdrOT8TeYXZUkSJqUPm2XdEk5wKVvLIg8HydE4w+b8AbAQEQO35q7yXTWU2SUp7I2nIkuI0KGl+n8sNg== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71398339-c0c3-4e36-b2ef-08d861465601 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:29:59.4310 (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: vxkFNbGxTtdfq8ltUw9bBVltoFeiMRspKj4SvZ1fnCyU9BSkoq+mIP4p4VkOw2sBuyr7lPFI4UNu0TDefitnyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073004_154416_DE4384F1 X-CRM114-Status: GOOD ( 20.38 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The sbi_hsm_hart_started_mask() API should take one more parameter to allow caller specify domain under which started_mask is being generated. Further, the sbi_hsm_hart_started_mask() depends on sbi_hsm_hart_get_state() which also should return HART state under specified domain. This patch updates both sbi_hsm_hart_started_mask() and sbi_hsm_hart_get_state() as-per above. Signed-off-by: Anup Patel --- include/sbi/sbi_hsm.h | 7 ++++--- lib/sbi/sbi_ecall_hsm.c | 4 +++- lib/sbi/sbi_ecall_legacy.c | 4 +++- lib/sbi/sbi_hsm.c | 17 ++++++++++------- lib/sbi/sbi_ipi.c | 6 ++++-- lib/sbi/sbi_system.c | 4 +++- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/sbi/sbi_hsm.h b/include/sbi/sbi_hsm.h index 18d129b..296b267 100644 --- a/include/sbi/sbi_hsm.h +++ b/include/sbi/sbi_hsm.h @@ -19,6 +19,7 @@ #define SBI_HART_STARTED 3 #define SBI_HART_UNKNOWN 4 +struct sbi_domain; struct sbi_scratch; int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot); @@ -27,10 +28,10 @@ void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch); int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid, ulong saddr, ulong smode, ulong priv); int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow); -int sbi_hsm_hart_get_state(u32 hartid); +int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid); int sbi_hsm_hart_state_to_status(int state); -bool sbi_hsm_hart_started(u32 hartid); -int sbi_hsm_hart_started_mask(ulong hbase, ulong *out_hmask); +int sbi_hsm_hart_started_mask(const struct sbi_domain *dom, + ulong hbase, ulong *out_hmask); void sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid); #endif diff --git a/lib/sbi/sbi_ecall_hsm.c b/lib/sbi/sbi_ecall_hsm.c index 992c93a..3698a41 100644 --- a/lib/sbi/sbi_ecall_hsm.c +++ b/lib/sbi/sbi_ecall_hsm.c @@ -7,6 +7,7 @@ * Atish Patra */ +#include #include #include #include @@ -34,7 +35,8 @@ static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid, ret = sbi_hsm_hart_stop(scratch, TRUE); break; case SBI_EXT_HSM_HART_GET_STATUS: - hstate = sbi_hsm_hart_get_state(args[0]); + hstate = sbi_hsm_hart_get_state(sbi_domain_thishart_ptr(), + args[0]); ret = sbi_hsm_hart_state_to_status(hstate); break; default: diff --git a/lib/sbi/sbi_ecall_legacy.c b/lib/sbi/sbi_ecall_legacy.c index 3bfe749..909cbe3 100644 --- a/lib/sbi/sbi_ecall_legacy.c +++ b/lib/sbi/sbi_ecall_legacy.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -33,7 +34,8 @@ static int sbi_load_hart_mask_unpriv(ulong *pmask, ulong *hmask, if (uptrap->cause) return SBI_ETRAP; } else { - sbi_hsm_hart_started_mask(0, &mask); + sbi_hsm_hart_started_mask(sbi_domain_thishart_ptr(), + 0, &mask); } *hmask = mask; diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index 8c1b7b0..1f8dadc 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -56,13 +57,13 @@ int sbi_hsm_hart_state_to_status(int state) return ret; } -int sbi_hsm_hart_get_state(u32 hartid) +int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid) { struct sbi_hsm_data *hdata; struct sbi_scratch *scratch; scratch = sbi_hartid_to_scratch(hartid); - if (!scratch) + if (!scratch || !sbi_domain_assigned_hart(dom, hartid)) return SBI_HART_UNKNOWN; hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset); @@ -70,9 +71,9 @@ int sbi_hsm_hart_get_state(u32 hartid) return atomic_read(&hdata->state); } -bool sbi_hsm_hart_started(u32 hartid) +static bool sbi_hsm_hart_started(const struct sbi_domain *dom, u32 hartid) { - if (sbi_hsm_hart_get_state(hartid) == SBI_HART_STARTED) + if (sbi_hsm_hart_get_state(dom, hartid) == SBI_HART_STARTED) return TRUE; else return FALSE; @@ -80,12 +81,14 @@ bool sbi_hsm_hart_started(u32 hartid) /** * Get ulong HART mask for given HART base ID + * @param dom the domain to be used for output HART mask * @param hbase the HART base ID * @param out_hmask the output ulong HART mask * @return 0 on success and SBI_Exxx (< 0) on failure * Note: the output HART mask will be set to zero on failure as well. */ -int sbi_hsm_hart_started_mask(ulong hbase, ulong *out_hmask) +int sbi_hsm_hart_started_mask(const struct sbi_domain *dom, + ulong hbase, ulong *out_hmask) { ulong i; ulong hcount = sbi_scratch_last_hartid() + 1; @@ -97,7 +100,7 @@ int sbi_hsm_hart_started_mask(ulong hbase, ulong *out_hmask) hcount = BITS_PER_LONG; for (i = hbase; i < hcount; i++) { - if (sbi_hsm_hart_get_state(i) == SBI_HART_STARTED) + if (sbi_hsm_hart_get_state(dom, i) == SBI_HART_STARTED) *out_hmask |= 1UL << (i - hbase); } @@ -259,7 +262,7 @@ int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow) struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset); - if (!sbi_hsm_hart_started(hartid)) + if (!sbi_hsm_hart_started(sbi_domain_thishart_ptr(), hartid)) return SBI_EINVAL; oldstate = atomic_cmpxchg(&hdata->state, SBI_HART_STARTED, diff --git a/lib/sbi/sbi_ipi.c b/lib/sbi/sbi_ipi.c index a27dea0..4347832 100644 --- a/lib/sbi/sbi_ipi.c +++ b/lib/sbi/sbi_ipi.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -77,10 +78,11 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data) { int rc; ulong i, m; + struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); if (hbase != -1UL) { - rc = sbi_hsm_hart_started_mask(hbase, &m); + rc = sbi_hsm_hart_started_mask(dom, hbase, &m); if (rc) return rc; m &= hmask; @@ -92,7 +94,7 @@ int sbi_ipi_send_many(ulong hmask, ulong hbase, u32 event, void *data) } } else { hbase = 0; - while (!sbi_hsm_hart_started_mask(hbase, &m)) { + while (!sbi_hsm_hart_started_mask(dom, hbase, &m)) { /* Send IPIs */ for (i = hbase; m; i++, m >>= 1) { if (m & 1UL) diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index 6f7be14..a938003 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -21,10 +22,11 @@ void __noreturn sbi_system_reset(u32 platform_reset_type) { ulong hbase = 0, hmask; u32 cur_hartid = current_hartid(); + struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); /* Send HALT IPI to every hart other than the current hart */ - while (!sbi_hsm_hart_started_mask(hbase, &hmask)) { + while (!sbi_hsm_hart_started_mask(dom, hbase, &hmask)) { if (hbase <= cur_hartid) hmask &= ~(1UL << (cur_hartid - hbase)); if (hmask) From patchwork Fri Sep 25 11:29:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371189 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=HUyYh6se; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=MQJfwFFy; 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=oqG3dOuL; 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 4ByV884r1Vz9sSn for ; Fri, 25 Sep 2020 21:30:16 +1000 (AEST) 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=GWLjVV56ZdcAJgMYGUJ7ykR8PUOetM+tU5kWIuvPjJU=; b=HUyYh6se9TKOOSoJrlWGGRgAG 3BjKI5BVDpF+l+GvBYw0tUJSkh5SAf1jeG7RdiSNZeshBAnek4bp3fbidQS2a+Aid9hnnbpY/nfha MqFMIY7TtFM3WU8zYEHNYOmTXf9npN4U/vYSqICWjxG6oxsdWhyIF4XeRuy8+DAFU+o4XLNGjjBv1 sQG8s7yYkTbQLRAHUZ9ql+Dl3mnwkLBop07stvhs1x5bbiQsAUIj8JoxSyeU/K8QEycqdlsXXyfHF IKtWIXEcK3JYmbkazuXXh8VH+G6RhzqB9AcJHOoOp6EWPbbNzCvAt3sclpX8TMCZOaIVmbKbvlkMb nav1ob4TQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvW-0004Jm-SO; Fri, 25 Sep 2020 11:30:10 +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 1kLlvP-0004GE-Sc for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:07 +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=1601034558; x=1632570558; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=koxaOWwaN3zB/LHuBZE5qUn8y9ivZM376ZhP6rlr364=; b=MQJfwFFyBGqbhvcq9KMmbd3egqHl336xmSYlPB4ABCa4/oU5vJOh9MGY M6Zuuy0FGnKZVAzO2XPGZD3Ao3WwO+0h0V6wE+MS0+yuXjJIrELISHmhk 1OxHap+STrbcgtz1/wa1KlETW6VbHsLo+KRbZcbpAD1L/xW7ABr+tZ70V PjjVqBo8WWcBByUbduLrtFof7aCg8K0dJsk356X5f3J0vLiuU2lu9tHjV J0Q49vRTOWhVM5svDHWwDMy90uY3WnArrf1lqGBQVXJe1emMfpTPaPy8W efOy4GeOTOamF0G9eip6ZhmHRcLze7eFJc0562aWgYiJ/Z0feGadRA3rV A==; IronPort-SDR: BSloyvt6XwfrwZBG1TPVofmnIh0rq83x9TbNe7WovesEe10toPBZuNuDuOQIYoq3kdVaVpAQkH 5x4iso9CQtHTPbLI32BpMpQrkvbMNVh7ihYvtFrlf6LZifvHcdrUIR+Bv0yNNc54gRxAjdho88 y9gaGGMFHIHTDRpcdCtZKXLwSFbSWeGMoKAFaZoUy/URXrG5049xUuaqdgsySanIT0rUN++YSe 5nQ7b6IAfjRQhY4Srgm4iqaY0lPN/MmABpO7nFlkMD2sH0w5veNbQWnh9Z/5OXjQlh+/KdGzee 5+0= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="251658589" Received: from mail-co1nam04lp2052.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.52]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:49:16 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mBNbK3Hter6hTOb74KyX5RIn/OrJ5UTPbIHkvSZoN3LDvKOEUK7p3DAqw88EwxAcMv56zViLeHgLUXRPFawHGXSYTwqXzzgKUnMqQGxqZyn+PgdWe3WhcbyaWepolM2hodBTrfsx45jkVy2a0h6TjmGPaYzyb9nsWwQiWYJk9yOy32uniyxzMPGbxNjpAHErsDGTGGxucAqyGiYouZyiL8FIzgf+xj3+/7nJMkEvDoQU3+UMOBIPiEDnQ0AoABAsntA3yVDKCU/IQhBONvU60YNerxLLs0lRVdXRsbeRB1xZhgOItQNVNFHat//kD9F5/9zXMalBZ0PLGiFeLioK4w== 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=x1ggmXdTIUyncikoAHGlXrLjH2zzkgFKE0OVpuzOrhs=; b=cJGSTdg93HrS6oMqcvWPJ2XRzsYqizzUCNX/ojFjAxPXSchliFew4ySPp5p+kYLKpxQUtE+4i34ohS1rJurrK9rcGWNYZDTldcJGCbC/ny9lcNyqdJjK0otqXVVrAvlC0Ot6iT7CtVeN7d3vQqvlzw0dyGhOUbF6KciEc+jH7d8XsIf2SR5x3hYM3JUDbusWNhi7Bbmzh4uDtZ5IR/G8UhXUK1IOZSbAu5iRm338f7doHtJY+joKxIPg20RoX6J6twTm7Pw5LCcV3AO+oOFT3tXJWFCEh9pAHQepFGerfHVeYRwwDUY1Abz30gJadTS13T+TgWmeRGAV1TmbcaH6jQ== 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=x1ggmXdTIUyncikoAHGlXrLjH2zzkgFKE0OVpuzOrhs=; b=oqG3dOuL4git3egmWLOswpzlfgRg8akVuYhVT3H6xzZpZo+RTKRxtNifS3u8SwVVjDDoW4w7pez2DgIQawI3eVsMaeyBbik4iPIEyPXiD4tQbdy7XdDROagtJIAJyh9e8NnDYo6eXfJZyWDZ5g75R8Notg86DyY+i9RnyFhIjAQ= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:02 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:02 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 08/16] lib: sbi: Extend sbi_hsm_hart_start() for domains Date: Fri, 25 Sep 2020 16:59:06 +0530 Message-Id: <20200925112914.725846-9-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:29:59 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 865ff35c-4453-4919-a0a1-08d861465797 X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: e3m43NzcftmM/IL0m1RHLqlU2D2Yp1dMZeIqjrXF1DbATdZlg/CLj5xHAHGaCotcu1Wn4zuB1BDw4s7wv1H35LhEh47dJdne3uk+9QtK/WNU4bM5kZDjJ0lmES/GKEEgtJeXuWWFR/RVPv3us8kc3TNys+vQPtleN1dV0yyBZmiWQ615Ikn8p5mgjTQUOxp9sxQCCA1qbWpZmBFm/Xi63cRK4r8LfKGWV5GTVY1D+rCRHehqKEDRfgHKk4/59XXlAvc2wseB9rQuUVlMJFNqabixJAuUb3xxuX6N3x3iW8XbvU4bUJRRnbVra+u8DPH+/sQ7G0xNZS7HSgLa3S62vFadTjyG5YoV/wqBEb6wkUU3u3cYTWlQakj5QcDu2ylQ 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(6666004)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 1O8/qmTDO5UYZlZJ1mOtiVVVtOcQUNltaInJftidBRFXBf579TrOFOTQxhX4kXZ07Fyfj1T35f3gLrFAehGy0Wl9unJF3VDU/zSExi9XD8xmnhH/byms4t1pZoH6Tt88viLzeyg0CP7q7U2E129v/qc/oFqcX4GmXRf/5gTU80Ln/owjLpAr5ie60BCUaonaBrCDHL44xI179oAs8pwwqLvhtsDPP7FRTOULa/IpKP/FnWkB4e1FMAvvqJ+io1OsNAnbPlRkJO/qypqH29x4U/aCCNhp43U85ba3/P5AJTIkGCIzoPMNlIN9sIezLgyh5VHT13ZKXtM4rJvSw2gjLYFW2A8Hq7Rqj4XiHa0wAaIl61mXBufx3dE/Z63hG1ePNC/Y+KxOCkNjDL5ozfQwvU0Rs6Xd8r8E3xa28IhbF8FiBf3NLPKOTHnJjHXKV5zfe2Xi3jAU+ZVh7caFNL6Qs8+dyilSL8OViGbSU1Br9cbQBv9UeoBfph6MM5vLydU2zVE737PMairMJZvwaOD46vOlultbaZ8o5hOE6Azxf8LAhnNspTbkFC2pNYJpKWWmuKYD4qSxqs9Ico/U4aJs9OK5wTOjhweEx75xHNKPU2mWlLKaEqGG4ZyjimgO/+5xlYnVCvR+YOJP2W6dXZkE7g== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 865ff35c-4453-4919-a0a1-08d861465797 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:02.0433 (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: Gtge0abMw2FGk4/5ArU/sG7yGBlG+XtfPvMpZfJ5F3VoFu6K3nKkR5dZLVxygiTFxxSIGhRBDjZQuyWK5nppjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073004_173296_B579B172 X-CRM114-Status: GOOD ( 18.33 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The sbi_hsm_hart_start() should consider the domain under which we are trying to start the HART. This will help ensure that HART A can start HART B only if both HARTs A and B belong to the same domain. We also have a special case when we bring-up boot HART of non-root domains in sbi_domain_finalize() where we should skip domain checks in sbi_hsm_hart_start(). To achieve this, sbi_hsm_hart_start() should do domain checks only when domain parameter is non-NULL. This patch extends sbi_hsm_hart_start() as-per above. Signed-off-by: Anup Patel --- include/sbi/sbi_hsm.h | 5 +++-- lib/sbi/sbi_domain.c | 6 ++++-- lib/sbi/sbi_ecall_hsm.c | 4 ++-- lib/sbi/sbi_hsm.c | 16 ++++++++-------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/sbi/sbi_hsm.h b/include/sbi/sbi_hsm.h index 296b267..4823383 100644 --- a/include/sbi/sbi_hsm.h +++ b/include/sbi/sbi_hsm.h @@ -25,8 +25,9 @@ struct sbi_scratch; int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot); void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch); -int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid, - ulong saddr, ulong smode, ulong priv); +int sbi_hsm_hart_start(struct sbi_scratch *scratch, + const struct sbi_domain *dom, + u32 hartid, ulong saddr, ulong smode, ulong priv); int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow); int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid); int sbi_hsm_hart_state_to_status(int state); diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index 8d5dae1..df0f2a5 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -309,8 +309,10 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid) scratch->next_mode = dom->next_mode; scratch->next_arg1 = dom->next_arg1; } else { - rc = sbi_hsm_hart_start(scratch, dhart, dom->next_addr, - dom->next_mode, dom->next_arg1); + rc = sbi_hsm_hart_start(scratch, NULL, dhart, + dom->next_addr, + dom->next_mode, + dom->next_arg1); if (rc) return rc; } diff --git a/lib/sbi/sbi_ecall_hsm.c b/lib/sbi/sbi_ecall_hsm.c index 3698a41..376740c 100644 --- a/lib/sbi/sbi_ecall_hsm.c +++ b/lib/sbi/sbi_ecall_hsm.c @@ -28,8 +28,8 @@ static int sbi_ecall_hsm_handler(unsigned long extid, unsigned long funcid, case SBI_EXT_HSM_HART_START: smode = csr_read(CSR_MSTATUS); smode = (smode & MSTATUS_MPP) >> MSTATUS_MPP_SHIFT; - ret = sbi_hsm_hart_start(scratch, args[0], args[1], - smode, args[2]); + ret = sbi_hsm_hart_start(scratch, sbi_domain_thishart_ptr(), + args[0], args[1], smode, args[2]); break; case SBI_EXT_HSM_HART_STOP: ret = sbi_hsm_hart_stop(scratch, TRUE); diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index 1f8dadc..c16d542 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -205,10 +205,10 @@ fail_exit: sbi_hart_hang(); } -int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid, - ulong saddr, ulong smode, ulong priv) +int sbi_hsm_hart_start(struct sbi_scratch *scratch, + const struct sbi_domain *dom, + u32 hartid, ulong saddr, ulong smode, ulong priv) { - int rc; unsigned long init_count; unsigned int hstate; struct sbi_scratch *rscratch; @@ -217,6 +217,11 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid, if (smode != PRV_M && smode != PRV_S && smode != PRV_U) return SBI_EINVAL; + if (dom && !sbi_domain_assigned_hart(dom, hartid)) + return SBI_EINVAL; + if (dom && !sbi_domain_check_addr(dom, saddr, smode, + FALSE, FALSE, FALSE, TRUE)) + return SBI_EINVAL; rscratch = sbi_hartid_to_scratch(hartid); if (!rscratch) @@ -234,11 +239,6 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid, if (hstate != SBI_HART_STOPPED) return SBI_EINVAL; - rc = sbi_hart_pmp_check_addr(scratch, saddr, smode, PMP_X); - if (rc) - return rc; - //TODO: We also need to check saddr for valid physical address as well. - init_count = sbi_init_count(hartid); rscratch->next_arg1 = priv; rscratch->next_addr = saddr; From patchwork Fri Sep 25 11:29:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371191 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=c1XiXRnS; 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=gySe444d; 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=kYiSoAv7; 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 4ByV8D0RT8z9sSn for ; Fri, 25 Sep 2020 21:30:19 +1000 (AEST) 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=vHySk7l2tlSnrpFSYtqV+t7Efsvrb414JOi8LEkDrhI=; b=c1XiXRnS2DJA6MZvaaeaz7hd1 hcDDdx7E8anJ0gCITsh1phi/l/t3OaHxKlUCjU6KBhptR7jcO/Eavz6tZSbUQe/Ecki0ky+uAGNQV nHVoGawXYYr8otu2icWvBaYoAoX0/YgibrpDSbFC9OIyHliWlLN35GCV3DeTAS3eCYd3KN/lwJ3rS tzuqfstFLvlzLwHYfa0UOiHdNcRt4S5BS1PdjdiqoEbuElo9z7O0yMRJ18cYLjIYvLMJnCnTTj02i S/LXp7vRNbaMQRxzhwAX5Tqyy7ZR0MWFPJMpJlSyfG5T36aL7hPellyYLb5Khd1Yl+BP+qECBeHSQ wwAk0wseA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvZ-0004Lp-J3; Fri, 25 Sep 2020 11:30:13 +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 1kLlvT-0004HZ-PL for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:10 +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=1601033408; x=1632569408; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=vGJIEYwmfhLoVdcWXBrmPbThZtXdeOzPpHyb0hE0fTo=; b=gySe444dZfnZitgjFTQXz1kzk6QlIEIVf606OgeKg8WV9t/ptoRHT4Y4 L67cUn1lWKIT20IGhjLYA3PSW3jKtrPg5Jp752Z/XHlfGjwcyZFzZo7PF 6kX8DkPMwUs0VxUxrLCxgAYYd5EPPvpHwUQq0roCiR4TLN+kxAYlLhQ4B FGlw79LTEc9/j64FlIvrG2zGWGQyX2cMN66yc5o+sPnDuH2A8FtCAAEKB 5Sqk+u5fY4YrnJ+SVYlCWBCKFuzuiUNxplfG3BjaERfMOE6jVIVG0bY4V 8Fqiybq8qsrmEarN0rj9xTHBHfkWf0/S84WNstndtogxIALC2XJgw51/l w==; IronPort-SDR: Fhjfe/7LJ3++oCkUA6w6gfqqUlI7hIFv8LDG2OQX3eoA0S63CprFUWG2aNVAkMUFp0U50aFKA6 RBj4rFPv2MiGSLrdwmJyQlKaPhzeSBRjIH2BKKDx0ucUaS6NqwwCVpLP1iuj5rkmAINH3V9W3o G3YWs/JJ95i/Qqdf4h0i/PDjEb6iWOik7i9pj5u//kJEsnEW042wIwroBE8wuzQ2wrz+Fvi5m8 m6a2S7Ne/3nu8+Zp5/ucSSKFdM6gd38zEvtB+ghHt/WowRUPW1Sw1RtF2CQQq6L3an/sernoSn Y+c= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="152637932" Received: from mail-dm6nam12lp2174.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.174]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:30:06 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cYBz4JqYPyvFzLJdhO9oeq0gmBOSooxO92jV4ndpCw60/HT5yDDlFNvEXnnGdIBqafxxD6kuGSybjKECP/Hakax648U5BkyX2fAzaGUp4k2dwFtCKvRsFFUQHmhm+LkWCfpF1sCZHwQetTH8Lp9Oi4ss0hliDSB6tY44utTYohTY8ajWZ1ObXHJqfVwXpLBYyIFUPH/J9lkCT1FZPZq8lxxvy7PuinsjtcNweOgUf663QZp2SDa7vFh17aNRbslv+qXEhMoicrchbf/N6vsV7UJy6BhZwuhKWJBdjnMNhcOtLuCsLqWSAQ37iOWeNjyUZyrKBAJZxJ12uRRwVA+HoQ== 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=TOXOUnOnqnOd3IE8FCG/pLJTQt/7vqO2osAJ2zkVLo0=; b=fEzzIrvrf/uY7nm8Wh0hfl9ztpjNdm+JwKFZ8iO5/Ise7iybf4nQO6jbKybASKfMjG0h4Je9fs9IZdi7eu0PCOouPkxXMgMAJsZiee7wlY6L23ZzyEdu0V9LhMjhstL454Z09o/2Hp0p0b09msmf2FbwEpjuLK3REKN+c3IlDOvljQY9x8j1UVb6zLGq5dnxLg1A5+6aH3ihV++Ao1VaOMwZCVWvrKsKL6rd1vfsCZvxjx8QcE0dJCi7lhH7PQj3LZXEn1BU8MrIxVFlNOsoJICRJaJWb90PiiR1quMovQ6FAOoIDPGTGd2ZRSOfjTWWHzbuURH0EHBNqdl2PGIubw== 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=TOXOUnOnqnOd3IE8FCG/pLJTQt/7vqO2osAJ2zkVLo0=; b=kYiSoAv7CWoMZgTxF2nb6cmPGUeX6BOjKGka/VD7j+Wn3mLHCO7S7mXRD1jMPKl13qqxwIh0M31rchUh2OvBgar/P87g1g7zm4zdimk4iVtz9D70XqNmvT1KU1oyIpWyMtol1U4DXz60+P2wOXyxwC5WeDIizsvErqcETKMv/fg= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:04 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:04 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 09/16] lib: sbi: Optimize sbi_hsm_hart_started_mask() implementation Date: Fri, 25 Sep 2020 16:59:07 +0530 Message-Id: <20200925112914.725846-10-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:02 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fe40b4e5-b95f-451c-fd95-08d86146590d X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:1850; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OhhU0Hp/hpEqF2aIR4UJPsJe33pOCU4R3lE2do5bihV+Qds5eu/G+bh4OverYccu9G6YUmjmWiUBy8G1MqjEc74evklh7v4UMEG8/3Uqkru/PsjJvne4mDtWAmhPMnX19+Ri6mWkV/o4yzb/Qf/nI2DhdobGvJav4zhCmFj/IGV0XEjUeh+LEwyfTmfnpt6TwzP+0a7zN09xxTtS41qe071214tOCH0oRJgcET6HGdaFXaE3YczbJNWMWHDLNy8xgcPF0RX6KQ4WbB5xgAq6lb80BI92o7FXj6x85xjctQJ1bVw6c0KIN7Ih3U4R5nZLApXfgq/I3qp8ou2Xyf+beH8jfopAoTOiLVe+r3EkHsQe6G5jUgvh6Dsl3o8mlXXk 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: vvNJQPPhu6QdrFa28oanvqaMAYgCeUH4xMj0SG3V8pCk9+csI5j9IHTjhUD29IZSY/5GGWwHHeUbpK3B8Ubu1bE2iCd5aBH+r1Ecnd2UPQ8hSSHfftWgswJzfP/QziRJzwQsRCiG6czoi0Wzar+fSsWony8OHNvjM0rSCGwS57P0mj0P8xRKOao17FmfBx7c8Fza0v8YPh3CmNxiSdu4un9e0Mqv+awWUb/Ksmzc5nRzoZIJx95gbOpSd5FS+IqgfWWM5QlhounFEzc4ffJm6vm6H3mncd7iVjrl3ncTogrOMgxendfqLTI/46DFuMCvAfzPJoapCcPfQJGApHPWhk+kVYBZrvwpWpeQ5X2JeGyx4WMSasClu1h01Id9vYbDViw21B/6pb3PNtBpFHzOwqjaI9KRfGLO6WYGQOLrfSsgn7fv4AQCGOIv46PVHffWgfSsDrMYzQaNsEyUYVpuEn5GwnR6e3wtzLidWe3rQrWTrdVoZrp4GeccS8ug0Cby/s1hu3gjTs2tqUnRTSDSXePhQSjZeSVZ+Pvl87F54Zg7fO6DCYguGvlM03HPxMoAfoZ29ZFxPx2KfyA1dzGCX0sOy2M3PZoojrhWxUllgjw/Tr9TkL0Ms9tSLYrW6SuVGl119YOJWKtWUjcZBGpfNw== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe40b4e5-b95f-451c-fd95-08d86146590d X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:04.6866 (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: c+9veIMPNGHvybl0ZLTYmXQ/FgqN2g9I7hKatRcMuiBnWdQB0MQ/GalgHcKujufBrBhhaBWU4T0CiNnvR7Hx8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073008_070534_6ED6CD34 X-CRM114-Status: GOOD ( 14.76 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 Instead of calling sbi_hsm_hart_get_state() in a loop, we can simply call a new inline __sbi_hsm_hart_get_state() which only takes "hartid" and enforce domain checks using sbi_domain_assigned_hartmask(). This patch optimizes sbi_hsm_hart_started_mask() as-per above. Signed-off-by: Anup Patel --- lib/sbi/sbi_hsm.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c index c16d542..d443ba8 100644 --- a/lib/sbi/sbi_hsm.c +++ b/lib/sbi/sbi_hsm.c @@ -57,20 +57,27 @@ int sbi_hsm_hart_state_to_status(int state) return ret; } -int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid) +static inline int __sbi_hsm_hart_get_state(u32 hartid) { struct sbi_hsm_data *hdata; struct sbi_scratch *scratch; scratch = sbi_hartid_to_scratch(hartid); - if (!scratch || !sbi_domain_assigned_hart(dom, hartid)) + if (!scratch) return SBI_HART_UNKNOWN; hdata = sbi_scratch_offset_ptr(scratch, hart_data_offset); - return atomic_read(&hdata->state); } +int sbi_hsm_hart_get_state(const struct sbi_domain *dom, u32 hartid) +{ + if (!sbi_domain_assigned_hart(dom, hartid)) + return SBI_HART_UNKNOWN; + + return __sbi_hsm_hart_get_state(hartid); +} + static bool sbi_hsm_hart_started(const struct sbi_domain *dom, u32 hartid) { if (sbi_hsm_hart_get_state(dom, hartid) == SBI_HART_STARTED) @@ -90,18 +97,21 @@ static bool sbi_hsm_hart_started(const struct sbi_domain *dom, u32 hartid) int sbi_hsm_hart_started_mask(const struct sbi_domain *dom, ulong hbase, ulong *out_hmask) { - ulong i; - ulong hcount = sbi_scratch_last_hartid() + 1; + ulong i, hmask, dmask; + ulong hend = sbi_scratch_last_hartid() + 1; *out_hmask = 0; - if (hcount <= hbase) + if (hend <= hbase) return SBI_EINVAL; - if (BITS_PER_LONG < (hcount - hbase)) - hcount = BITS_PER_LONG; - - for (i = hbase; i < hcount; i++) { - if (sbi_hsm_hart_get_state(dom, i) == SBI_HART_STARTED) - *out_hmask |= 1UL << (i - hbase); + if (BITS_PER_LONG < (hend - hbase)) + hend = hbase + BITS_PER_LONG; + + dmask = sbi_domain_assigned_hartmask(dom, hbase); + for (i = hbase; i < hend; i++) { + hmask = 1UL << (i - hbase); + if ((dmask & hmask) && + (__sbi_hsm_hart_get_state(i) == SBI_HART_STARTED)) + *out_hmask |= hmask; } return 0; From patchwork Fri Sep 25 11:29:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371192 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=H8MPWHRM; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=OLlIpaMR; 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=pcumgNUB; 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 4ByV8F3wY4z9sSf for ; Fri, 25 Sep 2020 21:30:21 +1000 (AEST) 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=nLLNu2lPs1NUH1lVgjoRiJqQMIlIDHofWsDxX5NLgsI=; b=H8MPWHRMaJ6rUSwySCQN9ykJL YWRoQnPuJsbT04LdjEQSADcAl8lEbfiBhE6j+b3T4J2dy/Rh0MC4Ay5cF8kt5CxpsDvRLIH8654m3 Hokw4GQGZHqM1J00YwbV7PD9y9GMqvRa15oRnX0QQnaxbCHD5lB4hmHWs3g64hrj51C1qb9XIddWG 789Dg6kQJ8cL07u5NRPdIyxpRh+TsWdsZkzS/bMgfLcd3hfIDoOIjKRSgas4nYFjtDfaw5DrmyK4n H6ndvNM/uD5zg8itbb+ipLYZq4U9ZIOFw+Yd3ZUn10hR+cXHOxgschma6pF108YbUmaLM33jF8zdR F0LMfetwQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlva-0004Mz-S9; Fri, 25 Sep 2020 11:30:14 +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 1kLlvU-0004GE-T4 for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:10 +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=1601034565; x=1632570565; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=xLbjfDdIP577KiMB+jJ1KmvjY4xaFeuK12Z/jgXtFSI=; b=OLlIpaMREtfFkt2GmQcFDoeMra/2g9EO60RJ+RCeGnH0D5MUvNnJaNzW lzz7sC3YGHxwdKgJBJMiBFxJlWqGedGkBZdAezvUQQVfaQmtMC76X2jeL 1Yyhndgv/bB/KZar599MOueCH+xO+p3nSWLosj8rbgMsPQyPYGmEGZmUW K9huyKlOT9x3oxWaj6ApHaVT5Se0bZPvkiS/VyLMXBq6KqykNFL4N8J1V kQWcyPGGg1Z0bNK3POY+vzZCzaqwOi2AuwOnhtYVcZ57D9TFrS/m/qXdY FdcfhkMsC+98KRGZmHpntNavLVOgM0Fv5IMS5RGdwFUxHFDmqvS+shHsn A==; IronPort-SDR: /0uosW9Oj3gIV15C6FOGJ6Co4NQUZPx61WniplZEIayFSA0cZlXQmIWmmECmcg1gO8hEHaRGtc 4ElIhDZ3t243QdM33mPLrVY1bfzPvJS8XW0QrS3oVVnRgA9vcm9CLRVvp4WQ0045mW9w03m2HV DdvpuGZ/ss1scELG8exPMo76eiSiKtawg9MdNClo7Zp9VidDZeYul0fBAy/dvcBqp7Tcqz1RkX gXoqlV8ltZHkAHRPVOfDI4LO36lXYRIE8fQ7REnxk7Hgu5I/BVs1jrhOjaOZQJvjXeZNJ3Zft6 yL4= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="251658594" Received: from mail-co1nam04lp2059.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.59]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:49:25 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e4jssTSl/LzPp+8uYt3jQwJCSACO6HEKshmBXIv4Q/WLW+Btn6gOZmuRdWn1oAqrOblvBzf3dXWA54Jp3i7RiStEpDt8+Q9fCbuhpcWpN2DF03shMp4U9oratoB1LMug1TPeV8IIpdKHupK0axHDFhBZ64RXgppwjfv4r8HpnSTG8KkUpmiMXLTDVy+14WfTtt6KR4HILxZKFT4EGy5wstvlRqKiGJrMsgaU5FSJCUFL04eJcm+9lp82sXj0kKgZ2CImsBudPe+tEUyBrmdLMZwklyvqJzIW303UY9temXJQMlD48OIqj2hAlu7MCx8JKJLHfbADfJCLYtOqVWJMig== 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=QP4+bUEUkUgkkRytG7N2xL96h+D5rTdenRYgGfN4gvg=; b=K7lGBaB5vbxvB+UBf6+BCasS/gXpRdosyq8c093/ZnAyB9AX6//rkxnhca6b0OMH/g2L2oqtxJAjNZcpDbkNb1CKixT8nzLbKXLhG1VF8kEICsefGCAVm8TqnqXVTodktokKWIEzmUk7M4KwNLkMkeR2tVoRhw9ZrQkJrLmT4CBXfn2FeJWU/tmDCdYq+z2eHH7gQORh1UzseQU7tgtfqQ/++kOb5J8tO1ILwVrtqFQRMdrlQjyglandBJT0hZH1BNKVkjXinIzAYukOgfLyDU4uZsUAybykeVr8/VWymXwCX9dMzOx83q2OcODA5BF6yTjF96PkAJ2M7PP3wDML3w== 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=QP4+bUEUkUgkkRytG7N2xL96h+D5rTdenRYgGfN4gvg=; b=pcumgNUBDc4SasdKrT4etIgpLgut/zTDWcAAY5wrsH2PHF1QcIJFlupOTUKBDgEzLo4PRow42/nsDqxCG8fPovLbY9pEbL0kdexfeH48FVWspdqSsvyBJ8ngzXicBh5Xw6Tm6efDxVElLPOBMsHivNimyY9xNljgLb+Pzwad/uQ= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:07 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:07 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 10/16] lib: sbi: Extend sbi_system_reset() for domains Date: Fri, 25 Sep 2020 16:59:08 +0530 Message-Id: <20200925112914.725846-11-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:05 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3746a0b1-39e6-45a8-3d15-08d861465aab X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:270; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QaKotHFE6FwynbqusTpB+vu3Mlc9cRYUBs5H9UwjRzYuoxPVLE4FfN12i34LncdZQn+yhwGSaXF892N1MtGn743zywUyeuy3NFJwh1urUijF5xSwBahqjUYHvSGkpWdCTFu54ysf51oiypYVsC7LtdV4xe4nVkyR0lFkut8dQ0wuuGkTaRo22YJV3KW/zESI6eQ+FC8avpLR98C+buEI+SvH4hgjAdbCmJHnYp4HaQw0PKG9WJtEA2Dln+TWWrr/pdN6pWRF5DxeTHhX5lDQxuCqMRFJ5tXoOxZGboMy1Lz2/TTxPOBfoeg9W4jR4isL+6DORaAzbxjl6BdOFlnThVMplJqlLDTDYPSDfczb3iAdeH7917/0AGsz4fP8ioRN 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(4744005)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: scYSKNVEHbzXkMphFFBZNrb7IZc6O3eWqSdZPllm17fE2mhruAj6tSP//ArcYN8xUa0iIlxyJF1abYLktRuo9WsgsnGTzv7HcQA8wK7BxUo1TeA0aX3W+njlOswCpKj8c9ualoPYChmVMtYBRPV06KeLuef6D8r4GphJb9P8DIgFIQOIhxEpGuD69x+xoPCZmDE7CV10SwtcKiL2P3hkUr3XyIBEFbuAV2gWuVcgfGKyYvuWYT9i8MXY14k7WqoUoyo56wLJZ2Sk51digsjxVTlpxv+FGyFkxNOm0Nh5x/gyLC2UvJkFIYxeGwiU+bxigcYH/Hf9vts1rs6VXilNpGLwn5xk8E835twb2OoNu6nluTr0VsYUzS2JwYV2LCWo9kcwHuZQ4kzwKFTSl4cKQc1Yb/tMRcSqUXcPVidOShxc+8RYkDtS75VT8GJC1MNSKP6sUf3QLBr1Snson2aC70eqeSKy9B/UwU4iiWcVP3aoBkT0xNOXztVwdSUVcbaE0+PHxUW4Dl8/7GKsDz3GtrtFRP9P0hpsRZ+k3LLWI1EoUNUz8tsUiCrNbBPKNe+MyKVHCvprIRMe67Htg4gLCk+NyidiZM4J79hep58LBfctZpuCzFiled14AVWASGR85Gfvuv+ZW1jIcqxckZ0kUQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3746a0b1-39e6-45a8-3d15-08d861465aab X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:07.4818 (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: Jh8WctAs/S1dZVaHwmux8YFDQNIs4KeYKv5swBVSAiP9BGI8ZNR08j1DF0ieMUzo1L9ARROuv5CsnhykTymumw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073009_176202_7D9275E9 X-CRM114-Status: GOOD ( 13.04 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The sbi_system_reset() should issue platform system reset only if domain of current HART is allowed to do system reset. This patch extends sbi_system_reset() as-per above. Signed-off-by: Anup Patel --- lib/sbi/sbi_system.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c index a938003..96290b3 100644 --- a/lib/sbi/sbi_system.c +++ b/lib/sbi/sbi_system.c @@ -37,9 +37,10 @@ void __noreturn sbi_system_reset(u32 platform_reset_type) /* Stop current HART */ sbi_hsm_hart_stop(scratch, FALSE); - /* Platform specific reset */ - sbi_platform_system_reset(sbi_platform_ptr(scratch), - platform_reset_type); + /* Platform specific reset if domain allowed system reset */ + if (dom->system_reset_allowed) + sbi_platform_system_reset(sbi_platform_ptr(scratch), + platform_reset_type); /* If platform specific reset did not work then do sbi_exit() */ sbi_exit(scratch); From patchwork Fri Sep 25 11:29:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371193 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=sJAoBcDQ; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=VpLbJMJR; 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=cRf6oM0H; 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 4ByV8G583Qz9sSn for ; Fri, 25 Sep 2020 21:30:22 +1000 (AEST) 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=94H3+tybMSnY98Q0uSRJyPr85uEd+MRhJ06qbSlJ4v4=; b=sJAoBcDQHf8gG2SG4ehMNxO0+ OYPtmPMyuTZidJu8he05ejN+C3a4ySmXDoTh9JFRZZAz26I/2RMgO5EmLiPrc3ziyYPolbNXdoRmV 2mih6wb5Ul1hyPdDiYVAbUoxLfslZvaCr6Ul2Ph5F2tZnek0H5oMEjUfHAyRreJ6phH0J5rLFoj3D mZ59E13oBD2N1g6/371uwYXVgjs+I1XP/BweZYx+6Jn92+Xo96M47JgochHXM7Tp4PuzucHxl90Fu v9QyrpoqC0TAz3d4X7QyTjx9GKIPdXiMlm3LA6ly+HIgVIpLwQ4uNoqBcRK7z61Q437GIPdROOAF5 GxyqzzcgQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvc-0004Nz-0h; Fri, 25 Sep 2020 11:30:16 +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 1kLlvY-0004Kl-8K for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:13 +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=1601034571; x=1632570571; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=+G7n26optR0cu9iO3RmNRwqL5hNzUOQZPDdWi2TXcrc=; b=VpLbJMJRZs2F0saoOl8BdofyYPyXL4P+OZpbSNrdL4TBnhgsnWBY2RZz bGryHGGvRTV3UXGwOJ1R5L/5w5WDq09Dr62/u2jWOUijlehQ8w/6PQ4p5 lzt3zfmEOZ991RkaXHwhR1ljgYLTU46iFtZC2qme4vfwJgQGHJbQwrICb t+BaiqKeY42qWXM/AAhAhn0mMQdCdDWpqgUBfXY4uZwf1DBh3P16WvEPy y6lY6qRdwM4GOzGzEbpG9V9Y+QcQvmLICyITvDTKMCT0HJGX1hadu6T/O batb4cxZ5bGR16ORUnlu7FmFHRWe/H3TTMk5kbyzCLwdZMaPhZb7CFuYJ g==; IronPort-SDR: nLp3BKM5NsqQYczZuj26MwRMSi1VsoskQncl4e/vIQCVyorql+HHxa+GoI6DCzOG6SFp8ri8qz ENHq+7J132tLQHp/AY4WRtEb+o0EtK17ujPpA46r8mzAvQDw4MprUBj98pLPIVMORwgbOtQCwa BTKJOHJ1cbgqbjpGvO80BxPbiyZGemnSd5eUYPDF5c2KHrNBuTi8QLfMl3FkIe6e5qVTC/6g+3 07BObOBanxODkLtCtV9xgBI92979rglsrACqGGlUvf0EvVE4OTN7P+dytLM80HOLyqDv6kvO4x YZ8= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="251658599" Received: from mail-co1nam04lp2057.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.57]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:49:29 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l4WX35jtQx9Xv/ySmgRb48v+KNi8opXvUkNseQU8t6l9Ima4EyYFkr68hPfybyECfQFQJIsS2UypX4c2zA7dQ+3LjgvMvs+NK3nV8eZ/5uapjYiGrK+JjKa2/uacuEBJ/2xZTHtAVpwQy13VRiocU5kQbq5i5UGUEKC9AS1H3Wi58+7K+q+XupisgB+o/ooE3XcXj6xAp/wBL88RcHuI8TxKSz7ylp3IFWWSorx4sH8QPNxuI0t4+jEHoNWMLjmkDUcBtr9VlAVkc+FEht5NdtFvRhwMy3JXJkz1Tuy3zY/nXpcC4CkVwcKDoXTauQYqEFK9IF6LwGesqPTKjIz6xg== 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=doIMOrr/bhkUpRWQkCD/9lghcslmDD+zsWmHK74mj/E=; b=KoydpnokPUPlC+wh+zYn4QZUH+QSH+wTNKCHNIN+5b7dIh9lNXtvz7QnmGg6xhSUSxZROnnYiXJdYm15zUkf7z5Re7qqMUGO81RVyI/ai9g8hOKNnpd3Jl3jwJVDJAou4Kvcr6E7fzLvufn9kzSE9X1dtbQaT9t9qTJasVmsE23fwTK6irs/sUiwC7Whx5z39OHwUVulr1pHIIPQ64sOzaIXtFeHhIj9dVcng7mn+E2ssLsjZVlx7GzxRug7a911uI770XnnNQydx6TWbaewAXlV16T1aBIZdxZ40l2i90ybqToTcqX9RVCZjH6EBrnVgnZM6JSl1cAVTenDArRIiQ== 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=doIMOrr/bhkUpRWQkCD/9lghcslmDD+zsWmHK74mj/E=; b=cRf6oM0H7QtF3LHnCAIX4ZBNputmUqusJljnFcYblNcWMtkEjw48VN2ZiVlMyCHnyY/+gDd3LDblHycQ4FodGmeaMioYQr7wVj2fDs/RmxjhFVnswbNpuAKSt5emxIJ+Xh0nGUneDVpjYMjipPCEYIgRmJBIeT3+md/i9WDy+OU= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:10 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:10 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 11/16] lib: utils: Update fdt_reserved_memory_fixup() to use current domain Date: Fri, 25 Sep 2020 16:59:09 +0530 Message-Id: <20200925112914.725846-12-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:07 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 02e95ad4-e758-4982-f922-08d861465c56 X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JUvM+3n5XqwM4NwCQePeb6N4AWys9CCaY7zNoytG9NymrpZ703ThTMZbjIW9wfU9/WV2Y5qLuvIdACIJO1Yx+9hrT1dwwaM7i7IMurp1Z4RQt39nUnWxx3HmXpspo8EGuP/FHL4ZZ8PofhcrVRAkJW0vYmACzIALCYBofVqPcJoMkvBlzcEXmvbdgWw6/PdXlAAPuZQ3hNV7x/dkxkNwytE3FJQjuI6lgYdV83NOkj91uHvbJumOevIJLI5sULUy+n9/m6Yt9M3WxeWY9YJqj4kHeVKRVeFfM64DU3/mIJdOWUEG/UYoUuoc92MA+za/EDQQGH7pt4mfcphj2FuMbbKTwJjATldjOw5EHuRQeM8Y7/RsajoU3mnXYfFk8gJV 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)(346002)(136003)(366004)(39860400002)(396003)(376002)(6636002)(55016002)(66946007)(86362001)(26005)(1076003)(316002)(4326008)(2616005)(110136005)(44832011)(83380400001)(186003)(956004)(478600001)(52116002)(7696005)(66476007)(66556008)(16526019)(8886007)(2906002)(15650500001)(5660300002)(8676002)(36756003)(8936002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: igKFPoFfUMKPM0SDeGDIcaxERO22HrXEICVAiyGd9N4+aOfjUNHpT+MK3Q+Ms0h7yotqie8EKHMno8cwJQlenHM3t9Z0AS7BBJD3twk7PD07w/ntezq4D2BOgLjZWd0N0TgIttDL8qyK/8rhKv5NJJYlWGUrU+a1YuW5GMHJRjXd9Aari5sSsPpvvHJumFjKW5MDXcS1yxo5Qr2L7UfzOrqHgn1p4Acz9s7dLyvP7GHkbWUvT1/mG8Ccxmhz1PSBAXLAHPmRy0m9uoxKoWiBA9fw1qW1Gvk6dSzDQNJl2hMziLG6LzHtqjQsO/UKy/jDW4dMI0h/9O0kPEl5mRI2T2DYC5kaSfyyW+prH3rm28i9CAoi4ZDL7cRFeOSPsxMSFbIR0vwQGmZ4t6y8iiQ60sMZoz7qC9YaWoRUMOjFxThGmr2GUdK1Z8LdswsWsGFwzOO4BhpSkcEG5T9d8+q2F8BviKDSPspjXERzCgpuLegBt0yzHqjAQnjQwEa8V3f+D8xPdrRu/+sOikx7pvioIyshftlHg48HOzgV0yAI4PyKDbt38eZihJrgcCU04MTbESL5ReVjzn5dOhA6DSmHng7+FMI5TNbTiOSeFHm2MhMKXr91QmQ5flZBm7y0Jr6heh87G5NtbTz/Q9pncnxkEQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 02e95ad4-e758-4982-f922-08d861465c56 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:10.2011 (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: siTAPeTfjV8CQ3XV8xzC4qkkVNSm6ptdHXZsw9Tv1+Tuz1VnSS1u77WLBnyA8mrbOGeB4mxldfQE+Y4yKMN2uA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073012_492106_7229A4DF X-CRM114-Status: GOOD ( 21.61 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 Now that each HART is mapped to a domain having a set of memory regions, we update fdt_reserved_memory_fixup() to use domain memory regions for adding reserved memory nodes in device tree. We also change reserved memory node name prefix from "mmode_pmp" to "mmode_resv" because domain memory regions can impact other hardware configurations (such as IOPMP, etc) along with PMP. Signed-off-by: Anup Patel --- lib/utils/fdt/fdt_fixup.c | 47 ++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c index 8f554e1..e9e1dff 100644 --- a/lib/utils/fdt/fdt_fixup.c +++ b/lib/utils/fdt/fdt_fixup.c @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -97,11 +98,11 @@ static int fdt_resv_memory_update_node(void *fdt, unsigned long addr, if (na > 1 && addr_high) sbi_snprintf(name, sizeof(name), - "mmode_pmp%d@%x,%x", index, + "mmode_resv%d@%x,%x", index, addr_high, addr_low); else sbi_snprintf(name, sizeof(name), - "mmode_pmp%d@%x", index, + "mmode_resv%d@%x", index, addr_low); subnode = fdt_add_subnode(fdt, parent, name); @@ -153,10 +154,11 @@ static int fdt_resv_memory_update_node(void *fdt, unsigned long addr, */ int fdt_reserved_memory_fixup(void *fdt) { + struct sbi_domain_memregion *reg; + struct sbi_domain *dom = sbi_domain_thishart_ptr(); struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); - unsigned long prot, addr, size; - int parent, i, j; - int err; + unsigned long addr, size; + int err, parent, i; int na = fdt_address_cells(fdt, 0); int ns = fdt_size_cells(fdt, 0); @@ -203,34 +205,29 @@ int fdt_reserved_memory_fixup(void *fdt) * We assume the given device tree does not contain any memory region * child node protected by PMP. Normally PMP programming happens at * M-mode firmware. The memory space used by OpenSBI is protected. - * Some additional memory spaces may be protected by platform codes. + * Some additional memory spaces may be protected by domain memory + * regions. * * With above assumption, we create child nodes directly. */ - if (!sbi_hart_pmp_count(scratch)) { - /* - * Update the DT with firmware start & size even if PMP is not - * supported. This makes sure that supervisor OS is always - * aware of OpenSBI resident memory area. - */ - addr = scratch->fw_start & ~(scratch->fw_size - 1UL); - size = (1UL << log2roundup(scratch->fw_size)); - return fdt_resv_memory_update_node(fdt, addr, size, - 0, parent, true); - } - - for (i = 0, j = 0; i < sbi_hart_pmp_count(scratch); i++) { - err = sbi_hart_pmp_get(scratch, i, &prot, &addr, &size); - if (err) + i = 0; + sbi_domain_for_each_memregion(dom, reg) { + /* Ignore MMIO or READABLE or WRITABLE or EXECUTABLE regions */ + if (reg->flags & SBI_DOMAIN_MEMREGION_MMIO) + continue; + if (reg->flags & SBI_DOMAIN_MEMREGION_READABLE) continue; - if (!(prot & PMP_A)) + if (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE) continue; - if (prot & (PMP_R | PMP_W | PMP_X)) + if (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE) continue; - fdt_resv_memory_update_node(fdt, addr, size, j, parent, false); - j++; + addr = reg->base; + size = 1UL << reg->order; + fdt_resv_memory_update_node(fdt, addr, size, i, parent, + (sbi_hart_pmp_count(scratch)) ? false : true); + i++; } return 0; From patchwork Fri Sep 25 11:29:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371194 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=fZk7b1xO; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=GIQAMc6E; 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=ALW6XtAk; 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 4ByV8L39RDz9sSf for ; Fri, 25 Sep 2020 21:30:26 +1000 (AEST) 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=YRE6Pv3x5Qr9F97gQUoPmae1nTZvyg3J/R53D44l2g0=; b=fZk7b1xO1kjPvMLvFY5lDAkQe jVsDeoBMG3FVtZExe6NP69pmRq5ETevol8MvI6B/f18tVe/VN48YNIMBeA7qOtygXRiJUDp0bEg4A S6MbRnnC4HzCkLluL8kvbTdfw7M1BnBDzBsAbC0EXrIk7VJiYdmCxTIOV5ILEYUN3CvSQyD7y7jUN bM5aSekL3wRCJe6kqNnIaNQ21liuCCVK6J3hSrDf18iQJP+rXCtX+oUQcMZEB5Y3pq/zXrPPsRCjk 3bpTqpj9e2i1ZuaCznsd2vQHzvQNy5+DLbcbxY2y2wIB3X2p3n+BwV/rHopuT+MaiYwIytHcjrCZH sYWlMLxfw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlve-0004PG-Mv; Fri, 25 Sep 2020 11:30:18 +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 1kLlva-0004Kl-1w for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:15 +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=1601034573; x=1632570573; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=p9RqhbxP8nRbEujzLDj2a+0gNVkVZdckGh7nfKbI1Qk=; b=GIQAMc6EMw67XuiWvzHZoBz4yOcDLAETN17qx9iQYjn/z4JeLV6FFAQh IN593hEBu5t/Pw/SO6jKUvdeMDTVpeDTi1NMIDGGFEga4/SoHhc4h3tcR mpAks7Ke2LpC2vPAy2k7YAv5YEMgEhrtptCuxz8B0R//VH3m/ql3TQzqF k5yhUSel89rD5kQG9/Z7WdOHTeaHDaArOHGvp+cvaDEWXNI8WueVTJJwm mDx86Y5aBNwhNR5UZaxNQAsT3TfEtse0/+qe7/gjC6eEOLLznt420RF8Q WAqGLYmd+o4tA9iaourDSAS2Cyvoz4QiAE2HYptC/fLs30yGeec+kZYTk w==; IronPort-SDR: avMqBLX9DcNp/Fii81JN7EF8Rt3RRB5/+BD3Zy0GxYldpCiXTymhkpQLqEzslcZxxdMCDIHQLs hi0vVuly2LZzIL3Mh3bDhe2n14+cUK9Qgp2Aau2JmqW7m1W8qBGOWwT5kEKLh4RfegR40twm13 KopPvo16t5bxAr+lxYPDcpH36rPuw5CcAaEC6SD8MG2RiQ7HnOdAVnTJq8pwR48DlMcfIlhupM HDjXJAeAVDilpsGetXHF3cpG/++7Io+AP+2sFfr9l6FrfMi/MPI/xzQIGtn3qizrWFZiPGbOD9 CXw= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="251658602" Received: from mail-co1nam04lp2053.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.53]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:49:32 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EeT0/1acMG/slXJAtCjvEKcFXyROflN3G3UZ2CrRx3xZ708X/QYxlLhjDhN1ak7LHqVA1VhZYwctQau2IuIOJZ/Y7XuzscTMepgMfiZUucLWlVPrZGFv5Col/+Ry//nqW7SkfpZi7ob5mVwXGd8xafwV7pAZdpLQDDn1qYsQ3i54txjJRahxRFaZ3u3Jv3sF0PjmUCYTnpL1jVVgXkIpzNHISFLi7U3c90qJW+GHAolwWJIn0HBFbnYaOEmRLl5+7MM8DRiwNPeghWg4CgoTrOvvX/bvnmHxuRkLwP2s75CCQBKDvyclfOD7340HJxy1Cm84Mp6jippcao8IhbbkzA== 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=E9AK56gSw40VE/GmHRyt+sVZ7DdhOlvKQOiACdq4Lho=; b=MC1ThRHdAFTdXuyAs4+Yf+Ci3k4ShbTtvyIl+mefFpxfP68RbKkc/qbYnMRSTrcCaR/7l/dXullmUiLTcTkJyLmjEFiicNWLyhSpWjn+kYoLhbq0+1oqo+xtKjdaRAnSjz+Qb1sUE3DYZ/sG5tWY6fdMW1KXaCBj6wpO53L+S7u/Ds8mFoO+ONuJWPXAnlXW+wxek1t39l20rp6P8qOUli6tEMIXsuZ95mU6HmyyLF3X9Pc/sDObqKJZLYJbquJpvvv5R8ASsHwO4SBIDZyruReZoFW+lvfgXPW4LKQHvM4PbRi4l5rqP1tUgsEcFcNfYEIwZ76M6FnmMGOV9FEYsQ== 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=E9AK56gSw40VE/GmHRyt+sVZ7DdhOlvKQOiACdq4Lho=; b=ALW6XtAkvHBR0rh0D649dNNrO0jRCaEiQ2uk/8jM+QSH1XLedqqQQyh8t5nMLMV617rrDWcgoCDiM59PwQGMld6uyDIeVT5yNIUvevlddW00En355pg7+e4CMCpvB7Mbp+tCnWY2qMQSte4kRgja/OCn+GZ8TiCTCXXCEvY2Nro= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:12 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:12 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 12/16] lib: utils: Update fdt_cpu_fixup() to use current domain Date: Fri, 25 Sep 2020 16:59:10 +0530 Message-Id: <20200925112914.725846-13-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:10 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ead49df8-b83d-4fb2-040d-08d861465dfa X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3HyrerMI+dLQm/rrf6VsOeplp6fqTQgAJyU+/iFKXT5WFxyq5irWjuhaI3Uprx3fYEDfvV8XR01AvEXvHhuvuAmswVw7Efkx58tkpj3gB5bnr9e4bJX4jqv8iOy08djtjyWoY0mNDLcakXJZFlgGlkRupZ44wWi097Nfp+LpgEEtVwLcES++NtDMdYpBFFlUKKsAlbY1BAajMuv5OxDfpUqBV2kUs7gfB8urZnyBDPKMjYYTVSZn4zw4uy0xljr35i+jVgILaPlaZzqdo3gy7T0/cLrDKpdnXawAvoAahLdbC/23ptabx1gvkdHFDovUlaQ9K+EYZwEOaIf/3hjsNGa+LaAILcyLWwaBzzxg9nDxe9TlDoXj3DZY1t4fP5oC 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)(376002)(39860400002)(396003)(136003)(346002)(66556008)(66476007)(16526019)(8886007)(8676002)(2906002)(15650500001)(5660300002)(52116002)(7696005)(54906003)(36756003)(8936002)(86362001)(26005)(1076003)(316002)(6636002)(55016002)(66946007)(478600001)(956004)(110136005)(44832011)(2616005)(83380400001)(4326008)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: +kfYQWUtQkMR/MzdqDtrtCum9X6ooUweVFYETteyzj615HYgSIT2fN2Ki/7VnsedcWN/GkYZZ6fDJ5YcJoHDmmIKZcZ0SHDbX6bIimP9tQfa9CWOqPloepFOu6jeuftE4CeaxVlFiuN6rtW9UrPsEhzKYLHmpJHBsE++YrEv/v8t9L15k2c5Knvz0WYCrwo7hrGkv5OaVEDSfCpHHrwftpyHNwNDvpGpFoy1jjLt3xUxnTJ05yMA8kYje20MSNehcevzw1SVrVSYoKAG7uoT2J8mi278XhVYGS/nqQx/llB3rA/ejiw01L4uMA+47l3h2ozppQ+f9yWmrdlm7YKkh6Aqk1b9hCBBxwckK39xcMWVK5IVtYuQpwGhC/2CI2/PNon6/+dY/6fQLG71xM8PyneFs2jWSzFiXyai30f01mnOMba+HdGrGNHlSQzu/QeWUxkEdYy+q4FWFWWNy7wVo/kwLPCfjYMdm+Lz4u0tKeQlW9ci1gFjY8IUBEjfgoDONc28uyS1jNsm0bZJ5hLHmPyPcJOHacIqIJrFDnjdh+UETeLdDHCI3xmI4FxmdLmRGAd+jD5wXd2LsFPvK0NiNtPwuhqoysF1IA4HmqVlOnfR1IoyP0Ghp8KMJQoMVaMmL/bGeR0Tc6Rg0z34Td0F8Q== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ead49df8-b83d-4fb2-040d-08d861465dfa X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:12.7264 (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: Jqyl/KVZncMFVR0wLj7OgMSvza+FLn2KZF7q7wZWKLuvj2+4zLoNxY73CAbzNKqFBJ2YZs1pYdOl4aiRJtG9wg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073014_325699_8F536DA5 X-CRM114-Status: GOOD ( 16.86 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The fdt_cpu_fixup() should disable a HART in DT if the HART is not assigned to the current HART domain. This patch updates fdt_cpu_fixup() accordingly. Signed-off-by: Anup Patel --- lib/utils/fdt/fdt_fixup.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c index e9e1dff..436179a 100644 --- a/lib/utils/fdt/fdt_fixup.c +++ b/lib/utils/fdt/fdt_fixup.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -20,8 +19,7 @@ void fdt_cpu_fixup(void *fdt) { - struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); - const struct sbi_platform *plat = sbi_platform_ptr(scratch); + struct sbi_domain *dom = sbi_domain_thishart_ptr(); int err, cpu_offset, cpus_offset, len; const char *mmu_type; u32 hartid; @@ -41,12 +39,12 @@ void fdt_cpu_fixup(void *fdt) /* * Disable a HART DT node if one of the following is true: - * 1. The HART is marked invalid by platform support + * 1. The HART is not assigned to the current domain * 2. MMU is not available for the HART */ mmu_type = fdt_getprop(fdt, cpu_offset, "mmu-type", &len); - if (sbi_platform_hart_invalid(plat, hartid) || + if (!sbi_domain_assigned_hart(dom, hartid) || !mmu_type || !len) fdt_setprop_string(fdt, cpu_offset, "status", "disabled"); From patchwork Fri Sep 25 11:29:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371195 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=EgZX3NYZ; 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=Lq/1+LHG; 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=XNrSwxdD; 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 4ByV8R2ppbz9sSf for ; Fri, 25 Sep 2020 21:30:31 +1000 (AEST) 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=BP9aMiYuf61TGDP1s37btJtjsAObMVUqePpx/y/K7CI=; b=EgZX3NYZOdFgVBSOc8A5Myo1Z 50tRpPcoQcIal1KAgBYNvz886FMyYjZBCz2SRdI+tD3sTepn8Xx6MEvKQsnxjkpIX51U2zO9H2RWs YyqkwqSZuFaRaNBh6z66qeiJOZ3Mt4YLeQxBmPApzFMJCfHDlqoGfivYi3IbpnzQi2qhIiFX+bi8X Zn8Trw7XC3q/lG5+indH3AFt7Auz/RE19QHddPZ6AfSJ0+plqBT1fVASE5XmrPB43OUDKAVEaKWa5 Lh0waTGLvJaAo+zcDahXO/2mPPbCdhsGSc0oQinSoMfa1T8G2lWnMYISqDmpvv35qDOIZuhlqH4Ox Q3+NcJ4RA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvl-0004UE-1V; Fri, 25 Sep 2020 11:30:25 +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 1kLlvf-0004PV-Ht for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:21 +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=1601033419; x=1632569419; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=AJnECo3exLPpj9Zpdy5rDbD+lcUNiRSUTDVnSE1Q/n0=; b=Lq/1+LHGyd0kclNwmBuF6JKNsr6YX0+/kOJFCrucCt6YTNvzo2KeXBGw EMNycOz8yywrnWYzZ++Av/MllESgZwyAfM4QJjA4Pz1KNYcqV7pLRhmBh WGzpxbvWXplVsKLzEEBbwJnUBc0/Y2GDquYH4AsWpLo1aNSAsIHymlLr2 fdD2urU+OjNLFu4YPsQINEh73yoVIe9mXrRTy9zOK4Gqla4j6YkiwsVy4 xFlA/aRYmrf2fWaaJW0V+lLEGDHRP4o+ciDzAYOoDF6nh+zMpPDarcrii ts55x2pya/dQQVz1xM8p9aK20gPJIuVYP8p8NYlDkrkrIr5Jmx0BlyODH Q==; IronPort-SDR: 8CCP4YrJJV3rYdAdAFQZRr46Qw5w0iqCrjmv63XptioB/2JWPvmX9EASgYB5QmWondOmO1ZQdx 38u1NLU0T/aPJHL86SyijPDpQVGRr38XrzgvBabQznW/xNG9VXFl+e8tVUaO1369fhaOxZeR9h F3aB3LwcngB9sKOOODlZw6jWxBXaA9+fZdkv/+qW/lTUNsu9ZPRlIynGuphp9DxdfVaM7UDXI2 SGFR0G8LOfShc0GyZCgWqs3BlOqQGYUcHxcOkNai0NRbFW3+twZjMVcCXrU0J1TNQrhfLHYmEj 7TA= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="152637950" Received: from mail-dm6nam12lp2173.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.173]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:30:18 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=INOAArcYWcilDhZkzfzu2GsGjLpoOV2RmmZjh1blCgMjjDKLOpnt5aHZG+tEo5fHdR5hSd0IuKKVVRCYXMTvO4uNCMTsJjttby0GZGgKr/OOK7EMaTnMkrXnkar0DAJfvNzcLpbegPp+ev1f1V/Ji2lbY71xGkoY4rp9BiXTCjtxXMNbf2gy4fRMs3nv97HP4A+nmbuf2mAFz0m8k2kea/jmJa5rIp06zbOEbMXIO0gFBeBkqST2LCD1tknjaTLwKB+iYYFpGdTeltMTfS0avzW0utMAAgPuuTIfH+5fWQMIIT/K9cbxvbuShQMDiOwhSDiSuOcHu4aGEciaNfX7Ig== 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=geAa8tedADcNkq1ztkAMYCmDxmJi0ohZ5BuWBdEjBko=; b=mwyCmoo+v1HrfA/hNxMbmYRHgewRD0m7II0j0iXjoyuNP9qxHSSvOgsGmdQzP1Y1UFxnPXsc6AkUWIFycYQqWfxkIwRHBVDtJzmdXhz9Jnmc/I8UD8RV8JY46XLBDCKBOpCs4Ldpvx/AU++4f5ShbE1aRNpu/wSd92GDdeaPyYzgOuhC1w1m0GSBev/g+HHDs9yWK2Zpooy91P8WOkBamoWRauYvv2eGw+hrDahLVx3VDh92T6KLmeqfBCgz7xtmia9nD2gC6WpW/GZ/B7IvIWbOKjihdIy4wN/DoHac+LrXzX9+MdodFmCwgN5e+aXqo1O8J1a0fJkFZcLf/8cwkA== 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=geAa8tedADcNkq1ztkAMYCmDxmJi0ohZ5BuWBdEjBko=; b=XNrSwxdDy4ty4tn3mHW9ViqfWT+pbpils66hm+grN4FkBTvppkT8reEkHEnIM1kVmMdqyT/uZUz+xo8puAzZAE8e9q7OtAayNDaNmRVGCkmGIV5xWU1eDXKvHK2Oda6KLaoo8ElZMMh+dRRoKr83acukQUgK66F9891s2497k2I= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:15 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:15 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 13/16] lib: sbi: Remove redundant sbi_hart_pmp_xyz() functions Date: Fri, 25 Sep 2020 16:59:11 +0530 Message-Id: <20200925112914.725846-14-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:13 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fc45351c-849e-4bf5-33ab-08d861465fb8 X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k1F0oYV6tfGCr2aXhdNPfIafOyU4K/uCzeLjCFAptDX1N2gNV/lMSWs9SjUEV0gt8oXiAuSuQAp/IeSn782IIi3AIT6R/3Op/OfVQ0jm/QSK/ILY5xFXEU6t8WosENy09WZYbHEGihkv/GFyP2oRZYKPWESqJRgsPuRzVl4RsSalqSiMd8hgXp75CQ26+ofejJ+tjztV7M/pL8AtY0Ry5HGSjhAMnDa4uT3vX38w+ePSGYD/uShYyATIFOtEz9kbS3FdIehadgdFCF8jsYonea3Wik+DM61ihjYRYmdXicW3X8mb3ZQmTCTNQezaS6EGf1xawaNrYhXySC9zD7YkJ4X1Ows+at7NaUW8+LhANwPc+aaARTrZZBs8Ge3CyVou 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)(376002)(39860400002)(396003)(136003)(346002)(66556008)(66476007)(16526019)(8886007)(8676002)(2906002)(5660300002)(52116002)(7696005)(54906003)(36756003)(8936002)(86362001)(26005)(1076003)(316002)(6636002)(55016002)(66946007)(478600001)(956004)(110136005)(44832011)(2616005)(83380400001)(4326008)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pgCjsMN4XYURpjKsOYL4hl6EmjEK4teUGIsTFLwr08b2L5PKeB9o59BmOod/JqUIxeHzBy8CnbvGkUPnIP/Qf7lXhzn8tZBna2ZXz3zEJRDTGG6CJ7+uMpG/Oxbq0uGTPOe/Pm0odNlDD9krBesPkQ4rCKLP6ahOAzi6yLbYAHMkTeNCW4TDy3yyf3fhK+Hr3MlxX8fn+sCZuqKxdyNTYEjUhfzSsYgw9fMCJSRXmIu5Bc/aQ8gLWpPaXPZmCIcB47JInJfjB9wuD6p+42XODRfVXVxXzTm77qAoKsmuGXHKGSddE1m54c2PZGuH8YbTqcwJehBoZJUb3aGuUlgXrlB2ZFwSJNpdwJKOSeXOJEjsRRiU6bWFjy4mSaMH2AJWVeDaIgefN+4NHYNLaUvncBV3iaVIX7R0407TEeqhotvuxJGKZ5KB09n25m96jqA+xCveXSI994UIIb2leG/lcIGe6jxU7Dx4R2d7CS0r/4AqCwiKfOzt/iLstDy843orK8v6WmCbcZMkLTOR7+d3Egwd244ROvKQkbtGIHlp5BrDvwERy8wrMuMc+VVKixma9tKLOgtSmhkuS4PbqaTdHcw5P0Kjxe9nsK+RNWkEZYoP13TjWJutcfZkMJE4zhWmfNfnAiB/zXntwupzlf5YKA== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc45351c-849e-4bf5-33ab-08d861465fb8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:15.6686 (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: OFUPkRdM78FEtwmLY1EqmiKUSQj1gskas6p5jGUNajBaH+UMjy9ctVZC7e5sshKamHctZgRo7GgmrwIHC04SIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073019_768250_19DD3A49 X-CRM114-Status: GOOD ( 14.05 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The sbi_hart_pmp_get() and sbi_hart_pmp_check_addr() functions are not used anymore hence this patch removes these functions. Signed-off-by: Anup Patel --- include/sbi/sbi_hart.h | 6 ------ lib/sbi/sbi_hart.c | 42 ------------------------------------------ 2 files changed, 48 deletions(-) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 2efe44d..79d745a 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -38,13 +38,7 @@ static inline ulong sbi_hart_expected_trap_addr(void) unsigned int sbi_hart_mhpm_count(struct sbi_scratch *scratch); void sbi_hart_delegation_dump(struct sbi_scratch *scratch); unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch); -int sbi_hart_pmp_get(struct sbi_scratch *scratch, unsigned int n, - unsigned long *prot_out, unsigned long *addr_out, - unsigned long *size); 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, diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 88ffab0..ea5d479 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -153,24 +153,6 @@ unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch) return hfeatures->pmp_count; } -int sbi_hart_pmp_get(struct sbi_scratch *scratch, unsigned int n, - unsigned long *prot_out, unsigned long *addr_out, - unsigned long *size) -{ - int err; - unsigned long log2size; - - if (sbi_hart_pmp_count(scratch) <= n) - return SBI_EINVAL; - - err = pmp_get(n, prot_out, addr_out, &log2size); - if (err) - return err; - *size = (log2size < __riscv_xlen) ? 1UL << log2size : 0; - - return 0; -} - void sbi_hart_pmp_dump(struct sbi_scratch *scratch) { unsigned long prot, addr, size, log2size; @@ -200,30 +182,6 @@ void sbi_hart_pmp_dump(struct sbi_scratch *scratch) } } -int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, - unsigned long addr, unsigned long mode, - unsigned long attr) -{ - unsigned long prot, size, log2size, tempaddr; - unsigned int i, pmp_count; - - pmp_count = sbi_hart_pmp_count(scratch); - for (i = 0; i < pmp_count; i++) { - pmp_get(i, &prot, &tempaddr, &log2size); - if (!(prot & PMP_A)) - continue; - if (mode == PRV_M && !(prot & PMP_L)) - continue; - size = 1UL << log2size; - if ((log2size >= __riscv_xlen) || - ((tempaddr <= addr && addr <= tempaddr + size))) - if (!(prot & attr)) - return SBI_EINVALID_ADDR; - } - - return SBI_OK; -} - int sbi_hart_pmp_configure(struct sbi_scratch *scratch) { u32 pmp_idx = 0; From patchwork Fri Sep 25 11:29:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371196 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=n1BrSi0d; 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=gApEZ/y9; 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=KzWNox0I; 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 4ByV8Y270Kz9sSf for ; Fri, 25 Sep 2020 21:30:37 +1000 (AEST) 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=pX731FFzUCtScya+EMM5Pcbswv6Tdvmn42a3X98EJaM=; b=n1BrSi0drgPZZvA+/jS8dIZ9p rS4bLjNHz/ZjabEb0AnMAUNYMAtvHobfZNNh7h9xhbQCUQ7u6d2WCXMmKHwC8SkDLDBf45guJ1jua P8l36xP0tWxTZWHT3Rs3Zfs+Co+7p9EgDCJDV3vsbTJyMhnJH4A52CCBC8mjayBis/JSV2App1gHh EwRFawIcunfpbCTFQMYqfHq+rupwG3B7zgX+vB4eC1tMaGkn6CaPITpTesIEEPc4I0G6nDfTxQZ4x 1GSOE9T3tGhauVdSGHKslvoRAkYJMJbTMUGqdXTGnafyE3d1PiCfGvX1UNZ7A0XgZ7/AsnAB7brFb 9oQnYP1pA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvq-0004Xw-H1; Fri, 25 Sep 2020 11:30:30 +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 1kLlvh-0004PV-G0 for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:24 +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=1601033421; x=1632569421; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=YfIExUeF5qxGAgO3aqk+5/vQZvlAtbsHQHFA40U3tQ4=; b=gApEZ/y9I0IG7KfkNuO6fJFuRLouK6rFN50TKFj0ghd69BBpy3wPJOGO dNtP8GbWbF9+/WAb0MWSl+XsXEBUxydRTtukjwXY1dectcejUOwbR0oki ulhlE409Wbe9uOSb2NswwFD2dL2Kra7U9ScuQ6J4mkaGx2AY4eUTNwkQ/ aup01SuUPaDWKGqHkVsL7EshaKN+wThmFeUBFJCZZ6uzsebWYkmZyMTJa sjl6p3tQebBsER/dmJ+HSQ/uP5yickO9nhKnaDGfiG00K2I1Df+Z26CGm cRWQ3Rn7EfZV07KHEIFjzstQk0q+qzO/GGVtMYeIhnnnfHJIx/5BXcfin w==; IronPort-SDR: 4RfRNbeC+kOpo/tcH8jMpAPaJS9uUF5odhaOUhLE2iDNq2XxAEXDVrbrzuxXk9eSE6Em2eaA+j 26MTT+6OiBz84r20+oT2KOq06z2LlYlrNREUl0sGVSSUi6XncwqF+7wdMGSGXKgCeYZVTcMRV2 aq7PgBkezzftvZYr74qLgk0HmjBcwBnPQmeOCKzSUYQAwSZjgpGty4BLtN3Pz6Q/qozDGFHFYn TsxVETpSlZK91Xtu2DYgfUGq0vmlLe9+v/OHhsEIPEnv6kb3hFYOJPQgXA+vHIG3PA66FT+6kC ah8= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="152637955" Received: from mail-dm6nam12lp2169.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.169]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:30:19 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j2wjyZO6zsiHWdzbXqhAzuxX4xNlahjJJwIkUBHNlNvLuxg9hIjGNTBYLplQcoKmbhJ6JKvKbpnobUwQG+tBJ8fh8L4Ruv1+sBHYnuVjNNc4LtEPXcc52m/W3l0B4W4QLXzEp6oOyVSSvI0jOw71gcVdqSVSz01vN5634eS/6UzM2N4XbyLWEloHYGNqWVBolbBk2+q5nCns2DjQraY66h2nhPZ3f9N/0HX/551IrGKaFtTCaj/5akx+3gFOoc84nI9om9gCxtjBL5vKg2WOqeDkwKcn0hp9W9DQkdT1wXh/9xmVt4O2UGfp2NRmLh0RQoHOaoHihq7lUeA863tfDw== 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=ZF1IVzoSEpRLrLp3YN2/62HayoNC5/SDWlHpz+MYYHU=; b=hJyESqp17fbyG5e7y3Hs/Lg3JqNMSVo3ybmvlTQmOpOIaZyfg/Xi4q0bfOMSfzOtY2xP+fJNOgglZczP+fth14nt/wjG5odBFUPRH9dP0g6iz181ZpEadFS0WKZlKAW3y8lRSKflfK9JIzokQinWfqBbcnOxmFXQhmE1AiR8rkwqCOBlmj5lWqOgw9BCE6rTU20tAXwX62+rQXx+nATuh8EX9nAg8qzwla/7D+VQvssRa2pqVUzuuy0hS/c4QTFQEXVZdiH/+Ee8Dwluq66bfPQzSSa7EIkc0pZ/Z5EN/c8+Ehz3KJ7txLaEJLts3kbIHzinw4VFj7DJtoxhl7ynVg== 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=ZF1IVzoSEpRLrLp3YN2/62HayoNC5/SDWlHpz+MYYHU=; b=KzWNox0IUvaIphaj3aiGKWEjEMLYrlJvkt2uOApYp5zSucvven+EOj0Fxi8zT0WMxMgh+AE5KyCtJA5efp3NN1bJikUziJtTX6+X6Tn80+gLRVc+NnBK4Is0ZhpkRo7KKCd6S4lOBJlickkadoQrC7rFeEAG1aS8CN90Y0BOQZo= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:18 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:18 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 14/16] lib: sbi: Configure PMP based on domain memory regions Date: Fri, 25 Sep 2020 16:59:12 +0530 Message-Id: <20200925112914.725846-15-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:16 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 789b3ed9-4f9c-4588-fd83-08d861466129 X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G7596W+u8T90kDvga/+oAteZvPAU7uMdSveHRpsyQhHNdYkOcor++gE2rwkr6pKpiCq8WBu3rJE+fxKuwFY0bSGzixe29ACEnlnt3GpskKG/tSLbprP4V5pB8rYgXJKVv2MvuM/YMn6dGGZXIbggRfciFnrjLpMfYAggBJLpaQ0wxy5H0GfWkt5dfjNbZ1e2DnOgnEw71srhphkKeq/cuFX2l6wZp7d2db3R4+l53ACceLiCw2eK9T5ymXcq5fiI5Q4TSDh7dzQRdKDJqG3USxYKpDQtYLXTRbE9p8AiZjl73Mcd2SE9nl4JNZSh95gNB0K9UnP4x+ny0joTLi9OYIVRBx5bR5JOwcY9BAcUgjW1VlGWH54m0O0PEOp6V7xJ 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)(376002)(39860400002)(396003)(136003)(346002)(66556008)(66476007)(16526019)(8886007)(8676002)(2906002)(5660300002)(52116002)(7696005)(54906003)(36756003)(8936002)(86362001)(26005)(1076003)(316002)(6636002)(6666004)(55016002)(66946007)(478600001)(956004)(110136005)(44832011)(2616005)(83380400001)(4326008)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: yQ+xTMHZffvjfjc/0LUICADkjx7CTF+1XMJJJ/E9OLSe0G8R2MW+wrQjOtGKeMoYD7njR+4Qy6Fz7989nLFi3ZgPPwVN041ihMBGLq9wp1TWt4WEkKUI9sqz2FHOxL0c/v1C74PAPo4qaYVFUf5nk5MNwW3PTbHKetuDDy1Xv7d3AH16gNndoY+2PdnToi2u4ALKAEg8Ht7IREAJ8Sh27SzAz20MVV6LCxyHY388ybDlMolzDdlSEUoIFqdgi3bcnQvwNwNUdddVd1xYWbW7KnHg9DcMPSrWNluWQM8c6WGW+XFcVchjAd77WM7HmB1tlz8nomPrDQYQFzjmFXEFS9fDj39ifUftOqUtRAAcbz+piXiUrnwGhkegbdBra5MIqaw91HkKdLo4zS04Cj84T9cctNvB8MmsklxkmcoMwL0CU078tpXeZYCM1HqA3jymMWQ1Jr/eSymIf9S84OvpY+RNaWvAB0c4KjY6A1hXNcDb2hXMK1sXQq5EB0L/FvLEgXKNE4nCDO3c7gE01crSTngj7AjpQlwMLPr3E3j9ufsFIJOyvLjilNgeCOxWCYTJgdf/zDMKrXRlydm6TiID4t4mUP7I/I+BJ/hxphKNKGNI96k545qAgVIxZgY93oJ4sNBLqCcCMJRRK2PpR3vA3w== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 789b3ed9-4f9c-4588-fd83-08d861466129 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:18.0930 (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: nvxN1HKj9eN4B6ZiYHjkbrX4kfqGmMTjhWw9shxNwFENano98T3IMw8+EFtgiStv516P2FXrZtHO1hFFruhaEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073021_736597_0024137F X-CRM114-Status: GOOD ( 16.75 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 The PMP configuration on each HART should be only based on the memory regions of the assigned domain. This patch updates the sbi_hart_pmp_configure() function accordingly. Signed-off-by: Anup Patel --- lib/sbi/sbi_hart.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index ea5d479..1871a1e 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -184,24 +185,30 @@ void sbi_hart_pmp_dump(struct sbi_scratch *scratch) int sbi_hart_pmp_configure(struct sbi_scratch *scratch) { - u32 pmp_idx = 0; - unsigned long fw_start, fw_size_log2; + struct sbi_domain_memregion *reg; + struct sbi_domain *dom = sbi_domain_thishart_ptr(); + unsigned int pmp_idx = 0, pmp_flags; + unsigned int pmp_count = sbi_hart_pmp_count(scratch); - if (!sbi_hart_pmp_count(scratch)) + if (!pmp_count) return 0; - /* Firmware PMP region to protect OpenSBI firmware */ - fw_size_log2 = log2roundup(scratch->fw_size); - fw_start = scratch->fw_start & ~((1UL << fw_size_log2) - 1UL); - pmp_set(pmp_idx++, 0, fw_start, fw_size_log2); - - /* - * Default PMP region for allowing S-mode and U-mode access to - * memory not covered by: - * 1) Firmware PMP region - * 2) Platform specific PMP regions - */ - pmp_set(pmp_idx++, PMP_R | PMP_W | PMP_X, 0, __riscv_xlen); + sbi_domain_for_each_memregion(dom, reg) { + if (pmp_count <= pmp_idx) + break; + + pmp_flags = 0; + if (reg->flags & SBI_DOMAIN_MEMREGION_READABLE) + pmp_flags |= PMP_R; + if (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE) + pmp_flags |= PMP_W; + if (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE) + pmp_flags |= PMP_X; + if (reg->flags & SBI_DOMAIN_MEMREGION_MMODE) + pmp_flags |= PMP_L; + + pmp_set(pmp_idx++, pmp_flags, reg->base, reg->order); + } return 0; } From patchwork Fri Sep 25 11:29:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371197 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=UMozZkIF; 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=dJe562tx; 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=SfthmbZ7; 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 4ByV8Y2r53z9sSn for ; Fri, 25 Sep 2020 21:30:37 +1000 (AEST) 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=dOdeGpPqOBVGWG2U2XtAVXM1/vyhoH/PdQvfKx/TL6M=; b=UMozZkIF4b8lxTiUZEI4clPCS 6Acuj1RlBdQEgJyHMj2YRCFm0tjkA5CSxOUidz2Z3qMU9eLGmA/m/g6o69syiqvEOc5R9qpBPgNgA /tFrI9v9MzRJoclrRCR0TcoSIlcxmoJWCdF2/33AF7tvX+eTGuT6JoWIjA5dawNUCuXobW/F32WPT pvhv8k5GF0drax1UyoTvuLRoq3SBM5gh9Pwq8rAihDOA9h1PpdibqPmdl9dzy4rNbBcLEogK9Nvgm yZ0F01a1+8VJd+xyRxt+NWibiuIT7rKNlAO6AHDjS/OVps4dY72XlhxT6HmlNAyxdIq+3pAbmzM9v 4USn6UO8A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvr-0004Ya-GN; Fri, 25 Sep 2020 11:30:31 +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 1kLlvj-0004TY-Sy for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:27 +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=1601033424; x=1632569424; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=LDkkx0p6FrJULbRkbpcVRwelcZpeYIRHrwveNFTS/o4=; b=dJe562tx+oI5a1iT+CmCrIuplhwnWZxkAxWN0j6668oAlntlCk39Wvfz 51SYlO8KvL9fF5RO9EDUWlBUnItLM8jyp1xt9yul7rBJA7uuVasC/Ww0P GiIJfv2v/E7mKJHd5guOpgILV5YKlBVNLN8uNGATMAw/Szr5PpDpdY1zI cBrnkKO1g1coT7Oe1XGUcFDy/eJrRSQtRCSLW+lnw1pWopJL74ZcL9v7/ D7GxbMcNYVNcwaSR6peB6oesq4lzdqEv+OiPnpIu9r/MVVsTpqK6WYygG 8Ye8UPJzPyNrBncIWCKUk14Uj+jNqxMBcCBsHiv3dBvOsLB6dDMLujLQl g==; IronPort-SDR: 95qxdb09VZsYMzfJwen6A8H/fEPw54nakcVXbSe8cYDige0La1zsp3SX2Nl+ES7JRM+JJT6KFL PxWA8dAsHeuxg7AunER9zGRdtoX6tRbgZ1yfACkywnErRhi7kcQ/hrF0Srem3hMUt08XjiWTa4 chQxMMkGyTl4B7AZ/WEQR5pFxflCTIFMOgnak4kHHIF2nxJu7S1I5P3shfsrPeKq9SmwtOxVIQ oDwEb9B9rV7WbGoHqCuorxCCO30wnxAQYHHBRgvmqlSscjXWWqS6H74gsIdfOWhM5iN7WO4ZDe R7Y= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="152637977" Received: from mail-bl2nam02lp2051.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([104.47.38.51]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:30:22 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UwH9ymOPViN4cpVlF5bxCENpPZPQSWhvadkizd3o+wi78tKYJ8FinzSwnrS3SQ8XhMkeV6xUY2mhOkvxAYAgALtVyGqwkjXrerVH21j8YwOm9e8g5mgV01cuWK3FR+jKTCYahIXvzzbVqaBb8ZX8jO0f0/yDQ163lyBuLYEwGcvMf8SE6Illb2BDuN8v3TJYownUioAmO8X15xlKjLELhyqzZ0clXFl5MxlntJac2u5LLxvpCl6L6pPPQYUaRVrBNG3CWk5f2Bp7vZkb4ym33ihspY9uF4nProyLYM3pMCrEc44nN9p/BZpBkWDSwzLJXt+OzjQXunjx03lR/dCN7A== 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=W+3j81VGZe0Gc2GT8Id7rhTdr0Qc6TIdOK6nGlYI3AA=; b=ZPxj+l50cgAwTazNlBh67WByTgyCNPcsYEOkts1s6szfL9pNT2HdgTcUa1a2R99ZV3jee+hKr4AgIFpq2vvL1ePnTj+vf9od2UTf3iUinNNXA+z1z3N3AuH4w/hgojgvgANOt8ip9m7waKtrlXKRT4dsaHLGyBPYDKLwleA+ls09zmOPyjcgWqQADxfkgF1lsTAmSBpZaVwBxuRVgztPjlei9VIABdTKF+pADXFNXCIoH26L7k43GlbLdG5UQcCCbD8LA3o/sERfNOpU0lIXVDAyzZC8asyGuIADN7LfAJMKV0RRSLpteYbcs3i/L/m5nPBcSUiXMS2l+YLLep9r1Q== 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=W+3j81VGZe0Gc2GT8Id7rhTdr0Qc6TIdOK6nGlYI3AA=; b=SfthmbZ7dqlHG5/3CnhCSjus9YZCLH0y+vkzps4OuKI6WniDG+XXY/C4/NQfT3IxWbgaP4LtpdkvZ8Qo5PO1ebLM7nefkN9Kp8c32LiUV3Ao1ezKZXdft6hR8OPspjYwI1I3r5GZ5ZgmgvjQZzHOuKFxwLX2miTuI7Pkm4ghrVo= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:21 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:20 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 15/16] lib: sbi: Display domain details in boot prints Date: Fri, 25 Sep 2020 16:59:13 +0530 Message-Id: <20200925112914.725846-16-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:18 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 49b4cb98-f65f-4e12-26aa-08d86146629d X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:343; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XbT58VzUm0+WPRQNgsv6DYXVfcRfie0UYMED2W5ihYHAbvHqIcoEYJT4Da2SW5f29QcT7xStjhGFqDl/G9QIEQt9utf9NqkFLsKJRi0bP9ILwXiCfXZRzgKmtHJrk+HIrCJPrp5gEFacBCcFs/rGmMuht/5b1A36z/mfG4Kj7YvFAJ4QdNwEXcSeh5pFb0KjZRlMcdrUwPv5FLhtOa7Zgn7tBMcQPDzd6siDh5pxNKeAlvhBbbPzEsLIoR2QmckMkcyA7Jul39kC8q/AS27N3bagyAu4CNzEfAIAJENHlDkFcS4j7LjBjdtWrO3g7W08Ua9h6baW4EcjB2XwpBoQcBGXaOsVrvHoQ5GjT5R+kKnAGLfy8co47GvnzdL9A+1C 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)(376002)(39860400002)(396003)(136003)(346002)(66556008)(66476007)(16526019)(8886007)(8676002)(2906002)(5660300002)(52116002)(7696005)(54906003)(36756003)(8936002)(86362001)(26005)(1076003)(316002)(6636002)(6666004)(55016002)(66946007)(478600001)(956004)(110136005)(44832011)(2616005)(83380400001)(4326008)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 5X/ORz4E7K4hVJyr3+e97wM79CO4gEQcHs/om+5pfZf4uq+3anJVx//jPr9Rb6QZX0ROjdbXhxJKnWmwMCY7gecqVD/6vwaGO5PfSLFpXi5BGPGlanBAZs3rq4Zxl5cf8XPq0p+EZv9XTNlZWX2/kY7FBXWOspdh41z7w0VizmKZtmexnNSn64UzhEjBqHntO68T4CS5jxjqjTDaSND9ZlQOdWPPSq4VYFxNwsgCtMKV/mLf6eCF6jWem8qiIQ/nMXGluxeLsHj6LMSsF+gasaACYq2GnkTdNgpU3J0namq4sipJqHT40oYKScdKm2Uoqxs5Js+K0IxfQfOxHbpNieuRp7dfxldAKR9EVMPsz2bbIf2kckA1dnwkw0U0M0jbxXF0F24HAN0Pgw2lKS0SMHeZ3JGIIyIK279Yzoh1Bj+/DNMUxMwlg9pxw4aXOLtt5JNrgvFoOqwl7W3GXgDryZTe0OYFAs87I+Lkb9gK/68Ys8EWP1KpT8NOJdJPvulBDmFFBLS62nSXrZZTS6itRyrFYYvFf13/mYWlLfQMUPHou3rSkI5MeD3BdJXtwpk58hzG9DiZpA3TaI3/pNxN36k8agmf/k9MxzvdnR/V3rluSGeDiNT3Ow6y6Xkp8RnjSK2Ar7gvRch+q0ufv4bJLA== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49b4cb98-f65f-4e12-26aa-08d86146629d X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:20.7693 (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: T58wZwlgUwxVFqdp/AfJg6NjEqSjeDZxzPeloxRl2PBZRJXnhY6niuNDREFGt/FQ5TsE8WxLRrcv0s4+DH3uMA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073024_292327_C0FB145D X-CRM114-Status: GOOD ( 19.90 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 extend boot prints to display details of each domain. In the process, we remove sbi_hart_pmp_dump() because it shows redundant information which domain details already show. Signed-off-by: Anup Patel --- include/sbi/sbi_domain.h | 6 +++ include/sbi/sbi_hart.h | 4 +- lib/sbi/sbi_domain.c | 94 ++++++++++++++++++++++++++++++++++++++++ lib/sbi/sbi_hart.c | 44 +++++-------------- lib/sbi/sbi_init.c | 27 +++++++----- 5 files changed, 127 insertions(+), 48 deletions(-) diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index a3f174c..3b69c95 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -129,6 +129,12 @@ bool sbi_domain_check_addr(const struct sbi_domain *dom, unsigned long addr, unsigned long mode, bool mmio, bool read, bool write, bool execute); +/** Dump domain details on the console */ +void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix); + +/** Dump all domain details on the console */ +void sbi_domain_dump_all(const char *suffix); + /** Finalize domain tables and startup non-root domains */ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid); diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 79d745a..3ac1500 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -36,9 +36,9 @@ static inline ulong sbi_hart_expected_trap_addr(void) } unsigned int sbi_hart_mhpm_count(struct sbi_scratch *scratch); -void sbi_hart_delegation_dump(struct sbi_scratch *scratch); +void sbi_hart_delegation_dump(struct sbi_scratch *scratch, + const char *prefix, const char *suffix); unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch); -void sbi_hart_pmp_dump(struct sbi_scratch *scratch); 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, diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index df0f2a5..93dad41 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -235,6 +236,99 @@ static int sanitize_domain(const struct sbi_platform *plat, return 0; } +void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix) +{ + u32 i, k; + unsigned long rstart, rend; + struct sbi_domain_memregion *reg; + + sbi_printf("Domain%d Name %s: %s\n", + dom->index, suffix, dom->name); + + sbi_printf("Domain%d Boot HART %s: %d\n", + dom->index, suffix, dom->boot_hartid); + + k = 0; + sbi_printf("Domain%d HARTs %s: ", dom->index, suffix); + sbi_hartmask_for_each_hart(i, dom->possible_harts) + sbi_printf("%s%d%s", (k++) ? "," : "", + i, sbi_domain_assigned_hart(dom, i) ? "*" : ""); + sbi_printf("\n"); + + i = 0; + sbi_domain_for_each_memregion(dom, reg) { + rstart = reg->base; + rend = (reg->order < __riscv_xlen) ? + rstart + ((1UL << reg->order) - 1) : -1UL; + +#if __riscv_xlen == 32 + sbi_printf("Domain%d Region%02d %s: 0x%08lx-0x%08lx ", +#else + sbi_printf("Domain%d Region%02d %s: 0x%016lx-0x%016lx ", +#endif + dom->index, i, suffix, rstart, rend); + + k = 0; + if (reg->flags & SBI_DOMAIN_MEMREGION_MMODE) + sbi_printf("%cM", (k++) ? ',' : '('); + if (reg->flags & SBI_DOMAIN_MEMREGION_MMIO) + sbi_printf("%cI", (k++) ? ',' : '('); + if (reg->flags & SBI_DOMAIN_MEMREGION_READABLE) + sbi_printf("%cR", (k++) ? ',' : '('); + if (reg->flags & SBI_DOMAIN_MEMREGION_WRITEABLE) + sbi_printf("%cW", (k++) ? ',' : '('); + if (reg->flags & SBI_DOMAIN_MEMREGION_EXECUTABLE) + sbi_printf("%cX", (k++) ? ',' : '('); + sbi_printf("%s\n", (k++) ? ")" : "()"); + + i++; + } + +#if __riscv_xlen == 32 + sbi_printf("Domain%d Next Address%s: 0x%08lx\n", +#else + sbi_printf("Domain%d Next Address%s: 0x%016lx\n", +#endif + dom->index, suffix, dom->next_addr); + +#if __riscv_xlen == 32 + sbi_printf("Domain%d Next Arg1 %s: 0x%08lx\n", +#else + sbi_printf("Domain%d Next Arg1 %s: 0x%016lx\n", +#endif + dom->index, suffix, dom->next_arg1); + + sbi_printf("Domain%d Next Mode %s: ", dom->index, suffix); + switch (dom->next_mode) { + case PRV_M: + sbi_printf("M-mode\n"); + break; + case PRV_S: + sbi_printf("S-mode\n"); + break; + case PRV_U: + sbi_printf("U-mode\n"); + break; + default: + sbi_printf("Unknown\n"); + break; + }; + + sbi_printf("Domain%d SysReset %s: %s\n", + dom->index, suffix, (dom->system_reset_allowed) ? "yes" : "no"); +} + +void sbi_domain_dump_all(const char *suffix) +{ + u32 i; + const struct sbi_domain *dom; + + sbi_domain_for_each(i, dom) { + sbi_domain_dump(dom, suffix); + sbi_printf("\n"); + } +} + int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid) { int rc; diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index 1871a1e..ff18c9d 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -123,18 +123,23 @@ static int delegate_traps(struct sbi_scratch *scratch) return 0; } -void sbi_hart_delegation_dump(struct sbi_scratch *scratch) +void sbi_hart_delegation_dump(struct sbi_scratch *scratch, + const char *prefix, const char *suffix) { if (!misa_extension('S')) /* No delegation possible as mideleg does not exist*/ return; #if __riscv_xlen == 32 - sbi_printf("MIDELEG : 0x%08lx\n", csr_read(CSR_MIDELEG)); - sbi_printf("MEDELEG : 0x%08lx\n", csr_read(CSR_MEDELEG)); + sbi_printf("%sMIDELEG%s: 0x%08lx\n", + prefix, suffix, csr_read(CSR_MIDELEG)); + sbi_printf("%sMEDELEG%s: 0x%08lx\n", + prefix, suffix, csr_read(CSR_MEDELEG)); #else - sbi_printf("MIDELEG : 0x%016lx\n", csr_read(CSR_MIDELEG)); - sbi_printf("MEDELEG : 0x%016lx\n", csr_read(CSR_MEDELEG)); + sbi_printf("%sMIDELEG%s: 0x%016lx\n", + prefix, suffix, csr_read(CSR_MIDELEG)); + sbi_printf("%sMEDELEG%s: 0x%016lx\n", + prefix, suffix, csr_read(CSR_MEDELEG)); #endif } @@ -154,35 +159,6 @@ unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch) return hfeatures->pmp_count; } -void sbi_hart_pmp_dump(struct sbi_scratch *scratch) -{ - unsigned long prot, addr, size, log2size; - unsigned int i, pmp_count; - - pmp_count = sbi_hart_pmp_count(scratch); - for (i = 0; i < pmp_count; i++) { - pmp_get(i, &prot, &addr, &log2size); - if (!(prot & PMP_A)) - continue; - size = (log2size < __riscv_xlen) ? 1UL << log2size : 0; -#if __riscv_xlen == 32 - sbi_printf("PMP%d : 0x%08lx-0x%08lx (A", -#else - sbi_printf("PMP%d : 0x%016lx-0x%016lx (A", -#endif - i, addr, addr + size - 1); - if (prot & PMP_L) - sbi_printf(",L"); - if (prot & PMP_R) - sbi_printf(",R"); - if (prot & PMP_W) - sbi_printf(",W"); - if (prot & PMP_X) - sbi_printf(",X"); - sbi_printf(")\n"); - } -} - int sbi_hart_pmp_configure(struct sbi_scratch *scratch) { struct sbi_domain_memregion *reg; diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 406cb3f..5151d36 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -39,6 +39,7 @@ static void sbi_boot_prints(struct sbi_scratch *scratch, u32 hartid) { int xlen; char str[128]; + const struct sbi_domain *dom = sbi_domain_thishart_ptr(); const struct sbi_platform *plat = sbi_platform_ptr(scratch); #ifdef OPENSBI_VERSION_GIT @@ -64,27 +65,29 @@ static void sbi_boot_prints(struct sbi_scratch *scratch, u32 hartid) sbi_printf("Platform HART Count : %u\n", sbi_platform_hart_count(plat)); - /* Boot HART details */ - sbi_printf("Boot HART ID : %u\n", hartid); - misa_string(xlen, str, sizeof(str)); - sbi_printf("Boot HART ISA : %s\n", str); - sbi_hart_get_features_str(scratch, str, sizeof(str)); - sbi_printf("BOOT HART Features : %s\n", str); - sbi_printf("BOOT HART PMP Count : %d\n", sbi_hart_pmp_count(scratch)); - sbi_printf("BOOT HART MHPM Count: %d\n", sbi_hart_mhpm_count(scratch)); - /* Firmware details */ sbi_printf("Firmware Base : 0x%lx\n", scratch->fw_start); sbi_printf("Firmware Size : %d KB\n", (u32)(scratch->fw_size / 1024)); - /* Generic details */ + /* SBI details */ sbi_printf("Runtime SBI Version : %d.%d\n", sbi_ecall_version_major(), sbi_ecall_version_minor()); sbi_printf("\n"); - sbi_hart_delegation_dump(scratch); - sbi_hart_pmp_dump(scratch); + /* Domain details */ + sbi_domain_dump_all(""); + + /* Boot HART details */ + sbi_printf("Boot HART ID : %u\n", hartid); + sbi_printf("Boot HART Domain : %s\n", dom->name); + misa_string(xlen, str, sizeof(str)); + sbi_printf("Boot HART ISA : %s\n", str); + sbi_hart_get_features_str(scratch, str, sizeof(str)); + sbi_printf("Boot HART Features : %s\n", str); + sbi_printf("Boot HART PMP Count : %d\n", sbi_hart_pmp_count(scratch)); + sbi_printf("Boot HART MHPM Count: %d\n", sbi_hart_mhpm_count(scratch)); + sbi_hart_delegation_dump(scratch, "Boot HART ", " "); } static spinlock_t coldboot_lock = SPIN_LOCK_INITIALIZER; From patchwork Fri Sep 25 11:29:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1371198 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=abM+B92n; 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=cHX+27ov; 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=PqMYCl0g; 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 4ByV8b5SFGz9sSf for ; Fri, 25 Sep 2020 21:30:39 +1000 (AEST) 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=CFTu5Rqqgsgaz43OOp3ezSjjT/VCbcyOB6ssYCjjqRE=; b=abM+B92nu0RQtS/hO6G9e/Kem a5tadf52P2rOwwudXIhK7Pt4+zODDADYcqegXNq0WpgATslOwYelZwjiSdxClYtWJAR3gj3qUObqH 5obNexw3lbaZH/t1pGGH3d4upFdSe3S6WIkg3k866I7ir4oomHVu2gGyphqJLcYXUNAzet01qZkVt zSXkC58/geWUYWApK4TLpCJcyjEnDGN51L8t0e3DouGOnDE2xNEou7z9SzhRyCrFoltWLiGWlK5YO /TcO9I0aADcnOYtMakWDkdpF8nOly0n76ddQof9jatetz7IZGQasgXtx2P0e6YToqCU3/xlsT0tuQ PUdj6V7Yw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvs-0004Z6-Sj; Fri, 25 Sep 2020 11:30:32 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kLlvm-0004VC-7l for opensbi@lists.infradead.org; Fri, 25 Sep 2020 11:30:29 +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=1601033426; x=1632569426; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=oWX+/v4vCI3yWzE8wJPoGhX/wbyL898TClv070gFKvA=; b=cHX+27ovHzQ46jWRnrqgV661aJlDpqPuw0X3Jgm5HT927SPRXC/M8XAk L4PjOFQA8IXDLh0lhytt2qGpxsU7JQsnom32DzHosoDSd+cUVgnICOWQE 5znym/xeQAmmh3Fvxva8oLas5V0mpb+x0wer37sIor8KVrXA+Cfo/Otgt m3zkeTwfjxKY+kpg3UA5+Ee1qGD9PvCNlUWGFtz8gD1X9kxhFg8mWKgsi gIHJAKViTJp3JrRCNP0pXhFVgRnCXfPHqhFq3cYGCNeWc10b+AxCusMaY JZ/L0UWRIF2S5m+pv8AxceazPZILw+aIYLqNI/K5rbBEg+QV5VL6mFroC Q==; IronPort-SDR: MeENYIqwfM4Hdd0zEOxu54P7q4LYfMwnmTKuTH8R5Z2wIwdcCwjEAkNYevy66CIw9wI1wNx0+Q iXC4YD3VjCubeWJR+1z9USTpNqDzB8H4SkN4XNGLc6CR5uWbhowdfXeVQiQqKEwWGc9Wl8iRIt 0W908ltmjwhgMAzwYuJ/1oLVlfPAVDylz9eUmuBN5+MjJwNaiDQbtbYqxl3tp3OFiPwAz5z9t4 UrWpgXGCTiZMmrzoCGhhJjx7PZRAL70dCa2VWnh4UNTNSymGrhKGWu2HlbZ/Wqd/+B/VcBR20P J5A= X-IronPort-AV: E=Sophos;i="5.77,301,1596470400"; d="scan'208";a="148192149" Received: from mail-co1nam04lp2055.outbound.protection.outlook.com (HELO NAM04-CO1-obe.outbound.protection.outlook.com) ([104.47.45.55]) by ob1.hgst.iphmx.com with ESMTP; 25 Sep 2020 19:30:25 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ilCTyQOnWK1YkTEnGuo0L6vWOTdByffeB5FF32YVsf9xRr2zcghyBlCLsfWpWtj6X3F7EZ/O1TeSdtqzUXdyRmTEUk32x6qgN3ned3TdU6ju/NOfbE31/1bnkS2gYv0j1CoP9HZFCrwZQElMuuBqnISFnkKwV9w4SKBYWeDIAUv4n4hJBU7nXclFUJeP+dDftZqVV8iXNiBCQFlaU73u0uJ/JPtiRd4yCpx5ZV8JqX8aPi6kOAHO5p/xksshUn6QO23wZpf0Mxa/SuObXwQFuC3yTZAQdW/C8tIzJ6kaIeu3Y4RYL5wPG7MRVo7AsYIfroDWwx/ZYTR8eGHpx62a5Q== 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=MMeyYfKWZD46PPIMSRZQ5ySt09BWu2lMwGXpAAtFZ9U=; b=ShG3JxTjCJSeECgCVNdXt/4BLjuvIeaFDqw1Pe4sjDkWXYce+O7wdxdDmO+rhQc3H2qxtjWbGzetFbBad2wN5ec2a95Bu6HGM78oCr8vxQ9ACssc+SR15Gn24RGvpHhVgYWZn+CKFN+5S3bjlAn+Um0YE4fGdFMkgyr0fkeB0WZYKr0BAqVERa9bLKgvxnGyp+IVwC17c7IPtXHaZwc1DPiu+737nsa5fkGDkmT/qqMTuMWOUz+emgHBRCJvmP3LM79gV4ULd+CyBqlIBjTy5sOr6qFn7hgTcP4LNw00X1tY2JzxN/NmU4FySW5e7NsWHZiBUFIwy71yX1jc5CHBgQ== 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=MMeyYfKWZD46PPIMSRZQ5ySt09BWu2lMwGXpAAtFZ9U=; b=PqMYCl0gwXYpVvk6aHPakkrU2Y5PLje6r1ovxL9TzoMuAfs58Fqk9W6jQQFyl2G/tneSK/hZsI7abvWEqf1lt/2rFUDNyReMuw4XrL0xZyHmft2NTrkKJTIWSxyPXyES+iBfmjZI4qCwAGgjILfXBkDSh/LHma2LWS7pyOJHRsk= 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 DM6PR04MB6778.namprd04.prod.outlook.com (2603:10b6:5:24c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20; Fri, 25 Sep 2020 11:30:24 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3391.020; Fri, 25 Sep 2020 11:30:23 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH 16/16] docs: Add initial documentation for domain support Date: Fri, 25 Sep 2020 16:59:14 +0530 Message-Id: <20200925112914.725846-17-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200925112914.725846-1-anup.patel@wdc.com> References: <20200925112914.725846-1-anup.patel@wdc.com> X-ClientProxiedBy: MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::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.179.69.106) by MA1PR01CA0152.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:71::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Fri, 25 Sep 2020 11:30:21 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [122.179.69.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: eb142824-3242-4f11-fe99-08d861466433 X-MS-TrafficTypeDiagnostic: DM6PR04MB6778: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F6EXCybItJ8BnFNv3pLjz3cmsbBnNj+EufavUQxatgbEjMIjsA/yab1c7/s8zd7YPbLbLxFMRB9sPyHnCYpxHvzf4aJ4l9/HvH66DlP6lMb7OsV2QKPYeUu9Y5GjLxlFtygww0AR5oRKLaFQE/FC+p6/uCWj5Yq766Nb2OKRBxz9i6gABk6180VTQz3T+Y9OjcDcDQ2xjV/j7MPLLgXKMg8bVMJiR9KaYTlbMgdVJ4y8CcZ0+Ef2Ua5mCcTHegIYWK2DV5UEonKHnlrVNQG4zgP029LLeYSZG6OJOi/FbqaLfOTVbzAc7PA9b8RUN13xg14EVdnfzERGeyDldecq4ycQR8nUsEA0mTktmHDWcX9bLMvoHVKUlX2DHjIJeem1dlknFUuCK/Ceqx4zldnCjCImTLBHNQ1akfuTlp/6T1UMj/87/QNFY2y7czrlCYQj13IU33GHLPC0PWNDfMmGq2QPUAQIO/FgOasMlRDurwRiwefq8cSPmpGbyUE7HWy6teBV+17ymJYFb/D369FeNQ== 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)(376002)(39860400002)(396003)(136003)(346002)(66556008)(66476007)(16526019)(8886007)(8676002)(19273905006)(2906002)(5660300002)(966005)(52116002)(7696005)(83080400001)(54906003)(36756003)(8936002)(86362001)(26005)(1076003)(316002)(6636002)(6666004)(55016002)(66946007)(478600001)(956004)(110136005)(44832011)(2616005)(83380400001)(4326008)(186003)(562404015)(563064011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: RgsauGbZDLZAFPb4Mew3HVwUaGeHPJHdDyjZC1JWJDet4+C5wuX1LW2Xro5BKFd4qRxHPhjj0+CwBhRQIhf0jTxtWOJKjh4DK9FtWaRmLaGKvxsmsKxCb+PtFPtaUuNU09EiQ7mCf93jRiyqy1zkAE6OxWHkLailNOk3Q7pRpMMcr4UJWs5ZJc+Z70UnbxiHWPCdUtpbitVyafD0j1O0Zx+Hf05fAeJnEhWnA84uGHxbxSnvMp82wsdaPvrMrcUU6VvEQOWONPSzF25Z7TCCnkfjxyMxX4iitR9NrS25XrzlBNMIZYvRGz5CXR7q+oZ3LfMGt+/lad6ahZtSMgJ0+RjhYpwyWfFiX4NAkLFvMWqLIkhutVv6kyfSWtwJs1zKeGP+mL5mCEbmNTtEY9s7FcrOxNVnpV9VH9CWLG2Z9gq4Hffp7YHVoYgBm2deoCdcVcK2DGmIw5seKTaBBpKg6wgEMPYA+7xmHcygzfCfkPP3GsR4h0bkC7CFLTj1RBnb+OdnGZPC0l5uJXvGRQDj9TPdyx7w8i/FZhUhBq400tFrGRkpJMW05RII+RqY/bXvZFxDR2jLlVZ9r2bGupxGResXkUC4/QbRimvajQPSu3y+Mzpz+6a/BvQNalqIjmr2oWJisfy6+NEtiwSiCSW8kg== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb142824-3242-4f11-fe99-08d861466433 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2020 11:30:23.2067 (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: xVytenAcJ6ds/wk+UBLgsWeS8KS748HXYo5sxaVHW6o/218IX37Svn+W9S6Y4zKtZ4fWwr2CuHNrREwqhfYd8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6778 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200925_073026_529258_6903C3A9 X-CRM114-Status: GOOD ( 26.41 ) 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.154.42 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from 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 add initial documentation for OpenSBI domain support to help RISC-V platform vendors achieve system-level partitioning. Signed-off-by: Anup Patel --- README.md | 3 ++ docs/domain_support.md | 105 +++++++++++++++++++++++++++++++++++++++++ docs/doxygen.cfg | 1 + 3 files changed, 109 insertions(+) create mode 100644 docs/domain_support.md diff --git a/README.md b/README.md index bd41ba3..03c02fb 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,8 @@ Detailed documentation of various aspects of OpenSBI can be found under the * [Platform Documentation]: Documentation of the platforms currently supported. * [Firmware Documentation]: Documentation for the different types of firmware examples build supported by OpenSBI. +* [Domain Support]: Documentation for the OpenSBI domain support which helps + users achieve system-level partitioning using OpenSBI. OpenSBI source code is also well documented. For source level documentation, doxygen style is used. Please refer to the [Doxygen manual] for details on this @@ -278,6 +280,7 @@ make I= install_docs [Platform Support Guide]: docs/platform_guide.md [Platform Documentation]: docs/platform/platform.md [Firmware Documentation]: docs/firmware/fw.md +[Domain Support]: docs/domain_support.md [Doxygen manual]: http://www.doxygen.nl/manual/index.html [Kendryte standalone SDK]: https://github.com/kendryte/kendryte-standalone-sdk [third party notices]: ThirdPartyNotices.md diff --git a/docs/domain_support.md b/docs/domain_support.md new file mode 100644 index 0000000..fad4f67 --- /dev/null +++ b/docs/domain_support.md @@ -0,0 +1,105 @@ +OpenSBI Domain Support +====================== + +An OpenSBI domain is a system-level partition (subset) of underlying hardware +having it's own memory regions (RAM and MMIO devices) and HARTs. The OpenSBI +will try to achieve secure isolation between domains using RISC-V platform +features such as PMP, IOPMP, etc. + +Important entities which help implement OpenSBI domain support are: + +* **struct sbi_domain_memregion** - Representation of a domain memory region +* **struct sbi_hartmask** - Representation of domain HART set +* **struct sbi_domain** - Representation of a domain instance + +Each HART of a RISC-V platform must have an OpenSBI domain assigned to it. +The OpenSBI platform support is responsible for populating domains and +providing HART id to domain mapping. The OpenSBI domain support will by +default assign **the ROOT domain** to all HARTs of a RISC-V platform so +it is not mandatory for the OpenSBI platform support to populate domains. + +Domain Memory Region +-------------------- + +A domain memory region is represented by **struct sbi_domain_memregion** in +OpenSBI and has following details: + +* **order** - The size of a memory region is **2 ^ order** where **order** + must be **3 <= order <= __riscv_xlen** +* **base** - The base address of a memory region is **2 ^ order** + aligned start address +* **flags** - The flags of a memory region represent memory type (i.e. + RAM or MMIO) and allowed accesses (i.e. READ, WRITE, EXECUTE, etc) + +Domain Instance +--------------- + +A domain instance is represented by **struct sbi_domain** in OpenSBI and +has following details: + +* **index** - Logical index of this domain +* **name** - Name of this domain +* **assigned_harts** - HARTs assigned to this domain +* **possible_harts** - HARTs possible in this domain +* **regions** - Array of memory regions terminated by a memory region + with order zero +* **boot_hartid** - HART id of the HART booting this domain. The domain + boot HART will be started at boot-time if boot HART is a possible and + assigned for this domain. +* **next_addr** - Address of the next booting stage for this domain +* **next_arg1** - Arg1 (or 'a1' register) of the next booting stage for + this domain +* **next_mode** - Priviledge mode of the next booting stage for this domain +* **system_reset_allowed** - Is domain allowed to reset the system? + +The memory regions represented by **regions** in **struct sbi_domain** have +following additional constraints to align with RISC-V PMP requirements: + +* A memory region to protect OpenSBI firmware from S-mode and U-mode + should always be present +* For two overlapping memory regions, one should be sub-region of another +* Two overlapping memory regions should not be of same size +* Two overlapping memory regions canot have same flags +* Memory access checks on overlapping address should prefer smallest + overlapping memory region flags. + +ROOT Domain +----------- + +**The ROOT domain** is the default OpenSBI domain which is assigned by +default to all HARTs of a RISC-V platform. The OpenSBI domain support +will hand-craft **the ROOT domain** very early at boot-time in the +following manner: + +* **index** - Logical index of the ROOT domain is always zero +* **name** - Name of the ROOT domain is "root" +* **assigned_harts** - At boot-time all valid HARTs of a RISC-V platform + are assigned the ROOT domain which changes later based on OpenSBI + platform support +* **possible_harts** - All valid HARTs of a RISC-V platform are possible + HARTs of the ROOT domain +* **regions** - Two memory regions available to the ROOT domain: + **A)** A memory region to protect OpenSBI firmware from S-mode and U-mode + **B)** A memory region of **order=__riscv_xlen** allowing S-mode and + U-mode access to full memory address space +* **boot_hartid** - Coldboot HART is the HART booting the ROOT domain +* **next_addr** - Next booting stage address in coldboot HART scratch + space is the next address for the ROOT domain +* **next_arg1** - Next booting stage arg1 in coldboot HART scratch space + is the next arg1 for the ROOT domain +* **next_mode** - Next booting stage mode in coldboot HART scratch space + is the next mode for the ROOT domain +* **system_reset_allowed** - The ROOT domain is allowed to reset the system + +Domain Effects +-------------- + +Few noteworthy effects of a system partitioned into domains are as follows: + +* At any point in time, a HART is running in exactly one OpenSBI domain context +* The SBI IPI and RFENCE calls from HART A are restricted to the HARTs in + domain assigned to HART A +* The SBI HSM calls which try to change/read state of HART B from HART A will + only work if both HART A and HART B are assigned same domain +* A HART running in S-mode or U-mode can only access memory based on the + memory regions of the domain assigned to the HART \ No newline at end of file diff --git a/docs/doxygen.cfg b/docs/doxygen.cfg index dbf8ef9..82f31a7 100644 --- a/docs/doxygen.cfg +++ b/docs/doxygen.cfg @@ -795,6 +795,7 @@ INPUT = @@SRC_DIR@@/README.md \ @@SRC_DIR@@/docs/platform_guide.md \ @@SRC_DIR@@/docs/platform_requirements.md \ @@SRC_DIR@@/docs/library_usage.md \ + @@SRC_DIR@@/docs/domain_support.md \ @@SRC_DIR@@/docs/firmware \ @@SRC_DIR@@/docs/platform \ @@SRC_DIR@@/include \