Skip to contentSkip to conversation

xen: do some cleanup

PATCH Applied Juergen Gross 2 participants 7 messages Oct 28, 2021 – Nov 3, 2021

Subsystems (7)
lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

cover xen: do some cleanup

Some cleanups, mostly related to no longer supporting 32-bit PV mode.

Juergen Gross (4):
x86/xen: remove 32-bit pv leftovers
xen: allow pv-only hypercalls only with CONFIG_XEN_PV
xen: remove highmem remnants
x86/xen: remove 32-bit awareness from startup_xen

 arch/arm/xen/enlighten.c             |   1 -
 arch/arm/xen/hypercall.S             |   1 -
 arch/arm64/xen/hypercall.S           |   1 -
 arch/x86/include/asm/xen/hypercall.h | 233 ++++++++++++---------------
 arch/x86/xen/enlighten_pv.c          |   7 -
 arch/x86/xen/mmu_pv.c                |   1 -
 arch/x86/xen/xen-head.S              |  12 +-
 drivers/xen/mem-reservation.c        |  27 ++--
 include/xen/arm/hypercall.h          |  15 --
 9 files changed, 118 insertions(+), 180 deletions(-)
Signature · 1 line
2.26.2
author maintainer
#1 lore raw

PATCH 1/4 x86/xen: remove 32-bit pv leftovers

There are some remaining 32-bit pv-guest support leftovers in the Xen hypercall interface. Remove them.

---
 arch/x86/include/asm/xen/hypercall.h | 40 +++++++---------------------
 drivers/xen/mem-reservation.c        | 27 +++++++------------
 2 files changed, 19 insertions(+), 48 deletions(-)
arch/x86/include/asm/xen/hypercall.h +9 -31
index 454b20815f35..02156b76aa92 100644
@@ -323,9 +323,7 @@ HYPERVISOR_get_debugreg(int reg)
 static inline int
 HYPERVISOR_update_descriptor(u64 ma, u64 desc)
 {
-	if (sizeof(u64) == sizeof(long))
-		return _hypercall2(int, update_descriptor, ma, desc);
-	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
+	return _hypercall2(int, update_descriptor, ma, desc);
 }
 
 static inline long
@@ -344,12 +342,7 @@ static inline int
 HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val,
 			     unsigned long flags)
 {
-	if (sizeof(new_val) == sizeof(long))
-		return _hypercall3(int, update_va_mapping, va,
-				   new_val.pte, flags);
-	else
-		return _hypercall4(int, update_va_mapping, va,
-				   new_val.pte, new_val.pte >> 32, flags);
+	return _hypercall3(int, update_va_mapping, va, new_val.pte, flags);
 }
 
 static inline int
@@ -461,16 +454,10 @@ MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va,
 {
 	mcl->op = __HYPERVISOR_update_va_mapping;
 	mcl->args[0] = va;
-	if (sizeof(new_val) == sizeof(long)) {
-		mcl->args[1] = new_val.pte;
-		mcl->args[2] = flags;
-	} else {
-		mcl->args[1] = new_val.pte;
-		mcl->args[2] = new_val.pte >> 32;
-		mcl->args[3] = flags;
-	}
+	mcl->args[1] = new_val.pte;
+	mcl->args[2] = flags;
 
-	trace_xen_mc_entry(mcl, sizeof(new_val) == sizeof(long) ? 3 : 4);
+	trace_xen_mc_entry(mcl, 3);
 }
 
 static inline void
