From nobody Mon Feb 9 10:29:53 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1578067820; cv=none; d=zohomail.com; s=zohoarc; b=XactGjt3/2vxFQ+8jAAQosuVSUQqg4xdlCKTT7Ab+P1tyeZ1DeKTvDf3OODBFUTAsizC+z0XpXRIhjYtp95SF22I20/usAT1JoqamZVPntPm2VQcw54wbZ1YlFyR28RJXLiqW78tE4uCQEaojXQXv4AksxcEUPVWaChXgDrfuXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067820; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sA9P4fa7xqhmFwIiN1PJJ0djoh9oqHB/idCV+PfCPi0=; b=M4GkG3CRrG/HLrv/JITLgEeTB1/6Lrx14a04iuwZlCoGu9agrtGtsEhCSDC9Hh+ryFWctFv8zWB/sbBFtd6VZY/8JUrU/8BlG3FWTgQKFPdGrhj5ouI7S9lU8IgM4iB8w+FLmoFHtVNC7J57we1Pm2vsKSrcJkYL7oo7dnVyvn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157806782015144.78661901198848; Fri, 3 Jan 2020 08:10:20 -0800 (PST) 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 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) 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) X-Inumbo-ID: 5d648e3e-2e43-11ea-b6f1-bc764e2007e4 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) 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=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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); =20 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) =3D vp_index_msr; } =20 +static void set_vp_assist(void) +{ + uint64_t val =3D paddr_to_pfn(this_cpu(hv_vp_assist).maddr); + + val =3D (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 =3D smp_processor_id(); + + pg =3D alloc_domheap_page(NULL, 0); + if ( !pg ) + panic("Failed to allocate vp_assist page for %u\n", cpu); + + mapping =3D __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 =3D page_to_maddr(pg); + this_cpu(hv_vp_assist).mapping =3D mapping; + + set_vp_assist(); +} + static void __init setup(void) { setup_hypercall_page(); setup_hypercall_pcpu_arg(); + setup_vp_assist(); } =20 static void ap_setup(void) { setup_hypercall_pcpu_arg(); + setup_vp_assist(); } =20 static const struct hypervisor_ops ops =3D { 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); =20 const struct hypervisor_ops *hyperv_probe(void); =20 --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel