Skip to contentSkip to conversation

x86/hvm/viridian: APIC assist

PATCH Superseded Paul Durrant 2 participants 6 messages Mar 16, 2016 – Mar 17, 2016

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover x86/hvm/viridian: APIC assist

This patch series enables use of the 'APIC assist' enlightenment in Xen.

See section 13.3.4.1 of the Microsoft Hypervisor Top Level Function Specification v4.0b at:

https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/develop/tlfs

for more information.

Patch #1 modifies the viridian code to keep the guest APIC assist pages mapped for the lifetime of the domain (and incorporates a straightforward data-structure change).

Patch #2 adds a new viridian code and a configuration option to the toolstack that, when enabled, allows the local APIC emulation to make use the APIC assist pages.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw

PATCH v3 1/2 x86/hvm/viridian: keep APIC assist page mapped...

... for the lifetime of the domain.

If Xen is to make use of the APIC assist enlightenment then a persistent mapping needs to be kept, rather than the temporary one which is currently used only to initialize the page content.

This patch also adds a comment block at the top of the source with information on the latest version of the spec. from Microsoft and the current URL where it may be found.

Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

---

v2:
- Re-instated warning if the initialization of an APIC assist page fails.
- Added up-to-date information about the viridian specification to the comment block at the top of the source.

---
 xen/arch/x86/hvm/hvm.c             |  2 +
 xen/arch/x86/hvm/viridian.c        | 76 ++++++++++++++++++++++++++++----------
 xen/include/asm-x86/hvm/viridian.h |  8 +++-
 3 files changed, 65 insertions(+), 21 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -0
