[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH] VMX: convert EOI exit bitmap to a proper bitmap
... allowing bitmap operations to be used on it, making things consistent with struct pi_desc's pir field, and shrinking overall source code size. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- a/xen/arch/x86/hvm/vmx/intr.c +++ b/xen/arch/x86/hvm/vmx/intr.c @@ -280,6 +280,7 @@ void vmx_intr_assist(void) intack.source != hvm_intsrc_vector ) { unsigned long status = __vmread(GUEST_INTR_STATUS); + unsigned int i, n; /* * Set eoi_exit_bitmap for periodic timer interrup to cause EOI-induced VM @@ -294,14 +295,13 @@ void vmx_intr_assist(void) status |= VMX_GUEST_INTR_STATUS_SUBFIELD_BITMASK & intack.vector; __vmwrite(GUEST_INTR_STATUS, status); - if (v->arch.hvm_vmx.eoi_exitmap_changed) { -#define UPDATE_EOI_EXITMAP(v, e) { \ - if (test_and_clear_bit(e, &v->arch.hvm_vmx.eoi_exitmap_changed)) { \ - __vmwrite(EOI_EXIT_BITMAP##e, v->arch.hvm_vmx.eoi_exit_bitmap[e]);}} - UPDATE_EOI_EXITMAP(v, 0); - UPDATE_EOI_EXITMAP(v, 1); - UPDATE_EOI_EXITMAP(v, 2); - UPDATE_EOI_EXITMAP(v, 3); + + n = ARRAY_SIZE(v->arch.hvm_vmx.eoi_exit_bitmap); + while ( (i = find_first_bit(&v->arch.hvm_vmx.eoi_exitmap_changed, + n)) < n ) + { + clear_bit(i, &v->arch.hvm_vmx.eoi_exitmap_changed); + __vmwrite(EOI_EXIT_BITMAP(i), v->arch.hvm_vmx.eoi_exit_bitmap[i]); } pt_intr_post(v, intack); --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -915,15 +915,12 @@ static int construct_vmcs(struct vcpu *v if ( cpu_has_vmx_virtual_intr_delivery ) { + unsigned int i; + /* EOI-exit bitmap */ - v->arch.hvm_vmx.eoi_exit_bitmap[0] = (uint64_t)0; - __vmwrite(EOI_EXIT_BITMAP0, v->arch.hvm_vmx.eoi_exit_bitmap[0]); - v->arch.hvm_vmx.eoi_exit_bitmap[1] = (uint64_t)0; - __vmwrite(EOI_EXIT_BITMAP1, v->arch.hvm_vmx.eoi_exit_bitmap[1]); - v->arch.hvm_vmx.eoi_exit_bitmap[2] = (uint64_t)0; - __vmwrite(EOI_EXIT_BITMAP2, v->arch.hvm_vmx.eoi_exit_bitmap[2]); - v->arch.hvm_vmx.eoi_exit_bitmap[3] = (uint64_t)0; - __vmwrite(EOI_EXIT_BITMAP3, v->arch.hvm_vmx.eoi_exit_bitmap[3]); + bitmap_zero(v->arch.hvm_vmx.eoi_exit_bitmap, NR_VECTORS); + for ( i = 0; i < ARRAY_SIZE(v->arch.hvm_vmx.eoi_exit_bitmap); ++i ) + __vmwrite(EOI_EXIT_BITMAP(i), 0); /* Initialise Guest Interrupt Status (RVI and SVI) to 0 */ __vmwrite(GUEST_INTR_STATUS, 0); @@ -1171,26 +1168,16 @@ int vmx_add_host_load_msr(u32 msr) void vmx_set_eoi_exit_bitmap(struct vcpu *v, u8 vector) { - int index, offset, changed; - - index = vector >> 6; - offset = vector & 63; - changed = !test_and_set_bit(offset, - (uint64_t *)&v->arch.hvm_vmx.eoi_exit_bitmap[index]); - if (changed) - set_bit(index, &v->arch.hvm_vmx.eoi_exitmap_changed); + if ( !test_and_set_bit(vector, v->arch.hvm_vmx.eoi_exit_bitmap) ) + set_bit(vector / BITS_PER_LONG, + &v->arch.hvm_vmx.eoi_exitmap_changed); } void vmx_clear_eoi_exit_bitmap(struct vcpu *v, u8 vector) { - int index, offset, changed; - - index = vector >> 6; - offset = vector & 63; - changed = test_and_clear_bit(offset, - (uint64_t *)&v->arch.hvm_vmx.eoi_exit_bitmap[index]); - if (changed) - set_bit(index, &v->arch.hvm_vmx.eoi_exitmap_changed); + if ( test_and_clear_bit(vector, v->arch.hvm_vmx.eoi_exit_bitmap) ) + set_bit(vector / BITS_PER_LONG, + &v->arch.hvm_vmx.eoi_exitmap_changed); } int vmx_create_vmcs(struct vcpu *v) --- a/xen/include/asm-x86/hvm/vmx/vmcs.h +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h @@ -118,8 +118,8 @@ struct arch_vmx_struct { unsigned int host_msr_count; struct vmx_msr_entry *host_msr_area; - uint32_t eoi_exitmap_changed; - uint64_t eoi_exit_bitmap[4]; + unsigned long eoi_exitmap_changed; + DECLARE_BITMAP(eoi_exit_bitmap, NR_VECTORS); struct pi_desc pi_desc; unsigned long host_cr0; @@ -331,13 +331,7 @@ enum vmcs_field { EPT_POINTER = 0x0000201a, EPT_POINTER_HIGH = 0x0000201b, EOI_EXIT_BITMAP0 = 0x0000201c, - EOI_EXIT_BITMAP0_HIGH = 0x0000201d, - EOI_EXIT_BITMAP1 = 0x0000201e, - EOI_EXIT_BITMAP1_HIGH = 0x0000201f, - EOI_EXIT_BITMAP2 = 0x00002020, - EOI_EXIT_BITMAP2_HIGH = 0x00002021, - EOI_EXIT_BITMAP3 = 0x00002022, - EOI_EXIT_BITMAP3_HIGH = 0x00002023, +#define EOI_EXIT_BITMAP(n) (EOI_EXIT_BITMAP0 + (n) * 2) /* n = 0...3 */ VMREAD_BITMAP = 0x00002026, VMREAD_BITMAP_HIGH = 0x00002027, VMWRITE_BITMAP = 0x00002028, Attachment:
VMX-EOI-exit-bitmap.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |