From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752771AbcF1QsJ (ORCPT ); Tue, 28 Jun 2016 12:48:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57440 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752337AbcF1QsD (ORCPT ); Tue, 28 Jun 2016 12:48:03 -0400 From: Vitaly Kuznetsov To: xen-devel@lists.xenproject.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Stefano Stabellini , Boris Ostrovsky , David Vrabel , Juergen Gross , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Julien Grall Subject: [PATCH linux 3/8] x86/xen: use xen_vcpu_id mapping for HYPERVISOR_vcpu_op Date: Tue, 28 Jun 2016 18:47:24 +0200 Message-Id: <1467132449-1030-4-git-send-email-vkuznets@redhat.com> In-Reply-To: <1467132449-1030-1-git-send-email-vkuznets@redhat.com> References: <1467132449-1030-1-git-send-email-vkuznets@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 28 Jun 2016 16:47:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HYPERVISOR_vcpu_op passes Linux's idea of vCPU id as a parameter while Xen's idea is expected. In some cases these ideas diverge so we need to do remapping. There is an issue, however. PV guests do VCPUOP_is_up very early (see xen_fill_possible_map() and xen_filter_cpu_maps()) when we don't have perpu areas initialized. While it could be solved with switching to early_percpu for xen_vcpu_id I think it's not worth it: PV guests will probably never get to the point where their idea of vCPU id diverges from Xen's. Signed-off-by: Vitaly Kuznetsov --- arch/x86/include/asm/xen/hypercall.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h index a12a047..20750c8 100644 --- a/arch/x86/include/asm/xen/hypercall.h +++ b/arch/x86/include/asm/xen/hypercall.h @@ -49,6 +49,7 @@ #include #include #include +#include /* * The hypercall asms have to meet several constraints: @@ -422,7 +423,15 @@ HYPERVISOR_vm_assist(unsigned int cmd, unsigned int type) static inline int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args) { - return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args); + /* + * PV guests call HYPERVISOR_vcpu_op before percpu areas are + * initialized. As we always use direct mapping for vCPU ids + * for them we can simply use Linux vcpuid here. + */ + return _hypercall3(int, vcpu_op, cmd, + per_cpu(xen_vcpu_id, vcpuid) != -1 ? + per_cpu(xen_vcpu_id, vcpuid) : vcpuid, + extra_args); } #ifdef CONFIG_X86_64 -- 2.5.5