On Mon, Jan 07, 2013 at 06:58:15AM +0000, Zhang, Yang Z wrote: > Gleb Natapov wrote on 2013-01-07: > > On Mon, Jan 07, 2013 at 10:02:37AM +0800, Yang Zhang wrote: > >> From: Yang Zhang <yang.z.zhang@xxxxxxxxx> > >> > >> basically to benefit from apicv, we need clear MSR bitmap for > >> corresponding x2apic MSRs when guest enabled x2apic: > >> 0x800 - 0x8ff: no read intercept for apicv register virtualization > >> TPR,EOI,SELF-IPI: no write intercept for virtual interrupt delivery > >> Signed-off-by: Yang Zhang <yang.z.zhang@xxxxxxxxx> > >> Signed-off-by: Kevin Tian <kevin.tian@xxxxxxxxx> > >> --- > >> arch/x86/include/asm/kvm_host.h | 1 + arch/x86/include/asm/vmx.h > >> | 1 + arch/x86/kvm/lapic.c | 2 + arch/x86/kvm/svm.c > >> | 6 +++ arch/x86/kvm/vmx.c | 80 > >> +++++++++++++++++++++++++++++++++++--- 5 files changed, 83 > >> insertions(+), 7 deletions(-) > >> diff --git a/arch/x86/include/asm/kvm_host.h > >> b/arch/x86/include/asm/kvm_host.h index 135603f..af9a8c3 100644 --- > >> a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h > >> @@ -704,6 +704,7 @@ struct kvm_x86_ops { > >> void (*update_exitmap_end)(struct kvm_vcpu *vcpu); void > >> (*load_eoi_exitmap)(struct kvm_vcpu *vcpu); void > >> (*restore_rvi)(struct kvm_vcpu *vcpu); + void > >> (*enable_virtual_x2apic_mode)(struct kvm_vcpu *vcpu); int > >> (*set_tss_addr)(struct kvm *kvm, unsigned int addr); int > >> (*get_tdp_level)(void); u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, > >> gfn_t gfn, bool is_mmio); > >> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h > >> index d1ab331..694586c 100644 > >> --- a/arch/x86/include/asm/vmx.h > >> +++ b/arch/x86/include/asm/vmx.h > >> @@ -140,6 +140,7 @@ > >> #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001 #define > >> SECONDARY_EXEC_ENABLE_EPT 0x00000002 #define > >> SECONDARY_EXEC_RDTSCP 0x00000008 +#define > >> SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE 0x00000010 #define > >> SECONDARY_EXEC_ENABLE_VPID 0x00000020 #define > >> SECONDARY_EXEC_WBINVD_EXITING 0x00000040 #define > >> SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080 > >> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > >> index e1baf37..dba5300 100644 > >> --- a/arch/x86/kvm/lapic.c > >> +++ b/arch/x86/kvm/lapic.c > >> @@ -1349,6 +1349,8 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 > > value) > >> u32 id = kvm_apic_id(apic); > >> u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf)); > >> kvm_apic_set_ldr(apic, ldr); > >> + kvm_x86_ops->enable_virtual_x2apic_mode(vcpu); > > And where do you disable it? > Yes, need to disable it when guest rolls back to xapic mode. Will add it in next patch. > You also need to reorder patches 2 and 3. Otherwise x2apic will be broken after patch 2. -- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html