Skip to contentSkip to conversation

tools/libxl: Don't read STORE/CONSOLE_PFN from Xen

PATCH In review Andrew Cooper 4 participants 6 messages Dec 9, 2021 – Dec 14, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxl: Don't read STORE/CONSOLE_PFN from Xen

The values are already available in dom->{console,xenstore}_pfn, just like on the PV side of things. No need to ask Xen.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>

---
 tools/libs/light/libxl_dom.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)
tools/libs/light/libxl_dom.c +5 -12
index c9c24666cd04..03841243ab47 100644
@@ -722,13 +722,10 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
 }
 
 static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
-                                libxl_domain_build_info *info,
-                                unsigned long *store_mfn,
-                                unsigned long *console_mfn)
+                                libxl_domain_build_info *info)
 {
     struct hvm_info_table *va_hvm;
     uint8_t *va_map, sum;
-    uint64_t str_mfn, cons_mfn;
     int i;
 
     if (info->type == LIBXL_DOMAIN_TYPE_HVM) {
@@ -749,12 +746,6 @@ static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
         munmap(va_map, XC_PAGE_SIZE);
     }
 
-    xc_hvm_param_get(handle, domid, HVM_PARAM_STORE_PFN, &str_mfn);
-    xc_hvm_param_get(handle, domid, HVM_PARAM_CONSOLE_PFN, &cons_mfn);
-
-    *store_mfn = str_mfn;
-    *console_mfn = cons_mfn;
-
     return 0;
 }
 
@@ -1168,12 +1159,14 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
     if (rc != 0)
         goto out;
 
-    rc = hvm_build_set_params(ctx->xch, domid, info, &state->store_mfn,
-                              &state->console_mfn);
+    rc = hvm_build_set_params(ctx->xch, domid, info);
     if (rc != 0) {
         LOG(ERROR, "hvm build set params failed");
         goto out;
     }
+
+    state->console_mfn = dom->console_pfn;
+    state->store_mfn = dom->xenstore_pfn;
     state->vuart_gfn = dom->vuart_gfn;
 
     rc = hvm_build_set_xs_values(gc, domid, dom, info);
Signature · 1 line
2.11.0
#1 lore raw
Quoted 21 lines · Andrew Cooper

The values are already available in dom->{console,xenstore}_pfn, just like on the PV side of things. No need to ask Xen.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>

---
  tools/libs/light/libxl_dom.c | 17 +++++------------
  1 file changed, 5 insertions(+), 12 deletions(-)
tools/libs/light/libxl_dom.c +0 -1
index c9c24666cd04..03841243ab47 100644
@@ -722,13 +722,10 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
  }
 
  static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
-                                libxl_domain_build_info *info,

