From nobody Thu May 2 14:03:58 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=1578067802; cv=none; d=zohomail.com; s=zohoarc; b=R4O/JCX0lXXoNwGqoaN0o8Jyi3GxdnA4uAW5QOfiSItwjUOecJXRGk3mS+gzuff4mcSftmlQJgxMgU1la7e7RwHydo1TIyOYz3KzDgzI17GBW1i43eY10a9b9190OdjIAA5Uf1eG6iYRFHpZHVw5dKHr9q3tc9ScXN+E31k+jgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067802; 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=cxTPxMQumaHIaTl73HwvaqdjZe8FytmQL597d9n/DnQdMkgJc3B5P22eMyHFwY4qu3vFgVQCnZJUgc61BFn/lKKsuHdbNaGgT1wi9R4hyR7TDjB4gjP97ERB+Ui7Ahs9I5f1jhbOs1arPyqYAYn6cPP9HWqLTkU38a7NYh0X6GM= 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 157806780282083.02913303156674; Fri, 3 Jan 2020 08:10:02 -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 1inPVX-0005RC-Al; Fri, 03 Jan 2020 16:09:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVW-0005R6-KU for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:02 +0000 Received: from mail-wm1-x331.google.com (unknown [2a00:1450:4864:20::331]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 58a495d8-2e43-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 16:08:57 +0000 (UTC) Received: by mail-wm1-x331.google.com with SMTP id b19so8784734wmj.4 for ; Fri, 03 Jan 2020 08:08: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 z11sm61000235wrt.82.2020.01.03.08.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:08:56 -0800 (PST) X-Inumbo-ID: 58a495d8-2e43-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=Lzk7QT42x4Bu7yTXlGHeGQsXy2o8S3NY1hIpuuMaZPg=; b=gx/+v4CdSMB+xrjc75vD3ZDNiL8126npbFc9alC4qtaab8Vm58o/WqSDbzU2mf7e96 6KWhLdK1W5a44ItW5kkY6fKssQUMpQXUH0Jq6ZOtUN2UpxToer5xd/OQRc2vzNAqXg+o vlEUpgq/gt6NpxDm4Q6BgMthkFmg+M0fIHM2xkFK8kOWJ1QKvvrcTLIfiy3T498podoS HxPQ/C1g673GjiB/gnW/fybUNeTEWfxAae+WQrQgaXduz7Ba+rjh90nOBt0b7UTivO03 4VH9+dY+De7HnX91j4vOdh7BytkzQ3iDvSqt5P5Chr1TrW7fDFgTlShqCrViuqSm/fQI U/wQ== 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=TS4P6gM2dkdeBF1snmczgv/bbiItAczVJqwMO/ScMyBGDeE3rTVjZUthLVhmXscLia 8pZjWlXtHI2UZ0CO7SgI/MQUk3IOcb5rHKfQ312NqJ0c9qIPzTWIDbSfN/R4Sl4+VUu/ CJxfFVnMBseunLQHw7a1HG3qInX7J5eiEoyvF8Sh7EGRVuUazuDS1D6YfwslfKNSn9KP fga3hJLN0UBtIoGBlPrJ6YM1Id2FbGBJImWBHwfc3tjdNTrIDrR90HF0GRe25Ib0ke4v 1JImyixo+c87NbUsZhJ4nNzW3eouAlizDEYg0pwXRj/9oB7hu0Aetnsjoof4OTa87hTl 182w== X-Gm-Message-State: APjAAAUHz1MzrOXcqhdptU2WmZs7rYVUZKsbJuNcZN/B61Yeg+8c9FG6 QW+qsg6iCkPSEblqZQdH6FLrOy4BV0Syqg== X-Google-Smtp-Source: APXvYqwVlJzNuW6gI1Cd20+TFIp4Lb9cRdIKKgrnL9ZcpvRM98xluSSt+IeUcyJZwS27AYbrAtQiJQ== X-Received: by 2002:a1c:4c5:: with SMTP id 188mr20367174wme.82.1578067736826; Fri, 03 Jan 2020 08:08:56 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:18 +0000 Message-Id: <20200103160825.19377-2-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 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 --- 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 Thu May 2 14:03:58 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=1578067791; cv=none; d=zohomail.com; s=zohoarc; b=bRyCpMcRgijszcJ+8ykKq37HGQjL5HSe0gy/kOFblUDbnlAXfq6FtJQTXny0eNwFBk+TRXqJcVt2Ucb4HmdQj6srgX1Yu/B5l6tHIYyRZLzKy+JmlKBpZj2hMOE5C80Atmy9wDCzXpeGdhABTT4WnevnRrEb1pfOgxYxddoB5II= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067791; 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=y5G4VNzrEwnq4KoISEaPIESvc621xYIUZ0faA8DBkBE=; b=jZTVA0glBXzH8xZP9jRPqHG4kn0gS6zpcbyMgdD1KTk3zJb3N+wk1QC7+zLbhSWuP6N7qFz0qYUmZCS4bjOPPQp6XgtRNGXpo4qEvojsQ2ccVMuKTiyqkfzieukr9bl2WEh9lCns/m/vSL28yOwc74OYBjiG3ia9uh1P2JKwCQY= 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 1578067791276695.2848234100315; Fri, 3 Jan 2020 08:09:51 -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 1inPVc-0005Rk-KJ; Fri, 03 Jan 2020 16:09:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVb-0005RW-KW for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:07 +0000 Received: from mail-wr1-x42a.google.com (unknown [2a00:1450:4864:20::42a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5939d5d0-2e43-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 16:08:58 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id y17so42927624wrh.5 for ; Fri, 03 Jan 2020 08:08: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 z11sm61000235wrt.82.2020.01.03.08.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:08:57 -0800 (PST) X-Inumbo-ID: 5939d5d0-2e43-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=lOdhYFEVelSK6Ytux96+pcbc6B3h71rDSrm39/P7N80=; b=RQoC+pso/dCEYUaDHg9flDKa37SjRprUJMgemtpKRxCsPrvxs9iJkn7WeC7HPW0Ylv ctfJD4pZLNqk8J7cnwGjzIhrTxkvNvkpCI6qfv3noYM21lC3ah0jlh9Pu8LzgaEo9OCI R4fV0hlpTKt07b58i16PSq/+49RFYSIBEhZgjwW/45syTKuV/Uj0O60/HLaOpTYxY8Nl ZaNl66pPGp+mdqB4o9WMNzEIQZXuEnuKjTfV6hOTTAQddUrTvg75IueLOlm22Yqkte1F rZvrmpjoC+fm4z0BkHdj66WPLdYU/LEpPwYOMzElxnsLyht8XbA4d3xAQlarb6O9QSx7 kJ/w== 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=lOdhYFEVelSK6Ytux96+pcbc6B3h71rDSrm39/P7N80=; b=IzKTxuluHu1IaPwIfVz5S0B0OLlh17gULalhXUtTbp7BKyLhI/aEyTbVaG+V1+8QUG pdVJ50UStmUB9qjXIe4IJona4lnZ5WAuhhxiWbOo+VSzIUQcR75rdSnryBNypzfyDQvj +7TkqA63e4OYcuDNtnY5vS+k5ebpdyrqVYR3qMeAKFct2GQ+tnZIdMARmb2zOI07ow3j WrsSiT5u3qC85/JcUMXH6DEEtxmSbytYAOWF9tYBMOK4qGO62mk4aqCJLRPHGpnwPQCv GhrzFDk0zS8H+RjeYgY0HcB5t1j/hrAy3t4ZV3LAiGQg3Ox+WJw3tCc7JXzGnfUT2bjr ByzA== X-Gm-Message-State: APjAAAXe085P6ZdNT/jZsM0zglcuhjsWOcAwJh5jclWmTzImnquXVxGA 0fMmLTcIhhkGf1H5FErP0IFD2zVIERIRFQ== X-Google-Smtp-Source: APXvYqwdsSwb9hd2N7DiC6+ZLYhBc1aNVFNbCK+TvaRkPAFWFvi8P4cLv1psIRtr5DGKdEpmHEKg5w== X-Received: by 2002:adf:df8e:: with SMTP id z14mr87620646wrl.190.1578067737706; Fri, 03 Jan 2020 08:08:57 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:19 +0000 Message-Id: <20200103160825.19377-3-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 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 --- v2: 1. Fix comment style --- xen/arch/x86/guest/hyperv/hyperv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 2e70b4aa82..8d38313d7a 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,16 @@ 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 Thu May 2 14:03:58 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=1578067804; cv=none; d=zohomail.com; s=zohoarc; b=VkHrGJT4hqXuFfCKuGT/j6OKz49j+uk+9SItWESuYEalrcZkErEDkxPOnn9v1fE8D8S7qldcXAL4vuFtFwuilVCsCSopGVo2RAXUnWmfz+deVwZ0oL0A/PyPpPL9E1mSP/0wsO7AXyoneDwFIJUaiZPGraTEVf1C4KRP8NF6wCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067804; 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=jkp17+Pv2KEV5e5QQ7gZUViSnCLP8okHHzi/sAlJMFY=; b=g994cVa43TTKl78syxBDWsxBBe2pejqZOvlS4NyJy7KQNJLPfMqX3YyLGDZQVTCgNkcXus6dDWR2NutJB3MNFdl7nO0RdW9qubToSsAJ86wM5ZgiTbQ/TXIU8ATk3J7ZMF+36h7IWpFQhNB9uUaY6olfJUgGqKTntkspbSKxcBw= 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 1578067804705992.9999501073131; Fri, 3 Jan 2020 08:10: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 1inPVi-0005T7-4l; Fri, 03 Jan 2020 16:09:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVg-0005Sk-Kd for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:12 +0000 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5a81d460-2e43-11ea-a914-bc764e2007e4; Fri, 03 Jan 2020 16:09:00 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id a5so8826475wmb.0 for ; Fri, 03 Jan 2020 08:09: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 z11sm61000235wrt.82.2020.01.03.08.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:08:59 -0800 (PST) X-Inumbo-ID: 5a81d460-2e43-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=gvmWC2BuiVkIzJZx/luRPH2eJYAdGqz17W1cKVo4/9M=; b=pQCRr8JYbHc7z9/csugoZ8r2OsoJObDGeZwtWzlm+h4/c56uBeSnh2etlJafkCPZ/k 90cEuhNz5dmd9UUM6UmfMn9AlXONJl45NDU9lYTznVM4Gc+KadRd2TI7iq+jruWZqPIF SS1N8rVo+iZL4r538feNOwxOegTND+yqqJVzIX7VBUxIrsBS7qEu/gKCl7TuaaXco3Uz 9ie6elVpSt+0fTWv10wNOm9PmIhNOMyN31JMNyY/dJDBA7man20O0EzE7Oxgas0CJWFC bkyLtb2Qm2d38F9vIqTxYbHiJERf2j3X2zn/LjqaAs5bbvus4zJ5FNZla124FETzRIdM l0Jw== 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=gvmWC2BuiVkIzJZx/luRPH2eJYAdGqz17W1cKVo4/9M=; b=q6tqBR0sM+FGO2ZzEGf+Yt7wGsJjeU2kuVkLbuhkv46zswKJpuwstckEEzII9Rd10j RnpYNmC22SWYtp9SluaTqDqusb+xVwCKvaQRpkZ1AwmpZRLeG5rLNaevjfre3Trgy7Q7 EsLUbCd/gVgURmTnUBT/AFNn6Rl0zg7PCJLMF8ChfU5bJbmiM/0IRxjBN0K0WoyF++iM TvvVWLo/8FfeqIQ1GVe+573Ks+it24724la5CDcEfGovPrPdzylq+yqmxQhqk/S67l9E rxktubvDGVYOrxNfTJ6Pt3daUsNjvHBm7JumbFUuBdAz49GYTJENwIE7DCQubjETsa+Q i8WQ== X-Gm-Message-State: APjAAAV4kxoGDNvsCfXIWoUXcfn4RVQp/exL4iHxECo6zJsVfsqlkTck iw1ZgBShDyauH80/46Y/h1hHWPcGXgRjGA== X-Google-Smtp-Source: APXvYqxXGcegu67DdeDDmrIBAqf0He81OqI/mFhZxL9RUkqd15Px0MdQG+NXibrZluj6waOysHZFFg== X-Received: by 2002:a05:600c:409:: with SMTP id q9mr20365834wmb.19.1578067740002; Fri, 03 Jan 2020 08:09:00 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:20 +0000 Message-Id: <20200103160825.19377-4-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 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 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 Thu May 2 14:03:58 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=1578067807; cv=none; d=zohomail.com; s=zohoarc; b=baaO6cI6ULWfiE2zjItAGH+vtc3k62KhcG6/cczZ/unADf3szgdB5cx71V0kX1zwlRnnoyI7nMif9OdsUE0MzJBmiGDK21OUjBxjjyeIXT029rJGrdp5aqn+ZvGn0akN0WqB6TwhwsiDwk1NYrMy0L+XtyBkRpt44xNFkZ6Xk2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067807; 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=qdZbjgjuvHY8W+oILsJrPK/5lOiFI85+tjGS8v4SqfM=; b=alA6gq+NV13M8MKzSAgQgXRMOZmCuAGHfym6Wt0L8CyoxCdtZxdVvGube22piJGyLhkeBDn8jDDkEREWgVM/K0vp3lELwcVRFYhoHVHi60PhCtj8Qa09PFy9NxzDHZYDwnm07Fz5FqHExZPpLVP9G9rIBytkikEFlyO/720zGBc= 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 1578067807109300.33654901949797; Fri, 3 Jan 2020 08:10:07 -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 1inPVm-0005Ua-Ek; Fri, 03 Jan 2020 16:09:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVl-0005UK-Lp for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:17 +0000 Received: from mail-wm1-x329.google.com (unknown [2a00:1450:4864:20::329]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5afe3b9a-2e43-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 16:09:01 +0000 (UTC) Received: by mail-wm1-x329.google.com with SMTP id b19so8784888wmj.4 for ; Fri, 03 Jan 2020 08:09: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 z11sm61000235wrt.82.2020.01.03.08.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:09:00 -0800 (PST) X-Inumbo-ID: 5afe3b9a-2e43-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=AeVdaCAPZTMCoRydrJF1kMnbXuo4DmKCUTwBKEx4Ftg=; b=f4X1oyi9sh1zTPgxK6RoOIEv5yHCPevuLRvYvmGuDyfr9FjEB0LxhAwbi8Exzfzy4v mzjBfnW5J7mE5yx3GHq2mSMGHPzXu3X+D6RlXQQxzlGJx5UH53s4Lg7DRRoS/P1yk7/Z c1mk6hbHBh1aNg6LSgTIDkB52V68a7SMx54j+Uv5/xq8+WgAbcFptDjceC9euxe/lA1l 0QHdrX+oB4XrfMHud3UZYDi8dEjFia9ymeOmnbiNlNBtkvXJ/0r9K/QdVvGZqG0OoMgI hRtLfCm99Hk2jzKoBHVj4DjhMz6FRiXAB86P6OBolTwy2Fqv2JHfV/8YhjVSDlWs/oRr W71A== 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=AeVdaCAPZTMCoRydrJF1kMnbXuo4DmKCUTwBKEx4Ftg=; b=XyfSTd9fKbDSEzDLvroDqw1Gxs+ghiuHJz0LK0rCiHp+zaWhDz4XTaas4xKMCk9tXh Hmly2z98Hyh60347vOmlXHLisW7V+T8vieXy55HoUQim6Z6C08p+yAsDuHX4sJ+ff+AV +IckcdqifCePajrigEYmeTs7Nv9RT01oVYA9iLPMo40W38IKcRVBsOx2LizCuG/4g8Be OWq7Wfba/PggMtxW78pUMKNboPqQDKsJAl6ODasf1iANVvp21K+3h6qYd9QUZZoqGR8N 4EFWL5HIG15Jne8PhB8nhhy+9dNC8wXup4FzFbFUmVTnDjJF1GeX0QCAhDYoWHnNcVV3 koSQ== X-Gm-Message-State: APjAAAXe1EdVGB6A/79Gq8bJsmEc0586U7IgjtRDiVdfBxop/jHeK4Rx VOvnineyHve6W/06ooQrPDfXBRUSWkdBkQ== X-Google-Smtp-Source: APXvYqxbMR8RYP5sL+FAKCqyBnntlD2gxHmRqxI+cznR9X69weUoxjSyDz5vfC81rfyr/nYC37V8VQ== X-Received: by 2002:a1c:a949:: with SMTP id s70mr20167401wme.69.1578067740767; Fri, 03 Jan 2020 08:09:00 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:21 +0000 Message-Id: <20200103160825.19377-5-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 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 --- v2: 1. Fix issue discovered by Michael 2. Use a statically allocated page as hypercall page --- xen/arch/x86/guest/hyperv/Makefile | 1 + xen/arch/x86/guest/hyperv/hypercall_page.S | 21 +++++++++++++++++ xen/arch/x86/guest/hyperv/hyperv.c | 27 +++++++++++++++++++--- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 xen/arch/x86/guest/hyperv/hypercall_page.S diff --git a/xen/arch/x86/guest/hyperv/Makefile b/xen/arch/x86/guest/hyperv= /Makefile index 68170109a9..1a8887d2f4 100644 --- a/xen/arch/x86/guest/hyperv/Makefile +++ b/xen/arch/x86/guest/hyperv/Makefile @@ -1 +1,2 @@ +obj-y +=3D hypercall_page.o obj-y +=3D hyperv.o diff --git a/xen/arch/x86/guest/hyperv/hypercall_page.S b/xen/arch/x86/gues= t/hyperv/hypercall_page.S new file mode 100644 index 0000000000..6d6ab913be --- /dev/null +++ b/xen/arch/x86/guest/hyperv/hypercall_page.S @@ -0,0 +1,21 @@ +#include +#include + + .section ".text.page_aligned", "ax", @progbits + .p2align PAGE_SHIFT +GLOBAL(hv_hypercall_page) + /* Return -1 for "not yet ready" state */ + mov -1, %rax + ret +1: + /* Fill the rest with `ret` */ + .fill PAGE_SIZE - (1b - hv_hypercall_page), 1, 0xc3 + .type hv_hypercall_page, STT_OBJECT + .size hv_hypercall_page, PAGE_SIZE + +/* + * Local variables: + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 8d38313d7a..381be2a68c 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -19,16 +19,16 @@ * 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", -}; +extern char hv_hypercall_page[]; =20 +static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) { uint32_t eax, ebx, ecx, edx; @@ -72,6 +72,27 @@ 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; + + rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); + hypercall_msr.enable =3D 1; + hypercall_msr.guest_physical_address =3D + __pa(hv_hypercall_page) >> HV_HYP_PAGE_SHIFT; + 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 Thu May 2 14:03:58 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=1578067805; cv=none; d=zohomail.com; s=zohoarc; b=HnU6INUhCOx3KCRgLrakSLJ7x9qvzYRyETiVXetG/E8z4FLDhsaU0PrcjD/cpjJnIh+I9+xvYNoFlscafp4tEDSj3xmTuxCPpM+MYJFXbbuTJ8/c4tbf25ZzRU6agLFBq0ocywQ1HUPYTnbXQhhlF6jMJ6i5mwbCygF+zS+ePZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067805; 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=8bWfZYm26NJgdZnCGavGpNfHTJUHVi3I3O4VWmPI+RU=; b=G2wobXrA6Xt8eDBOzjqgec+myPFf3cvDKeYEZT2SD/9iFaMrM2O0v90JaljZ437FNTOhnDsChhlK9TX8V3mSAor6RlThQ5hn8UkxppdcTNnjOKNKnulbPz/PEFYGQWJeGmin8zjK4GYhDcDPzWHPjU2bMECFrwlLxhdKcwSeupg= 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 1578067805072885.0073062770612; Fri, 3 Jan 2020 08:10:05 -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 1inPVr-0005Wl-OM; Fri, 03 Jan 2020 16:09:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVq-0005WC-LG for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:22 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5b7ce030-2e43-11ea-a914-bc764e2007e4; Fri, 03 Jan 2020 16:09:02 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id p17so9045937wma.1 for ; Fri, 03 Jan 2020 08:09: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 z11sm61000235wrt.82.2020.01.03.08.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:09:01 -0800 (PST) X-Inumbo-ID: 5b7ce030-2e43-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=RUfnlZlwFuHWpde6sRvjxDfadwPtw2oJdC3k1kQv/fc=; b=tUbHi0DpRaYWZ3lxVGLFpcaSMEAc4PBWX+py0GYk/V1mca4StnwqTGD2Z8bGwK0gHF TP0q8tHZ1laPI1bmR1NaekYETPtGvI/oDtHmd9u0I/nTOFwudnzDUBjQ2rSAuQyfEH0X EbD4j5U0WdVJ1bOFO1IUN0bYFvMBgO0yWjWyFtadcVgF06PxsXKCxX4FrDmsmm35YuOT c/jT/Ups37cbNsCJNfZaBFqzPK5Y2tzG08cGxkiqLb1wQXLrJTF4eZ07XEhlIEou0ziz Rgu9RM3A8Ran/Goz8ne0+v3qZ1I4AmDZRM5qLX3qlx9e3RJhxNRyYS8+FktP4OMVES2t ASzQ== 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=RUfnlZlwFuHWpde6sRvjxDfadwPtw2oJdC3k1kQv/fc=; b=YLXS77vRzpJfoJ39+ceA06ITZhwkFdpk0lh+8JxadXFNy7gF5kqnQFtzqOyaolWsH+ Fp7eZtRcIz4cfnhXD02E58G4Ixun5rC8cQ2iwSO29XNCwR30jJ/2xO+BZKMAwkAssLCR jhuVk65fo2v/HPj/PUGKcVyp4cqnGUsf5YUuZ7aomUEvdW05D7CNMUtKMuoAJNAPGMSy 4ZIaDgXjqSPgcoonY7Fvr9Og5hYo5d16nWfpn81qTNT6wfKB5k0MsDKNS53p02oab+XD OlM/rEDMau2jBAaP9xaxMo0qlR4yAx4LWCj87kdgLgS2Dt/P8tME7Q2K7/O/qKVMVw+X dwEg== X-Gm-Message-State: APjAAAW5YAST86MrsxCxHquqR8BPf88pH8eicJp7KX8zYGsCs29GjPgR 7ANcS13juMadq697VC0vYbqLLOKrMg7YWA== X-Google-Smtp-Source: APXvYqxOVtQLjKCVbZacFTlx6nzgZtiAYBluSMVrihTmit9tKrvWHb/2hHm9MhvYZCCKCRH5ezfz1A== X-Received: by 2002:a7b:cf12:: with SMTP id l18mr21771776wmg.66.1578067741581; Fri, 03 Jan 2020 08:09:01 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:22 +0000 Message-Id: <20200103160825.19377-6-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 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 --- v2: 1. Use direct call --- xen/include/asm-x86/guest/hyperv-hypercall.h | 95 ++++++++++++++++++++ 1 file changed, 95 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..928d85ae7e --- /dev/null +++ b/xen/include/asm-x86/guest/hyperv-hypercall.h @@ -0,0 +1,95 @@ +/*************************************************************************= ***** + * 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 + +static inline uint64_t hv_do_hypercall(uint64_t control, paddr_t input, pa= ddr_t output) +{ + uint64_t status; + + asm volatile ("mov %[output], %%r8\n" + "call hv_hypercall_page" + : "=3Da" (status), "+c" (control), + "+d" (input) ASM_CALL_CONSTRAINT + : [output] "rm" (output) + : "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; + + asm volatile ("mov %[input2], %%r8\n" + "call hv_hypercall_page" + : "=3Da" (status), "+c" (control), + "+d" (input1) ASM_CALL_CONSTRAINT + : [input2] "rm" (input2) + : "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 Thu May 2 14:03:58 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=1578067819; cv=none; d=zohomail.com; s=zohoarc; b=PsSqRfl27xXOmmMN59j7UXq+0lcsD9vO1SeGw1DB+TBbGMCUdmICyrZyO5DAyruC2a311eC7m3lXzUnYYxrjq46PldxV1xvmmFB4FAyNoUkrKoPDmKIUXb2vXrdDIhaVntoslPcvtFUaC2RVUFprcDLYPNhamWv1PpQfkFHrYF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067819; 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=f9Y/T850aeEeU0Y/dOKjiadBvpNlHW87yc1BumF1fsk=; b=e4w+AdMnoY2zJ7ypmuRkBOYIeMOKLSeu6odU7hoIVT0zytDcuFffpVv8Ya7js9yIxK2v9DbpZ82MKBMhtyNj9FQ9Ys3tUoOcVZRPG2y48v9voPFQXcM+sPRdUbj3yt6xfvyPGGK5Rlo5wANyTb0qzU2Tbvxc7+JiiixRGMCmhao= 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 1578067819342857.8070507363748; Fri, 3 Jan 2020 08:10:19 -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 1inPVx-0005aG-2X; Fri, 03 Jan 2020 16:09:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPVv-0005ZG-Lo for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:27 +0000 Received: from mail-wr1-x444.google.com (unknown [2a00:1450:4864:20::444]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5c099f48-2e43-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 16:09:03 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id y17so42927838wrh.5 for ; Fri, 03 Jan 2020 08:09:03 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:09:02 -0800 (PST) X-Inumbo-ID: 5c099f48-2e43-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=CQAPrwZ6zHYdeecjna9SU+ovWbg6SlC0hmlnmabw3K0=; b=gmCFLGnFcf+29R1n5v0xIWDuW3zWHEzSWuTJErOBQYqfjFbu4+LY+8t0UDm6Scl4d+ Yb/BlmUMcNvH7G0tXDLB/0tpUmsIolrrwTd04qfX+uGSzVJxqe3obvWDdGq1UMOj2WLG l43pZD3fIx+5+t2UTf9T8BCKPftCDDaSyGCILETg+EQFtbpAWoVN0dPi5WWMakKXwVfx wvQZlImx2HGb0irF7dkRPvCFVoLBoZGifjOUZyyL1ObNhhaugvhOGTPc1Zy0jrk5y7dW jO9RUQ7Ntve/jPdROGyoPeKaGINVS1M0Yo0uk30SNsLyGB0mZLiQoOidu6KeUTRHG0S3 M5Eg== 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=CQAPrwZ6zHYdeecjna9SU+ovWbg6SlC0hmlnmabw3K0=; b=BmvHGAxUiOmOEjdhfA/scbq7l98V0yxSnZsAlh1Q63wgfix/wNlqt1lOT4WOThH2tV XgRQm0Nt7apEs3wAPx0hVbQ02MqRs+C/pYE2rKhHlJzQLxt13zN6/mKLjMSH2qpT4UuL ygMBvw/QwNpEAcYL6vS3mc4fIDjpnR6gvEihtB4Lh+edXVQiMgwceB1Q9QTcN+bWLHQW fCD1yXSLAx7l45LlaP5HXJvFuzV9kdCl10TEnh+tao55mGzuf7RDtqEg9lyeuxwqQJJg tCoORGFC+6ku5Inakce9GY+bjab9Y+3qiorAbg+n7ejgx1dzJN8ELAj+yCRWnyCkb/T+ KtYA== X-Gm-Message-State: APjAAAV367xutEqH07KFLI/6RgEX4p89dLLWNbZdxfC5c52Lbsbx0A2V lIxENzakYCV1mdbYMtYFwUU0gbdyZ/D3DQ== X-Google-Smtp-Source: APXvYqyWeqNbXCdXFT2fFknZH+3j9VXX2ry3FTDYp8zpb2KWhKVx4hj6hXbMX0G6+30mCzVZ/fLI/g== X-Received: by 2002:adf:fd07:: with SMTP id e7mr86811193wrr.21.1578067742550; Fri, 03 Jan 2020 08:09:02 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 3 Jan 2020 16:08:23 +0000 Message-Id: <20200103160825.19377-7-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 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 381be2a68c..03027bd453 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -27,6 +27,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; =20 extern char 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) @@ -83,14 +84,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 Thu May 2 14:03:58 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=1578067812; cv=none; d=zohomail.com; s=zohoarc; b=nC6dyv3KNilikMWPI3QXawHkIAlXI2r4XPz04w09iSGHl2+rc9tDumOtdwSdlfgUq9SanmUHhOQ2JFZX5IP/6LyUM1TJC4owi5s3EA5rLo8sYey9YfSucG9XnHmtnCrC80i53spzXfXHz0V93iK9tXFZaknw2sHBAiNNwWQWjj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578067812; 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=PUzql44iRrrV4JmAJUiot20kTEdEPa6ek2j6tDbMimY=; b=SVntAuTtPssV00r1G8MFFdQhl5woNQfu615P+QHCbRbwgIQK0d8H+eTKraMV5gDcqhKvDsbpQ6VMaEeNpaHEYUmdkO64MXoMcK1LQq5YVdhcUUhpWk1EdXHIgoKxIMkZPeiRKKMMiLqZLHYRdhs1Cn4IdmklLGdLAGZV+ySVD9g= 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 157806781288570.72581442361809; Fri, 3 Jan 2020 08:10:12 -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 1inPW2-0005e1-Dh; Fri, 03 Jan 2020 16:09:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inPW0-0005cS-Lv for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 16:09:32 +0000 Received: from mail-wm1-x32a.google.com (unknown [2a00:1450:4864:20::32a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5ce7faea-2e43-11ea-a1e1-bc764e2007e4; Fri, 03 Jan 2020 16:09:04 +0000 (UTC) Received: by mail-wm1-x32a.google.com with SMTP id f129so9033350wmf.2 for ; 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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 08:09:02 -0800 (PST) X-Inumbo-ID: 5ce7faea-2e43-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=LMFPYGrcm7BM/XK1EMrwljwKrMIeS9V+k4JmcGsTosc=; b=M7QorUtbzSu5vyn70UvJR7qvQ3056ecP9mQDPqnTvieFdUEipkc8BzYae6CM5fMgYR r0rx2pqX7OgDWHxukofI48aJt/s29s2AluJP8hJcD1EjOuT/y+qcDc6ubE3JsGARF0ks j3QxPAvsmUt624E4sCjyGtQkX/YhrzEooJCL/eh/l9ZO0y79N5e7DR4MGUTf3fiHu9ko ZHkfpK1HWLw+2dhziymQ5IYIAkeAHXfCKKYAsE/c/1lUWLGV8EeStwsmc2YAZCNA9quz 1/3LQMcW8KwzzeagqTasNnvyVpJ/kNhL0QCS+izN3bs0UU63N9vfmCspVZFPa65wlKQz LBHw== 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=LMFPYGrcm7BM/XK1EMrwljwKrMIeS9V+k4JmcGsTosc=; b=fWgRel29kGTN9UfN20Qo8/xPWcYmyXc4FIwFDBO3w74hs8F/KsmN3woc/LiKO1rHcd ur+hAD+tSmZNJe2kx/KWpLok3cTqZ27Ejn8/YVNMi/kRphnkr7bB/ZIE2MxKw3G9vMlU 4yZ7GICTBcBL1KLIgCHSijPyAK9YZw6vQXBgqh557ojg3ZfrY3Y8qT7E0Yt4mfzdIIFs IjZzf2FiTo75GDcsP0O3uP4gd6Hf3BTO59iLCqsN+zGhL5XNm21/tSvkEHxoKTx55JcP n5BRT+uuI4UUbnzCy2Wwo83zd98ynijpk0hAJ4ks/EiH6Mu0r/tpskRXKzKZ0Aan4z1I Wyng== X-Gm-Message-State: APjAAAVuauRXuOoNV2ufgaoLqd9u3puowECvC3S++Z9xtt+yWUNResUS 0HGjpBKLDDiKrS1Sddq4ZcBFAj+3+KL02g== X-Google-Smtp-Source: APXvYqwbmx3bwNOOo/1sV5t8b4Apt1cPAv+VYMDE0eRYPgCRC1vooxFDz8tYUy6sNtuRw7ttVlMrMw== X-Received: by 2002:a05:600c:23c9:: with SMTP id p9mr20631914wmb.160.1578067744026; 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:24 +0000 Message-Id: <20200103160825.19377-8-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 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 --- v2: 1. Fold into setup_pcpu_arg function --- xen/arch/x86/guest/hyperv/hyperv.c | 5 +++++ xen/include/asm-x86/guest/hyperv.h | 1 + 2 files changed, 6 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c index 03027bd453..5c5aed46cb 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 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); =20 static const struct hypervisor_ops ops; const struct hypervisor_ops *__init hyperv_probe(void) @@ -89,6 +90,7 @@ static void setup_hypercall_pcpu_arg(void) struct page_info *pg; void *mapping; unsigned int cpu =3D smp_processor_id(); + uint64_t vp_index_msr; =20 pg =3D alloc_domheap_page(NULL, 0); if ( !pg ) @@ -100,6 +102,9 @@ static void setup_hypercall_pcpu_arg(void) =20 this_cpu(hv_pcpu_input_arg).maddr =3D page_to_maddr(pg); this_cpu(hv_pcpu_input_arg).mapping =3D mapping; + + rdmsrl(HV_X64_MSR_VP_INDEX, vp_index_msr); + this_cpu(hv_vp_index) =3D vp_index_msr; } =20 static void __init setup(void) 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 Thu May 2 14:03:58 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=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