From patchwork Fri Jan 3 16:08:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11316989 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 9392C138D for ; Fri, 3 Jan 2020 16:10:36 +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 6FB4A2084D for ; Fri, 3 Jan 2020 16:10:36 +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="aLHpkybu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FB4A2084D 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 1inPW6-0005hZ-SI; Fri, 03 Jan 2020 16:09:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPW5-0005gn-Mf for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:37 +0000 X-Inumbo-ID: 5d648e3e-2e43-11ea-b6f1-bc764e2007e4 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5d648e3e-2e43-11ea-b6f1-bc764e2007e4; Fri, 03 Jan 2020 16:09:05 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id d16so42885705wre.10 for ; Fri, 03 Jan 2020 08:09:05 -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=QxvxkFsBq9Bc5+7I063/jL+c+OhXWyTgW7n8J0N8R6s=; b=aLHpkybuVzC/g9a2pgPZck1nlSkeJ97bBZ6COKF2fLL1RNsJYXZymDjD+k39c6qEUk uqdbh6qeBxDoH8k+DmbPlECAckHel9QdG2FcqakMg7d0/jQfJBQvccYiE8MJhC5bZDqz 5Lglb4UZHpa3gatpwAcAk9zhglDtVXk93iKmwcU8Hpo5TlJsVtX/Syx4gqfYaYdSlJX+ obqS0vT2BGiv/ft4QWF8w42503Vt8f4wajzSZZNdSQ8wgTaGHwJMi21IA1TfFqDia4gE IFyBE3J6ANtY3u6bAvPhKX8DlgWvYJNVoqNs2bVeMwJbwCz1uZ4Wii0N4esk0JYp67FT YV2g== 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=QxvxkFsBq9Bc5+7I063/jL+c+OhXWyTgW7n8J0N8R6s=; b=IJY1rnVoMrgMhv563bmJTC7mXAUi67XU61iYBnZQMAD+WjQ+jiLE7TJ89zSBp/u0/9 9HIvo5p/Fz5hF9u4qyCj0UD0D028SozkyDkdk5lz9QVEV54WwpoGSVkafGMtbivNOTWd 43w5sBgyJOJEAMdwmC2YN6Oh89h58B3XdltukFieTO/kzqX7lfmhZ9CFwWj6SOZilypR XxyQAXIJ/snalXeCLRULJqmgVzqNozMeFkJA8Px0eG8rkiGHzRI3pGj1DQ6hrAW9xs94 t6bLzG9Ux2sqgIbDdT9jmH6SZhbO6eRRTDCbPXt6tGYSGgVB702TheKddZS4YXt3TkVv yk2g== X-Gm-Message-State: APjAAAXEFIOycpiral3uE1zYw241Zz+aqcPfMdNJgWQQh0yC8ZgKparn Q/n/WJuimv9+K3QDEeTGNSj0yOWet/uFag== X-Google-Smtp-Source: APXvYqzg54U/jtCaQ8LIaT9EwOnit73cCh1PWTZ+FGutrIgePQed6FkLIv3g+t3ZdHIQNRrVsnxhPA== X-Received: by 2002:a5d:608a:: with SMTP id w10mr83549018wrt.136.1578067744831; 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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:09:04 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:25 +0000 Message-Id: <20200103160825.19377-9-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 8/8] 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 for efficient nested virtualisation. Preemptively split out set_vp_assist page which will be used in the resume path. Signed-off-by: Wei Liu --- v2: 1. Use HV_HYP_PAGE_SHIFT instead --- xen/arch/x86/guest/hyperv/hyperv.c | 34 ++++++++++++++++++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 35 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index 5c5aed46cb..cf6ad13e48 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(struct hyperv_pcpu_page, hv_pcpu_input_arg); DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index); +DEFINE_PER_CPU_READ_MOSTLY(struct hyperv_pcpu_page, hv_vp_assist); static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -107,15 +108,48 @@ static void setup_hypercall_pcpu_arg(void) this_cpu(hv_vp_index) = vp_index_msr; } +static void set_vp_assist(void) +{ + uint64_t val = paddr_to_pfn(this_cpu(hv_vp_assist).maddr); + + val = (val << HV_HYP_PAGE_SHIFT) | HV_X64_MSR_VP_ASSIST_PAGE_ENABLE; + + wrmsrl(HV_X64_MSR_VP_ASSIST_PAGE, val); +} + +static void setup_vp_assist(void) +{ + struct page_info *pg; + void *mapping; + unsigned int cpu = smp_processor_id(); + + pg = alloc_domheap_page(NULL, 0); + if ( !pg ) + panic("Failed to allocate vp_assist page for %u\n", cpu); + + mapping = __map_domain_page_global(pg); + if ( !mapping ) + panic("Failed to map vp_assist page for %u\n", cpu); + + clear_page(mapping); + + this_cpu(hv_vp_assist).maddr = page_to_maddr(pg); + this_cpu(hv_vp_assist).mapping = mapping; + + set_vp_assist(); +} + 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 4b635829f3..917f4e02c2 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -71,6 +71,7 @@ struct hyperv_pcpu_page { }; DECLARE_PER_CPU(struct hyperv_pcpu_page, hv_pcpu_input_arg); DECLARE_PER_CPU(unsigned int, hv_vp_index); +DECLARE_PER_CPU(struct hyperv_pcpu_page, hv_vp_assist); const struct hypervisor_ops *hyperv_probe(void);