x86/hvm/viridian: Enable APIC assist enlightenment
PATCH v6 1/1 x86/hvm/viridian: Enable APIC assist enlightenment
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.
---
v6:
- Addressed various comments from Jan
v4:
- Re-worded xl.cfg text and added missing LIBXL_HAVE_ definition
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 | 12 +++++++- tools/libxl/libxl.h | 6 ++++ tools/libxl/libxl_dom.c | 4 +++ tools/libxl/libxl_types.idl | 1 + xen/arch/x86/hvm/viridian.c | 62 ++++++++++++++++++++++++++++++++++---- xen/arch/x86/hvm/vlapic.c | 60 ++++++++++++++++++++++++++++++++---- xen/include/asm-x86/hvm/hvm.h | 3 ++ xen/include/asm-x86/hvm/viridian.h | 5 +++ xen/include/public/hvm/params.h | 7 ++++- 9 files changed, 146 insertions(+), 14 deletions(-)
docs/man/xl.cfg.pod.5 +11 -1
@@ -1484,10 +1484,20 @@ 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 guests 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.h +6 -0
@@ -218,6 +218,12 @@#define LIBXL_HAVE_SOFT_RESET 1/* +* LIBXL_HAVE_APIC_ASSIST indicates that the 'apic_assist' value +* is present in the viridian enlightenment enumeration. +*/ +#define LIBXL_HAVE_APIC_ASSIST 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility
tools/libxl/libxl_dom.c +4 -0
@@ -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
@@ -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 +56 -6
80 lines not on this page · raw message
xen/arch/x86/hvm/vlapic.c +54 -6
96 lines not on this page · raw message
xen/include/asm-x86/hvm/hvm.h +3 -0
@@ -402,6 +402,9 @@ static inline unsigned long hvm_get_shadow_gs_base(struct vcpu *v)#define has_viridian_time_ref_count (d) \ (is_viridian_domain(d) && (viridian_feature_mask(d) & HVMPV_time_ref_count)) +#define has_viridian_apic_assist (d) \ + (is_viridian_domain(d) && (viridian_feature_mask(d) & HVMPV_apic_assist)) +void hvm_hypervisor_cpuid_leaf (uint32_t sub_idx,uint32_t *eax,uint32_t *ebx,uint32_t *ecx,uint32_t *edx);
xen/include/asm-x86/hvm/viridian.h +5 -0
@@ -24,6 +24,7 @@ struct viridian_vcpustruct {union viridian_apic_assist msr;void *va; +int vector; } apic_assist; };
@@ -122,6 +123,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); +int viridian_complete_apic_assist (struct vcpu *v); +void viridian_abort_apic_assist (struct vcpu *v); +#endif /* __ASM_X86_HVM_VIRIDIAN_H__ */ /*
xen/include/public/hvm/params.h +6 -1
@@ -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
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 18.03.16 at 11:32, <[email protected]> wrote:
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.
Signed-off-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 32 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.
Signed-off-by Paul Durrant <[email protected]>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]>---
v6:
- Addressed various comments from Janv4:
- Re-worded xl.cfg text and added missingLIBXL_HAVE_definitionv3:
- Re-instated read-modify-write for forwards compatibility
- Fix a coding style issuev2:
- 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 | 12 +++++++- tools/libxl/libxl.h | 6 ++++ tools/libxl/libxl_dom.c | 4 +++ tools/libxl/libxl_types.idl | 1 +
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 18.03.16 at 11:32, <[email protected]> wrote:
xen/arch/x86/hvm/viridian.c +6
-0@@ -278,6 +281,53 @@ static void teardown_apic_assist(struct vcpu *v)put_page_and_type (page); } +void viridian_start_apic_assist (struct vcpu *v,int vector) +{ +uint32_t *va = v->arch.hvm_vcpu.viridian.apic_assist.va; + +if ( !va ) +return ;
xen/arch/x86/hvm/viridian.c static void teardown_apic_assist(struct vcpu *v) · line 299
Quoted 10 lines
xen/arch/x86/hvm/viridian.c +10
-0+ +/* +* If there is already an assist pending then something has gone +* wrong and the VM will most likely hang so force a crash now +* to make the problem clear. +*/ +if ( v->arch.hvm_vcpu.viridian.apic_assist.vector >=0 ) +domain_crash (v->domain); + + v->arch.hvm_vcpu.viridian.apic_assist.vector = vector;
Considering the osstest failures I (see also IRC) I now wonder what happens if the guest gets migrated while a vCPU has this field holding a valid vector, namely how ...
xen/arch/x86/hvm/vlapic.c int vlapic_has_pending_irq(struct vcpu *v) · line 1193
Quoted 12 lines
xen/arch/x86/hvm/vlapic.c +8
-0@@ -1170,10 +1183,27 @@ int vlapic_has_pending_irq(struct vcpu *v) !nestedhvm_vcpu_in_guestmode(v) )return irr; +/* +* If APIC assist was used then there may have been no EOI so +* we need to clear the requisite bit from the ISR here, before +* comparing with the IRR. +*/ + vector =viridian_complete_apic_assist (v); +if ( vector !=-1 ) +vlapic_clear_vector (vector, &vlapic->regs->data[APIC_ISR ]);
... this would then be taken care of on the new host.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 38 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 24 March 2016 13:51
To: Paul Durrant
Cc: Andrew Cooper; Wei Liu; Ian Jackson; Stefano Stabellini; xen- [email protected]; Keir (Xen.org)
Subject: Re: [PATCH v6] x86/hvm/viridian: Enable APIC assist enlightenmentQuoted 11 lines
Quoted 1 line
Quoted 1 line · On 18.03.16 at 11:32, <[email protected]> wrote:
xen/arch/x86/hvm/viridian.c +6
-0@@ -278,6 +281,53 @@ static void teardown_apic_assist(struct vcpu *v)put_page_and_type (page); } +void viridian_start_apic_assist (struct vcpu *v,int vector) +{ +uint32_t *va = v->arch.hvm_vcpu.viridian.apic_assist.va; + +if ( !va ) +return ;xen/arch/x86/hvm/viridian.c static void teardown_apic_assist(struct vcpu *v) · line 299
Quoted 10 lines
xen/arch/x86/hvm/viridian.c +10
-0+ +/* +* If there is already an assist pending then something has gone +* wrong and the VM will most likely hang so force a crash now +* to make the problem clear. +*/ +if ( v->arch.hvm_vcpu.viridian.apic_assist.vector >=0 ) +domain_crash (v->domain); + + v->arch.hvm_vcpu.viridian.apic_assist.vector = vector;Considering the osstest failures I (see also IRC) I now wonder what happens if the guest gets migrated while a vCPU has this field holding a valid vector, namely how ...
Quoted 4 lines
xen/arch/x86/hvm/vlapic.c +0
-0@@ -1170,10 +1183,27 @@ int vlapic_has_pending_irq(struct vcpu *v) !nestedhvm_vcpu_in_guestmode(v) )return irr;
Quoted 11 lines
xen/arch/x86/hvm/vlapic.c int vlapic_has_pending_irq(struct vcpu *v) · line 1193
Quoted 8 lines
xen/arch/x86/hvm/vlapic.c +8
-0+/* +* If APIC assist was used then there may have been no EOI so +* we need to clear the requisite bit from the ISR here, before +* comparing with the IRR. +*/ + vector =viridian_complete_apic_assist (v); +if ( vector !=-1 ) +vlapic_clear_vector (vector, &vlapic->regs->data[APIC_ISR ]);... this would then be taken care of on the new host.
Yes, you're right. I need to add that field to the viridian vcpu state. Patch coming a.s.a.p.
Paul
Quoted 1 line
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel