[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2] arm,smmu: match start level of page table walk with P2M


  • To: sstabellini@xxxxxxxxxx, julien@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, Volodymyr_Babchuk@xxxxxxxx, will@xxxxxxxxxx
  • From: laurentiu.tudor@xxxxxxx
  • Date: Fri, 2 Oct 2020 12:47:37 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.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-SenderADCheck; bh=3jsiYolmuFMXOgRZZk1T4VfnT84ijQrqqp/hl7R8W0g=; b=CFU36d2Cg8mczxCZGAeNtfJGnAmbx0gOGbhYdfyrqEGJ2pfDA7C9+3wOgw0ovybyMOKj05s3HaTBy6rNHzsGL3eI4JIsovejmJsytXzlIhTt6fo3U5OagX1mLvfYjmCFVG/nJHvVz6fEQBN35PisIRuX7tkG31CevFY8nUEu7E9tyGpRdu1wNLxmCDxdSaDsKFt804J4iSOYFqeXc+/NwcLcqQSmz+kmtSuJF/MSbaqeMYyEfYen9cNLrFZE41uSj5hIFwpfeG5VcIBK0pjYm2kcZeDTiYmtQHkTUQBmly3tgSwxSwreJRjmrFdjEYPmzDxdDGSy30wAiOQDXvop4A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dkmYYkbuM/mO7NaxIBoMoPiavl8s89qmMEvNLN1/uTGlo5/QKpf/DXXFoIC9aY6TgDx4gWK7R8FJsyYWNghynOUKizIG8KuRaLFe+ZdVCTF03SA2PLSMhKkQogHwVnc2w1rskaQIeQUbecgWdkyi12QjZETphMh5osgUJijTfigbZqH29EI5g1GVqNkiJQfkwZMuJuR+I87EjFJvYK/AaSeGZsKb8Qs0fDN1weFzXSt7NO6jpCKtjnt3pQhmZlzxtxDwBrJnbGLI8xstl+hHF8cvAFwh9FIzxEH1CbBgbYG/rruueP24eAzawWd0r8Z7Faf5dql7kZKSVVHjusDgiA==
  • Authentication-results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=nxp.com;
  • Cc: diana.craciun@xxxxxxx, anda-alexandra.dorneanu@xxxxxxx, Laurentiu Tudor <laurentiu.tudor@xxxxxxx>
  • Delivery-date: Fri, 02 Oct 2020 09:48:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Laurentiu Tudor <laurentiu.tudor@xxxxxxx>

Don't hardcode the lookup start level of the page table walk to 1
and instead match the one used in P2M. This should fix scenarios
involving SMMU where the start level is different than 1.
In order for the SMMU driver to also compile on arm32 move the
P2M_ROOT_LEVEL in the p2m header file (while at it, for
consistency also P2M_ROOT_ORDER) and use the macro in the smmu
driver.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@xxxxxxx>
---
Changes in v2:
 - made smmu driver compile on arm32

 xen/arch/arm/p2m.c                 |  7 +------
 xen/drivers/passthrough/arm/smmu.c |  2 +-
 xen/include/asm-arm/p2m.h          | 10 ++++++++++
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index ce59f2b503..bb75f12486 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -18,16 +18,10 @@
 
 #ifdef CONFIG_ARM_64
 static unsigned int __read_mostly p2m_root_order;
-static unsigned int __read_mostly p2m_root_level;
-#define P2M_ROOT_ORDER    p2m_root_order
-#define P2M_ROOT_LEVEL p2m_root_level
 static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT;
 /* VMID is by default 8 bit width on AArch64 */
 #define MAX_VMID       max_vmid
 #else
-/* First level P2M is always 2 consecutive pages */
-#define P2M_ROOT_LEVEL 1
-#define P2M_ROOT_ORDER    1
 /* VMID is always 8 bit width on AArch32 */
 #define MAX_VMID        MAX_VMID_8_BIT
 #endif
@@ -39,6 +33,7 @@ static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT;
  * restricted by external entity (e.g. IOMMU).
  */
 unsigned int __read_mostly p2m_ipa_bits = 64;
+unsigned int __read_mostly p2m_root_level;
 
 /* Helpers to lookup the properties of each level */
 static const paddr_t level_masks[] =
diff --git a/xen/drivers/passthrough/arm/smmu.c 
b/xen/drivers/passthrough/arm/smmu.c
index 94662a8501..4ba6d3ab94 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -1152,7 +1152,7 @@ static void arm_smmu_init_context_bank(struct 
arm_smmu_domain *smmu_domain)
              (TTBCR_RGN_WBWA << TTBCR_IRGN0_SHIFT);
 
        if (!stage1)
-               reg |= (TTBCR_SL0_LVL_1 << TTBCR_SL0_SHIFT);
+               reg |= (2 - P2M_ROOT_LEVEL) << TTBCR_SL0_SHIFT;
 
        writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBCR);
 
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 5fdb6e8183..ab02b36a03 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -12,6 +12,16 @@
 
 /* Holds the bit size of IPAs in p2m tables.  */
 extern unsigned int p2m_ipa_bits;
+extern unsigned int p2m_root_level;
+
+#ifdef CONFIG_ARM_64
+#define P2M_ROOT_ORDER    p2m_root_order
+#define P2M_ROOT_LEVEL p2m_root_level
+#else
+/* First level P2M is always 2 consecutive pages */
+#define P2M_ROOT_ORDER    1
+#define P2M_ROOT_LEVEL 1
+#endif
 
 struct domain;
 
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.