tools/libs/light/libxl_dom.c int libxl__build_pv(libxl__gc *gc, uint32_t domid, · line 731

Quoted 10 lines
tools/libs/light/libxl_dom.c +1 -3
-                                unsigned long *store_mfn,
-                                unsigned long *console_mfn)
+                                libxl_domain_build_info *info)
  {
      struct hvm_info_table *va_hvm;
      uint8_t *va_map, sum;
-    uint64_t str_mfn, cons_mfn;
      int i;
 
      if (info->type == LIBXL_DOMAIN_TYPE_HVM) {

What about moving this if () to the only caller and renaming the function from hvm_build_set_params() to hvm_set_info_table()?

Juergen

#2 lore raw
Quoted 27 lines · Juergen Gross
Quoted 26 lines · Andrew Cooper

The values are already available in dom->{console,xenstore}_pfn, just like on
the PV side of things.  No need to ask Xen.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
---
  tools/libs/light/libxl_dom.c | 17 +++++------------

  1 file changed, 5 insertions(+), 12 deletions(-)
tools/libs/light/libxl_dom.c +0 -0
index c9c24666cd04..03841243ab47 100644
@@ -722,13 +722,10 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
   }

    static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
-                                libxl_domain_build_info *info, -                                unsigned long *store_mfn, -                                unsigned long *console_mfn) +                                libxl_domain_build_info *info) {

Quoted 8 lines
Quoted 5 lines

      struct hvm_info_table *va_hvm; uint8_t *va_map, sum;
-    uint64_t str_mfn, cons_mfn;
      int i;
        if (info->type == LIBXL_DOMAIN_TYPE_HVM) {

What about moving this if () to the only caller and renaming the function from hvm_build_set_params() to hvm_set_info_table()?

Because I was hoping to delete it outright in a subsequent patch.

~Andrew

#3 lore raw
Quoted 37 lines · Andrew Cooper
Quoted 27 lines · Juergen Gross
Quoted 26 lines · Andrew Cooper

The values are already available in dom->{console,xenstore}_pfn, just like on
the PV side of things.  No need to ask Xen.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>

---
   tools/libs/light/libxl_dom.c | 17 +++++------------
   1 file changed, 5 insertions(+), 12 deletions(-)
tools/libs/light/libxl_dom.c +1 -3
index c9c24666cd04..03841243ab47 100644
@@ -722,13 +722,10 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
   }
     static int hvm_build_set_params(xc_interface *handle, uint32_t
 domid,
-                                libxl_domain_build_info *info,
-                                unsigned long *store_mfn,
-                                unsigned long *console_mfn)
+                                libxl_domain_build_info *info)
   {
Quoted 8 lines

tools/libs/light/libxl_dom.c int libxl__build_pv(libxl__gc *gc, uint32_t domid, · line 731

Quoted 5 lines
tools/libs/light/libxl_dom.c +0 -1
       struct hvm_info_table *va_hvm;
       uint8_t *va_map, sum;
-    uint64_t str_mfn, cons_mfn;
       int i;
         if (info->type == LIBXL_DOMAIN_TYPE_HVM) {

What about moving this if () to the only caller and renaming the function from hvm_build_set_params() to hvm_set_info_table()?

Quoted 1 line

Because I was hoping to delete it outright in a subsequent patch.

I'd suggest to either do the renaming or to add that subsequent patch making this a small series.

Juergen

#4 lore raw
Quoted 40 lines · Juergen Gross
Quoted 39 lines · Andrew Cooper
Quoted 37 lines · Juergen Gross
Quoted 25 lines · Andrew Cooper

The values are already available in dom->{console,xenstore}_pfn, just like on
the PV side of things.  No need to ask Xen.

---
CC: Wei Liu <[email protected]>
CC: Anthony PERARD <[email protected]>
CC: Juergen Gross <[email protected]>
---
   tools/libs/light/libxl_dom.c | 17 +++++------------

   1 file changed, 5 insertions(+), 12 deletions(-)
tools/libs/light/libxl_dom.c +0 -0
index c9c24666cd04..03841243ab47 100644
@@ -722,13 +722,10 @@ int libxl__build_pv(libxl__gc *gc, uint32_t
 domid,
    }

     static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
-                                libxl_domain_build_info *info, -                                unsigned long *store_mfn,

Quoted 8 lines

-                                unsigned long *console_mfn) +                                libxl_domain_build_info *info) {
       struct hvm_info_table *va_hvm;
       uint8_t *va_map, sum;
-    uint64_t str_mfn, cons_mfn;
       int i;
         if (info->type == LIBXL_DOMAIN_TYPE_HVM) {

What about moving this if () to the only caller and renaming the function from hvm_build_set_params() to hvm_set_info_table()?

Quoted 4 lines
Quoted 1 line

Because I was hoping to delete it outright in a subsequent patch.

I'd suggest to either do the renaming or to add that subsequent patch making this a small series.

That's a separate task, which I don't have time to untangle right now.

I don't think it is worth delaying this improvement for a future only-tangentially-related change.

~Andrew