From patchwork Sun Jan 5 16:48:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11318511 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 7BB00138C for ; Sun, 5 Jan 2020 16:49:40 +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 580542077B for ; Sun, 5 Jan 2020 16:49:40 +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="qqEb8PLb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 580542077B 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 1io94z-0003qc-Ig; Sun, 05 Jan 2020 16:48:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1io94y-0003pz-H4 for xen-devel@lists.xenproject.org; Sun, 05 Jan 2020 16:48:40 +0000 X-Inumbo-ID: 2cb8ba8c-2fdb-11ea-a914-bc764e2007e4 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2cb8ba8c-2fdb-11ea-a914-bc764e2007e4; Sun, 05 Jan 2020 16:48:18 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id c127so10348821wme.1 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=z0cjj/lBQl0c9w1vDyVAOKv50SGygVYLUy39Nar8kbQ=; b=qqEb8PLbYwd+C8pWU6U9Z01IXdSrrma0roIdjxBrgKgPvumCHDa1ujNwFIaKwpE9QQ wkWkDfwCI/jYddKFQuUoYOMk+VspFVzI0bznyhSELZ6J5nDkUtLzf2442f4JW7j1YJhc Ki+M9Z4ZzwJi5rcQX1jkkQQuW6zn9CsiLyRmgsZ4MmfZwb8K+QxzZOeImGZ4QOKFMPhi JoW25wbNgKa+4ppgyQP6Cb9z7sYt2doz+yS9Vwfp0HDmn7b9uC9BHX6Ft+96CxEjr08R HbgJR4osfNI1s65vyqjI9SonmiPvRGurxRZPEMPCH0YQoSOABGuyadJ4Mtfed04mcORd KhhQ== 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=z0cjj/lBQl0c9w1vDyVAOKv50SGygVYLUy39Nar8kbQ=; b=nfQhJJzMb0rjetfPggissXHuSq6AwCa1Y92rwm4cU/ggs2hvRXDi/xbd0QflyTgYB0 fT2mLAeNZ1n2fwUc6aJ0hZut0pb4rDVp+6SF9w6h9vqNtqRbcaIa36Qo//cdpo+d9F8K 6KFw2LhtN80yCbO/XkuL/TeGKpse3ozt0q2PWZSctsri5FyelfbqTJqy8Mz6E5zv4il6 b7iDvQOR9nbFZg7L5Z77aehDOEFRydNZDXC/VkufwZPchiMRVEVZAmn0fSI+8vSAUIA1 f2T+x8RioN6AQUugBwW2aFr3tSVgC6lPkJgFuGf125bwam2cg/aM6d6tsrWU/JLkvQ3B kucg== X-Gm-Message-State: APjAAAVcKW6zLWt9+ybktgsWDjezU2LUoDji4mD9LpwECjEsFRRkTt8l Djk0AcrLAs/bozJhsKBDYekkyQBqV94= X-Google-Smtp-Source: APXvYqwzJDSMmx3E/QqOTDjHNRu3BYDa6GcOcWslL6+9+unRjR45tgun0vDm11rOLWIZGvMdNYUzzw== X-Received: by 2002:a05:600c:21c5:: with SMTP id x5mr29046737wmj.72.1578242897883; 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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jan 2020 08:48:17 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 5 Jan 2020 16:48:01 +0000 Message-Id: <20200105164801.26278-6-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 5/5] x86/hyperv: setup VP assist page 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" VP assist page is rather important as we need to toggle some bits in it for efficient nested virtualisation. Signed-off-by: Wei Liu --- v3: 1. Use xenheap page 2. Drop set_vp_assist v2: 1. Use HV_HYP_PAGE_SHIFT instead --- xen/arch/x86/guest/hyperv/hyperv.c | 21 +++++++++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 22 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index e5f258c946..17488f8c40 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; 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); +DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist); static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -101,15 +102,35 @@ static void setup_hypercall_pcpu_arg(void) this_cpu(hv_vp_index) = vp_index_msr; } +static void setup_vp_assist(void) +{ + void *mapping; + uint64_t val; + + mapping = alloc_xenheap_page(); + if ( !mapping ) + panic("Failed to allocate vp_assist page for %u\n", + smp_processor_id()); + + clear_page(mapping); + + this_cpu(hv_vp_assist) = mapping; + val = (virt_to_mfn(mapping) << HV_HYP_PAGE_SHIFT) + | HV_X64_MSR_VP_ASSIST_PAGE_ENABLE; + wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, val); +} + static void __init setup(void) { setup_hypercall_page(); setup_hypercall_pcpu_arg(); + setup_vp_assist(); } static void ap_setup(void) { setup_hypercall_pcpu_arg(); + setup_vp_assist(); } 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 bae06c8a3a..2ddfd53f8c 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -67,6 +67,7 @@ extern struct ms_hyperv_info ms_hyperv; DECLARE_PER_CPU(void *, hv_pcpu_input_arg); DECLARE_PER_CPU(unsigned int, hv_vp_index); +DECLARE_PER_CPU(void *, hv_vp_assist); const struct hypervisor_ops *hyperv_probe(void);