xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	Julien Grall <julien.grall@citrix.com>,
	Ingo Molnar <mingo@redhat.com>,
	David Vrabel <david.vrabel@citrix.com>,
	Jan Beulich <JBeulich@suse.com>, "H. Peter Anvin" <hpa@zytor.com>,
	xen-devel@lists.xenproject.org,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH linux 2/8] xen: introduce xen_vcpu_id mapping
Date: Wed, 29 Jun 2016 13:30:13 +0100	[thread overview]
Message-ID: <689743e6-0b0e-9935-58e1-2dfa257c7bf8__13426.1762178086$1467203496$gmane$org@citrix.com> (raw)
In-Reply-To: <87shvwur5p.fsf@vitty.brq.redhat.com>

On 29/06/16 13:16, Vitaly Kuznetsov wrote:
> Andrew Cooper <andrew.cooper3@citrix.com> writes:
>
>> On 28/06/16 17:47, Vitaly Kuznetsov wrote:
>>> @@ -1808,6 +1822,8 @@ static int xen_hvm_cpu_notify(struct notifier_block *self, unsigned long action,
>>>  	int cpu = (long)hcpu;
>>>  	switch (action) {
>>>  	case CPU_UP_PREPARE:
>>> +		/* vLAPIC_ID == Xen's vCPU_ID * 2 for HVM guests */
>>> +		per_cpu(xen_vcpu_id, cpu) = cpu_physical_id(cpu) / 2;
>> Please do not assume or propagate this brokenness.  It is incorrect in
>> the general case, and I will be fixing in the hypervisor in due course.
>>
>> Always read the APIC_ID from the LAPIC, per regular hardware.
> (I'm probbaly missing something important - please bear with me)
>
> The problem here is that I need to get _other_ CPU's id before any code
> is executed on that CPU (or, at least, this is the current state of
> affairs if you look at xen_hvm_cpu_up()) so I can't use CPUID/do MSR
> reads/... The only option I see here is to rely on ACPI (MADT) data
> which is stored in x86_cpu_to_apicid (and that's what cpu_physical_id()
> gives us). MADT also has processor id which connects it to DSDT but I'm
> not sure Linux keeps this data. But this is something fixable I guess.

Hmm yes - that is a tricky issue.

It is not safe or correct to assume that xen_vcpu_id is APICID / 2.

This is currently the case for most modern versions of Xen, but isn't
the case for older versions, and won't be the case in the future when I
(or someone else) fixes topology representation for guests.

For this to work, we need one or more of:

1) to provide the guest a full mapping from APIC_ID to vcpu id at boot time.
2) add a new interface where the guest can explicitly query "what is the
vcpu id for the entity with this APIC_ID".
3) Allow HVM guests to identify a vcpu in a hypercall by APIC_ID.

3 is the cleaner approach, but given that vcpu ids have already leaked
into an HVM domains idea of the world, 1 or 2 is probably a better
ladder to dig us out of this hole.

~Andrew.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-06-29 12:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1467132449-1030-1-git-send-email-vkuznets@redhat.com>
2016-06-28 16:47 ` [PATCH linux 1/8] x86/xen: update cpuid.h from Xen-4.7 Vitaly Kuznetsov
2016-06-28 16:47 ` [PATCH linux 2/8] xen: introduce xen_vcpu_id mapping Vitaly Kuznetsov
2016-06-28 17:28   ` Andrew Cooper
     [not found]   ` <c16250fe-28a4-20d6-2c47-6c2d3cae85ff@citrix.com>
2016-06-29 12:16     ` Vitaly Kuznetsov
2016-06-29 12:30       ` Andrew Cooper [this message]
     [not found]       ` <689743e6-0b0e-9935-58e1-2dfa257c7bf8@citrix.com>
2016-06-29 12:50         ` Vitaly Kuznetsov
     [not found]         ` <87oa6kupko.fsf@vitty.brq.redhat.com>
2016-06-29 16:19           ` Vitaly Kuznetsov
2016-06-29 16:27             ` Andrew Cooper
2016-06-30  9:10               ` Jan Beulich
2016-07-01 12:06                 ` Vitaly Kuznetsov
2016-07-01 13:33                   ` Jan Beulich
2016-07-05 15:34                 ` Konrad Rzeszutek Wilk
2016-07-05 15:44                   ` Jan Beulich
     [not found]                   ` <577BF1FC02000078000FB51A@prv-mh.provo.novell.com>
2016-07-07 10:15                     ` Joao Martins
2016-06-28 16:47 ` [PATCH linux 3/8] x86/xen: use xen_vcpu_id mapping for HYPERVISOR_vcpu_op Vitaly Kuznetsov
2016-06-29 12:26   ` David Vrabel
2016-06-28 16:47 ` [PATCH linux 4/8] x86/xen: use xen_vcpu_id mapping when pointing vcpu_info to the shared_info page Vitaly Kuznetsov
2016-06-29 12:32   ` David Vrabel
2016-06-28 16:47 ` [PATCH linux 5/8] xen/events: use xen_vcpu_id mapping in events_base Vitaly Kuznetsov
2016-06-28 16:47 ` [PATCH linux 6/8] xen/events: fifo: use xen_vcpu_id mapping Vitaly Kuznetsov
2016-06-28 16:47 ` [PATCH linux 7/8] xen/evtchn: " Vitaly Kuznetsov
2016-06-28 16:47 ` [PATCH linux 8/8] xen/pvhvm: run xen_vcpu_setup() for the boot CPU Vitaly Kuznetsov
2016-06-28 17:32 ` [PATCH linux 0/8] xen: pvhvm: support bootup on secondary vCPUs David Vrabel
     [not found] ` <5772B4C2.4010906@citrix.com>
2016-06-29  9:16   ` Vitaly Kuznetsov
     [not found]   ` <871t3gwe0o.fsf@vitty.brq.redhat.com>
2016-06-29 12:36     ` David Vrabel
     [not found]     ` <5773C0DF.3090905@citrix.com>
2016-07-01  9:24       ` 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='689743e6-0b0e-9935-58e1-2dfa257c7bf8__13426.1762178086$1467203496$gmane$org@citrix.com' \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=david.vrabel@citrix.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=julien.grall@citrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=x86@kernel.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).