From patchwork Wed Jul 12 04:34:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Chauhan X-Patchwork-Id: 1806593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=arx7IFqG; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=Teg307vO; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R14fZ6shBz20b9 for ; Wed, 12 Jul 2023 14:35:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SDgj7XcYmkOvtzhgimX8OceLIIUgrNDa3bCAzpbvNtA=; b=arx7IFqGO66+kY ZxdtC1Cjvy6SfSPaFsdFrUxhdaYryKBFlNKKqo9L8J3cbqv9iyPKnGq1zRN+FzibeUnv5P0cDBe+F 3kME6Myj20IjGwN+IcgO7dpPAyflGNhyBjss4cGOXNRggMiqxxCj7GAIk9chhB+Oxln2lGhn45KqK LFjqgeB+rCM9pLN4fP31t81ZvL7VBYHwV+mGTJ2QVFotANj7xsFzbKTgupBlVQRZtGNtCgyWjDNVm hPbg2LvJr/u2qvF9+b5OOf4KhvGvEeIpYYANy3zmSU6zgnHMAkVe9YVR7onY6J5ocQ0O97h/xCvYf KmmPrH6+HVJzyedirkTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJRZB-00GUx6-38; Wed, 12 Jul 2023 04:35:05 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJRZ9-00GUuI-2z for opensbi@lists.infradead.org; Wed, 12 Jul 2023 04:35:05 +0000 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5576ad1b7e7so1039874a12.1 for ; Tue, 11 Jul 2023 21:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1689136502; x=1691728502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uoZgMiFAh4Kmyz2zC+xVpFgLpeKpdWuDrRWjlM1eq40=; b=Teg307vOTzNaKy4cC+3w+isDGdqHlmbsG5nar5EeH+7elW31G0Mz2ScgM8bMowK5bH tzS5OItBFzOzkku64fS6huHA6Z9hjtC5TC+eDGBRrKwEFABZCJiCcATWRLgbS+ng6GSd GgOOW9EIAOJbjPhUNWcHkNqI0EGs+pzf/Ib5xa9q6kg7ZlY22T8dsMGwn57AkTVl9TM3 16aBGCdY571xWlPy3P15QjNKVw4e93M3LIJeAFLnub3e42h5vSypzuLf7u0S8BYnGz7w D/SNwKHVPbWor+vPXRXWAswXIsDxrSvHhT16tn8FTE0tO0hiYCa9g2sCKQASSw/TgV44 /+JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689136502; x=1691728502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uoZgMiFAh4Kmyz2zC+xVpFgLpeKpdWuDrRWjlM1eq40=; b=e2XwJVKsCJB411F6XCITA1Il1iAfSQnLLpSXfajX3+u+0seaYKlyMPztCXtENjI0XK J6K/A8OSTBy+oYvOySv2UQYrs9xwlJHX7dK5VKHwhNObIo3Q8rJPkCuLJfS6sFD62eDB u6wv4NhtYmnviGlQydnt6/mkUlj0LYp8G9eSEo//MSRY7Tordu1Jr5DYl6VvzYUOuGVE uegPSpFsCZCfS54SWYDKXJqO+ZJ3Ij7s1jtEV8wxD73CYIExt0J5pFB+VlxmisznavqT t3Y8PGXMtLkJ4rzNqZOntfBZFfnb1NaFqlP47HsuDyL9yLNw3QHqGK09JwOvuL3zddlv 8C0Q== X-Gm-Message-State: ABy/qLZcUOX6FV8o0BR9vJwHskfqr/BpUu5o7ulnRASXa1na63POQHVz jubXZQz+q4cHfGcNaB1dD6L73RnvRe3iVEYbFs0= X-Google-Smtp-Source: APBJJlFhlxnLJfWg1J3Id/T6C7q+dU3RmJJEQNWlabDObjSQnfUlB04DwTzO/EIQ/MewADgSH5aKxw== X-Received: by 2002:a17:903:41c7:b0:1b8:b55d:4cff with SMTP id u7-20020a17090341c700b001b8b55d4cffmr22429736ple.2.1689136502056; Tue, 11 Jul 2023 21:35:02 -0700 (PDT) Received: from saptrishi.. ([2409:40f2:101d:c560:cb32:f5f5:1d86:260a]) by smtp.gmail.com with ESMTPSA id ix13-20020a170902f80d00b001b896686c78sm2806152plb.66.2023.07.11.21.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 21:35:01 -0700 (PDT) From: Himanshu Chauhan To: opensbi@lists.infradead.org Cc: Himanshu Chauhan Subject: [PATCH v3 08/10] lib: sbi: Change the order of PMP initialization Date: Wed, 12 Jul 2023 10:04:34 +0530 Message-Id: <20230712043436.100548-9-hchauhan@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712043436.100548-1-hchauhan@ventanamicro.com> References: <20230706104928.3391947-1-hchauhan@ventanamicro.com> <20230712043436.100548-1-hchauhan@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230711_213503_959235_DE45D0AD X-CRM114-Status: GOOD ( 10.25 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Configure PMP at last when all other initializations have been done. Because if SMEPMP is detected, M-mode access to the S/U space will be rescinded. Signed-off-by: Himanshu Chauhan --- lib/sbi/sbi_init.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:52c listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Configure PMP at last when all other initializations have been done. Because if SMEPMP is detected, M-mode access to the S/U space will be rescinded. Signed-off-by: Himanshu Chauhan Reviewed-by: Anup Patel --- lib/sbi/sbi_init.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c index 423e6d8..35e6633 100644 --- a/lib/sbi/sbi_init.c +++ b/lib/sbi/sbi_init.c @@ -356,13 +356,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) sbi_hart_hang(); } - rc = sbi_hart_pmp_configure(scratch); - if (rc) { - sbi_printf("%s: PMP configure failed (error %d)\n", - __func__, rc); - sbi_hart_hang(); - } - /* * Note: Platform final initialization should be after finalizing * domains so that it sees correct domain assignment and PMP @@ -392,6 +385,17 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid) sbi_boot_print_hart(scratch, hartid); + /* + * Configure PMP at last because if SMEPMP is detected, + * M-mode access to the S/U space will be rescinded. + */ + rc = sbi_hart_pmp_configure(scratch); + if (rc) { + sbi_printf("%s: PMP configure failed (error %d)\n", + __func__, rc); + sbi_hart_hang(); + } + wake_coldboot_harts(scratch, hartid); count = sbi_scratch_offset_ptr(scratch, init_count_offset); @@ -445,11 +449,15 @@ static void __noreturn init_warm_startup(struct sbi_scratch *scratch, if (rc) sbi_hart_hang(); - rc = sbi_hart_pmp_configure(scratch); + rc = sbi_platform_final_init(plat, false); if (rc) sbi_hart_hang(); - rc = sbi_platform_final_init(plat, false); + /* + * Configure PMP at last because if SMEPMP is detected, + * M-mode access to the S/U space will be rescinded. + */ + rc = sbi_hart_pmp_configure(scratch); if (rc) sbi_hart_hang();