VMX: fix interaction of Viridian emulation with advanced features
v2 cover VMX: fix interaction of Viridian emulation with advanced features
1: VMX: fix interaction of APIC-V and Viridian emulation
2: VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V 3: VMX: suppress pointless indirect calls
4: Viridian: populate CPUID leaf 6
5: Viridian: cleanup
---
v2: Split off cleanup parts from patch 1 (into new patch 3). Add new
patch 5.
PATCH v2 1/5 VMX: fix interaction of APIC-V and Viridian emulation
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Based on analysis by Yang Z Zhang <[email protected]>.
---
v2: Split off cleanup parts to new patch 3.
xen/arch/x86/hvm/vlapic.c +3 -0
@@ -386,6 +386,9 @@ void vlapic_EOI_set(struct vlapic *vlapivlapic_clear_vector (vector, &vlapic->regs->data[APIC_ISR ]); +if ( hvm_funcs.handle_eoi ) + hvm_funcs.handle_eoi (vector); +if (vlapic_test_and_clear_vector (vector, &vlapic->regs->data[APIC_TMR ]) )vioapic_update_EOI (vlapic_domain (vlapic), vector);
xen/arch/x86/hvm/vmx/vmx.c +14 -1
@@ -1502,6 +1502,15 @@ static void vmx_sync_pir_to_irr(struct vvlapic_set_vector (i, &vlapic->regs->data[APIC_IRR ]); } +static void vmx_handle_eoi (u8 vector) +{ +unsigned long status =__vmread (GUEST_INTR_STATUS ); + +/* We need to clear the SVI field. */ + status &=VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK ; +__vmwrite (GUEST_INTR_STATUS , status); +} +static struct hvm_function_table __initdata vmx_function_table = { .name ="VMX" , .cpu_up_prepare = vmx_cpu_up_prepare,
@@ -1554,6 +1563,7 @@ static struct hvm_function_table __initd .process_isr = vmx_process_isr, .deliver_posted_intr = vmx_deliver_posted_intr, .sync_pir_to_irr = vmx_sync_pir_to_irr, + .handle_eoi = vmx_handle_eoi, .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m, };
@@ -1580,7 +1590,10 @@ const struct hvm_function_table * __initsetup_ept_dump (); } - + +if ( !cpu_has_vmx_virtual_intr_delivery ) + vmx_function_table.handle_eoi =NULL ; +if ( cpu_has_vmx_posted_intr_processing )alloc_direct_apic_vector (&posted_intr_vector, event_check_interrupt);else
xen/include/asm-x86/hvm/hvm.h +1 -0
@@ -186,6 +186,7 @@ struct hvm_function_table {void (*process_isr)(int isr,struct vcpu *v);void (*deliver_posted_intr)(struct vcpu *v,u8 vector);void (*sync_pir_to_irr)(struct vcpu *v); +void (*handle_eoi)(u8 vector);/*Walk nested p2m */ int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa,
VMX: fix interaction of APIC-V and Viridian emulation
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Based on analysis by Yang Z Zhang <[email protected]>.
---
v2: Split off cleanup parts to new patch 3.
xen/arch/x86/hvm/vlapic.c +3 -0
@@ -386,6 +386,9 @@ void vlapic_EOI_set(struct vlapic *vlapivlapic_clear_vector (vector, &vlapic->regs->data[APIC_ISR ]); +if ( hvm_funcs.handle_eoi ) + hvm_funcs.handle_eoi (vector); +if (vlapic_test_and_clear_vector (vector, &vlapic->regs->data[APIC_TMR ]) )vioapic_update_EOI (vlapic_domain (vlapic), vector);
xen/arch/x86/hvm/vmx/vmx.c +14 -1
@@ -1502,6 +1502,15 @@ static void vmx_sync_pir_to_irr(struct vvlapic_set_vector (i, &vlapic->regs->data[APIC_IRR ]); } +static void vmx_handle_eoi (u8 vector) +{ +unsigned long status =__vmread (GUEST_INTR_STATUS ); + +/* We need to clear the SVI field. */ + status &=VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK ; +__vmwrite (GUEST_INTR_STATUS , status); +} +static struct hvm_function_table __initdata vmx_function_table = { .name ="VMX" , .cpu_up_prepare = vmx_cpu_up_prepare,
@@ -1554,6 +1563,7 @@ static struct hvm_function_table __initd .process_isr = vmx_process_isr, .deliver_posted_intr = vmx_deliver_posted_intr, .sync_pir_to_irr = vmx_sync_pir_to_irr, + .handle_eoi = vmx_handle_eoi, .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m, };
@@ -1580,7 +1590,10 @@ const struct hvm_function_table * __initsetup_ept_dump (); } - + +if ( !cpu_has_vmx_virtual_intr_delivery ) + vmx_function_table.handle_eoi =NULL ; +if ( cpu_has_vmx_posted_intr_processing )alloc_direct_apic_vector (&posted_intr_vector, event_check_interrupt);else
xen/include/asm-x86/hvm/hvm.h +1 -0
@@ -186,6 +186,7 @@ struct hvm_function_table {void (*process_isr)(int isr,struct vcpu *v);void (*deliver_posted_intr)(struct vcpu *v,u8 vector);void (*sync_pir_to_irr)(struct vcpu *v); +void (*handle_eoi)(u8 vector);/*Walk nested p2m */ int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa,
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation
Quoted 8 lines · Jan Beulich
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Based on analysis by Yang Z Zhang <[email protected]>.
Signed-off-by Jan Beulich <[email protected]>
Hmm... so there are three paths which may end up calling this vmx EOI code -- from viridian.c:wrmsr_vidiridan_regs(), from vlapic.c:vlapic_reg_write(), and vmx_handle_eoi_write().
Obviously the viridian code is what we want. But which of the other two paths will also end up taking it, and is it correct? In other words, for which of those will cpu_has_vmx_virtual_intr_delivery be set?
-George
Quoted 66 lines
---
v2: Split off cleanup parts to new patch 3.xen/arch/x86/hvm/vlapic.c +3
-0@@ -386,6 +386,9 @@ void vlapic_EOI_set(struct vlapic *vlapivlapic_clear_vector (vector, &vlapic->regs->data[APIC_ISR ]); +if ( hvm_funcs.handle_eoi ) + hvm_funcs.handle_eoi (vector); +if (vlapic_test_and_clear_vector (vector, &vlapic->regs->data[APIC_TMR ]) )vioapic_update_EOI (vlapic_domain (vlapic), vector);xen/arch/x86/hvm/vmx/vmx.c +14
-1@@ -1502,6 +1502,15 @@ static void vmx_sync_pir_to_irr(struct vvlapic_set_vector (i, &vlapic->regs->data[APIC_IRR ]); } +static void vmx_handle_eoi (u8 vector) +{ +unsigned long status =__vmread (GUEST_INTR_STATUS ); + +/* We need to clear the SVI field. */ + status &=VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK ; +__vmwrite (GUEST_INTR_STATUS , status); +} +static struct hvm_function_table __initdata vmx_function_table = { .name ="VMX" , .cpu_up_prepare = vmx_cpu_up_prepare,@@ -1554,6 +1563,7 @@ static struct hvm_function_table __initd .process_isr = vmx_process_isr, .deliver_posted_intr = vmx_deliver_posted_intr, .sync_pir_to_irr = vmx_sync_pir_to_irr, + .handle_eoi = vmx_handle_eoi, .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m, };@@ -1580,7 +1590,10 @@ const struct hvm_function_table * __initsetup_ept_dump (); } - + +if ( !cpu_has_vmx_virtual_intr_delivery ) + vmx_function_table.handle_eoi =NULL ; +if ( cpu_has_vmx_posted_intr_processing )alloc_direct_apic_vector (&posted_intr_vector, event_check_interrupt);else xen/include/asm-x86/hvm/hvm.h +1
-0@@ -186,6 +186,7 @@ struct hvm_function_table {void (*process_isr)(int isr,struct vcpu *v);void (*deliver_posted_intr)(struct vcpu *v,u8 vector);void (*sync_pir_to_irr)(struct vcpu *v); +void (*handle_eoi)(u8 vector);/*Walk nested p2m */ int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa,
Re: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation
Quoted 7 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 5 lines · Jan Beulich
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Quoted 7 lines
Quoted 3 lines
Based on analysis by Yang Z Zhang <[email protected]>.
Signed-off-by Jan Beulich <[email protected]>Hmm... so there are three paths which may end up calling this vmx EOI code -- from viridian.c:wrmsr_vidiridan_regs(), from vlapic.c:vlapic_reg_write(), and
vmx_handle_eoi_write().
This is the very reason why I favored patch 2 over this one for 4.3 ...
Quoted 3 lines
Obviously the viridian code is what we want. But which of the other two paths will also end up taking it, and is it correct? In other words, for which of those will
cpu_has_vmx_virtual_intr_deliverybe set?
The two other paths would in the worst case end up re-doing what the hardware already did.
However, both of them can't occur with APIC register virtualization enabled, and during early investigation of this issue I was told that even if they're formally independent features, virtual interrupt delivery always implies APIC register virtualization.
Jan
Re: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 5 lines · Jan Beulich
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Based on analysis by Yang Z Zhang <[email protected]>.
Signed-off-by Jan Beulich <[email protected]>Hmm... so there are three paths which may end up calling this vmx EOI code -- from viridian.c:wrmsr_vidiridan_regs(), from vlapic.c:vlapic_reg_write(), and
vmx_handle_eoi_write().This is the very reason why I favored patch 2 over this one for 4.3 ...
Yes, I think I didn't realize that when I looked at the patch on Friday. (It was the end of a very tiring week.)
What other operating systems have you tested patch #2 with? IIRC Vista and Win7 both also have extensions, IIRC. Also, has either #1 or #2 been tested on AMD boxen?
Choosing #1 involves the risk that we've missed something an will make one of those three cases *not* like real hardware, which seems fairly small. Choosing #2 involves the risk that MS may not have implemented the feature flag checking properly -- they almost surely test it *with* the feature flag much more than *without* it. Even if they do test without it, they may not test with the particular combination of flags that we are proposing.
So overall, I still tend to think #1 is probably less risky. But as I said, I'm willing to go with either one.
-George
Re: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation
Quoted 15 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 8 lines · Jan Beulich
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Based on analysis by Yang Z Zhang <[email protected]>.
Signed-off-by Jan Beulich <[email protected]>Hmm... so there are three paths which may end up calling this vmx EOI code -- from viridian.c:wrmsr_vidiridan_regs(), from vlapic.c:vlapic_reg_write(), and
vmx_handle_eoi_write().
Quoted 8 lines
Quoted 2 lines
This is the very reason why I favored patch 2 over this one for 4.3 ...
Yes, I think I didn't realize that when I looked at the patch on Friday. (It was the end of a very tiring week.)
What other operating systems have you tested patch #2 with? IIRC Vista and Win7 both also have extensions, IIRC.
Win7 surely has been tested, but I doubt Vista has (we don't routinely do that).
Quoted 1 line
Also, has either #1 or #2 been tested on AMD boxen?
No, and I don't see the point. The actor #1 adds is simply NULL for SVM (and hence behavior doesn't change), and the flag tested in #2 is VMX specific too (so behavior doesn't change either).
Quoted 10 lines
Choosing #1 involves the risk that we've missed something an will make one of those three cases *not* like real hardware, which seems fairly small. Choosing #2 involves the risk that MS may not have implemented the feature flag checking properly -- they almost surely test it *with* the feature flag much more than *without* it. Even if they do test without it, they may not test with the particular combination of flags that we are proposing.
So overall, I still tend to think #1 is probably less risky. But as I said, I'm willing to go with either one.
Which might as well mean to go with both, provided we get acks soon.
Jan
Re: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation
Quoted 38 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 13 lines · Jan Beulich
Quoted 13 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 8 lines · Jan Beulich
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Based on analysis by Yang Z Zhang <[email protected]>.
Signed-off-by Jan Beulich <[email protected]>Hmm... so there are three paths which may end up calling this vmx EOI code -- from viridian.c:wrmsr_vidiridan_regs(), from vlapic.c:vlapic_reg_write(), and
vmx_handle_eoi_write().Quoted 7 lines
Quoted 2 lines
This is the very reason why I favored patch 2 over this one for 4.3 ...
Yes, I think I didn't realize that when I looked at the patch on Friday. (It was the end of a very tiring week.)
What other operating systems have you tested patch #2 with? IIRC Vista and Win7 both also have extensions, IIRC.
Win7 surely has been tested, but I doubt Vista has (we don't routinely do that).
Quoted 1 line
Also, has either #1 or #2 been tested on AMD boxen?
No, and I don't see the point. The actor #1 adds is simply NULL for SVM (and hence behavior doesn't change), and the flag tested in #2 is VMX specific too (so behavior doesn't change either).
Quoted 8 lines
Choosing #1 involves the risk that we've missed something an will make one of those three cases *not* like real hardware, which seems fairly small. Choosing #2 involves the risk that MS may not have implemented the feature flag checking properly -- they almost surely test it *with* the feature flag much more than *without* it. Even if they do test without it, they may not test with the particular combination of flags that we are proposing.
Quoted 4 lines
Quoted 2 lines
So overall, I still tend to think #1 is probably less risky. But as I said, I'm willing to go with either one.
Which might as well mean to go with both, provided we get acks soon.
Um, I think exactly the opposite. The question we want to ask now is, "What option will fix the problem with the lowest risk of having another problem crop up?" If we choose *both*, then we get a failure if there is a secondary problem in *either* patch.
That's like saying, "I'm not sure which of these revolvers is loaded/has more bullets, so if I'm going to play Russian roulette, I might as well do it with both." :-)
-George
Re: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation
Quoted 8 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 5 lines · Jan Beulich
Quoted 3 lines
Quoted 1 line
Quoted 1 line · George Dunlap
So overall, I still tend to think #1 is probably less risky. But as I said, I'm willing to go with either one.
Which might as well mean to go with both, provided we get acks soon.
Quoted 8 lines
Um, I think exactly the opposite. The question we want to ask now is, "What option will fix the problem with the lowest risk of having another problem crop up?" If we choose *both*, then we get a failure if there is a secondary problem in *either* patch.
That's like saying, "I'm not sure which of these revolvers is loaded/has more bullets, so if I'm going to play Russian roulette, I might as well do it with both." :-)
Yeah, if you're taking this from the pessimistic side...
Jan
Re: [PATCH v2 1/5] VMX: fix interaction of APIC-V and Viridian emulation
In reply to Jan BeulichQuoted 8 lines · Jan Beulich
Viridian using a synthetic MSR for issuing EOI notifications bypasses the normal in-processor handling, which would clear GUEST_INTR_STATUS.SVI. Hence we need to do this in software in order for future interrupts to get delivered.
Based on analysis by Yang Z Zhang <[email protected]>.
Signed-off-by Jan Beulich <[email protected]>
Quoted 68 lines
---
v2: Split off cleanup parts to new patch 3.xen/arch/x86/hvm/vlapic.c +3
-0@@ -386,6 +386,9 @@ void vlapic_EOI_set(struct vlapic *vlapivlapic_clear_vector (vector, &vlapic->regs->data[APIC_ISR ]); +if ( hvm_funcs.handle_eoi ) + hvm_funcs.handle_eoi (vector); +if (vlapic_test_and_clear_vector (vector, &vlapic->regs->data[APIC_TMR ]) )vioapic_update_EOI (vlapic_domain (vlapic), vector);xen/arch/x86/hvm/vmx/vmx.c +14
-1@@ -1502,6 +1502,15 @@ static void vmx_sync_pir_to_irr(struct vvlapic_set_vector (i, &vlapic->regs->data[APIC_IRR ]); } +static void vmx_handle_eoi (u8 vector) +{ +unsigned long status =__vmread (GUEST_INTR_STATUS ); + +/* We need to clear the SVI field. */ + status &=VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK ; +__vmwrite (GUEST_INTR_STATUS , status); +} +static struct hvm_function_table __initdata vmx_function_table = { .name ="VMX" , .cpu_up_prepare = vmx_cpu_up_prepare,@@ -1554,6 +1563,7 @@ static struct hvm_function_table __initd .process_isr = vmx_process_isr, .deliver_posted_intr = vmx_deliver_posted_intr, .sync_pir_to_irr = vmx_sync_pir_to_irr, + .handle_eoi = vmx_handle_eoi, .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m, };@@ -1580,7 +1590,10 @@ const struct hvm_function_table * __initsetup_ept_dump (); } - + +if ( !cpu_has_vmx_virtual_intr_delivery ) + vmx_function_table.handle_eoi =NULL ; +if ( cpu_has_vmx_posted_intr_processing )alloc_direct_apic_vector (&posted_intr_vector, event_check_interrupt);else xen/include/asm-x86/hvm/hvm.h +1
-0@@ -186,6 +186,7 @@ struct hvm_function_table {void (*process_isr)(int isr,struct vcpu *v);void (*deliver_posted_intr)(struct vcpu *v,u8 vector);void (*sync_pir_to_irr)(struct vcpu *v); +void (*handle_eoi)(u8 vector);/*Walk nested p2m */ int (*nhvm_hap_walk_L1_p2m)(struct vcpu *v, paddr_t L2_gpa,
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v2 2/5 VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V
In reply to Jan BeulichWhen the CPU has the necessary capabilities, having Windows use synthetic MSR reads/writes is bogus, as this still requires emulation (which is pretty much guaranteed to be slower than having the hardware carry out the operation).
xen/arch/x86/hvm/viridian.c +3 -2
@@ -87,8 +87,9 @@ int cpuid_viridian_leaves(unsigned int lif ( (d->arch.hvm_domain.viridian.guest_os_id.raw ==0 ) || (d->arch.hvm_domain.viridian.guest_os_id.fields.os <4 ) )break ; - *eax = (CPUID4A_MSR_BASED_APIC | -CPUID4A_RELAX_TIMER_INT ); + *eax =CPUID4A_RELAX_TIMER_INT ; +if ( !cpu_has_vmx_apic_reg_virt ) + *eax |=CPUID4A_MSR_BASED_APIC ; *ebx =2047 ;/* long spin count */ break ; }
VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V
When the CPU has the necessary capabilities, having Windows use synthetic MSR reads/writes is bogus, as this still requires emulation (which is pretty much guaranteed to be slower than having the hardware carry out the operation).
xen/arch/x86/hvm/viridian.c +3 -2
@@ -87,8 +87,9 @@ int cpuid_viridian_leaves(unsigned int lif ( (d->arch.hvm_domain.viridian.guest_os_id.raw ==0 ) || (d->arch.hvm_domain.viridian.guest_os_id.fields.os <4 ) )break ; - *eax = (CPUID4A_MSR_BASED_APIC | -CPUID4A_RELAX_TIMER_INT ); + *eax =CPUID4A_RELAX_TIMER_INT ; +if ( !cpu_has_vmx_apic_reg_virt ) + *eax |=CPUID4A_MSR_BASED_APIC ; *ebx =2047 ;/* long spin count */ break ; }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 2/5] VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V
Quoted 9 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 24 June 2013 08:05
To: xen-devel
Cc: Paul Durrant; George Dunlap; Eddie Dong; Jun Nakajima; Yang Z Zhang; Keir (Xen.org)
Subject: [PATCH v2 2/5] VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V
Quoted 7 lines
When the CPU has the necessary capabilities, having Windows use synthetic MSR reads/writes is bogus, as this still requires emulation (which is pretty much guaranteed to be slower than having the hardware carry out the operation).
Signed-off-by Jan Beulich <[email protected]>
Seems better just to not use the MSR in this case so I favour this patch over #1, hence
Ack-ed by: Paul Durrant <[email protected]>
Quoted 16 lines
xen/arch/x86/hvm/viridian.c +3
-2@@ -87,8 +87,9 @@ int cpuid_viridian_leaves(unsigned int lif ( (d->arch.hvm_domain.viridian.guest_os_id.raw ==0 ) || (d->arch.hvm_domain.viridian.guest_os_id.fields.os <4 ) )break ; - *eax = (CPUID4A_MSR_BASED_APIC | -CPUID4A_RELAX_TIMER_INT ); + *eax =CPUID4A_RELAX_TIMER_INT ; +if ( !cpu_has_vmx_apic_reg_virt ) + *eax |=CPUID4A_MSR_BASED_APIC ; *ebx =2047 ;/* long spin count */ break ; }
Re: [PATCH v2 2/5] VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V
Quoted 14 lines · Paul Durrant
Quoted 14 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 24 June 2013 08:05
To: xen-devel
Cc: Paul Durrant; George Dunlap; Eddie Dong; Jun Nakajima; Yang Z Zhang; Keir (Xen.org)
Subject: [PATCH v2 2/5] VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-VWhen the CPU has the necessary capabilities, having Windows use synthetic MSR reads/writes is bogus, as this still requires emulation (which is pretty much guaranteed to be slower than having the hardware carry out the operation).
Quoted 6 lines
Quoted 2 lines
Signed-off-by Jan Beulich <[email protected]>Seems better just to not use the MSR in this case so I favour this patch over #1, hence
Ack-ed by: Paul Durrant <[email protected]>
This may push this over into the "#2 is probably a better idea" category; Paul, Yang, and Jan all think it's less intrusive.
Jan, I think it's your call -- You have an ack from me to put either #1 or #2 in for 4.3 (but please not both).
-George
Re: [PATCH v2 2/5] VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V
Quoted 22 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Quoted 14 lines · Paul Durrant
Quoted 14 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 24 June 2013 08:05
To: xen-devel
Cc: Paul Durrant; George Dunlap; Eddie Dong; Jun Nakajima; Yang Z Zhang; Keir (Xen.org)
Subject: [PATCH v2 2/5] VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-VWhen the CPU has the necessary capabilities, having Windows use synthetic MSR reads/writes is bogus, as this still requires emulation (which is pretty much guaranteed to be slower than having the hardware carry out the operation).
Quoted 4 lines
Quoted 2 lines
Signed-off-by Jan Beulich <[email protected]>Seems better just to not use the MSR in this case so I favour this patch
over #1, hence
Quoted 1 line
Quoted 7 lines
Quoted 1 line
Ack-ed by: Paul Durrant <[email protected]>
This may push this over into the "#2 is probably a better idea" category; Paul, Yang, and Jan all think it's less intrusive.
Jan, I think it's your call -- You have an ack from me to put either #1 or #2 in for 4.3 (but please not both).
So I pushed this one, considering the above and the lack of an ack for #1.
Jan
PATCH v2 3/5 VMX: suppress pointless indirect calls
In reply to Jan BeulichGet the other virtual interrupt delivery related actors in sync with the newly added handle_eoi() one: Clear the respective pointers (thus avoiding the call from generic code) when the feature is unavailable instead of checking feature availability in the actors.
xen/arch/x86/hvm/vmx/vmx.c +8 -10
@@ -1411,13 +1411,10 @@ static void vmx_set_info_guest(struct vcstatic void vmx_update_eoi_exit_bitmap (struct vcpu *v,u8 vector,u8 trig) { -if ( cpu_has_vmx_virtual_intr_delivery ) - { -if (trig) -vmx_set_eoi_exit_bitmap (v, vector); -else -vmx_clear_eoi_exit_bitmap (v, vector); - } +if ( trig ) +vmx_set_eoi_exit_bitmap (v, vector); +else +vmx_clear_eoi_exit_bitmap (v, vector); }static int vmx_virtual_intr_delivery_enabled (void )
@@ -1430,9 +1427,6 @@ static void vmx_process_isr(int isr, strunsigned long status;u8 old; -if ( !cpu_has_vmx_virtual_intr_delivery ) -return ; -if ( isr <0 ) isr =0 ;
@@ -1592,7 +1586,11 @@ const struct hvm_function_table * __init }if ( !cpu_has_vmx_virtual_intr_delivery ) + { + vmx_function_table.update_eoi_exit_bitmap =NULL ; + vmx_function_table.process_isr =NULL ; vmx_function_table.handle_eoi =NULL ; + }if ( cpu_has_vmx_posted_intr_processing )alloc_direct_apic_vector (&posted_intr_vector, event_check_interrupt);
VMX: suppress pointless indirect calls
Get the other virtual interrupt delivery related actors in sync with the newly added handle_eoi() one: Clear the respective pointers (thus avoiding the call from generic code) when the feature is unavailable instead of checking feature availability in the actors.
xen/arch/x86/hvm/vmx/vmx.c +8 -10
@@ -1411,13 +1411,10 @@ static void vmx_set_info_guest(struct vcstatic void vmx_update_eoi_exit_bitmap (struct vcpu *v,u8 vector,u8 trig) { -if ( cpu_has_vmx_virtual_intr_delivery ) - { -if (trig) -vmx_set_eoi_exit_bitmap (v, vector); -else -vmx_clear_eoi_exit_bitmap (v, vector); - } +if ( trig ) +vmx_set_eoi_exit_bitmap (v, vector); +else +vmx_clear_eoi_exit_bitmap (v, vector); }static int vmx_virtual_intr_delivery_enabled (void )
@@ -1430,9 +1427,6 @@ static void vmx_process_isr(int isr, strunsigned long status;u8 old; -if ( !cpu_has_vmx_virtual_intr_delivery ) -return ; -if ( isr <0 ) isr =0 ;
@@ -1592,7 +1586,11 @@ const struct hvm_function_table * __init }if ( !cpu_has_vmx_virtual_intr_delivery ) + { + vmx_function_table.update_eoi_exit_bitmap =NULL ; + vmx_function_table.process_isr =NULL ; vmx_function_table.handle_eoi =NULL ; + }if ( cpu_has_vmx_posted_intr_processing )alloc_direct_apic_vector (&posted_intr_vector, event_check_interrupt);
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 3/5] VMX: suppress pointless indirect calls
Quoted 6 lines · Jan Beulich
Get the other virtual interrupt delivery related actors in sync with the newly added
handle_eoi()one: Clear the respective pointers (thus avoiding the call from generic code) when the feature is unavailable instead of checking feature availability in the actors.Signed-off-by Jan Beulich <[email protected]>
Quoted 48 lines
xen/arch/x86/hvm/vmx/vmx.c +8
-10@@ -1411,13 +1411,10 @@ static void vmx_set_info_guest(struct vcstatic void vmx_update_eoi_exit_bitmap (struct vcpu *v,u8 vector,u8 trig) { -if ( cpu_has_vmx_virtual_intr_delivery ) - { -if (trig) -vmx_set_eoi_exit_bitmap (v, vector); -else -vmx_clear_eoi_exit_bitmap (v, vector); - } +if ( trig ) +vmx_set_eoi_exit_bitmap (v, vector); +else +vmx_clear_eoi_exit_bitmap (v, vector); }static int vmx_virtual_intr_delivery_enabled (void )@@ -1430,9 +1427,6 @@ static void vmx_process_isr(int isr, strunsigned long status;u8 old; -if ( !cpu_has_vmx_virtual_intr_delivery ) -return ; -if ( isr <0 ) isr =0 ;@@ -1592,7 +1586,11 @@ const struct hvm_function_table * __init }if ( !cpu_has_vmx_virtual_intr_delivery ) + { + vmx_function_table.update_eoi_exit_bitmap =NULL ; + vmx_function_table.process_isr =NULL ; vmx_function_table.handle_eoi =NULL ; + }if ( cpu_has_vmx_posted_intr_processing )alloc_direct_apic_vector (&posted_intr_vector, event_check_interrupt);
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v2 4/5 Viridian: populate CPUID leaf 6
In reply to Jan BeulichProperly reporting hardware features we use can only help Windows in making decisions towards its own performance tuning.
xen/arch/x86/hvm/viridian.c +14 -0
@@ -41,6 +41,11 @@#define CPUID4A_MSR_BASED_APIC (1 << 3)#define CPUID4A_RELAX_TIMER_INT (1 << 5) +/* Viridian CPUID 4000006, Implementation HW features detected and in use. */ +#define CPUID6A_APIC_OVERLAY (1 << 0) +#define CPUID6A_MSR_BITMAPS (1 << 1) +#define CPUID6A_NESTED_PAGING (1 << 3) +int cpuid_viridian_leaves (unsigned int leaf,unsigned int *eax,unsigned int *ebx,unsigned int *ecx,unsigned int *edx)
@@ -92,6 +97,15 @@ int cpuid_viridian_leaves(unsigned int l *eax |=CPUID4A_MSR_BASED_APIC ; *ebx =2047 ;/* long spin count */ break ; +case 6 : +/* Detected and in use hardware features. */ +if ( cpu_has_vmx_virtualize_apic_accesses ) + *eax |=CPUID6A_APIC_OVERLAY ; +if ( cpu_has_vmx_msr_bitmap || (read_efer () &EFER_SVME ) ) + *eax |=CPUID6A_MSR_BITMAPS ; +if (hap_enabled (d) ) + *eax |=CPUID6A_NESTED_PAGING ; +break ; }return 1 ;
Viridian: populate CPUID leaf 6
Properly reporting hardware features we use can only help Windows in making decisions towards its own performance tuning.
xen/arch/x86/hvm/viridian.c +14 -0
@@ -41,6 +41,11 @@#define CPUID4A_MSR_BASED_APIC (1 << 3)#define CPUID4A_RELAX_TIMER_INT (1 << 5) +/* Viridian CPUID 4000006, Implementation HW features detected and in use. */ +#define CPUID6A_APIC_OVERLAY (1 << 0) +#define CPUID6A_MSR_BITMAPS (1 << 1) +#define CPUID6A_NESTED_PAGING (1 << 3) +int cpuid_viridian_leaves (unsigned int leaf,unsigned int *eax,unsigned int *ebx,unsigned int *ecx,unsigned int *edx)
@@ -92,6 +97,15 @@ int cpuid_viridian_leaves(unsigned int l *eax |=CPUID4A_MSR_BASED_APIC ; *ebx =2047 ;/* long spin count */ break ; +case 6 : +/* Detected and in use hardware features. */ +if ( cpu_has_vmx_virtualize_apic_accesses ) + *eax |=CPUID6A_APIC_OVERLAY ; +if ( cpu_has_vmx_msr_bitmap || (read_efer () &EFER_SVME ) ) + *eax |=CPUID6A_MSR_BITMAPS ; +if (hap_enabled (d) ) + *eax |=CPUID6A_NESTED_PAGING ; +break ; }return 1 ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 4/5] Viridian: populate CPUID leaf 6
Quoted 4 lines · Jan Beulich
Properly reporting hardware features we use can only help Windows in making decisions towards its own performance tuning.
Signed-off-by Jan Beulich <[email protected]>
Does viridian allow for the possibility of these flags to change during runtime, e.g. migrating an HVM domain from hardware supporting HAP to hardware which can only manage shadow?
~Andrew
Quoted 36 lines
xen/arch/x86/hvm/viridian.c +14
-0@@ -41,6 +41,11 @@#define CPUID4A_MSR_BASED_APIC (1 << 3)#define CPUID4A_RELAX_TIMER_INT (1 << 5) +/* Viridian CPUID 4000006, Implementation HW features detected and in use. */ +#define CPUID6A_APIC_OVERLAY (1 << 0) +#define CPUID6A_MSR_BITMAPS (1 << 1) +#define CPUID6A_NESTED_PAGING (1 << 3) +int cpuid_viridian_leaves (unsigned int leaf,unsigned int *eax,unsigned int *ebx,unsigned int *ecx,unsigned int *edx)@@ -92,6 +97,15 @@ int cpuid_viridian_leaves(unsigned int l *eax |=CPUID4A_MSR_BASED_APIC ; *ebx =2047 ;/* long spin count */ break ; +case 6 : +/* Detected and in use hardware features. */ +if ( cpu_has_vmx_virtualize_apic_accesses ) + *eax |=CPUID6A_APIC_OVERLAY ; +if ( cpu_has_vmx_msr_bitmap || (read_efer () &EFER_SVME ) ) + *eax |=CPUID6A_MSR_BITMAPS ; +if (hap_enabled (d) ) + *eax |=CPUID6A_NESTED_PAGING ; +break ; }return 1 ;
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 4/5] Viridian: populate CPUID leaf 6
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 4 lines · Jan Beulich
Properly reporting hardware features we use can only help Windows in making decisions towards its own performance tuning.
Signed-off-by Jan Beulich <[email protected]>Does viridian allow for the possibility of these flags to change during runtime, e.g. migrating an HVM domain from hardware supporting HAP to hardware which can only manage shadow?
Don't know, but this is only reporting capabilities of the hypervisor, so if they store those anywhere for any purpose they wouldn't have migration in mind even on their own hypervisor.
Jan
Andrew Cooper
Reviewed-byRe: [PATCH v2 4/5] Viridian: populate CPUID leaf 6
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
Quoted 4 lines · Jan Beulich
Properly reporting hardware features we use can only help Windows in making decisions towards its own performance tuning.
Signed-off-by Jan Beulich <[email protected]>
Quoted 9 lines
Quoted 3 lines
Does viridian allow for the possibility of these flags to change during runtime, e.g. migrating an HVM domain from hardware supporting HAP to hardware which can only manage shadow?
Don't know, but this is only reporting capabilities of the hypervisor, so if they store those anywhere for any purpose they wouldn't have migration in mind even on their own hypervisor.
Jan
Very true.
PATCH v2 5/5 Viridian: cleanup
In reply to Jan Beulich- functions used only locally should be static
- constify parameters of dump functions
xen/arch/x86/hvm/viridian.c +4 -4
@@ -111,7 +111,7 @@ int cpuid_viridian_leaves(unsigned int lreturn 1 ; } -void dump_guest_os_id (struct domain *d) +static void dump_guest_os_id (const struct domain *d) {gdprintk (XENLOG_INFO ,"GUEST_OS_ID:\n" ); gdprintk(XENLOG_INFO, "\tvendor: %x\n",
@@ -128,7 +128,7 @@ void dump_guest_os_id(struct domain *d) d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); } -void dump_hypercall (struct domain *d) +static void dump_hypercall (const struct domain *d) {gdprintk (XENLOG_INFO ,"HYPERCALL:\n" ); gdprintk(XENLOG_INFO, "\tenabled: %x\n",
@@ -137,7 +137,7 @@ void dump_hypercall(struct domain *d) (unsigned long)d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn); } -void dump_apic_assist (struct vcpu *v) +static void dump_apic_assist (const struct vcpu *v) {gdprintk (XENLOG_INFO ,"APIC_ASSIST[%d]:\n" , v->vcpu_id); gdprintk(XENLOG_INFO, "\tenabled: %x\n",
@@ -180,7 +180,7 @@ static void enable_hypercall_page(structput_page_and_type (page); } -void initialize_apic_assist (struct vcpu *v) +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;
Viridian: cleanup
- functions used only locally should be static
- constify parameters of dump functions
xen/arch/x86/hvm/viridian.c +4 -4
@@ -111,7 +111,7 @@ int cpuid_viridian_leaves(unsigned int lreturn 1 ; } -void dump_guest_os_id (struct domain *d) +static void dump_guest_os_id (const struct domain *d) {gdprintk (XENLOG_INFO ,"GUEST_OS_ID:\n" ); gdprintk(XENLOG_INFO, "\tvendor: %x\n",
@@ -128,7 +128,7 @@ void dump_guest_os_id(struct domain *d) d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); } -void dump_hypercall (struct domain *d) +static void dump_hypercall (const struct domain *d) {gdprintk (XENLOG_INFO ,"HYPERCALL:\n" ); gdprintk(XENLOG_INFO, "\tenabled: %x\n",
@@ -137,7 +137,7 @@ void dump_hypercall(struct domain *d) (unsigned long)d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn); } -void dump_apic_assist (struct vcpu *v) +static void dump_apic_assist (const struct vcpu *v) {gdprintk (XENLOG_INFO ,"APIC_ASSIST[%d]:\n" , v->vcpu_id); gdprintk(XENLOG_INFO, "\tenabled: %x\n",
@@ -180,7 +180,7 @@ static void enable_hypercall_page(structput_page_and_type (page); } -void initialize_apic_assist (struct vcpu *v) +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;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v2 5/5] Viridian: cleanup
Quoted 4 lines · Jan Beulich
- functions used only locally should be static
- constify parameters of dump functionsSigned-off-by Jan Beulich <[email protected]>
Quoted 44 lines
xen/arch/x86/hvm/viridian.c +4
-4@@ -111,7 +111,7 @@ int cpuid_viridian_leaves(unsigned int lreturn 1 ; } -void dump_guest_os_id (struct domain *d) +static void dump_guest_os_id (const struct domain *d) {gdprintk (XENLOG_INFO ,"GUEST_OS_ID:\n" ); gdprintk(XENLOG_INFO, "\tvendor: %x\n",@@ -128,7 +128,7 @@ void dump_guest_os_id(struct domain *d) d->arch.hvm_domain.viridian.guest_os_id.fields.build_number); } -void dump_hypercall (struct domain *d) +static void dump_hypercall (const struct domain *d) {gdprintk (XENLOG_INFO ,"HYPERCALL:\n" ); gdprintk(XENLOG_INFO, "\tenabled: %x\n",@@ -137,7 +137,7 @@ void dump_hypercall(struct domain *d) (unsigned long)d->arch.hvm_domain.viridian.hypercall_gpa.fields.pfn); } -void dump_apic_assist (struct vcpu *v) +static void dump_apic_assist (const struct vcpu *v) {gdprintk (XENLOG_INFO ,"APIC_ASSIST[%d]:\n" , v->vcpu_id); gdprintk(XENLOG_INFO, "\tenabled: %x\n",@@ -180,7 +180,7 @@ static void enable_hypercall_page(structput_page_and_type (page); } -void initialize_apic_assist (struct vcpu *v) +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;
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
1: VMX: fix interaction of APIC-V and Viridian emulation
2: VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V 3: VMX: suppress pointless indirect calls
4: Viridian: populate CPUID leaf 6
5: Viridian: cleanupSigned-off-by Jan Beulich <[email protected]>---
v2: Split off cleanup parts from patch 1 (into new patch 3). Add new
patch 5.
While patch 2 went in for 4.3, all of the others here are still awaiting reviews/acks. Anyone?
Thanks, Jan
Zhang, Yang Z
Reviewed-byJan Beulich wrote on 2013-07-04:
Quoted 13 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Jan Beulich
1: VMX: fix interaction of APIC-V and Viridian emulation 2: VMX/Viridian: suppress MSR-based APIC suggestion when having APIC-V
3: VMX: suppress pointless indirect calls
4: Viridian: populate CPUID leaf 6
5: Viridian: cleanupQuoted 4 lines
Signed-off-by Jan Beulich <[email protected]>---
v2: Split off cleanup parts from patch 1 (into new patch 3). Add new
patch 5.
Quoted 4 lines
While patch 2 went in for 4.3, all of the others here are still awaiting reviews/acks. Anyone?
Thanks, Jan
Best regards,
Yang