From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Matt Wilson <msw@linux.com>
Cc: xen-devel@lists.xen.org, Paul Durrant <paul.durrant@citrix.com>,
Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH] x86/hvm: Extend HVM cpuid leaf with vcpu id
Date: Wed, 10 Dec 2014 10:36:18 +0000 [thread overview]
Message-ID: <54882222.7090005@citrix.com> (raw)
In-Reply-To: <20141210055958.GA28631@u109add4315675089e695.ant.amazon.com>
On 10/12/14 06:00, Matt Wilson wrote:
> On Thu, Nov 06, 2014 at 09:27:59PM +0000, Andrew Cooper wrote:
>> On 06/11/2014 19:32, Konrad Rzeszutek Wilk wrote:
>>> On Thu, Nov 06, 2014 at 03:07:10PM +0000, Paul Durrant wrote:
>>>> To perform certain hypercalls HVM guests need to use Xen's idea of
>>> What are those 'certain'?
>> Some HVM hypercalls take a vcpu_id as a parameter. See the
>> functionally-unrelated-but-companion patch "x86/hvm: Add per-vcpu evtchn
>> upcalls".
>>
>> HVM guests currently have no way of obtaining a xen vcpu_id for a given
>> vcpu, and therefore have no way of passing an appropriate parameter to
>> the hypercalls.
> Sorry for chiming in late...
>
> That's not strictly true. You can use the processor index in ACPI.
The LAPIC objects in the MADT/APIC table? That is still constructed
with the broken LAPIC_ID = 2 * processor_id logic.
>
>> As it currently happens, HVM guests can (and sadly do) take their APIC
>> id, divide by 2, and end up with a number which happens to match the Xen
>> vcpu_id. This only works because Xen's allocation of APIC IDs is wrong
>> on AMD hardware and Intel Hardware with hyperthreading, and is an issue
>> I plan to fix in the not too distant future. (It is one of the quagmire
>> of issues relating to cpuid policies)
> This is absolutely the wrong thing to do. If a guest OS is doing this,
> it is doing the wrong thing. FreeBSD went down this erroneous path...
>
> See http://lists.xen.org/archives/html/xen-devel/2013-05/msg03156.html
>
>>>> vcpu id, which may well not match the guest OS idea of CPU id.
>>> Can you elaborate more on the use case please? And why
>>> only restrict this to HVM guests? Why not PV?
>> PV guests unconditionally know their vcpu_id's right from the start, and
>> indeed need them to bring up APs. HVM guests currently only know APIC IDs.
> No, don't assume anything about APIC IDs mapping to Xen virtual
> processor index. This will break things on EC2 instances that expose
> proper CPU topology through CPUID, and this does *not* follow the
> "index * 2" formula.
>
>>>> This patch adds vcpu id to the HVM cpuid leaf allowing the guest
>>>> to build a mapping.
>>> Don't we have existing hypercalls to get this? Ah VCPUOP_get_physid
>>> is what I was thinking of and that does not seem to be what
>>> you want?
>> This hypercall is only valid for pinned vcpus (i.e. only dom0 with
>> opt_dom0_vcpus_pin), and gives back the underlying APIC ID, and the ACPI
>> processor ID for that APIC ID.
>>
>> The APIC ID can be obtained from cpuid as the vcpus are pinned, and the
>> ACPI ID can be obtained from the ACPI tables, as the domain is dom0.
>> Ergo, this hypercall is quite redundant, has nothing at all to do with
>> the problem Paul is trying to solve, and appears buggy as it hands back
>> two 64bit values, shifted 32bits apart, in a 64bit integer.
> And the Xen vCPU index can be determined by the processor object IDs
> in DSDT.
The processor object IDs have no requirement in the spec to be in order,
or contiguous. A DSDT processor object refers back to the MADT, which
in turn still has the broken logic.
Also, any solution using ACPI tables is going to be an issue for PVH guests.
~Andrew
next prev parent reply other threads:[~2014-12-10 10:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-06 15:07 [PATCH] x86/hvm: Extend HVM cpuid leaf with vcpu id Paul Durrant
2014-11-06 15:14 ` Andrew Cooper
2014-11-06 15:16 ` Paul Durrant
2014-11-06 15:20 ` Andrew Cooper
2014-11-06 19:32 ` Konrad Rzeszutek Wilk
2014-11-06 21:27 ` Andrew Cooper
2014-12-10 6:00 ` Matt Wilson
2014-12-10 10:29 ` Jan Beulich
2014-12-11 18:07 ` Matt Wilson
2014-12-10 10:36 ` Andrew Cooper [this message]
2014-12-11 18:19 ` Matt Wilson
2014-12-11 19:00 ` Andrew Cooper
2014-12-11 20:27 ` Matt Wilson
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=54882222.7090005@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=msw@linux.com \
--cc=paul.durrant@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 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.