@@ -478,19 +465,10 @@ MULTI_update_descriptor(struct multicall_entry *mcl, u64 maddr,
 			struct desc_struct desc)
 {
 	mcl->op = __HYPERVISOR_update_descriptor;
-	if (sizeof(maddr) == sizeof(long)) {
-		mcl->args[0] = maddr;
-		mcl->args[1] = *(unsigned long *)&desc;
-	} else {
-		u32 *p = (u32 *)&desc;
-
-		mcl->args[0] = maddr;
-		mcl->args[1] = maddr >> 32;
-		mcl->args[2] = *p++;
-		mcl->args[3] = *p;
-	}
-
-	trace_xen_mc_entry(mcl, sizeof(maddr) == sizeof(long) ? 2 : 4);
+	mcl->args[0] = maddr;
+	mcl->args[1] = *(unsigned long *)&desc;
+
+	trace_xen_mc_entry(mcl, 2);
 }
 
 static inline void
drivers/xen/mem-reservation.c +10 -17
index 3782cf070338..24648836e0d4 100644
@@ -35,6 +35,7 @@ void __xenmem_reservation_va_mapping_update(unsigned long count,
 	for (i = 0; i < count; i++) {
 		struct page *page = pages[i];
 		unsigned long pfn = page_to_pfn(page);
+		int ret;
 
 		BUG_ON(!page);
 
@@ -46,16 +47,10 @@ void __xenmem_reservation_va_mapping_update(unsigned long count,
 
 		set_phys_to_machine(pfn, frames[i]);
 
-		/* Link back into the page tables if not highmem. */
-		if (!PageHighMem(page)) {
-			int ret;
-
-			ret = HYPERVISOR_update_va_mapping(
-					(unsigned long)__va(pfn << PAGE_SHIFT),
-					mfn_pte(frames[i], PAGE_KERNEL),
-					0);
-			BUG_ON(ret);
-		}
+		ret = HYPERVISOR_update_va_mapping(
+				(unsigned long)__va(pfn << PAGE_SHIFT),
+				mfn_pte(frames[i], PAGE_KERNEL), 0);
+		BUG_ON(ret);
 	}
 }
 EXPORT_SYMBOL_GPL(__xenmem_reservation_va_mapping_update);
@@ -68,6 +63,7 @@ void __xenmem_reservation_va_mapping_reset(unsigned long count,
 	for (i = 0; i < count; i++) {
 		struct page *page = pages[i];
 		unsigned long pfn = page_to_pfn(page);
+		int ret;
 
 		/*
 		 * We don't support PV MMU when Linux and Xen are using
@@ -75,14 +71,11 @@ void __xenmem_reservation_va_mapping_reset(unsigned long count,
 		 */
 		BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE);
 
-		if (!PageHighMem(page)) {
-			int ret;
+		ret = HYPERVISOR_update_va_mapping(
+				(unsigned long)__va(pfn << PAGE_SHIFT),
+				__pte_ma(0), 0);
+		BUG_ON(ret);
 
-			ret = HYPERVISOR_update_va_mapping(
-					(unsigned long)__va(pfn << PAGE_SHIFT),
-					__pte_ma(0), 0);
-			BUG_ON(ret);
-		}
 		__set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
 	}
 }
Signature · 1 line
2.26.2
author maintainer
#2 lore raw

PATCH 2/4 xen: allow pv-only hypercalls only with CONFIG_XEN_PV

In reply to Juergen Gross

Put the definitions of the hypercalls usable only by pv guests inside CONFIG_XEN_PV sections.

On Arm two dummy functions related to pv hypercalls can be removed.

While at it remove the no longer supported tmem hypercall definition.

---
 arch/arm/xen/enlighten.c             |   1 -
 arch/arm/xen/hypercall.S             |   1 -
 arch/arm64/xen/hypercall.S           |   1 -
 arch/x86/include/asm/xen/hypercall.h | 211 +++++++++++++--------------
 include/xen/arm/hypercall.h          |  15 --
 5 files changed, 102 insertions(+), 127 deletions(-)
arch/arm/xen/enlighten.c +0 -1
index 7f1c106b746f..7619fbffcea2 100644
@@ -442,7 +442,6 @@ EXPORT_SYMBOL_GPL(HYPERVISOR_hvm_op);
 EXPORT_SYMBOL_GPL(HYPERVISOR_memory_op);
 EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op);
 EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op);
