From patchwork Tue Jun 28 16:47:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Kuznetsov X-Patchwork-Id: 9203619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A7A96075F for ; Tue, 28 Jun 2016 16:49:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C4B5285FD for ; Tue, 28 Jun 2016 16:49:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 614842860E; Tue, 28 Jun 2016 16:49:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E75CC285FD for ; Tue, 28 Jun 2016 16:49:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHwAq-0003dz-NJ; Tue, 28 Jun 2016 16:47:44 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bHwAp-0003d4-Cz for xen-devel@lists.xenproject.org; Tue, 28 Jun 2016 16:47:43 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 46/7D-11548-E2AA2775; Tue, 28 Jun 2016 16:47:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysWW7jK7eqqJ wg3dr+C2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owPp0oKlvBWdP5bzNbAOJ+7i5GLQ0hgL5PE z11bWSCcI4wSGy+1M3UxcnKwCehIfH96ihnEFhFQkri3ajITSBGzwBRmic8bt7OCJIQFgiR65 mxiB7FZBFQljnV3gDXzCjhJnHozB6yZU8BZ4nP7NrAaIaD4iRXz2EBsCQFtiecXJrODDJUQ6G OUmNh7nm0CI88CRoZVjOrFqUVlqUW6hnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bm bGIGeZwCCHYw7nzsdYpTkYFIS5f3WWxQuxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXeiVQTrAo NT21Ii0zBxiCMGkJDh4lEd5nK4DSvMUFibnFmekQqVOMilLivOdBEgIgiYzSPLg2WNhfYpSVE uZlBDpEiKcgtSg3swRV/hWjOAejkjDEdp7MvBK46a+AFjMBLWatzgdZXJKIkJJqYOw+tGRNxp 8vLM/2NQg6qE4oVtC0/7gvi7Vce+829vcGE6rXzZqa2n3uyvnZUV6RkkvuHBLf9NdBY/k7C4O dZ2St7safn3v+Z9nkmJjNr6flBl2RvPQ24oDLW8kbD458e3Bknvm6rZ+2Son8238pzTzA99Hl GvcdbLvrNoR+FhPdH2nOpRKq07ZJiaU4I9FQi7moOBEA8+BRDnYCAAA= X-Env-Sender: vkuznets@redhat.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1467132460!21396493!1 X-Originating-IP: [209.132.183.28] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMjA5LjEzMi4xODMuMjggPT4gNTQwNjQ=\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35592 invoked from network); 28 Jun 2016 16:47:42 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by server-7.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Jun 2016 16:47:42 -0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C8C7C04B325; Tue, 28 Jun 2016 16:47:40 +0000 (UTC) Received: from vitty.brq.redhat.com (vitty.brq.redhat.com [10.34.26.3]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5SGlUI8004662; Tue, 28 Jun 2016 12:47:38 -0400 From: Vitaly Kuznetsov To: xen-devel@lists.xenproject.org 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-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 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) Cc: Juergen Gross , Stefano Stabellini , x86@kernel.org, linux-kernel@vger.kernel.org, Julien Grall , Ingo Molnar , David Vrabel , "H. Peter Anvin" , Boris Ostrovsky , Thomas Gleixner Subject: [Xen-devel] [PATCH linux 3/8] x86/xen: use xen_vcpu_id mapping for HYPERVISOR_vcpu_op X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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