From nobody Mon Feb 9 07:55:50 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=1579724693; cv=none; d=zohomail.com; s=zohoarc; b=gw4KDgPcW/nob8xL9BXNigScH/GoEfAyJjazY442PgQKhqN6aOvJsr/VJ0W0XFsYkqT4YkzhSI5W85hXZRQ4l2VhL/6seK1z6YTlg+xopd6eTf8uUjQ5kI4FqPy8izTJVuERFiM0rIglUDCxVQIVILWTTh54ZVLVEGVW9oh17Ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579724693; 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=69mAZVDGdcts5hGa2ocRhlWIx9jTtZT6bg5ZVw7mnNw=; b=HpwypgQQUeOS+5bINWrmQQdSI5HSqPLK4oNPuPtDzi7xq9WbCVX7mbApSk7A2oGOWEJsSgyolAVVJTdSGprCWCWDhDXTE7vI3Tzh91ygut3rONWrWTPAdtLulNPGmpk+cLtMddurpx/2cQSpZF4tWctvXHeElrvbWLL7t7+rcjw= 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 1579724693085359.06360958921005; Wed, 22 Jan 2020 12:24:53 -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 1iuMY4-0006RO-I7; Wed, 22 Jan 2020 20:24:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iuMY3-0006Ql-1G for xen-devel@lists.xenproject.org; Wed, 22 Jan 2020 20:24:23 +0000 Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1bd0d312-3d55-11ea-8e9a-bc764e2007e4; Wed, 22 Jan 2020 20:23:54 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id w15so517542wru.4 for ; Wed, 22 Jan 2020 12:23:54 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id r6sm60267992wrq.92.2020.01.22.12.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2020 12:23:52 -0800 (PST) X-Inumbo-ID: 1bd0d312-3d55-11ea-8e9a-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=ljuvtGQ8FLfUz4xqMnHKyZjGxy69y+jnVAsAFm6RVds=; b=gtWqCrbHnArBT6pIE/e3Y59E1lIcOgMjtNLGL1C7YC42YtP68AF5M4BX6OCuElrzDZ Hrf/QYX18PFyL/bWd8GgoXfky6CXRkPqGZbmXgJ8kx7K5FH0i3aXpi3BYSAwW6+QdqDB eRQhsk/PYzUzkbEEV/TLKOHi10fDaCrESQDdJncT5TgyMIX4Ke2ZcV9gIZ5oLb5FUfYv yBtK0iMqxC10cyTQu8CsBulBx4JtLodzGHUJE20mN6iWDAUYzb7U9mk+LAZJqLZWXdWU Ba71w9stZVz5OJ5HtYKNqF16AoJIWLkgADxtW92ZoDBA70lFwfNkX6RIVv0PLJswqF1H OHIQ== 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=ljuvtGQ8FLfUz4xqMnHKyZjGxy69y+jnVAsAFm6RVds=; b=EcaGVcGtkZWB8BA2wyKtOIQ7ancTGx8X+nSTNiE32ASY17EUFYG4esB0gWjIPL31ax CwbjlYM6WibuQGpPf/hQ0GW1gSDZe5DxetjnIWtdGR3OyHhHd9qT/YeJqB87GZpugmUW NVkmgZTPJT9c2S+161ilGZLvx7s/E+weXGZZrVQgi3nGUdCF+vjjIDtBB9oO1dTS+TOd 6o8ZUItXmK9MqQ6KjW/pjd/9kYinX36fH8Ykkrpw7h1olc8QcgShc0qIwyGwYZHMezdM QA3x8FrjsSKgZb22BAtu7ziEuUX3R2hDffyr4QhCV8LZHtA5BRZvpiFkDPQy/OBF5G96 tdHQ== X-Gm-Message-State: APjAAAX3xPia5PziEnOksEpIvn3Fa+/0TFaSwfKUE7gg3M/yWr2qqvzX cFFMVRCAQTaL0kI4YLs54futBWWn7MPifQ== X-Google-Smtp-Source: APXvYqxPFih+zc1HHE4XDSBA6Wgr59+EAa8ucv5Qi9jgZF14d9ZZt7xwP2/sOF8TCZ+dbKmIGZUe2w== X-Received: by 2002:adf:ea05:: with SMTP id q5mr12536429wrm.48.1579724633088; Wed, 22 Jan 2020 12:23:53 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 22 Jan 2020 20:23:43 +0000 Message-Id: <20200122202343.5703-8-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200122202343.5703-1-liuwe@microsoft.com> References: <20200122202343.5703-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 7/7] 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 , =?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 it for efficient nested virtualisation. Signed-off-by: Wei Liu --- v4: 1. Use private.h 2. Prevent leak 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 | 26 ++++++++++++++++++++++++++ xen/arch/x86/guest/hyperv/private.h | 1 + 2 files changed, 27 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 085e646dc6..89a8f316b2 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -32,6 +32,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; 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); =20 static uint64_t generate_guest_id(void) { @@ -142,15 +143,40 @@ static void setup_hypercall_pcpu_arg(void) this_cpu(hv_vp_index) =3D vp_index_msr; } =20 +static void setup_vp_assist(void) +{ + void *mapping; + uint64_t val; + + mapping =3D this_cpu(hv_vp_assist); + + if ( !mapping ) + { + mapping =3D alloc_xenheap_page(); + if ( !mapping ) + panic("Failed to allocate vp_assist page for CPU%u\n", + smp_processor_id()); + + clear_page(mapping); + this_cpu(hv_vp_assist) =3D mapping; + } + + val =3D (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(); } =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/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyper= v/private.h index da70990401..af419e9d4b 100644 --- a/xen/arch/x86/guest/hyperv/private.h +++ b/xen/arch/x86/guest/hyperv/private.h @@ -26,5 +26,6 @@ =20 DECLARE_PER_CPU(void *, hv_pcpu_input_arg); DECLARE_PER_CPU(unsigned int, hv_vp_index); +DECLARE_PER_CPU(void *, hv_vp_assist); =20 #endif /* __XEN_HYPERV_PRIVIATE_H__ */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel