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

[PATCH 1/2] xen/arm: Drop {boot_}phys_offset usage


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 14 Aug 2024 11:43:02 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=orGz9J979LxEriGwI1+0fdMAD1Fr4iF2kav9HAlL6Qs=; b=tUPKdumYV4OpEnMeq++83RZhlmJmO2cgHr5Xkhdq1aYI9g2K9r1rTbIliSMwf130oSXYAzzUgIuIIpKYV9inpX2kAiLkTVSRuMjj8zxCaJcPWg5JBm6Vg7tHDouM7hkBKFJnzMbE5kLPiSGtOc4tgm63OvqU3U+ImJIWf4Xke7DYNoC8k9P9o6sryz5whvFlenQD9shRZTxE0LcfoH7xrt7QNSHYbbB16YNL71rp6/SaUGTr8lCDwOD28w8PrfheXbP3pZRn0eBlo8f44E8nFH/pROS/OS3okzVSITWmE045w+zSjozpw34vvHoFoXx7pZTOaKiJcvtVo3fYRwwumA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s0qpplCp1mi4XpRKzFq6WeIk9QJSrmHnTXHtWiq1moQhl5gxT16O2MNT05DCqc1x2muXbKmai86BevbC/av2YzARGezSDgDNU0Se5HGygUNumbpbMs4R5LiMMHmusHV3UjVCNPNGOXfJoa0yFnY2HMPwk23LBULrLWxW83d0gfPVdBn0Xm1KMFvKAv9Pb7pGJs+Y04M7EM9k9ku41XfAfLrrg9Ht60iK71+KBP2lEGXzLu2SjGfRQ27WDyxwirWOfZ5JIB2SatkZtYuyrsV+CbB6MNLWKZQzPYGuSa5fwvQymuzQ490Mm+vT15bUfQoWqKjuM7QmYSPiSIFrJ4R4KA==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 14 Aug 2024 09:43:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

boot_phys_offset stores the physical offset (PA-VA), is calculated in
the startup head.S code and passed to start_xen() as a first argument.
There is no point in using it given that we can ask MMU to translate
a VA for us using e.g. virt_to_{mfn,maddr}. Drop usage of these
variables from the C world.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
It should also simplify the LLC coloring last patch:
https://lore.kernel.org/xen-devel/20240502165533.319988-14-carlo.nonato@xxxxxxxxxxxxxxx/
---
 xen/arch/arm/include/asm/mm.h |  2 +-
 xen/arch/arm/mmu/setup.c      | 16 ++++++----------
 xen/arch/arm/setup.c          |  2 +-
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
index f6ba611f01f7..5abd4b0d1c73 100644
--- a/xen/arch/arm/include/asm/mm.h
+++ b/xen/arch/arm/include/asm/mm.h
@@ -199,7 +199,7 @@ extern unsigned long frametable_base_pdx;
 #define PDX_GROUP_SHIFT SECOND_SHIFT
 
 /* Boot-time pagetable setup */
-extern void setup_pagetables(unsigned long boot_phys_offset);
+extern void setup_pagetables(void);
 /* Map FDT in boot pagetable */
 extern void *early_fdt_map(paddr_t fdt_paddr);
 /* Remove early mappings */
diff --git a/xen/arch/arm/mmu/setup.c b/xen/arch/arm/mmu/setup.c
index 57042ed57b4a..9664e85ee6c0 100644
--- a/xen/arch/arm/mmu/setup.c
+++ b/xen/arch/arm/mmu/setup.c
@@ -17,6 +17,8 @@
 /* Override macros from asm/page.h to make them work with mfn_t */
 #undef mfn_to_virt
 #define mfn_to_virt(mfn) __mfn_to_virt(mfn_x(mfn))
+#undef virt_to_mfn
+#define virt_to_mfn(va) _mfn(__virt_to_mfn(va))
 
 /* Main runtime page tables */
 
@@ -52,8 +54,6 @@ DEFINE_BOOT_PAGE_TABLE(xen_fixmap);
  */
 static DEFINE_PAGE_TABLES(xen_xenmap, XEN_NR_ENTRIES(2));
 
-static paddr_t phys_offset;
-
 /* Limits of the Xen heap */
 mfn_t directmap_mfn_start __read_mostly = INVALID_MFN_INITIALIZER;
 mfn_t directmap_mfn_end __read_mostly;
@@ -138,9 +138,7 @@ static void __init __maybe_unused build_assertions(void)
 
 lpae_t __init pte_of_xenaddr(vaddr_t va)
 {
-    paddr_t ma = va + phys_offset;
-
-    return mfn_to_xen_entry(maddr_to_mfn(ma), MT_NORMAL);
+    return mfn_to_xen_entry(virt_to_mfn(va), MT_NORMAL);
 }
 
 void * __init early_fdt_map(paddr_t fdt_paddr)
@@ -228,14 +226,12 @@ static void xen_pt_enforce_wnx(void)
  * Boot-time pagetable setup.
  * Changes here may need matching changes in head.S
  */
-void __init setup_pagetables(unsigned long boot_phys_offset)
+void __init setup_pagetables(void)
 {
     uint64_t ttbr;
     lpae_t pte, *p;
     int i;
 
-    phys_offset = boot_phys_offset;
-
     arch_setup_page_tables();
 
 #ifdef CONFIG_ARM_64
@@ -290,9 +286,9 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
     xen_second[second_table_offset(FIXMAP_ADDR(0))] = pte;
 
 #ifdef CONFIG_ARM_64
-    ttbr = (uintptr_t) xen_pgtable + phys_offset;
+    ttbr = virt_to_maddr(xen_pgtable);
 #else
-    ttbr = (uintptr_t) cpu0_pgtable + phys_offset;
+    ttbr = virt_to_maddr(cpu0_pgtable);
 #endif
 
     switch_ttbr(ttbr);
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index cb2c0a16b824..cfe19e15b0be 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -304,7 +304,7 @@ void asmlinkage __init start_xen(unsigned long 
boot_phys_offset,
     /* Initialize traps early allow us to get backtrace when an error occurred 
*/
     init_traps();
 
-    setup_pagetables(boot_phys_offset);
+    setup_pagetables();
 
     smp_clear_cpu_maps();
 
-- 
2.25.1




 


Rackspace

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