Skip to contentSkip to conversation

tools/pvh: set coherent MTRR state for all vCPUs

PATCH Superseded Roger Pau Monne 3 participants 4 messages Oct 2, 2018 – Oct 4, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/pvh: set coherent MTRR state for all vCPUs

Instead of just doing it for the BSP. This requires storing the maximum number of possible vCPUs in xc_dom_image.

This has been a latent bug so far because PVH doesn't yet support pci-passthrough, so the effective memory cache attribute is forced to WB by the hypervisor. Note also that even without this in place vCPU#0 is preferred in certain scenarios in order to calculate the memory cache attributes.

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 tools/libxc/include/xc_dom.h |  3 ++
 tools/libxc/xc_dom_x86.c     | 69 ++++++++++++++++++++++++------------
 tools/libxl/libxl_dom.c      |  2 ++
 3 files changed, 52 insertions(+), 22 deletions(-)
tools/libxc/include/xc_dom.h +3 -0
index 0b5a632d3c..bc125dbd3a 100644
@@ -230,6 +230,9 @@ struct xc_dom_image {
 #endif
 
     xen_pfn_t vuart_gfn;
+
+    /* Number of vCPUs */
+    unsigned int nr_vcpus;
 };
 
 /* --- pluggable kernel loader ------------------------------------- */
tools/libxc/xc_dom_x86.c +47 -22

94 lines not on this page · raw message

tools/libxl/libxl_dom.c +2 -0
index 8a8a32c699..5c80aab767 100644
@@ -803,6 +803,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
     dom->xenstore_evtchn = state->store_port;
     dom->xenstore_domid = state->store_domid;
     dom->claim_enabled = libxl_defbool_val(info->claim_mode);
+    dom->nr_vcpus = info->max_vcpus;
 
     if (info->num_vnuma_nodes != 0) {
         unsigned int i;
@@ -1256,6 +1257,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
     dom->mmio_start = mmio_start;
     dom->vga_hole_size = device_model ? LIBXL_VGA_HOLE_SIZE : 0;
     dom->device_model = device_model;
+    dom->nr_vcpus = info->max_vcpus;
 
     rc = libxl__domain_device_construct_rdm(gc, d_config,
                                             info->u.hvm.rdm_mem_boundary_memkb*1024,
Signature · 7 lines
2.19.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Roger Pau Monne

Instead of just doing it for the BSP. This requires storing the maximum number of possible vCPUs in xc_dom_image.

This has been a latent bug so far because PVH doesn't yet support pci-passthrough, so the effective memory cache attribute is forced to WB by the hypervisor. Note also that even without this in place vCPU#0 is preferred in certain scenarios in order to calculate the memory cache attributes.

[...]

tools/libxl/libxl_dom.c int libxl__build_pv(libxl__gc *gc, uint32_t domid, · line 806

Quoted 10 lines

---

tools/libxl/libxl_dom.c +1 -0
index 8a8a32c699..5c80aab767 100644
@@ -803,6 +803,7 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
     dom->xenstore_evtchn = state->store_port;
     dom->xenstore_domid = state->store_domid;
     dom->claim_enabled = libxl_defbool_val(info->claim_mode);
+    dom->nr_vcpus = info->max_vcpus;

This isn't strictly needed, but I think setting it for PV as well is more consistent.

Andrew, can you give this a try?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Roger Pau Monne
Quoted 11 lines · Roger Pau Monne

Instead of just doing it for the BSP. This requires storing the maximum number of possible vCPUs in xc_dom_image.

This has been a latent bug so far because PVH doesn't yet support pci-passthrough, so the effective memory cache attribute is forced to WB by the hypervisor. Note also that even without this in place vCPU#0 is preferred in certain scenarios in order to calculate the memory cache attributes.

This is all moderately nasty, but that is entirely the fault of get/set context API.  Seeing as the interface is going to be fully rewritten eventually, this will do.

Quoted 15 lines

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 tools/libxc/include/xc_dom.h |  3 ++
 tools/libxc/xc_dom_x86.c     | 69 ++++++++++++++++++++++++------------
 tools/libxl/libxl_dom.c      |  2 ++
 3 files changed, 52 insertions(+), 22 deletions(-)
tools/libxc/include/xc_dom.h +0 -0
index 0b5a632d3c..bc125dbd3a 100644

tools/libxc/include/xc_dom.h struct xc_dom_image { · line 235

Quoted 6 lines
tools/libxc/include/xc_dom.h +3 -0
@@ -230,6 +230,9 @@ struct xc_dom_image {
 #endif
 
     xen_pfn_t vuart_gfn;
+
+    /* Number of vCPUs */
+    unsigned int nr_vcpus;

I'd be tempted to name this max_vcpus so it can't be confused with CPU hotplug cases.

Somewhere early in the domain builder also might want to sanity check that it isn't 0.

If you're in the mood for some cleanup, build_hvm_info() probably wants an adjustment in light of this field now existing.

As for the eventual code, LGTM.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 34 lines · Andrew Cooper
Quoted 11 lines · Roger Pau Monne

Instead of just doing it for the BSP. This requires storing the maximum number of possible vCPUs in xc_dom_image.

This has been a latent bug so far because PVH doesn't yet support pci-passthrough, so the effective memory cache attribute is forced to WB by the hypervisor. Note also that even without this in place vCPU#0 is preferred in certain scenarios in order to calculate the memory cache attributes.

This is all moderately nasty, but that is entirely the fault of get/set context API.  Seeing as the interface is going to be fully rewritten eventually, this will do.

Quoted 17 lines

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 tools/libxc/include/xc_dom.h |  3 ++
 tools/libxc/xc_dom_x86.c     | 69 ++++++++++++++++++++++++------------
 tools/libxl/libxl_dom.c      |  2 ++
 3 files changed, 52 insertions(+), 22 deletions(-)
tools/libxc/include/xc_dom.h +0 -0
index 0b5a632d3c..bc125dbd3a 100644
@@ -230,6 +230,9 @@ struct xc_dom_image {
 #endif
 
Quoted 7 lines

tools/libxc/include/xc_dom.h struct xc_dom_image { · line 235

Quoted 4 lines
tools/libxc/include/xc_dom.h +3 -0
     xen_pfn_t vuart_gfn;
+
+    /* Number of vCPUs */
+    unsigned int nr_vcpus;

I'd be tempted to name this max_vcpus so it can't be confused with CPU hotplug cases.

The naming was chosen to match existing fields in xc_dom_image that already start with nr_. I don't mind changing it to match the hypervisor side that uses max_vcpus.

Quoted 7 lines

Somewhere early in the domain builder also might want to sanity check that it isn't 0.

If you're in the mood for some cleanup, build_hvm_info() probably wants an adjustment in light of this field now existing.

As for the eventual code, LGTM.

I can take a look tomorrow and send a new version.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel