From patchwork Sun Jan 5 16:48:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11318509 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 5F9C66C1 for ; Sun, 5 Jan 2020 16:49:34 +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 3C3A52077B for ; Sun, 5 Jan 2020 16:49:34 +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="Pecq2HSH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C3A52077B 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 1io94u-0003nz-4e; Sun, 05 Jan 2020 16:48:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1io94t-0003nm-Hm for xen-devel@lists.xenproject.org; Sun, 05 Jan 2020 16:48:35 +0000 X-Inumbo-ID: 2c464d4e-2fdb-11ea-a1e1-bc764e2007e4 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2c464d4e-2fdb-11ea-a1e1-bc764e2007e4; Sun, 05 Jan 2020 16:48:18 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id a5so12670468wmb.0 for ; Sun, 05 Jan 2020 08:48:18 -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=WF8WbKtTBhS4BHGj5cB1aEH2QagI1ZAGsiQPgtzAOMw=; b=Pecq2HSHZroLPuNAiwy0aVovMUhQaNl5eW+t42s/BKtCEhQwadEAeik73V656FJISM XLkPanOOEV0CiZb26QWdY0+zcVgcladeC3NK+GaKxAaOxYpzmZEIvKwXtjDU5Dx4uOXy o/I5YPPMP/AM2vi8LO13kXcprpnlo8xFd1g78D0P9TB1PaNasF8k1XKihI269+OSsJd8 93EzXkIdz6hI5jeWPlRJhqpMWsSD+RJr6JxfST2rWEoG8V3skkHeFl2DNCLworzkD8UT BUJP0bG0pgtYyWwYtlFQpAJgCy/ksd+oQjOc+Vdc+alZVVIKwSOmANB5YFiCWG5+heH7 w1og== 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=WF8WbKtTBhS4BHGj5cB1aEH2QagI1ZAGsiQPgtzAOMw=; b=YCZoyflbz/kdu+vJgzfwUO84iLQJIZq9cxOlPo7yCGhURuogKp7imVtT9fXjPS1lBe 6aABKWE3U8UQkQB1cPWxwQ+qiTZe34L9Luao4tEETRIX9FwP0eun4f2Dxg3aABHVZM34 N/uQ77qEwcEEzBmV8Uf6Uuu2EaAd69VriqTJKxEA/mdYXhITDg6YIpsEGRE2EFMM0qii qM/UMdp4wFLEl08nJ5d+MutSbgIGqGFg/FQpTadHCGlIczuf4Zm+4puBtZ7EAboAS1Gi fws2b/5K2A9oEvGXK3mpbqPgqpWYIx1TX+vS4cVsM0++5L+H18ZS8nx7PCMMDT6VZKaA tElg== X-Gm-Message-State: APjAAAXTah0dU8W6egmB4eu1z6LKf0qDnKJIgexJzZuO3YA8oXOuxz2u 7Iyp9jRWs5H+w3XmFaY3t/3mYKzL2y4= X-Google-Smtp-Source: APXvYqx2DIQd26D44159xlchspxu/nXkZ5hTAc6k5+voMv2DpaDhI7uHFedu6PAXTvCWdOovCKxaqA== X-Received: by 2002:a1c:770e:: with SMTP id t14mr32371711wmi.101.1578242897110; Sun, 05 Jan 2020 08:48:17 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id y139sm20834028wmd.24.2020.01.05.08.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 08:48:16 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 5 Jan 2020 16:48:00 +0000 Message-Id: <20200105164801.26278-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200105164801.26278-1-liuwe@microsoft.com> References: <20200105164801.26278-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v3 4/5] 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 Reviewed-by: Paul Durrant --- 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 7e046dfc04..e5f258c946 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(void *, 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) @@ -87,6 +88,7 @@ static void __init setup_hypercall_page(void) static void setup_hypercall_pcpu_arg(void) { void *mapping; + uint64_t vp_index_msr; mapping = alloc_xenheap_page(); if ( !mapping ) @@ -94,6 +96,9 @@ static void setup_hypercall_pcpu_arg(void) smp_processor_id()); this_cpu(hv_pcpu_input_arg) = 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 6cf2eab62f..bae06c8a3a 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -66,6 +66,7 @@ struct ms_hyperv_info { extern struct ms_hyperv_info ms_hyperv; DECLARE_PER_CPU(void *, hv_pcpu_input_arg); +DECLARE_PER_CPU(unsigned int, hv_vp_index); const struct hypervisor_ops *hyperv_probe(void);