vmx, apicv: fix save/restore issue with apicv
PATCH v2 1/1 vmx, apicv: fix save/restore issue with apicv
From: Yang Zhang <[email protected]>
This patch fixes two issues:
1. Interrupts on PIR are lost during save/restore. Syncing the PIR into IRR during save will fix it.
2. EOI exit bitmap doesn't set up correctly after restore. Here we will construct the eoi exit bitmap via (IRR | ISR). Though it may cause unnecessary eoi exit of the interrupts that pending in IRR or ISR during save/restore, each pending interrupt only causes one vmexit. The subsequent interrupts will adjust the eoi exit bitmap correctly. So the performance hurt can be ignored.
---
Hi Olaf and Malcolm, please help to retest this version.
xen/arch/x86/hvm/vlapic.c | 3 +++ xen/arch/x86/hvm/vmx/vmx.c | 24 ++++++++++++++++++++++++ xen/include/asm-x86/hvm/vlapic.h | 2 ++ 3 files changed, 29 insertions(+), 0 deletions(-)
xen/arch/x86/hvm/vlapic.c +3 -0
@@ -1293,6 +1293,9 @@ static int lapic_save_regs(struct domain *d, hvm_domain_context_t *h) for_each_vcpu ( d, v ) { +if ( hvm_funcs.sync_pir_to_irr ) + hvm_funcs.sync_pir_to_irr (v); + s =vcpu_vlapic (v);if ( (rc =hvm_save_entry (LAPIC_REGS , v->vcpu_id, h, s->regs)) !=0 )break ;
xen/arch/x86/hvm/vmx/vmx.c +24 -0
@@ -1584,6 +1584,8 @@ static void vmx_process_isr(int isr, struct vcpu *v) {unsigned long status;u8 old; +unsigned int i, vector; +struct vlapic *vlapic =vcpu_vlapic (v);if ( isr <0 ) isr =0 ;
@@ -1597,6 +1599,28 @@ static void vmx_process_isr(int isr, struct vcpu *v) status |= isr <<VMX_GUEST_INTR_STATUS_SVI_OFFSET ;__vmwrite (GUEST_INTR_STATUS , status); } + +/* +* Theoretically, only level triggered interrupts can have their +* corresponding bits set in the eoi exit bitmap. That is, the bits +* set in the eoi exit bitmap should also be set in TMR. But a periodic +* timer interrupt does not follow the rule: it is edge triggered, but +* requires its corresponding bit be set in the eoi exit bitmap. So we +* should not construct the eoi exit bitmap based on TMR. +* Here we will construct the eoi exit bitmap via (IRR | ISR). This +* means that EOIs to the interrupts that are set in the IRR or ISR will +* cause VM exits after restoring, regardless of the trigger modes. It +* is acceptable because the subsequent interrupts will set up the eoi +* bitmap correctly. +*/ +for ( vector =0x10 ; vector <NR_VECTORS ; vector++ ) +if (vlapic_test_vector (vector, &vlapic->regs->data[APIC_IRR ]) || +vlapic_test_vector (vector, &vlapic->regs->data[APIC_ISR ]) ) +set_bit (vector, v->arch.hvm_vmx.eoi_exit_bitmap); + +for ( i =0 ; i <4 ; i++ ) +__vmwrite (EOI_EXIT_BITMAP (i), v->arch.hvm_vmx.eoi_exit_bitmap[i]); +vmx_vmcs_exit (v); }
xen/include/asm-x86/hvm/vlapic.h +2 -0
@@ -61,6 +61,8 @@#define VEC_POS (v) ((v) % 32)#define REG_POS (v) (((v) / 32) * 0x10) +#define vlapic_test_vector (vec, bitmap) \ + test_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))#define vlapic_test_and_set_vector (vec, bitmap) \ test_and_set_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))#define vlapic_test_and_clear_vector (vec, bitmap) \
Signature · 1 line
1.7.6.3
xen/arch/x86/hvm/vmx/vmx.c static void vmx_process_isr(int isr, struct vcpu *v) · line 1587
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 21.10.14 at 07:32, <[email protected]> wrote:
xen/arch/x86/hvm/vmx/vmx.c +1
-0@@ -1584,6 +1584,8 @@ static void vmx_process_isr(int isr, struct vcpu *v) {unsigned long status;u8 old; +unsigned int i, vector;
I don't really see the need for two variables here - just "i" would seem to suffice.
xen/arch/x86/hvm/vmx/vmx.c static void vmx_process_isr(int isr, struct vcpu *v) · line 1588
Quoted 1 line
xen/arch/x86/hvm/vmx/vmx.c +1
-0+struct vlapic *vlapic =vcpu_vlapic (v);
const?
Quoted 14 lines
xen/arch/x86/hvm/vmx/vmx.c +10
-0@@ -1597,6 +1599,28 @@ static void vmx_process_isr(int isr, struct vcpu *v) status |= isr <<VMX_GUEST_INTR_STATUS_SVI_OFFSET ;__vmwrite (GUEST_INTR_STATUS , status); } + +/* +* Theoretically, only level triggered interrupts can have their +* corresponding bits set in the eoi exit bitmap. That is, the bits +* set in the eoi exit bitmap should also be set in TMR. But a periodic +* timer interrupt does not follow the rule: it is edge triggered, but +* requires its corresponding bit be set in the eoi exit bitmap. So we +* should not construct the eoi exit bitmap based on TMR. +* Here we will construct the eoi exit bitmap via (IRR | ISR). This +* means that EOIs to the interrupts that are set in the IRR or ISR will
xen/arch/x86/hvm/vmx/vmx.c static void vmx_process_isr(int isr, struct vcpu *v) · line 1621
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +10
-0+* cause VM exits after restoring, regardless of the trigger modes. It +* is acceptable because the subsequent interrupts will set up the eoi +* bitmap correctly. +*/ +for ( vector =0x10 ; vector <NR_VECTORS ; vector++ ) +if (vlapic_test_vector (vector, &vlapic->regs->data[APIC_IRR ]) || +vlapic_test_vector (vector, &vlapic->regs->data[APIC_ISR ]) ) +set_bit (vector, v->arch.hvm_vmx.eoi_exit_bitmap); + +for ( i =0 ; i <4 ; i++ )
ARRAY_SIZE(v->arch.hvm_vmx.eoi_exit_bitmap) instead of 4 please, like already done in construct_vmcs().
xen/include/asm-x86/hvm/vlapic.h line 65
Quoted 13 lines
xen/arch/x86/hvm/vmx/vmx.c +2
-0+__vmwrite (EOI_EXIT_BITMAP (i), v->arch.hvm_vmx.eoi_exit_bitmap[i]); +vmx_vmcs_exit (v); }xen/include/asm-x86/hvm/vlapic.h +2
-0@@ -61,6 +61,8 @@#define VEC_POS (v) ((v) % 32)#define REG_POS (v) (((v) / 32) * 0x10) +#define vlapic_test_vector (vec, bitmap) \ + test_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))
Don't cast away possible const-ness here.
But of course if there are no other needs to change the patch I could take care of all of these while committing.
Jan
Quoted 14 lines · Yang Zhang
From: Yang Zhang <[email protected]>
This patch fixes two issues:
1. Interrupts on PIR are lost during save/restore. Syncing the PIR into IRR during save will fix it.
2. EOI exit bitmap doesn't set up correctly after restore. Here we will construct the eoi exit bitmap via (IRR | ISR). Though it may cause unnecessary eoi exit of the interrupts that pending in IRR or ISR during save/restore, each pending interrupt only causes one vmexit. The subsequent interrupts will adjust the eoi exit bitmap correctly. So the performance hurt can be ignored.
Quoted 4 lines
Signed-off-by Yang Zhang <[email protected]>Signed-off-by Olaf Hering <[email protected]>---
Hi Olaf and Malcolm, please help to retest this version.
Yes, this works as well. Thanks!
Olaf
Jan Beulich wrote on 2014-10-21:
Quoted 63 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 21.10.14 at 07:32, <[email protected]> wrote:
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1584,6 +1584,8 @@ static void vmx_process_isr(int isr, structvcpu
*v) { unsigned long status; u8 old;+ unsigned int i, vector;
I don't really see the need for two variables here - just "i" would seem to suffice.
Quoted 1 line
+ struct vlapic *vlapic =
vcpu_vlapic(v);const?
Quoted 2 lines
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1597,6 +1599,28 @@ static void vmx_process_isr(int isr, structvcpu
*v)
Quoted 13 lines
status |= isr << VMX_GUEST_INTR_STATUS_SVI_OFFSET; __vmwrite(GUEST_INTR_STATUS, status); }xen/arch/x86/hvm/vmx/vmx.c +10
-0+ +/* +* Theoretically, only level triggered interrupts can have their +* corresponding bits set in the eoi exit bitmap. That is, the bits +* set in the eoi exit bitmap should also be set in TMR. But a periodic +* timer interrupt does not follow the rule: it is edge triggered, but +* requires its corresponding bit be set in the eoi exit bitmap. So we +* should not construct the eoi exit bitmap based on TMR. +* Here we will construct the eoi exit bitmap via (IRR | ISR). This +* means that EOIs to the interrupts that are set in the IRR or ISR will xen/arch/x86/hvm/vmx/vmx.c static void vmx_process_isr(int isr, struct vcpu *v) · line 1621
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +10
-0+* cause VM exits after restoring, regardless of the trigger modes. It +* is acceptable because the subsequent interrupts will set up the eoi +* bitmap correctly. +*/ +for ( vector =0x10 ; vector <NR_VECTORS ; vector++ ) +if (vlapic_test_vector (vector, &vlapic->regs->data[APIC_IRR ]) || +vlapic_test_vector (vector, &vlapic->regs->data[APIC_ISR ]) ) +set_bit (vector, v->arch.hvm_vmx.eoi_exit_bitmap); + +for ( i =0 ; i <4 ; i++ )
ARRAY_SIZE(v->arch.hvm_vmx.eoi_exit_bitmap)instead of 4 please, like already done inconstruct_vmcs().xen/include/asm-x86/hvm/vlapic.h line 65
Quoted 13 lines
xen/arch/x86/hvm/vmx/vmx.c +3
-0+__vmwrite (EOI_EXIT_BITMAP (i), + v->arch.hvm_vmx.eoi_exit_bitmap[i]); +vmx_vmcs_exit (v); }xen/include/asm-x86/hvm/vlapic.h +1
-0@@ -61,6 +61,8 @@#define VEC_POS (v) ((v) % 32)#define REG_POS (v) (((v) / 32) * 0x10) +#define vlapic_test_vector (vec, bitmap) \ + test_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))Don't cast away possible const-ness here.
Quoted 2 lines
But of course if there are no other needs to change the patch I could take care of all of these while committing.
It appears no other comments. Should I send out the v3 or you will help to commit it with modifications?
Best regards,
Yang
Quoted 66 lines
Quoted 1 line
Quoted 1 line · On 24.10.14 at 04:00, <[email protected]> wrote:
Jan Beulich wrote on 2014-10-21:
Quoted 13 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 21.10.14 at 07:32, <[email protected]> wrote:
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1584,6 +1584,8 @@ static void vmx_process_isr(int isr, structvcpu
*v) { unsigned long status; u8 old;+ unsigned int i, vector;
I don't really see the need for two variables here - just "i" would seem to suffice.
Quoted 20 lines
Quoted 1 line
+ struct vlapic *vlapic =
vcpu_vlapic(v);const?
Quoted 2 lines
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1597,6 +1599,28 @@ static void vmx_process_isr(int isr, structvcpu
*v)
Quoted 13 lines
status |= isr << VMX_GUEST_INTR_STATUS_SVI_OFFSET; __vmwrite(GUEST_INTR_STATUS, status); }xen/arch/x86/hvm/vmx/vmx.c +10
-0+ +/* +* Theoretically, only level triggered interrupts can have their +* corresponding bits set in the eoi exit bitmap. That is, the bits +* set in the eoi exit bitmap should also be set in TMR. But a periodic +* timer interrupt does not follow the rule: it is edge triggered, but +* requires its corresponding bit be set in the eoi exit bitmap. So we +* should not construct the eoi exit bitmap based on TMR. +* Here we will construct the eoi exit bitmap via (IRR | ISR). This +* means that EOIs to the interrupts that are set in the IRR or ISR will
Quoted 30 lines
xen/arch/x86/hvm/vmx/vmx.c static void vmx_process_isr(int isr, struct vcpu *v) · line 1621
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +10
-0+* cause VM exits after restoring, regardless of the trigger modes. It +* is acceptable because the subsequent interrupts will set up the eoi +* bitmap correctly. +*/ +for ( vector =0x10 ; vector <NR_VECTORS ; vector++ ) +if (vlapic_test_vector (vector, &vlapic->regs->data[APIC_IRR ]) || +vlapic_test_vector (vector, &vlapic->regs->data[APIC_ISR ]) ) +set_bit (vector, v->arch.hvm_vmx.eoi_exit_bitmap); + +for ( i =0 ; i <4 ; i++ )
ARRAY_SIZE(v->arch.hvm_vmx.eoi_exit_bitmap)instead of 4 please, like already done inconstruct_vmcs().xen/include/asm-x86/hvm/vlapic.h line 65
Quoted 13 lines
xen/arch/x86/hvm/vmx/vmx.c +3
-0+__vmwrite (EOI_EXIT_BITMAP (i), + v->arch.hvm_vmx.eoi_exit_bitmap[i]); +vmx_vmcs_exit (v); }xen/include/asm-x86/hvm/vlapic.h +1
-0@@ -61,6 +61,8 @@#define VEC_POS (v) ((v) % 32)#define REG_POS (v) (((v) / 32) * 0x10) +#define vlapic_test_vector (vec, bitmap) \ + test_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))Don't cast away possible const-ness here.
Quoted 5 lines
Quoted 2 lines
But of course if there are no other needs to change the patch I could take care of all of these while committing.
It appears no other comments. Should I send out the v3 or you will help to commit it with modifications?
As said above - I'm fine doing those minor adjustments, but I certainly would like to wait for Citrix folks' confirmation. This has been taking so long that I don't think waiting a few more days really matters.
Jan
Jan Beulich wrote on 2014-10-24:
Quoted 65 lines
Quoted 65 lines
Quoted 1 line
Quoted 1 line · On 24.10.14 at 04:00, <[email protected]> wrote:
Jan Beulich wrote on 2014-10-21:
Quoted 62 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 21.10.14 at 07:32, <[email protected]> wrote:
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1584,6 +1584,8 @@ static void vmx_process_isr(int isr, structvcpu
*v) { unsigned long status; u8 old;+ unsigned int i, vector;
I don't really see the need for two variables here - just "i" would seem to suffice.
Quoted 1 line
+ struct vlapic *vlapic =
vcpu_vlapic(v);const?
Quoted 2 lines
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1597,6 +1599,28 @@ static void vmx_process_isr(int isr, structvcpu
*v)
Quoted 17 lines
status |= isr << VMX_GUEST_INTR_STATUS_SVI_OFFSET; __vmwrite(GUEST_INTR_STATUS, status); }+ + /* + * Theoretically, only level triggered interrupts can
have their + * corresponding bits set in the eoi exit bitmap.
That is, the bits + * set in the eoi exit bitmap should also be
set in TMR. But a periodic + * timer interrupt does not follow
the rule: it is edge triggered, but + * requires its
corresponding bit be set in the eoi exit bitmap. So we + * should
not construct the eoi exit bitmap based on TMR. + * Here we will
construct the eoi exit bitmap via (IRR | ISR). This + * means
that EOIs to the interrupts that are set in the IRR + or ISR will +
* cause VM exits after restoring, regardless of the trigger modes.
It + * is acceptable because the subsequent interrupts will set +
up the eoi + * bitmap correctly. + */ + for ( vector =0x10; vector <NR_VECTORS; vector++ ) + if (vlapic_test_vector(vector, + &vlapic->regs->data[APIC_IRR])|| +Quoted 3 lines
vlapic_test_vector(vector, &vlapic->regs->data[APIC_ISR]) ) + set_bit(vector, v->arch.hvm_vmx.eoi_exit_bitmap); + +for ( i = 0; i < 4; i++ )
ARRAY_SIZE(v->arch.hvm_vmx.eoi_exit_bitmap)instead of 4 please, like already done inconstruct_vmcs().xen/include/asm-x86/hvm/vlapic.h line 65
Quoted 13 lines
xen/arch/x86/hvm/vmx/vmx.c +3
-0+__vmwrite (EOI_EXIT_BITMAP (i), + v->arch.hvm_vmx.eoi_exit_bitmap[i]); +vmx_vmcs_exit (v); }xen/include/asm-x86/hvm/vlapic.h +1
-0@@ -61,6 +61,8 @@#define VEC_POS (v) ((v) % 32)#define REG_POS (v) (((v) / 32) * 0x10) +#define vlapic_test_vector (vec, bitmap) \ + test_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))Don't cast away possible const-ness here.
But of course if there are no other needs to change the patch I could take care of all of these while committing.
Quoted 6 lines
Quoted 2 lines
It appears no other comments. Should I send out the v3 or you will help to commit it with modifications?
As said above - I'm fine doing those minor adjustments, but I certainly would like to wait for Citrix folks' confirmation. This has been taking so long that I don't think waiting a few more days really matters.
I want to catch the first RC release since we will perform a full testing with first RC. But it is ok now since the first RC already released.
Quoted 2 lines
Jan
Best regards,
Yang
Quoted 59 lines · Yang Z
Jan Beulich wrote on 2014-10-24:
Quoted 58 lines
Quoted 58 lines
Quoted 1 line
Quoted 1 line · On 24.10.14 at 04:00, <[email protected]> wrote:
Jan Beulich wrote on 2014-10-21:
Quoted 56 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 21.10.14 at 07:32, <[email protected]> wrote:
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1584,6 +1584,8 @@ static void vmx_process_isr(int isr, structvcpu
*v) { unsigned long status; u8 old;+ unsigned int i, vector;
I don't really see the need for two variables here - just "i" would seem to suffice.
Quoted 1 line
+ struct vlapic *vlapic =
vcpu_vlapic(v);const?
Quoted 2 lines
xen/arch/x86/hvm/vmx/vmx.c +0
-0@@ -1597,6 +1599,28 @@ static void vmx_process_isr(int isr, structvcpu
*v)
Quoted 17 lines
status |= isr << VMX_GUEST_INTR_STATUS_SVI_OFFSET; __vmwrite(GUEST_INTR_STATUS, status); }+ + /* + * Theoretically, only level triggered interrupts can
have their + * corresponding bits set in the eoi exit bitmap.
That is, the bits + * set in the eoi exit bitmap should also be
set in TMR. But a periodic + * timer interrupt does not follow
the rule: it is edge triggered, but + * requires its
corresponding bit be set in the eoi exit bitmap. So we + * should
not construct the eoi exit bitmap based on TMR. + * Here we will
construct the eoi exit bitmap via (IRR | ISR). This + * means
that EOIs to the interrupts that are set in the IRR + or ISR will +
* cause VM exits after restoring, regardless of the trigger modes.
It + * is acceptable because the subsequent interrupts will set +
up the eoi + * bitmap correctly. + */ + for ( vector =0x10; vector <NR_VECTORS; vector++ ) + if (vlapic_test_vector(vector, + &vlapic->regs->data[APIC_IRR])|| +Quoted 3 lines
vlapic_test_vector(vector, &vlapic->regs->data[APIC_ISR]) ) + set_bit(vector, v->arch.hvm_vmx.eoi_exit_bitmap); + +for ( i = 0; i < 4; i++ )
ARRAY_SIZE(v->arch.hvm_vmx.eoi_exit_bitmap)instead of 4 please, like already done inconstruct_vmcs().xen/include/asm-x86/hvm/vlapic.h line 65
Quoted 13 lines
xen/arch/x86/hvm/vmx/vmx.c +3
-0+__vmwrite (EOI_EXIT_BITMAP (i), + v->arch.hvm_vmx.eoi_exit_bitmap[i]); +vmx_vmcs_exit (v); }xen/include/asm-x86/hvm/vlapic.h +1
-0@@ -61,6 +61,8 @@#define VEC_POS (v) ((v) % 32)#define REG_POS (v) (((v) / 32) * 0x10) +#define vlapic_test_vector (vec, bitmap) \ + test_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))Don't cast away possible const-ness here.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
But of course if there are no other needs to change the patch I could take care of all of these while committing.
It appears no other comments. Should I send out the v3 or you will help to commit it with modifications?
As said above - I'm fine doing those minor adjustments, but I certainly would like to wait for Citrix folks' confirmation. This has been taking so long that I don't think waiting a few more days really matters.
I want to catch the first RC release since we will perform a full testing with first RC. But it is ok now since the first RC already released.
With the changes Jan wants, Reviewed-by: Andrew Cooper <[email protected]>
We don't have much time for out-of-band testing at the moment, but I will test it specifically as part of our 4.5-rc$N testing. The patch does look functionally very similar to the previous version which we positively confirmed as fixing our observed issues.
~Andrew
Quoted 17 lines
From: Zhang, Yang Z
Sent: Tuesday, October 21, 2014 1:33 PMFrom: Yang Zhang <[email protected]>
This patch fixes two issues:
1. Interrupts on PIR are lost during save/restore. Syncing the PIR into IRR during save will fix it.
2. EOI exit bitmap doesn't set up correctly after restore. Here we will construct the eoi exit bitmap via (IRR | ISR). Though it may cause unnecessary eoi exit of the interrupts that pending in IRR or ISR during save/restore, each pending interrupt only causes one vmexit. The subsequent interrupts will adjust the eoi exit bitmap correctly. So the performance hurt can be ignored.
Quoted 2 lines
Signed-off-by Yang Zhang <[email protected]>Signed-off-by Olaf Hering <[email protected]>
Quoted 86 lines
---
Hi Olaf and Malcolm, please help to retest this version.xen/arch/x86/hvm/vlapic.c | 3 +++ xen/arch/x86/hvm/vmx/vmx.c | 24 ++++++++++++++++++++++++ xen/include/asm-x86/hvm/vlapic.h | 2 ++ 3 files changed, 29 insertions(+), 0 deletions(-)xen/arch/x86/hvm/vlapic.c +3
-0@@ -1293,6 +1293,9 @@ static int lapic_save_regs(struct domain *d, hvm_domain_context_t *h)for_each_vcpu (d ,v ) { +if ( hvm_funcs.sync_pir_to_irr ) + hvm_funcs.sync_pir_to_irr (v); + s =vcpu_vlapic (v); if ( (rc = hvm_save_entry(LAPIC_REGS, v->vcpu_id, h, s->regs)) !=0 )
break;xen/arch/x86/hvm/vmx/vmx.c +24
-0@@ -1584,6 +1584,8 @@ static void vmx_process_isr(int isr, struct vcpu *v) {unsigned long status;u8 old; +unsigned int i, vector; +struct vlapic *vlapic =vcpu_vlapic (v);if ( isr <0 ) isr =0 ;@@ -1597,6 +1599,28 @@ static void vmx_process_isr(int isr, struct vcpu *v) status |= isr <<VMX_GUEST_INTR_STATUS_SVI_OFFSET ;__vmwrite (GUEST_INTR_STATUS , status); } + +/* +* Theoretically, only level triggered interrupts can have their +* corresponding bits set in the eoi exit bitmap. That is, the bits +* set in the eoi exit bitmap should also be set in TMR. But a periodic +* timer interrupt does not follow the rule: it is edge triggered, but +* requires its corresponding bit be set in the eoi exit bitmap. So we +* should not construct the eoi exit bitmap based on TMR. +* Here we will construct the eoi exit bitmap via (IRR | ISR). This +* means that EOIs to the interrupts that are set in the IRR or ISR will +* cause VM exits after restoring, regardless of the trigger modes. It +* is acceptable because the subsequent interrupts will set up the eoi +* bitmap correctly. +*/ +for ( vector =0x10 ; vector <NR_VECTORS ; vector++ ) +if (vlapic_test_vector (vector, &vlapic->regs->data[APIC_IRR ]) || +vlapic_test_vector (vector, &vlapic->regs->data[APIC_ISR ]) ) +set_bit (vector, v->arch.hvm_vmx.eoi_exit_bitmap); + +for ( i =0 ; i <4 ; i++ ) +__vmwrite (EOI_EXIT_BITMAP (i), v->arch.hvm_vmx.eoi_exit_bitmap[i]); +vmx_vmcs_exit (v); }xen/include/asm-x86/hvm/vlapic.h +2
-0@@ -61,6 +61,8 @@#define VEC_POS (v) ((v) % 32)#define REG_POS (v) (((v) / 32) * 0x10) +#define vlapic_test_vector (vec, bitmap) \ + test_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))#define vlapic_test_and_set_vector (vec, bitmap) \test_and_set_bit(VEC_POS(vec), (uint32_t *)((bitmap) + REG_POS(vec)))#define
vlapic_test_and_clear_vector(vec, bitmap)
\
--
1.7.6.3