-EXPORT_SYMBOL_GPL(HYPERVISOR_tmem_op);
 EXPORT_SYMBOL_GPL(HYPERVISOR_platform_op_raw);
 EXPORT_SYMBOL_GPL(HYPERVISOR_multicall);
 EXPORT_SYMBOL_GPL(HYPERVISOR_vm_assist);
arch/arm/xen/hypercall.S +0 -1
index b11bba542fac..f794dac9859a 100644
@@ -88,7 +88,6 @@ HYPERCALL2(hvm_op);
 HYPERCALL2(memory_op);
 HYPERCALL2(physdev_op);
 HYPERCALL3(vcpu_op);
-HYPERCALL1(tmem_op);
 HYPERCALL1(platform_op_raw);
 HYPERCALL2(multicall);
 HYPERCALL2(vm_assist);
arch/arm64/xen/hypercall.S +0 -1
index 5b09aca55108..9d01361696a1 100644
@@ -80,7 +80,6 @@ HYPERCALL2(hvm_op);
 HYPERCALL2(memory_op);
 HYPERCALL2(physdev_op);
 HYPERCALL3(vcpu_op);
-HYPERCALL1(tmem_op);
 HYPERCALL1(platform_op_raw);
 HYPERCALL2(multicall);
 HYPERCALL2(vm_assist);
arch/x86/include/asm/xen/hypercall.h +102 -109

251 lines not on this page · raw message

include/xen/arm/hypercall.h +0 -15
index b40485e54d80..9d7dd1c65a21 100644
@@ -53,7 +53,6 @@ unsigned long HYPERVISOR_hvm_op(int op, void *arg);
 int HYPERVISOR_memory_op(unsigned int cmd, void *arg);
 int HYPERVISOR_physdev_op(int cmd, void *arg);
 int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args);
-int HYPERVISOR_tmem_op(void *arg);
 int HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type);
 int HYPERVISOR_dm_op(domid_t domid, unsigned int nr_bufs,
 		     struct xen_dm_op_buf *bufs);
@@ -74,18 +73,4 @@ HYPERVISOR_suspend(unsigned long start_info_mfn)
 	return HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
 }
 
-static inline void
-MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va,
-			unsigned int new_val, unsigned long flags)
-{
-	BUG();
-}
-
-static inline void
-MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req,
-		 int count, int *success_count, domid_t domid)
-{
-	BUG();
-}
-
 #endif /* _ASM_ARM_XEN_HYPERCALL_H */
Signature · 1 line
2.26.2
author maintainer
#3 lore raw

PATCH 3/4 xen: remove highmem remnants

In reply to Juergen Gross

There are some references to highmem left in Xen pv specific code which can be removed.

---
 arch/x86/xen/enlighten_pv.c | 7 -------
 arch/x86/xen/mmu_pv.c       | 1 -
 2 files changed, 8 deletions(-)
arch/x86/xen/enlighten_pv.c +0 -7
index a7b7d674f500..fe19a398bc00 100644
@@ -27,7 +27,6 @@
 #include <linux/export.h>
 #include <linux/mm.h>
 #include <linux/page-flags.h>
-#include <linux/highmem.h>
 #include <linux/pci.h>
 #include <linux/gfp.h>
 #include <linux/edd.h>
@@ -1245,12 +1244,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
 	__supported_pte_mask &= ~_PAGE_GLOBAL;
 	__default_kernel_pte_mask &= ~_PAGE_GLOBAL;
 
-	/*
-	 * Prevent page tables from being allocated in highmem, even
-	 * if CONFIG_HIGHPTE is enabled.
-	 */
-	__userpte_alloc_gfp &= ~__GFP_HIGHMEM;
-
 	/* Get mfn list */
 	xen_build_dynamic_phys_to_machine();
 
