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

[PATCH] 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: Mon, 28 Sep 2020 16:51:57 +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=EtrpiFAw8fryXVx09xzLaB7pzZ9QXT5keQDitNDChsM=; b=k12UOzFbYv6ZNo0f5QfLKqLO9FqLB8YpHUMFqj9o3W6f9luWgnMutLb4xenG6cb/wAeFiLW7GzL2YAwsfjd0kT/soS3TQRnbiC8CniiBqanV7eheIuN3TXdzHQ+dxGCuAevu8Hxmyy3iCx62DS7Q2kGsxmOH0+/nNhdioSf1u0w6lMQT3yxQEIwbWy2SNRadaJVHBoYGMXP5KRfRi3o8obmRYUeCSerZurokPglRR6rHKQ9Qv4gDqrUaBmxLTrcK4qssJPdGxosESBHpRzXJKTIRHtkwL5zcWrJtIKM9wE8SnBPF3i1vbNTtmnNsCmE4s9XG9Oj8nKOQ1N0BftTy/Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HD+WoFWOoIgQftR/O0jpMaa6RvBZ1xFkd1Q6ZaKKDqof3iwoRBwqrNKA/x3y0P/3oZgyiSS0TM0l9sJXU0RuuWwbiVIUcobRTwzUGwYQgHZ8kGlmEdDnizCd59ZMw3AVfIPpqZrX4MayEn8mwfHLpuRrs1rpajXwSwi8wArW/O1UTqAdfJlCtKoey5+N6Uf/sLkNkt03wdt3bUqDgsbl4cvFNC4TTPxV/CVoRrGxst3n8/1bro+eH6OwOP2L3/me4CHaScbE/1iWpIZBriWAfwrKDYJTyC9A7GQydX58NVKotODU1BzATKv1ILosAxC5dxoGeWtupVHa2ZfZnXqFrw==
  • 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: Mon, 28 Sep 2020 14:34:16 +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.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@xxxxxxx>
---
 xen/arch/arm/p2m.c                 | 2 +-
 xen/drivers/passthrough/arm/smmu.c | 2 +-
 xen/include/asm-arm/p2m.h          | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index ce59f2b503..0181b09dc0 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -18,7 +18,6 @@
 
 #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;
@@ -39,6 +38,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..85709a136f 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..97b5eada2b 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -12,6 +12,7 @@
 
 /* Holds the bit size of IPAs in p2m tables.  */
 extern unsigned int p2m_ipa_bits;
+extern unsigned int p2m_root_level;
 
 struct domain;
 
-- 
2.17.1




 


Rackspace

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