From patchwork Sun Dec 29 18:33:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11312371 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 566F0138C for ; Sun, 29 Dec 2019 18:35: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 2F7C020748 for ; Sun, 29 Dec 2019 18:35: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="mzo4iLLT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F7C020748 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 1ildOa-000093-31; Sun, 29 Dec 2019 18:34:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOZ-00008S-58 for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:31 +0000 X-Inumbo-ID: c84d13c0-2a69-11ea-88e7-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c84d13c0-2a69-11ea-88e7-bc764e2007e4; Sun, 29 Dec 2019 18:34:01 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id y17so30942958wrh.5 for ; Sun, 29 Dec 2019 10:34:01 -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=1PyVSClYu6+fDv7K0LaZ45jC77EsJu0qmCTArhICeFU=; b=mzo4iLLTUYldPFh730/DhrNjr8B9qAMIcr8unfvwQoC13MrSgRZ7ZFLrfQN6tJY2nw 0wQLBgjuCYNzsIruWTDKu1wjy2UZ539FSM0YbXhKEcOC7bGlEBQz8iZVX84LxrrBMcqp 5bpcFhpfbf1Lz4LrptPZQrcP+E1Ih2oQOaUR2gsIcxPJm7MkK6vI8LoAAaV5/oIa6TsD IoKA0+wkJmTXgbs0i39HYnQMGBKZVwlH/f3vkvIFiM6QXTnIvYm9OpWHn+vg5/cl/GkO fI86jdThY9wE7V8INb7BzkdvnWnljJLtf6BTAIVcN09kxqv80xDPmo6D6h0hXw+0ZJ1J ivpA== 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=1PyVSClYu6+fDv7K0LaZ45jC77EsJu0qmCTArhICeFU=; b=rV8LeepV+DkN13PSCQSKiCUnzqbtte+YrbYxzZFGc/X5aKEuSoIOwk7CxYCs8zEDeo UVvvPd7cbqdZ9kEKfUQdRTUjDvcSIEk9ZExsqVNc94zNbFb9x4xHLS/cGUfkmNDfGQ9f FDRrgaqtQUDbknSWkn4bT1FVbY7JFD7GtdVOrcC9a5vADPfDJ7UCoHFb0dXtp7HJzawC BHP2A+dNc2LfDmBZInu5W7JoV0koEG17OYIJTs9P8GOnHtfLGqAQBRHRKPxndyTdwSmy WrHEAVDZWp1bBzhpazFsVnG7IIifMTEFLJxkkksTbIlG7ubg2EBDkiSFf9Yw7Wjc2Fgm XbNw== X-Gm-Message-State: APjAAAXqiMm6oks3cDemvS/Pp/KP2/N4mK/5pvkGE65CG9khWuAGTZvt jmbdVHF5iSsduG92O2nemxQPufa/xSs= X-Google-Smtp-Source: APXvYqxjqzOJIVTIL9UaC91HvisLkiqlLpmaBAk4pcOLatt0n4Ua8s+HZiiNR8fBGNysQNzDiRfVIw== X-Received: by 2002:a5d:51c6:: with SMTP id n6mr1352933wrv.250.1577644440417; Sun, 29 Dec 2019 10:34:00 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id f207sm19667903wme.9.2019.12.29.10.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:34:00 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:40 +0000 Message-Id: <20191229183341.14877-8-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191229183341.14877-1-liuwe@microsoft.com> References: <20191229183341.14877-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 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 --- xen/arch/x86/guest/hyperv/hyperv.c | 12 ++++++++++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 13 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index 67667936e9..da3a8cd85d 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -29,6 +29,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; void *hv_hypercall; static struct page_info *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) @@ -115,15 +116,26 @@ static void setup_hypercall_pcpu_arg(void) this_cpu(hv_pcpu_input_arg).mapping = mapping; } +static void setup_vp_index(void) +{ + uint64_t vp_index_msr; + + rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr); + + this_cpu(hv_vp_index) = vp_index_msr; +} + static void __init setup(void) { setup_hypercall_page(); setup_hypercall_pcpu_arg(); + setup_vp_index(); } static void ap_setup(void) { setup_hypercall_pcpu_arg(); + setup_vp_index(); } static const struct hypervisor_ops ops = { 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);