* [PATCH] KVM: nVMX: Fix host crash when loading MSRs with userspace irqchip
@ 2015-05-04 6:32 Jan Kiszka
2015-05-07 9:31 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2015-05-04 6:32 UTC (permalink / raw)
To: Paolo Bonzini, kvm; +Cc: Eugene Korenevsky
vcpu->arch.apic is NULL when a userspace irqchip is active. But instead
of letting the test incorrectly depend on in-kernel irqchip mode,
open-code it to catch also userspace x2APICs.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
Affects kernels since 3.19.
arch/x86/kvm/vmx.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index f7b6168..0ef4f96 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2170,8 +2170,7 @@ static void vmx_set_msr_bitmap(struct kvm_vcpu *vcpu)
if (is_guest_mode(vcpu))
msr_bitmap = vmx_msr_bitmap_nested;
- else if (irqchip_in_kernel(vcpu->kvm) &&
- apic_x2apic_mode(vcpu->arch.apic)) {
+ else if (vcpu->arch.apic_base & X2APIC_ENABLE) {
if (is_long_mode(vcpu))
msr_bitmap = vmx_msr_bitmap_longmode_x2apic;
else
@@ -8924,7 +8923,7 @@ static int nested_vmx_msr_check_common(struct kvm_vcpu *vcpu,
struct vmx_msr_entry *e)
{
/* x2APIC MSR accesses are not allowed */
- if (apic_x2apic_mode(vcpu->arch.apic) && e->index >> 8 == 0x8)
+ if (vcpu->arch.apic_base & X2APIC_ENABLE && e->index >> 8 == 0x8)
return -EINVAL;
if (e->index == MSR_IA32_UCODE_WRITE || /* SDM Table 35-2 */
e->index == MSR_IA32_UCODE_REV)
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: nVMX: Fix host crash when loading MSRs with userspace irqchip
2015-05-04 6:32 [PATCH] KVM: nVMX: Fix host crash when loading MSRs with userspace irqchip Jan Kiszka
@ 2015-05-07 9:31 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2015-05-07 9:31 UTC (permalink / raw)
To: Jan Kiszka, kvm; +Cc: Eugene Korenevsky
On 04/05/2015 08:32, Jan Kiszka wrote:
> vcpu->arch.apic is NULL when a userspace irqchip is active. But instead
> of letting the test incorrectly depend on in-kernel irqchip mode,
> open-code it to catch also userspace x2APICs.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> Affects kernels since 3.19.
>
> arch/x86/kvm/vmx.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index f7b6168..0ef4f96 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2170,8 +2170,7 @@ static void vmx_set_msr_bitmap(struct kvm_vcpu *vcpu)
>
> if (is_guest_mode(vcpu))
> msr_bitmap = vmx_msr_bitmap_nested;
> - else if (irqchip_in_kernel(vcpu->kvm) &&
> - apic_x2apic_mode(vcpu->arch.apic)) {
> + else if (vcpu->arch.apic_base & X2APIC_ENABLE) {
> if (is_long_mode(vcpu))
> msr_bitmap = vmx_msr_bitmap_longmode_x2apic;
> else
> @@ -8924,7 +8923,7 @@ static int nested_vmx_msr_check_common(struct kvm_vcpu *vcpu,
> struct vmx_msr_entry *e)
> {
> /* x2APIC MSR accesses are not allowed */
> - if (apic_x2apic_mode(vcpu->arch.apic) && e->index >> 8 == 0x8)
> + if (vcpu->arch.apic_base & X2APIC_ENABLE && e->index >> 8 == 0x8)
> return -EINVAL;
> if (e->index == MSR_IA32_UCODE_WRITE || /* SDM Table 35-2 */
> e->index == MSR_IA32_UCODE_REV)
>
Applied, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-07 9:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-04 6:32 [PATCH] KVM: nVMX: Fix host crash when loading MSRs with userspace irqchip Jan Kiszka
2015-05-07 9:31 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.