diff mbox series

[v5,06/12] x86/hypervisor: provide hypervisor_reserve_top_pages

Message ID 20200129202034.15052-7-liuwe@microsoft.com (mailing list archive)
State Superseded
Headers show
Series More Hyper-V infrastructures | expand

Commit Message

Wei Liu Jan. 29, 2020, 8:20 p.m. UTC
This function will return the number of pages that need to be reserved
in the machine address space.

E820 code will use that number to adjust the maximum PFN available to
Xen.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
 xen/arch/x86/guest/hypervisor.c        | 8 ++++++++
 xen/include/asm-x86/guest/hypervisor.h | 4 ++++
 2 files changed, 12 insertions(+)

Comments

Roger Pau Monné Jan. 30, 2020, 10:32 a.m. UTC | #1
On Wed, Jan 29, 2020 at 08:20:28PM +0000, Wei Liu wrote:
> This function will return the number of pages that need to be reserved
> in the machine address space.
> 
> E820 code will use that number to adjust the maximum PFN available to
> Xen.
> 
> Signed-off-by: Wei Liu <liuwe@microsoft.com>

It's hard to figure out whether the proposed code is suitable since
it's not yet called by any other function, and there's no hypervisor
implementation.

I wouldn't mind if this was merged into the next patch so that there's
a implementation and a user of the introduced code.

Thanks, Roger.
diff mbox series

Patch

diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index e72c92ffdf..8b9cf1ce4c 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -66,6 +66,14 @@  void hypervisor_resume(void)
         ops->resume();
 }
 
+unsigned int hypervisor_reserve_top_pages(void)
+{
+    if ( ops && ops->reserve_top_pages )
+        return ops->reserve_top_pages();
+
+    return 0;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
index b503854c5b..37eb9d531e 100644
--- a/xen/include/asm-x86/guest/hypervisor.h
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -28,6 +28,8 @@  struct hypervisor_ops {
     int (*ap_setup)(void);
     /* Resume from suspension */
     void (*resume)(void);
+    /* How many top pages to be reserved in machine address space? */
+    unsigned int (*reserve_top_pages)(void);
 };
 
 #ifdef CONFIG_GUEST
@@ -36,6 +38,7 @@  const char *hypervisor_probe(void);
 void hypervisor_setup(void);
 int hypervisor_ap_setup(void);
 void hypervisor_resume(void);
+unsigned int hypervisor_reserve_top_pages(void);
 
 #else
 
@@ -46,6 +49,7 @@  static inline const char *hypervisor_probe(void) { return NULL; }
 static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); }
 static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; }
 static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); }
+static inline unsigned int hypervisor_reserve_top_pages(void) { return 0; }
 
 #endif  /* CONFIG_GUEST */