From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932107AbcF2MRE (ORCPT ); Wed, 29 Jun 2016 08:17:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43888 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751674AbcF2MQH (ORCPT ); Wed, 29 Jun 2016 08:16:07 -0400 From: Vitaly Kuznetsov To: Andrew Cooper Cc: , Juergen Gross , Stefano Stabellini , , , Julien Grall , Ingo Molnar , "David Vrabel" , "H. Peter Anvin" , "Boris Ostrovsky" , Thomas Gleixner Subject: Re: [Xen-devel] [PATCH linux 2/8] xen: introduce xen_vcpu_id mapping References: <1467132449-1030-1-git-send-email-vkuznets@redhat.com> <1467132449-1030-3-git-send-email-vkuznets@redhat.com> Date: Wed, 29 Jun 2016 14:16:02 +0200 In-Reply-To: (Andrew Cooper's message of "Tue, 28 Jun 2016 18:28:31 +0100") Message-ID: <87shvwur5p.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 29 Jun 2016 12:16:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andrew Cooper 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. -- Vitaly