From: Paolo Bonzini <pbonzini@redhat.com>
To: Nadav Amit <namit@cs.technion.ac.il>, mtosatti@redhat.com
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 5/5] KVM: x86: BSP in MSR_IA32_APICBASE is writable
Date: Mon, 30 Mar 2015 16:12:02 +0200 [thread overview]
Message-ID: <551959B2.10503@redhat.com> (raw)
In-Reply-To: <1427719163-5429-6-git-send-email-namit@cs.technion.ac.il>
On 30/03/2015 14:39, Nadav Amit wrote:
> After reset, the CPU can change the BSP, which will be used upon INIT. Reset
> should return the BSP which QEMU asked for, and therefore handled accordingly.
>
> To quote: "If the MP protocol has completed and a BSP is chosen, subsequent
> INITs (either to a specific processor or system wide) do not cause the MP
> protocol to be repeated."
> [Intel SDM 8.4.2: MP Initialization Protocol Requirements and Restrictions]
>
> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
Please provide a kvm-unit-tests testcase for this.
Paolo
> ---
> arch/x86/kvm/lapic.c | 2 --
> arch/x86/kvm/svm.c | 2 +-
> arch/x86/kvm/vmx.c | 2 +-
> include/linux/kvm_host.h | 7 ++++++-
> 4 files changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 17da6fc..b0dbf68 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1498,8 +1498,6 @@ 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 */
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 1ef4c0d..ef5bf21 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1261,7 +1261,7 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
>
> svm->vcpu.arch.apic_base = APIC_DEFAULT_PHYS_BASE |
> MSR_IA32_APICBASE_ENABLE;
> - if (kvm_vcpu_is_bsp(&svm->vcpu))
> + if (kvm_vcpu_is_reset_bsp(&svm->vcpu))
> svm->vcpu.arch.apic_base |= MSR_IA32_APICBASE_BSP;
>
> svm_init_osvw(&svm->vcpu);
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 8aee6db..7e370b2 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -4709,7 +4709,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
> if (!init_event) {
> apic_base_msr.data = APIC_DEFAULT_PHYS_BASE |
> MSR_IA32_APICBASE_ENABLE;
> - if (kvm_vcpu_is_bsp(&vmx->vcpu))
> + if (kvm_vcpu_is_reset_bsp(&vmx->vcpu))
> apic_base_msr.data |= MSR_IA32_APICBASE_BSP;
> apic_base_msr.host_initiated = true;
> kvm_set_apic_base(&vmx->vcpu, &apic_base_msr);
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 0f574eb..8365cae 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -968,11 +968,16 @@ static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
> #endif /* CONFIG_HAVE_KVM_EVENTFD */
>
> #ifdef CONFIG_KVM_APIC_ARCHITECTURE
> -static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
> +static inline bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu)
> {
> return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id;
> }
>
> +static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
> +{
> + return (vcpu->arch.apic_base & MSR_IA32_APICBASE_BSP) != 0;
> +}
> +
> bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu);
>
> #else
>
next prev parent reply other threads:[~2015-03-30 14:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 12:39 [PATCH 0/5] KVM: x86: 64/32 bit fixes and INIT/BSP fixes Nadav Amit
2015-03-30 12:39 ` [PATCH 1/5] KVM: x86: CMOV emulation on legacy mode is wrong Nadav Amit
2015-03-30 12:39 ` [PATCH 2/5] KVM: x86: POPA emulation may not clear bits [63:32] Nadav Amit
2015-03-30 12:39 ` [PATCH 3/5] KVM: x86: BSF and BSR emulation change register unnecassarily Nadav Amit
2015-03-30 12:39 ` [PATCH 4/5] KVM: x86: INIT and reset sequences are different Nadav Amit
2015-03-30 12:39 ` [PATCH 5/5] KVM: x86: BSP in MSR_IA32_APICBASE is writable Nadav Amit
2015-03-30 14:12 ` Paolo Bonzini [this message]
2015-03-30 14:40 ` Nadav Amit
2015-03-30 14:45 ` Paolo Bonzini
2015-03-30 19:31 ` Nadav Amit
2015-03-30 19:37 ` Paolo Bonzini
2015-03-30 14:46 ` [PATCH 0/5] KVM: x86: 64/32 bit fixes and INIT/BSP fixes Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=551959B2.10503@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=namit@cs.technion.ac.il \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox