kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: "Yang, Sheng" <sheng.yang@intel.com>
Cc: kvm-devel <kvm@vger.kernel.org>, Avi Kivity <avi@redhat.com>
Subject: Re: [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled	APICs
Date: Mon, 20 Oct 2008 13:56:29 +0200	[thread overview]
Message-ID: <48FC71ED.6060505@siemens.com> (raw)
In-Reply-To: <20081020115117.GB30536@yukikaze>

Sheng Yang wrote:
> On Mon, Oct 20, 2008 at 10:50:57AM +0200, Jan Kiszka wrote:
>> The locic of kvm_apic_accept_pic_intr has a minor, practically hardly
> 
> Typo...
> 
>> relevant incorrectness: PIC interrupts are still delivered even if the
>> APIC of VPU0 (BSP) is disabled. This does not comply with the Virtual
>> Wire mode according to the Intel MP spec.
>>
>> To avoid side effects, the BSP APIC is now enabled on reset.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  arch/x86/kvm/lapic.c |   19 +++++++++----------
>>  1 file changed, 9 insertions(+), 10 deletions(-)
>>
>> Index: b/arch/x86/kvm/lapic.c
>> ===================================================================
>> --- a/arch/x86/kvm/lapic.c
>> +++ b/arch/x86/kvm/lapic.c
>> @@ -933,7 +933,8 @@ void kvm_lapic_reset(struct kvm_vcpu *vc
>>  	update_divide_count(apic);
>>  	atomic_set(&apic->timer.pending, 0);
>>  	if (vcpu->vcpu_id == 0)
>> -		vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP;
>> +		vcpu->arch.apic_base |=
>> +			MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE;
> 
> I think this have already been done in vmx_vcpu_reset()/svm_create_vcpu()?

Indeed, will drop that hunk.

> 
>>  	apic_update_ppr(apic);
>>  
>>  	apic_debug(KERN_INFO "%s: vcpu=%p, id=%d, base_msr="
>> @@ -1089,17 +1090,15 @@ int kvm_apic_has_interrupt(struct kvm_vc
>>  
>>  int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu)
>>  {
>> +	struct kvm_lapic *apic = vcpu->arch.apic;
>>  	u32 lvt0 = apic_get_reg(vcpu->arch.apic, APIC_LVT0);
> 
> Reuse just defined variable "apic"?

[ Cleaning my glasses ] Ahh, I see. :)

> 
>> -	int r = 0;
>>  
>> -	if (vcpu->vcpu_id == 0) {
>> -		if (!apic_hw_enabled(vcpu->arch.apic))
>> -			r = 1;
>> -		if ((lvt0 & APIC_LVT_MASKED) == 0 &&
>> -		    GET_APIC_DELIVERY_MODE(lvt0) == APIC_MODE_EXTINT)
>> -			r = 1;
>> -	}
>> -	return r;
>> +	/* Virtual Wire mode, but we only deliver to the BSP. */
>> +	if (vcpu->vcpu_id == 0 && apic_hw_enabled(apic)
> 
> Good point! How about apic_enabled(apic)? Software disable apic should also
> can't functional(hope this wouldn't expose some bugs...)

apic_sw_enable is also covered by the LVT_MASKED check we do on delivery
anyway. That's why I lest it out here. Can spend a comment, though.

> --
> regards
> Yang, Sheng
> 
>> +	    && !(lvt0 & APIC_LVT_MASKED)
>> +	    && GET_APIC_DELIVERY_MODE(lvt0) == APIC_MODE_EXTINT)
>> +		return 1;
>> +	return 0;
>>  }
>>  
>>  void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu)
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux

  reply	other threads:[~2008-10-20 11:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-20  8:50 [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs Jan Kiszka
2008-10-20 11:51 ` Sheng Yang
2008-10-20 11:56   ` Jan Kiszka [this message]
2008-10-20 12:02     ` Jan Kiszka
2008-10-20 12:06 ` [PATCH] KVM: x86: Don't deliver PIC interrupts to disabled APICs - v2 Jan Kiszka
2008-10-20 12:22   ` Sheng Yang
2008-10-22 10:22   ` Avi Kivity
2008-10-22 14:08   ` Avi Kivity
2008-10-22 15:09     ` Jan Kiszka
2008-10-22 15:12       ` Jan Kiszka
2008-10-22 15:39         ` Jan Kiszka
2008-10-22 20:44           ` Jan Kiszka
2008-10-23  1:51             ` Yang, Sheng
2008-10-23  8:11               ` 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=48FC71ED.6060505@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=sheng.yang@intel.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;
as well as URLs for NNTP newsgroup(s).