From nobody Sun Apr 28 19:51:08 2024 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=1577644492; cv=none; d=zohomail.com; s=zohoarc; b=Nn71FFoIbid2MoVuL/eO9u+xGPFrDSGbq57CbFbb5rSdaw+inji9CiP1XE8SJVZC6YWC/wHa3bh1bz0M+dSt/SIn2ay0JUVBVJ/K1m6oaGVI6hFqkI7NJ2UHkN3/QapU4w90/6mrvDA8cyo4xQIyp1bW+47293HlLdCibbCTDwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644492; 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=GLY91T4TpEz/BfE26lMEF6lpLTAKmpd8+irNnqten44=; b=Nvh20h7TDAi6RcZZCCs/ZitCidkOHxRFz/73gHwcPFb+ar9HvItUTZrw9Xlj4DCacEhA3jahPiWJe3awCi+iA+3f7Fn4wry/dAIZJPjnULifkrBRcf9MioMp9BJ778SgWKOfW9pjripAER6SCBYAIHjpHcMOKiOfJWCCGw7w8Xo= 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 1577644492334459.6897102802792; Sun, 29 Dec 2019 10:34:52 -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 1ildO6-0008No-4d; Sun, 29 Dec 2019 18:34:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildO5-0008Ne-41 for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:01 +0000 Received: from mail-wm1-x331.google.com (unknown [2a00:1450:4864:20::331]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c5358e60-2a69-11ea-a914-bc764e2007e4; Sun, 29 Dec 2019 18:33:56 +0000 (UTC) Received: by mail-wm1-x331.google.com with SMTP id 20so12569928wmj.4 for ; Sun, 29 Dec 2019 10:33:56 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:33:54 -0800 (PST) X-Inumbo-ID: c5358e60-2a69-11ea-a914-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=Lzk7QT42x4Bu7yTXlGHeGQsXy2o8S3NY1hIpuuMaZPg=; b=jzmrxNyKaQHHXZ7zCuNwtQhbfZZGjTRm2EojYXvM+qcoB+nBkzn5gEWIol77zJ/4gl hRXZnqwVYCkLWg9j2cyYTAp9Zf2UTVN61Rwsu4u45uvUvT3m1wiu4gB7epwC/xo7s6f7 cq+wv5GnLVt1avr62Zx1Ywuyq0auGOEQKWwF3yFR8pwFQzKI5voOxsgp8c2Uqh8+kabs 2R0Pr78L/+0k13w4AbWENQW2apTT5S4/XbTMihHXDf7Vz1aDXUkkmhjSQmNzBbEw72Gn PAnbcRuePpaER21rP9tIj7LbLCsxwt7a9RDB4UkWpA7+ehE9ToKmw2qluUo1uFuS4GXw XfVQ== 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=Lzk7QT42x4Bu7yTXlGHeGQsXy2o8S3NY1hIpuuMaZPg=; b=qiXyY5twMj+OMvueAW49LzX/Kaj4Qx6Fx3uubvACY2eo4inhyFD9gk6yX37qAUs7sq Ur9JmFENsElXVAdzTfEa+KN4PlUktft037a6X9DaWy1l6XU2znPWPm5PMD/mA5jAjblX fGOBPBJZxv1Z4z2+GoiqQMYmck2A8Q/3uNSehlFIYSYgEB5omELknvKPvAmJDb2pRH/+ F6DhMEMUg/qbeCdO5N5wHaX5zjmR9ZsUbkc7PZ/heJFQkxeNf3YeSTc90ozrtz+aOaEW uzi3hugQC1PZLjzsX3rse0xG449mxXf2a4Pl8djutoiqTK4KME4LXk2DB3uHNmox2Fb9 wgiw== X-Gm-Message-State: APjAAAXlzDxWUDiUaMrzCs1UqdroD5Js5UVcGP4ighZCPslY0yIQelPz ntVAqvZN7R2GdXSOlNQ/Z0ajUrY9toM= X-Google-Smtp-Source: APXvYqw+CyT9N157GmEJ+JKv8Mub8BdU1g9V6Edu2xw7pljK08sfuhP4NowP1K84gxRwVCr34s+jYQ== X-Received: by 2002:a7b:cbcd:: with SMTP id n13mr30034816wmi.104.1577644435103; Sun, 29 Dec 2019 10:33:55 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:34 +0000 Message-Id: <20191229183341.14877-2-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 1/8] x86: include xen/lib.h in guest/pvh-boot.h 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) It needs ASSERT_UNREACHABLE. Signed-off-by: Wei Liu Acked-by: Jan Beulich --- xen/include/asm-x86/guest/pvh-boot.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/include/asm-x86/guest/pvh-boot.h b/xen/include/asm-x86/gue= st/pvh-boot.h index b8a76c4eed..48ffd1a0b1 100644 --- a/xen/include/asm-x86/guest/pvh-boot.h +++ b/xen/include/asm-x86/guest/pvh-boot.h @@ -30,6 +30,8 @@ void pvh_print_info(void); =20 #else =20 +#include + #define pvh_boot 0 =20 static inline void pvh_init(multiboot_info_t **mbi, module_t **mod) --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 19:51:08 2024 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=1577644490; cv=none; d=zohomail.com; s=zohoarc; b=M159Hbz+VD1JRABcKHP9NxsGqVqHdNnNGnREX3Mq0NYg1F+ue6ooFaJtpwAB+BbJliuPx/pilFY0l3E9gqj8ygbssZx4ORF67BtKqRYKBfamSWhdVUHcWmmayvvj3I4tA0pAf3j0zcYHwG5GJwVy5ajcoxnNfiPbsdQpejWTzSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644490; 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=05+f0khf6GOPWBUHITDzhcXEpuSMcLKA0KrF/yR/0Ro=; b=e7aIDRjMP552s6/8cgH+FMiWjmd8d6EnW4z1YA4BdEYLKMDeN1M3/MxA3G/EzJWoDwuLfkDc7RxuPqRlpwhMb6DbWXXuGiPe8nASSxZcYFio1t8YgIk+FveVZKZtix4jT9EBvgzsyVjpkAMhZIvh3qD1HWZ4HAb7aV5rsQ22nqY= 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 157764449013121.380804617142303; Sun, 29 Dec 2019 10:34:50 -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 1ildOB-0008OP-DO; Sun, 29 Dec 2019 18:34:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOA-0008OC-3t for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:06 +0000 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c5bc2eb6-2a69-11ea-a1e1-bc764e2007e4; Sun, 29 Dec 2019 18:33:57 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id j42so30877131wrj.12 for ; Sun, 29 Dec 2019 10:33:57 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:33:55 -0800 (PST) X-Inumbo-ID: c5bc2eb6-2a69-11ea-a1e1-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=+T4GPsHUk9nuxqbVFm0EUaUmXOk2IzXkX+VVh/krqzU=; b=OU+4AHjqz/NAKuZI3VYv8fyUs7tnmNWY1e9EXbF6UpTk/q2Kfpj269wnHzHBSi+Ov8 ROJUPsowviVzxM2Pu3ThoKMOA60tSwm8xz1N5oby3XI3gx5viA4E+2eIYj52kFDDUs+M 4p8bKS1wStvjFBb/EuIHUI6ozSo7zfsmAu5ULUytySrLLQyAVzzOx1GCBHp5+ONNut7b BnmveNOhkmTjWSIOgd17iBaZq9KSEfNXHzld1Pu0yp89owZmjYfLVqoWrbz7C9jxqd8A 13mGnebQd84Cdeu5pUPBdpusgj+fGPAkcqUE/t4LGqD0/zvX4YXcsrBgrs1+NEjfJyow qE+g== 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=+T4GPsHUk9nuxqbVFm0EUaUmXOk2IzXkX+VVh/krqzU=; b=pSEtyzsj/JH181F0SLHoBcV+lLp2bP4IzM7445regXASklLy/MXNAhrV/S+mGRu7BQ 2pMNehYpEqSPTqWN5zbxJgI/bWxKCvm9jYRfZUpzhW+Xm9QipgyfwXm+XNVZfU7EIMhe CZK8oJo3kQSQr4HbIpfBu4uCaElOiXIKlgn8srVi+sWEuewcBFTMWX7R7jk5vwrU9k2A 4G48jeu1duqZo2T9Sp+U/0rATv/6dK5MRPrbPv+NEo+nTgqICX6Gm9BGXDl8buPKXt8J 5xdUydTAtM1avrJ70XE6f0dRRCfVTjTUEZWIqyAVscQ+6mzmf7PQJ2NnIpuatUdMknQ/ xiTA== X-Gm-Message-State: APjAAAXJTzEZn8pm19vVqGRhVkSJasjKx1/4ujW6TFmUcLrLuhDmM4mj PNXnRNM1t4+qAX51ZJ8MEux9cdmtJlQ= X-Google-Smtp-Source: APXvYqw/YO/cDA3aZjfUEK+TEYTaZtNX+da0gMiZ1nJY681tg54LCSdhDnn212HH0uMckb6WNMu+Iw== X-Received: by 2002:adf:90e1:: with SMTP id i88mr59664807wri.95.1577644436007; Sun, 29 Dec 2019 10:33:56 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:35 +0000 Message-Id: <20191229183341.14877-3-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 2/8] x86/hyperv: detect absolutely necessary MSRs 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) If they are not available, disable Hyper-V related features. Signed-off-by: Wei Liu Acked-by: Jan Beulich --- xen/arch/x86/guest/hyperv/hyperv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 2e70b4aa82..c6a26c5453 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -32,6 +32,8 @@ static const struct hypervisor_ops ops =3D { const struct hypervisor_ops *__init hyperv_probe(void) { uint32_t eax, ebx, ecx, edx; + uint64_t required_msrs =3D HV_X64_MSR_HYPERCALL_AVAILABLE | + HV_X64_MSR_VP_INDEX_AVAILABLE; =20 cpuid(0x40000000, &eax, &ebx, &ecx, &edx); if ( !((ebx =3D=3D 0x7263694d) && /* "Micr" */ @@ -57,6 +59,15 @@ const struct hypervisor_ops *__init hyperv_probe(void) ms_hyperv.max_vp_index =3D eax; ms_hyperv.max_lp_index =3D ebx; =20 + if ( (ms_hyperv.features & required_msrs) !=3D required_msrs ) + { + /* Oops, required MSRs are not available. Treat this as + * "Hyper-V is not available". + */ + memset(&ms_hyperv, 0, sizeof(ms_hyperv)); + return NULL; + } + return &ops; } =20 --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 19:51:08 2024 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=1577644492; cv=none; d=zohomail.com; s=zohoarc; b=jLwmuCe31vc/xdYUoW+2wZKrYfVxkTlEe0K/6FLkqbwpil1bXV+eabVFR0tdlNLnNGtkuJnmHkfLjqnInNNI1CAcZjxG7WKVYx//EKBQ00o/uwbl8GkZCFVEIcmEpSMFF/wbqcI5g03WodZ//yb3jpVxK59TtrudcADhypTTzs4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644492; 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=fgMj9Q6xjaY8XtR9JSO4vYi0yIM8rl/f0Kgee2Par1w=; b=I8FwcR5xDiu2NxOgckH1DB0XsiNFVLflKIMtJdDMaAxntxIdDOiZL/bNTWh6TWhU4ifZ4Wj8sv/oNxhGo9c+dtV5iqG/YRFv8tSyZRXX1+DCtbfRdYq7y1VgXvLs1DKzfy/KfX49apfYuTpzH7EWpDMKR7Z9O+uUIaW7KA37kq0= 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 1577644492704261.92087498071237; Sun, 29 Dec 2019 10:34:52 -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 1ildOG-0008PV-Mg; Sun, 29 Dec 2019 18:34:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOF-0008PB-4b for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:11 +0000 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c6344626-2a69-11ea-a1e1-bc764e2007e4; Sun, 29 Dec 2019 18:33:57 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id a5so12404050wmb.0 for ; Sun, 29 Dec 2019 10:33:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:33:56 -0800 (PST) X-Inumbo-ID: c6344626-2a69-11ea-a1e1-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=K1Ry921yr+IZa8O5IZElaz4gVH0PBJzo0v4gt3MXWag=; b=SxBaX5Oi99rlPTZQFBkh90vrNnjhJTR1dJ5bXy0x5rQE8VN5dpKYsmbNu2bwN4uPQ5 NeUr66ukvC6JCbZb74xxlVMGC1jT+NAl2jKEIreDKrqL/HEp6Za1EebszwcYDv4E7CLn g2RksYY45PIUSZiRw23Su05N/zc6Kj7KEEUTk6yuwKD/0d0s96Kq7Beb+Tyu1cnKUSdk SeQpMJg/RJoiByKIO493sfWLb5GWGcqJFka8s88wVUcT4EuUSGkeNUDtlIUnHz9zUqF6 9908bmFIqcOxGTWkvEIqPU9DlFPEeCpLv8NUGSN1b3u/xbv9uwJuPrx5TLRxl1KmwQZw p50w== 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=K1Ry921yr+IZa8O5IZElaz4gVH0PBJzo0v4gt3MXWag=; b=JS7L2V/fH36MNY8xpsc08PIa/VKdw19F9cvlaH4qVKi5UBLEmcrWyZxPH+eDC+dgUv V8LlrthnIfVWUOGKxZbNpKRZoOrMHE7j5vQ4xeSkjQh05c4mO2jhEFwF5ORTiG27Hqxc R59gXlhLBVnDLi1qxvR2x+/j85UgM2ruvd4SZVWurNb4DvV4zDBx8vWb1rtiDtjfqDrQ Vh62x6qEYbxrNcuTVNyLwi4Zs/OMGcgrQrr03B7Ts4tLlD6R9qZTCU5zwRQqW78jQ2tQ aVfqzFRGOKXcWrvySA89MzaDqTueiEzzVte/6NgvlTVTsu2z1lIqgyucf+5nNOb139Iy u/aQ== X-Gm-Message-State: APjAAAXTK9DC+XsdvRnb6rPVvJqOeBjZSePTMDh05lz5UEbpvxCHS0F2 ATadLDpVsyOyyFy9Yk4S/47/fFaAcGk= X-Google-Smtp-Source: APXvYqwp/gfQzxhMttTf34WHAy7Q09gBFru8baiBnlmuTgG6CHkRNLWmp1cEwn/3fJ/AjBwj1mrDhg== X-Received: by 2002:a1c:7203:: with SMTP id n3mr28829827wmc.119.1577644436910; Sun, 29 Dec 2019 10:33:56 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:36 +0000 Message-Id: <20191229183341.14877-4-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 3/8] x86: rename guest/hypercall.h to guest/xen-hypercall.h 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) We will provide a header file for Hyper-V hypercalls. No functional change. Signed-off-by: Wei Liu Acked-by: Jan Beulich Reviewed-by: Paul Durrant --- xen/include/asm-x86/guest.h | 2 +- xen/include/asm-x86/guest/{hypercall.h =3D> xen-hypercall.h} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename xen/include/asm-x86/guest/{hypercall.h =3D> xen-hypercall.h} (99%) diff --git a/xen/include/asm-x86/guest.h b/xen/include/asm-x86/guest.h index 94448606d4..7f09c643d4 100644 --- a/xen/include/asm-x86/guest.h +++ b/xen/include/asm-x86/guest.h @@ -19,11 +19,11 @@ #ifndef __X86_GUEST_H__ #define __X86_GUEST_H__ =20 -#include #include #include #include #include +#include #include =20 #endif /* __X86_GUEST_H__ */ diff --git a/xen/include/asm-x86/guest/hypercall.h b/xen/include/asm-x86/gu= est/xen-hypercall.h similarity index 99% rename from xen/include/asm-x86/guest/hypercall.h rename to xen/include/asm-x86/guest/xen-hypercall.h index d0d2f5022d..681d3aecd7 100644 --- a/xen/include/asm-x86/guest/hypercall.h +++ b/xen/include/asm-x86/guest/xen-hypercall.h @@ -1,5 +1,5 @@ /*************************************************************************= ***** - * asm-x86/guest/hypercall.h + * asm-x86/guest/xen-hypercall.h * * This program is free software; you can redistribute it and/or * modify it under the terms and conditions of the GNU General Public --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 19:51:08 2024 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=1577644497; cv=none; d=zohomail.com; s=zohoarc; b=PIVgq0OfM1wUJOaa/kKdJFWwFNWGeqADjRVrUStu0uw979tdpNxkK2cL9M9lS1PnVGcX/91TB1zE2iE4pVuV+Xi2NpGGNMQpoYXlw/F18OWv4vlbEzWlCegi/aEMoECfi7aWb+AgIAc6a11E+cFEGHK0SitVTW+hHf2JsVozlfg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644497; 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=nIzNCe7SFo3pVMcFkMdwOCymPi5HRo0AxegpKTtC/O0=; b=NYZu2989bsxHpxPDqafvhmdBm2C93m7EtAA1nqLoVfV2spX2LgGjp94IpKXavp1mHNMFaYoNi6PPHYsD3CNLaZtqnSvYGpa3tNr0FVnLEX8V8E8apsaN62ytHWNzHwxuiIQDYJoKUXE46aD+CDUO1R3y8CZzKNTJZLPcp9ycO5c= 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 15776444978081003.06625991494; Sun, 29 Dec 2019 10:34:57 -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 1ildOK-0008R9-W0; Sun, 29 Dec 2019 18:34:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOK-0008Qq-43 for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:16 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c6ba7d36-2a69-11ea-a1e1-bc764e2007e4; Sun, 29 Dec 2019 18:33:58 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id t14so12582604wmi.5 for ; Sun, 29 Dec 2019 10:33:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:33:57 -0800 (PST) X-Inumbo-ID: c6ba7d36-2a69-11ea-a1e1-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=yUTd1JvE33R5YeeJoO6ibJUr87M2fq2cnap5F1T4Coo=; b=Wm0uGfM6hWk8ZafajtIAZFnjIh6xQ1k4yOyITXMZLz1rWcp7VujvIHAiyj+Zlvh8PA x8um2YQWFzgbKiQsD89HIdzqWuRYu+2mLkwMNPmt8u74DbLJcyVYVtV+aRuy5PPHPyYX xDjts14mKc2dtohOz5TRSyvcpc+oIu1mCqSaLpu7CCxzMqiWk6iaGxs7c4paIc+2iIZS OoEOqYF7C+qg8Py2/GHARXGErInL+YJroGTmL3xBZVwuMnBqn2bWPejpVMMtEEhsXLBg FZYh4QlPZF6Eucdo0yC5AFTAGKTnJGp+K8Zcd5bTUIj0WNsgEivwlU1JzTj6FsxCfB56 uv/A== 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=yUTd1JvE33R5YeeJoO6ibJUr87M2fq2cnap5F1T4Coo=; b=TBrwjfdt/BC4APCbb9Gs1xYxF2AUhklSQNA+u2FBKWbHymjHMQLGbNvdd1AW095txT lF2aw5uMMMqvYPEULoAWAlQKLm87m8D93T5hvO7QqdGtI/Zqadu3Faal0kVPaoJtxEOi bwQSf1icDMNGoZ/1YX7REBuCmtxZ3+T1P3g6wvUY7osmvCm7Qnzv7T/08OqDbYrDxp9d Oag0HalVAUPg4YYTiNrkienQjlEhO6HMf4R2zwRSorEbSVTBSM0D5Nkoc5eju61TYJGQ Vnz7aiTRN4OFbviNdgRkYbXSU0BuqzSUadz0TpLSyJpFwEo1iiBhLXBBgCSXuGW+7Kiv zSfg== X-Gm-Message-State: APjAAAXkgwt1xpTXRzwatB2RcIsmdC6OES0BPpReL77Pm61fOZ8KYl/w rwKvBJdJ6J5CHKBr7y/Ov7s222JCCH0= X-Google-Smtp-Source: APXvYqxvZHLSgFp1w4L8h63Ft9w6NohjU7jzmD9SL+fwvxhj1RPLSp7MME6k71NQVXZLFxYklWeFpQ== X-Received: by 2002:a1c:3189:: with SMTP id x131mr28988125wmx.59.1577644437764; Sun, 29 Dec 2019 10:33:57 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:37 +0000 Message-Id: <20191229183341.14877-5-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 4/8] x86/hyperv: setup hypercall 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) Signed-off-by: Wei Liu --- xen/arch/x86/guest/hyperv/hyperv.c | 41 +++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index c6a26c5453..438910c8cb 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -19,16 +19,17 @@ * Copyright (c) 2019 Microsoft. */ #include +#include =20 #include #include =20 struct ms_hyperv_info __read_mostly ms_hyperv; =20 -static const struct hypervisor_ops ops =3D { - .name =3D "Hyper-V", -}; +void *hv_hypercall; +static struct page_info *hv_hypercall_page; =20 +static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) { uint32_t eax, ebx, ecx, edx; @@ -71,6 +72,40 @@ const struct hypervisor_ops *__init hyperv_probe(void) return &ops; } =20 +static void __init setup_hypercall_page(void) +{ + union hv_x64_msr_hypercall_contents hypercall_msr; + + /* Unfortunately there isn't a really good way to unwind Xen to + * not use Hyper-V hooks, so panic if anything goes wrong. + * + * In practice if page allocation fails this early on it is + * unlikely we can get a working system later. + */ + hv_hypercall_page =3D alloc_domheap_page(NULL, 0); + if ( !hv_hypercall_page ) + panic("Failed to allocate Hyper-V hypercall page\n"); + + hv_hypercall =3D __map_domain_page_global(hv_hypercall_page); + if ( !hv_hypercall ) + panic("Failed to map Hyper-V hypercall page\n"); + + rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); + hypercall_msr.enable =3D 1; + hypercall_msr.guest_physical_address =3D page_to_maddr(hv_hypercall_pa= ge); + wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); +} + +static void __init setup(void) +{ + setup_hypercall_page(); +} + +static const struct hypervisor_ops ops =3D { + .name =3D "Hyper-V", + .setup =3D setup, +}; + /* * Local variables: * mode: C --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 19:51:08 2024 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=1577644500; cv=none; d=zohomail.com; s=zohoarc; b=afKNuG9tLdp40RxQ1mGwXiQ6hQrCznoyE+/Lw3u35RUzFCkNjMwTH8+ey+ukaN/03WnX5sVN1diEBeRIBfnsQPX1mm8k2RexwNNqV/1NctpHlB3zSEjhSp2otwz9xA+bbXHtzhuSNobY8GKy0XeKhFI5SsyRRRMZXLf2em/YmW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644500; 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=tbqxLOGrtht4qnjEQaRFF6MumDCmUfHi0bJWGnEF96Y=; b=EO8Tu7mCxx2rAyjyWsvi28AjIiUUP6Ga0Ak888F8G13L5RR31GeKZ/VMeMRdyjhyoHL6WAYq2PivDEw++iMw6Ew5hvBNKx2HN7wSSxLOp6IDyV0d93Tr6T9/NEPyzbsQddWaMJbqibrjs7N5ifW3tN0JC5d1sC0Yd+pYvLdOAzU= 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 1577644500417225.97678836727414; Sun, 29 Dec 2019 10:35:00 -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 1ildOQ-0008TC-9e; Sun, 29 Dec 2019 18:34:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOP-0008Sd-3s for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:21 +0000 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c73e166e-2a69-11ea-a1e1-bc764e2007e4; Sun, 29 Dec 2019 18:33:59 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id u2so12582280wmc.3 for ; Sun, 29 Dec 2019 10:33:59 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:33:58 -0800 (PST) X-Inumbo-ID: c73e166e-2a69-11ea-a1e1-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=asb9o+xNQOO3u3ZzsBKwpRrK8IPM5jQNg7xWqM9F3KI=; b=JgLyZz0TTlhU4o9sVht7VWWxB4MwDi78qPrKGJnxkdr84WHBeGEzsRQZ3n2vC+enLl 3A2yLT0aTPK8EUhUT1rer7u8iCyYG79xvZvq5DcoiRMsx7wAuYHbDyRJBmuaWcSIHdom TITyQMSlhqyECseyN4dbX3SJzK+leuMLzNKp9UiUAk0X3S6ptqBJ8wKZn6Q7XblVPnE1 zHFWeZIh8IUZGvmtxNWj7ZH9NdEKr8U6MsPy1QQhmTnuinOBFgKbPl1QOUqEGttQUwkE hhsOPHNcKyFrlBsD6kdJ6G7BI30ftu5J75l40nyK0bD1eTX2PZZ+LibszBKLR2wns0yV KPYw== 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=asb9o+xNQOO3u3ZzsBKwpRrK8IPM5jQNg7xWqM9F3KI=; b=IefAebYaNMN58zBdYtUjXW8tVRfjNv4UO/G/sNqs9Tb5L+QqglaUvP/J89mS2Ftsiv 9Drz753tf4FuXqVotXm0l/FcZqvs86zMmhh56rUTGG5Wt29edjmVqxFEuMDimDzKp7Y+ fzGFGl9rIy9yoVdmUH98Yw4GYFSRbRbtTztt9bWvEfkl5SC5d4ulTL+G6IQP3lrV6ZtB jt3+SjjU5TN7BoZya6INrs2Ga+1ETzPHQnT4lbPTkFNTODKKDQfW98T1cUq5RcpIYxGy DSO9tL/lm3VbYmpFdZ1/c9IsNrLCxvSUjjGI0pmGxt1kNfY7ZsITXiRXhtkWSaxDzFf7 NqVg== X-Gm-Message-State: APjAAAWWAlIZALjFxnYUfknEFAaqIS9WzHtttg4xwxIIfrvUF6wrL3c+ 0ULdWzyY8TrO0knPqQs+t8eYuIUOm74= X-Google-Smtp-Source: APXvYqxK16Szy+NwFppVU3dxWcnXH2X9+bWRzo14fFbTnWTN3tHw1swQbWvNuMmBQJqcKyb4HC023w== X-Received: by 2002:a1c:4e10:: with SMTP id g16mr29792019wmh.94.1577644438582; Sun, 29 Dec 2019 10:33:58 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:38 +0000 Message-Id: <20191229183341.14877-6-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 5/8] x86/hyperv: provide Hyper-V hypercall functions 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) These functions will be used later to make hypercalls to Hyper-V. I couldn't find reference in TLFS that Hyper-V clobbers flags and r9-r11, but Linux's commit message says it does. Err on the safe side. Signed-off-by: Wei Liu --- xen/include/asm-x86/guest/hyperv-hypercall.h | 105 +++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 xen/include/asm-x86/guest/hyperv-hypercall.h diff --git a/xen/include/asm-x86/guest/hyperv-hypercall.h b/xen/include/asm= -x86/guest/hyperv-hypercall.h new file mode 100644 index 0000000000..6017123be5 --- /dev/null +++ b/xen/include/asm-x86/guest/hyperv-hypercall.h @@ -0,0 +1,105 @@ +/*************************************************************************= ***** + * asm-x86/guest/hyperv-hypercall.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + * + * Copyright (c) 2019 Microsoft. + */ + +#ifndef __X86_HYPERV_HYPERCALL_H__ +#define __X86_HYPERV_HYPERCALL_H__ + +#include + +#include +#include +#include + +extern void *hv_hypercall; + +static inline uint64_t hv_do_hypercall(uint64_t control, paddr_t input, pa= ddr_t output) +{ + uint64_t status; + + if ( !hv_hypercall ) + return ~0ULL; + + asm volatile ("mov %[output], %%r8\n" + "call *%[hypercall_page]" + : "=3Da" (status), "+c" (control), + "+d" (input) ASM_CALL_CONSTRAINT + : [output] "rm" (output), + [hypercall_page] "m" (hv_hypercall) + : "cc", "memory", "r8", "r9", "r10", "r11"); + + return status; +} + +static inline uint64_t hv_do_fast_hypercall(uint16_t code, + uint64_t input1, uint64_t inpu= t2) +{ + uint64_t status; + uint64_t control =3D (uint64_t)code | HV_HYPERCALL_FAST_BIT; + + if ( !hv_hypercall ) + return ~0ULL; + + asm volatile ("mov %[input2], %%r8\n" + "call *%[hypercall_page]" + : "=3Da" (status), "+c" (control), + "+d" (input1) ASM_CALL_CONSTRAINT + : [input2] "rm" (input2), + [hypercall_page] "m" (hv_hypercall) + : "cc", "r8", "r9", "r10", "r11"); + + return status; +} + +static inline uint64_t hv_do_rep_hypercall(uint16_t code, uint16_t rep_cou= nt, + uint16_t varhead_size, + paddr_t input, paddr_t output) +{ + uint64_t control =3D code; + uint64_t status; + uint16_t rep_comp; + + control |=3D (uint64_t)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET; + control |=3D (uint64_t)rep_count << HV_HYPERCALL_REP_COMP_OFFSET; + + do { + status =3D hv_do_hypercall(control, input, output); + if ( (status & HV_HYPERCALL_RESULT_MASK) !=3D HV_STATUS_SUCCESS ) + break; + + rep_comp =3D (status & HV_HYPERCALL_REP_COMP_MASK) >> + HV_HYPERCALL_REP_COMP_OFFSET; + + control &=3D ~HV_HYPERCALL_REP_START_MASK; + control |=3D (uint64_t)rep_comp << HV_HYPERCALL_REP_COMP_OFFSET; + + } while ( rep_comp < rep_count ); + + return status; +} + +#endif /* __X86_HYPERV_HYPERCALL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 19:51:08 2024 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=1577644504; cv=none; d=zohomail.com; s=zohoarc; b=AtHVUULVb75EdQyrMEiFObf3wVO9a6phYthuHR8jJjSw604Ud1b+mSVAZd+ALOIdncPixjHmA0+XuDXrUwitX3XmMyywfcB1spM6v3U+lAixYq8+nsOhz8SYtuE8Mn4sovGg3AStKQb8Q3sWfDe45xPljgmapIM6W/T4prpAUCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644504; 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=xT7GIe10mkakNNAHfsEvlkPN4u6IYmuqIr88+BQGevo=; b=TWjzrYhub+hVK7s9l9/lBHpcqU3onwdDT1p/0ZzLYqrINUnDyEjIJcLyhheiEaKmm6gWOU5gIXP+tn6UGzivNmsVADQKhJPyGC8R8FbBi1gX5xYtztDc2uIFHMyC1mjOXXND4Osh/xkuR5it8+UIOo1EIJRQo63uqHygLhX9Qtw= 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 1577644504519444.6221363758568; Sun, 29 Dec 2019 10:35:04 -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 1ildOV-00005p-Od; Sun, 29 Dec 2019 18:34:27 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOU-0008W9-4X for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:26 +0000 Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c7d4fbc4-2a69-11ea-a1e1-bc764e2007e4; Sun, 29 Dec 2019 18:34:00 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id d16so30908595wre.10 for ; 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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:33:59 -0800 (PST) X-Inumbo-ID: c7d4fbc4-2a69-11ea-a1e1-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=StyhxDStPdtUMfRwKkbsK2BEaAdOM3U2G5Vjbak1HKc=; b=ad4ZNFkXeZ49oe7phaJulphqWcCrj4QvF3WlthAxXUijKDxuqAv8jxfkgl10R+5ZwR f/OEDDRYgkOXk/+3m7qZRC8BjTXF7mCl8pDBiN/W9SR7Ub9XL3K3o1DeovbzTJaISWIP m1mnmN41TqaDhGmJex9zf1rUQZ73T9Ir66b28uvUJv7WxUCPqw60EzRYc2iwZum2A7FN /4J+kwICeFXRn4m32HApaKIYRQY/lm9usJ6BPhZwoAbHfmyKIt5NcFFDqi3e3SNtGRU/ Id2vGL30pSA6rWrMq9vx/ceYT6dQWXLV3XoEMLHR1f6KfXSEYPDgGKHmXrkO3w8ZnSkF 09fw== 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=StyhxDStPdtUMfRwKkbsK2BEaAdOM3U2G5Vjbak1HKc=; b=T0fbyzB7XClleShFxkAE97gLJ50slSJ5Qsx7L3MaryYGxbwBxY2l/sO8spX5SSgNo6 xNkc8/RcpVDgx6ia5QgM96Oqq8Jvv4+3JVfIWMUt6mdgY1B95PQjOi7X8Opd4Coq0PTY 9+3dyw4qiD73oHP1EBGrPmuSrR5OTEhXFq4ak+0OXRvJKFSj9AciLUIYCReU5mLALCEN BT0kAtO1EOhr+SUaHky0ggephLB1IfXgZIDppFk4CX5ov4Dxja/sJJUib1hbAQ0K2d5C Fvq3HKKIAS7gLi2aFOLhZieXor3SHfRnLmw7CADePL12lS3GvN50HtZNx47vlp3jVNbT jfkQ== X-Gm-Message-State: APjAAAW1b0MXoV7Ma9MC8qXT9uBQoSlLVpyzYZyGiuNjPkLnH78rGvTY nmtU3FEs24nfm+IfV66k2zz+X/rC5sA= X-Google-Smtp-Source: APXvYqybCE4wFqLyTxmwqM75QIH48UygDKWCpeGYtU6iBh75gnOTS7eiDr1jRKDjZNqlxesQ+3JBZA== X-Received: by 2002:adf:ee45:: with SMTP id w5mr60470220wro.352.1577644439429; Sun, 29 Dec 2019 10:33:59 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:39 +0000 Message-Id: <20191229183341.14877-7-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 6/8] x86/hyperv: provide percpu hypercall input 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) Hyper-V's input / output argument must be 8 bytes aligned an not cross page boundary. The easiest way to satisfy those requirements is to use percpu page. For the foreseeable future we only need to provide input for TLB and APIC hypercalls, so skip setting up an output page. The page tracking structure is not bound to hypercall because it is a common pattern for Xen to write guest physical address to Hyper-V while at the same time accessing the page via a pointer. We will also need to provide an ap_setup hook for secondary cpus to setup its own input page. Signed-off-by: Wei Liu Reviewed-by: Paul Durrant --- xen/arch/x86/guest/hyperv/hyperv.c | 26 ++++++++++++++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 8 ++++++++ 2 files changed, 34 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 438910c8cb..67667936e9 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -28,6 +28,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; =20 void *hv_hypercall; static struct page_info *hv_hypercall_page; +DEFINE_PER_CPU_READ_MOSTLY(struct hyperv_pcpu_page, hv_pcpu_input_arg); =20 static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -96,14 +97,39 @@ static void __init setup_hypercall_page(void) wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); } =20 +static void setup_hypercall_pcpu_arg(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 setup hypercall input page for %u\n", cpu); + + mapping =3D __map_domain_page_global(pg); + if ( !mapping ) + panic("Failed to map hypercall input page for %u\n", cpu); + + this_cpu(hv_pcpu_input_arg).maddr =3D page_to_maddr(pg); + this_cpu(hv_pcpu_input_arg).mapping =3D mapping; +} + static void __init setup(void) { setup_hypercall_page(); + setup_hypercall_pcpu_arg(); +} + +static void ap_setup(void) +{ + setup_hypercall_pcpu_arg(); } =20 static const struct hypervisor_ops ops =3D { .name =3D "Hyper-V", .setup =3D setup, + .ap_setup =3D ap_setup, }; =20 /* diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest= /hyperv.h index c7a7f32bd5..83f297468f 100644 --- a/xen/include/asm-x86/guest/hyperv.h +++ b/xen/include/asm-x86/guest/hyperv.h @@ -51,6 +51,8 @@ static inline uint64_t hv_scale_tsc(uint64_t tsc, uint64_= t scale, =20 #ifdef CONFIG_HYPERV_GUEST =20 +#include + #include =20 struct ms_hyperv_info { @@ -63,6 +65,12 @@ struct ms_hyperv_info { }; extern struct ms_hyperv_info ms_hyperv; =20 +struct hyperv_pcpu_page { + paddr_t maddr; + void *mapping; +}; +DECLARE_PER_CPU(struct hyperv_pcpu_page, hv_pcpu_input_arg); + const struct hypervisor_ops *hyperv_probe(void); =20 #else --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Sun Apr 28 19:51:08 2024 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=1577644511; cv=none; d=zohomail.com; s=zohoarc; b=WSc0IikiqisTQkDVwXaH8W4MdinVbBcwV7bihw4f2/fD1JAokYMef6ZxsjqjnM2kg5QlxNiRKeqtQzSSRYTv7fZRlYz9AKvN/N52iML6O98Y3riixHOX91v2Q5xi9jVxnXvT9uGfEi99BXMIyCmz/LnWB6tSQp29rDBEHJyP9mY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644511; 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=VvobyzF525iGBPdp52aXQ5GV0EhAZkEXlYT/1ScskkY=; b=TX4daZS0cBB95smf9727tU6cPVpW4Qy55wk1mtnlMtoM6NeWz6uhyv1vKXW6bpoNYU08Pel2dNE/PJWJ/c7TlMxNXIM/zP4LujOL0UY8Fxll6e5c8ZEUXLHmQBdkWHOT6b4+G1Zd8f9n4NYE7EACRZZbMMiHvH4jWAaPAsCsw0M= 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 1577644511758606.0210446688178; Sun, 29 Dec 2019 10:35:11 -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 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 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) 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) X-Inumbo-ID: c84d13c0-2a69-11ea-88e7-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=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) 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=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) 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); =20 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 =3D mapping; } =20 +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) =3D vp_index_msr; +} + static void __init setup(void) { setup_hypercall_page(); setup_hypercall_pcpu_arg(); + setup_vp_index(); } =20 static void ap_setup(void) { setup_hypercall_pcpu_arg(); + setup_vp_index(); } =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 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); =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 From nobody Sun Apr 28 19:51:08 2024 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=1577644516; cv=none; d=zohomail.com; s=zohoarc; b=cagiMNX0+HDMy6hOiLCEtRyjRNAs00gyu8BaBGtMTg0VrBoxZ/m/2UqYjJbAS0jmwz4WEfwBu0IXXqm5inJmqQZRqemXCBdNTDSsTNvipCo8Z61ySAsHLYaUI3KEvDprwUuvNmgDy9KFFMVdjGZo5VAQ54Sf7NcbbE9pJkXh4Cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577644516; 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=PGV0WzTnXsPtBlqQ3UI3v/WABXwbLAucifFI9ICWwv0=; b=hd2/HeiTkJqNExN31MXE9wMvJ6C6I6IPw6TgHPGDvgExFx8EqtEF+t5AQiBKRw1AvycxEF4uQmhS6WgQnwY/A9XGQ9mSlKFhtZsZC3gqICcfFX6J+LS3f138ZGNTMooCvCNZtBOaZG0UNMIBZ5hdMcPPc+QUbV6gO1gBuuKOvUo= 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 1577644516533665.7646654211949; Sun, 29 Dec 2019 10:35:16 -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 1ildOf-0000DK-EG; Sun, 29 Dec 2019 18:34:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOe-0000CJ-5K for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:36 +0000 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c8ce5a2a-2a69-11ea-88e7-bc764e2007e4; Sun, 29 Dec 2019 18:34:02 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id b19so12372785wmj.4 for ; Sun, 29 Dec 2019 10:34:02 -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.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:34:00 -0800 (PST) X-Inumbo-ID: c8ce5a2a-2a69-11ea-88e7-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=3d0oAYCyKACs7Jy203uplvN0cNjl3u8rMIY3VL6ToB4=; b=Sd5UeMLWT/ULhIt8rsmXOfpj1l/hPLNOYGjd7XhnZ65OnTkhbxpsScWPgkWybcN6CK tU/eTPQkjAnLHePBhkZqSLBN0TDaqmC7e+mjgbWNHyJ/2SbRnwq0TZoDtXSsXonz9IEt vX6u06amFCuiYqHY2waJ0+7Q9xFruNt2z1GSR5gH1f6EEoDeTIWCyHIa/DLY6b5N51Y9 Qa81e4c+m14uHpU0+cqMYmhC9y4GYbgtirmSFr8VOdMROw4SWcZamUctlPP8Bqnrtkb5 3+e9x3B3murU62Ht3bObs12QElYJOyE7Ts8ZllFSDyUDzLjwPJ6V2HL/KVfzH2IlkoxJ oHfw== 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=3d0oAYCyKACs7Jy203uplvN0cNjl3u8rMIY3VL6ToB4=; b=axaCYO08On3duYJAC4916xkOEuTTxeyyUzurSzk/6/JBbM0uaZ+pHU3Vl6WNP/7uHn wnBrT9RDQTZsKjcS+BklyXPYbuXc1pQ93XeMoOZdON5QWNDyzWfcRaSR65AQmNyyqtpx AGDYe1vYf5WXH19EzCH5ptD/DGWNCE0Vm2QG7jqsXf702Av43nLWO3ihN9eUPzlaSFaG j4s6jBRvNPYbEfCcQrLPsPG5OpvaFchmQrBQs37MYw513nWaxaKde5A6WFoNG8sTQubt ygDa8s0KtyCS5q1BTuFg+JEtf7isqrALF+u2yGWOv6klCL4eQ2HhvV/9iwNVaU4VjwFM lWfw== X-Gm-Message-State: APjAAAVoR59zAhou2/F4N5MOS/d/Ul4mFoTKCXPm2dZvcytULgk/8cTI eh8MW+Wh+XwsxCtvhqaR4xLJsVwC/Gw= X-Google-Smtp-Source: APXvYqyrf/tgheg5khGn4qrLjdxD4PqIp9ePYibVwAtbgqUC8fVlrdP0wLyJAoQCOpH/YXW+MITFfw== X-Received: by 2002:a7b:cfc2:: with SMTP id f2mr28916093wmm.44.1577644441234; Sun, 29 Dec 2019 10:34:01 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:41 +0000 Message-Id: <20191229183341.14877-9-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 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 that page such that L1 guest can make hypercalls directly to L0 Hyper-V. Preemptively split out set_vp_assist page which will be used in the resume path. Signed-off-by: Wei Liu --- xen/arch/x86/guest/hyperv/hyperv.c | 35 ++++++++++++++++++++++++++++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 36 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index da3a8cd85d..a88b9ae6d9 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -30,6 +30,7 @@ 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); +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) @@ -125,17 +126,51 @@ static void setup_vp_index(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_X64_MSR_VP_ASSIST_PAGE_ADDRESS_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_index(); + setup_vp_assist(); } =20 static void ap_setup(void) { setup_hypercall_pcpu_arg(); setup_vp_index(); + 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