From patchwork Thu Oct 15 13:26:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382669 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=aamwEdM1; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=g4cRXGCA; 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=KzFDfeVH; 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 4CBqpY1pb3z9sRk for ; Fri, 16 Oct 2020 00:27:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6EmPWk/lcLIF4DU12YMS3OJ2bPfVMboER48zQt4VD38=; b=aamwEdM1h2w7XRcxQAjVDhf6O PvIuLaaiwvSkgU2qdIfGnxlDaXtycs52NkMeB3eP/b/RHrzey1ZpNXmWlf1WxLw15R+nOgHXg/Npe Y3b9dejdXI5V61aaVGb+J2yWrFyQ4ANpAEbEwZBT2g6uDi0C+QU20igzR54PaZZgTJjcWvGge7o7e qfhFCeR6ku9OOhObPAxaOJ390t1XoWTT1ymqAQhSs0tvkeEQ1x9LnwjiRwh0NJAb88AZwruT48QI1 XIwqNsdgcBQ+EuyopXk3GEUcBubv4CQLkEwIc21c+iIgUVdJ7p6sdtIGR1pCC31Cot7nIODq50NMw 0zgeYVd3w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3ID-0004HW-No; Thu, 15 Oct 2020 13:27:41 +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 1kT3IA-0004Fc-Dx for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:39 +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=1602768804; x=1634304804; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=9dR6Ooy3ioY2zhtnxfEBgSlkDOjvxT7evw1LulV9wq8=; b=g4cRXGCAERDDfO0KlRR1Vxuv4re1kh0SEJ7yWpotmgt0FYEyU/BGFwu+ 8dJqoBIq23IrtnyjqEAk20F8j6VvKj+MYlryidyghIulKDu8VK9ggYqnf g9/TjOtoGOL2cLlPEeNnggayVh+4KebLiec27+Dcu6PF3UxgVvfOoChJ/ CstDRHQAJGFyqqEtZ5n4QyXUejXypTTm+hv0sqTDnTWgqK2GXCUk/izdq k0/hW5McmI2rT/3TfMExltSqQafArMx3rjNcl1rtahu54kBPD7tqbcsTP DQpBx8dohjCo0OBk7rOfahdbONWJl9SOVd8YFTyDT86d0jKt4ZISg/YM1 Q==; IronPort-SDR: ypVZzXLdNXN3RzUBXqmdLhUqZLU8rApDrlpF214mfhkz3r9+R9BzVnYzQj9N4oQtTY2l1gIM6Q ntAHq/+r/ilAHuwsdWV3CQtd4F53KEwoJAf3oGhb1ndQPBHfHn5Dy0XhviOrJE/5HQzcIHclVv eDaUlPXHLVcYv7iiXQxrEr6ZLaLJ/ylSMThvyoI2ZHNWNA759T6dPIZJizS0qJ6l4epYk47JUT IUP5kBWJh5+YG/IUnK5dkX29TIT9mx1nYMC2xFOFCuIPsGVych5CuT/9rGBar3UXJsyQR3pnss cPY= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="253498951" Received: from mail-bn8nam08lp2049.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.49]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:33:07 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W9lWTfktpqbzl/Przs90WAg4gix2/mSCq8IwzRUUcZwyKBJL0EWr44KnOjbEGPQOSFcxqTlCeRLEM2YN62IYohCgIHKccthIIonGVWUNN+POqLGuyjid1coIODHkMf5v1vt1viAR5/PQhr7vcI/OWiLU2Y5HB5RDVs9Nx/L13py411kNHwqooMulaq8dkrZ7uT7OQUoF/rr/1kVzBpNpoLUytv/nHFe3l6NfKQg0WHTyavojn8/3AJJoKMXa0lvJRcSj0r0PcvEipq9SN3BfKtiYRy0bOECP8GM1qzJq3gCASqlU3QnN5TyzZaDEl6lXolLLwALoZt0diQgi0r2ruQ== 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=R/CYqZ+lL4W+/hMp75JJbUcoiAJIcNjLjUyzAklWSfA=; b=jzGg1WCk0w0u9Jw7nsYwSOCTDEU+1V2aI64traT+Lp8p3yyGUOnkaYl3S8Ba5nOQbHNFEkpkqVlbg4ZBPz73L2ktTyLUhZf5G+KUB7iUrt59lukZfbD16b5/5LubIfppmlK/88TBOh4eRuZFJunDQrPcZZ6yDNjUDqxWQP1jsY6pPxNkxbSTnhffxof6SYb2QRPT68hzqkochfhMS3IH/Zfo+uE+4QA9qv9FovdwKIHbadbKWVhYJEgo98YrnkxYoZLwlLWN97Xikdr9824o8v7Ox0cr3zegrWBGtBew5O8CB9rwm5nNkEXlf25q72UO2Lr/fBYie2mvFpCunVaDag== 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=R/CYqZ+lL4W+/hMp75JJbUcoiAJIcNjLjUyzAklWSfA=; b=KzFDfeVH6LlUp4GfU902vqbU85D2cKFcsxtbuH6xac9InYfvLT+4isT0h5vqsMfHnO4bOj3YBWZ8yDG6OqV6UUPjgMCkfe4OvWvPjnpspCGViYkT9i76+uA5iVfjexS2chReZhh21iTe3iOBLf7wAAAUtNqXOM6glU12/zi75Iw= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:26 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:26 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 01/16] include: sbi: Remove redundant includes from sbi_platform.h Date: Thu, 15 Oct 2020 18:56:45 +0530 Message-Id: <20201015132700.2232820-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bd314bdb-2926-4788-5761-08d8710e0e84 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: LQDf4DLUDMLfyC4UwZZ/zeejQGElW/LlvZgMU088Y3Tr4gmT5CE9zp6uy+sqYd28W5bLyZJoQsEhW08LIq37/1RS0Z/kDTWw0dxDusGIfI/d11GU71zc2aSGUmR+htHjWeHgStCSZqar9zfIuRcomm0FyTrlR4rXRZE0HzujCf7o7DvfTV/l0rZBo/h+N5XxJWqmnLkGiBLdeAWO468hXfNL1CHeJaiV5GO/KJE51+7xScAu8Fz8fgSXfrlQ5QeKCnaza5eGoaPn+Lh2OG4JvM7Bcj9xOtO9/UZNQWSMuCO3fTtp1JoMSDjwRXZhGZSvi7VSNb2cnl3hf+iecJEStGkYaFBVOI9DuuAQg7QHNd8z7D4itN7Fd+hYWWRS3XDH X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dKRTsH666kTbjlI2IJqbJZD7IRuH0/a8mI2lMqpUZsCkSq1nHYaiBLhtaY3jBAT4MMURpvCLxr575pqa6sHv36lwrEU4KOYYEd+uA2bqMudJmqSWUDbW3WPFpXpBr5iVqI0sOBtmpHLsZw6UKoecVMy4NI5DdrMDljbuPbVn38SnA4Kh84oqelwivATxA0UJYKcQ712Dz1Hp89d+grGUJwFHWMKWyoNjSh1gE7rVkUkTAL0z6aWyM/tNb/Z6SRTrCdhf3sKmTXAqlQgyFKc0nf/SisjJWIICfDkCGakUCjTLNkDJ5ijN+jvEFrbgSQ/eatwz3//VInjSKg4v5xFY94PveUVbd5YB/uhcHLwEFHDwyQqSs4L+j937mG7h6+tN9W6d6XzrT7WidMgj0+KUU0bEF1KF4DuH2dZUz8+XA96GOtCyafymZ5vCKCi+6XKgVvcbzwMNDoSlt9RXy/mHpgE3qw4ruC0vuKPBo3dEKE7ojwUYu6v9Z73gfmwylc3Gvz6J3l+cU1CAnMIguV/Fm1P0ss4RZ75Am9OqjGdoCl/lyyy7EZvnuGM6NFqfFocwiCEU2V8TkfgmOluocdUuQ+8jYmb9zToRxacD9XDyHx/VUeop7pMbifqGPqUBcgt8+NBRSGR9a3l/ykMk8wyM/w== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd314bdb-2926-4788-5761-08d8710e0e84 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:26.4866 (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: nbpux9Yvav+IRpPGH7y01oo2WzJmyMRqMMiA/fXFpFSFve+7hMa9nynOShiXo/eLzRHh6fbKpgefApVAKJCNsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092738_616068_4E1235CE X-CRM114-Status: GOOD ( 14.48 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Thu Oct 15 13:26:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382667 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=X/mmU1Eg; 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=gUiRMb3R; 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=apd25Jst; 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 4CBqpP2XyXz9sRk for ; Fri, 16 Oct 2020 00:27:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ff7+O2Ap7mJXfQWpRgqLW9GfeoCRozjPusLHpdteWKs=; b=X/mmU1EgDeVcXLj4MKbp+r9VL nXdSNpyDsX3cYejSDXF3SXTzugNaw+FkH47mQyPFXvXy7okCP0C9wjMcV2rUlhCdoK0kUosc442Jj WsNCrXEeP28ztsBZvhD9b7Xy5KsT4ILiNpU3vWdvmf8BkM0TFIqGFaUC+efgmcDCJzeO07BVphqkS vz5ld1eehQQHR20w8k1LqHENOyyuSlcg1GLSEHmMkJe8Ky/fe+euCoYetR2owdhD1nqkowfr88ywe bPjSLlnZFXEAgIqcwxI16QBdy5yglhKIamQuGC+DuAw8rzjlK2Ubf8Vf0MIiiC2g0Dxq/9YhCXz6U LIJKaNpTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3I6-0004Ea-LV; Thu, 15 Oct 2020 13:27:34 +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 1kT3I4-0004DJ-Gc for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1602768452; x=1634304452; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=EVQsQqSSEG4MP/aRPY4zJCMkhGcjbdQelhdiBKMohmw=; b=gUiRMb3RNYZDIVE634imYEtPV62xXBtfwDShqZvvvPwvRIwItrjau5/S AA3PDzLn3sGHsbPfTUVmxIROVw5UvkgY+TyoMOc9WU3nzynm1JDPtp1d0 ZkmrMsFDEwdtHcb07siwyKNETOeQYpMMu5AAcKHmGH6+HJAJ2NFk+GC2Y IvKA9917/nIG0X3DQLe0qqkPx1Cu6n8x41NWmRUwL7SSiW1sWCvXwIgC8 es++BVhsIghbMFyc/gTldwd6VmLl9o37A6EamK26T+NxU7c5nioGEQevx jwg0YI3B5FkpOkSAr3pAW3dgTwaNLqdPV30Pv8nzxfO2UfNm38vGxF8a+ Q==; IronPort-SDR: q6rEkYo3H8KCQQqYHzt/0XoF+siYxsw1Esr+r7QoLUYwRIZoFmgu1pIpPbch8hEwARsIuXPSZb 8QR5z7PmekjT/3BZ6wI51if4Wcma7xGnXed8VfueE8eaCQMgTepiRbzIJck9fD+XnYunUCw55s tPunEYGRLhI9Vxq9TuVL6ncXMDLJEB7XsAFAShMAUNukZJsn7160vvH63SQJ+BgwmO64B9NN33 YIDeAeAOOerHcHE+6Qp+Pi8nTTJ/iqZiERYBazBcv82RraCP/Ralmv+wXwzD5tayr8Px55AU4w YuE= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457424" Received: from mail-cys01nam02lp2054.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.54]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:32 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HbN4t9ZE1Tm1vTCPqauwKUUxoXNwp1nQtM+ACX0WX8wYhDwte9taE7FLXQfAsThjQviu3rvtDzwuB7t1L+IZNgvxN9opGnOdPyfF5wOA3y/CLAHRVEvLEnObat9LdbGtlenPer0alHyCKqjnirNrkb1ey1Lo7ZWVm+6J6l4IvNimlQK+V5jQIew0lniRMMlcFXgGc5KCUwjn7cyzX72IqmHR7o7Fno3p8z/7hHdtSPW8QR0UQ5xZqivOP+5vAQE09B/idpS9k71bi2uXCgqpYbL/ghPK2vCdTtetZTYMQP0ttofXWNOCFNnuJPSr3gp0cz+28EzYG8aBIX+L8BcNTw== 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=aL0MR261MM/VWQytajzIh+kKBAbQvN977leaYfoXwTk=; b=KEuk2iMgQBYlWUfmseSM0DJTY/geDjRqzvC1efctk+odGHX0CiYlXXl46QmzLRcRqc17lW3fy4I3M6ml8QWD6I7LgttTHd4m3U8xDw5f6XPTD51Pov01h7CCm2es3At89+96n0GalfThF51pqWDTWsOyMhOTGNWUHcv4Xm/M+fDeRKL3CNjPTLqkLEcFm746/RcCItFN0B/9fqDPqOZW4biAJ+M2jABrSpftJjTTBI8/78UnVAvoUMB1DA2HPNSjfswIU2e8jRa3zJe5lCtxzqVk+Umz5tGE+H3IEBw15x5tA8ewQXP25CjKE72CCam7b1fvdPuDT82BfoJe/bGWgQ== 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=aL0MR261MM/VWQytajzIh+kKBAbQvN977leaYfoXwTk=; b=apd25JstctYRJEzMlrugFiyC6qGJbU9hLYKkTEOTQWHvjzuRFDw3EW8RAwMOyHWqKuAuNiwEb7FDtSaR/C/b+weppjF4TOOBtZuQRYi9/pWTOIhp/VVEdb/E5c+OWCCGFKOZWWZHdA/xkf9mxTPAoc025fUy/w2HkJVyfppLmfM= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:29 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:29 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 02/16] include: sbi: Remove pmp_region callbacks from sbi_platform_operations Date: Thu, 15 Oct 2020 18:56:46 +0530 Message-Id: <20201015132700.2232820-3-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e2018ffb-3183-43f5-fc94-08d8710e1030 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: AGNI9tV6mmZckht/aejXhC9MdY8z0irB2AHeTdNcsg8K89OBLAdEp9nSiqi3Jls+B9itwGf4lfOjGOtMPc96pzT84X83jSrBdjrd7ePmpeXLnAT4gykdpkryEitfDToFriJq/QzJc0u84fKca3NO1vgkhu61IS6lWXmUcsIG4S/Aqxh5eDlGnQOg8BC1XGJBGIkoYaivZ2NhAuYwpAYZh/A9NkQzBn7zBIsbLlNFNGKsItlXmLoNAdbOfVXDy29tIof4F2hC7+1LcbNd+leYN0FquLBpALOZggenSFuoFIRJOQ6WY4NfVtdEwQY/LD0gxk51D1UiSKJ9XxrT6x+nQ9mhMbYOk9cCeOy/WyQNhcN3qg5SUGUWCL5w3BocyrM7 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: aGJjg68cYg/dMarjR+1aW4hq+B57G078YD4obZ4i4P5FrDXemAhNnjR7iDSMCWJ8cGirBunsf3o4XlGLI/ZdGW1yntRT2FJQDz1R6yD8gDFcg/eVx+ZbG9h689omUyMMqDGW1omx4buS0JKWNbA6oD+Tf3a0yC6+ls0Hb+9Y5LBxPiO31ie/lu8pkrbUEGTSuzNMvjqZv6kkROLmH3gZFZi8Fdy40WZFW358fOjLvZzmLaS+rgq9kmYOq902kogYiY5sfDErIQxIa7yF+Pkakd6kD9H82Hwak8JmQYVuzWnmEGqlfDgzfcXWnmbaKBTScgO7fq+CTq/qtXzTIRFXB0C4odgLHLCOlywEh16eYyID53gaQfWQ+MqehsEu+uW8j5EH87IEhAHuRh1V6q0qj1x+hKNjiLX1ZCk491M+NsHmhP5NV3O2QgCMMGfZ0S/BUtwUHEFPPVoRzYo4U2FKrkpTqpw1uL18hnmtFu60Z52bYvpyYKJz38qCn0ggQ/ErHkSCS9XvNKF58wc2TceEStR2sV56U26hma4QDiOx3BI+NP+cB+uJTf1qtBK3zaxtrB5ecZhxF5DM8OCHn1bwlUl2mB4HawIx2l4ikxho8lOxgVHz1eKKxCEXO2ipKOWuGbsxueiBGnekjd/vT8zGSg== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2018ffb-3183-43f5-fc94-08d8710e1030 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:29.4057 (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: uzBHDxSCOIhdGzbTuZxLRuCRsl1OAz0jCkYkUxeLxyAQA7duMt5IVY26YiA1nfkv7T878txsPpZR9rZAz1u9fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092732_812684_F1F5F59E X-CRM114-Status: GOOD ( 18.59 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Thu Oct 15 13:26:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=q37+JwHv; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=NCHZglxo; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-sharedspace-onmicrosoft-com header.b=boi75oAR; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CBqpR2W2Dz9sV1 for ; Fri, 16 Oct 2020 00:27:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/UpQ4mFPEcUTkwmnkoci0/O7u5QcAqTa01xBYk2iKiI=; b=q37+JwHv20KfzCX0EE3c583S9 kQbccw0MNctaWXOo4LYZx4D+/Pax9hMicAPW5BrDYqRaBKG4GgldLtXprDuQz2bDTONlZBLg8H+6z G9k/hRmZxBdMJvLmR+56opLNf7m9FQaghQU7mLIXjMXi+qsPFIFWfXTUesGk8JXmUOPAZTpdAy22J mGlIJjKzLAQjn7z6TXX8yN4RPADJ/iwEfSUj65UP6ZhE1M2aBXgnnrqg6pNR1N7Vpbt5+70G1b78o uNRbREItrCTqpXLNsH5bQrrPzK3IsVd3+ASL6U1Uso4x/nKntL7mmRPTCaycSrLgcKcLVd3iiWUE8 zoAHr1jRQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3I9-0004FG-8u; Thu, 15 Oct 2020 13:27:37 +0000 Received: from esa3.hgst.iphmx.com ([216.71.153.141]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3I6-0004DJ-HE for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1602768454; x=1634304454; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=sbvNykyZ+6H7Fy1xTRek6AfInkDQagsF50UczhsTOKA=; b=NCHZglxoXklRP6C154vOd1cXcd3k2brIRj+zQ1kuZlokWJ/NL57wy873 h2yKYX2bM5tU5klOl36baIXt5pKI1/lpddsvtRNGIWAegYyj7RZc/igyr 7kj1xlFvzZCBY8Hi+rBNsuhacaO6u7ldf1uKTaDw+xkpcW1WCFrp22ljC IncTVZoB6csD+iaSHdtFBX6NBC/L4/dcasWMmXCA4HMxmcex7nonuenuc TExpdhDXAFJDjc77JRd3xmQWkagly7rVQJrz9J4hLuvxiiSzE+8055H9m OIz8PwyDbb5F+bEabtx87zO1X5DrOojFDdQTNGFN2kdqZ6IS/KKphES2h Q==; IronPort-SDR: piO/v95NtTAyf52HkuFvw15G0ZCKWDrWl62Pq7r7X66l2VN1NMntMf1gMi0ExtMLUZMmcAxGRJ B4Wjf2wbKGxR0N/DDMeSoWfVqI+h8kPuTnhGef3+LrpcyiW1p3ABAzAO3sS9gRxMjtpUGX/ie4 MaJ3a2nHHssekV19Bj9lNKw/B4NFKqB5tneTn4iWsJrFSmLd51e0lOD7kqPqWGDCCIy5xyaJng sYrN5IGRhlJCZgbWy7E12+Dxz/Q9j0N4r1kGu/YYYPvdwTW2IUwQL4KOIQxR2CMAmXx5DOV//9 Le0= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457428" Received: from mail-cys01nam02lp2053.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.53]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:34 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=doTjVU9YN+qNjGS7CEorAuVAb/IDQyrg/lHdnURHNHLN/uZXPHvk0C+K8WeSmeNWZvETcW83rlM9bRxPhdtnWsYR3HTDsCOxQqkQMecRRNOLEgZqhTkeR1DR6R/1muXPuXR3Er42atW2AaJgIzvMs683F5JWx6nNH86/9CqnCVPBJxO5i8QbPgobW/Q94SCGFtIoOTKB9Z7m6JaebWdAMIrVIUliX1RSfbSKgqapu9TgrjuRa9qYN0e1Flsk+AyPILfXcksLM9uAzsSRQCpEmLubwBQYkpEmVSWVm+rApY98MWwzEY2rlYFlCd37jDnG1J3UD88v7ZbhawLE1XyVxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=28Z932hgLMY6IQA7KSmGIy1OaJaT7Jn1uWkSC3dvqo0=; b=gRngk2CjowpPLFbrOBsImDBMUNlhwI0gEQuMlQqAJqtt/987RVmxl/UEzm5Oq/VaIjwf/pDosSEIdNID0urdDjqd1Rg31WqiK1xmTNxZTVQOlAq7zbsWhYyuZnDggVGH8f61jOfai8DLbRFopKgdCj8YPQvVaxwOmXOxQ/Jy5tnY7aekWkchKWAFYfuk6uOs9nB8tdKTzLsMFEuY30CT1Y7hCWks8iH8nIHydlUwtf4spGs5DnHPJ8VUlVu9eAzHi8Uw/gv290+g+j3DZK/Hs7J4QQIeOI4j5uq+hWQp+PJQfCMjSdrwvsAi3WuLU6bodgyQYesQzTKdlTtOenIhjg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=28Z932hgLMY6IQA7KSmGIy1OaJaT7Jn1uWkSC3dvqo0=; b=boi75oARmYbD7LbiNGHKn3WAFJAoWqxEv9N+9iCQDSztpL5dPwkjwU+rxe2YLPXW0K/33qHNkOmn7YMt/CFaxB5hbC5p/rvS9o+FCez5vUfTD2aYL5DvUefYAfK03BFUMY10FulLQHv9jkhwidp/edR2lJa6zMIXYa8nLzMLwG4= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:33 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:33 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 03/16] lib: sbi: Configure PMP late in coldboot and warmboot path Date: Thu, 15 Oct 2020 18:56:47 +0530 Message-Id: <20201015132700.2232820-4-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ef6fea36-23e8-4900-ff12-08d8710e1224 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v9irrk6n1PJ7D13yNllATqLbhHxF5Mk+bY4Eazefz5DpaQRNNPb5H40+5NXZtF8n9xlbhzXkzkyqcPSU8DEuSrZwQwFzrvhp9KsdQYYeUa0QqFKPciChh8/hkaoAop71ea2YG56LuvYz9w3XAbwi5YayIym2+CxoxHf6kHo9fmnARe7sdS5bt8YyElwmvCRj6ykM0YPwsTbyjmSGbqR3OSFoseNaGX6CDVIVxga9lujZIfGFfk5MbU0aelVaYDGYzj7cwGNGTP94nkRHzGx1knfeRisvzoPYEwxhrnZWg5Q8VyeRMFOlMLs76/eW8i+bXoWsJST4c9UFLysNFuZgTD+Op8Qs6/X+gRDI6DZNQW5nDO2mZTdqLKJuJp5mAcTI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: iPOzcYISnXJI+R3LQgHsQKmvmqZsTRPLBPzozLNjHtqxmXU5v2pQ7mXKVuGbJiisJXDpM66ewj8VRSIsqMY6xydyhiU8R2ZXkjhSYmGa+x49dXvkA4X8SIy2QDr93qZwpSrbneQ5HZBPmGLdT5oxq5yL1LXq/oPxkdSf+OIlSb4qOioKLC+oZ/q7e9w+7gmyPHVNZPG6i2p8Q6tnYuoTw1ZzjEOmiPin7Uyi7LJPBfFQ6i5zSH9g/qHuTcBcaiLgt1Sf4/LAZq7kBINl0KEwVOEkNb/K+/yl8YLusu6UEO2tYUXeL+qs3bHyfmORGYhHa/EIzVemhB49hlfoW+WEmuxOQ2YrGty99LqhwaS5uLLRr8bDP4/88LyIUBw+dPfb8iwkL0sQvtUEnwhJkg9Q66GEcf8qF9lyJY+3GC96bc27OJhFTFRxk5Gh47vDaiQ3Xd0YSXQ+JNjYcX9eaux6zsYpxheecFRuHZQ9t+FE0XIH8o5eShNm0p5FJrXLEkZhplCeOnY8tEbZyklPBSO4adfdqReloptG1HO7XQr1WkgH5kHl0zTQtMsDw6CSVLAgVVD+W6Hlk4dHLoxm6TehIxjn25Yd+dqUsj4E4nuZ5Lzz8qs0lTnNJlUUPHgGKGZ0aXV6lYhXPxe9jBM+g/wXLQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef6fea36-23e8-4900-ff12-08d8710e1224 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:32.8685 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RyGL19a/wsGYAATV8dhVT0QMMpRzRH53JgweGHMD5MJKcOhhEzddpFra17pPFL8NXkRim4pKFuZhltQ4rkgjqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092734_872698_7CE978EB X-CRM114-Status: GOOD ( 16.18 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We factor-out PMP configuration from sbi_hart_init() as a separate sbi_hart_pmp_configure() function and do the PMP configuration very late in coldboot and warmboot path just before platform_final_init(). Eventually, this enable us to configure PMP totally based on OpenSBI domain where OpenSBI domains can be parsed from device-tree in any of the platform operations except platform_final_init(). Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- include/sbi/sbi_hart.h | 1 + lib/sbi/sbi_hart.c | 4 ++-- lib/sbi/sbi_init.c | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 0ba68f0..9207f4c 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -45,6 +45,7 @@ void sbi_hart_pmp_dump(struct sbi_scratch *scratch); int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, unsigned long daddr, unsigned long mode, unsigned long attr); +int sbi_hart_pmp_configure(struct sbi_scratch *scratch); bool sbi_hart_has_feature(struct sbi_scratch *scratch, unsigned long feature); void sbi_hart_get_features_str(struct sbi_scratch *scratch, char *features_str, int nfstr); diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index edf79b7..7244f1c 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -224,7 +224,7 @@ int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, return SBI_OK; } -static int pmp_init(struct sbi_scratch *scratch, u32 hartid) +int sbi_hart_pmp_configure(struct sbi_scratch *scratch) { u32 pmp_idx = 0; unsigned long fw_start, fw_size_log2; @@ -462,7 +462,7 @@ int sbi_hart_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot) if (rc) return rc; - return pmp_init(scratch, hartid); + return 0; } void __attribute__((noreturn)) sbi_hart_hang(void) diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 65d81ba..85a5f13 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -210,6 +210,10 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); + rc = sbi_hart_pmp_configure(scratch); + if (rc) + sbi_hart_hang(); + rc = sbi_platform_final_init(plat, TRUE); if (rc) sbi_hart_hang(); @@ -266,6 +270,10 @@ static void __noreturn init_warmboot(struct sbi_scratch *scratch, u32 hartid) if (rc) sbi_hart_hang(); + rc = sbi_hart_pmp_configure(scratch); + if (rc) + sbi_hart_hang(); + rc = sbi_platform_final_init(plat, FALSE); if (rc) sbi_hart_hang(); From patchwork Thu Oct 15 13:26:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382668 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=PwAB30Ny; 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=n3kVA6ar; 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=clvPRhXF; 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 4CBqpV3c2hz9sVH for ; Fri, 16 Oct 2020 00:27:46 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i49LTs0ecrNWvsS1yCBDvVfKXyVwMgppluJHm8GT8YY=; b=PwAB30Nydx/H1YfLCcHez/YsW 40Ngy9PQJDH38AY5LSk0dc+XR/Pp3ksoCo5o0VpCQqjevEPkjz6PF4N0iF2emWQj3kO653woPt94c NZ7S6N0l1xlE/zWnZS2oGeZ8TJ0yuMrkUhJaA46FqHJHyT4ZYEaKiDviyopUf/2ROQKPdwU0Wrr7f 3z1hNevuF3wBqxq9276U1TZrrT+8ABa+900zrblnN6zGMciaRTHtCSTHKX1H3MmI4qVAu7X3B5mp8 xhcrPipHsjc9f1URRNRMVYjbqCW4oPrRQ/GwKHkDBWxicgca3nfEfqUpqdqjL8Bsv5UVeuli/7dBf 31BOFCw3A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IB-0004GD-6e; Thu, 15 Oct 2020 13:27:39 +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 1kT3I9-0004DJ-66 for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:38 +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=1602768457; x=1634304457; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=ZGt5gKZWU9O+BjNh47hkqqg1k7HEfTLRWbx/XTiDs+A=; b=n3kVA6arct0CXrQlBqOccDE40L2HyHyjgWv1zAAR25lUEt+AFbI1AZZM A4cN06RttWqYlsELPqW3xZsS0DmPFOqlKWpCS3NVHYUlh3l6kwgG/A435 GB6hvfYJ48YlhXcyVLzct16WvyBB/YN0h19Iig1zxF7+C69HTmyESIe4N fKY7CBT9TO01kanXZ6l/UOdIXQYY70SrYYvslt7tf4FnONxZVP8RW4R1V dXoZbkZ9Gb7c6Po7Z1kTQH0zGUuSuvAdMF4UXFbM0c0oMYe3fTBXfZYMU 32tQ9uUwr+B2zSiaGu9Ah4xwTRYeMlKzcXJczbDgC3NHLtnK6dIcLWbVz Q==; IronPort-SDR: nXnBNtgtrdqCtiU8UL/Jnjt8JtZPD00RdoFY6maKifE2hRWMLUowUN4PS0jpfJndfM/MJFNzqN N4lMld05rgbS752xh/jRnSPOo0ecPXW77tNWra4bZekV/3bTJ5czYCWtiJQSeR9clexd1WpW7v pzehTJnXk5kcr9Es0Ruv63SOe0+zAXJ64NHkDT9W8fSPUzs+MFSa0FaqGVWgwtKmYJbin8CPfm R4qbddZa0K+1u0GJ4n8DIF+xl3EthosHnKxo1Asd3OW7ZnQmlk65YbXelmcaLBXWWoHoTs62R2 kp8= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457434" Received: from mail-cys01nam02lp2050.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.50]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:37 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cjW7FgJiWzywBxh8FYqelavMT8b+Pcpk5xTNHJAJ5cpL77VTu+L68fTdabv2ZXuxrqJo3YMIP7A4SkT2tVz/0ZqFxIccH5zOkjoSc8WwANs51JJKN/rwHankiNC6LVmarzdSPcOHWZBjqDphAm1NqHLZ9qgE8bMDL3tY0eCuTnq8G6Og78uI3QTfhUc9oZuDOjVbyjd95IumifophIsMk6p/e2h9LgaV+TKmata4LguovvM9SSMbeEMnuhDZL1DMqNugVx1X0y82iTz3od1vYqUnFgEXnmsLtVw38zqYMrmqafxV9Y+ncyXhQC/WltktzjqA8T8qNyr3b4QNN/nENQ== 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=6NoDu+zgTmcKnGteg5I8gRopdVVC5+Li12esk1ZA6/M=; b=GN+DiJ/4pdkYhct0Jvow43JdD2x/COgAl2i25H4Q+S0N9Wu1qYrxz+IyqCOKDBgYDSoLU2qEoAPyMLJhnUdYHdtWICUfgQS0TWzdtu4kuxo9UQC+VBYsvjKuPjsScWES0pLBZ6gfMuy9nyx4p6uRI7v4fD3WEin7cSjQmUVW12hTrIBQDdBj058u2nUlooDgv3PDgMwodIXZiwomnZutSBnn5zHQZVjFFeWU5NVOoiE7cqFiRmBuu3oDhywFQ7ciaifDUA9yA6Sm//1ZhWRu7mr7lMw00y/46yRdnAvGYfinQUNzcYLYmtD963yTuEOLGKeHGfgde+Jcyz2qnWEA+Q== 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=6NoDu+zgTmcKnGteg5I8gRopdVVC5+Li12esk1ZA6/M=; b=clvPRhXFPWzNYo/K2783TKjPEuSrLflghjBayI9kglCxuYYSwFT0l9MVxUm2r2BaaA4qH1xNcf33pQoNbvLIORkJGQEbBfCwiJ7UeFxGZI1LIpPF0bS68a+Ma+AUbFYpVfW1yJ5o3qUAX8wC2f20jGy19oCfMsxFv6qTEvy7qg0= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:36 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:36 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 04/16] lib: sbi: Remove redundant hartid parameter from sbi_hart_init() Date: Thu, 15 Oct 2020 18:56:48 +0530 Message-Id: <20201015132700.2232820-5-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b1a73a4f-91e1-46f1-6a0a-08d8710e1475 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: /tqTrjqeR3q7vxRxPFWFNAs6D7arlk7Z9QeaVls7Ts4Dc7AHB7VwvtO7OfBji0ZMTITxB/As1GyPjKMpB8OvxEX87LAWAbVSZYfHsfjAeva8fmVCjBKUI6QW8194pXrUwPN1MDTEoA8nlCu91XuBUvGO9cnUathRvo7hGZK/9IRiPUR05vRFnFR0BqLSkW3AFtTju43SgyL0X/fSWIDrF4snfF+tPXKvE6lk9Lc4wr+dzoejI5ePTtwD8NnOJMw5OTDXAAEWR4QKZuTBpXGSzOK7RkvHblRIkvb301Ibtb/sPb6ElrKhRAuRPzVm0DKRVKDgTR9M3kufmbBj459u63YhIk/OfJm+MFVEm5NoXqN0ew7nUEHXO220MygadCLe X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: oIdRNpttKfQ2F33ZHz0UjoEDeS4KIiurjSXkjclBcP/0LuRtKK9hTRS+XqXGTyPBsS3f5lEAGodENfmdzUaRc2SCvcXI1q5gl//oSJq04xxraxIXjEQRQTFWksdzOg0bhAf2jxUmsafre/+aWBEGxwKiS6QlEkTIeE9OdoH7pkiPIdKRF6ZLh06xmk0nUmd5cjAwYK+sW6PIG7HBgDE2bL/2bVcMlaKvXtLD8E9Vi2v7gm0017gr0py2IwwbRuQDKla0l2tmC740m08iuVfOUf9rmIy3NUNsqmoTPNCxR0CVuzghLiXSyWUpKWvSd4dd9DZZzQXiKTNZ91nIafUbFJfWnb1pfj/WTRTSWrGdmhLN6UR8iWDoGJEOBIpD/KfA0cfIqw93fCo+7qUcdM1kZjn8Ns2X07tVaB21DqyDxAJWki36tqOHl3tKHK9uCpJSzibvPq3aS8X6FyFRBxucNHtQLC9n+s8pnRc1F9xmrKeRJc9yGXviKGE+cEK/DOWroFZ/SV1D7G6uIlfqyjokGO4EdRx9tauqLy77xxrO49GpwX2YaWNRB8aVuYOVIje/XCChYfQViIEFBEx2L7AMXk7IGzakw2r05742hc+ntWpjNrB6wZE57yX9JuLuo2q2bT1nwqJYqFMuP2ACIm6BlA== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1a73a4f-91e1-46f1-6a0a-08d8710e1475 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:36.1294 (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: 6Dlw8JPUkAJovNHHzEco52z4GRNdCy8z8rY1fNnMyaizlR8PSwczlYRzRDjyjMF+6pV9lPFPOBywByCSkdmLOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092737_460421_1AE4A57C X-CRM114-Status: GOOD ( 15.51 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Thu Oct 15 13:26:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382670 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=klXktvFY; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=k5g9Putq; 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=X+JBDa3P; 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 4CBqpY6V0bz9sSs for ; Fri, 16 Oct 2020 00:27:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9gCFhVXXM/1SmYfUA8LrMp3JUyNyHfhabu75Vlj+XAs=; b=klXktvFYYPdHQX9/pR9ayx7AH /hiAbK/2VF1MWjj2yRtr8zPoazPlHzRz/YrTE5/9Oq0Mcyl+nxmrem4stO1RQIYqGOumTDtByxVF7 KPZNnrCRHjtEcpfp9+dXtuspPUZu1ZvXQqNEY0gv2JBk9MyAtnbWQnDPcTlLHIvCuWRF820vLwa4R e/BMGNk6ugrXTtDuN8hcDtwf2KtdsfBBTFOu9uYsSJ3wD0JWlKE4lGpOuYnWlXAUpuOhQrqdQGWR8 aqfMGsOLYKkVYr9fW20fHhH81diUdnrpAtWSVDJbm9Idn+5BLwzWEyq4fWSOk9lmO9fEKN9CpYhfV hK8Wh7dCQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IF-0004I6-GF; Thu, 15 Oct 2020 13:27:43 +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 1kT3IC-0004Fc-Em for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:41 +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=1602768807; x=1634304807; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3CnLDsUXZJFTcw6wRMhYUUETa5tvhEl3FyZbIpEZQPs=; b=k5g9PutqhJUp34fiGkihVYczwROQNaMfhiYEisOQCkwHG+Y0ry23KW8E AQyBTFTcU0efpTd+9LkN6eVFITIWycikew7yRntOepX5gLMoWXx9QQSct O6IKpI727IIbNLJ/UOO5n52OrvYkYwE0NrHv+MVy77YBW7F8ovj2Ogd7G w4xOqCY6OYPsevOPbooRgjczQvnbTbYACKWwe2WmPWlAMZMLYy3dZWJbB kOTKGg6lEHt+6oTsX6QHE5ovazDDnKkiSyrEzGLHEotQQrfJ19JNQMldg N9RQcdrHQ4Mp4cN0cqKhBSktZp8lR+8u8I9BwhkHBPhvva/eKcUV2NByy w==; IronPort-SDR: QkYyOaUxJ834c91Th2iGjvOwBkJR0DPsCE6UtF0E26QvDgIdY6DTcZeZyOWbT0HWzz1/ZqKiZW Q16QEzLvmVECAbm0dqHmXrNzlVIK6yv24C6GUH0gcQUyzR3QZFffm0HZd6/C1TTvoU84znV/qc 2Q3nUTrLL4A2lh0ussJYzCc765sHOkwIbBvxX22NfhyavqblfzgKvb+N2MLQF58hO2P3Oc72s6 SARlWAhhMWJB0ar109MI+u3KA3MOa0U9DNAVE8JB7big2oPQWaKCnIFx/h1Iv/hAerdXW+JgER Rf0= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="253498956" Received: from mail-bn8nam08lp2045.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.45]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:33:26 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y1at+K7VGyrOn7E2tfdb44bTQF6vb3xrQqJbACYpFPFJqh49Qf9Ua2Dtbj4TVtuyqTA+CJfar8j73+fqBpBGpL7APhHnndQFVpxDfrQ663uNzdY9Ni5Rwy4vYDx9HxqdHcY7dDD+T4iXRzcvoOngu6y/j+CH4DXl5/b7Ypl1z2IcQdwK1dp5fqS1u4xBP9e9IRp2bEAGYv9aaGsdaMa29ujOlj51reXXvk3WX6P5H4S5nP3itXxpxlQo6K31d38IGK833Ov2MPVpRDxJ9EYoetYhPtlVdFPwBttTTCvCWFWKgmC4KbDceqEIZuH7NV4mxdgSQFwyjRgIzYobLg9R4A== 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=koYOchMTwVf7noNQ0WVIY2ofhyuN3srMBvS+7KbDUQ+9BHDko0Zgy/c7ADAQEEqzirLWd1NP2us4yNvnoYnoCSfXvD3/ZUJlqw1ab2TXUIzTG1H3+KheBHdgmReZ9uExYqP4GOtPr58B+qexAJVMQLJx69Gh2uuSQNMj3/RrDeXVEKnO1h2la8G2eW4TOltTCjnRFc3q1WqNAhRQTdlos+AB0PCFs9fVGx9a83ZCKvp7cxLdWzK09fkcDHvCD5UFGp41OzjcbYyrLuwYLidBtLrMyRvfz3sstNNZHjvJpwwRHF0KepMLFYWNhReiXcTk+cMP48CAvHBN+5+h3jO+RQ== 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=X+JBDa3PDns2YbN/MuaaA3uaWmqO0vRSb2HKElWyV5fLUDmsynDCe0h78Fcn2uuf/WBhVxW2X8BJWuAUW0yGeTEzTEiIndAQm+fUMSSoquHP9uAVWyYaQn/l822yevlkiuu0IDMSSX3RKSlpzgnFjz43xJoa2anwnKGWEIPcbns= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:39 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:39 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 05/16] include: sbi: Make hartmask pointer const in sbi_hartmask_test_hart() Date: Thu, 15 Oct 2020 18:56:49 +0530 Message-Id: <20201015132700.2232820-6-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4c64198e-a720-4a6c-7e95-08d8710e1602 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: i8K5TRKOV0fTQEDJ0Nv5Jttu9uOE9bU8cdQYcehQNbY+o0urccRs4K5N+RnV2ampKgeWVx21YwQDNcHy0Tf1SAU0YYVpWFljse+NaL8dbgo4ZDL+4bbfBAj0fFTjh6oAH6VA3OjxtLASjTBi5+8v+r30/waIt/6RMDWEKKHl8+9ND/fveyu0RzZP/OHrycHMCLf65TrubQ0xsmBdd5mWFt5T7qFjYvYSdF1i2gHlXLuBvD6pf6mthKkVlCca2G4oG92bDGfRc+Y3kLsw8QDbGBbzjePIuM9fQ2H8/+oEhknhQiHqGNs9SAeIZrlo6gdyhMWqvgdP6uQEVGObAFR6jP+DOpbv46li7R8LxMIwBVK9XRfseqCGSKm3J4qzpZNa X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(4744005)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dF2SMAfAWam5+vql4cx5TNlgvG08J8hbnJScTtMgUPXABXtEpn67z6GgTNpm8vmweRNdXhOIXAk1hAzlG9slVhZU3GCuuuLjhQYCxk2QbwzurIut1k7HK3IeJ6yhJIACHq8Al5U0rMtu7LBD5JJNEQUXpCoxvE7ihrj57FSTfFr5wS5wHEA/SXwH4hg0OETiA45/I618XmogWe7e0UWh784o9yjYOtiKAwOrCWFSYm+KOsR3r6fV9+WRjTjJnJ1WqlWo6K5zROw2FBvh/Z9PSnmQiXzcqYvrztVDW0gluVsexIX/xrlpyi57nnCra5Ko2HLl6tKO84/BI3mWHsbSy5nlDpNCD/xyCTm55YzKB6/ssx7suKynuB/hfbvJkjyqZWOSPUjnMdQ4Wgh93PtzVdgVYYUYjJdUiwDH9Q+uBqtk278PhS4eC5dClwQ/oopJwmOmgpzaN34SGUa9oWjYQUW+7CWjpsiKFtjTE3VzUMSPQUoW3dtB0XTLaQ1HxUAwfo6ehnr+OrWVX1mfyxxek6D6pFcTG6NL04FhAdZzqerBrlwLDUAaTTbAHciZcbAgQzNTd6CmlVbUpFflvfaHyT3+4hSlcMLuoreFEzxBuR81GRLDW2lmC8nNFBFHgFHPg8lUQD5VPkn88PfdfYXu+g== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c64198e-a720-4a6c-7e95-08d8710e1602 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:38.9875 (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: /LwMl90owAhzGj1AreKNclkt8VHgv97mQ5kbAaT2mnqyL9H5DbshWg/3Nz8bw3i9aINEng1UBcrv7GPBD1y2Dg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092740_690130_388C9087 X-CRM114-Status: GOOD ( 15.27 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Thu Oct 15 13:26:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382671 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=pf7ia1Xz; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=f+5BL10b; 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=hs5XgmMB; 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 4CBqpf1tnHz9sRk for ; Fri, 16 Oct 2020 00:27:54 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+CbV9QT7P4Puyk1B8pAAuQOFWhLzkjXKHNZYvXnjfAA=; b=pf7ia1Xz+eVmuzMxFUxe3RE6d 5Tpg1okyYySbDUQ6hkq3ng2Rz7+NNUk6K1rQp8F5cVNAFn/Yq6aIPvW2/P9ORLHsOFotB0jugCxtl ONXNWQVkDWT/yP343ctY+gx0GcF0AFH9ypMkaaAEH+2Fxp74OTzeHkS9iErtPuQwpPp7pVKSaEWgo RZqqhCzrO/oD0bsy5bGNSUapqkoQPJoyqyF75WuPDRjhBBJow9V8w7P7BAomlMkjQRAonIA0ukjZU esRRRI0CjdOW4v4+Q6RWUVm2D1lsSg6QxEx9D8ottj+oGedmYcpBkUu1nzqWD8jKMTZ9nQo3ymCBC f265NykTg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IJ-0004Jg-Gw; Thu, 15 Oct 2020 13:27:47 +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 1kT3IF-0004Fc-JF for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:45 +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=1602768812; x=1634304812; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=tiyMHbhLkZbsD5cAtzoZLz+lqAg1uHurshIdOCzewKQ=; b=f+5BL10b55q3IWjpv3Jz6F9IoMPWTn7sdRUxjg9cS0tw34eYqslsJYSF c6EcH1zucaffBK7jqYd8VguNhgVDxozLkJrmX1CWOOt0qKpCzDH+ly57+ eT1AZbJVwriQjsqm1Te0WvOJUAFD22ZtSMf5cHlvauP+76mKZyMnXue25 DARXlWgPdpG+jm8RY8pa0y0Yqknk9nGlRC3DE6QSSevbgN68LpuEVgs83 obplm49FU8ZpKIbhIINcmUUBiLlG6LUhJ6mulijoxLZFTYUL+10q3MVhp B4QpqNijTl+F4ANn9vILumvMb9cnfj36Lb8h55kq6euxvwSQnKlP1VcP0 w==; IronPort-SDR: VJ33OInyYPsbeJwPFai0NB/pMgYMNEYK6gsKACeB6mSLDbougQRhjerdQdwc4/1bgEl8YwwrHk 6ZK8eIQujiVRAoAepnyqhU/3fje3Oq8Q/9AWkPkbp7SPbM8MLzZJw6k19gGkBNAcGlxnMOEl9o I7HmYqmEQmlpXZkKsR2sLyM1TfO0fBa8nqodIENEAICH51w7gwGv4WvlLqY8c5qTNfrfE/cE1U mxNM4MQ5rqXNOh+gHNueD7l3X4ouRW81JPcofi0bcu87GZM48XU/7ahX14IKbeYm67zrfTQR8L 6UI= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="253498980" Received: from mail-bn8nam08lp2040.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.40]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:33:31 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ab/QmArIDh5V1pqov/koEBhkHLiuHalsBVha+8zw8vFajqcpzwEeGCbSbRJu3DaycCh6EX/lpa8lmAIVMyZfm0rwzKxpcBxDj2eLHDNf3jMVdR4E0VnAfihsPLHK/biXZ2JJ+s438daKy6UkKv41UgMNNbzwqDONSuO8QT1HCHhiJRmOc71JVDsqamwG5Qla7WduNDmSG5dfn7j843HFnHK7azlz1riKrKFz9RuqBFADiF2i4is+Pc4f9AoUlEyLC4ojhG1f56JrEU8iTZjRr4uoKCc08XJEuob+WijCXWwbYTILFEaPMMyn5PpVMf/Fz3k6VDVToJA/MsvADAMWwA== 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=7tqfLlQZ8v7nWnp2N8RPZ/TwdmMjCH7HljU0zZR0cCk=; b=ShjY1Qxb8JQhfv2ZkrdUHClQBb+QhsQOQiwFrvqITgzRPeH1zHQb5xJSIR+wxEfHMGmsNyHFZoIW8aQiSwSjO7Bn2e1lxdT4+W4Zs+GISfeuqAApbwoDfK5mTVNSpWpjdzPebIGIk0s5BGGf3dP+UmwadcNgXtLCjWmdei3lItswBT4CR0/Nd+8RRMZwzdeH2tMAN+GIf9C2tWVvF9l3YuW5Q6jBc7xHdcBBV9qLf+BAw/pS8nl4XCKkXFC/L4c6Xj12aN6ustzvS1DdSUsZaQILHjWWduqxEUtEjgwlR3m/kM5Tm+m4U2zI1kHDqKkSwIaI0vk/yBqoFw0JL771Qw== 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=7tqfLlQZ8v7nWnp2N8RPZ/TwdmMjCH7HljU0zZR0cCk=; b=hs5XgmMBMyZRvzNacNy3LvSlbWTRRmSZAwTYjfAn+G3h9Zaphfoq4BF/Ik2oMkVoymFUfB0n/CkviCI7FmTuWcuYibhoszsA9EqzEtuzvY5q3J8JyH4+Q1Fop4tXZX3con+Yw5OsERpmMct/NduHoObereVTExkTdHVILtrdeMk= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:42 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:41 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 06/16] lib: sbi: Add initial domain support Date: Thu, 15 Oct 2020 18:56:50 +0530 Message-Id: <20201015132700.2232820-7-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6b7ccf0c-013f-4ded-b04e-08d8710e179c X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: gh65EW0GFh5ItrmL5+TmiBCjCQLU1eyQNR1hGXxZfRbwWbErBQzSZX5yraIdG5SWXlxzQEfin5kEAuuDRUq2xnErW9gO+ZWLJPM9L4ErVfvRSz0MrwrVvHwcl3oL55hiPq7eU5UZL9UyMAtnVXD4lcKSJ3Qm1aQ3VmeuqgYyu9zdCazTdBPqFa/GltEVoIwQOrAKVi/US7a8nlFTNl/TokA/hqnHr1zEOUvsvC7wBubiZh8gW+gkpPvnZsHJdxggxsLJPrHVfcCPSiOoba8r9PZNwt0+X7o9c0oeuapTcDBWqSeFVjYC3Y9PIe6lqaEHsMVMhUF1wFuVcMMDRUTnvNhfDut+RTkcbHvfnNKzUfXZSiotT5cyilqBGrHZrzMv X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005)(30864003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: wVyA871/cdzhmFwlVaTulYrfr8r0Yv3r2suOJ7dvrQmJtwwcONYVb0WAIdGbEFzCXiV/JxmwRZMmc7YmLjH0KxeaOa3JelBpS/NEWnsZu/AO+F2Md8fJ2zjwzoLK67xaX1jhKHjDn1s1tYLjgNogVqpNuHvimOiinkLujhRX7yc3k0htX/P45jbAvwnhSFz+n4DDPtl3SYd53PWfCUwW1hGxPp6L4VE2HI/567VsOy/rXUfeMNKCYCyzrkd0QdlNeAT1Xs3lWPYQHetpwVhQB4QNGA/PU3LlBqtGwpRxQTJFZhoTWZZB3LFd56XN18PwYKEa7wBRRoU3rCj7WdYbrg4jdM1HEPFT9tg/WqMUzmDLeErRoLgCxwuV/HlUOxOsdXPW2bWTxxVj4Nta49aAwOcbR/awdY13RUJGV43ESt1aw2qIDBytwZjbRPP/oxKlSoEI3tok4WLcWsBbBMQyrjlngKbmU+1HPLk1NnkyCWJqnITOQAK1CX4B8chx8iin/80LbL8pGKKeMgcw8JC3X/imb29PPWoDtShEZv2adkoQkGVSAPlzLtDTU02mPWddjdRrVOpPgYx8a0ulmaMPS2vTdHVe8p9+fELOiefmlgWr5aPmqH50U3X8UdrOvEy1bDONkI+0Q5RyCSuCxoDIVw== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6b7ccf0c-013f-4ded-b04e-08d8710e179c X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:41.8556 (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: v0dLpsDZP0fCLZKjV6hqUaIwtVDQ7bP1RRhQPS6YMnctoFUHGt84NVyM4GEaNdWYj98gFcGE0Alnr/b2b2B+9g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092743_946842_3CF5B9EC X-CRM114-Status: GOOD ( 29.09 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 | 142 ++++++++++++++ include/sbi/sbi_platform.h | 20 ++ lib/sbi/objects.mk | 1 + lib/sbi/sbi_domain.c | 377 +++++++++++++++++++++++++++++++++++++ lib/sbi/sbi_init.c | 20 ++ 5 files changed, 560 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..17fb013 --- /dev/null +++ b/include/sbi/sbi_domain.h @@ -0,0 +1,142 @@ +/* + * 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; +}; + +/** Maximum number of domains */ +#define SBI_DOMAIN_MAX_INDEX 32 + +/** 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; + /** Privilege 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 region 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_is_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_get_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..53a703e --- /dev/null +++ b/lib/sbi/sbi_domain.c @@ -0,0 +1,377 @@ +/* + * 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_DOMAIN_MAX_INDEX] = { 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_is_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_get_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 presence 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 + * + * We only allow next mode to be S-mode or U-mode.so that we can + * protect M-mode context and enforce checks on memory accesses. + */ + if (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) { + /* + * Ensure that we have room for Domain Index to + * HART ID mapping + */ + if (domain_count <= SBI_DOMAIN_MAX_INDEX) + return SBI_ENOSPC; + + /* 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 Thu Oct 15 13:26:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382672 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=2CBYIZ1p; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=rwk1Mw+J; 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=k4EjTALj; 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 4CBqpk1P9bz9sRk for ; Fri, 16 Oct 2020 00:27:58 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OVnghqCT3e/8ysa1vTLJ39pdsqs5FQW6v8nOX2bYb0k=; b=2CBYIZ1pxarAS6YePNh4voYzO xahXUqM7I+2ILUBtkEYJjbw5nGrNSEboxnzFcyfu+A46hLtdzlaSg2C4vjx4bloJW+kI84z2MDXor PfUcT9aKISFAeI/trDNM5orau6sWROamPb2F4e+UlWaUJ9CdM1+CKjAsn49Du5iSJa4ebdcj23FPI CNbGP/+FY+S6Z4tyNHMboAeZlNgX9Av5HvSaVBJ+GipQP0C1ES3J6uWkg8twLPcujaHwHPBkP7F05 fy8DZqwdglZCORhlv7q7WEGJxylT6BG084Y5MGD9XEvCpJvFo/t8GlY+vIgmlv11USkWiQhYWJUIp vsZv8KHTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IN-0004N0-GM; Thu, 15 Oct 2020 13:27:51 +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 1kT3II-0004Fc-RB for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27: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=1602768817; x=1634304817; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=TE+AVyZLoI6MFYIghjV3m6Eo3B7XDD+AooUXWGAynpA=; b=rwk1Mw+JA5DdTwhxdHSyS/Gjm+rri3KYr424d+00BrzLZGsSgZAOHLI6 vG9gya012xpeP0ioHzn3DHWBCoqHbxOW1u3eaYMum6Mnuv5KZtS9NrIeu XtjEe/iBste7RQj/m5YeJ/ThejauNm+DPj/3DaISlkr0pxUlLmyEWEE3O bKwScl3qp2uxlLH683jrisn3k6o/VOyPwXpnD2WBNiKc/MZNcOXGJ92Rb WQjUvUhTsuDBBeRPk9R4KK7fzQhDSFafbD/1OKIYPY7LaxBclSpSQpWKb YOKCXv/RczoRPpdxtsuqJ/agfMja1HCZIuTMovzcGM+h7IIitvdd7IQzy w==; IronPort-SDR: q3v2f8ZP09moR+G1pZpwJQ3uqasYl1AcUgEi6yFSjUXdeut5XyBC6cxMPIckN9w1fN9rFbo261 IdiJ8rUSEOv7NAg9q7C+UUZpWpjAIhdYIS6A6ICJe9SBiDAOkOIyrloVEDq7gBCWE9w1R0qZB7 6m08cxLKItigDazixZp4DYnuxRoQx1GiGb+Y5LNHEABBQtB1h57r21Bm0YQC1LgPF8wuNCCQZG LSo9kLWFbsMUZIyRUw4d+960Ae4FEHX1xxSVjFfSPcyvFjV7Oy4KrbvCcmGjutLi3ttwgJ4Pnj P5Q= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="253498985" Received: from mail-bn8nam08lp2048.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.48]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:33:36 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jYTZJYwgbKGgTpN5nqqMechz/2ltuNTKI9oK9nlX5Sx5ZHoFMbLbmwO8Kch4Y7YEVdG+/Shwgr6bdtmPmmt2yZ9A2Ry0M/cVlNqvo8kuEPXlhk3X2dETxqwNi1IeB0i1I/RHo15ke0gLno0mw1vFzi1asviBtbf6cAax/FcLT81W1CepCSZ1VCBRLUHHlpUBrtHFa/gzxtsBLi3pF20sT0v3b5egGftUyMdelvIguGd7FmCIPj6raOEWRpRo/vUbKntk522NGDL219nn4K/IkxrPvjTEJuXNTmt8qwQIzucIPG7wdCHonicOE/hnOHwq8nS9CKGko/aQTsEZ/b2ZdA== 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=6AN6syAa6SwDXOMkUpKwDmnMHK/W6ammeJ4hO6U42sI=; b=JwRXg+8gq1Ntq8wNPypR0S6HoXJocdHxtQVlCbEpI+NGUo01h54oamkFKXkmntaL2FldagfhB1+VIDk9NEzUjNCx8zkt8tYmfocbTgv8Q7d91bMrbCIOvGwdttsrHlSmC4PEwByQrdQw6utgyrE6PJq1yNI6Alg2brioWChZfU/VArFXxJyiNRQwRnd7PmM0EufmN32LkpjN/CHhGQWqJf9Z5/+UeVMmj0+79vikNQVkmBnqJCHIJEDDBrEwmebtgYxF3kknIcKfFcg1TksZ5Mqc+LxRIFlZGvuuE4cgIzfLKlPKB14b7duFFvMD5FR/xgYEd7T2/8H2RCqKTTg6/w== 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=6AN6syAa6SwDXOMkUpKwDmnMHK/W6ammeJ4hO6U42sI=; b=k4EjTALjGWqGCIkQ7q8JK8Y4qsFahcQPYuutrlTdyhRku9Z9+E5DZnJ7iqij2d21ZVlNtMPkfag0EYVFXyOiXuVifX9jIooDP6Sj4IkOusOe8C05oF/0eNAaW/570/Rikwd1ncQk2eUgFXG1c5CisETVs70m2lcJaniRosMP0Kw= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:45 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:45 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 07/16] lib: sbi: Extend sbi_hsm_hart_started_mask() for domains Date: Thu, 15 Oct 2020 18:56:51 +0530 Message-Id: <20201015132700.2232820-8-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 10d5bb9f-e49a-4a3e-805e-08d8710e19af X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: eJ3gRUspB+zxJKfhWyEKM0LWXan+h8aRI1XaV4gqj1jYCJm/bffgion1msVQfrQ1jSyuh8giywufFDePB8bnWFYtmrE1UZTRVGepnBo+BhfRRIZimKOqBLuRFbV5WkliqkxFU14sEc4Or5kP+cmQT2dkwEGSh40TqAnlVV9Ys2blwC0MOpm/tBD8UlaIerGeE2/k3OE1gXNwo6NOtSpIbmUI5oilotZzNUABZvd5t2raqZbT2TDBQjJgyrym009Fsyv3LPiCfmvuHOMc+jM2L3+HCkQT9qSaQ9EWX1gxuZKtQ34ImBHBg0XmxlqtE3435tBU2+2RZaveiwMBSB4mvuIL3xJUPVx+GsdsuR0YJ57m68wcsJtR8DqJ8CDbaYnM X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: jgaqKhDLuBhFSyT6WwlzzpXwCu+d4ujxuSOoWQag1F7U2uFciV7/K9yvCt7Ih0ixtwvzKomgNGxNXs+9vmqSyHohsdapArI1tJKshGqXcagpJkj1ObYumj+QEVu/N60/Sukbvc3biNDim0FySNjzEPFwnxPXiHytmhwp5OWlsoYynPFwtXpX3h9OUCvJgZeic+CeyNSwaDh1DzQAWtGAKdpjmbgRK6IEB5iA02DL/WZNM+zNW+2diT+acu46YoMKLoclT1eZdnNcog4/XTYcQC0vtLlaaYeA7+WHNJbIjBEShLtK0jLKg1C+2zbc7y4a1F+1+fFi2lIj/VZvFdXiPbBM3QgfyJmOH44xsf0ayfT+yLIZBUn87yLGWjaZYazodR6Fw/7A0MFrU5pymVCLzPRJsKe16N1r85TN2JPYERn5z/r5yGNbkdEfSVNCgxYYEkVzALJXsgVcqTZhor6HHQ7tcZT9xnFGDfsnPn3oVOxVC9aSE4awPOmeU15TuhIKv180eyqvnauRbaPDnrnofEVkLn3QnmWwF4hOi76TscgGtDP45N4/GxFYMe9cyH4x0lXYzEsta14qbaIuDM/bXfpC98l3iDEsNZby4X6915Mgb2F3iHcQNdCsI5vrRd5bXIMw5DXKJziVYAJ9hwXo3Q== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10d5bb9f-e49a-4a3e-805e-08d8710e19af X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:45.3354 (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: Yt5IsjiLzVBVCdyHj07bMplyItIzUDWsi6l+ThUqE66vh4cK749BrD5zj3kJjhX21h6r8A3r+Irvam5n8+tuAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092747_178792_69B7E388 X-CRM114-Status: GOOD ( 21.22 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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..65e7f3d 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_is_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 Thu Oct 15 13:26:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382673 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=27fnjLLR; 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=XPL5DQJR; 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=I0IZ9ryH; 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 4CBqpm22xpz9sV1 for ; Fri, 16 Oct 2020 00:28:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FKHSAe4BK+BRoGJcNCBgIPaZdUO8TeM5BCwMDzL4/io=; b=27fnjLLRcVCfigs2hJm2bZ34B zkWDvnie2anlGL4snLE4qJULK5hlcmmjpxGvFUS1UBIfFxaeKr/8kcUlsBYu6XXpd8qIVdqDBP8tY RQNPTyMzG0W3jMvXnyjWe67Rgbod+fo+mRVUo+3QPI1dWDCyb15fUeuXnoq8YPnc4rkcBMbKjKUdG qPpHx5Vn2lPmy65JQog036VRbsW36eCyr8vQADpalzx1GaO03HgYeR5C3UEcn/sOHyCBM5uuWrlnl A9zUP+Bb0FhsYfKxex82IEhleqqtHBPE0EP8+LGVrY8UPGl8RbhRzlbvnuNu/PXA5Ehb0c843CxA2 lP6R8AfXg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IQ-0004Nt-2L; Thu, 15 Oct 2020 13:27:54 +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 1kT3IM-0004MS-Mb for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27: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=1602768470; x=1634304470; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Z+idxlDkiDLaljS/znuZSkznyErXDWZ19jwENNlM8PE=; b=XPL5DQJRJ5KQPwAaxeRkkk+9ySKMGwPlZIRNv7pe0cpda5izX4SLF3IV oUb/zunHyzflXjIN6w+Y/J5JEkvplvER7UxVRCMWtjkvoP4X2rP017hHy cQGDO4cthoOIvKHs+b59i6b0uwhdPYW7FnePLwug0bWa9OFYjbjkxN+oS omxVFAdtjIhkL5TBNj+1B1Gcsddgpn7gYtzeocwaL9KZ0yK56ZJ7dDQSW dGtHpCv0GkF6QwiDIbBEW+mucotkj+S6ZBA2ToP9Twsjwv6PRSWYiKwWM CJ/8bfvqD2AP1pukZZDwxMTP3cbqu1WGPW+f/fmYKFAUdsvV+YeqEzZTq A==; IronPort-SDR: HzQmMd8nBEC4dT/kvoVwODRj61Ra4DZm8K1nOhhg2aJw4ElUCHXFHZE/rQIhbEo+NeF+A5mYGk uZF1LNuJ1NXSpVlj3GLEyJy6naLPpdZE6qM9Sc5b0RiZu+Z/jgloaD5Qm73UuJ2afuxAix/m48 OJIhKaCec3L+jsJWEbX0K64F6mvWgL3ga6qFH8BIAFQ/jvDCsutP/28x7L74WarvrZdrHozr08 /loEeBBmr76VeogmfYBDXwmq+YNK5LZIMRifmeBtile+Gh+gQYHTOOAkRtKFAUcVk77BjPUlfY QJk= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457470" Received: from mail-bn8nam08lp2043.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.43]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:49 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RgRA0pxs479ZTcTiPEsZa9epu18xiNt5v9iv9ZRHOcrWOptA9qGoAPYMterLWpA3eSnbWDBP9ksOOdkIc/hMFkII1Ay62M8KqKagDNXRglFuFEPb+Lwwf71omJDKbgiEqUzdnrXPF3xM0ezWIkeqlzeqix6045P4k9WzU/MgbDMswpkbIUkX+YegnVBC5fe7gafhjirNYeAM9Dkp3CaTfhQIs3fEeNNjAZFhMN7SwQTRNgYsQPpydjDATfUGA44TlO5xFqs1Mh1zRMbbW+EKN+elXCKgzaXdY4iitbZsesVAobpav6qSxBkRgTRY5pHt9ZR/J3ArFlB2CIwlX8Xo1A== 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=eQAw14RD576Ie8oAWiv9K+BS3QqGxh9bRa2Rsd+SOto=; b=Slrcsc2ybs+F2pSEq/Ykz6TOYCPY87dcbHf+8JgTLOGBxdTuWFZ8IYgUCC9Uy++CAU3He+sLfetUyGLGD4uxgixMyd+EWq/v8MFgsClOkFQ5yMmESkQE0i60XzZbp8rCd8sF6IUu0FedhnWNTvioSgCYLPgZSIO3FYWrpF4ZEYyNEP4WaqsFNlooN62C3GrUb73kO9Frlv0h+6xroIkMpYFJK935DPwKEwx8c6rOLCY7nGavP0RHczWQm7ZJjw5Ovgy7pYYMMJkWp1yz+QWgpDhJcaYdSew9k+fq14TZpQbxszc1Funz3WBz9wjlNRnD+pjwi55ByS55i3cIn0tStA== 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=eQAw14RD576Ie8oAWiv9K+BS3QqGxh9bRa2Rsd+SOto=; b=I0IZ9ryHj1AJ1/dcdx/sSWw0qwXjf1VYBBjlMv7vcV2JxQmr08FIyVkrsmzFiloHWA8d2WH0MWe+kPq7VcFPDOuyjS3gMHkOL9H7KSuuMo++vOUngM9X80WocNN/u2VHIcEfHb3iFeyd5rfgAU3dzAN618cZm7ShJC0OJduhhlo= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:48 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:48 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 08/16] lib: sbi: Extend sbi_hsm_hart_start() for domains Date: Thu, 15 Oct 2020 18:56:52 +0530 Message-Id: <20201015132700.2232820-9-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c1392049-ec48-462b-8e1a-08d8710e1bb8 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: 4/ufzmbQM1EYdV2Z6etBrvGZT0MMIDlvlts+z95hIYNEjsDPtEUG8KwVg4h8xT5eIVsNMXkdjGwg1QhjkysSLhWFvbQ6l7QjP0PVpmR+7s44mHocjK9WgoR1xyFiry1OOVnjqhMzS0kg5ZsJDyLYvn9n03NLFVJUEaCdVb1AvvwbbQub7bgwqEeol+A1Vk+0D5xK0LRppjP/VTx8M7C6nC9HPnBr2RI5uJob5bvMejcAObucqCPP/ZlTo+gQYqKcC+u2smdhdlPGWaLRLO9I76EHgYm2B1o66RflaC6IXQqF9qGH3/1brG4gup/R0HjZThnOIe9Qs8Ta1cB7N/3wjBAWR+s2npe4q0Ixuzld+YlIBK5u2Aa5vuxhFoVN4woE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KmfUJoX2LuzZaaM3HmtkoDPO4BrK9bQ8biH1PNJwwp2O2cCHk9iZShjJ9dvKmoMuvT5gO0uVhJlBrYw5RqT/lljBRhc0U5l676M8j++Tyxq4hXiS7ddHXgYqcppf+slLAa5N6J0hur9BQEnzjkZZO7oVg9K4Y5c1GSqiPa1LZQnvtHJL0cI9pK5x9LBsYMFy/M4zJqTRV6j9QjnhavmYSHQ9CV6y4DRc/3FosThTlcld15Ms5NYgTk+c90iL9qT7iBhzmhOtFMav2rLKOw5wfzgpiK1QFZFrHIi/yhkbivC/IdOLimMmOgTSyXKciR65dk/Di8Q5zw6i71DWRZh1c+deuLtwLfnECfzIaYybivJlA/QsmDrFy4/MHsKWmWMbwXTkvpic3OsLBiBe8b2mZbMwOlpjdXJJqbuqo/uYOVbaP1bx8p52L6uuFwpf3LQcUuRi7MKQzxymern88HwYf3Fhv2fnLXrk3MACvuu88aDlBMdFatf/b6lkai+CTNhZqjUaBIonrDTz11GqN5bWH6/WFrvthKRFMd47pYol29wTeOgnmaQKwMPiLCsCruKKJZOKwhXKkj1k4peFyg8JxWV8/bxLON1IetOke5LD0PnC3+8GT3t4e2pn+M5KUV3M6/vlzqewAkLKOebvLnKtaQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1392049-ec48-462b-8e1a-08d8710e1bb8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:48.3364 (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: fbomcwwJ2ZD9ddbSJdJJKbs4W3FJztmzFmj3wEmRlFgBVEXnIUH8X8ZXKRPMTFykLO+xQzbXpY96UuL8j5CgJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092750_908330_35556391 X-CRM114-Status: GOOD ( 19.17 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 53a703e..7659409 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -321,8 +321,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 65e7f3d..149acf9 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_is_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 Thu Oct 15 13:26:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382674 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=gpEAj0IM; 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=BAxBaj5J; 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=HSUw+CAo; 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 4CBqpp0vS6z9sRk for ; Fri, 16 Oct 2020 00:28:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Rp3QT7BRT/UK1D7ED865P22yi1JVb7b6/J2FPaWGF6U=; b=gpEAj0IMAhel7zsNDTKyB6aEx ISm7OVSFYWNXA3l+x3TwkCvWXEA4xtItv4mJryITAuUsuH1GdpaOM3tn39HIzge28ariQZUc8MC6+ 7FA+aOMGx08/Yt1gutYmMN4wuqSSQoops/beLR4wCb3KnOLGxrJITlt/32Ci1FuymNz57hZbEuTz6 NEqPhc1fDjoZebiXO7G2BIBzdrL3sL8fOoAEIl1WGEoy8Om2on85Fyhn3KR45V8cCz058yn7b3WeX AxW9USiEnHbhE43xTZXp+iBsn/CT6lyTx1rlb8aZzAHHWhunRUB1nDtfb6THgtozvMkrWWPCCYu7N +hj/TPYqQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IR-0004Ot-OM; Thu, 15 Oct 2020 13:27:55 +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 1kT3IO-0004MS-Us for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:53 +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=1602768473; x=1634304473; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=PDXjKfQiWUBmCU+ZQrRF9/OfQawAl3CCivPJW7yP2mM=; b=BAxBaj5JaVzjMvt2hm3XpouyvMhXbgBPbIAkz/1NLWWEsum/QY8GmzYv NRqS7jQQv8j4zXN2/B4HgLd86WL3i0gRzDFocTsl3BHYmF3Y4eLsIcJK3 qoq3+eV81s9XSgoyad3YQvQk3O4zwWbA3Z5tRYSTl+HRLXoRPv4EcWNul yJjDr0Qb2jOBeY4KyEdg5uWPu9NWwDOfNxAlXLjylcY/AyAcMQu4kMcG4 JZO+kkxpN4YKAB/SipQtlvdPsYCKlReDT5gEckPW04iNDIf8hzx9T77AV SPx8a/BL65dAnshp6l3fb3JoF1c5wtyAqcGtjs3vt5nrDe8q1wKV8O9pA w==; IronPort-SDR: 17xMWyJx3fv6xOpPWjPrtwKDf5OfXHl4XlfgxuC62YFOM+6ZVbLSk+6hjSNS5zr1gn0fwRfFkB 5BhDgX5DFRy9fhZw86Ixsz4d0mE3Q3s8OdDOXnrzXvnaKm6ghnfyt7opkDm6Q12/ks48TBR6iX NHR5f6ThlAuxVofZI1cy0DmTYu4pckyOZA9v8ujESqaqOX5zCcc+CmA5qb0mFQvHiWu7pLqe2O ScV1dfs3wgrVrhnujfMl8pe4v0YqDwfe+TXeX1S1Qzp5RfilTKqrtThLqFP+/CcRB91sce+rU+ Yl0= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457480" Received: from mail-bn8nam08lp2048.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.48]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:52 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V3LVptydBkiKiPozBWSvuyeR2lDIVPIfCNtwvIZkWUgCWA5YZErt5j2AqhFixxh4wlLVL4uRAjrSaFvC6R8GZVZHcJd6rduVh2ZnTT2lv08zpJJ0KrVoOXif1Jtb31rgE2P+a0dLuCvIuxo6/pXSzOLm4aGMBquRu9qKKKYvF3gUX5ndrVXR69+nmW2cM6YvqLykhJzrjpFieom7/qu2bLN89YjORjwsJ9uJqdq6BGWpuUM1whkFGaE69KZKjBU9KWy88DLbVQpsbQ18JIhtOcNCsZKHDLrOIPCD7hDimTNZWyWrz69cyB2GF2KxLk6wfTn6seDglU+EKBlGF6VtbQ== 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=Wy3WRV7mzLRSJ72n0zgekl61py1hteqD4oWhf9AsQdA=; b=ijJSI3UsFARLGpqqHbpGifAWz8otd+T+FpU6RjZW7WMwyU/XtKNL11pKYO5XzzD0BjjPTPI+zxvDMBVUmyKS0cRpcrgwStd0BuUs9p5N/Jca87TBMjbHeO6PGlXBjbBii2Z9gP/B5JLeUg6XnxGnTLSsKoKGBWW8Tn7AP9Amsnk6fljHDQXdOXpOmrJrPeDCMDLTEgxlDwhnraLTV7ZDzak3lbIIvvtSnaKjNSuPY+C8A1uBMkOtOiy9C1CHXnTPEu2DNtAwRI/wcQ1fvVsU/QM2Hkg7+OgKrTMUmWzTPnDEpXGARVPBqW8qlKuhAZd//HR8XYd+24vWwCn7tjJFTg== 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=Wy3WRV7mzLRSJ72n0zgekl61py1hteqD4oWhf9AsQdA=; b=HSUw+CAon2U/CplO6f5Bvrwjtjqy/DVcTlSOFRUxLkuFfrJ54DJaLODytNm7mJBtRB2FRJhU9wrF8LP/knsKLMcY23LpJLkH9TYVZ0CeIghXCOIlDMwHYRiSG8a5jkZjeTX5QxQzAFn28vZsOWO54KL+ad78dKxoEd4t8l0zaWI= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:51 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:51 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 09/16] lib: sbi: Optimize sbi_hsm_hart_started_mask() implementation Date: Thu, 15 Oct 2020 18:56:53 +0530 Message-Id: <20201015132700.2232820-10-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cd0e3185-e531-4b82-2762-08d8710e1d59 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: R7Xto29wwmOnOHSmjPM02alcRCqAnzbvENqMbNX9mAz6vWUB8MoxJcvnXYSdV6heXaE4or3ZPbkifb9/UpSHMOL5IJyHm7D7XCUQcVAZ6B1uPwNZLiuyfPviCvhWWPyTF9p+Kz6qSCxxzLg8NM5d8Q2G/YBXzr1T5CQb1VxsTqyDq2JRgnPHbWiYRomMPiPSDSBfK2TKMHCbKZe7eSqA5eVvdA0EeaduQeG5+y4B74BGCpYdB+Z1j3scbOnImr3O5ATXvyzXgFMFBOBx4TiAFi2PnYy4yKJ16ubP7qBfi789Py+y8sOD6LQ5kd0bwS3JEi/n3Mcp5PwHnt0QABMHNF/nlTu0yfkTuDC15tXrRiUjDpxPWb9zdgopKW0G8Iv0 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: aPEO+4VmfxyKWWXTmZr97G4O1XPzrYdKgbQHfS2KDTXV87Qp2aP8BTWoQDZIXKkIObA7tYP01+pZQ6nCWb6Az8Y+I7K3KkaR498OYzkTbFV1NLD+uwA4N8ybf22sVjHXJaaXDJ2tLQTH0aY5Or51F6NlNP/GYP+OLLcETATpA2x76QO2Rk92PaKVF6LqaxKxB3y0oQXhCnLBQupD6a7Fs84+6zfes5QbNUyo3cHWDd2EuXGCKSdagL+QsYtb5pP1jk8AcxFyvWd0B2DB4ozpvvUTDZGzSNbozGiaY3vG275nKwMuyvVxJCzU2nKHe6FCFuf0XuGL6dstgngFGsVjSclv6GB82ooKmg2gkyAAaKLTZHYSDUMXBLa1NbB5qRfhiBs0CZTJeDOZKJ7BNdPqXVrvW6neZQONuKys9DFKFotYcUbfvQTbJHcRWa8c1t+ovgUMF8xO8/LwhL4ulLvGLI5ZCnOsq1oTU+DTyUy9jNaB2Jit+bP2CUqWPeW0KH9tCXZqIX6v9Cs/6h+xtOnGdFjsj3gEB6hI+cAPZrCpPMaL4h22dthI60nQUjlY2AEHYu6BiUShot+pMl85T6QO3ykL+CkT8GVwu6C87dHaWCPsKpkvXMPAVOFcCnjYwJVKMKe1wsalU7zifj76neBd5Q== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd0e3185-e531-4b82-2762-08d8710e1d59 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:51.4024 (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: jHMpIPI3tTmQB3aKtTh+2Ysh8ZF//QOTunvm1CjfsoBgQBbaq+e1MiBTzUBysR9cQ7q/PfoX5otJbSZyqTnVqg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092753_218094_5272314B X-CRM114-Status: GOOD ( 15.50 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 149acf9..174f8d0 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_is_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_is_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_get_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 Thu Oct 15 13:26:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382675 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=usofDJk2; 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=fzuulRol; 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=qRKv71RK; 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 4CBqps3Y7Vz9sRk for ; Fri, 16 Oct 2020 00:28:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nLLNu2lPs1NUH1lVgjoRiJqQMIlIDHofWsDxX5NLgsI=; b=usofDJk2+G+nrWhXr2zsalL1O joUkHChb76QBkDozLVWAVlOo5jrm0h2lj6f/N6S3fz1uzGdCfmbDIyIlFCju3lc3P7JiKaUo8Ol8C +5Cv8AEesiCdXYvB55zO0HTEo8R050zR9/NMJN0IpHgLWhBn4s/81P2R3y3h6EEZIfsff9gVuk5iu 23kWzp/iMrXpAusRAUpN7eaJDJpV2bu1cc5ILkAMq6zS+1PiVIJ4spL5j3X+boJaHswGzvPRFY2pi 4rMHlaKSFn3QtsqJL/JLs7QR4pSZiYRDwf1of4RlIZnKRrYugcNyw42wh23xlqAxjFKUk+w59Tqd6 5yj2elqNQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IV-0004Ri-GR; Thu, 15 Oct 2020 13:27:59 +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 1kT3IS-0004PA-LA for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27: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=1602768476; x=1634304476; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=xLbjfDdIP577KiMB+jJ1KmvjY4xaFeuK12Z/jgXtFSI=; b=fzuulRolinLWHAIrj1ktt72QReCDafVCt7robrlwyGWonXyyZot+/nJd 6CRvkwTG0j+SuLoMuUu3UiA9qg6/ht7rW3ZC2Dc3U8gINty6gUS9o4dU1 AjknQNIx7jdFp3GZdfcHn2evwzn4FxrXA67SsAJNcxzzP6/JBl3+Oecp2 Axqu1n28qYudu2VZfbreoJcwxQ8xk2qrA7+MDFYd8Kvkss1Aj9sclJP+p h4B053qGY2UaJxcZWe8Nlgt52z9TZJJ3H7qMMhEXQR8udpjPE5C9d8OK7 5Vrdmf2SqvdMrhhnDp1iJKFV91xpLbCAkfSj0yKDn+qhf+Dh7ig1bVWt9 g==; IronPort-SDR: WMe5252vIHFeeCOLrl33jA5qxnwaAxNmjOZIE0WXxtk3Bch77eDVBc9qXi16OMtvHgnqd1w+X5 +WJ/SQM17V7pua0yPcs+Ku/o3qUgp4eKRjQ+zKOZmR08B+zSSoTM3ookL+4MmU4+0U7fNULgCV gRNA5X7h2dSEVn57yZEocYQMHK2hcmEeb6T0+EEVAcEu6X4TBiRlqZhR1uu+OJGHxXvyr+V34s y1A11+/HqhQ5IEwJZYOmSaDXRpEJOrXiKKj0L781Hgw4VXoyhV6nhLGO//zWgHpjN2XyJHvJBU Wts= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457486" Received: from mail-cys01nam02lp2051.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.51]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:56 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E3/C8dBQWxkHQQg5GyzvuMh5KNjHirlwSDG8FVRXNkqtW955vhhjRe6KrRw1ldwxs1W7zGKssfGzmNad+ud/M60AWXBiv4NE7xyp8PJApDnL0Ph2IKw7NGWN/BAmr0feB5ReZNVmB/BQdB341UeC3+VxxpJ5WsT38Sf9zird2FvYdRA1pVOoH/xLuEC+aCI98vY2HUkVL1NXkoYFiBEmX4SSeAbjj9CQWog2BCinNeUPCb2clToUNQMD+Tgx0m3pgVn9bXvI9FIVzsh1Tv5JvAWpS2lUPuwMVYsZiMtv0WZ2+Szt0TNoUk7rh72kgLHnTS5F6jxiNBTdJhH3Xjsj8A== 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=lhquqY/RCoudoFUGReh2bL9jfa17N//9LVdLX1SWNerkfl/LNl+uxkrNvIyEtc0I4XCMiqGIrJhj6OaVo5hAuJaNHZl2y1f7x6Emiu/ATPzXbWQQ5CruLFbTBvLgeZywo+Ou3B0BDqSKD5P2wR4FqqplA5xFCVFLz495+meu1xD0EkQYKtQGsk/MuiU+IuXvRlp8+HWYjw1Kw3tkuZWhXE7B5KeriDQM0tId1gT6X+RUmB8lp68ezk73SUNgZlMZn8KwelLoYiCtzldjCgX0VFHQitqReNuTyYTzRno1nAlD7RcyI7njDb3dbWK6GYmCi7hH1L77WACTCkStnPngdw== 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=qRKv71RK9Wlt1PUtadN/fJOKshNk1SXf6ody90AN7dovZ66h3XF38pIKzPuHMhf6lvTpLt8fn9kYetW0jgoiJt5OP6ayGSU/7B4f08LN4mG2WYELcxinnSDMeteVHEH/8wchd/Rt3iHIzmdpluLHB4nqcHsmRG5o4xHiI4cjhy8= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:55 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:55 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 10/16] lib: sbi: Extend sbi_system_reset() for domains Date: Thu, 15 Oct 2020 18:56:54 +0530 Message-Id: <20201015132700.2232820-11-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 087a846d-29fc-402e-9977-08d8710e1f8c X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: IXpyfw2uFiAzAIOfl2IcLoSuJGEFBOYaLfrElaHqJTdLPIEYwsCwVe95wiIl2/PqgGEnhNMn5K+13dPTUZ9Kl+43SDfnhyOzXKJR4ri3lsLcSAXplkbgR7GrbOeqVeLdiu2qqIiKd4kNHlOCJLkzcbeJZMSt9RnwhXkQDfJkIp5etx84i94o2T1tIlqXNIcHTYcHIBzNneSrZFDeMeQAzONWW5Q39Ukr8yKEqiQud/4SlGG81rpFkDR6xpCPpVGj+tRfW6LITA7XUucpAZfwQ7tzTQSKKstoUZLGz6JiK6xfqTOjceg2baWq6hkoGg+fF5LTESm0BM35QK7xt6fpc7xpEQQkFza+N5Uyw11scp52B9KwdtiqLhoyBElOFLXa X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(4744005)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: kY/az/QpJoJD0p55DerS047mI4Zs342VId02wl4QRw3SrKzRj3RZSK4No/Kez+ssU3o8X69qWP1lJE/nP7AxPZoar3b4Za+CrDYAuWI59bporBUxJl6PJzsts/pxPIBLmzYGHEh3Slfn4JMsF2w6JWpuqpEzqmnSC/9w1DBkeRjQ1w769KI7JQqF9almxJqJWry/hMlFSRF3QmtMpr6PHsEuv+T7Qus4VRQYcSHF7GOy1swsiYmS6zfbQCxMOgpZzSkDmWhw4Mbt6RHSHXRHdnoK1e2TEP9ZVvL/tI5cKsagOX9heOVG7p165LbcEzlctXjGC+rhbK4iFsv/7uWgbpBuCp9LINO4tMSbcT7BgO7agLBi+2izwrnKWz/LLZFwuJzv60doJmd5Erepay/m78q8LjArCXDDR/xfTaxjKqxgPd83JtFuOEZwG4t8RdUkEYqstDp56SI5IuJWR/rFyZoLZS4LrHzNxlm4rjB9bFzSEKUyh1qQYrEgpVdHF7Ec1078SKSLf5M2mxbrEj+uzYI/dNvZ0zcaUjk1hIzQnAr1MhiHFJoqOJGM0xL7rtQD8IdLGiaA3pywescieQ96f/fS7pOcTfBcGY12TjUbn77vak4k6cefj9Apg4qv6eSXTaxcCG7jI5JK9Gf0FgyeLA== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 087a846d-29fc-402e-9977-08d8710e1f8c X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:55.1630 (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: wTuy4auGC7K2V/w1cSAYEjknoVVSLjSzRrJt5aS9QjhMZkDotOGbDNDe/g1+LG4Hn1ZLkxKZq4FiPbfmKZIjUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092756_864340_1F556F96 X-CRM114-Status: GOOD ( 13.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.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Thu Oct 15 13:26:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382676 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=ifLcXhp+; 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=VLLOOHHP; 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=YYxFQg9P; 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 4CBqpv0ghGz9sSs for ; Fri, 16 Oct 2020 00:28:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=94H3+tybMSnY98Q0uSRJyPr85uEd+MRhJ06qbSlJ4v4=; b=ifLcXhp+ZJevoKecTfpgCpzIV tWYMt/NcxR/ogCPQ0fqZps2k8aZU+AhIJv37GA/gVPTMwQA+A8XwzFr82TZlrp2Mb3iCBHUMPgg3f DP2bVp/0fggEP0F90GSyeTl2S+ZPXJ33aHBzs4V20kECKB4MMOKCS91m7ugbTtwl5ytJBDOYegpOo 5XOzCiREBbNM8T4zgrsMnIl+6fe5Kp9B++VEhGuUCcpZxBI3uIpjNtkWSEor6B5XCEcz3rGcwZcQ7 zNPcdwg3ncI3PxqAnbPDmb0TOBtolf16MgCUN3OeJRSekeqQWFT2DjC7e8Yqd7mhdE24MoSHEiOUl OUpR+24tw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3IX-0004Se-5X; Thu, 15 Oct 2020 13:28:01 +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 1kT3IU-0004PA-UZ for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:27:59 +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=1602768479; x=1634304479; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=+G7n26optR0cu9iO3RmNRwqL5hNzUOQZPDdWi2TXcrc=; b=VLLOOHHPdGRBnOtKJ+3+WlVqC/XSirqyTlrpKeB9UCTrzttTOC6mx9rg yZe1Yn41Pk3nh0FMDWdn4gNpw61NS6hZBiKtU12nLEthZ2prBXWyjLfXo pFjYoYXg4TabcLjRtFFVT+p1EmFOiBs4gBWGG/+zZhbQIVtRdcmspQDHd diZ6cBgHIj+OqthdmrTHMP8mD6x1pg/HokoDkbk4CzG9ENkK6u7o/QhHI w6hTqvIaXhZeCbs7UAr+3zE3Mjgl6W+iWIh0etTdgmG4DK7mTt913JIaQ xb0mpOihBeBZBy1yygeIOxGiBvkfKzXoyPlifBh6G+8q5IA460Njv5gZc w==; IronPort-SDR: lpDOKdPVuaVfFmDHF7uKVOYgPmZXTTuMAuOWZCC/+TYvNI+XMhFTmvvr63NUqppFhP1TGI43+3 tZwjy6GKnNW+mgn8xFnBTbN/HCY0YmbnbkPwFWJv0NmKMy5L15iAvu6GV50PXhSBAzLQQy5Oo/ udpISRv97jwZa5wQj1o0jbH5K2WZjybHWGXCIqAfLuxBapPsBQCVO7Q+gnEkDaIKyGirYxUxLf mJIOJ210TWbwSadXpq35ij0Lw2gu/Ac2RP3T3kNj5lLmn7o4SL0NZLXzCsbAeNmjhhgpSVTiO8 msI= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457490" Received: from mail-cys01nam02lp2053.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.53]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:27:58 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h11axPgxzeXBpvYHA4X+qYeyNGric+kHHmM2CiH2cy1JPzNXY/bsfeXaPK8tJOfi7XhT3BYpMsKSRlIkYF9UIVG91/a0y39XhGu29OEXTfYn+fllD0ONSF9qPHCs618O0QClz/qsvSncUPU+HdbuE4fUVS4Wqi02le+YSJiVTeRnZc90z5/u3Ds5JpNW67ErXI0Q3BscxJMJrfQn22RTU/IXiN6FLX0bhei979krOYvVVD68acqNfYDxxmKy04dbDhMuwFptQz0EDzRSMEFNvheYBZfZ3DES6DN/D7D6l7bLSDkwPyA7JoHixYynkeX9dSH6Ql1u2AlIBe1iZgTs2w== 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=X3tFCKBgWA/EaR1XyxpVapqxvx9RKG1AcIKiIPcnqQudLwpTm0wnV1VHN6yaXXU8HTtRI1N+xPhsneKdkEgZAPbAXCOUA45DFWrSfOUCmXYxPc1bemeYwXWn6/pZw2jTTV6v2HRcedFA+eIqsNgDdx/a14Q0tVHEftPBkPD0V3IiTFt7HEvfMnX2kW/CQ0rCqa8TdwdPmB7/05Ei/Rbpob1N0S9pOH6IHBptFnEuIcNK5WHtrYqP7E+J7MuyRFTdj+BtWUUCT2PMJLmVEre4lZj3+xGp2oKE2UtvsmRgVDoD0HN+YFSQjAooRRj6fos0f9Iazngh0r4L7nXar4liSw== 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=YYxFQg9PndUjW+FjdAaD2mbMR+UfYxQFmhO2YKJZVG/GzabIoh+gavHJEyoAjfJnUbTuuobEc3NAJHOOHbLROtZaOxZaF35+f+vFeU3peu92l5O2+mnmEmgUcGRCh5CkkcXXHAPZi/MCSGgs7FqpKwABcrdbfxvl7Jb0Jg8+IrE= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:27:57 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:27:57 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 11/16] lib: utils: Update fdt_reserved_memory_fixup() to use current domain Date: Thu, 15 Oct 2020 18:56:55 +0530 Message-Id: <20201015132700.2232820-12-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b38aea07-3671-4dd4-6f4d-08d8710e2160 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: BzToKQ62kgChQCRdk2XydrQ/EBst7IK+pc7/WT5XpjKoEkyaM5tiFf/iYbhTJyIz+8FXFw6+U+HOHCXmC3KqMNQI2+VTAQMoP6bdD+E7vwSXwYf5vC23QJerQTCr2lw7JtJ+AIfk21BtEXTrpc5WkGZSwXl5b3cX84hG+a+5RZqEJfGgbqHHb5pxzJEJjEKNXYMasAaqnbw1Cb3JPnUT34Y81yLbrZC3G91vBMqMub5t+LFkhE5LOblQZzQwPbTFTEaThVYFnFXTNmnDewkk8wvBbcTQpYEGDNs+BC9xx70cpY9v7GTr1AYEHWSUtD+m+1GNtn5O5yGf72cfv0+ri991AMA/JzQSUB5CHHOiP5OtlTP3BXSnyjxLg94tkBjE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(316002)(54906003)(15650500001)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: KDyToWFWE2/4zlq8+YEqjk+0vN/prrYDQyobrdGMXADdAzjMXRODRWW5siaCcYWpZuNBU+zBVEJUFzrrqOnWPF74AVTU+oNyXHqjIEB4+fhBIb1AvEZ9edxdpN0SVGG56xTsvtZIdz8zfNALnfy1WJSQ0xtNoMO6nulbRYaUrdsOq1Zv8MA0rnOvrLZ35QigJLiTPua2vMBLZaEOmgv8xkC/LwvSUcVIEoA4Ze8fXnY5J0XuiEjshiT0GW8zmUzxQfil//QBPQqO/hqH3/u34/8Hn2U/36iQeaq5LAjxGdZ0z+K/Cptg3Ku4Bndsg8rduGsOqjE8I7zFhKARl2JNh/j3BxypoU8UFS0j0y3hefibG9KRjonK+baU+pTc9aAdQWHGeqKGRYxbDkZNltRFhJ3Aab1uAqCvsvPnkDlvgTAScoXV1/zjeCGK6REp19wU+ZN+yYsd4oTxQFvhbn6V8W9L2GuFciHBFHnTvbA7BGaVGVg71U38u4tYv1q4PpW1GqBgPFP39SJuJP+tz5v/YuILApx6PSS3dXF8GebOkGjc7/DJ5mxsAy2aXed5O3RbCvhF6zQb2rg7cF+XZVoB2l26ZROSvAa1Nw4pSmiDtx1/9a4hzrJEy8h9owPGmnXc/Uawbn5RrYdhYHi1sjwe4w== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b38aea07-3671-4dd4-6f4d-08d8710e2160 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:27:57.8662 (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: G7Znr3F8xBPq1807Pqh2TxOB5ermoNjWg7v5nxPKdb9AO+/kAf+uvQNRxVchLUdiTvs+TQUqSHI33d39fQAMYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092759_172725_28F340F2 X-CRM114-Status: GOOD ( 22.16 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Reviewed-by: Atish Patra --- 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 Thu Oct 15 13:26:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382677 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=YcKI1YWI; 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=EuVB3NsW; 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=a2uEBIzK; 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 4CBqpz0CHsz9sRk for ; Fri, 16 Oct 2020 00:28:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0rqWxFqIzce4HXUo7m+9R5AQDbYXZKTFlHbv1b011SA=; b=YcKI1YWICUU04z3JBRimp7y27 kCRb9cRhE5qDwuM6oiNKx2YVV3vf44SaJh7g6RZLRQAOgekNwD768V88Lup0kbl1jOj5ovmBjl91C iEGQBjWWS3d5aWMqMFArSvj0jOoGyshoz9/ojeixM3TWr+H9KEU7KC1c68QKT+xqlEWjtmLcRDd6y I5FXHY/tkFxwIS/bguFOv74PchTDJhQPHqALdH4diJ/zHgPv77cM+bI0qeW74jWpGmB+oP9Fs2bP+ /uJJc39RXPYakXwf5W7J4cDFIEzEFi3yQegdhUDJwM0kblgKuolQiJHwqEv+qMkTN1yeO4KWMBFHW bR2jLMBCA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3Ia-0004Un-Ky; Thu, 15 Oct 2020 13:28:04 +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 1kT3IY-0004PA-7g for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:28:03 +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=1602768482; x=1634304482; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=jMzCekbcGFfheJbYdnjzYicJYzuPfEgoRqtX8DBysyk=; b=EuVB3NsWtOJp+oPJbYlt9r8SFcrtsguph7ohzXPfWqez8CQmY2zylS63 oSTNBD2naDW+iyY8ZhBdtWO7B7KXRZywRxbPRIWu97Q78gnqdJlodCGrM /epykPYJBH5OV2eTmrdJCMusVNdzx00dBk7VOvBOzuaSESBIiyVyOh+iA OrrFHJ9pLuNB3Msm4kNsJ8FDnCPtKRUC8jsrA6gRySh74El7dSAZ2wSd4 PF2HXmU4zz5ptURzEC+IoqezY168VfdR2myzLhbWaD/nmAXEQsLv9K+oj 2RdP7VnfL9Rtb5nakV5ld5VXDdoXbgcTzXWiG1i64/r0u2BwUzMKPSfSx w==; IronPort-SDR: umsn/KE1cSgHQ+5fLjOuhKvp79qiBILoRmCJhkNGT5SV4dlO3q0lD53HSpwwIFzb9mlouTJvI6 G7JgIW7uAK03+U+UiNAm/OJKkeZyxnWPViPIgWqyBDtJzDXvAb3Qt1tm1OqHddhQbjX3m7xZO7 tdKyoeOXCwQ8hxxoqvHUtOIouYjTY6T+uImOcR9EYrjnYSA5OysPFJS3y7XTY4i90qadz8Xq6H HmvMvqbG2T1g6bDCs7OHw0DZVM1r8CHCnHJFDGyJNrvlGEg0YAI/gUcE5jkscKHCE0/Et3RUE+ 7ic= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457510" Received: from mail-bn8nam08lp2049.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.49]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:28:01 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YzIjCcR0XY/izAOp7UW3dq3P2jNqlQVdZLeb8hfySYBClXXcZJYoyMSl21m941sjjYGcBWF5UQRPH1yar5zPmmp3Rhgf7oXqPuB/R/p/GzXwVrIwCZNBLMhH5Eh2t8agAWYH1NNS4KfPHuEy0DBKNZFLTegaF+2/B2VR4P8fGTxIY2n6DiylhNOHXzQor5Nnl9ICVo3hx+ryZfO0kxDKC/WezZ2y929htoOo/R11/RMpF/7kboSo0eupP/AKwDmw2fyQjs6d/VZAVL/7tG4DKlVgyMC/BTyTXZtjt4WYyQ4DzMaaDJkNBa3lPUlAoW4fyl1HCvxxfDVpa9v2kPf1XA== 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=aXJ4wO1cObE/Dzv41FleZY7YMbmDKqtSyD7pzrb9ivI=; b=iMnsIzmmgOXgS8lun9hhwgtZT+SeKPB43A7kCLcwrhASMlHavylIeJSCDWDx5jllqjURZQ2UExXTZvbbWE7+pVhtie3VQ9KfOy8ImOhooKfIvTR113i6GGvsgKPDx73nuoRwI8L3IqLJCeLFgDn7IWsgvjUuaViqYK/LA7EsewpzGRY8QNYW5qMfoP1nKveuEJfuyZWjmO2RxMBx8T5p4Dk3rwQD+/5QqioNsYnyX5oF5eIR117EPu0q23IsgcLRGXVUScEc7B2sKoE4tVYZmKQ00QryGVX2EhWxT8imW4z6++1bWDG6DHSNasSUZ0dNIjBMbLnmYzr0aJGPDvystQ== 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=aXJ4wO1cObE/Dzv41FleZY7YMbmDKqtSyD7pzrb9ivI=; b=a2uEBIzKk2vtIIfzOMzjvK/TRvJB47hJxrGaa2UAAlBgYB4fG+prKRQbt2vO80c4ogJktWStyUDKpXckTgjIXvMAFb/w5bBYoOaHnil7T/2lxS8E1kfcHQ033bj5FGHD1E3ilWnkGM43vUtFDF8XQpu5Qy4OGy5oaxfsngerMJo= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:28:00 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:28:00 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 12/16] lib: utils: Update fdt_cpu_fixup() to use current domain Date: Thu, 15 Oct 2020 18:56:56 +0530 Message-Id: <20201015132700.2232820-13-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:27:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 55fa4431-e277-44b3-a191-08d8710e2325 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: BHT9f+2YvfTQBn5255xPiHlpBzzX3MkHZpDU4Ri9L+lh2x5POJ2VH7ssAJDO/KkJ54DZ+SYC+35GQwz5SJabL3VlVzuXK/UDHn4w+RlwwdgCfJM9frEkdSz9fmdNyFHRjGlgzFqVTKsmpOtzndl6kkcpiTyBNu1tJo/Rkne54oHwWqVRg6Jb9DAtH86vKKtvixs1/JIR9ZzGdPej89oCs+l3DK0BUFs1122Blobig2cHgeqwCO3B7WktPysAbQRs1atFbspz1ZuhR0OpeqMW/cXL8hfq0dHFlfjbnXIFHIsU4PMBMJYkZPNJj24j4k4tOOxV2tMAEqg2mMxlqpj+Mhn3xOcVqn5k6EViZOJIQ5RIhkQequ/2/ZnyWrzBISbl X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(316002)(54906003)(15650500001)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: lFsclswymIn1sJBFg5ma9fnQ8q9zRN2ALmutgB98bCuPkJv/89h71RMPP6Zb9VUFdiISnJ7pelGSPRVeMn1BF4xbx7/8AzaUtMRW+2PpiDoRNY/D14X5tR9N58ostvsdaLwfBh1YbKQ9Tg4vB2Ir3omNnMvyAJQdBCGf0ip5MKN0I3u0Y8yO7fA7UrZ2Bjdn1kN4iwwfqmRoPCFQmAC8sbLfJY7b/I/3kR8aT6utbbZsGdUv6r55TQiADp2GQCQs9KwriPKnXGz3j/8hOwAdR00NqWc6CqJgdHnFRiwQDuxlpeQPQ7WjlV/6AZagkjVNckCVFLk2OA7bvFe+25uT73cx+QCGEq2+mEk7m1c2vdyRsKxq4Qt4k6FQPkZI9LOucuYYuGI3DFSEJHsLJNMmQhkKzH8EF1hkl0lTMHWc7bUdzagPsi1YxNX04Bwzumrk15KiHhp8X7ucWH4xwS5XCAt6CcPSvGV+HlXx8AY7yeLu/oyj22JeMozpcby1WHSXwfY6YlEWajusU1haWQ+KT5ghHyXydYF5Wf8wQP2GQGA7m2At20KntZb2TYDOuSb6sQ9fov6E8Qro8gdaptzxlyIDZbRntwrUI0wPLtus72nCiGUBsAGuI23PF/7vyyOOqjYw+RgLilLbK18sRNA8+w== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 55fa4431-e277-44b3-a191-08d8710e2325 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:28:00.8763 (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: spL2O8vfWXjVZbreahndHGJZG/bg1mqXpAMvIi6RdXjiciKi3qahw37xPSeUmDosdhyGWRM6cvDTnHgd5KP7sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092802_513129_9A69C1E1 X-CRM114-Status: GOOD ( 17.55 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Reviewed-by: Atish Patra --- 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..eea450d 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_is_assigned_hart(dom, hartid) || !mmu_type || !len) fdt_setprop_string(fdt, cpu_offset, "status", "disabled"); From patchwork Thu Oct 15 13:26:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382678 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=VlRZ/Sv/; 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=RmIWc9i1; 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=l6QLOxXC; 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 4CBqq35jFxz9sRk for ; Fri, 16 Oct 2020 00:28:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BP9aMiYuf61TGDP1s37btJtjsAObMVUqePpx/y/K7CI=; b=VlRZ/Sv/DSOlTH8sTdZWiCRrv 23Vh/vxYwwwGvl7DI0Cd5SEdz1ZD/OrZEEr+kKTxYb7f2Ryj55yqiy8Uf3NLAUPsv1X77eLqx1Pez YRQe8ixHZ408kcHpdQ8HP2EszlmGIn/jt/4DaufGFZ+n+DSZsaVavyYDhpBo1S7lT1TcQkmGlwaeC 4LE3RsTyjXSsUVW3Vz4PtCIAckT6znTlqsH0q4ywtmodXznv7/Rj5kwhhav+zwImNsNfXlc+1X4YA uh0rInxqRWFHkABm38v/TJ38fG7VLrfa77+7eKnfaIcN1V/R+MfhhMahnlUatP2oYyg23XTz1+BrJ xCT0uSUvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3If-0004Xf-HI; Thu, 15 Oct 2020 13:28:09 +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 1kT3Id-0004Vx-HF for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:28: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=1602768487; x=1634304487; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=AJnECo3exLPpj9Zpdy5rDbD+lcUNiRSUTDVnSE1Q/n0=; b=RmIWc9i1WsugAXseN+piIGOWTwEZLVd/++dbipWqYkzkRM+nkcfUJGyK 9Qb9d41Ux8VwQciEOOTjdCvrqDPYfNqeyFp3nx8rONaH/Ep94QkvkwZ58 JqjFjgpMFch77x50759iRIru3BFlStSDyBnajObFfkvxztGsBfWQT2+mu X+hRMSVvzNEwecpttZ/l8M+lJrnaEirhG/CkGx1brrWcO64mcbvBS5ltB YYLRdR4IsHMM6WZ+zM6rYYF55WxTpnUmpCuFEe6osd+QJuLMixiN2gbOq zJAeJBZe5/dAEcWJCja/XLHhbArJ3PdczlQnB9HqMbg1QGSNhwtqHIlnu Q==; IronPort-SDR: 30Sirbo6jrQi1mxQvC5yG2HfOYADSEPnNt4/BuENieYhK+QAwqXRz0mXLdoRH86Sow/Gy0XdUu 4i7VspsrAh+eQoHaVFgYkGy5jgUoXofjToz1EDR/jyha3+9wzgrshzmdI4dY+TVCLQj7GQwwYn r7XZjtVl05mz97Ru16F3I3VXUsGuFQ++ZPCRjBMRryIM3/9XZZQUaXGwZDhverj6wmUheTM65L X+zYAoMhA9vF5wYWNXL4soA5wyYTeQfcA3+WzMypEg6HnALkZFC2Vyjj5AoQpRv9NL2O+WLEdU /uQ= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="149952388" Received: from mail-bn8nam08lp2041.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.41]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:28:05 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SBsMEUHvulLnbFOfY53CrWJKZnnnT+vKSIQJO5x5sizmaIphxVKBLwBKFJU7uwi3r1jxgp5dTaShMYE0vDqMEwZw/jjGnNxvB6NgrSaWbPe8/qlizwVbJr/f7/OL13tLBt6xvVMWbDhR/UgYBu5wR0WXFykba+9G8L3WBkQYo0iJL2UM2idNh/4sXPU3bWzRh2as8+F0DooAzkdpXn7wbgSzIDxbmuzMTN6PcYn+Y+lJWGQeZJIW1qhN6+mtKHi0zI/NYKKmnj/lrnt3t+GjVIS1mN0vA4ggauaOVNYPo2rgg5PO7Nyx0bNU4CdK7xYyCeis50qh1mw033SRNsTLvg== 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=DcUZgslASIdcKJ2sU5RIZ768g5560zitNbfg0SUODbEOsfSrh2AIyBcTUsdYtn+HDo1o47TccLd3/GVr3nqjVcBaCqQCzati+8O7+mIb0Bzbu5vHw0mOmhqg/Nq9V1GJG39zwLjtQPHhM2+Ngk0ODsbktdbFWB7Z4bvisKRGhnEnstcWJkZcFxCAWnnd6qmIj6vRTdIcVv9I9udlSsDpRuc0/4nMngvf8NOC7CNzzEehDdRLfYX6idZjaVJ9L6rJ5r2bDevNdlGvDgfzOL9D7TezpDZJFKyLLTp3QbmmTsUs8d8Y8jv1zlwQO4BOTSGrmqPaV7KuQnnWOPacDj6ygQ== 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=l6QLOxXCgEJy7w5TEcXPhF0xkPnRlGV3worwCZTaDdBXCOQMsluY1s7UsrNjmrtxWu3WN+6k9NMOs1MWP67JOTg2geWPPOA52FyoBapQLnC4P2u2UMjadn7TzJ6xBMNmHWwXFqj7+olv8potKQNLFYvAGjiNa6oPTpBRZrDfs4A= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:28:04 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:28:04 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 13/16] lib: sbi: Remove redundant sbi_hart_pmp_xyz() functions Date: Thu, 15 Oct 2020 18:56:57 +0530 Message-Id: <20201015132700.2232820-14-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:28:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0c7a19dc-f8f0-4ecf-97e5-08d8710e2541 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: VWaOwJ342oVCEHRGP/f0OGt75CcOidyCMyJz4eyGt90WaV+ooLodoFFBFC8netErqR/ANTiiyvspbq424tTAxJxvt+LedHKWax/EErSR+uh0SDH//ZhKRReRK+sdjGEkCNAZmz8V13LsUTi908GkoGwFU5EwtiecX8jJ7QoKPi8uiz627Z9YLRoCvIoi1uPqTyn/DAkb7ZtnpE+iy8fssB3wSrv2wAOByKh9o3V+LWsv4kYckhIxqNC24n5wCdunmJSS9ly8+SYp1ZxzjvPHKGPon5oMW0USDkv6/auUD3OUu9m38zihFPIb+WHRGYIl0XFz0csdNVHZb8wmAejlXcgc9uy8ALV03NNEfLCaVpO+JSr7mLgTppacsQ0PHVgQ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: RV78muunBod1djdYdsCBT5DbtI8gIhsVXdoVKYRKmQ8St6SyfO4da2QAExBH33p8cqqecKF5z5TgWyqkQkQul1Oib9fN6SVHWqXrzxJOVCJGF2GuJVqz6RwTIdTLfeNRDnVz216MkPzTHQ0YRI30TGoj2gwFQx0MBPxNNs0gjitxXjCFotToGkZv6ksNBlgtE683SvLiAr5cXQF9NjWqIkRjhzgYD81uhF+rdPcby82ui6LEkEsCvVYpY8FHVPFKKkcWMqJJP4LUYpPmxcS9lsFJRnNwBIoOScZJqKaUxLCcXE7mhf5PuAQ/GFgHzgg3RYtxRkjC65jRZhs6cc645n/s3CpZw6ppgUPmNRN221TxD2Qqk0JMjiZMGzlhUfsZ9Zyhc8aXKyHi9ZpEK2wtj7acz9sHsw3uMomY1ZSa0xe5DH2wNuEwgoTmOa1O13LSA4iTpSg4ojreE+fut1+rC+l1d16Z2hWLeKgvz4JAmi1fEdbCFGXB9c/tiLZQjkQbzeuNeHP7LXSJwM2wMiSw5NJDy+pbtsvUB0dprhu5Swm4Vs9NtwrmJ6Y+5yVLOf5wogpQqwPeTbSN3z86s0N8goyGEN2K8EJIPG7TyvSSpTigRTx3lctAL9YAuFXkJar0fka2C6EAngUuAMR7bmKhWQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c7a19dc-f8f0-4ecf-97e5-08d8710e2541 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:28:04.5748 (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: 3qwP3HARY6z0TCZApPw3MNwGidfvKa05Bmw/HrXn+Dy6CcGoC5aURTqTojxZ36ho1DJxl0dnaV+UTfOI3xjsKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092807_730528_AE27FE22 X-CRM114-Status: GOOD ( 14.62 ) 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_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Reviewed-by: Atish Patra --- 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 Thu Oct 15 13:26:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1382679 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=TdmVynqa; 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=bma/671K; 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=Ym8xyejG; 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 4CBqq72lf8z9sRk for ; Fri, 16 Oct 2020 00:28:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pX731FFzUCtScya+EMM5Pcbswv6Tdvmn42a3X98EJaM=; b=TdmVynqafVtfQ4Q7hz7XbArti 1AHH58iVI/Ar7o9O6zDVFcvpQtb8HUTXZd/0Lqr5h7CdYm3qcOKTirjOIle4eE8jsvlP0qbr5F4aS Gm3NIOK1+8GMRaxZO+w4XpYC/1G87kgYULSOQm+E7iT54sFEI+ovX7+er5vp/jyZCAi23cAGh9ZbZ rjMPlg4v6iUATOWsZ+aOHEmzGdhPmS3wcEqyFs1PGkK8aPq7vwHJX+fBdmPQnkVFCQnpYyTFrhGSi Si+pRM/zSQwd/LmQsXfzJeTgNs/PH2e3ra0IM53apTo9pewEJpkcx6Th/ncGXbzNnwloBREW5ubPF y8T271M0w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3Ii-0004Z8-8u; Thu, 15 Oct 2020 13:28:12 +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 1kT3If-0004Vx-0G for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:28:09 +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=1602768488; x=1634304488; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=YfIExUeF5qxGAgO3aqk+5/vQZvlAtbsHQHFA40U3tQ4=; b=bma/671KopTTIlGfWY3r4cmxzX/PHch4xjnhMDUxXFq+2dJtWcqCmNME w2YsDW2jyBHe+EJjkvanwK3LpODzisVCfynycgNy4X6vIceFO9ofULUj3 VFda4XNkNeWHn+2RnpRE28wuYnGeRW85eqJa0AkE2ochVhokXaGOHAyEh Uz0jk3q5O/2Vu+KPZ04oRqZMdWhofGgK8n9YzISHtnp8INv1niW3jwV54 zRpzwR/giP3Oszvdc6nt9EVhe/rPGxGtvVHuGceDmNsI8RoGHGq5aTWIw f5+q0bil1PN7c7XHmXvmg6MFrZUtPugkTRLgOHehFZN2MlnAKucBvoEwq g==; IronPort-SDR: Gm9bUTrXBz8gxXyvd5RjkFgHADkckuvc6e7epinobO34TJ4/daKkHjvjBWJpJQqr/Z6TVuajQ+ dt/hDsbLESerg57Ja/2RYNRWw5OZ8PDIZx8LDRv7uTFMmXRH/DEER2AnGbeOCUor0ECJDILJdv khG6x5QKJ3BHTd5szHZ8dMsUxDi3/vlJbQkhYbbB8SdU0kN07997c89h+Cr0BnQDlS3hUNKjRV NnDOnznkgYhmX1Sda82dOhsM8v58hWUzMR45qyVlD9OXaQ/A7ekriosPZ2v7eNcCM/igkHSa9a wQ0= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="149952395" Received: from mail-bn8nam08lp2047.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.47]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:28:07 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PHP9vf/z6QKMXV9DF6qH+0awZ1zlUAYAJxg1BfeyeswT+QzyKeLIuo32Z5vgaedk6Wtx8KqVcfcHh3AlXo1vHFfuAtBMEi2W9b3t7dPzONIbPpZcBBNVyC0sVXxCSaNhFEnGZH5TyF22RpjDooyaBHG9yRlZEypN4+6u/c3ebR9nW1j9aGBn9iKz9mi678P3mZLp8CJ3OjgmmzDA2yFq6r4T4hOJxSlokbEn+EgSIxf7OWZABNIIG8hqhdUao/JTqQIgxv516eEs4O0XtxzzLVT71DNJKX1c3XWLE4ObGV5WuKNNLAHryj/l/1pUN7foFt7vV5AAUKG4x2pYXTpVzw== 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=TO4s1WSPnE8kwsbhLWzt9SetW6llJZD8aoub+XIDfewDrUniCrDpAONrMp1JfOpKdk4WTXd2P5fvZ9pLnxR/jIToaCyFvkJMc7nhEUBWGF8iynCP15FxmQKYj5dQHEryfKYOGSuA+WfVD6tWdzP1alZDxpphv94XhdDFfzQhSSOV3MKwMNDDQsdhoNQ5bMXqBrKasr/8M+AaKMHgfkj7d3f+7ubohdl5FdZ0gOh3+BBySQRtYzZi2vNSydT90ZNcgh25rfN5Noh1okveVBFtZxzBhEq4mhgrgumI1XoZ/H/z7KXGE7Gv9scJDZoww6Y0aGUlnKqBSMWlFS1MVnltfw== 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=Ym8xyejGkvg6F/x579OWAXu6CnWlv4vsw2ZeX3GZw/YAI/RyVZa6Fq8GFoFahIoEcG3Ld1WEo6NhA5sIRWGUUBp8aSBnqHUufEubpRr5CTOFD3aQ/E7njxGhzcLYY6fKY57YWIchJjvDNn4gVut5UO8dgHyieXNXoDWonJFpIIE= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:28:07 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:28:07 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 14/16] lib: sbi: Configure PMP based on domain memory regions Date: Thu, 15 Oct 2020 18:56:58 +0530 Message-Id: <20201015132700.2232820-15-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:28:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3022d3b8-39c4-4780-3d34-08d8710e26ee X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: Jzhj7La4IlbOkVkxvx7qtT3P5H6Meagk79aJ0uYjO5g44wwUDnDZPn6gfHpkBNDQxg5iDdbUrxhMxjIF0/NM+O/iaK7c9IaXqWiPiUl6BoZtpTwNVBNRvzqGwBdtu2VY+EkCKO102WE3gmtFYIN76JMx0bNfNENANBONjJEhp9oqcLg2N+lScV+zzQIwq8szNNVcXEcnSQnS2G7IRmAB6IgKk4QCSCZfMiNe51ByrsSkz4b7dSU2rNxcDxAhN6PEVOgVymrEQvJAkRQMVI6t59b6ESkX6bDRzrUF/jIbPv/xZ5bqzEWPaQe5XbrkBVEbrOtuTkTvdJrsc3j5QLDZje6ur6mnmC61wJeeFm/wrPDBe35AkAJswk57xUI43fxc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: a1X9NH19vybFxFaHMvPH0MFeXGCENHuRhM0zUR2t2W6I+6tFAW55Ckkph1PQl2sBrUCmqLOJLt7APZz6la0M2WYxLJMzJx2/bGa25kMjHxBvEsj/BIrSC1p+4QzEizdn1kGuXmZcoVlTJXxqNEeJa7MTVj+BWCmJ5yRECfA42ahh5i8lt+xQBQif0DQ8ETv1PsjNDS4HJAXNA2URbutX4GQVS1WCBt2RqLOvrlDvjxkk4kQjHduqdFa26dLbLrfU1JFD86CJ9muacfZhtk0Ih1dcBgaAD253r3RRHrGBXYpTF3B5MIjNHkWdl5zws4YmnuVIHLCnAvFpBwjSYahCi358vnmAUSWyS56l0M+XB0PDzmawo1VPFKjoz+laWhh2q/U7lUIrXp6IhWfG25uGZUJqiRkOT1B4YBHlvSmAE/rl3b6gvFz30jvIUz6Q+1odwnng479coxHGSgvlhvJ7j34MENCO3w2OXQiW9Zpzo5yHY51WRN1KMnt7qgJVLA60wbgLhoVm955fT439mOLV2lwPyiORKut8b/4i8TKKslQoZ9EyC6J4NYC+FF9Uvo2WccNcDxNY7bkLj94btiSeExMSLjB/egXK49hptGZiWwTGCldKt9adHb6LnAuyNE2N0FdAM2vOHvjoeNhX5xzxuw== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3022d3b8-39c4-4780-3d34-08d8710e26ee X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:28:07.1332 (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: fvgmS+l5nNUjviZk9e12izq5fyjqTF1vu61eeeWbE2ySbj2xx+tgPo3v0TO2TtSNwLMDJ9GhrZ1y+dU2tWx53w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092809_169488_C2CC9070 X-CRM114-Status: GOOD ( 17.18 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.154.42 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 Reviewed-by: Atish Patra --- 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 Thu Oct 15 13:26: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: 1382680 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=e/PjFphz; dkim=permerror header.d=wdc.com header.i=@wdc.com header.a=rsa-sha1 header.s=dkim.wdc.com header.b=PDA6GV+x; 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=ZJLOKbD4; 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 4CBqqC02SWz9sVH for ; Fri, 16 Oct 2020 00:28:23 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GRRY/0zfNkJ0jQ6c0+nvtPlqO+hU13yJ0/wkCbf2QHY=; b=e/PjFphzJnljea8BBRaczl789 6a0zYU/iKlYksIRTwESB9v81SWiYxlF7DmQ83Z/oMos99KfGsDd98w8Uv3iNC8yp7OsvarF053/zQ w3JNQgpaCcNFnkG4/YSK1XqvIQqEowyN/0Z6xx9H1t/OJ9oOGBUneRgXXkc4RMnYCA+3oXRm59Etl PuOG4YC9AKgmG4k77qP3RZekIpOuLAD8pJewmvGL++y7l+q8HFVpJzHPNziTJNLPRXzFuL8baCMOA 5sEew32ZEcFnvJ7xFvqDl2KSw9AmBXX6X/nFFQBOg9SftZfo9d5zVJQjRKFsE3fd1mkvU+Dktykap V1gnD4oRw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3Im-0004ao-Kl; Thu, 15 Oct 2020 13:28: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 1kT3Ii-0004Z0-7D for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:28: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=1602768855; x=1634304855; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=/ScvrGjSHoRvnSvdAV1RerM+NO05Ri4C2kXsRYy96G8=; b=PDA6GV+xmwOoy4M2dJ0Pn8OXm2ygDHN7HaZbIROMJRhF2hBWYfUjWdFt JRqdaH5YRCMqpNGQ1+sEkzcbzmZpDJk+zF/icodnKSp93iRqESWZ832JR AqNGYBBI8yJiMGLt04NoWxLegmA+c6a+huzeeW9DGoWZJUE83IiTvUXqu StZlP2OX6sQ++lR9HoVx/NoYSHzrXAGRBftvGzmOGfFWH2RVWZEC3jMqR eYalUI3hNuL2tTOZ7bEMet6shKqbmTIOA8Hh/ElYMLYq764umFdIoRkvp RoDXo/wCXGnEnyPr4Blb49GY+OyY+dkWoDFXK53SJ7exg3j9Mdlqo0273 Q==; IronPort-SDR: Qc3xPFNO4B7pYD28H/4sDE9uUQphQkvcDDMbSbjrPhC+JFhvqFR8SoSKf2euf4yoXw/PaxhU4t VtgIIEDhParLc0YaaPHmAyqtuODufP2hdoG59djxQvnH2g1sSf7xbC0fzzdOLsrb2DEnY3L53d PA8iT/vun3r3OOUndffPseITf9Ei0ecEUyIw6DmX8cO79R0P5S/FibZWJ+iZvNcWjjWKmgrWIf X+Y/9Vpn5gbxxe7/OhVaAbV8vDzvKGUrsYoTcK9t+O0mYTWEQ9H6RiX5gXex7eUUu/55kBbmRU GDs= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="253499060" Received: from mail-bn8nam08lp2045.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.45]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:34:13 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvS+5xhqyBQwKsIpV6dMaQPsT6j4ItXgdhLixz/tdMR9W+xjNGeCKBPceilT7zJ1FetjeRyXJ9VBQBecpc4eratQwW2pppVrn135QYqvPmpjU0BXHupqp1O5WLx4oa/k8a89M9io/GRL3te6NOkS0+xKngZwvU6KAG0lj6bVlE0HflqKI9s2Cp4pzf+pKjPY42dIACNsswkojhKnrlYRBUlFSxUxmNWrdpj5Ynm0+ihiNGpgUsXv/lUw7/8pGe1igIA+AgZL0wKpQKTq8dPhJVjkCVtgjMCuHgGB7z9pbndT3qBTeilww5wFx3raOKyzv1BtoVOfgt7eynQyZyLVUA== 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=BOg6M/zAnNRUSzwq1iTSyvor1IHyGnBzG4AmSFbuJwc=; b=WCSghY0oR9esI5iGqxl+rE3gC1e47XiZP/ZE7/AVdOminqhFnlDF6bAYHYcSojw3ALSPoWvBfvk0/LVYpcpUm1GgePHMSfNd8gAk0jVw9T8i5dWXXLuRV41EkfD4ln2So32rlLTbANr8ljaUzUwYz1PWHdiebN7V7oAzModYCxOJNLWy0BfyQz8Colcp81w/pNit2Q76e4JNgynNTwzSnhafFtSn3K7eqbkOkOlLAOEW7Ro8Bkwi0kNRR//4LEVcmFXYinKisGvoWP+KkNTThYCWzVl4QxMAfdPhfnL5mkccXJoQHcs5TLAKCUNGZMpw1In+Y3nh6Ks3H3VfdNMBRw== 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=BOg6M/zAnNRUSzwq1iTSyvor1IHyGnBzG4AmSFbuJwc=; b=ZJLOKbD4Tun9wmSQGbhgecuqLOhVcO1dAy5GTrRJ4rRX630gCR8VrN7TrKP5Z9qoy2SQJsST6ZWgEohN4QeohvsKwKPmOaV+9e8AmvziGhmY64l+K4UltqvEysSJP+V7K60wdAHYEsAqFCAyJ6VbxwyuY1q08JRCtWDjWtqp9Po= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:28:09 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:28:09 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 15/16] lib: sbi: Display domain details in boot prints Date: Thu, 15 Oct 2020 18:56:59 +0530 Message-Id: <20201015132700.2232820-16-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:28:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 30e321e5-d60d-440b-357b-08d8710e2865 X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: Yi1cKpp0l9cql2rUuGaywp/TBrIkLvIFYfT8FavRJNaJUkMLyg+xf4GSLTGAD7DIw5O+20i/Yva2yodHFwhyWauR9JxzdJ0XlWoidWzjYbKiZIeOxpNunVg37G9C6h5lpFpLiAxqwCAewejQueaArnoVwCPXoeHtNsFifI7EIrnsk5ncwfpamp38Nft1vmBXkfADneOslpHyuT9M//bzAR7q+pX5Xk0V4jXSz8mONrGPDgyJvUtM0CA19Kh/71fqW5EmrC3c5IfIWimwbgZNVldjs2xr2LtQgGNf47fZ1OHWK8cBfv/5kQlxEmqecT91hLSgC0xzX/HG1VdZXNPpB2NmqOBAjZKT2B/1mUOXsjClLBSGhMcD1ozYWS2w20/o X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(478600001)(956004)(2616005)(6636002)(4326008)(7696005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: 1BEMoZjqQUm2eht8NMs8aFThcXeBR1VJgC7NYpI+pH3SuO03IYlZC07RWt3C7aFpId38C2ykORRnd/q7Ip7Ye7y3qwVRdSwdFSIopIkz3suCXSWxaRJEAaKqdt95vDFgMHaEc+IRs7OvWBbOFM52HZUrh82ps1RYu8EaO5JkJaAKF5N+ME5KqMj6hvnOY1iBmFmU3eOVSL7pSlwPq4PziWiGEeA6RF6BwZsLeIUufhoEJ6KVVaaqoBqS4/EJmxwUdSiyd8NT1ve0LKhh3POD29T3qBXzflxmJQb1IN8WTIC4tTaZq/fAqmiSj765YAG5qPd7RMN2sQCYdDGvrjDlHycVdcYWDSAa02a8xxmOk0eQNvgm5xsvIDFJwbVEbnQUcbtXyg1GtyBT9OoTKpiBncSaowP1eOopYTId+el7fhSOSrFocxoCt6JctjcB1bjLjvCprzH2gybOShIWEWzWCtudvqtXhFGH1fhKu0dDEgMlWttgh9/YdxWKDyxMRYAHzYNe0GI958IrqQezR5pXEcItHEJ+PKnofCoMrhc/xcPOFkvfd4fnSvLAXFBVezBM4UKJviDcamsDq0kiUYULHM581B3b0kb7mWaAmYcbFQJfMvj2yHYZgR6eCmIu5k7jLP4PrmQZO4c4TvcULeRKeQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30e321e5-d60d-440b-357b-08d8710e2865 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:28:09.7575 (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: KiFgWkVEybX0k68ZIZm61YSZoBN2Gz4Q08LF+bKCuN+UOxLTtTO0YokQjBicDr1ArN3VwR4VnqbcaCsrWQStxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092812_472395_CE3C5428 X-CRM114-Status: GOOD ( 20.58 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We 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 17fb013..646f51d 100644 --- a/include/sbi/sbi_domain.h +++ b/include/sbi/sbi_domain.h @@ -133,6 +133,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 7659409..b51a79d 100644 --- a/lib/sbi/sbi_domain.c +++ b/lib/sbi/sbi_domain.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -240,6 +241,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_is_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 Thu Oct 15 13:27: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: 1382681 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=3Qk34GQH; 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=SBj8Dgow; 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=KFzEB8qe; 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 4CBqqH5Ncqz9sRk for ; Fri, 16 Oct 2020 00:28:27 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pg+pfuJkwLf0IulEVlhG2DZgQCkk521PLQE82QiaaEY=; b=3Qk34GQH0fs1p69Gp0uMhyJTi nie6/d7xIZEFjdEU5Q/Kk537P5siwrHcFDmZ+M2g6SdIRiMrog5OjZJPY3vizYGP1KVSZkwXOF+pU kBdScSSjNyxzBaKn7IOi+RIGQKPmCQGs5TneYrCsnD1ngZhdvOjH6STfzbw/q9/R+PNKucRyKG0+J W7mU7nyow5ZFzmZ2V/HjoqxAhK4M7xXLfS3wrRgVUGkcU3fB6DD0j/Xyb/EWQa+2x94bKOZyWAYcR FUjrs8xcM6gKP+6LEiDnkxJUDagbfoJMaw3wWahFIitkur/LANvY6Q4cG+LeEsN15UD7PustBEMJA DF+vv8v5w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kT3Ir-0004dG-FB; Thu, 15 Oct 2020 13:28:21 +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 1kT3In-0004bO-Jr for opensbi@lists.infradead.org; Thu, 15 Oct 2020 13:28:18 +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=1602768497; x=1634304497; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3XC4cAYUSGKm5rNI8Xq5wxb886i3wDvpqRs50SXERXo=; b=SBj8Dgow7d1br+M/eZXSZbdtG19nj17SI1J5w+6PrL+v3AzIwxjh7Rub Xm6F/scikHSY3AlsFLWQmgY29T4CJqleFc5IvhVNF4AZpcQ7EwfpH+7Nu sPClVkDIez75UK3BFSl7qgHlz5EhySqJbZKtnbBhNdSdVytWBtjeDLI6y u9T4U7vGeeS3v8SkP4EKwQt7637p1yYlHBLYCgfQHG1I6nYBDIuMCxziD 9Ddduse/lCjpUxbXTGiFobCnN6/1CPchnoHe96cSXXLxE5hs0+Z8Q7mgT WIkuDqnFUOCXcyfhij8tJvjTFIEPuSyRt8ZVi9hOu5QP5QivpfxwDu3jF A==; IronPort-SDR: bDz6Ed1XDKD/eWeRNWsR+Fn08NbUnj2r/x9bnyJOt53nePWpn9W2t8PHJVCaO+Fl+KlvVzoFFR 3eCg0KUGd0QuPw46DJOEHoAzRhLPY1qEaurS6Ff7ashSFthiJE00FB/FiH4ZASGSlfgtjqGV3e p73QOqyWB2xeHFYDgQaSKNnWZ6FKY/vBIhZiKfyhpZTzyoHZsCdtS319OhyYV6C75ZMo/a1azr eQ5i2MMRpf4qbx6iTaHKzBWHBqSYOHMBHOutsf8EON2m3uLVT4uUUr4tLi0dmHIJaJ8Fwd2Xkv CTE= X-IronPort-AV: E=Sophos;i="5.77,379,1596470400"; d="scan'208";a="154457542" Received: from mail-bn8nam08lp2048.outbound.protection.outlook.com (HELO NAM04-BN8-obe.outbound.protection.outlook.com) ([104.47.74.48]) by ob1.hgst.iphmx.com with ESMTP; 15 Oct 2020 21:28:16 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fzanzaf4cEQxu8V1nNvF9XzGUQgJ/+mQZw7kYQx20XUrt22EwcKAmIqPJTh4YhvCLRBAvxOImEYUK9DhmpRvuivYjrUAHSKpGZ1J4btBkjphxyHgQYI0/RZIcPRgSZFqJlNXsAG/JJCXRc+PGL13PimsycVBI0XTcjvyUKT09MswJC/fY2Ib4URgTJtIKxwCrPQ6NNvFFg+kxD+1tm1jANEHRvwPzuzf4n1Dm8jNquCN5HInmRlZxboWbMbo186t2vDi1HGkuSQDYCDFEuwTalkH90ehVo/mEc1b9/bICQOGG9YNUXVnnko/Hq9TrOuY6XsrOSK1AIOk+L+581DZag== 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=EmItzTUeqVaiun5cQrQ+KWjND4FnLA2Rv1c2ESXBSgM=; b=LV0UXcrt9RmecKtgl3ZMYgkoIiP0iweDow6ogYeLAhZP3On/Z+vwoAIJswvIiQQj5himWhJ4AtIpBEdCtDqsBFXCVucRSO/gOy2gQMTSwl+a483l/E1kX/F/DyvnZzcfDt5n84ZDuUq1chusKVeON6IQmEMlAt/0PesOD4Re1At0Ic/7fQ3W1mn5U9GnFhs88/kKAc6pPP3Sh8omKBEl2Ir5JMderdFgX2tMRGxH5zfDoJaOqC5APlRVVwLk/bdkSvMRdnApmw187zqnaSmSJV9jCh6BJe0sxUyu8acuY0LRVOfmznyTS9bsvZPQctddveC3+BjMcGz/Q4vZ1VGNAA== 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=EmItzTUeqVaiun5cQrQ+KWjND4FnLA2Rv1c2ESXBSgM=; b=KFzEB8qe3vUtyYkMbN2lS5U1Ndw9ICi9V7Fvk2ZtrD/VEKFDlctX6EWjDKUmPbymXdC/UM/WJOvIAkJzdie87Ledh0dqHllnlsIcb5i5SpG4pzfWXCTQuuc3hw/xX6h08MRsnavnDz221QK3HG59IG6VHLahgKhzkAaWGFo43HE= Authentication-Results: wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=none action=none header.from=wdc.com; Received: from DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) by DM6PR04MB6624.namprd04.prod.outlook.com (2603:10b6:5:1b6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.21; Thu, 15 Oct 2020 13:28:14 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::d035:e2c6:c11:51dd%6]) with mapi id 15.20.3477.021; Thu, 15 Oct 2020 13:28:14 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v2 16/16] docs: Add initial documentation for domain support Date: Thu, 15 Oct 2020 18:57:00 +0530 Message-Id: <20201015132700.2232820-17-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201015132700.2232820-1-anup.patel@wdc.com> References: <20201015132700.2232820-1-anup.patel@wdc.com> X-Originating-IP: [122.167.44.151] X-ClientProxiedBy: MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from wdc.com (122.167.44.151) by MAXPR0101CA0065.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.22 via Frontend Transport; Thu, 15 Oct 2020 13:28:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 521a97e0-1fed-400b-dcea-08d8710e2a2a X-MS-TrafficTypeDiagnostic: DM6PR04MB6624: 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: LkL1ypx/2vt9RXGvKQ/+t37vhjaT4awOpHCDuIZFDPumXSL7xO6/AZQJpV037Q/RtyzmbW0IYDzNNj3cM1e9wP5Im22sksFPa7mFDLfvgBKMN2CpYRC4qeYt/RZa1zpbWa7yY+975cyA9iG4vwJ5jS+J5mZ2UjYoq9SjrgLswWo+s9ornVZTyihwScL0/RXuHqfnaGds98QzZ7E0EUeCb97byBlmqtrSSE0UJtypoIc4NPlXqx3vwNI+UQlXown5Us+nwMGRWH6fRhbtXdp/VYSVxsBQX5fl630JOKZCzywWWL4yKeisGQ3N1AThTT57PiE6qLe2UDjMG77SA1gty59RviP0xZwoC5J6n1r5r9TZUacUq/27AW44gvNydw/Th1wrzGRg1KvS5LVOTrZO0Ruh+hMndzBw165AEOSNqVq7h0miz+YvrCJPQAXbBbma7vUuGPnocyDwKzzp91Adgra8l5T6EEgv3fjYCrfH3cV4EPNW1Pcas1qGdLyM1zAFp8HWJyh2vH9cyGIZh7z1Nw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR04MB6201.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(376002)(39860400002)(136003)(366004)(346002)(2906002)(66946007)(110136005)(66556008)(5660300002)(44832011)(66476007)(36756003)(6666004)(19273905006)(316002)(54906003)(8886007)(8676002)(8936002)(86362001)(34490700002)(1076003)(52116002)(26005)(16526019)(186003)(55016002)(83380400001)(966005)(478600001)(956004)(2616005)(6636002)(83080400001)(4326008)(7696005)(562404015)(563064011); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: GLIRA/0IzuC6tCFZStkCGZbNrpiA5eZIsL6tMkgoYYNrOTW85z5SG7iKcp66ioE88JBFRdnDs1+BfpRzPCeetwyL0kSVhRsxD2DiWf7p2p+TpaH4t7efIEF5cSnFytwIWtDapfxSvfJDNcO5V5bid/PFxCnErRN+4eMS/XLjxJ7LSo535lJUNUaoU93+FDw065fetd6nGDCUm1LnHW5cng0GPTxSr3iwO9vCB5SrbnUquKL/D+Y2mXXJBxkABEClL2vyrQRwR2tXNf+0Y3tS6jpKjT5qJctgjD8Byl1bdjnUOcDfhBiaRp/bKiIzphYwbkvgLvqNs7+E5YcL1+mB5rt27Ihs3t/iVf7TzQYrztBsFJyvDsQTCmWYSZ9TYLESX9n5kBYg/cpC49AGbVfF4oK3CqVOJBhwuDvWGDUr+/gnSUsWiF9xdT+SaEmpspmx7VFeV2Fc/TnNOeEwwXSoQgnOewqH3E/bt+2gO3zyqR4JIv1koGHrI61w1HOxNBJqsouSA1DYzK6nLeQYspxbaBixCRyfwNS5OfZ58GVFscKA3ZhenXc+joZLKZqWWDSO/1YhgK2rmGoAcutruv12rcHEaXRXB4uwZvUCBFFcMkgtZX9QlSy9XG8rRClI0nYp2iptqhQQZPzqDj5LZJAAyw== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 521a97e0-1fed-400b-dcea-08d8710e2a2a X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2020 13:28:13.5700 (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: j2NtgselQFAZAI1e5jhRFJJhAtNUkhVz7RHEhP5HpRD64UgJN2a/XuHnaG6qO+rr/2TUDgNxgOSgQcU2+SAX4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB6624 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201015_092817_886352_B5CB4388 X-CRM114-Status: GOOD ( 26.88 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anup Patel , Anup Patel , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We 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 | 106 +++++++++++++++++++++++++++++++++++++++++ docs/doxygen.cfg | 1 + 3 files changed, 110 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..53967dd --- /dev/null +++ b/docs/domain_support.md @@ -0,0 +1,106 @@ +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, ePMP, IOPMP, SiFive Shield, 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. This can be either S-mode or U-mode. +* **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 cannot 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 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 \