arch/x86/xen/mmu_pv.c +0 -1
index 3359c23573c5..793870fb942a 100644
@@ -41,7 +41,6 @@
  * Jeremy Fitzhardinge <[email protected]>, XenSource Inc, 2007
  */
 #include <linux/sched/mm.h>
-#include <linux/highmem.h>
 #include <linux/debugfs.h>
 #include <linux/bug.h>
 #include <linux/vmalloc.h>
Signature · 1 line
2.26.2
author maintainer
#4 lore raw

PATCH 4/4 x86/xen: remove 32-bit awareness from startup_xen

In reply to Juergen Gross

startup_xen is still 32-bit aware, even if no longer needed.

Replace the register macros by the 64-bit register names for making it more readable.

---
 arch/x86/xen/xen-head.S | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/xen/xen-head.S +6 -6
index cb6538ae2fe0..38b0a3226c95 100644
@@ -28,13 +28,13 @@ SYM_CODE_START(startup_xen)
 
 	/* Clear .bss */
 	xor %eax,%eax
-	mov $__bss_start, %_ASM_DI
-	mov $__bss_stop, %_ASM_CX
-	sub %_ASM_DI, %_ASM_CX
-	shr $__ASM_SEL(2, 3), %_ASM_CX
-	rep __ASM_SIZE(stos)
+	mov $__bss_start, %rdi
+	mov $__bss_stop, %rcx
+	sub %rdi, %rcx
+	shr $3, %rcx
+	rep stosq
 
-	mov %_ASM_SI, xen_start_info
+	mov %rsi, xen_start_info
 	mov initial_stack(%rip), %rsp
 
 	/* Set up %gs.
Signature · 1 line
2.26.2
reviewer Reviewed-by on the v1 series
#5 lore raw
In reply to Juergen Gross
Quoted 8 lines · Juergen Gross

Some cleanups, mostly related to no longer supporting 32-bit PV mode.

Juergen Gross (4):
x86/xen: remove 32-bit pv leftovers
xen: allow pv-only hypercalls only with CONFIG_XEN_PV
xen: remove highmem remnants
x86/xen: remove 32-bit awareness from startup_xen

Quoted 10 lines
  arch/arm/xen/enlighten.c             |   1 -
  arch/arm/xen/hypercall.S             |   1 -
  arch/arm64/xen/hypercall.S           |   1 -
  arch/x86/include/asm/xen/hypercall.h | 233 ++++++++++++---------------
  arch/x86/xen/enlighten_pv.c          |   7 -
  arch/x86/xen/mmu_pv.c                |   1 -
  arch/x86/xen/xen-head.S              |  12 +-
  drivers/xen/mem-reservation.c        |  27 ++--
  include/xen/arm/hypercall.h          |  15 --
  9 files changed, 118 insertions(+), 180 deletions(-)
reviewer Applied
#6 lore raw
Quoted 23 lines · Boris Ostrovsky
Quoted 17 lines · Juergen Gross

Some cleanups, mostly related to no longer supporting 32-bit PV mode.

Juergen Gross (4):
   x86/xen: remove 32-bit pv leftovers
   xen: allow pv-only hypercalls only with CONFIG_XEN_PV
   xen: remove highmem remnants
   x86/xen: remove 32-bit awareness from startup_xen

  arch/arm/xen/enlighten.c             |   1 - arch/arm/xen/hypercall.S             |   1 - arch/arm64/xen/hypercall.S           |   1 - arch/x86/include/asm/xen/hypercall.h | 233 ++++++++++++--------------- arch/x86/xen/enlighten_pv.c          |   7 - arch/x86/xen/mmu_pv.c                |   1 - arch/x86/xen/xen-head.S              |  12 +- drivers/xen/mem-reservation.c        |  27 ++-- include/xen/arm/hypercall.h          |  15 --

Quoted 1 line
  9 files changed, 118 insertions(+), 180 deletions(-)
Quoted 1 line

Applied to for-linus-5.16b.

-boris