Re: [PATCH] x86/smp: Add irq_enter/exit() in smp_reschedule_interrupt()
From: Wanpeng Li
Date: Mon Oct 17 2016 - 20:02:18 EST
2016-10-17 18:08 GMT+08:00 Paolo Bonzini <pbonzini@xxxxxxxxxx>:
[...]
>> > Something like the below avoids all that. Paravirt will still need fixing.
>>
>> kvm_guest_apic_eoi_write
>> -> native_apic_msr_write
>
> kvm_guest_apic_eoi_write can use native_apic_msr_eoi_write too:
>
> diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
> index f5aaf6c83222..9769d76a62c4 100644
> --- a/arch/x86/include/asm/apic.h
> +++ b/arch/x86/include/asm/apic.h
> @@ -174,7 +174,7 @@ static inline void disable_local_APIC(void) { }
> static inline void lapic_update_tsc_freq(void) { }
> #endif /* !CONFIG_X86_LOCAL_APIC */
>
> -#ifdef CONFIG_X86_X2APIC
> +#if defined CONFIG_X86_X2APIC || defined CONFIG_KVM_GUEST
If CONFIG_X86_X2APIC is undefined and CONFIG_KVM_GUEST is defined,
there are undefined reference warning for x2apic_mode and check_x2apic
etc since they are extern variables and just define under
CONFIG_X86_X2APIC.
> /*
> * Make previous memory operations globally visible before
> * sending the IPI through x2apic wrmsr. We need a serializing instruction or
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index edbbfc854e39..61cc6a5e3f44 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -319,7 +319,7 @@ static void kvm_guest_apic_eoi_write(u32 reg, u32 val)
> */
> if (__test_and_clear_bit(KVM_PV_EOI_BIT, this_cpu_ptr(&kvm_apic_eoi)))
> return;
> - apic_write(APIC_EOI, APIC_EOI_ACK);
> + native_apic_msr_eoi_write(APIC_EOI, APIC_EOI_ACK);
> }
If -cpu host,-x2apic we should go through mmio when writes xapic EOI.
Regards,
Wanpeng Li