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

[Xen-devel] [PATCH RFC v1 45/74] x86/guest: use unpopulated memory to map the shared_info page



This prevents hardcoding a known unpopulated memory page to map
the shared info page. This fixes a TODO item in a previous patch.

Remove hypervisor_early_setup as now it is not required anymore.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxx>
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/arch/x86/guest/xen.c        | 20 ++++++++------------
 xen/arch/x86/setup.c            |  3 ---
 xen/include/asm-x86/guest/xen.h |  5 -----
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen.c
index f66c10fbe5..0a4c02a8cd 100644
--- a/xen/arch/x86/guest/xen.c
+++ b/xen/arch/x86/guest/xen.c
@@ -77,23 +77,22 @@ void __init probe_hypervisor(void)
     xen_guest = true;
 }
 
-static void map_shared_info(struct e820map *e820)
+static void map_shared_info(void)
 {
-    paddr_t frame = 0xff000000; /* TODO: Hardcoded beside magic frames. */
+    mfn_t mfn;
     struct xen_add_to_physmap xatp = {
         .domid = DOMID_SELF,
-        .idx = 0,
         .space = XENMAPSPACE_shared_info,
-        .gpfn = frame >> PAGE_SHIFT,
     };
 
-    if ( !e820_add_range(e820, frame, frame + PAGE_SIZE, E820_RESERVED) )
-        panic("Failed to reserve shared_info range");
+    if ( hypervisor_alloc_unused_page(&mfn) )
+        panic("unable to reserve shared info memory page");
 
+    xatp.gpfn = mfn_x(mfn);
     if ( xen_hypercall_memory_op(XENMEM_add_to_physmap, &xatp) )
         panic("Failed to map shared_info page");
 
-    set_fixmap(FIX_XEN_SHARED_INFO, frame);
+    set_fixmap(FIX_XEN_SHARED_INFO, mfn_x(mfn) << PAGE_SHIFT);
 }
 
 static void xen_evtchn_upcall(struct cpu_user_regs *regs)
@@ -187,15 +186,12 @@ static void __init init_memmap(void)
     }
 }
 
-void __init hypervisor_early_setup(struct e820map *e820)
-{
-    map_shared_info(e820);
-}
-
 void __init hypervisor_setup(void)
 {
     init_memmap();
 
+    map_shared_info();
+
     init_evtchn();
 }
 
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 1b3576bc7d..9b45a4fd94 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -898,9 +898,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     /* Create a temporary copy of the E820 map. */
     memcpy(&boot_e820, &e820, sizeof(e820));
 
-    if ( xen_guest )
-        hypervisor_early_setup(&boot_e820);
-
     /* Early kexec reservation (explicit static start address). */
     nr_pages = 0;
     for ( i = 0; i < e820.nr_map; i++ )
diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h
index ba826d75db..7a4d734795 100644
--- a/xen/include/asm-x86/guest/xen.h
+++ b/xen/include/asm-x86/guest/xen.h
@@ -31,7 +31,6 @@
 extern bool xen_guest;
 
 void probe_hypervisor(void);
-void hypervisor_early_setup(struct e820map *e820);
 void hypervisor_setup(void);
 void hypervisor_ap_setup(void);
 int hypervisor_alloc_unused_page(mfn_t *mfn);
@@ -42,10 +41,6 @@ int hypervisor_free_unused_page(mfn_t mfn);
 #define xen_guest 0
 
 static inline void probe_hypervisor(void) {};
-static inline void hypervisor_early_setup(struct e820map *e820)
-{
-    ASSERT_UNREACHABLE();
-};
 
 static inline void hypervisor_setup(void)
 {
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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