From: Chao Gao <chao.gao@intel.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, xen-devel@lists.xen.org
Subject: Re: [PATCH v2] x86/vlapic: Don't reset APIC ID when handling INIT signal
Date: Wed, 19 Apr 2017 15:41:41 +0800 [thread overview]
Message-ID: <20170419074141.GA100130@skl-2s3.sh.intel.com> (raw)
In-Reply-To: <58F78D8A0200007800151FE6@prv-mh.provo.novell.com>
On Wed, Apr 19, 2017 at 08:17:14AM -0600, Jan Beulich wrote:
>>>> On 19.04.17 at 08:40, <chao.gao@intel.com> wrote:
>> @@ -1257,7 +1257,12 @@ void vlapic_reset(struct vlapic *vlapic)
>> }
>> vlapic_set_reg(vlapic, APIC_ICR, 0);
>> vlapic_set_reg(vlapic, APIC_ICR2, 0);
>> - vlapic_set_reg(vlapic, APIC_LDR, 0);
>> + /*
>> + * LDR is read-only in x2APIC mode. Preserve its value when handling
>> + * INIT signal in x2APIC mode.
>> + */
>> + if ( !vlapic_x2apic_mode(vlapic) )
>
>In order for this to work you need to ...
>
>> + vlapic_set_reg(vlapic, APIC_LDR, 0);
>> vlapic_set_reg(vlapic, APIC_TASKPRI, 0);
>> vlapic_set_reg(vlapic, APIC_TMICT, 0);
>> vlapic_set_reg(vlapic, APIC_TMCCT, 0);
>> @@ -1275,6 +1280,22 @@ void vlapic_reset(struct vlapic *vlapic)
>> destroy_periodic_time(&vlapic->pt);
>> }
>>
>> +/* Reset the VLAPIC back to its power-on/reset state. */
>> +void vlapic_reset(struct vlapic *vlapic)
>> +{
>> + const struct vcpu *v = vlapic_vcpu(vlapic);
>> +
>> + if ( !has_vlapic(v->domain) )
>> + return;
>> +
>> + vlapic_set_reg(vlapic, APIC_ID, (v->vcpu_id * 2) << 24);
>> + vlapic_set_reg(vlapic, APIC_LDR, 0);
>> + vlapic_do_init(vlapic);
>> +
>> + vlapic->hw.apic_base_msr &= ~(uint64_t)MSR_IA32_APICBASE_EXTD;
>
>... do this before calling vlapic_do_init() afaict (and I see no strong
>reason why you would need a cast here)). Likely it is a good idea
>then to also ...
Got it and will fix. The APIC_LDR is also cleared in vlapic_reset.
Do you mean it will do a cast automatically? I don't know that before.
I was afraid that the higher qword of ~MSR_IA32_APICBASE_EXTD will is
zero.
>
>> + vlapic->hw.apic_base_msr |= MSR_IA32_APICBASE_ENABLE;
>
>... do this up front.
>
>> @@ -1489,8 +1510,7 @@ int vlapic_init(struct vcpu *v)
>>
>> vlapic_reset(vlapic);
>>
>> - vlapic->hw.apic_base_msr = (MSR_IA32_APICBASE_ENABLE |
>> - APIC_DEFAULT_PHYS_BASE);
>> + vlapic->hw.apic_base_msr |= APIC_DEFAULT_PHYS_BASE;
>
>Perhaps better move this ahead of the call to vlapic_reset() then
>too.
>
>Remains the question (not answered by the SDM afaics): What
>happens to the base address during reset?
Actually, I don't know and that's also why I don't touch apic_base_msr in the
first verson. Will try to get a confirmation from hardware guys.
Thanks
Chao
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-04-19 7:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-19 6:40 [PATCH v2] x86/vlapic: Don't reset APIC ID when handling INIT signal Chao Gao
2017-04-19 14:17 ` Jan Beulich
2017-04-19 7:41 ` Chao Gao [this message]
2017-04-19 15:04 ` Jan Beulich
2017-04-19 19:33 ` Chao Gao
2017-04-20 9:55 ` Jan Beulich
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=20170419074141.GA100130@skl-2s3.sh.intel.com \
--to=chao.gao@intel.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=xen-devel@lists.xen.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 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).