public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] KVM: x86: Rework INIT and SIPI handling
Date: Wed, 13 Mar 2013 14:22:16 +0200	[thread overview]
Message-ID: <20130313122216.GA2127@redhat.com> (raw)
In-Reply-To: <51406E6E.30801@siemens.com>

On Wed, Mar 13, 2013 at 01:17:50PM +0100, Jan Kiszka wrote:
> >>>> -             svm->vmcb->save.cs.base = svm->vcpu.arch.sipi_vector << 12;
> >>>> -             svm->vmcb->save.cs.selector = svm->vcpu.arch.sipi_vector << 8;
> >>>> -     }
> >>>>
> >>>>       kvm_cpuid(vcpu, &eax, &dummy, &dummy, &dummy);
> >>>>       kvm_register_write(vcpu, VCPU_REGS_RDX, eax);
> >>>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> >>>> index f17cd2a..5b862ed 100644
> >>>> --- a/arch/x86/kvm/vmx.c
> >>>> +++ b/arch/x86/kvm/vmx.c
> >>>> @@ -4121,10 +4121,6 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu)
> >>>>       seg_setup(VCPU_SREG_CS);
> >>>>       if (kvm_vcpu_is_bsp(&vmx->vcpu))
> >>>>               vmcs_write16(GUEST_CS_SELECTOR, 0xf000);
> >>>> -     else {
> >>>> -             vmcs_write16(GUEST_CS_SELECTOR, vmx->vcpu.arch.sipi_vector << 8);
> >>>> -             vmcs_writel(GUEST_CS_BASE, vmx->vcpu.arch.sipi_vector << 12);
> >>>> -     }
> >>>>
> >>>>       seg_setup(VCPU_SREG_DS);
> >>>>       seg_setup(VCPU_SREG_ES);
> >>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> >>>> index b891ac3..37c0807 100644
> >>>> --- a/arch/x86/kvm/x86.c
> >>>> +++ b/arch/x86/kvm/x86.c
> >>>> @@ -162,8 +162,6 @@ u64 __read_mostly host_xcr0;
> >>>>
> >>>>  static int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt);
> >>>>
> >>>> -static void kvm_vcpu_reset(struct kvm_vcpu *vcpu);
> >>>> -
> >>>>  static inline void kvm_async_pf_hash_reset(struct kvm_vcpu *vcpu)
> >>>>  {
> >>>>       int i;
> >>>> @@ -2823,10 +2821,9 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
> >>>>       events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu);
> >>>>       events->nmi.pad = 0;
> >>>>
> >>>> -     events->sipi_vector = vcpu->arch.sipi_vector;
> >>>> +     events->sipi_vector = 0; /* never valid when reporting to user space */
> >>>>
> >>>>       events->flags = (KVM_VCPUEVENT_VALID_NMI_PENDING
> >>>> -                      | KVM_VCPUEVENT_VALID_SIPI_VECTOR
> >>>>                        | KVM_VCPUEVENT_VALID_SHADOW);
> >>>>       memset(&events->reserved, 0, sizeof(events->reserved));
> >>>>  }
> >>>> @@ -2857,8 +2854,9 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
> >>>>               vcpu->arch.nmi_pending = events->nmi.pending;
> >>>>       kvm_x86_ops->set_nmi_mask(vcpu, events->nmi.masked);
> >>>>
> >>>> -     if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR)
> >>>> -             vcpu->arch.sipi_vector = events->sipi_vector;
> >>>> +     if (events->flags & KVM_VCPUEVENT_VALID_SIPI_VECTOR &&
> >>>> +         kvm_vcpu_has_lapic(vcpu))
> >>>> +             vcpu->arch.apic->sipi_vector = events->sipi_vector;
> >>> This looks out of place in this patch. Why is it needed?
> >>
> >> It is required as long as we support MP_STATE_SIPI_RECEIVED as input
> >> from user space.
> > What problem are fixing with adding kvm_vcpu_has_lapic() here?
> 
> A NULL pointer access when setting the mp_state of a VCPU without an APIC.
> 
Only now I noticed that you changed vcpu->arch.sipi_vector to
vcpu->arch.apic->sipi_vector :)

--
			Gleb.

  reply	other threads:[~2013-03-13 12:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-13  8:50 [PATCH] KVM: x86: Rework INIT and SIPI handling Jan Kiszka
2013-03-13 10:31 ` Gleb Natapov
2013-03-13 11:16   ` Jan Kiszka
2013-03-13 11:36     ` Jan Kiszka
2013-03-13 12:29       ` Gleb Natapov
2013-03-13 12:40         ` Jan Kiszka
2013-03-13 12:48           ` Gleb Natapov
2013-03-13 12:58             ` Jan Kiszka
2013-03-13 13:18               ` Gleb Natapov
2013-03-13 12:16     ` Gleb Natapov
2013-03-13 12:17       ` Jan Kiszka
2013-03-13 12:22         ` Gleb Natapov [this message]
2013-03-13 11:10 ` Paolo Bonzini
2013-03-13 11:20   ` Jan Kiszka

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=20130313122216.GA2127@redhat.com \
    --to=gleb@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    /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