index 4ea51d7..f446ee4 100644
@@ -2606,6 +2606,8 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
 void hvm_vcpu_destroy(struct vcpu *v)
 {
+    viridian_vcpu_deinit(v);
+
     hvm_all_ioreq_servers_remove_vcpu(v->domain, v);
 
     if ( hvm_altp2m_supported() )
xen/arch/x86/hvm/viridian.c +56 -20

140 lines not on this page · raw message

xen/include/asm-x86/hvm/viridian.h +7 -1
index c4319d7..ee3a120 100644
@@ -21,7 +21,11 @@ union viridian_apic_assist
 
 struct viridian_vcpu
 {
-    union viridian_apic_assist apic_assist;
+    struct {
+        union viridian_apic_assist msr;
+        struct page_info *page;
+        void *va;
+    } apic_assist;
 };
 
 union viridian_guest_os_id
@@ -117,6 +121,8 @@ viridian_hypercall(struct cpu_user_regs *regs);
 void viridian_time_ref_count_freeze(struct domain *d);
 void viridian_time_ref_count_thaw(struct domain *d);
 
+void viridian_vcpu_deinit(struct vcpu *v);
+
 #endif /* __ASM_X86_HVM_VIRIDIAN_H__ */
 
 /*
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#3 lore raw

PATCH v3 2/2 x86/hvm/viridian: Enable APIC assist enlightenment

In reply to Paul Durrant

This patch adds code to enable the APIC assist enlightenment which, under certain conditions, means that the guest can avoid an EOI of the local APIC and thereby avoid a VMEXIT.

Use of the enlightenment by the hypervisor is under control of the toolstack, and is added to the default set.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

---

v3:
- Re-instated read-modify-write for forwards compatibility
- Fix a coding style issue

v2:
- Removed some code duplication and unnecessary read-modify-write operations on the APIC assist word.
- Stated in the xl.cfg text that the enlightenment has no effect if posted interrupts are in use.
- Added the enlightenment to the default set.

---
 docs/man/xl.cfg.pod.5              | 13 ++++++++-
 tools/libxl/libxl_dom.c            |  4 +++
 tools/libxl/libxl_types.idl        |  1 +
 xen/arch/x86/hvm/viridian.c        | 59 ++++++++++++++++++++++++++++++++++----
 xen/arch/x86/hvm/vlapic.c          | 58 +++++++++++++++++++++++++++++++++----
 xen/include/asm-x86/hvm/viridian.h |  5 ++++
 xen/include/public/hvm/params.h    |  7 ++++-
 7 files changed, 134 insertions(+), 13 deletions(-)
docs/man/xl.cfg.pod.5 +12 -1
index 56b1117..1ba026b 100644
@@ -1484,10 +1484,21 @@ This set incorporates use of hypercalls for remote TLB flushing.
 This enlightenment may improve performance of Windows guests running
 on hosts with higher levels of (physical) CPU contention.
 
+=item B<apic_assist>
+
+This set incorporates use of the APIC assist page to avoid EOI of
+the local APIC.
+This enlightenment may improve performance of Windows guests,
+particularly those running PV drivers that make use of per-vcpu
+event channel upcall vectors.
+Note that this enlightenment will have no effect if the guest is
+using APICv posted interrupts.
+
 =item B<defaults>
 
 This is a special value that enables the default set of groups, which
-is currently the B<base>, B<freq> and B<time_ref_count> groups.
+is currently the B<base>, B<freq>, B<time_ref_count> and B<apic_assist>
+groups.
 
 =item B<all>
 
tools/libxl/libxl_dom.c +4 -0
index b825b98..09d3bca 100644
@@ -211,6 +211,7 @@ static int hvm_set_viridian_features(libxl__gc *gc, uint32_t domid,
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_BASE);
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_FREQ);
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_TIME_REF_COUNT);
+        libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_APIC_ASSIST);
     }
 
     libxl_for_each_set_bit(v, info->u.hvm.viridian_enable) {
@@ -253,6 +254,9 @@ static int hvm_set_viridian_features(libxl__gc *gc, uint32_t domid,
     if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_HCALL_REMOTE_TLB_FLUSH))
         mask |= HVMPV_hcall_remote_tlb_flush;
 
+    if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_APIC_ASSIST))
+        mask |= HVMPV_apic_assist;
+
     if (mask != 0 &&
         xc_hvm_param_set(CTX->xch,
                          domid,
tools/libxl/libxl_types.idl +1 -0
index 632c009..e3be957 100644
@@ -221,6 +221,7 @@ libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [
     (2, "time_ref_count"),
     (3, "reference_tsc"),
     (4, "hcall_remote_tlb_flush"),
+    (5, "apic_assist"),
     ])
 
 libxl_hdtype = Enumeration("hdtype", [
xen/arch/x86/hvm/viridian.c +54 -5

77 lines not on this page · raw message

xen/arch/x86/hvm/vlapic.c +52 -6

94 lines not on this page · raw message

xen/include/asm-x86/hvm/viridian.h +5 -0
index ee3a120..e0a523e 100644
@@ -25,6 +25,7 @@ struct viridian_vcpu
         union viridian_apic_assist msr;
         struct page_info *page;
         void *va;
+        int vector;
     } apic_assist;
 };
 
@@ -123,6 +124,10 @@ void viridian_time_ref_count_thaw(struct domain *d);
 
 void viridian_vcpu_deinit(struct vcpu *v);
 
+void viridian_start_apic_assist(struct vcpu *v, int vector);
+bool_t viridian_complete_apic_assist(struct vcpu *v, int *vector);
+void viridian_abort_apic_assist(struct vcpu *v);
+
 #endif /* __ASM_X86_HVM_VIRIDIAN_H__ */
 
 /*
xen/include/public/hvm/params.h +6 -1
index 73d4718..e69c72c 100644
@@ -115,12 +115,17 @@
 #define _HVMPV_hcall_remote_tlb_flush 4
 #define HVMPV_hcall_remote_tlb_flush (1 << _HVMPV_hcall_remote_tlb_flush)
 
+/* Use APIC assist */
+#define _HVMPV_apic_assist 5
+#define HVMPV_apic_assist (1 << _HVMPV_apic_assist)
+
 #define HVMPV_feature_mask \
         (HVMPV_base_freq | \
          HVMPV_no_freq | \
          HVMPV_time_ref_count | \
          HVMPV_reference_tsc | \
-         HVMPV_hcall_remote_tlb_flush)
+         HVMPV_hcall_remote_tlb_flush | \
+         HVMPV_apic_assist)
 
 #endif
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#4 lore raw

Re: [PATCH v3 2/2] x86/hvm/viridian: Enable APIC assist enlightenment

Quoted 41 lines · Paul Durrant

This patch adds code to enable the APIC assist enlightenment which, under certain conditions, means that the guest can avoid an EOI of the local APIC and thereby avoid a VMEXIT.

Use of the enlightenment by the hypervisor is under control of the toolstack, and is added to the default set.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

---

v3:
- Re-instated read-modify-write for forwards compatibility
- Fix a coding style issue

v2:
- Removed some code duplication and unnecessary read-modify-write operations on the APIC assist word.
- Stated in the xl.cfg text that the enlightenment has no effect if posted interrupts are in use.
- Added the enlightenment to the default set.

---
 docs/man/xl.cfg.pod.5              | 13 ++++++++-
 tools/libxl/libxl_dom.c            |  4 +++
 tools/libxl/libxl_types.idl        |  1 +
 xen/arch/x86/hvm/viridian.c        | 59 ++++++++++++++++++++++++++++++++++----
 xen/arch/x86/hvm/vlapic.c          | 58 +++++++++++++++++++++++++++++++++----
 xen/include/asm-x86/hvm/viridian.h |  5 ++++
 xen/include/public/hvm/params.h    |  7 ++++-
 7 files changed, 134 insertions(+), 13 deletions(-)
docs/man/xl.cfg.pod.5 +0 -0
index 56b1117..1ba026b 100644

docs/man/xl.cfg.pod.5 This set incorporates use of hypercalls for remote TLB flushing. · line 1493

Quoted 10 lines
docs/man/xl.cfg.pod.5 +7 -0
@@ -1484,10 +1484,21 @@ This set incorporates use of hypercalls for remote TLB flushing.
 This enlightenment may improve performance of Windows guests running
 on hosts with higher levels of (physical) CPU contention.
 
+=item B<apic_assist>
+
+This set incorporates use of the APIC assist page to avoid EOI of
+the local APIC.
+This enlightenment may improve performance of Windows guests,
+particularly those running PV drivers that make use of per-vcpu
+event channel upcall vectors.

I think this can be changed to

This enlightenment may improve performance of guests that make use of per-vcpu event channel upcall vectors.

Surely Linux can benefit from this too, right?

Quoted 39 lines
docs/man/xl.cfg.pod.5 +5 -1
+Note that this enlightenment will have no effect if the guest is
+using APICv posted interrupts.
+
 =item B<defaults>
 
 This is a special value that enables the default set of groups, which
-is currently the B<base>, B<freq> and B<time_ref_count> groups.
+is currently the B<base>, B<freq>, B<time_ref_count> and B<apic_assist>
+groups.
 
 =item B<all>
 
tools/libxl/libxl_dom.c +4 -0
index b825b98..09d3bca 100644
@@ -211,6 +211,7 @@ static int hvm_set_viridian_features(libxl__gc *gc, uint32_t domid,
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_BASE);
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_FREQ);
         libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_TIME_REF_COUNT);
+        libxl_bitmap_set(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_APIC_ASSIST);
     }
 
     libxl_for_each_set_bit(v, info->u.hvm.viridian_enable) {
@@ -253,6 +254,9 @@ static int hvm_set_viridian_features(libxl__gc *gc, uint32_t domid,
     if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_HCALL_REMOTE_TLB_FLUSH))
         mask |= HVMPV_hcall_remote_tlb_flush;
 
+    if (libxl_bitmap_test(&enlightenments, LIBXL_VIRIDIAN_ENLIGHTENMENT_APIC_ASSIST))
+        mask |= HVMPV_apic_assist;
+
     if (mask != 0 &&
         xc_hvm_param_set(CTX->xch,
                          domid,
tools/libxl/libxl_types.idl +0 -0
index 632c009..e3be957 100644

tools/libxl/libxl_types.idl libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [ · line 226

Quoted 6 lines
tools/libxl/libxl_types.idl +1 -0
@@ -221,6 +221,7 @@ libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [
     (2, "time_ref_count"),
     (3, "reference_tsc"),
     (4, "hcall_remote_tlb_flush"),
+    (5, "apic_assist"),
     ])
 

Missing a LIBXL_HAVE macro in libxl.h for this new field.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw

Re: [PATCH v3 1/2] x86/hvm/viridian: keep APIC assist page mapped...

In reply to Paul Durrant
Quoted 156 lines

-----Original Message-----
From: Paul Durrant [mailto:[email protected]]
Sent: 16 March 2016 17:44
To: [email protected]
Cc: Paul Durrant; Keir (Xen.org); Jan Beulich; Andrew Cooper
Subject: [PATCH v3 1/2] x86/hvm/viridian: keep APIC assist page mapped...

... for the lifetime of the domain.

If Xen is to make use of the APIC assist enlightenment then a persistent mapping needs to be kept, rather than the temporary one which is currently used only to initialize the page content.

This patch also adds a comment block at the top of the source with information on the latest version of the spec. from Microsoft and the current URL where it may be found.

Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

---

v2:
- Re-instated warning if the initialization of an APIC assist page fails.
- Added up-to-date information about the viridian specification to the comment block at the top of the source.

---
 xen/arch/x86/hvm/hvm.c             |  2 +
 xen/arch/x86/hvm/viridian.c        | 76 ++++++++++++++++++++++++++++---
-------
 xen/include/asm-x86/hvm/viridian.h |  8 +++-
 3 files changed, 65 insertions(+), 21 deletions(-)
xen/arch/x86/hvm/hvm.c +2 -0
index 4ea51d7..f446ee4 100644
@@ -2606,6 +2606,8 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
 void hvm_vcpu_destroy(struct vcpu *v)
 {
+    viridian_vcpu_deinit(v);
+
     hvm_all_ioreq_servers_remove_vcpu(v->domain, v);
 
     if ( hvm_altp2m_supported() )
xen/arch/x86/hvm/viridian.c +4 -1
index 1ee22aa..e990163 100644
@@ -1,7 +1,12 @@
 
 /**********************************************************
 ********************
  * viridian.c
  *
- * An implementation of the Viridian hypercall interface.
+ * An implementation of some Viridian enlightenments. See Microsoft's
+ * Hypervisor Top Level Functional Specification (v4.0b) at:
+ *
+ * https://msdn.microsoft.com/en-

us/virtualization/hyperv_on_windows/develop/tlfs
+ *
+ * for more information.
*/

#include <xen/sched.h>

xen/arch/x86/hvm/viridian.c +1 -1
@@ -163,7 +168,7 @@ static void dump_apic_assist(const struct vcpu *v)
 {
     const union viridian_apic_assist *aa;
 
-    aa = &v->arch.hvm_vcpu.viridian.apic_assist;
+    aa = &v->arch.hvm_vcpu.viridian.apic_assist.msr;
 
     printk(XENLOG_G_INFO "%pv: VIRIDIAN APIC_ASSIST: enabled: %x pfn:
 %lx\n",
            v, aa->fields.enabled, (unsigned long)aa->fields.pfn);
xen/arch/x86/hvm/viridian.c +2 -2
@@ -217,9 +222,9 @@ static void enable_hypercall_page(struct domain *d)
 static void initialize_apic_assist(struct vcpu *v)
 {
     struct domain *d = v->domain;
-    unsigned long gmfn = v->arch.hvm_vcpu.viridian.apic_assist.fields.pfn;
+    unsigned long gmfn = v-
 >arch.hvm_vcpu.viridian.apic_assist.msr.fields.pfn;
     struct page_info *page = get_page_from_gfn(d, gmfn, NULL,
 P2M_ALLOC);
-    uint8_t *p;
+    void *va;
 

/*
* We don't yet make use of the APIC assist page but by setting

xen/arch/x86/hvm/viridian.c +0 -0
@@ -227,25 +232,49 @@ static void initialize_apic_assist(struct vcpu *v)
      * bound to support the MSR. We therefore do just enough to keep

windows
* happy.
*
- * See http://msdn.microsoft.com/en-
us/library/ff538657%28VS.85%29.aspx for

xen/arch/x86/hvm/viridian.c +35 -10
-     * details of how Windows uses the page.
+     * See section 13.3.4.1 of the specification for details of this
+     * enlightenment.
      */
 
-    if ( !page || !get_page_type(page, PGT_writable_page) )
+    if ( !page )
+        goto fail;
+
+    if ( !get_page_type(page, PGT_writable_page) )
     {
-        if ( page )
-            put_page(page);
-        gdprintk(XENLOG_WARNING, "Bad GMFN %lx (MFN %lx)\n", gmfn,
-                 page ? page_to_mfn(page) : INVALID_MFN);
-        return;
+        put_page(page);
+        goto fail;
     }
 
-    p = __map_domain_page(page);
+    va = __map_domain_page_global(page);
+    if ( !va )
+    {
+        put_page_and_type(page);
+        goto fail;
+    }
 
-    *(u32 *)p = 0;
+    *(uint32_t *)va = 0;
 
-    unmap_domain_page(p);
+    v->arch.hvm_vcpu.viridian.apic_assist.page = page;
+    v->arch.hvm_vcpu.viridian.apic_assist.va = va;
+    return;
+
+ fail:
+    gdprintk(XENLOG_WARNING, "Bad GMFN %lx (MFN %lx)\n", gmfn,
+             page ? page_to_mfn(page) : INVALID_MFN);
+}
+
+static void teardown_apic_assist(struct vcpu *v)
+{
+    struct page_info *page = v->arch.hvm_vcpu.viridian.apic_assist.page;
+    void *va = v->arch.hvm_vcpu.viridian.apic_assist.va;
 
+    if ( !va )
+        return;
+
+    v->arch.hvm_vcpu.viridian.apic_assist.va = NULL;
+    v->arch.hvm_vcpu.viridian.apic_assist.page = NULL;
+
+    unmap_domain_page_global(va);
     put_page_and_type(page);
 }

xen/arch/x86/hvm/viridian.c int wrmsr_viridian_regs(uint32_t idx, uint64_t val) · line 408

Quoted 8 lines
xen/arch/x86/hvm/viridian.c +2 -2
@@ -374,9 +403,9 @@ int wrmsr_viridian_regs(uint32_t idx, uint64_t val)
 
     case VIRIDIAN_MSR_APIC_ASSIST:
         perfc_incr(mshv_wrmsr_apic_msr);
-        v->arch.hvm_vcpu.viridian.apic_assist.raw = val;
+        v->arch.hvm_vcpu.viridian.apic_assist.msr.raw = val;
         dump_apic_assist(v);
-        if (v->arch.hvm_vcpu.viridian.apic_assist.fields.enabled)
+        if ( v->arch.hvm_vcpu.viridian.apic_assist.msr.fields.enabled )

Actually there's an omission here. If the MSR had previously been set then we potentially leak a mapping so there needs to be a teardown before the (re-)initialize.

Paul

Quoted 74 lines
xen/arch/x86/hvm/viridian.c +7 -2
             initialize_apic_assist(v);
         break;
 
@@ -485,7 +514,7 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val)
 
     case VIRIDIAN_MSR_APIC_ASSIST:
         perfc_incr(mshv_rdmsr_apic_msr);
-        *val = v->arch.hvm_vcpu.viridian.apic_assist.raw;
+        *val = v->arch.hvm_vcpu.viridian.apic_assist.msr.raw;
         break;
 
     case VIRIDIAN_MSR_REFERENCE_TSC:
@@ -521,6 +550,11 @@ int rdmsr_viridian_regs(uint32_t idx, uint64_t *val)
     return 1;
 }
 
+void viridian_vcpu_deinit(struct vcpu *v)
+{
+    teardown_apic_assist(v);
+}
+
 static DEFINE_PER_CPU(cpumask_t, ipi_cpumask);
 
 int viridian_hypercall(struct cpu_user_regs *regs)
@@ -721,7 +755,7 @@ static int viridian_save_vcpu_ctxt(struct domain *d,
 hvm_domain_context_t *h)
     for_each_vcpu( d, v ) {
         struct hvm_viridian_vcpu_context ctxt;
 
-        ctxt.apic_assist = v->arch.hvm_vcpu.viridian.apic_assist.raw;
+        ctxt.apic_assist = v->arch.hvm_vcpu.viridian.apic_assist.msr.raw;
 
         if ( hvm_save_entry(VIRIDIAN_VCPU, v->vcpu_id, h, &ctxt) != 0 )
             return 1;
xen/arch/x86/hvm/viridian.c +3 -1
@@ -747,7 +781,9 @@ static int viridian_load_vcpu_ctxt(struct domain *d,
 hvm_domain_context_t *h)
     if ( hvm_load_entry(VIRIDIAN_VCPU, h, &ctxt) != 0 )
         return -EINVAL;
 
-    v->arch.hvm_vcpu.viridian.apic_assist.raw = ctxt.apic_assist;
+    v->arch.hvm_vcpu.viridian.apic_assist.msr.raw = ctxt.apic_assist;
+    if ( v->arch.hvm_vcpu.viridian.apic_assist.msr.fields.enabled )
+        initialize_apic_assist(v);
 
     return 0;

}

xen/include/asm- renamed from xen/include/asm-x86/hvm/viridian.h +0 -0

x86/hvm/viridian.h
index c4319d7..ee3a120 100644

xen/include/asm-x86/hvm/viridian.h +7 -2
@@ -21,7 +21,11 @@ union viridian_apic_assist
 
 struct viridian_vcpu
 {
-    union viridian_apic_assist apic_assist;
+    struct {
+        union viridian_apic_assist msr;
+        struct page_info *page;
+        void *va;
+    } apic_assist;
 };
 
 union viridian_guest_os_id
@@ -117,6 +121,8 @@ viridian_hypercall(struct cpu_user_regs *regs);
 void viridian_time_ref_count_freeze(struct domain *d);
 void viridian_time_ref_count_thaw(struct domain *d);
 
+void viridian_vcpu_deinit(struct vcpu *v);
+
 #endif /* __ASM_X86_HVM_VIRIDIAN_H__ */
 
 /*
--
Quoted 1 line

2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw

Re: [PATCH v3 2/2] x86/hvm/viridian: Enable APIC assist enlightenment

In reply to Wei Liu
Quoted 67 lines

-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 16 March 2016 18:31
To: Paul Durrant
Cc: [email protected]; Ian Jackson; Stefano Stabellini; Wei Liu; Keir (Xen.org); Jan Beulich; Andrew Cooper
Subject: Re: [PATCH v3 2/2] x86/hvm/viridian: Enable APIC assist enlightenment

Quoted 26 lines · Paul Durrant

This patch adds code to enable the APIC assist enlightenment which, under certain conditions, means that the guest can avoid an EOI of the local APIC and thereby avoid a VMEXIT.

Use of the enlightenment by the hypervisor is under control of the toolstack, and is added to the default set.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Wei Liu <[email protected]>
Cc Keir Fraser <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Andrew Cooper <[email protected]>

---

v3:
- Re-instated read-modify-write for forwards compatibility
- Fix a coding style issue

v2:
- Removed some code duplication and unnecessary read-modify-write operations on the APIC assist word.
- Stated in the xl.cfg text that the enlightenment has no effect if posted interrupts are in use.
- Added the enlightenment to the default set.

Quoted 5 lines
---
 docs/man/xl.cfg.pod.5              | 13 ++++++++-
 tools/libxl/libxl_dom.c            |  4 +++
 tools/libxl/libxl_types.idl        |  1 +
 xen/arch/x86/hvm/viridian.c        | 59

++++++++++++++++++++++++++++++++++----

Quoted 1 line
 xen/arch/x86/hvm/vlapic.c          | 58

+++++++++++++++++++++++++++++++++----

docs/man/xl.cfg.pod.5 This set incorporates use of hypercalls for

Quoted 9 lines
 xen/include/asm-x86/hvm/viridian.h |  5 ++++
 xen/include/public/hvm/params.h    |  7 ++++-
 7 files changed, 134 insertions(+), 13 deletions(-)
docs/man/xl.cfg.pod.5 +0 -0
index 56b1117..1ba026b 100644
@@ -1484,10 +1484,21 @@ This set incorporates use of hypercalls for

remote TLB flushing.

docs/man/xl.cfg.pod.5 This set incorporates use of hypercalls for remote TLB flushing. · line 1493

Quoted 10 lines
docs/man/xl.cfg.pod.5 +7 -0
 This enlightenment may improve performance of Windows guests running
 on hosts with higher levels of (physical) CPU contention.
 
+=item B<apic_assist>
+
+This set incorporates use of the APIC assist page to avoid EOI of
+the local APIC.
+This enlightenment may improve performance of Windows guests,
+particularly those running PV drivers that make use of per-vcpu
+event channel upcall vectors.

I think this can be changed to

Quoted 5 lines

This enlightenment may improve performance of guests that make use of per-vcpu event channel upcall vectors.

Surely Linux can benefit from this too, right?

Potentially Linux can benefit, yes. I'll re-word as you suggest.

Quoted 56 lines

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc,

Quoted 17 lines
docs/man/xl.cfg.pod.5 +5 -1
+Note that this enlightenment will have no effect if the guest is
+using APICv posted interrupts.
+
 =item B<defaults>
 
 This is a special value that enables the default set of groups, which
-is currently the B<base>, B<freq> and B<time_ref_count> groups.
+is currently the B<base>, B<freq>, B<time_ref_count> and B<apic_assist>
+groups.
 
 =item B<all>
 
tools/libxl/libxl_dom.c +0 -0
index b825b98..09d3bca 100644
@@ -211,6 +211,7 @@ static int hvm_set_viridian_features(libxl__gc *gc,

uint32_t domid,

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc, · line 211

Quoted 1 line
tools/libxl/libxl_dom.c +0 -0
         libxl_bitmap_set(&enlightenments,

LIBXL_VIRIDIAN_ENLIGHTENMENT_BASE);

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc, · line 212

Quoted 1 line
tools/libxl/libxl_dom.c +0 -0
         libxl_bitmap_set(&enlightenments,

LIBXL_VIRIDIAN_ENLIGHTENMENT_FREQ);

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc, · line 213

Quoted 1 line
tools/libxl/libxl_dom.c +0 -0
         libxl_bitmap_set(&enlightenments,

LIBXL_VIRIDIAN_ENLIGHTENMENT_TIME_REF_COUNT);

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc, · line 214

Quoted 1 line
tools/libxl/libxl_dom.c +1 -0
+        libxl_bitmap_set(&enlightenments,

LIBXL_VIRIDIAN_ENLIGHTENMENT_APIC_ASSIST);

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc,

Quoted 4 lines
tools/libxl/libxl_dom.c +0 -0
     }
 
     libxl_for_each_set_bit(v, info->u.hvm.viridian_enable) {
@@ -253,6 +254,9 @@ static int hvm_set_viridian_features(libxl__gc *gc,

uint32_t domid,

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc, · line 254

Quoted 1 line
tools/libxl/libxl_dom.c +0 -0
     if (libxl_bitmap_test(&enlightenments,

LIBXL_VIRIDIAN_ENLIGHTENMENT_HCALL_REMOTE_TLB_FLUSH))

tools/libxl/libxl_dom.c static int hvm_set_viridian_features(libxl__gc *gc, uint32_t domid,

Quoted 3 lines
tools/libxl/libxl_dom.c +1 -0
         mask |= HVMPV_hcall_remote_tlb_flush;
 
+    if (libxl_bitmap_test(&enlightenments,

LIBXL_VIRIDIAN_ENLIGHTENMENT_APIC_ASSIST))

tools/libxl/libxl_types.idl libxl_viridian_enlightenment =

Quoted 10 lines
tools/libxl/libxl_dom.c +2 -0
+        mask |= HVMPV_apic_assist;
+
     if (mask != 0 &&
         xc_hvm_param_set(CTX->xch,
                          domid,
tools/libxl/libxl_types.idl +0 -0
index 632c009..e3be957 100644
@@ -221,6 +221,7 @@ libxl_viridian_enlightenment =

Enumeration("viridian_enlightenment", [

tools/libxl/libxl_types.idl libxl_viridian_enlightenment = Enumeration("viridian_enlightenment", [ · line 226

Quoted 6 lines
tools/libxl/libxl_types.idl +1 -0
     (2, "time_ref_count"),
     (3, "reference_tsc"),
     (4, "hcall_remote_tlb_flush"),
+    (5, "apic_assist"),
     ])
 
Quoted 2 lines

Missing a LIBXL_HAVE macro in libxl.h for this new field.

Damn. That always catches me out.

Paul

Quoted 1 line

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel