[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 43/52] xen/mpu: configure VSTCR_EL2 in MPU system
- To: Penny Zheng <Penny.Zheng@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Ayan Kumar Halder <ayankuma@xxxxxxx>
- Date: Wed, 5 Jul 2023 15:21:09 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
- 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lvFvdJIGeOI7z9GBRSz7Y5eAvlGkW/B+cgC1jVH4bP8=; b=StDP1ikhiL7KbXNtoBLyR7ETrG3PLLQpr5xBeEGWwNox9t1PqqPX4OGpoWztMRuNW4hl3XRoCrW7fUOxxkOEqsGNj7vt9BtiBERz2LNpQx5BgdK78JS7yzcqHmjrYW5mWFSVtiKrZbU3IXXn+oqcQL6pVAfSP1BkfWwHyEk+vPqiF7Dp+YRJfoBKua7yPdM45uIxhN3BYA9FrCp3p19dn86rrec+K9gOTmpsZvWdiMbX4k7JzmDlCKVzGfX7A5SVEVvfuqYW8qdoHs2xjtk2HP3izMO5HmRXp/TrEdPWGgWuLq88wmy2fDIZyKtvwNLd2mBcA1OztRyBzkr8o9/Nmw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AWD8LeanzrwJb0RRV/KXsDfaajhdQMLhbZMUt5smOEcoeQ/RCS5Nlzq3gR3JH+LrB+BaD5M6XdtG0O9VKDzoFFP7B3K+5TsU2USQWD2x6lnOEJLAaxL+dgr66oQFN6rwRBozVrbSEl6xuXze5cet0Ol23rcVTiEy7HjJtj4JiRv0gCkgBqcBczGVwsfJEkRWAgq7oh3MFwZwNj/uyxHCra2cf1qxf7E7tO1NxZbLd+2ACwxj9aTUMcOG2DyHPYLHq9ZkTS9JzkMBkGQeSGbWSTvQdqHxB90xw+BbWYOq6D2iQv24gexuXbsJgGmbE8iHqRFNpxSW3IlPkcqWZp3Yug==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
- Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Wei Chen <wei.chen@xxxxxxx>
- Delivery-date: Wed, 05 Jul 2023 14:21:34 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 26/06/2023 04:34, Penny Zheng wrote:
CAUTION: This message has originated from an External Source. Please use proper
judgment and caution when opening attachments, clicking links, or responding to
this email.
VSTCR_EL2, Virtualization Secure Translation Control Register,is
the control register for stage 2 of the Secure EL1&0 translation regime.
VSTCR_EL2.SA defines secure stage 2 translation output address space.
To make sure that all stage 2 translations for the Secure PA space
access the Secure PA space, we keep SA bit as 0.
VSTCR_EL2.SC is NS check enable bit.
To make sure that Stage 2 NS configuration is checked against stage 1
NS configuration in EL1&0 translation regime for the given address, and
generates a fault if they are different, we set SC bit 1.
Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
v3:
- new commit
---
xen/arch/arm/include/asm/arm64/sysregs.h | 6 ++++++
xen/arch/arm/mpu/p2m.c | 17 ++++++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/xen/arch/arm/include/asm/arm64/sysregs.h
b/xen/arch/arm/include/asm/arm64/sysregs.h
index ab0e6a97d3..35d7da411d 100644
--- a/xen/arch/arm/include/asm/arm64/sysregs.h
+++ b/xen/arch/arm/include/asm/arm64/sysregs.h
@@ -512,6 +512,12 @@
/* MPU Protection Region Enable Register encode */
#define PRENR_EL2 S3_4_C6_C1_1
+/* Virtualization Secure Translation Control Register */
+#define VSTCR_EL2 S3_4_C2_C6_2
+#define VSTCR_EL2_RES1_SHIFT 31
+#define VSTCR_EL2_SA ~(_AC(0x1,UL)<<30)
+#define VSTCR_EL2_SC (_AC(0x1,UL)<<20)
+
#endif
#ifdef CONFIG_ARM_SECURE_STATE
diff --git a/xen/arch/arm/mpu/p2m.c b/xen/arch/arm/mpu/p2m.c
index 04c44825cb..a7a3912a9a 100644
--- a/xen/arch/arm/mpu/p2m.c
+++ b/xen/arch/arm/mpu/p2m.c
@@ -10,7 +10,7 @@
void __init setup_virt_paging(void)
{
- uint64_t val = 0;
+ uint64_t val = 0, val2 = 0;
bool p2m_vmsa = true;
/* PA size */
@@ -76,6 +76,21 @@ void __init setup_virt_paging(void)
WRITE_SYSREG(val, VTCR_EL2);
#ifdef CONFIG_ARM_64
+ /*
+ * VSTCR_EL2.SA defines secure stage 2 translation output address space.
+ * To make sure that all stage 2 translations for the Secure PA space
+ * access the Secure PA space, we keep SA bit as 0.
+ *
+ * VSTCR_EL2.SC is NS check enable bit.
+ * To make sure that Stage 2 NS configuration is checked against stage 1
+ * NS configuration in EL1&0 translation regime for the given address, and
+ * generates a fault if they are different, we set SC bit 1.
+ */
+ val2 = 1 << VSTCR_EL2_RES1_SHIFT;
+ val2 &= VSTCR_EL2_SA;
+ val2 |= VSTCR_EL2_SC;
+ WRITE_SYSREG(val2, VSTCR_EL2);
#endif
+
return;
fault:
--
2.25.1
|