From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH v4 2/4] x86/HVM: fix ID handling of x2APIC emulation
Date: Wed, 24 Sep 2014 13:10:19 +0100 [thread overview]
Message-ID: <5422B4AB.8040603@citrix.com> (raw)
In-Reply-To: <5422CA1C0200007800038315@mail.emea.novell.com>
On 24/09/14 12:41, Jan Beulich wrote:
>>>> On 24.09.14 at 12:42, <andrew.cooper3@citrix.com> wrote:
>> On 22/09/14 16:19, Jan Beulich wrote:
>>> For full context, here's the full intended function again:
>>>
>>> +static void lapic_load_fixup(struct vlapic *vlapic)
>>> +{
>>> + uint32_t id = vlapic->loaded.id;
>>> +
>>> + if ( vlapic_x2apic_mode(vlapic) && id && vlapic->loaded.ldr == 1 &&
>>> + /* Further checks are optional: ID != 0 contradicts LDR == 1. */
>>> + GET_xAPIC_ID(id) == vlapic_vcpu(vlapic)->vcpu_id * 2 &&
>>> + id == SET_xAPIC_ID(GET_xAPIC_ID(id)) )
>>> + set_x2apic_id(vlapic);
>>> + else /* Undo an eventual earlier fixup. */
>>> + {
>>> + vlapic_set_reg(vlapic, APIC_ID, id);
>>> + vlapic_set_reg(vlapic, APIC_LDR, vlapic->loaded.ldr);
>>> + }
>>> +}
>> How about dropping the optional checks, as "id && vlapic->loaded.ldr ==
>> 1" covers the broken hypervisor case?
> I'd like to keep them for a while - after all that's why I added the
> comment saying they're optional. The moment they start conflicting
> with something else, they could be dropped.
>
> The alternative would be to make them WARN_ON()s inside the if().
Making them WARN_ON()s would make it more obvious if underlying
assumption/implementations change which subsequently invalidate the checks.
>
>> The "id = vcpu_id * 2" is a broken assumption which I do need to fix as
>> part of the cpuid infrastructure improvements, which would then break
>> this check for a broken Xen.
> For one it's not a broken assumption imo: The APIC ID gets set up
> this way.
Sorry - it is one which is expected to change in future development work.
> And then I don't see why altering the APIC ID setting
> would break this check here: If altering how the ID gets established
> would get backported, I'd surely expect the change to the ID
> handling here to also be.
This check gets applied equally to migrations from the same version of
Xen as to those from older versions. In this case I suppose the "id &&
vlapic->loaded.ldr" will short circuit the vcpu_id*2 check, in makes it
ok (assuming no backports).
>
>> Furthermore, vlapic_x2apic_mode(vlapic) contradicts the use of
>> {GET,SET}_xAPIC_ID().
> So it does, but intentionally. Remember - we're checking whether some
> fixup to what came in is necessary, and part of the brokenness was
> that the ID was left set in a legacy APIC manner.
Right, which again due to short circuiting ok given that we have never
supported x2apic with ids greater than 255.
~Andrew
next prev parent reply other threads:[~2014-09-24 12:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 14:35 [PATCH v4 0/4] x86/HVM: fix various aspects of APIC emulation Jan Beulich
2014-09-18 14:43 ` [PATCH v4 1/4] x86/HVM: fix miscellaneous aspects of x2APIC emulation Jan Beulich
2014-09-22 13:14 ` Andrew Cooper
2014-09-22 13:40 ` Jan Beulich
2014-09-23 16:56 ` Andrew Cooper
2014-09-24 8:02 ` Jan Beulich
2014-09-18 14:44 ` [PATCH v4 2/4] x86/HVM: fix ID handling " Jan Beulich
2014-09-19 6:09 ` Jan Beulich
2014-09-22 14:30 ` Andrew Cooper
2014-09-22 15:19 ` Jan Beulich
2014-09-24 10:42 ` Andrew Cooper
2014-09-24 11:41 ` Jan Beulich
2014-09-24 12:10 ` Andrew Cooper [this message]
2014-09-18 14:44 ` [PATCH v4 3/4] x86/HVM: a few type adjustments Jan Beulich
2014-09-18 14:45 ` [PATCH v4 4/4] x86/vlapic: don't silently accept bad vectors 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=5422B4AB.8040603@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.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).