public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Fix APIC map calculation after re-enabling
@ 2013-12-29  1:29 Jan Kiszka
  2013-12-30 20:59 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2013-12-29  1:29 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, Marcelo Tosatti; +Cc: kvm

From: Jan Kiszka <jan.kiszka@siemens.com>

Update arch.apic_base before triggering recalculate_apic_map. Otherwise
the recalculation will work against the previous state of the APIC and
will fail to build the correct map when an APIC is hardware-enabled
again.

This fixes a regression of 1e08ec4a13.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

Stable material.

 arch/x86/kvm/lapic.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 5439117..ab58ea4 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1346,6 +1346,10 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
 		return;
 	}
 
+	if (!kvm_vcpu_is_bsp(apic->vcpu))
+		value &= ~MSR_IA32_APICBASE_BSP;
+	vcpu->arch.apic_base = value;
+
 	/* update jump label if enable bit changes */
 	if ((vcpu->arch.apic_base ^ value) & MSR_IA32_APICBASE_ENABLE) {
 		if (value & MSR_IA32_APICBASE_ENABLE)
@@ -1355,10 +1359,6 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
 		recalculate_apic_map(vcpu->kvm);
 	}
 
-	if (!kvm_vcpu_is_bsp(apic->vcpu))
-		value &= ~MSR_IA32_APICBASE_BSP;
-
-	vcpu->arch.apic_base = value;
 	if ((old_value ^ value) & X2APIC_ENABLE) {
 		if (value & X2APIC_ENABLE) {
 			u32 id = kvm_apic_id(apic);
-- 
1.8.1.1.298.ge7eed54

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: x86: Fix APIC map calculation after re-enabling
  2013-12-29  1:29 [PATCH] KVM: x86: Fix APIC map calculation after re-enabling Jan Kiszka
@ 2013-12-30 20:59 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2013-12-30 20:59 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Gleb Natapov, Paolo Bonzini, kvm

On Sun, Dec 29, 2013 at 02:29:30AM +0100, Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Update arch.apic_base before triggering recalculate_apic_map. Otherwise
> the recalculation will work against the previous state of the APIC and
> will fail to build the correct map when an APIC is hardware-enabled
> again.
> 
> This fixes a regression of 1e08ec4a13.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Stable material.
> 
>  arch/x86/kvm/lapic.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 5439117..ab58ea4 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1346,6 +1346,10 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
>  		return;
>  	}
>  
> +	if (!kvm_vcpu_is_bsp(apic->vcpu))
> +		value &= ~MSR_IA32_APICBASE_BSP;
> +	vcpu->arch.apic_base = value;
> +
>  	/* update jump label if enable bit changes */
>  	if ((vcpu->arch.apic_base ^ value) & MSR_IA32_APICBASE_ENABLE) {
>  		if (value & MSR_IA32_APICBASE_ENABLE)
> @@ -1355,10 +1359,6 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
>  		recalculate_apic_map(vcpu->kvm);
>  	}
>  
> -	if (!kvm_vcpu_is_bsp(apic->vcpu))
> -		value &= ~MSR_IA32_APICBASE_BSP;
> -
> -	vcpu->arch.apic_base = value;
>  	if ((old_value ^ value) & X2APIC_ENABLE) {
>  		if (value & X2APIC_ENABLE) {
>  			u32 id = kvm_apic_id(apic);
> -- 

Applied to master branch, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-30 20:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-29  1:29 [PATCH] KVM: x86: Fix APIC map calculation after re-enabling Jan Kiszka
2013-12-30 20:59 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox