All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: linmiaohe <linmiaohe@huawei.com>
Cc: "x86\@kernel.org" <x86@kernel.org>,
	"kvm\@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Mingfangsen <mingfangsen@huawei.com>,
	"pbonzini\@redhat.com" <pbonzini@redhat.com>,
	"rkrcmar\@redhat.com" <rkrcmar@redhat.com>,
	"sean.j.christopherson\@intel.com"
	<sean.j.christopherson@intel.com>,
	"wanpengli\@tencent.com" <wanpengli@tencent.com>,
	"jmattson\@google.com" <jmattson@google.com>,
	"joro\@8bytes.org" <joro@8bytes.org>,
	"tglx\@linutronix.de" <tglx@linutronix.de>,
	"mingo\@redhat.com" <mingo@redhat.com>,
	"bp\@alien8.de" <bp@alien8.de>, "hpa\@zytor.com" <hpa@zytor.com>
Subject: Re: [PATCH] KVM: SVM: Fix potential wrong physical id in avic_handle_ldr_update
Date: Thu, 17 Oct 2019 11:48:48 +0200	[thread overview]
Message-ID: <87tv873dof.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <7db9f15500ab486b897bf1a7fa7e7161@huawei.com>

linmiaohe <linmiaohe@huawei.com> writes:

> Vitaly Kuznetsov <vkuznets@redhat.com> writes:
>
>>> Guest physical APIC ID may not equal to vcpu->vcpu_id in some case.
>>> We may set the wrong physical id in avic_handle_ldr_update as we 
>>> always use vcpu->vcpu_id.
>
> Hi, Vitaly, thanks for your reply.
> Do you think there may be a wrong physical id in
> avic_handle_ldr_update too ?

Honestly I'm not sure, however, as we need to put physical id to LDR
we'd rather get it from LAPIC then assume that it's == vcpu_id so I
think your patch makes sense even if it fixes a theoretical issue.

But I may be missing something important about AVIC.

>
>>>
>>> @@ -4591,6 +4591,8 @@ static int avic_handle_ldr_update(struct kvm_vcpu *vcpu)
>>>  	int ret = 0;
>>>  	struct vcpu_svm *svm = to_svm(vcpu);
>>>  	u32 ldr = kvm_lapic_get_reg(vcpu->arch.apic, APIC_LDR);
>>> +	u32 apic_id_reg = kvm_lapic_get_reg(vcpu->arch.apic, APIC_ID);
>>> +	u32 id = (apic_id_reg >> 24) & 0xff;
>>
>>If we reach here than we're guaranteed to be in xAPIC mode, right? Could you maybe export and use kvm_xapic_id() here then (and in
>>avic_handle_apic_id_update() too)?
>>
>
> I think we're guaranteed to be in xAPIC mode when we reach here. I would have a try to export
> and use use kvm_xapic_id here and in avic_handle_apic_id_update too.
> Thanks for your suggestion.
>
> Have a nice day.
> Best wishes.

-- 
Vitaly

  reply	other threads:[~2019-10-17  9:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17  2:12 [PATCH] KVM: SVM: Fix potential wrong physical id in avic_handle_ldr_update linmiaohe
2019-10-17  9:48 ` Vitaly Kuznetsov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-10-16  9:25 Miaohe Lin
2019-10-16 16:55 ` Vitaly Kuznetsov

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=87tv873dof.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingfangsen@huawei.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /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 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.