From patchwork Fri Aug 28 03:40:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1352991 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=23xvd3tI; 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=BZE+YQzq; 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=TncD1lHT; 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 4Bd53T5H5xz9sTS for ; Fri, 28 Aug 2020 13:40:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+8mEnXyrZuABk/xVG53NoI0YA71u9rGxiM8K2nBLdnw=; b=23xvd3tIdMcLHorYkMfT8Ia4z xBWQCj3viO4gPuXxACThj+DCKyBQQV9fEw4kfhvkLuhNi11K7f9iQai+kG6A/4Zgp8D7ZqPRKpjYU NIg3ExXtqomz1UR9UfYhhcN4uWrD+Yekstw/nBsdvaiv9gF4ODYSshWcfK8s84KLKx7xITWKaaQoA P+Lj0kWFEIU+LbL5qTEzpsAqdvMZ/QmGywN3DFbyZlB7aV9Xc8PD6MY/S3sZOtwVFvpHTYpTjvYSv 5iOrazvOmiay1XUcqP+ygsilrBQpIiQzVRa82Hw4fDfpbQTbzbpUxoooCzbYpx/uMhWYJX46dJneV +nDTK/CIw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBVFw-00071F-69; Fri, 28 Aug 2020 03:40:48 +0000 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBVFt-00070a-6h for opensbi@lists.infradead.org; Fri, 28 Aug 2020 03:40:46 +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=1598586045; x=1630122045; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=rjV6Fm8CbMuWb2ecCY0QxOygKYER+QcF8a53eRBx76g=; b=BZE+YQzqQ54Eo2zkFWzajGgTBU9l+UtXY/PvOVuEPsf8dzQUW0CvjJn9 O8II7C0zIS5kvGjaIPkjxGW2ZYOXapigzR4GjZ3sA/N+QTaF0QMG8SNDp yKZA+1C259SWB6FitFAyoEVXf4AxHpOFViZ4ryHTDm5ppTb0p0gW0TXHP 0ocQvElEsKyteTqzLR19i4I3tbhEYwAzEvXYMiwU5qvGq64pO9ODaqHi8 a6rrKM9xpeZo7OEZGb95N/cCyZhz6zEnb4ZPmRZ1vqNME+VvU6IPJL3Z3 ewd+pwTUSqHPqIbdmr9Sd4PXxwOpK1doti9GfocI404993WLdnH4zDDf0 g==; IronPort-SDR: 02YY+lT0iliAN3E4DySnthE8LOXZoQRPh5a+2ByHWClwb3Nrx5aintWryI8G4EZ6Ya3toCkgg9 ZjDoJAfsM2YuptbSkoMRCxURlX7H63kQoRPXXLzBOd4FWbDS0PQDpgAE6/qmBZ0/ehcCURA8Mf rreM+4iDehAn1H3BfnMQ8bvOscrA3JW89siBJ/TxcLkPSQAR8q5/4tyrSfRC6+jyo4ZAawWiQC KwyEFHZTcYFelH1rqQgSFa7OJaxpUiTpCdbaqMyvjvZBfrIkAOWhGQ4XaLgX7iQEuLfdqGaDjX lXk= X-IronPort-AV: E=Sophos;i="5.76,362,1592841600"; d="scan'208";a="145969967" Received: from mail-dm6nam12lp2176.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.176]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2020 11:40:41 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FHJFop4LB0jeDVN7PfRK3Dos7NA+8Q16mqlCMsL2NWcmUPcv0nadyboB1se8mbfAUAJR9yYAWPJsjqjJidffYwVfyLpVKw51c+laHATLFkVeMdqErdyClH5tQB82aawH1xw+wpw1gb0wy6pywgX2zJJU6y6mw1IxG5c/vnoN1cGWu5zUx8juMh+ynueSHPwWAuL/pPLwMRjQDOFmyXBFIEyoL6JCuCJ5HZ1PQQnsXsMHSuLM6sgCqRKHFQ/GoivGFADchNqBWGjErvF07t4ZfKMbnwIdV5KUmVTeYL/JWUQCBPqcz1HyyxGsLk9rWNguI7QTiyLEg7FKIO9841f1sw== 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=a1mW+lh7s8+RrfkdLdJJTqsksry1cJlEncmOviPl49c=; b=HM6ZcN+gZACKHn5D6yCKVfyE2eMYFqDB1DnAgFfc48vO7s62F6hHgpRbGTFeRe66DBJoV4I2n4omMSCMO83L5ZDffA39x7irCisTZU5sWzJJH1M2CREMBSDSHrS5Tmd2Swc4PiT8Oxj4km/U5K40NRwdvgYe3Lszy3iVdwEke1CBN+Q88cswc0cvHZ6UbeJjdw/oPEQFZkXl//Cz7Wcz6QVHVwpbA90YJJ0OSzpwBk9qNCOHrZm27f4yyhih5nDHSENOnANUKHA9fVKffxJL8ct3bXQetSAwTFE/3HqX/olBD+u4z5YhsI51j+Xdls2eQXaVlg02KQDfXhCHWvqQAQ== 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=a1mW+lh7s8+RrfkdLdJJTqsksry1cJlEncmOviPl49c=; b=TncD1lHToVM1WP2lb5mM350oTDc+5UBzo6Fg8LIj0KuDbDNOvbqYu+y6uMg0Vr1lPKnO/9dQVq3O1qukpos4llGnCwqUxLe1HCEO5OV/Gh1ZgR1M4h/Y3jTK9r6fqYNWEtfDFdEUNtyLiW8RLaegRx/3YOGK+RN/UwbwIu5p9aY= 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 DM6PR04MB4124.namprd04.prod.outlook.com (2603:10b6:5:95::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19; Fri, 28 Aug 2020 03:40:38 +0000 Received: from DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e]) by DM6PR04MB6201.namprd04.prod.outlook.com ([fe80::607a:44ed:1477:83e%7]) with mapi id 15.20.3326.023; Fri, 28 Aug 2020 03:40:38 +0000 From: Anup Patel To: Atish Patra , Alistair Francis Subject: [PATCH v3 1/5] lib: sbi: Remove redundant SBI_HART_HAS_PMP feature Date: Fri, 28 Aug 2020 09:10:08 +0530 Message-Id: <20200828034012.144048-2-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200828034012.144048-1-anup.patel@wdc.com> References: <20200828034012.144048-1-anup.patel@wdc.com> X-ClientProxiedBy: BM1PR0101CA0022.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::32) To DM6PR04MB6201.namprd04.prod.outlook.com (2603:10b6:5:127::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from 255.255.255.255 (255.255.255.255) by BM1PR0101CA0022.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3326.19 via Frontend Transport; Fri, 28 Aug 2020 03:40:35 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [103.56.183.50] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8079dd27-ac63-4d02-38db-08d84b042120 X-MS-TrafficTypeDiagnostic: DM6PR04MB4124: 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: K0khAouL+oB5ZhrA5uCrzyphozlE7tyeUSsaZk5Ap5g3Fet1jqQsEbuco8Ap/zPIs08K3N8neh86e8Xl8Cw2jVIlrrqg+xWlxqEaHp38tOqbJr+PO6TSMv3ZcHrLhOBFbDRDziSGw04YRpyWy7R5Ey7WoPLDAt3Up25Soz6aWqZLRK5Kt061tBqCi4PdaODbY4KeJnEgO90WAVotBkYb+Twi1HffUmGcZ9uAqi2zzw/mFC+jXcy8lXjcQKHqUyLqJSc90RCMncFToL57LSnTmBBEHSw7s90gTzPbQsBNVQCY+j93x00n8rq3fYkTG8S2ZkXqTjMvHjRVnLNcmUEFzQ== 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)(136003)(366004)(396003)(39860400002)(376002)(346002)(6636002)(5660300002)(6666004)(316002)(2906002)(83380400001)(8676002)(4326008)(1076003)(66476007)(8936002)(2616005)(956004)(66946007)(44832011)(6486002)(26005)(478600001)(54906003)(36756003)(186003)(66556008)(110136005)(52116002)(86362001)(16576012); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Q7lS/r1gK3WO5UgKIFT0Cxe6Y2i8AJiSXQ8+owcePbh2ihTs3TnUgO5rmU8JTUP821X6btVrzZVRYeCCAFHsd5w7yB4VbgOU7DztiNdbKZsqcu7Znnq+xOhuqDds1w8Q9DkR4Us3ccIFh0SkBxkNiKvudHlL1L07pcmZ/bm2qvPZuQHT4S0n7Y7BcxUBpNEB79C9W8KnH7dK0KEn/I8K5d3GLQzDd4Gxc0nJGX48O5a0PvGTdkaB7WWiLQG+PZxZdm2PNzpayvogs2MrK0ABiDmP+E3v0dyuNSiYcunsdayohfv8jS3/y9C7MIyU0GZ1ZgkTb9guM1EsdWAz6A5sfUFcupOaRNpHU0hP1kPWaW1TkQ3RTBEwSIuH9IrNM+La+grGa6MEH7M8W2jQgtdfStMFyUpBGuNAuqFfzx8oSJWh+Z2Oln5hZjEpd6sGFjTdmnPkxh8BWGKGPrrO6aTUcDuvBdxg0o+hF2v6iHGtudFKB6c4ess/1NYS1K0aytlwNkgijhsCYq3O5KpuPtTRQt038RG0NHl8O7Ae8uYiAsY6fvMNyNK7fE3jHHVf3TkhV6nXZWemNhjQgl4Y3lvknSJwfFWjNQi0PBGpag1n5Ui2CKsqitZy6iSsN+Vo9CENKfyY1GLOZPtJownxpOssJQ== X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8079dd27-ac63-4d02-38db-08d84b042120 X-MS-Exchange-CrossTenant-AuthSource: DM6PR04MB6201.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2020 03:40:38.3375 (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: ldBC73iEhAP51gXOILvjiEmXJQ+bRsmxg6IA4az7aX5y4JrKv3fQtH16VlPHk7MSB1jk5dG+OXh8Jr4NJhmmqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR04MB4124 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200827_234045_427029_93A33599 X-CRM114-Status: GOOD ( 19.66 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.2 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] 1.3 RCVD_ILLEGAL_IP Received: contains illegal IP address -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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.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 , Alistair Francis , opensbi@lists.infradead.org Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The SBI_HART_HAS_PMP feature is redundant because we already have number of PMP regions returned by sbi_hart_pmp_count(). Checking whether PMP is supported for a HART can be simply done by checking non-zero value returned by sbi_hart_pmp_count(). Signed-off-by: Anup Patel Reviewed-by: Alistair Francis Reviewed-by: Atish Patra --- include/sbi/sbi_hart.h | 8 +++----- lib/sbi/sbi_hart.c | 15 +-------------- lib/utils/fdt/fdt_fixup.c | 2 +- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 51c2c35..c2ea686 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -14,14 +14,12 @@ /** Possible feature flags of a hart */ enum sbi_hart_features { - /** Hart has PMP support */ - SBI_HART_HAS_PMP = (1 << 0), /** Hart has S-mode counter enable */ - SBI_HART_HAS_SCOUNTEREN = (1 << 1), + SBI_HART_HAS_SCOUNTEREN = (1 << 0), /** Hart has M-mode counter enable */ - SBI_HART_HAS_MCOUNTEREN = (1 << 2), + SBI_HART_HAS_MCOUNTEREN = (1 << 1), /** HART has timer csr implementation in hardware */ - SBI_HART_HAS_TIME = (1 << 3), + SBI_HART_HAS_TIME = (1 << 2), /** Last index of Hart features*/ SBI_HART_HAS_LAST_FEATURE = SBI_HART_HAS_TIME, diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index fa20bd2..80ed86a 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -158,9 +158,6 @@ void sbi_hart_pmp_dump(struct sbi_scratch *scratch) unsigned long prot, addr, size; unsigned int i, pmp_count; - if (!sbi_hart_has_feature(scratch, SBI_HART_HAS_PMP)) - return; - pmp_count = sbi_hart_pmp_count(scratch); for (i = 0; i < pmp_count; i++) { pmp_get(i, &prot, &addr, &size); @@ -190,9 +187,6 @@ int sbi_hart_pmp_check_addr(struct sbi_scratch *scratch, unsigned long addr, unsigned long prot, size, tempaddr; unsigned int i, pmp_count; - if (!sbi_hart_has_feature(scratch, SBI_HART_HAS_PMP)) - return SBI_OK; - pmp_count = sbi_hart_pmp_count(scratch); for (i = 0; i < pmp_count; i++) { pmp_get(i, &prot, &tempaddr, &size); @@ -213,7 +207,7 @@ static int pmp_init(struct sbi_scratch *scratch, u32 hartid) ulong prot, addr, log2size; const struct sbi_platform *plat = sbi_platform_ptr(scratch); - if (!sbi_hart_has_feature(scratch, SBI_HART_HAS_PMP)) + if (!sbi_hart_pmp_count(scratch)) return 0; /* Firmware PMP region to protect OpenSBI firmware */ @@ -276,9 +270,6 @@ static inline char *sbi_hart_feature_id2string(unsigned long feature) return NULL; switch (feature) { - case SBI_HART_HAS_PMP: - fstr = "pmp"; - break; case SBI_HART_HAS_SCOUNTEREN: fstr = "scounteren"; break; @@ -375,10 +366,6 @@ static void hart_detect_features(struct sbi_scratch *scratch) __detect_pmp(CSR_PMPADDR15); #undef __detect_pmp - /* Set hart PMP feature if we have at least one PMP region */ - if (hfeatures->pmp_count) - hfeatures->features |= SBI_HART_HAS_PMP; - /* Detect if hart supports SCOUNTEREN feature */ trap.cause = 0; val = csr_read_allowed(CSR_SCOUNTEREN, (unsigned long)&trap); diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c index a3bccae..4da7397 100644 --- a/lib/utils/fdt/fdt_fixup.c +++ b/lib/utils/fdt/fdt_fixup.c @@ -199,7 +199,7 @@ int fdt_reserved_memory_fixup(void *fdt) * With above assumption, we create child nodes directly. */ - if (!sbi_hart_has_feature(scratch, SBI_HART_HAS_PMP)) { + 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