From patchwork Fri Jan 3 16:08:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11316987 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DF721395 for ; Fri, 3 Jan 2020 16:10:28 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3AAA42084D for ; Fri, 3 Jan 2020 16:10:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M7QorUtb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AAA42084D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPW2-0005e1-Dh; Fri, 03 Jan 2020 16:09:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPW0-0005cS-Lv for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:32 +0000 X-Inumbo-ID: 5ce7faea-2e43-11ea-a1e1-bc764e2007e4 Received: from mail-wm1-x32a.google.com (unknown [2a00:1450:4864:20::32a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5ce7faea-2e43-11ea-a1e1-bc764e2007e4; Fri, 03 Jan 2020 16:09:04 +0000 (UTC) Received: by mail-wm1-x32a.google.com with SMTP id f129so9033350wmf.2 for ; Fri, 03 Jan 2020 08:09:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LMFPYGrcm7BM/XK1EMrwljwKrMIeS9V+k4JmcGsTosc=; b=M7QorUtbzSu5vyn70UvJR7qvQ3056ecP9mQDPqnTvieFdUEipkc8BzYae6CM5fMgYR r0rx2pqX7OgDWHxukofI48aJt/s29s2AluJP8hJcD1EjOuT/y+qcDc6ubE3JsGARF0ks j3QxPAvsmUt624E4sCjyGtQkX/YhrzEooJCL/eh/l9ZO0y79N5e7DR4MGUTf3fiHu9ko ZHkfpK1HWLw+2dhziymQ5IYIAkeAHXfCKKYAsE/c/1lUWLGV8EeStwsmc2YAZCNA9quz 1/3LQMcW8KwzzeagqTasNnvyVpJ/kNhL0QCS+izN3bs0UU63N9vfmCspVZFPa65wlKQz LBHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=LMFPYGrcm7BM/XK1EMrwljwKrMIeS9V+k4JmcGsTosc=; b=fWgRel29kGTN9UfN20Qo8/xPWcYmyXc4FIwFDBO3w74hs8F/KsmN3woc/LiKO1rHcd ur+hAD+tSmZNJe2kx/KWpLok3cTqZ27Ejn8/YVNMi/kRphnkr7bB/ZIE2MxKw3G9vMlU 4yZ7GICTBcBL1KLIgCHSijPyAK9YZw6vQXBgqh557ojg3ZfrY3Y8qT7E0Yt4mfzdIIFs IjZzf2FiTo75GDcsP0O3uP4gd6Hf3BTO59iLCqsN+zGhL5XNm21/tSvkEHxoKTx55JcP n5BRT+uuI4UUbnzCy2Wwo83zd98ynijpk0hAJ4ks/EiH6Mu0r/tpskRXKzKZ0Aan4z1I Wyng== X-Gm-Message-State: APjAAAVuauRXuOoNV2ufgaoLqd9u3puowECvC3S++Z9xtt+yWUNResUS 0HGjpBKLDDiKrS1Sddq4ZcBFAj+3+KL02g== X-Google-Smtp-Source: APXvYqwbmx3bwNOOo/1sV5t8b4Apt1cPAv+VYMDE0eRYPgCRC1vooxFDz8tYUy6sNtuRw7ttVlMrMw== X-Received: by 2002:a05:600c:23c9:: with SMTP id p9mr20631914wmb.160.1578067744026; Fri, 03 Jan 2020 08:09:04 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id z11sm61000235wrt.82.2020.01.03.08.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:09:02 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:24 +0000 Message-Id: <20200103160825.19377-8-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200103160825.19377-1-liuwe@microsoft.com> References: <20200103160825.19377-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 7/8] x86/hyperv: retrieve vp_index from Hyper-V X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Paul Durrant , Andrew Cooper , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This will be useful when invoking hypercall that targets specific vcpu(s). Signed-off-by: Wei Liu --- v2: 1. Fold into setup_pcpu_arg function --- xen/arch/x86/guest/hyperv/hyperv.c | 5 +++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 6 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index 03027bd453..5c5aed46cb 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -28,6 +28,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; extern char hv_hypercall_page[]; DEFINE_PER_CPU_READ_MOSTLY(struct hyperv_pcpu_page, hv_pcpu_input_arg); +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index); static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -89,6 +90,7 @@ static void setup_hypercall_pcpu_arg(void) struct page_info *pg; void *mapping; unsigned int cpu = smp_processor_id(); + uint64_t vp_index_msr; pg = alloc_domheap_page(NULL, 0); if ( !pg ) @@ -100,6 +102,9 @@ static void setup_hypercall_pcpu_arg(void) this_cpu(hv_pcpu_input_arg).maddr = page_to_maddr(pg); this_cpu(hv_pcpu_input_arg).mapping = mapping; + + rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr); + this_cpu(hv_vp_index) = vp_index_msr; } static void __init setup(void) diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest/hyperv.h index 83f297468f..4b635829f3 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -70,6 +70,7 @@ struct hyperv_pcpu_page { void *mapping; }; DECLARE_PER_CPU(struct hyperv_pcpu_page, hv_pcpu_input_arg); +DECLARE_PER_CPU(unsigned int, hv_vp_index); const struct hypervisor_ops *hyperv_probe(void);