[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] x86/cpuid: prevent decreasing of hypervisor max leaf on migration
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Wed, 27 Oct 2021 16:00:50 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vEFq9Noxa0+tac7zwTnn1lh6K/4Fwca86hbVXGfBKb4=; b=Ey1X7M1R1ihLtF0+J9tvvVdd+Eg0eR0fsCodK77nO0ANb2W+vFov57uGrtX/uTJMUqALUP4JbV7BTCt0E3NyxKUCtpyxEN/5QkLTJOt8J8NM3ERqirqDxaPymAC6J3ZIuWH33qCAKSgXD13/MzbTmuNEg3iLJWijOCyLR+B0POOdq3oHVW+p7p4psxiDMizk8d18umKnGVK7oCraUtHfcVtUyvSEKdxlLoHV9YGv0aStOFpS+mF5aqxXplSkoqR03DidXPKa4BPidiL4m/w2DU8s0TiLOiEIytzKT1J05Cw7o1yFTNaP26husYXGq+kjUvzb8dqFt22ZR3tsefbKig==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dle5zqP0YH9M+hp1QoDPPlBFkY8h2yLseu8tuhzwEh4Gm8uYAFd0VMCPBnvv+YYvCXJRjc30a7uX7UG5sUJvDREuqTTjnKeH6Hhm+tuD86KRqV8ciJnmpHljEjwWBuHdwgKmySNI3Foj5b+XrZdRgrpbrDA66KRQ4933o5oeWfE/YYxVep5iMq7UT/8D4ZYsYWh4+o1g93mlemQRAGZFg6i3Gkiv1dVaM+bVE/UB1xEnn/N5CkmxV4RMcabV4eyfjAwxh+aXksjLOntWuIICxziZmt49FPbkdkat0NRLUhq4tkfatxIk3QoB3yVgLOuojTW7W6bpy1SJW125o+7NfA==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
- Delivery-date: Wed, 27 Oct 2021 14:01:32 +0000
- Ironport-data: A9a23:8lh3VKC8yTj05RVW/9/kw5YqxClBgxIJ4kV8jS/XYbTApGwjgTFUz DMcXDzQOPrfZTGge4gjbtm+90wHvpeAz9VmQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WLGs1hxZH1c+EX550007wobVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/hRKzw9t/1 P509oWURQdwM73hkfwDXEwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHvuRuIcCgmlYasZmMtOOd tQ+dhhWakr8U01GYl01IZEGtbL97pX4W2IB8w/EzUYt2EDMyCRh3b6rN8DaEvSLWsd9jkuev njB/WnyHlcdLtP34SqI9Degi/HCmQv/WZkOD/uo+/hymlqRy2cPThoMWjOTo/O0l0q/UNJ3M FEP92wlqq1ayaCwZoCjBVvi+ifC50NCHYoLewEn1O2T4qTz2VqSCHQvd31YTNAm7cImaDUyy FDcyr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jILz9J+qj5zEnCv5a5854Cd3APV0k2hD0JdjpzX3cGDzVuNN4cLt 6x98BHrz2vdTA+adm6PGAMW6zmq8fQnJzrTBYaD1p/gTP+wA+A2frfKVy1zx0eWzRAzfML9n XEqRXw4uGGv+ugwhHR+mfP59B9mcfnyPFEGMuQ4/JlYAnEu0KNXsBMSreCtDc6rKWG70srqs DFp1MaM8F6+xrqDxeIiCqo/zOl/Ccl6nfkx1Pdq2Dku9bFSDUzDNcErZ5FczPCgnBQ8u1U4e Zu5Sa0ppBXBRTPkGDW/N7TTSxnkUKyvD4LjfMTtXpCSoETAYUh4rD3xHklUKvoIRiKq7zOSI JVfYPhDbdtAB+nhknizyhSKIfGZAV3Iv+EKnJyzfB9nQIm2EyR9HFot/D3qE1wgK7Ve6M0l9 gsDZ4Y5o2mNvVmFp6VJN1xCPdfWVa9CS4lDgqpUCHa/ec8SjXwl6I=
- Ironport-sdr: hx2+bg6HnU+EHOPVlrlIQK3cloXHRV9h5NtVW97K9ufx8fmKwaAWDdCoYlwtgxWt0QmKLRJUdB iJ10SZ4vZvCplg1RMX3qvkR+k/rlVVb5HegIUbsdb2He1Ksx+P9Ue4w82BlYSVpyVooKh3CDIa dhNAmN7Zu4LS5wHDjPmiOkoPXQEctl16nIZi7At8OIt8VTyP8vVN530fttyoe5gdOL8ogPVEzH mnjEUzGs7TFpH3lfivzAdlEkUViaDhar01SGQGPEkLfB6M4nMTo9teWajr6emk9ZRJheqqM2BA zCtRCl1mh6scp/3Bv8KAt4Xw
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
In order to be compatible with previous Xen versions, and not change
max hypervisor leaf as a result of a migration, keep the clamping of
the maximum leaf value provided to XEN_CPUID_MAX_NUM_LEAVES, instead
of doing it based on the domain type. Also set the default maximum
leaf without taking the domain type into account. The maximum
hypervisor leaf is not migrated, so we need the default to not regress
beyond what might already be reported to a guest by existing Xen
versions.
This is a partial revert of 540d911c28 and restores the previous
behaviour and assures that HVM guests won't see it's maximum
hypervisor leaf reduced from 5 to 4 as a result of a migration.
Fixes: 540d911c28 ('x86/CPUID: shrink max_{,sub}leaf fields according to actual
leaf contents')
Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Ian Jackson <iwj@xxxxxxxxxxxxxx>
---
Regarding release risks:
This is a partial revert of a commit. The main issues could be that a
partial revert could break the build or leave the remaining code in a
non-working condition.
Breaking the build will be easily discovered by our automated testing,
while leaving the remaining code in a broken state is unlikely, as the
chunks reverted are isolated from the rest of the change in
540d911c28.
---
xen/arch/x86/traps.c | 6 ++----
xen/include/public/arch-x86/cpuid.h | 6 +-----
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index a1c2adb7ad..79fd276a41 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1086,15 +1086,13 @@ void cpuid_hypervisor_leaves(const struct vcpu *v,
uint32_t leaf,
uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
uint32_t idx = leaf - base;
unsigned int limit = is_viridian_domain(d) ? p->hv2_limit : p->hv_limit;
- unsigned int dflt = is_pv_domain(d) ? XEN_CPUID_MAX_PV_NUM_LEAVES
- : XEN_CPUID_MAX_HVM_NUM_LEAVES;
if ( limit == 0 )
/* Default number of leaves */
- limit = dflt;
+ limit = XEN_CPUID_MAX_NUM_LEAVES;
else
/* Clamp toolstack value between 2 and MAX_NUM_LEAVES. */
- limit = min(max(limit, 2u), dflt);
+ limit = min(max(limit, 2u), XEN_CPUID_MAX_NUM_LEAVES + 0u);
if ( idx > limit )
return;
diff --git a/xen/include/public/arch-x86/cpuid.h
b/xen/include/public/arch-x86/cpuid.h
index 00926b1fef..ce46305bee 100644
--- a/xen/include/public/arch-x86/cpuid.h
+++ b/xen/include/public/arch-x86/cpuid.h
@@ -113,10 +113,6 @@
/* Max. address width in bits taking memory hotplug into account. */
#define XEN_CPUID_MACHINE_ADDRESS_WIDTH_MASK (0xffu << 0)
-#define XEN_CPUID_MAX_PV_NUM_LEAVES 5
-#define XEN_CPUID_MAX_HVM_NUM_LEAVES 4
-#define XEN_CPUID_MAX_NUM_LEAVES \
- (XEN_CPUID_MAX_PV_NUM_LEAVES > XEN_CPUID_MAX_HVM_NUM_LEAVES ? \
- XEN_CPUID_MAX_PV_NUM_LEAVES : XEN_CPUID_MAX_HVM_NUM_LEAVES)
+#define XEN_CPUID_MAX_NUM_LEAVES 5
#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
--
2.33.0
|