From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184991; cv=none; d=zohomail.com; s=zohoarc; b=doQRDsQgYPTOno/yfF49WK0DzWD5iEtpZ98FDHaBsF0MgkQOayMDXFcyafufcSG7NeJxcVH1TvRKEPNHlYDB3Ocfag0AJhdVjFmrPwxwfta5oUz6YKD1Vm/3bABho2vCChYKE7b2uy97MeyL7FvYTdSGFe3UkTs9OchD0e5kh/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184991; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=esa002n+umgb+uuAEw0alWBlRbDUr7KFNDpQLc54GuA=; b=D2WXqTFCCC59PXpY71/SCmboL9fnzhu0WIL2elvd0r6oXaLcmCRcAUigljMqECOS+MoSDtKPKPdgk/55/aA3XEpSDMucq8lC8KEKhqWcatzo/jqiZo6cESL7zYl3YY48UilSFJVD9IHh7VxnIyZT6rnw8j9MiHlsNdkvpyH483o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184991059278.44111827036886; Sun, 8 Nov 2026 16:43:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDRx-0005kL-A7; Sun, 08 Nov 2026 19:41:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRs-0005hi-T7 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:25 -0500 Received: from ci-2005c-snip6-2.eps.apple.com ([2a01:b747:3005:202::19] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRo-0006L1-4i for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:24 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 0B21F18007E6; Mon, 09 Nov 2026 00:41:13 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id DE94418001C2; Mon, 09 Nov 2026 00:41:12 +0000 (UTC) X-ICL-RepId: 01a1bdc0-87e9-7cac-ab36-dade25a13657 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0cZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeXxoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184875; x=1825720875; bh=esa002n+umgb+uuAEw0alWBlRbDUr7KFNDpQLc54GuA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=jZZ/HErx1MYgvAr676Ay7RaqmOCwYXBiUf3WwgCTcfA+o9gjbtoIbZgRNdAsfr9sL7T7BZSlUS7EJcdPy1vicUqdLqUNYLYcqqLIeHfru+90LCHpTbANnpUlVlPWizjqKnKJoRimqaX6ytN9vDOHKhwzIFM85c30HKBXQj1rwxwpbxBj5LBYA4e9FIViDia4mhooqUR38Y97Kk5+LqCUR8c10nMVik1DI9X9AuYuwgsa9QU1dwjuFRI6MYhxsetVDC180F51U0YmVlq7EVEYGuGpRACrgGsx095Xgq41UJUsGsiAXdjvY7Nui2s1KMpFkscCyRJe7OV8nQsAnIPH9Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org, Doug Cook Subject: [PULL 01/13] target/i386/whpx: fix VMX capability MSR values Date: Sun, 8 Nov 2026 17:40:56 -0700 Message-ID: <20261109004108.85808-2-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX1UfzGPdpjBWX scuEy6DXlZLcL9qUEaP5//YUzJsd1PdeuBFub4bO3fetJubCGtByfUO+6TqgdIxA1Nj2eAjo8GP Y201FiGTbdkspEvk2QFfpx6sm2E/p0uAQtJd4wlRme4lMMm9M7tDk5jd+MWygEk3efSAdgSR4lO Y/imRFJyAMfTGmGwc3EyIHyp9eChDL5aCztHbcbMoi3BMtLORax6j38o+TOvYuhFF/XRpk0Zieg gcb/Oyu6ALZ7UnsaZFwkCmgj0HtSNcRf0obsx5CC+p+Ig0kxJals8/JN69aHgh3KJC4yR8ltz3g U2ak/PpXlSAcBLg8aME3KIAC+87TJtgJ6B9uS5OdfsU+ppocUUWCsUS7qI3gB0= X-Proofpoint-GUID: hMErI7nlpnR6_WUvw7fF6gSBB0IHhhpH X-Authority-Info-Out: v=2.4 cv=BNu+bVQG c=1 sm=1 tr=0 ts=6af116aa cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yMhMjlubAAAA:8 a=34rDk-nlojoYW5TMjDsA:9 X-Proofpoint-ORIG-GUID: hMErI7nlpnR6_WUvw7fF6gSBB0IHhhpH X-JNJ: AAAAAAABt0vtPz8qpWIHUdSCHhU68ZLhCEqDciYsdPBkZDu/L+aAPeNMZ6UnnRwBEjStjA 4fI4nq8vSg4a9qdVKn6ad4drPTjaQOAVDoNXGCI+RH68m+phk+yhcAWxa03TmSdi25ukqt Q41fga26grMumaQoiH5DsIE9bDBmJ5duUv66tdWEuZCYauh+YSjVPj5zfjMcQjoD7mJlOk Zgx7o+B4tSCfp540QV6e0Qe1//VtOXawg2nHEShw8a8LOs7ydcSTINXJNHrPz2r8e3ykiB iIbKdfj9xBOetvZdb4qmOgklBfajunxSwd7GtGUUBE7d5hY3tVcoUwb4/DsnGs1MMZ7qLu 03FRr9iTa4fEVeOyL0vqyehBVXYAhbg0v5E785B/A1gn7sPLALhwogQPKbloasQWS6m0uB a/NbonRp5v969lP2eGBQsW0xBSTzq5zfj5v2IO5TZetQ2ODJ5UPWmBFjLb2gAAoIiEYXpR hKqXL3PyTXYMRHgOA3vNPDAowNCbAp1Vy3qDZdem3hO/LMsItePsz02qx81wXpn1o+reuC S4O+4vUlszXtFVF6UmiQCN6qK87HsMyVxVcrtbCT+DBEJplGLYpYMfeI2JQos+FsZo8FX3 oTvTrVxlE0uWMni410OTjgFFGIhGpCN9ySJxWScyD9SGoNezjHPMn5HGesnS0qAmCSwOM0 uDXkflgTJmjSEDO0rr0OcDJP5xPIE4kZVp7tLeTpKVEqT83HTPzCKqotRxKNQCtr/PFg+o XKQdh76t4kLy/V6eIy+900HmcVRrX4cL4u7C5yFChTl0xu9ysa4ZOpFEe3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:202::19; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184992138158500 Content-Type: text/plain; charset="utf-8" From: Doug Cook whpx_get_supported_msr_feature() had two bugs in how it reports the VMX control MSRs: - MSR_IA32_VMX_TRUE_PINBASED_CTLS and MSR_IA32_VMX_TRUE_PROCBASED_CTLS were queried using the non-TRUE capability codes (WHvCapabilityCodeVmxPinbasedCtls and WHvCapabilityCodeVmxProcbasedCtls). - For PROCBASED_CTLS2 and the four TRUE_* control MSRs, the raw allowed-0/allowed-1 pair was returned. The feature-word code expects only the bits that may be 1 but are not required to be 1. Apply the same transformation as kvm_arch_get_supported_msr_feature(); make_vmx_msr_value() adds the must-be-one bits back afterwards. As a result, with +vmx QEMU treated many VMX features the host does support (secondary controls, EPT, VPID, MSR bitmaps, ...) as missing, warned about each of them, and dropped them from the CPU model. The guest itself reads the VMX MSRs from the hypervisor, not from QEMU, so this did not change what the guest saw. Signed-off-by: Doug Cook Reviewed-by: Mohamed Mediouni Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index e3e672dcd1..3312dd8593 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1452,10 +1452,10 @@ uint64_t whpx_get_supported_msr_feature(uint32_t in= dex) cap =3D WHvCapabilityCodeVmxEptVpidCap; break; case MSR_IA32_VMX_TRUE_PINBASED_CTLS: - cap =3D WHvCapabilityCodeVmxPinbasedCtls; + cap =3D WHvCapabilityCodeVmxTruePinbasedCtls; break; case MSR_IA32_VMX_TRUE_PROCBASED_CTLS: - cap =3D WHvCapabilityCodeVmxProcbasedCtls; + cap =3D WHvCapabilityCodeVmxTrueProcbasedCtls; break; case MSR_IA32_VMX_TRUE_ENTRY_CTLS: cap =3D WHvCapabilityCodeVmxTrueEntryCtls; @@ -1474,6 +1474,31 @@ uint64_t whpx_get_supported_msr_feature(uint32_t ind= ex) if (FAILED(hr)) { return 0; } + + switch (index) { + case MSR_IA32_VMX_PROCBASED_CTLS2: + case MSR_IA32_VMX_TRUE_PINBASED_CTLS: + case MSR_IA32_VMX_TRUE_PROCBASED_CTLS: + case MSR_IA32_VMX_TRUE_ENTRY_CTLS: + case MSR_IA32_VMX_TRUE_EXIT_CTLS: { + /* + * These MSRs hold the allowed-0 settings in the low half and = the + * allowed-1 settings in the high half. QEMU's feature words = want + * only the bits that can be one but do not have to be one, so + * apply the same transformation as + * kvm_arch_get_supported_msr_feature(); make_vmx_msr_value() + * restores the must-be-one bits later. + */ + uint32_t must_be_one =3D (uint32_t)val; + uint32_t can_be_one =3D (uint32_t)(val >> 32); + + val =3D can_be_one & ~must_be_one; + break; + } + default: + break; + } + return val; } return 0; --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184983; cv=none; d=zohomail.com; s=zohoarc; b=UdFMN3OXo1ilKvmfODMDEVNhffqQfekPy/xXThTebaRsKKyiMO7S5Pz6jJXoYoMLODR1IL7aMiHZyeqAquVgVCv9tBVxPFxPunUQfOxQSby3HH6GXLp+czM7nJiNoGCzoie6rGOW7do53ZCQ/UO1zYgXWjPWyG/4o0y3d/HjaSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184983; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h06E3zBebDGKkNiR0+MMIDzb/mlZpYU2o+KvSJo9YoI=; b=PMJ3F7JRlnTZG/hx1A4kmghX/7sI0kupDhQGMTF/CoVj18HXwzyVUS2KD/MpnaSV3wR/RQRl8S7/hv2UNoqwj7lie1NYsdCE7jZh/QDJuakWmRqXp9d/8mjh0AnmDnBUo7VggF48GGVeSSt5i8aFy/2VU2CIkDbRwuNACPrXSfw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184982385757.9131973934618; Sun, 8 Nov 2026 16:43:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDRu-0005hr-Cp; Sun, 08 Nov 2026 19:41:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRr-0005hK-F1 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:23 -0500 Received: from ci-2005h-snip6-11.eps.apple.com ([2a01:b747:3005:202::53] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRo-0006Ky-4w for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:23 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 72FA918001D2; Mon, 09 Nov 2026 00:41:14 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 8438918001EC; Mon, 09 Nov 2026 00:41:13 +0000 (UTC) X-ICL-RepId: 01a1bdc0-89ae-7104-8471-a29bc488a93a X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0cZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeXhoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184875; x=1825720875; bh=h06E3zBebDGKkNiR0+MMIDzb/mlZpYU2o+KvSJo9YoI=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=g+6Bg9wvWEGvFuWb7iDw5GdySq1L3JKxBvdBqaJ3ARjuS0z39tYWkQBI3FdgFDX+0jkub16vIrVg0k7OGuhjwaFdbjpIUwMzf6FhbFCifxj26+a4FzaKv/KrtJlR1XQp4/KpZuZWzD+Ikdxm7wwQ982CEKem34CqaSW8SEQXlTZVEQ219w7Hd2jRbnOzW2m3zOAzXqddzCCn/qacA50paKdiNg691A1SP0hGm7dw7b3XPKudKEbwBb75eK8PjDbgAiakanoHu8yVBPBWh06s1gj37iTv/F2YXTQcSc3EPYXagwUXMhCbbTw/QCFEZ0ze99ht1dw0M99Pf+yGmqy1NQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org, "Doug Cook (WINDOWS)" Subject: [PULL 02/13] target/i386/whpx: whpx_get_xsave_state error handling Date: Sun, 8 Nov 2026 17:40:57 -0700 Message-ID: <20261109004108.85808-3-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=R9sO2NRX c=1 sm=1 tr=0 ts=6af116ab cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yMhMjlubAAAA:8 a=CyeGX34NJn-RfCE8euUA:9 X-Proofpoint-ORIG-GUID: iB0pdqnkWBkkJbraYWy98gzVNFVB1fy7 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX7Va0nCHROqeF nJo4pVFHfhaD1Ti+fwDvea5dlAwJE8YX1kPK1LQe0srBpECd1SzqIB0dFSFrJuJT0dkL+jinE0z TRNn1sxXB69p9RY8xdwqswju7a/l8zWoAeGsiKav4QVeXE+iUzyJFxyhCeh34bA4YJN1BwKLi79 5MMeTsHOPQP950ob71FfTHaWQGtSO4bf6DS7BJY7psio1qBSgU9H3PUuNgCNE2hYydSc6tdmqJq B33PSPWAYFn9o9TnWehNSBAWtudTxD1RmYE2n1Ztl0n+5lhaU9TztSrvHv1m1dHm9UXJPzpX19M m3aR8Mwo6F5WkqRNMJ2lUNLOIKsN8L6rQgKS4niYLLRr2P6PnipouCOg4+89lY= X-Proofpoint-GUID: iB0pdqnkWBkkJbraYWy98gzVNFVB1fy7 X-JNJ: AAAAAAABlV02S7ppif5sNmcMTbMS525KHH5wUFhzh/uYAS9kNAtco9hZRuC5jUea/yza0I 0dmt16VeuqdhvSUOwm6S+8mRqAmjcdoba2H6qmWLATDPp7f8RKmVwnwg4Fhhs7PMJsqxVf 64qOhCJPlT17d48Lc/JzY9Hf4TghPcB5zT0mdK6PhuxdCNUNNaLNC0sEDsAyFw46c4mKSF 5zj+xIqWKw/weCknbAFJznUKsCkYv2FexCvnyrlluqQyHTXsfVCKzVAMtAYfqxL1e+tmdS DcplPGMGtDkphTq4Roet4CA840Pq+xE6OQXHRWikEGmiPC+IfXdEFTIL+PSWnGEFqWJIs2 LrULnXGLeMPm59kXtGm5uyXTV6nSGFqWJaQgF++kRY84r02xKDNVN4QuB5VBboDMr5W51k 3qcrl0OxvPe0SEdwpaUhdpkcdxmRFofj7aHjzSN4T/Ac9Wf0tZJgy4L5Wkp5LNh7dO14id v/7okowv0Ub+KUotkLuS9B5lis/JuOEOBdTxpqZz3/56IhjShGISgwuk7upJHA0p6/KTCv SjhQAc0n/AVKljI8n8N5v36OcU+/oww4TSWMrVeqJaXEI9z9jjOokF1noD7VkMsZMOu/1U SjaW6p3Cg59KmQH3vdFa3VBkU2EcOPlU7+dsvdtglm5n7xqwQbK7eCkzfz9sZ8VxCA7txJ aL9UHaAf+oO0dZBOx5NtBmvHIzHpqVGIndas0khTKBfh7Pa9wN35stLfAAF4E2lWctx0mK 5IgUrlHJkK2SYRbU5KG3Za7WpLfmydg8qBf0dgoLmGO3d0TWJbWlAmCUx2Pw== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:202::53; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184986039158500 Content-Type: text/plain; charset="utf-8" From: "Doug Cook (WINDOWS)" Several problems with error handling in whpx_get_xsave_state: - Does not handle WHV_E_INSUFFICIENT_BUFFER, which occurs frequently in practice for XSAVE state. - Does not free xsavec_buf when an error occurs. - Error message and return code use errno where they should use hr. Fixes: cfaa3b6c9597 ("whpx: xsave support") Signed-off-by: Doug Cook Reviewed-by: Mohamed Mediouni Signed-off-by: Mohamed Mediouni --- include/system/whpx-internal.h | 5 ++- target/i386/whpx/whpx-all.c | 73 +++++++++++++++++++++++++--------- 2 files changed, 57 insertions(+), 21 deletions(-) diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index c295c5a529..b15f3d8faf 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -58,8 +58,9 @@ void whpx_apic_get(APICCommonState *s); =20 #define WHV_E_UNKNOWN_CAPABILITY 0x80370300L =20 -/* This should eventually come from the Windows SDK */ -#define WHV_E_UNKNOWN_PROPERTY 0x80370302 +/* These should eventually come from the Windows SDK */ +#define WHV_E_INSUFFICIENT_BUFFER 0x80370301L +#define WHV_E_UNKNOWN_PROPERTY 0x80370302L =20 #define LIST_WINHVPLATFORM_FUNCTIONS(X) \ X(HRESULT, WHvGetCapability, (WHV_CAPABILITY_CODE CapabilityCode, VOID* = CapabilityBuffer, UINT32 CapabilityBufferSizeInBytes, UINT32* WrittenSizeIn= Bytes)) \ diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 3312dd8593..f5f5c3b462 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -442,8 +442,8 @@ static int whpx_set_xsave_state(const CPUState *cpu) =20 qemu_vfree(xsavec_buf); if (FAILED(hr)) { - error_report("WHPX: Failed to get virtual processor context, hr=3D= %08lx", - hr); + error_report("WHPX: Failed to set xsave state, hr=3D%08lx", hr); + return -EIO; } =20 return 0; @@ -809,9 +809,28 @@ static void whpx_get_legacy_fp_registers(CPUState *cpu= , WHPXStateLevel level) idx +=3D 1; } =20 -static int whpx_get_xsave_state(CPUState *cpu) +static HRESULT whpx_get_xsave_state_buffer(const CPUState *cpu, void *buf, + size_t buf_len, + UINT32 *bytes_written) { struct whpx_state *whpx =3D &whpx_global; + + if (!whpx_is_legacy_os()) { + return whp_dispatch.WHvGetVirtualProcessorState( + whpx->partition, cpu->cpu_index, + WHvVirtualProcessorStateTypeXsaveState, + buf, + buf_len, bytes_written); + } else { + return whp_dispatch.WHvGetVirtualProcessorXsaveState( + whpx->partition, cpu->cpu_index, + buf, + buf_len, bytes_written); + } +} + +static int whpx_get_xsave_state(CPUState *cpu) +{ X86CPU *x86cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86cpu->env; int ret; @@ -824,27 +843,43 @@ static int whpx_get_xsave_state(CPUState *cpu) xsavec_buf =3D qemu_memalign(page, xsavec_buf_len); memset(xsavec_buf, 0, xsavec_buf_len); =20 - if (!whpx_is_legacy_os()) { - hr =3D whp_dispatch.WHvGetVirtualProcessorState( - whpx->partition, cpu->cpu_index, - WHvVirtualProcessorStateTypeXsaveState, - xsavec_buf, - xsavec_buf_len, &bytes_written); - } else { - hr =3D whp_dispatch.WHvGetVirtualProcessorXsaveState( - whpx->partition, cpu->cpu_index, - xsavec_buf, - xsavec_buf_len, &bytes_written); + bytes_written =3D 0; + hr =3D whpx_get_xsave_state_buffer(cpu, xsavec_buf, xsavec_buf_len, + &bytes_written); + + /* + * whpx_get_xsave_max_len() returns the size of user state components + * enabled in XCR0. The hypervisor returns an XSAVES image, which also + * contains the supervisor state, so the whpx_get_xsave_max_len() size + * may be too small. + */ + if (hr =3D=3D WHV_E_INSUFFICIENT_BUFFER && bytes_written > xsavec_buf_= len) { + qemu_vfree(xsavec_buf); + xsavec_buf_len =3D bytes_written; + xsavec_buf =3D qemu_memalign(page, xsavec_buf_len); + memset(xsavec_buf, 0, xsavec_buf_len); + + bytes_written =3D 0; + hr =3D whpx_get_xsave_state_buffer(cpu, xsavec_buf, xsavec_buf_len, + &bytes_written); } - if (FAILED(hr) || bytes_written =3D=3D 0) { - error_report("failed to get xsave state: %s", strerror(errno)); - return -errno; + + if (FAILED(hr)) { + error_report("WHPX: Failed to get xsave state, hr=3D%08lx", hr); + qemu_vfree(xsavec_buf); + return -EIO; + } + + if (bytes_written =3D=3D 0) { + error_report("WHPX: Failed to get xsave state, no data returned"); + qemu_vfree(xsavec_buf); + return -EIO; } =20 - ret =3D decompact_xsave_area(xsavec_buf, xsavec_buf_len, env); + ret =3D decompact_xsave_area(xsavec_buf, bytes_written, env); qemu_vfree(xsavec_buf); if (ret < 0) { - error_report("failed to decompact xsave area"); + error_report("WHPX: Failed to decompact xsave area"); return ret; } x86_cpu_xrstor_all_areas(x86cpu, env->xsave_buf, env->xsave_buf_len); --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184983; cv=none; d=zohomail.com; s=zohoarc; b=jlaL+uG/VWtKtqpErvgD9Q91KhQ447807Lzv6XYYjL2K9rmtcGQCApJpRhHo1sL5kYsSzj0IpJB+S6oOy9ibtwbDHAN2DMSf/k5x1UzPBic6VSNECusdlOFHzOte3rowyAag2NxlZtNG/+1IexqslH1Nf7MfqiCag2c7KIll4w4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184983; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BMfLaruRwjS2EuVB1qFM1OkXquvXAo2QdP40DhTsI1I=; b=Idc5MUG645Szji+2U48xeINJ8zQxW2vKQrXOoOl4hDMsDqc1LFM4QeS8h+mOHoRnxc2JQ/S7+9KXc/9GBVCLgdBANR2yK5habEizJyOOZBgcDlGNSIs60PCW8zmmcrlvnx6pN24q2gY58pp8F2bV4r1AZowr+uiCYQ8oiviuvw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184982266577.6331915252498; Sun, 8 Nov 2026 16:43:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDRs-0005hW-6G; Sun, 08 Nov 2026 19:41:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRq-0005gb-3H for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:22 -0500 Received: from ci-2005j-snip6-11.eps.apple.com ([2a01:b747:3005:202::67] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRo-0006LV-4y for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:21 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 2E0B518000A3; Mon, 09 Nov 2026 00:41:15 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 284B318007C2; Mon, 09 Nov 2026 00:41:14 +0000 (UTC) X-ICL-RepId: 01a1bdc0-8c62-7f61-ab23-0bcc6357001b X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0YZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeWRoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184876; x=1825720876; bh=BMfLaruRwjS2EuVB1qFM1OkXquvXAo2QdP40DhTsI1I=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=NwN/96Nci9+lkiFsJhCwYEadShkvWx1D3IDGKk66EzYFdkMTNSAOr9tsAlMp/049uGmRarA/gHddNwTbHBZnAL03DH7/vIJghsA5Rg7l26gtEu09SnmF64TGBTpcaDy2xcQcDdqXtJqrujILH8bwGm1YHsiRYzennRU+bm/WJB+KgBlfDbZy03AU8ihukGaHVc5fFuFdcWeLms2QbG1gSfelnssJtaPOqbb9yMJB4HJ1oX0qw/YLNLbR7vhu6pXJqzcahDCXBVZaSmUnl0foeXgXz/1MTckDDPC4cxNXGFdNPKydfszsElOMcdLNOhTZLiYel9+fXpI8yDtmQa6HEA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org Subject: [PULL 03/13] whpx: i386: get APIC state before VM save Date: Sun, 8 Nov 2026 17:40:58 -0700 Message-ID: <20261109004108.85808-4-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfXx3YdebabkSw7 E3SsOrmjCNreH+eEMOwvPFxKwrbAQjdGy1st+AyD0zz+l06hSlHhQJyDbRcAAJeWbkEW8hNWAw2 teXvjOgfu61rd01y10KVUbSARzkZf5XoNfe+A/OabcBOHvGUT4Q8cxDubOQKMgrQN6v+9y2oYDy smDzGrLL+v1N21OmHMH271+hrfBampmXBL3oVOJXuX10ltWPyDIceNPIRbuPE52ETUsrGISzozy lp2jMrg6KeenRl1us08l0xGSoWOuih8AXW9Ah6Ch7uy5N/nIJx31jqyxL78f56/JYYt9BCIIC1D 9ss+jeN7NoCE2kkJzjQ84ANlP5q68oo7iDghO7HoRtg1mx3lVghf2/8c123LIM= X-Proofpoint-ORIG-GUID: GfLqbDEOlLQq6ALG5paOhcuBb27g0y6z X-Proofpoint-GUID: GfLqbDEOlLQq6ALG5paOhcuBb27g0y6z X-Authority-Info-Out: v=2.4 cv=CLcnnBrD c=1 sm=1 tr=0 ts=6af116ab cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=O2XxGrO5I-fc2znLRzsA:9 X-JNJ: AAAAAAAB/S8lmttPpE7cQsYMkZWh9l4UuDTtuu20jP4ybm0Mr/AdXtoIpvCUiXMyvb59kg T8Y9TKIU8eN1MeEBzG8sYs4RJnuvytx9ukx6xzdOVP+6SD9c09dMPLiQAgCdziRJtEDWTU hy8hq006c38enS3Lt2xKjCyyCHwko6tgM9sIgCx4kcbVI98Q/fXn3AdgLyrh/OUAj8mlAz r3GgL9XWNuvPQsAnooI7FUUnHZCoeISpe5RiiA5Eqqe6ip7Z1jZnhEt/T5ME0LEi6L3kS0 UgKer3zmUtDx1xX9rFCuESGkmFpxrTxhritDmMJXxbF7QCANlpdH/5hu6Na1UryN0JrSKK UOMQn/FrpOT4pveS02obQPQgfhVl0KR5L6ccYFpmOTz0M5pBBOodcR500Rc7530RCjtFM+ PDFCmd5sj8ZR/x4hs75C2uBqy+9qzx43SKWICMJ7jIB9waOEsMEn/8+LCGQtl1P+3+7auq gQvWhHvofhMvSx/Gy74AXBtfUNUlFlddK8ZJ26QVvpHIGS2GhmCRZSvrxkS3CScbaJ5VwZ xM6To7iMV6qfHjk6OMNmH4jOcc22l3y0UzzbNWb8osY4YFA1LTe6RtIQrK0p/Qdc7ZYocQ Snf0/zv1gtGO7LYkh0a6qQHkxirEZb6MFgf07ULUp+rgiJt9nGyhYL7OPxjqUBLC6xiXME PJcQkmI/iWNYejRDbZmiRZ4T8eHLw6EaXkIia5wQJkUtjTI3XvV7v4wrp6Z8hV9E+hhYwG Mxfp9tAbvff+1lSowya+XnFWFCwSyQe98fSkR/wGDDpUC4PeVpajV2pw== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:202::67; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184985971158500 Content-Type: text/plain; charset="utf-8" Prerequisite for VM save/restore. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-apic.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c index cc272f82a5..efdedbcd77 100644 --- a/target/i386/whpx/whpx-apic.c +++ b/target/i386/whpx/whpx-apic.c @@ -242,6 +242,11 @@ void whpx_apic_get(APICCommonState *s) whpx_get_apic_state(s, &kapic); } =20 +static void whpx_apic_pre_save(APICCommonState *s) +{ + whpx_apic_get(s); +} + static void whpx_apic_post_load(APICCommonState *s) { run_on_cpu(CPU(s->cpu), whpx_apic_put, RUN_ON_CPU_HOST_PTR(s)); @@ -338,6 +343,7 @@ static void whpx_apic_class_init(ObjectClass *klass, co= nst void *data) k->set_base =3D apic_set_base; k->set_tpr =3D whpx_apic_set_tpr; k->get_tpr =3D whpx_apic_get_tpr; + k->pre_save =3D whpx_apic_pre_save; k->post_load =3D whpx_apic_post_load; k->vapic_base_update =3D whpx_apic_vapic_base_update; k->external_nmi =3D whpx_apic_external_nmi; --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184986; cv=none; d=zohomail.com; s=zohoarc; b=CsiAsW603Y3QefgDAqMYF2kmaHmyCCYe4z5WZTNFYmbH73d4/JU/ERRRawE5nTTNPg7eEeUZdv4dUzGDY1gn4awHD/BAOSu5KIAzhawN8PYXVCWwJLGqdX9sh7w1/Tu8GpysVn3ECs9yj0x/o4y3OGizL/4RbgiLV8oeS62vxqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184986; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4MtoiGWVHD1ql7ktrdOMb3tf+OVOyyTmcQKxYtuN+0U=; b=ct8BWaVMHXJJ21ck0FRhGs/mjGQ2BLrZ3SjF9X3nKTUgblG45Ca3g2BafG9SmkL39lwqwDuWOCvwtl0fVbrd9ts72qNJ/BVHPnxUmHTEPcsKdv3WtJds8aTdQg6W9Ug0RMOyqL2NexTAwWCikWMXZvVi8lXWHUEUkMiIcPM6QK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184986544149.95815033142844; Sun, 8 Nov 2026 16:43:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDRs-0005hV-EC; Sun, 08 Nov 2026 19:41:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRr-0005gt-0I for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:23 -0500 Received: from ci-2005b-snip6-2.eps.apple.com ([2a01:b747:3005:202::f] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRo-0006LL-4h for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:22 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 700F218007D8; Mon, 09 Nov 2026 00:41:15 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id B123F18007F4; Mon, 09 Nov 2026 00:41:14 +0000 (UTC) X-ICL-RepId: 01a1bdc0-8d9c-785d-ad8b-147b07a3ac45 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0YZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeWBoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184876; x=1825720876; bh=4MtoiGWVHD1ql7ktrdOMb3tf+OVOyyTmcQKxYtuN+0U=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=CkfHUSiL01XYvp6QGMipIp8NzM0Qm8gGdNybty55Goj8G0NqVrdeirYCvcgvco/PYCHTxOhYh4ngFuERcbsnzWgUKefL4DzsHeBLzIUh6vyj3BDo0NSmgvtyigiRRHt0+Nj/GGYkgOi75fp7aPJdRxOFUpX+4iHFONo9rYUp0fPEGQx2N81AH1T0KS4BH9Qx/8SCaEzPqh4BTmQGw5XALa4MQqK+3VuR9s86JPmZ2J0AVc1H+d/K0B21NztNMPoTI06wA6CcxgbpFmf96aV+isKRpVmokV5G/otaQda11KQ54zda4zsHVxG0N11C7iN3jr64aFSZFxrE/drZlvTZSg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org Subject: [PULL 04/13] whpx: i386: fix TPR encodings for local APIC Date: Sun, 8 Nov 2026 17:40:59 -0700 Message-ID: <20261109004108.85808-5-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=UJLQ3Sfy c=1 sm=1 tr=0 ts=6af116ab cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=YYz-tg3MKeN3tcD12NcA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX7aQ9h72C+yrV dxn2dEAskLGhikcch6pIzT7BxG9WOt6L8TsY7h122DmwwVf5jbbo41shv8eZA9xNHqk/rjPiqV5 Ozg5Tge6r2sVwSYqNJusF0MJcAqE8IWWtkfzqyZK9pCzhwTKmbXxtqiGtMmId4gUn0HTNV1Hhy/ FraoKf/eYUl80+Y+YAkOwnsp5r6NP9FjGVoWdxZCBjQm6FPgOv/0p19H4XbHTacLRzy2d3hDGhU iJp7OanHalvHtl2FTh8rleDm0a6XZfSjTfk0TkT+dyTemxL/J0QuZV96EuLkBVT36tIjEf5IO5h 1UVy3XYbXCnaLz+ZuQBcs6fy8NLNJligWA0GnRUF9Iz/sBvh2jIH0YG8xM0spY= X-Proofpoint-GUID: 3ZM-sBouDKnZjCNzVTgIcSCWnkRfcSBy X-Proofpoint-ORIG-GUID: 3ZM-sBouDKnZjCNzVTgIcSCWnkRfcSBy X-JNJ: AAAAAAAB6b2S1i9t86uGGP/ZZ6ewACoGyxYohZqO5I/jltjV3vmNU54n4XLca+eGq4MyqJ hm4O9sHRJYeteDbCH67gWwAwjjNiaXeGAWdJo75naMBgmuosJrpMRRp1BWmSKnCNX7+ZTc 5MP2q1WPUCvkm8LLlhvJtlwklKUWX41jf2O1Pyn65S6tTartQCtdCvud/mB579Q9dbTMpc 8JJgLt9qlml5OjgVvZtSIqT/CTufOXdaYtLacANU0AJIA4GMK/hlo4pTvCfjM26NaRTMG+ hexQj68x/t/LraOifNUgQKgnmZxxL5/+Tjdb4TaYO1pGV+EY0+Jr5MwESK8MiuK9fraPco s1kvY3gdmI3YT3X1u7Fg3RMP4vbI5jV7VssuqukCwF6U+UC6AdLHut+sHkTwzZ3baykJmu p4yG0TAXQCCRQ+nnB2Jdjq2KzfJme7lXL7YP8e8a2s1hLCbmsM1/5xUlL9JTaZIuMX0VSG 7K0+9L2O1g2pKlSD7yJUrlGJXOn6B+I8COiVRt7dK0bGMCSsK7dGqss4J/zzrY8GBZgqeL jjcf+abB9pKEopfiVdSjVk9Ut5sSHmlmC6uFZjG2F/o8VFFt3QeR0a0i+n8U18NPf+hEmo 13SHozabh7QNCV+18LvrXxT3iwvCdOzVkWTrjCONqFYSlWIVWDl7FR+lrVwD0huaxZzVrS HWJxfVa2nZIb4vT4cVu6n4UNki6d6TbQRAajbbu/ejXGIT073O3aRERqUrkO9EcAKVMHOF fDUYAs2eGHuQ2aQUJ2zAiFptq/RdR+c8Ki7vu42u+22RO1F4cDC7/5ehloyA== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:202::f; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184988000158500 Content-Type: text/plain; charset="utf-8" Convert between the TPR and the APIC priority encodings. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c index efdedbcd77..2d83291fae 100644 --- a/target/i386/whpx/whpx-apic.c +++ b/target/i386/whpx/whpx-apic.c @@ -184,12 +184,12 @@ static void whpx_put_apic_base(CPUState *cpu, uint64_= t val) =20 static void whpx_apic_set_tpr(APICCommonState *s, uint8_t val) { - s->tpr =3D val; + s->tpr =3D (val & APIC_PR_SUB_CLASS) << APIC_PR_CLASS_SHIFT; } =20 static uint8_t whpx_apic_get_tpr(APICCommonState *s) { - return s->tpr; + return s->tpr >> APIC_PR_CLASS_SHIFT; } =20 static void whpx_apic_vapic_base_update(APICCommonState *s) --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184993; cv=none; d=zohomail.com; s=zohoarc; b=X3JlMu8PGK0uWTk7RVpDs5C2Lsk/hsE6zNqVMSYqdbiPV4PoN1zpj1Zy9isPF9Pu7DuVoIPX//ouUxHcoSFwk9wKbMFTf3p+83Kglnf/E2MxXutIOL7/Kw22WHCeAfkxC3JuiVsM8lgzMr63y7e569E7QMwyERpPEFTOn//fZt0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184993; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dQy5MNZQGFpf+JnlbA5uYVTF4e5j4IrxugNiuk+SCcI=; b=IdAE+2smq2gFKEKj/GMN8iqBPvHnUNMakV4OYC0rHHhFsy/XW6AvUbwGpFzvtMoTuWoxx/QmpV98FEMqfjPxuXqAC6UuW91N38rhHoEAXKNqHYH6o3546ZoOHTMIk2F5QyDaK83mMCnFMMrj/3dArgbYL8Qgd8+ZCFxIILXfhZY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184992805285.27604128350015; Sun, 8 Nov 2026 16:43:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDS1-0005nL-P2; Sun, 08 Nov 2026 19:41:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRt-0005iU-Ue for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:26 -0500 Received: from ci-2003a-snip6-1.eps.apple.com ([2a01:b747:3005:200::4] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRq-0006Lr-Oo for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:25 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 4C06C18001C2; Mon, 09 Nov 2026 00:41:16 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 472A61800159; Mon, 09 Nov 2026 00:41:15 +0000 (UTC) X-ICL-RepId: 01a1bdc0-90ba-78db-bf3c-291e7c9ee0be X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0YZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeWxoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184877; x=1825720877; bh=dQy5MNZQGFpf+JnlbA5uYVTF4e5j4IrxugNiuk+SCcI=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=tJGG+8A3mm+7mxn4iyWaKrnzVxltqleDcNaKtuRqmSxy1f8YSc+hYysgHp6unDdZpuCAQZtP0Bsr6qUAHrSmWfmVOLOFr9QFQyCf2ZKCj0Wg6pzUVfgUyhKUmnKNQu3JKlcYZ5a4a/0+heL0nDPkQ2NvKtxl0+oB/Z6DLvU+K04JfyTYIxG1Ft5vzTUrrv4kf/G3EaqH3H7S4Mx44jqzjH9AfOeMG2VhWxIp3+4d1kNgPOy+WrEY//2XEAiCjft7205cuqdasWahlr3ekb1KorimAKcKJN2KTosdLGbUIySkEqgElDRc1q2NIZccBCFOMDxO2eR7MH9Q9HxaREFkxA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org Subject: [PULL 05/13] whpx: i386: save/restore xss Date: Sun, 8 Nov 2026 17:41:00 -0700 Message-ID: <20261109004108.85808-6-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX9UkNWO1W0bLk 4XnuhfnOFpLAQq3Rr7wmeRsUYy3URykn/V8EP4Vz0VRexm+SuUoXwIusaw2mIhJOAuIuS5G3tLc DZn+Q20i0kz69iMI9Mdmhc0FjN33H7UV/vgEl17gscyuYkqm1xFYTVGfLsBTQIGtHDqxFPmeceO 3xgFNWnMIEsJFzhw3IunWDqSpG49Jue9Ma8KCqoVzPl5mliW8B9JjoudbFGIsev+FzuVMX4qWBM 889l0VodW9+t8Bq8IewqkFEjNqBcRwk/r8gcCSDfHK6dCXgVzfqZ1UFG9lgRprEjikFNzJT5asF 8+UbnUU1KgrgU6BpaDLNtWEXLj8PSayVULbZDo1HrlldpVtsvbUJ6MDrVS/9Yc= X-Proofpoint-ORIG-GUID: XT-yEaqVTsTyOCX9mCKifqKgqQ3xiMI9 X-Proofpoint-GUID: XT-yEaqVTsTyOCX9mCKifqKgqQ3xiMI9 X-Authority-Info-Out: v=2.4 cv=CLcnnBrD c=1 sm=1 tr=0 ts=6af116ac cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=vvjR5Bv0Qg6bciTORDEA:9 X-JNJ: AAAAAAABxxpKmpdtWPw07cWv8s8Sl8qJ+cgL9hca4dCVdaiTGPja/sqL0kCRELU8dD1iX6 mFBlheZlVB+QsHeYaALLomq3sTk6GS2HBuV5JSuMBTKPW6RgWtud5JXY1ojZzDPF7fLq8/ hAiDPbz42XvtzGYuptUJhlawIWgKv7o5tSjz3paJbOs/3vUTW+mbxsqfKrxlBniE0tlU38 ihwQqlcdbaX5AGvzO7eshVjEgVO6as+c7wbbA2v+ZLGuDj1jrkOqqEBFlcRfhZlWecHJOZ hPdlpLuGZsApNcQk5JstltWJYctz8BQCqj5vFGXv7Bk3J3ZVLN9O5TgE1H8nEvctgGyLhx UXZ2N3tFz2Q6Z5i+wm8h8/2bBi35uWKjl20Bow4qkJQbjXfQcKTeFDfdM5+emdSa/yYxoV msoDZsdfm8KO2vJgwcO6Et3rTkoNn8gnwsn7ZyzOrZkXwi4Z3+ek0t0n4C1qtNK/gWnr5v EOUaC5DzNJNW6zdncWtothVMURH4N5h8nT756mS1ORN0EKS/w1FJolqzGkHnW65bQUAubL +nm9XGQ0h6ECEvzgmDZmKdGqOMrBBMRNJ3cmCc2R3ex/No6zKi3viN+T8hNbMtteLBjNmL wiVQcAO6Lmo+W7mwlkveGV77kfBaeq9Omg+gFv5YLz8o4ib465b1SGA30HRxauXo/bGrlp djDdheXOSJlx5IynkYgG3o87F2CYz/KnJyI7iDwA2GMVo6EmCVIb7pnquzcGeNTdYYTy+J qA2wDw9PMLYG+2pKtGH2apK/1siD5aMV28WB+yDuGWueR4eiM= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::4; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184994223158500 Content-Type: text/plain; charset="utf-8" More work on VM save/restore Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index f5f5c3b462..a72382c7dd 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -346,6 +346,8 @@ static void whpx_set_xcrs(CPUState *cpu) struct whpx_state *whpx =3D &whpx_global; WHV_REGISTER_VALUE xcr0; WHV_REGISTER_NAME xcr0_name =3D WHvX64RegisterXCr0; + WHV_REGISTER_VALUE xss; + WHV_REGISTER_NAME xss_name =3D WHvX64RegisterXss; =20 if (!whpx_has_xsave()) { return; @@ -358,6 +360,17 @@ static void whpx_set_xcrs(CPUState *cpu) if (FAILED(hr)) { error_report("WHPX: Failed to set register xcr0, hr=3D%08lx", hr); } + + if (!whpx_has_xsaves()) { + return; + } + + xss.Reg64 =3D cpu_env(cpu)->xss; + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters( + whpx->partition, cpu->cpu_index, &xss_name, 1, &xss); + if (FAILED(hr)) { + error_report("WHPX: Failed to set register xss, hr=3D%08lx", hr); + } } =20 static int whpx_set_tsc(CPUState *cpu) @@ -691,6 +704,8 @@ static void whpx_get_xcrs(CPUState *cpu) struct whpx_state *whpx =3D &whpx_global; WHV_REGISTER_VALUE xcr0; WHV_REGISTER_NAME xcr0_name =3D WHvX64RegisterXCr0; + WHV_REGISTER_VALUE xss; + WHV_REGISTER_NAME xss_name =3D WHvX64RegisterXss; =20 if (!whpx_has_xsave()) { return; @@ -705,6 +720,19 @@ static void whpx_get_xcrs(CPUState *cpu) } =20 cpu_env(cpu)->xcr0 =3D xcr0.Reg64; + + if (!whpx_has_xsaves()) { + return; + } + + hr =3D whp_dispatch.WHvGetVirtualProcessorRegisters( + whpx->partition, cpu->cpu_index, &xss_name, 1, &xss); + if (FAILED(hr)) { + error_report("WHPX: Failed to get register xss, hr=3D%08lx", hr); + return; + } + + cpu_env(cpu)->xss =3D xss.Reg64; } =20 static void whpx_get_registers_for_vmexit(CPUState *cpu, WHPXStateLevel le= vel) --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794185001; cv=none; d=zohomail.com; s=zohoarc; b=VRXlTjEWJa7cIJXkycPQWz6EkildALnwQb5iop8yBDJyhauqMNtvFhCnME2QK+sLGLE+rWtkUNPiOYKnIv71rM2T78SBX7BU0AZcsXja0OVHEeto2v68YaJZOqGUjRkgi/wNU611VZXowQxxOppwPPE09KizORz8O/J7iHgNxsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794185001; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zo8VHkRvOxPsN0lBHLgB1+jjjExS/dOPgbaOWnVL5Os=; b=NYIpCaHEQTlIuZjxXTADopj3p9AcLk3LV37gQgzuPOvaGpe+xAsWHD37HvO59oMAI4eJDpTjeSEwkLt2Tp+bC+9MZMRnqODdkx5kaI3+Ap5nctwx9GfQjO7//2QkMsHJfDOmQfYZI2+z1Xd9XAP4N0/SDd5GeS53GPCkQlb5qvo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794185001218806.2815426628935; Sun, 8 Nov 2026 16:43:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDS2-0005nT-98; Sun, 08 Nov 2026 19:41:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRt-0005iT-SB for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:26 -0500 Received: from ci-2003f-snip6-11.eps.apple.com ([2a01:b747:3005:200::3f] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRq-0006Lw-Oc for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:25 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 7F52218007E4; Mon, 09 Nov 2026 00:41:16 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id CEB4F18000B6; Mon, 09 Nov 2026 00:41:15 +0000 (UTC) X-ICL-RepId: 01a1bdc0-91c9-71d3-a49e-7ada854a5799 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0YZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeWhoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184877; x=1825720877; bh=zo8VHkRvOxPsN0lBHLgB1+jjjExS/dOPgbaOWnVL5Os=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=1MJlnSZ36shkWPmpUd8oGTMw8zm1eQSu0dDQ/q423iUXGzWUFaJEaqOYXC3neRgcE96jfL1EEJNsxUehM7Dcmadp+tvBNZbc/7gYBRyWT1jH5FvVQygA/VN4x6SZJk5HY+rq6GBTRdWgzNT6haS4kVQmK0hcU+NOlRIqI7LNX5YCMGYYrvE9NgazPfhJBr1iUrf6uobCDfnf/AvQCAYzM66+h16o85dV1zg9tcHpgrOZ/rec1CJZ69Zl8HlHCJi4F9XBWDDXXxhiuf991BrNuhu647bP+Y7iJh5nzY7dAfV11EorV5/ZjButCppDQDA0Xr0ULeIHI3SwWyZYaho8jA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org Subject: [PULL 06/13] whpx: i386: make nested virtualisation init failure non-fatal Date: Sun, 8 Nov 2026 17:41:01 -0700 Message-ID: <20261109004108.85808-7-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: khICCEFhy0Wiw2h_IOi8XmZ_BvcuWZvp X-Authority-Info-Out: v=2.4 cv=LbwxKzfi c=1 sm=1 tr=0 ts=6af116ac cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=p5XUOwc6s_shZ6Vv324A:9 X-Proofpoint-GUID: khICCEFhy0Wiw2h_IOi8XmZ_BvcuWZvp X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX8njWqmqEIWBq ETSiRZc7nggMQrUwYrQym9YZ1hFPu+5aSFEPid+jQKZN1OzCoSnNxcoh1of5w3howmnGQx/QH4u 7SjyyHpJHGZ8ErGXQLxyNei9gfGQFyYkNrnSWq14b+/9S4Qy7o4IB6zwTRrDmn86wNoYIkXN1nl +lVGElxprbg+xQ/PBs3wzp8HoVHalRwciWJVg+h3PGEzu0H1+nhDWW6YWCmuZpxWpJpEsKVKFF5 /IeuonxmURiDIi0LzI2NJ0GGPzB4KdULV/kd4+qYVirrsdoNqW8yef+ZtFjR4DQWo4G2XavLIPS 4KeW7F+i5dh/nbDKaRB8cKIn2NW2i9OdoBqh7h3rkGUJDItcYsRWvLdE8jhz4Q= X-JNJ: AAAAAAABobQgE5/GvvAaZt9X3aVAqqKaP+p6uLLYMsAhdA75/UrDWWQQubqB32hqOIQXYN 5vpGpszOKmzqwlKYMMZNCQ/5tjvUYGaQnLPge63hzq2ueL6NqQBy/w4igJWF+oYIh4p9Iq uL9ZxoUkRYgVyHSmW4aqMIkIHX0AwkNI7OF4LwpQCdfqF1IyMixmLZQCEMvEyWsg9cFlbe KjSwJfjB+Rv8Lj2f1UKFZl7kIuh6txRQ+LrdMYm9QSOG/iyiXVWlSorLx95dBOhCzeK2yy ZA3I3uy7/KSHF11nE73C177hwAeZGoPDMb3jC9R9l/Hu/18SiKUuPZuwqMxAGrOx35TA3c NRsQm9TzxIh2/CMXWQypIukVkPBmjujH07iGq5y8HdQCJzT2pKSLmU8vb38DSVSK2D8aOl 1SOoEDolfh9eJYdpOuU24nrbTOsAS/eoOKIuN3j7JcKUuTNsvKWlKJakxdTWIsgMfN0Mmo EAWYgUwAlf2gn2NVh/3HaPpctB92Eeq7etQetMTeRr2qmvPFzI+ZV5jBN/UBTjAyIoa2U+ m648GJmD4Lf0aaTsymm3C0oXKWWWbwSl/noK+roEpdqKA/ijfT8UO5dxQ1F/WPIG1r6xN3 b8+tMuY8F3axasDBpyxnn3g80ybqFHa1ZbNEl8P/IV+w2DlB7zNRm3a4nFYOflsx+wJvqQ Maqr4DQ36UpJb8Veuu910wJFemDjUIo0xhjihm/KHLjWVi1E/83uy710/KQ/J3d31VhaIj CsqBR5JoRbKl2B4jZHz8rFDs5sEZ7R5U1+rGIoi3VioxPEHnLDgjNv3JVXf80Ax6xehC9N NPEp Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::3f; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794185002210158500 Content-Type: text/plain; charset="utf-8" On some CPUs too old for Windows 11 (Skylake) support but running it anyway, WHP advertises nested virt despite it being unavailable. As such, make failures to initialise nested virt even when advertised non-fatal. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index a72382c7dd..7e418f1c91 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -3263,9 +3263,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) &prop, sizeof(WHV_PARTITION_PROPERTY)); if (FAILED(hr)) { - error_report("WHPX: Failed to enable nested virtualization= , hr=3D%08lx", hr); - ret =3D -EINVAL; - goto error; + warn_report("WHPX: Failed to enable nested virtualization,= hr=3D%08lx", hr); } } =20 --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794185008; cv=none; d=zohomail.com; s=zohoarc; b=Y0RO60No0c2ipslpsfuNteUU6MFpOchFi49tdUfvh7pJ/ueA5xl8+yavo/D2UxrsAMl+gmOu5C2H7yDtQB06DmI+HzQoXKJzgzFv1FjiZ1RaFTzfqVvS62f0eJLTXZQluSlFLkblGuDRu1LkcJG6cUR+v7L7yRxcV4B6WR5qUAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794185008; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=msvtbRnkNcds4kjimnMrSS+ln0rONrR/84Sl5Z/Nyh8=; b=EVTzkdiKNJ7edrEm20E5c0UsNCYUTFTA3KmDlz5QzyEDrRhJNXvPURtgoLb245VG5onsYeuuStHNdPe6CAa8kV3xShUWM4qMiCrgZEgSI1deWwVVCEPVsYIpR1WRMr5d7BDHEtG80J62mUQczn/VjlCx/7THUWotCKGsSDklMPI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179418500863662.56343210673447; Sun, 8 Nov 2026 16:43:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDSK-0005ug-Jb; Sun, 08 Nov 2026 19:41:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRv-0005jh-QV for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:27 -0500 Received: from ci-2003e-snip6-10.eps.apple.com ([2a01:b747:3005:200::34] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRr-0006MP-LU for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:26 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 56386180010F; Mon, 09 Nov 2026 00:41:17 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 655E318007C0; Mon, 09 Nov 2026 00:41:16 +0000 (UTC) X-ICL-RepId: 01a1bdc0-94f0-7d9b-9534-7ad2a988e152 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0cZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeVRoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184878; x=1825720878; bh=msvtbRnkNcds4kjimnMrSS+ln0rONrR/84Sl5Z/Nyh8=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=bO52jyDg8Qs4x1JPpbdTuWLZPmkSxOUGgZjNMI7RjTLx1zzC7sB0B2Xz7Kf866Tswzjdu4KffbgbhQU7p0eopPzYFYV/iCX0xrk7UF8aY5g8WTxWBtu4pDPc1K1QIKgiLVKctXcCpJ0dTN9wslMpFTU3tJTqecuM0F6iLp+CiyegzkYdIzohsiEWIcqG3nyfBrBDU/9rf9TYXS3ZMzjfHToTWLT+yJUYaUv7XWcDNGt9ZYMNe5c7wjCZFCVULdo1T8Qrfc6l/277YrkRc9oZ3St0pPmd2L1IPzXJ0fMZqySvNSA1GIEPX/rR6rAZEPWrt/HQvrlukXi1hfMKgj8oCQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org, Boden Randin Subject: [PULL 07/13] whpx: i386: avoid updating hflags for vmexits Date: Sun, 8 Nov 2026 17:41:02 -0700 Message-ID: <20261109004108.85808-8-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 4ltYpodwaV1Y7shP9F1xAIpgHuDKA8n- X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX29ku8tMcGuZd 9+L3ONFgPEeX7g3LyC+S9TYelJ3Fq2nhcKLLiigbsPxQbiw8c9V0toq9EyXZ9WXb8ilSHTPA7tS Z5QL2sCx0SG2FCCqQgXsvseAvQjW5VlxU0jezg7NB7Zkex+G1c2DO7+6u8RpWhRPFEJDjUsp5mO MT8sM/M9WsLikEPSyHgk6gelwipRVXU870XPIe3i7brESt2v3s6jAPYMIRv6Q+uULG2k8iVwBqJ C5DAe6WucumWQJCXpWho9igy0tzK8E0wUl0F4TYOwxD4I3koocIB3jM4MQRjZno4UjR46TEpDSl qVM+upNencx6lE0WkxGFJtVIY95Smj5dIbeY11gn9perc8vjNIBZizTbGOs0nY= X-Authority-Info-Out: v=2.4 cv=X5Zf6WTe c=1 sm=1 tr=0 ts=6af116ad cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=pGLkceISAAAA:8 a=XFq3rTXSGl1-eYzejacA:9 X-Proofpoint-ORIG-GUID: 4ltYpodwaV1Y7shP9F1xAIpgHuDKA8n- X-JNJ: AAAAAAABPH02SL0Xahkvci3GYjjO9SyzWHNvoFk/qY3ZOSpcLQIqBY2+6CQ1ykQwYizJO9 K80D/msVp6KDk5vEHxbMVbjGFYNhiCjDMnqPaLIXtRG//60RZ5WAuim4sCy6h62GtgpFbG X/FUdmb1AGtHQwDg7uneit55eObco7wnSSLAJEfQNSNOnq7OL1ev95k40D+hCUxRbFEq/5 I07jV029NKCSNLjDEU9KCePMYtMDNEAaqtXw1ih7JbAw1mO1BC2SfzbLFZWKoyt4nr6nyc kEb3P3GvfUjuEewnGdwpKNWujXueg9THqED1LmApFyYuzSjFTX5ZXXSNllFKQr/Cc/jkNU zZea+zQMoNx7ATz7V/mUV8qO3hBT2zS7xzpuxRbtkiajN4Ydcq9xosSLe+UKhJmE9fQK1n tfMpI/qHrMufOfaFp+DqMetthRr5s725WQPSMMTJ4wRnoy+G+wy2JGCowqvu/p7QEG6PsA JPwoepBuI3S1z0B55Mt+0hG3TRKbBHhFaSNl2hyR30lciEnn3c0+5cfdeGqXExstw97N6m atY/l9g9gPt5vbR/VnoJF+XLIHt7D2rI4BkezHEiArMF3VW0DH77Wa2xgXSwqPddPTpI1L kTwn5F/mgzSE8ZvLa9+hapXqhIbydnpy3KTJ+oWVkcCRBwLa39a+xjf3HgKltdn0//mBh/ rf/S0WqSwQ13VhKRjYME5ojv0iN+nqc/4Bbs7HdpVkuAjSB/PIOUIhwGno6jsE2T6HK23E tOk4gjSWFbKF7L4yvhOg6px9H6NbW66BBMPSMDFYPvEvh/6rk62wL501YZGeJcp/Qb8AMx 79dLqVc4Y39zN7HBwvtU8gwYOxe3AFwpEg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::34; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794185010312158500 Content-Type: text/plain; charset="utf-8" From: Boden Randin whpx_get_registers_for_vmexit only refreshes GPRs, RIP and RFLAGS. x86_update_hflags() depends on state not refreshed here, while the code using the fast runtime state does not depend on the hflags it recomputes. Signed-off-by: Boden Randin Reviewed-by: Mohamed Mediouni Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 7e418f1c91..8807a7b95f 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -772,8 +772,6 @@ static void whpx_get_registers_for_vmexit(CPUState *cpu= , WHPXStateLevel level) rflags_to_lflags(env); =20 assert(idx =3D=3D RTL_NUMBER_OF(whpx_register_names_for_vmexit)); - - x86_update_hflags(env); } =20 static void whpx_get_legacy_fp_registers(CPUState *cpu, WHPXStateLevel lev= el) --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794185000; cv=none; d=zohomail.com; s=zohoarc; b=ido7q66IZfxzT4+Pyh0bz5IIzuw+l49vfmXlv745WPgu45JSCJPgxAE5ehtz52OsGtnqX17ysH9+zAjad8sBeNsCf4yjx406c6RirXZKnTJztBJ/mbVNxb2IUwgbZ6MnM+9+1JQdRJkZyfveop+RCXvz1PulR8P5WFS2wiLyhW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794185000; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7tPPnHKP+B9aIxYDisiG9Yiz7gpVwqI+5XekoasBmXY=; b=PuCLNyk9TqbaEJER/LcwXvnJ8IoZFWDl7ytyLOKdF51eA6c1TLf/PPpF8+i2rnWOH0dED98YeLJkqNUv2FGfnqKfL8eSHIqUudVsVyIz00NZjGtLOcXBpEJPpr3OL91oZBlRpGnEHmq6oOAZ3RWuGOLmk3UbMN+i+ZUDflpJKVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794185000785962.0824738338246; Sun, 8 Nov 2026 16:43:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDS1-0005ml-49; Sun, 08 Nov 2026 19:41:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRu-0005jJ-OL for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:27 -0500 Received: from ci-2003j-snip6-3.eps.apple.com ([2a01:b747:3005:200::60] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRr-0006MO-F4 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:26 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id D98F61800159; Mon, 09 Nov 2026 00:41:17 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 0D83218000B6; Mon, 09 Nov 2026 00:41:17 +0000 (UTC) X-ICL-RepId: 01a1bdc0-970e-70df-9e06-1466b9669911 X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0cZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeVBoGXRhYFVYJdx5cAEsdVwRUH1MSVR0dC0VVEgRACFZQVB5BBFYVbAlYBlMZVw== Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184878; x=1825720878; bh=7tPPnHKP+B9aIxYDisiG9Yiz7gpVwqI+5XekoasBmXY=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=M8vV56hHIDUr8JjjCZDqd7VD+o0ORTLDmDaWV7+whrZ13ompiW+Gr+OMljfQTo9JhbdD9qfpaDrURcnhDKY1p9QnMRytaEmsqJj8gf2kTj476xm298JtG7rBNzU+aTKSx+rr/OgEKj+qcKyxrUYay3vqS/ErCEu3NbCycVV64pFpxhRyO4LCnkqMiqhCGhPqkdj/K4BuRTGsz0unB/zXVmPpOGNIzwSskUHtGCNqNMxnmBXJ9AJToRg2JriUa5kiO3s9KheQW+EsVPnQPPm5pPw/GuCUng1nJDMAxwfKsugUZMfdOW7bON2L88iptDaMqt78Q1ukg4Dx1riXZp2ePw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org, "Doug Cook (WINDOWS)" Subject: [PULL 08/13] target/i386/whpx: handle processor reset Date: Sun, 8 Nov 2026 17:41:03 -0700 Message-ID: <20261109004108.85808-9-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: d07mPBDoiACopYbzC28vVFpFLzaWcQDo X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfXwkZNn+HIp/dK y6f7vqmUqku2EKEg9vcdyA9M1K1nVw/92yCa8ANOVX7qKS8PFu9A/BOEmZbr3UJ8PkbTmWfa3+N 9eYGIzbwmI3dsgUbDH0pgb9rP0VmwXjOnHq5YgEd0XFmE1WlN5/s6C8XxqgGKZpI9erI2KApQk+ M9DlG2uNLodT2MKcbwP5o5kn+kqmO6S40DIRjy7iqYH/20XHJjcsIKf/0kuV/XjKluxX3u1hlcK +kpjsuwAYDVAcuS3KjAy23IprXLUwM26eV15EtTOGol4xxaTY/qn5+Zbu8iGxHtY/qSDlp1lM0D SV3BO81e7Mu1Sjgls9rOxJLSA2ZyrJVfD5Dfzl9/PfPM6rFO1SN4xXwol4yN7o= X-Authority-Info-Out: v=2.4 cv=X5Zf6WTe c=1 sm=1 tr=0 ts=6af116ae cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=p0WdMEafAAAA:8 a=yMhMjlubAAAA:8 a=eqzMyDhjfWJDk1Qr7fMA:9 X-Proofpoint-ORIG-GUID: d07mPBDoiACopYbzC28vVFpFLzaWcQDo X-JNJ: AAAAAAABd91ejgvxyE698n+C9h3a14zVZaMTlRTFK38coTUZCZ23ZbXuFphBJVeaesbOie ejnxhu94/p3TkbuWh2VLJXUA/WrodX864N1qRKdTT7FlqfAWswgoy1z520P4/5zAr7WNtD w0uF/bJfm5UNzRQujDxtbA4Mdh+Ns4BgF+OUzkET0b1SXu1cjPrUeqz8aH9TDNGZu5RQny QiyD+OgGopIq/hG+p3DT4ZfuIVzw7136+Pz+vWyKm4/8aIHaqb1r0798cwDLUCW6PHfk6E 22Xl1pkh7p74Y8Vd6i2PLFwMOKba+R1VUzk7QZgNldZTjf8bAYEgcmDJduvknDMntgeDmX W5Hl16CiGogIzAii9ZSS6onotuqJdGb6CJKsCYnepH1i7jmwLnuMOQY3oBSO5UWtHMxZkn RTLT291cF/X8WO+RzdfZsf7u1rzuCZ+MXwmbeDMNc3sWcndKL8F+0xjUBOOOVY9n3R4Fbk YAAFdN53avOyuCRFcvGI2UVCN+kKW9+roo55wjBPs2igdm/9c25iefeI+4BtPnIJDpgu7K TWDmpHohNGcZIr52sqcLTY2Hsn8iP+6cpt2LdNnv6mjFtUjKD17n/W5MMfkeshg2T4RP7q 6g1wYSkfvxfGMnMURavqHzURFTKUAttq6iileUbyP3fgBmrT2GfMY+fY+ZukwHGdw4Fwm8 EuA5PF3sv746FYpKm/lH9/j7B+WSajjIh397XNK5qwYq7tNK7Ui/+ZVZgR8MhF8RQzmhh4 PtzGIruADRUvJ8fkzx6xwuKSIeCR3HapjRjza2ucQ1rmTaQXpYU4/2SPR5mNudcg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::60; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794185002231158500 Content-Type: text/plain; charset="utf-8" From: "Doug Cook (WINDOWS)" WHPX is not properly handling processor reset: - Does not reset partition, so several registers (e.g. Hypercall, GuestOsId) carry values forward as "Locked" into the next session. - Does not clear hypervisor-managed TSC deadline (live-lock). - Does not re-arm the wait-for-SIPI trigger, so all CPUs start running immediately after reset. Some firmware may tolerate this, but OVMF does not. Typical result is that boot hangs or ends in triple-fault, e.g. qemu-system-x86_64: WHPX: Unexpected VP exit code 4 After this patch, I am able to boot to Windows desktop, reset, and boot back to Windows desktop. Tried many times in sequence with no problems. Used several different reset mechanisms (OS shutdown menu, external "reset", watchdog reset) with no problems. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2402 Signed-off-by: Doug Cook Reviewed-by: Mohamed Mediouni Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 8807a7b95f..2a91eabc10 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -541,6 +541,35 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel = level) =20 assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); =20 + /* Assumes that cpu_synchronize_all_post_reset() runs cpu 0 first. */ + if (level =3D=3D WHPX_LEVEL_RESET_STATE && cpu->cpu_index =3D=3D 0) { + hr =3D whp_dispatch.WHvResetPartition(whpx->partition); + if (FAILED(hr)) { + error_report("WHPX: Failed to reset partition, hr=3D%08lx", hr= ); + } + } + + /* Reset hypervisor-owned TSC deadline. */ + if (level =3D=3D WHPX_LEVEL_RESET_STATE) { + WHV_REGISTER_VALUE tsc_deadline =3D {}; + + whpx_set_reg(cpu, WHvX64RegisterTscDeadline, tsc_deadline); + } + + /* + * Re-arm partition's wait-for-SIPI state. + * whpx_vcpu_run() ignores cpu->halted, depends on SIPI for this. + * This must follow WHvResetPartition. + */ + if (level =3D=3D WHPX_LEVEL_RESET_STATE && whpx_irqchip_in_kernel()) { + WHV_REGISTER_VALUE activity =3D {}; + + whpx_get_reg(cpu, WHvRegisterInternalActivityState, &activity); + activity.InternalActivity.StartupSuspend =3D !cpu_is_bsp(x86_cpu); + activity.InternalActivity.HaltSuspend =3D 0; + whpx_set_reg(cpu, WHvRegisterInternalActivityState, activity); + } + /* * Following MSRs have side effects on the guest or are too heavy for * runtime. Limit them to full state update. --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184982; cv=none; d=zohomail.com; s=zohoarc; b=dvrnZc8Qex9pgld3LjYbN0PCi0ufxBL5+rF9rkMhjAvAO39AS5mi+GjBrTSEWmwipf3nTUazxKV+P20JpHlFc+genDPTr6R98zN3t2+FiBXfz4DB6gKhog3mjUm5QhVB4++UhBjIWjWh5qvk8xt1B+oH8+uajNdv8T2siC+/Grg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184982; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VU83oDCgFHA/p3V3FO5ZcurDhJlE6enRQJTLmsz1zhw=; b=cEbiljxTowefPScwSBeVZyiBtym2MDOtc5tNwA72BtKI2XwARFu8QzQ5pWyniNTEoYU1BA/sHCKy+GSoFNJZdtP00YgeqRCF9IeNBXdsG8zywCx5U6QF1OsqbQev9ESqz2ByLxiizyXcoWvxIvFfNIsv+J6wsvf62e3n0v6prOw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184982312372.2288822337056; Sun, 8 Nov 2026 16:43:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDS6-0005nl-JK; Sun, 08 Nov 2026 19:41:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRv-0005jg-Q7 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:27 -0500 Received: from ci-2003a-snip6-11.eps.apple.com ([2a01:b747:3005:200::d] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRr-0006Mj-SN for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:26 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 4880D18007C0; Mon, 09 Nov 2026 00:41:18 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 9802018007C2; Mon, 09 Nov 2026 00:41:17 +0000 (UTC) X-ICL-RepId: 01a1bdc0-98c2-78dd-bf35-50d57d0f7a7d X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0YZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeXAdGXx9RGV4IUytHHkkKVgleCEYRWxRWQ1EZDFBNAUMICghHA00XXjJTBF8RUBY= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184878; x=1825720878; bh=VU83oDCgFHA/p3V3FO5ZcurDhJlE6enRQJTLmsz1zhw=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=kfTWd8ZNH22CGgtrqLyn4JrNBiHgNOvw/s9Hu4wRR3GI2gkzbTuBV/N4TdF5pXklIGTxOEWiMvLe9IbD/z8AKi8JtUqJd0wKu6K0x9CPGn9M6slWUBweeqWqcSnGCnaM8zzV6Agl6L696kLLIUiR5IS+MF8f+O5rFrqoKgqbtn+zQx/zw84c5QCq3sFkoB2x+jFUFK3v/+/Py3NatfVWd0hk6GL1vW2yq3PTyXd8o25UyBGy5CRAMvBr4qpewYd1DPDxLiQLZivUSVz2cmQ5H7mOujbwdiW5szqEaMKHs/ZvltYaKcomn7XDo35xgiTXOfRj/ioDBJbH/ugiOp6zOA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org Subject: [PULL 09/13] target/arm/whpx: handle processor reset Date: Sun, 8 Nov 2026 17:41:04 -0700 Message-ID: <20261109004108.85808-10-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: QvaVmyHLKX6Pv1JfY4KDN-DQynxhsNXV X-Authority-Info-Out: v=2.4 cv=LbwxKzfi c=1 sm=1 tr=0 ts=6af116ae cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=loPyruWHUH_f1C729x8A:9 X-Proofpoint-GUID: QvaVmyHLKX6Pv1JfY4KDN-DQynxhsNXV X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfXyyGtcXS0wBiL oNTPgpCHj58tSmDkxla2BqCEB783wOnQcfzWaOIPoubnFh9NK3yfyvYOxhDnCed17OfYTOfxBuG BX6bHnNChuiHynRvz01LMQpS/O7SUL+tIzXNVA1qv4qfrZsQMwKyoeTRd3Zd+ipmCcEAbzY48uR 4b8yjJy8JySPNapLwQBiDG+vO2TiaW9sv16GKKvQZlCE376wsDFvUXaBYFzmFHNhaIK6e2coR5o jmJPUFqK0rPNlz/mmMijK9hsmb7QS/TlHNkceUPJo/eRWadrOO+s1WfiYji5aQ7ale3ll44zPQ1 J9X0h+Dy9ubq5hvjlH2OasglkL6vbOb1a7dUEA77ZNK1TXVqtXUnW0zXKKz6ao= X-JNJ: AAAAAAABLWmhJ6rvd+F/aDCZcicJwh3haNuE0tUu6d9Mup1sGQ7XJqIri9govgaoZubpOE 5iv/1sY8DK47Xjbt/a/d8rMmeXVH4FGb8xjAyz6Wij3yY7Df9SwIR6bVkqhWy9ZE/3hVh/ DhlfH2KgvyvkLYIwNOSKHb/67wsOH7+HiK62iddfVA+WPltDTOTNec0C6e5qXj2Saxn4Vs b76mAC0R1XIqHLm8YMu7XJ43xG/XhXjblUYF5iOluROt2Zj9CF5Un70M6mdoSCpniDOYho ylRdXZcUpLqE6aIMsURXXZauoLjTNe4fIwFTvwfXqYfNTAOHBu9o1VA/JIJiXcwEbfSSjG e/YkbkEA1QLbSzjaQCmO0NJHg1J9cZ6/d27R4TNg1mFNV6q91T4TQLWeosvlPfJxAGOTht Vr3kXf4mVSdXmEphkcU+M0BWolKhJaC1AqH3kYmUVNMUrdhN3auNWqNpjvTvAd7338FBdo TR27rYyEdECG+12BE/mbSExoIpsI9xFmMD0PRG1Y9HeZ1r+BJKoRlUHay9GGBgz0L6J9xq ouchzmiJAKpUlYXAsXbsTeOdeKbPEZhOfl8vzCWl0/xEF2yPZCcarQB++9bv+MdvMtd66K IFPRy/3VmkxDwPcepu9jddLAE0EN/QzVeWqlmwSuoE7KCZJW4VqPYv58GJZgkzAxvCjss/ xWJ+bLSaNt0TEKXgQuo4y3e0JbXjIJpyJ7xmjjNX02GjKi2WJuyUqFiBQ9NBMBaQo9F9lC it9SJil09c0MxH1Wab6P8Ex+cgdm+xLLZoAVE= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::d; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184984550158500 Content-Type: text/plain; charset="utf-8" Move WHvResetPartition to where it's effective on multi-core configurations. Signed-off-by: Mohamed Mediouni --- target/arm/whpx/whpx-all.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index ded42c980b..b702dfa8e6 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -471,8 +471,6 @@ int whpx_vcpu_run(CPUState *cpu) if (arm_cpu->power_state !=3D PSCI_OFF) { whpx_psci_cpu_off(arm_cpu); } - /* Partition-wide reset, to reset state for reboots to succeed= . */ - whp_dispatch.WHvResetPartition(whpx->partition); bql_unlock(); break; case WHvRunVpExitReasonNone: @@ -573,6 +571,14 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel = level) =20 assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); =20 + /* Assumes that cpu_synchronize_all_post_reset() runs cpu 0 first. */ + if (level =3D=3D WHPX_LEVEL_RESET_STATE && cpu->cpu_index =3D=3D 0) { + hr =3D whp_dispatch.WHvResetPartition(whpx->partition); + if (FAILED(hr)) { + error_report("WHPX: Failed to reset partition, hr=3D%08lx", hr= ); + } + } + for (i =3D 0; i < ARRAY_SIZE(whpx_reg_match); i++) { val.Reg64 =3D *(uint64_t *)((char *)env + whpx_reg_match[i].offset= ); whpx_set_reg(cpu, whpx_reg_match[i].reg, val); --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794185005; cv=none; d=zohomail.com; s=zohoarc; b=VNkWrKdprECiEouvzGp1s5Qv0GdXH2JmDausadOCRXA2HXnjKpHgITL5j2q0NZxlpLSDoxzL5AaB4N+uFlUKl8KY69FrEvKJAr6ZI0ZbYPgINJhBBbMBxywHxXGabwJbDiiOptieyW9e40R7aA7+U0rgdX9yXn+3nh15Qrd4ERg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794185005; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=d9reyV1jCF00VTlpnA3Dp8FbMUhLRSFOmv7Sc4XHdpc=; b=DDPEjl/p/NtYQz43Kf7wBUrXo4kRZDAiGXYXfponIa1K2P7cEv4surxsQKJ5YUaxcfB7TKy2oDSP8Lb1bKLVjpshHv32ArnCLr1yg9C3/H69DvSEtZ58hbjodvi3bVpsBqz2pSlPlwbiGGY2d9Ic0ptrQokvVVp3OaHF0wnTRb8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794185005499706.5469995053908; Sun, 8 Nov 2026 16:43:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDSK-0005v7-No; Sun, 08 Nov 2026 19:41:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRy-0005l6-9l for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:30 -0500 Received: from ci-2003b-snip6-7.eps.apple.com ([2a01:b747:3005:200::14] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRt-0006NF-99 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:28 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 2266D18007F3; Mon, 09 Nov 2026 00:41:19 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 301DE18007F4; Mon, 09 Nov 2026 00:41:18 +0000 (UTC) X-ICL-RepId: 01a1bdc0-9be5-767e-98e9-b9dbb9da6aa6 X-ICL-Out-Info: HUtFAUMEWwJACUgATUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0cZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeXAZGXx9RGV4IUytHHkkKVgleCEYRWxRWQ1EZDFBNAUMICghHA00XXjJTBF8RUBY= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184880; x=1825720880; bh=d9reyV1jCF00VTlpnA3Dp8FbMUhLRSFOmv7Sc4XHdpc=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=vgBpKqHXjJPx0B3b7RTPHT2C9V83D5WZ3+/s511ed3g5lD2Qus+igqIpizfwHYS8yMJK80MpmRJ/41AXp8K3iQiPYEByBca+u98RpQojtGGA1VP1pxVacz+eNvlUSsJD4YNcYt14XKuOv5L7ZjwIG6tjobc/dl2JR3PQCCKPFmiNENm0/FjxZDSqfYJCawT2oUZt0ga9xVhSy6mdwJpKwGihAwt6SU1lCRgfn3IAPs7ljMOU0lFeHY03FoY+rCOH/o7qVlKlg15yI4MOBMDHJjXVTjoK92ciuc7kXMj/VelG4YsTFHVcOOHPbqLfUh3MUSJcrKjaJswwE98Fv7B48Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org, Kostas Chatzikokolakis Subject: [PULL 10/13] whpx: i386: forward the dynamic EBX of CPUID[0xD] sub-leaves 0 and 1, not 1 and 2 Date: Sun, 8 Nov 2026 17:41:05 -0700 Message-ID: <20261109004108.85808-11-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=D8FK6/Rj c=1 sm=1 tr=0 ts=6af116af cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=DGLFwGUCAAAA:8 a=RSavJFEQRcchf7d-p6oA:9 a=4cWXuvdlNTBkoNYRywza:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX8Ijaer3cba/I RQ/7zjoRe4isxYUif0wYufhN3hHAtD7GXqv0AR0ZkcgifDHzUcBSr3hhweghXzCOT6Kz9WjrPZn gzQZglFqr06PH3BdeDey34aop+Yvxy4oSf3bF/6k+4BqaZcoC2+DyNiOOHei/6B6cS9Emts5JcZ XygSmwKM/A+kVhi/tRffOvqtDuEnv/NQohZXu5Db7QAJEPiIBrYoV0BmDni7Diqh2YGMvM6jtLS XSSE8bNGv4Ih0n4JLTyY1oJVgK8KfyGSyu0fWFPH1GYFJAAB8udKxB2VziIQksYCzQubAfTG7/j pqCgFrFc2XF+nTcDH+XS3M3LBH5c9cYOB+jSctCqJTKuCqF4T6tYgUMFQFaGHQ= X-Proofpoint-GUID: e2f9fth2d2SmVF0QSeAxxu8LDJg3gb4G X-Proofpoint-ORIG-GUID: e2f9fth2d2SmVF0QSeAxxu8LDJg3gb4G X-JNJ: AAAAAAABm2i0fKYI5uKusLHMnjOsn8y/oVdmY8Z9x+X2tnIY9CjERrAOKwHdWcOC1eTmBq oQPNjCr2ztdwTfd4b5pal4a7TtLz0FyNMqJg9Nom/zeKLM2bmjC8SuzfLxKF+Un5x7+eIC TxAqbDiJpXaFtsUzHUe93Ms1k9My2rYMy1SPJWT0O8swzPVcRHfjKDKO+pH9Y0mqqLP1ZS VdfGV0dNSEh0ThVhGjLFE/oJg10brntUIethKlPmAFtcPAi8XcQ9aeYtDTA/qShw1Tp0S2 xZ1Xl84C6oRcn5NFV/jTtA+VyNsIoBiZh+k23c19R2CK2h5qOf8IOPBV6ZBJ61gX9EuTUc ddKNMd4inXE+Vwp0htVezZYrNa8OeEK2rimBlNRyWnIEpGK/W9Xk1cp1IrX1qyykqH4+Hs TjnwvqPDOqlWEn4KameuvLfwDG8+AdcSthXzLZhAhx6ynYALHoJZm0ejXTyZSfu0kS/3+Q yKiEIhFE+SBKrYKFOvjykYB9BUktpks0XN5oHDI0L0jdHW/JhXGxLig2tgI0cwj79KDzUY lVa2IUNAn0QCbVQKO3BGlgRTaUw1uPLzT0nYTsNh1tCavGv18KIBw0hcqho3zYS1JEjrxu wXcLdmUheMsCvzYBFrpay8l73tpzyn05CNLjE9zBEGopP0b3xUkUVk8Hc25EAr3r1nHV8b +ZAniTmB4qo/IeZa5RjII5lRuQtJ1+AccksQvk8RcQD+UudJwRuOj0kqmJajpg3h9j9s0e 1JShDAIs9BHXteomogMy20VQUGRu35BE1Va4CoidSG+YT86uJjYiNSazwLN3oYBPBAdjbl 8KLpBCnkP87MbSvkra+ubBmX8KG2CJVYIUIftidk3GxbEUiE6VlO Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::14; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794185006332158500 Content-Type: text/plain; charset="utf-8" From: Kostas Chatzikokolakis CPUID[0xD,0].EBX is the size of the XSAVE area for the guest's current XCR0, and CPUID[0xD,1].EBX the size for XCR0 | IA32_XSS: those are the two values that depend on guest state. For sub-leaf 2 and up, EBX is the component's offset in the standard format, a constant. whpx_vcpu_run() forwards Hyper-V's DefaultResultRbx for sub-leaves 1 and 2 instead. Sub-leaf 2 is harmless: QEMU's own offset was read from Hyper-V at vCPU init. Sub-leaf 0 is not: QEMU computes it from env->xcr0, which WHPX refreshes only in whpx_get_registers(), never on a CPUID exit, so after the guest's XSETBV the leaf still reports the size for the reset XCR0, 576 bytes. A Linux guest on a host without XSAVES takes that as its kernel XSAVE size, fails the consistency check against the size it computed from the component offsets, disables XSAVE and panics on the fallback path: XSAVE consistency problem: size 832 !=3D kernel_size 576 WARNING: CPU: 0 PID: 0 at arch/x86/kernel/fpu/xstate.c:638 fpu__init_syst= em_xstate x86/fpu: XSAVE disabled BUG: kernel NULL pointer dereference, address: 0000000000000010 RIP: 0010:fpstate_reset+0x1a/0x90 Kernel panic - not syncing: Attempted to kill the idle task! Every CPU model with XSAVE is affected there (-cpu max, Haswell, SandyBridge); models without it (Westmere, Nehalem, qemu64) boot. A host with XSAVES boots because Linux takes the compacted size from sub-leaf 1, which is forwarded; sub-leaf 0 is stale there too. Reproduced on an Intel Core i5-4440 (Haswell) under Windows 11 Home build 26300 with QEMU 11.1.2 (the code is unchanged on master), guest Linux 6.18. With this patch the guest enables xstate 0x7 at 832 bytes and boots with -cpu max. An AMD Ryzen 9 7900X under build 26100, not affected before, still boots with the patch, enabling 0xe7 (compacted, 2432 bytes). Fixes: 79b3cb1f0145 ("whpx: i386: introduce proper cpuid support") Signed-off-by: Kostas Chatzikokolakis Reviewed-by: Mohamed Mediouni Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 2a91eabc10..8cfbc5f676 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2734,10 +2734,14 @@ int whpx_vcpu_run(CPUState *cpu) } } =20 - /* CPUID[0xD,{1,2}].EBX are dynamic depending on guest feature= s. */ + /* + * CPUID[0xD,{0,1}].EBX are dynamic: the XSAVE area size for t= he + * guest's current XCR0, resp. XCR0 | IA32_XSS. For sub-leaf >= =3D 2, + * EBX is the component's fixed offset, which QEMU already rep= orts. + */ if (vcpu->exit_ctx.CpuidAccess.Rax =3D=3D 0xd) { - if (vcpu->exit_ctx.CpuidAccess.Rcx =3D=3D 1 - || vcpu->exit_ctx.CpuidAccess.Rcx =3D=3D 2) { + if (vcpu->exit_ctx.CpuidAccess.Rcx =3D=3D 0 + || vcpu->exit_ctx.CpuidAccess.Rcx =3D=3D 1) { reg_values[4].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Def= aultResultRbx; } } --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184998; cv=none; d=zohomail.com; s=zohoarc; b=eC0NAPZ38iZUE5a5Sqwjq43hOTFBNgmRj1BVVz/TQKGn5h9cDgDZZJSl3poXHlWeUsVVvNmxps8W8TEW+j9p7W2LfzzVMXqF8j/AVu2iczO715BnNt8JHmaCkQgBXNoEYlva2TkEfurZ3G34MVDDP49HY6ri2l9ZWint6krIUzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184998; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jUaC27K84HIh4oYu0Zv9O7MV92rVDjSftsTK307Bs00=; b=hZa3EASe6Mc6MAnmEsGD8zr9tP6MYpRlvzRk4yJo5Uln/FZpq3QY2dYef28JXsbxHiwEc0pEsua4/5lehqILVf1N0LEnbO1Xugv0iQ+P3VdOz4QP4oZoU37iuEQ+8RZzUAK7pUUKKmxkz305mXKZMaatjS+vA327N3wbh0VmZVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184998057631.4573125711437; Sun, 8 Nov 2026 16:43:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDS2-0005nN-5D; Sun, 08 Nov 2026 19:41:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRv-0005jZ-Q1 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:27 -0500 Received: from ci-2003g-snip6-11.eps.apple.com ([2a01:b747:3005:200::49] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRs-0006Mk-0J for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:27 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 7BD7518007FB; Mon, 09 Nov 2026 00:41:19 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id C8A4A18000B6; Mon, 09 Nov 2026 00:41:18 +0000 (UTC) X-ICL-RepId: 01a1bdc0-9d7c-7d9f-8203-fcea6dc3fe70 X-ICL-Out-Info: HUtFAUMEWwJACUgATUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0cZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeXAVGXx9RGV4IUytHHkkKVgleCEYRWxRWQ1EZDFBNAUMICghHA00XXjJTBF8RUBY= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184880; x=1825720880; bh=jUaC27K84HIh4oYu0Zv9O7MV92rVDjSftsTK307Bs00=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=M5lmUOu7G7u6QcB/m1U/aHMkLyUc2LgQ5VSjCaw7Ckaoj8wyNSfpoN5csLkvIJ8QKVjNflHATr2TtLSh+z+U/8dtz1SMX/wOSOHmm5saWN294UkSwwes4flanlBI+G8SnU/UhPMY+KzTRY0jxgbHGHpqtlUMge15s8yQjo7XPRNd+RfjpYHCX62T+p/3D1aoBLIp8mktmz3VARaz1xiBVevC7vpuLL8JpfDWpsDQrPfT/1XlyuReymtNy7O7uaFHCtr+GoGSG60pJIjXZzyI7nn2TChKlsstgy+zA/v0arV/12d252eBEHb7lk9Bn5BcX2HbpAMBcqSiQqDEtSR7aw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org, Akshey Taneja Subject: [PULL 11/13] whpx: i386: do not require ProcessorFeaturesBanks on legacy Windows Date: Sun, 8 Nov 2026 17:41:06 -0700 Message-ID: <20261109004108.85808-12-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: a-mng1z6v5M4BEqkNCMVAtRFmqMbFboB X-Authority-Info-Out: v=2.4 cv=LbwxKzfi c=1 sm=1 tr=0 ts=6af116af cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=pGLkceISAAAA:8 a=gf5HlC0yx7l-uUfkWeAA:9 X-Proofpoint-GUID: a-mng1z6v5M4BEqkNCMVAtRFmqMbFboB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX0ZIA7SVvq2gi r8ZV91z2YAbLIXai0hlxqvaG5tuzRd33A3jJ0qrOav2Ej0FCyCWSu6ED7HoMxajcr8nENQNCp8V DUibzPXQ3V686jZ10upEoIM90I1iBwvP/kJEPORWt+dKliHRM23psCHzhQUNmj8EzEuboAnPHVw bBuAvA7/at0x22bR9Am6KzgARZsz0xLcFn6TarRe59nwjJ0eC1H6+WV1TyRcRhGXVKGk+rbyRH0 HovRnpTIkB43+B8XG1v8ncUcSH8uSsQHBHLYWTvC4R8pcO56jNUATolli6xKsx/lqN3xSETlv8Y 17UDgBqWlJYvyMgAoVQ9OTbwh/DIHC2BDLmzsxxqxV6Fr0aW1qXFUrSclws4as= X-JNJ: AAAAAAAB9t8iijDfD8a3GNk/zn0pwxbjB1YJE10TwViiZF0Ftoh8HIEUgeYg0HYv1u+UCb mniTEZRmID7tGuNcpAdiK7aqTQz4mvzuatt/S+dTFFdo2cSOVnECQOkwsnGMB8e46m8zKB DNbSkkGmrJaJ3a6TJCBuz/I9lEyrdKdNPj6NVHgT3EoLLCorHVuTUvCH/APTD0O1Cnvp9V z5zC6UE8M517wLxbreLU+0xEitVXSsXl+noVOKiLxCr4TyI9+fYoxaRjsy23s79FT7F3uz pRcRMQGs9dF/OLuqSVEJ8nIrtS8rQc56gmEBuxfWyOX51nDX6O4jP4BbhBEtxaMrQfcHYm aDMfw1lJON34b6IwKdWI+CEjX9OhQwMoqFTzHJANHtZt09I9zQDR6Uy+TuG5+hZW05gV/d LJpP649xdDSY/rnwmNXOQk02bLELLNGnPylZiTpLNaGQtxvEmNvLfN1mYm7KJck/dJGY2m puxkutxYngxKNRqNk9RPhmdIXusLXn3HgvzFpi2uwof9h0dViBF34T3It2l80S44/T02d7 qT+qJ5nugumBGDdBGL3b3jzxqFGJ3wGcOfmuKp+CV2JzqZKNDhoCA0ItMQeshDPwf2IzF4 5FkgkZsSa1VEx+PfVf6/3x6lVBkVSDnNmEtNGCwGigcHHF1XyRzFdCSxgQkBu6niVpwRG7 zGvKLSQlPJI7BSJo1dUGob/eMvWEjxRGziOAfm5i1o6d7/PN1gaW7LGLdkkKlB/ryPHyop RD7xMBSLVhKQVMQfKt7+oV+6fuKzYsY06LS8A0ACu1DoLNZFIO+4L0bA0UnRzSjH9vksrs ybWmZzYczUgIVB9Q07IncBo9UUgcxBIwgP6IXg== Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::49; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794185000284158500 Content-Type: text/plain; charset="utf-8" From: Akshey Taneja WHvCapabilityCodeProcessorFeaturesBanks and the matching partition property are implemented starting from Windows 10 version 20H1. On earlier Windows 10 releases, the capability query returns WHV_E_UNKNOWN_CAPABILITY (0x80370300) and whpx_accel_init() aborts with -ENOSPC, reported to the user as "failed to initialize whpx: No space left on device". This regressed older Windows 10 releases in 8b87283ce4 ("whpx: i386: enable all supported host features"). Fall back to the original single-bank WHvCapabilityCodeProcessorFeatures on legacy hosts and skip the corresponding SetPartitionProperty, which restores the pre-8b87283ce4 behaviour there. Reported on Windows 10 Enterprise LTSC (version 1809, build 17763) Signed-off-by: Akshey Taneja [Editing patch for reflecting the availability of this API, which is available in Windows 10 version 2004 onwards] Reviewed-by: Mohamed Mediouni Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 59 +++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 8cfbc5f676..7c2172a7ed 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -3273,13 +3273,33 @@ int whpx_accel_init(AccelState *as, MachineState *m= s) memset(&processor_features, 0, sizeof(WHV_PROCESSOR_FEATURES_BANKS)); processor_features.BanksCount =3D 2; =20 - hr =3D whp_dispatch.WHvGetCapability( - WHvCapabilityCodeProcessorFeaturesBanks, &processor_features, - sizeof(WHV_PROCESSOR_FEATURES_BANKS), &whpx_cap_size); - if (FAILED(hr)) { - error_report("WHPX: Failed to get processor features, hr=3D%08lx",= hr); - ret =3D -ENOSPC; - goto error; + if (whpx_is_legacy_os()) { + /* + * WHvCapabilityCodeProcessorFeaturesBanks is implemented starting + * from Windows 10 version 20H2 (19041). Fall back to the single-b= ank + * capability on earlier Windows 10 releases. + */ + WHV_PROCESSOR_FEATURES legacy_features =3D {0}; + + processor_features.BanksCount =3D 1; + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodeProcessorFeatures, &legacy_features, + sizeof(legacy_features), &whpx_cap_size); + if (FAILED(hr)) { + warn_report("WHPX: Failed to get legacy processor features, " + "hr=3D%08lx", hr); + } else { + processor_features.Bank0 =3D legacy_features; + } + } else { + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodeProcessorFeaturesBanks, &processor_features, + sizeof(WHV_PROCESSOR_FEATURES_BANKS), &whpx_cap_size); + if (FAILED(hr)) { + error_report("WHPX: Failed to get processor features, hr=3D%08= lx", hr); + ret =3D -ENOSPC; + goto error; + } } =20 whpx_rdtsc_cap =3D processor_features.Bank0.RdtscpSupport; @@ -3324,15 +3344,22 @@ int whpx_accel_init(AccelState *as, MachineState *m= s) } } =20 - hr =3D whp_dispatch.WHvSetPartitionProperty( - whpx->partition, - WHvPartitionPropertyCodeProcessorFeaturesBanks, - &processor_features, - sizeof(WHV_PROCESSOR_FEATURES_BANKS)); - if (FAILED(hr)) { - error_report("WHPX: Failed to set processor features, hr=3D%08lx",= hr); - ret =3D -EINVAL; - goto error; + /* + * The matching partition property is available on Windows 10 version = 20H2 (19041). + * and later. Rely on the whpx_is_legacy_os() check to enable this cod= e only on Server + * 2022 or Windows 11. + */ + if (!whpx_is_legacy_os()) { + hr =3D whp_dispatch.WHvSetPartitionProperty( + whpx->partition, + WHvPartitionPropertyCodeProcessorFeaturesBanks, + &processor_features, + sizeof(WHV_PROCESSOR_FEATURES_BANKS)); + if (FAILED(hr)) { + error_report("WHPX: Failed to set processor features, hr=3D%08= lx", hr); + ret =3D -EINVAL; + goto error; + } } =20 =20 --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184982; cv=none; d=zohomail.com; s=zohoarc; b=GTboVi2IpzytnlJ8KkMCdQCgwxQBN5Gy9Yo5Jh519dF8yit/+64M2Twg/jXzzfLv199ATwnWs5+i/Z3RJwfT2Wk+ljficXVdVYqQvqrGAjwzsmnkBqzisnqw0py7FcgGsETkJQ9QwhQC31Rtoewrte6AcX7+FZguRfYY/tghmt4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184982; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=opYY4a7WwdY0NtTgAyFUM3t3WZLewxo/9KRcUSqAG0g=; b=MjqhTBb3LcGDnghmcjsRoQYSHW6RDMoNdkwvi1XrdjSsf+bH5Qd88IU2t0H/uEOD9nNlFHMeWCL4JMCbhcwNjI4OnjA9/WNApkHPHqdYk+xnEzp8u+iNYQS82Nw/PH4HyRSuPW7v5T/NUmj+Y81W2Ii954WrYFKJKeGkur+wY6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184982311756.2324848026409; Sun, 8 Nov 2026 16:43:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDSC-0005qD-64; Sun, 08 Nov 2026 19:41:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRy-0005l3-29 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:30 -0500 Received: from ci-2003h-snip6-2.eps.apple.com ([2a01:b747:3005:200::4b] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRt-0006NG-90 for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:28 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 39BE618001EC; Mon, 09 Nov 2026 00:41:20 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 6C8B318007F9; Mon, 09 Nov 2026 00:41:19 +0000 (UTC) X-ICL-RepId: 01a1bdc0-a043-7aa3-8061-7f5a88cc6e5d X-ICL-Out-Info: HUtFAUMEWwJACUgBTUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0cZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeXARGXx9RGV4IUytHHkkKVgleCEYRWxRWQ1EZDFBNAUMICghHA00XXjJTBF8RUBY= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184881; x=1825720881; bh=opYY4a7WwdY0NtTgAyFUM3t3WZLewxo/9KRcUSqAG0g=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=RtUQ0FhbCsefbmXSY3G9fVLIR7SYnw/h5TUzlX9/o7Ow83YE37uVhzMwfdW44XN/8radMujw5OTXnfjYzYmZDnHmv6Hs2qawsS7ZiddbTCYC/mw0Q2Flbh6SE2D+/S+6sfIw0tWmJ6rqZv6Ae45oLwWfRjVtCorS3ZS4vRU0V9FNmCnd/+trKjIdPR2vgLi0vXHofk8u8pzMnm3gAr4Avrx0TtxzeyN+/cusuaOFR40oRi7h0WgnoJicvB8kVm6EHsn7JiaX5GzFGM9hcveLe4yQ6fkUP3MCx+B2jNvGY2UCPyymSFLwmBmb9kid0waHLJwc6mfLBgprSm3POQGj+Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org, Akshey Taneja Subject: [PULL 12/13] whpx: i386: fall back to xAPIC when the MSR exit bitmap is unavailable Date: Sun, 8 Nov 2026 17:41:07 -0700 Message-ID: <20261109004108.85808-13-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfXwsiCgeOtSiHg 0J/hmviWrv8irIrAzEgSQ5aCTkKxWMh+Y6ecb7oWCf6/CzFU0hM04USWYzVZXBAE76mPeLAzHxI PkrJGLyA8jtTkqqcgORhnIKFXmX0VJJb1lXKCznq6dHRUV7ZV81UIec4cE5gH+uwWmmZEZKIx0i I4Q1P/w1ykTUYdJMcqypReW18KG267BeQRlWmZVpheNE502ovR0ACY68aDlOhaFIY6UNkWWbvi6 /oNn2SNJSaZzEyeGxrfzlxrPUFmb+RFzmOWyS/gCPiKWvhjXAFAeDuRPx1o/Jn8Vi9A5ORjvc8Z 1hCEX/GT3RdMA8s5FRNwZqgD+sADEs4BE2vtxlHTmYHplfTCwbNjCNv1+xLiWw= X-Proofpoint-GUID: UfoURmnHxwdj60kzB8Gx0FYE0ta-E3qa X-Proofpoint-ORIG-GUID: UfoURmnHxwdj60kzB8Gx0FYE0ta-E3qa X-Authority-Info-Out: v=2.4 cv=UL7Q3Sfy c=1 sm=1 tr=0 ts=6af116b0 cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=pGLkceISAAAA:8 a=LzqnFUZUDoiWbgQmKAQA:9 X-JNJ: AAAAAAABkYZYzOukb4gCU7Vywt0n1AuWWzENR57CLjneQe3jjFnMd+KKTYoFjsiprDj57J 5KlPMF6E5Q0xzGQObfsWUvrwo+fxU1CUtqE3sLuCJ+qHxEPLAWbiwGXvEbqUfaBEkA5/8W mdYJHU3FDek6dwTkTtIT0W6RKcJLMSWHxGK2O9La5P9EGlwluk8Iz5+8iPXCr+OVseqk1Y mxPhkPP5To3XoTNUsALKs+NjJRCkPSDHohBakNpYDUqw+K579gKWpdrB+w7Ex3zXTh8Evu YjZ9/iJvzIzGC+iwfdbieFXuyOrpmh3m+S2XVjUmsEhfdBKfs+fVA46MaJSxnFPJA18f2d gDoxiSMEea40Sw2em75HW3uwd+hyZ57jLbugJ3hP5sQbg9167HCT7e2n2tqOLhudnnDBWf Xry4Bu8u6G9ZRjv6X6rltcle+MUMRXzXt97Qw2mdBG1Y5R9kBhHRaZn9L+6dvb/Mrdh3oK Mow2QZ7hk9Awy0lrP3k633AZ45MQl4iOiBQG4FC4Ks7gMWIGPs7/s2HNqSLs85/YOrlAvg kRENZ1nvGPf6e0HV2UF0HT3t+uqa1SkTM4jGQpnIpJjHeIjrdFUSpfI5u7hWy9jl1SgwoP PosSfhmfUqW3A+aOcgA61hqWwialounTikbhKQHlvHh+cf+A0lkNoDaE1fy19UKvK3ZlVV HK6uGdirT4cJUtcXejL1UY4sgep593ASYwEdcuTBgL44A8Nwmaqb1t528GPSAPWUDNpR7S yEOAjB0/LFGwbeipFOA6KgO7VDElTy4xR+fuBJvYfHQ9atytwywlzHf+d9vzPUQyIvE0CI Fbkucg1J6iTg7lZoG1PGhh7ApOzl+ie7/WseoH5/TOIy Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::4b; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184986023158500 Content-Type: text/plain; charset="utf-8" From: Akshey Taneja WHvPartitionPropertyCodeX64MsrExitBitmap is not implemented on Windows 10 version 1809 and earlier, where WHvSetPartitionProperty() returns WHV_E_UNKNOWN_PROPERTY (0x80370302) and whpx_accel_init() aborts with -EINVAL. QEMU started requesting it in ba1bda25b7 ("whpx: i386: x2apic emul= ation"). Treating the failure as non-fatal is not sufficient on its own: whpx_default_props unconditionally enables x2apic, and x2APIC is reached through MSRs, so without MSR exits the userspace LAPIC never observes the guest's APIC accesses and the guest hangs immediately after the firmware hands over. Observed as a black screen with an Ubuntu 24.04 guest that otherwise boots in about 40 seconds. Record whether the MSR exit bitmap was accepted and, when it was not, apply x2apic=3Doff so the guest uses the MMIO based xAPIC, which is still intercepted normally. Reported on Windows 10 Enterprise LTSC version 1809 (build 17763) Signed-off-by: Akshey Taneja [Patch edited, version 1903 is the first release of Windows 10 with this AP= I] Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 7c2172a7ed..19a552c456 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -57,6 +57,7 @@ #define HV_X64_MSR_GUEST_IDLE 0x400000f0 =20 static bool is_modern_os =3D true; +static bool whpx_msr_exits_available =3D true; =20 static const WHV_REGISTER_NAME whpx_register_names[] =3D { =20 @@ -3009,6 +3010,16 @@ static PropValue whpx_default_props[] =3D { { NULL, NULL }, }; =20 +/* + * x2APIC is reached through MSRs, so emulating it in userspace requires t= he + * MSR exit bitmap. Hosts without that property must fall back to xAPIC, + * which is MMIO based and therefore still intercepted. + */ +static PropValue whpx_no_msr_exit_props[] =3D { + { "x2apic", "off" }, + { NULL, NULL }, +}; + =20 void whpx_cpu_instance_init(CPUState *cs) { @@ -3016,7 +3027,8 @@ void whpx_cpu_instance_init(CPUState *cs) X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); =20 host_cpu_instance_init(cpu); - x86_cpu_apply_props(cpu, whpx_default_props); + x86_cpu_apply_props(cpu, whpx_msr_exits_available ? whpx_default_props + : whpx_no_msr_exit_p= rops); =20 if (xcc->max_features) { whpx_cpu_max_instance_init(cpu); @@ -3420,10 +3432,20 @@ int whpx_accel_init(AccelState *as, MachineState *m= s) WHvPartitionPropertyCodeX64MsrExitBitmap, &prop, sizeof(WHV_PARTITION_PROPERTY)); + /* + * Earlier Windows 10 releases not implement this property. + * It is implemented starting from Windows 10 version 1903 (18362). + */ if (FAILED(hr)) { - error_report("WHPX: Failed to set MSR exit bitmap, hr=3D%08lx", hr= ); - ret =3D -EINVAL; - goto error; + if (hr =3D=3D WHV_E_UNKNOWN_PROPERTY) { + whpx_msr_exits_available =3D false; + warn_report("WHPX: MSR exit bitmap unsupported on this Windows= " + "version, falling back to xAPIC"); + } else { + error_report("WHPX: Failed to set MSR exit bitmap, hr=3D%08lx"= , hr); + ret =3D -EINVAL; + goto error; + } } =20 hr =3D whp_dispatch.WHvSetPartitionProperty( --=20 2.54.0 (Apple Git-157) From nobody Mon Nov 23 04:34:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=unpredictable.fr ARC-Seal: i=1; a=rsa-sha256; t=1794184993; cv=none; d=zohomail.com; s=zohoarc; b=DlASFhlV0rwybz8NJXqg65gVUERRDl42wWJIq/JFe0EA6vHyaMsoiXJbbEBpI7LqbwdYhkZktPaYOr5xEF7Ut8PWub02U7NmdoowOTAu0xMUlJ7tbm1Axhb4Xf83iccr5jEtFQNk3GXxgYwGHyUgsUhyWiqUs2AiytmjdDNSFx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794184993; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7v5/qjKPPsvJnKcJsHDM3Cow7bRzPFGsWtpRPVq+Y+8=; b=hoRVn3tLz+0vg+F2CRSV39pdPdOrowRf3sQXsXlcbw8cjE73Gbz7w1nBFOqUmWa1txqMNeN3WGApTpnfT2IrX/BR50Bp5xr7U5/iRTZlWv1uhkXwaPLAU8pPzKLUE8OtiaPO4EwQ2/p9zdN/iayKTorRE85Ih5QhmIbOzo84mx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794184993026650.4693401919118; Sun, 8 Nov 2026 16:43:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xQDSC-0005pf-0K; Sun, 08 Nov 2026 19:41:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRy-0005l9-RC for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:30 -0500 Received: from ci-2003f-snip6-11.eps.apple.com ([2a01:b747:3005:200::3f] helo=outbound.ci.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xQDRt-0006NE-KM for qemu-devel@nongnu.org; Sun, 08 Nov 2026 19:41:29 -0500 Received: from outbound.ci.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPS id 1A44318007F0; Mon, 09 Nov 2026 00:41:20 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.156.36]) by p00-icloudmta-asmtp-us-central-1k-60-percent-2 (Postfix) with ESMTPSA id 0FDF318000B6; Mon, 09 Nov 2026 00:41:20 +0000 (UTC) X-ICL-RepId: 01a1bdc0-a37f-7f8d-92f0-1303a107de64 X-ICL-Out-Info: HUtFAUMEWwJACUgATUQeDx5WFlZNRAJCTQtMHVUDRQtBF0AGTVIPDx1WEFIAUg9yBVcIQQhTAlEEWBpfCBkNQFBfHA4YWRtAFV0RUBlWCV4VFx5BTUUID0YZEFYBWFZdBU0aXBhZDxwTUFZaDlsERxQXG1wAFxtGAgQjAl8ARQJeCVYBMBcPVk1MFkMfUg9bE00ZUQFSRVQCGRVaCQpXAEALTgJcB1ICQA1JA1UZUwdICUAeXANGXx9RGV4IUytHHkkKVgleCEYRWxRWQ1EZDFBNAUMICghHA00XXjJTBF8RUBY= Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1794184882; x=1825720882; bh=7v5/qjKPPsvJnKcJsHDM3Cow7bRzPFGsWtpRPVq+Y+8=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=xhvIeAH4017D4BLXgVPZMZHnh3DqN8NNfyXSNOLYgq9BVvAb8/hNZI5QgI3c+sdvCUlDSU2qDhd0DCNcNeXbKthHkJsjvapAAkDd4/MmAXJQRr/Yw1tOCjhYR3XG1xnNbzD0V9yW8euBIHEjDTSi2SB6KxXlzsDcV+WzvW6e9rs2hCKMkNhC9oe90wkZ528M9I192rsMnSIpsnsgzbJSS0/zxsZy8wSM7mqD0/3XsH0OuEeHWz+lZvKj7WI/G1EMEcUTkVr7OwI2gY1VO5fGRjkIyVvf0kAYtETMqW+bCEqv0puLdv5SieeDJH/1WwU+9C3ksMZBUFpozX5gYsOQNw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Pedro Barbuda , Pierrick Bouvier , Peter Maydell , Mohamed Mediouni , qemu-arm@nongnu.org Subject: [PULL 13/13] whpx: i386: also save debug registers Date: Sun, 8 Nov 2026 17:41:08 -0700 Message-ID: <20261109004108.85808-14-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20261109004108.85808-1-mohamed@unpredictable.fr> References: <20261109004108.85808-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: q9BjVoRJYHkvYjIW3vEBJvAC8X8CegmG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTA5MDAwMSBTYWx0ZWRfX7AKFkMBGnFdB /dZgwuleAfzWxlnj5i/QvTHo3D5nyrnGRY+0IvvvSJ8t5WbZFvuK4Vtq/tlMeoCJ1xr/z7f+hHI z+pP/Z3M6b/qQQ4mJJLQD9vN8opYVcR51bcdzXlek4P7X4cQmefYC9f9gjX6qaxIvlnPjO22x9a qIimecLRh6QoaId8w1Xf4VbsDNkOv27WiSUdC9dBJXvkKivWCFworBjiS0zfS3jz7s6OzrN7R54 Jrlbv/05UsGoEpxB3JNaHZmt5BAq0lo+FhW1cDWzg5hbD3OKajkFegU4tUIMx8B7tdms/0DNK2j qygo4MZdEZNxwxsOA3vWxLVx/D45M5jwH86MyVxqQENmKk8cgm/IhtpoDT8x98= X-Authority-Info-Out: v=2.4 cv=X5Zf6WTe c=1 sm=1 tr=0 ts=6af116b1 cx=c_apl:c_pps:t_out a=2G65uMN5HjSv0sBfM2Yj2w==:117 a=2G65uMN5HjSv0sBfM2Yj2w==:17 a=zJRp6_cAMcgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=3nrfYwkK1g5-NatN6WYA:9 X-Proofpoint-ORIG-GUID: q9BjVoRJYHkvYjIW3vEBJvAC8X8CegmG X-JNJ: AAAAAAABtbKoyoNVKFYc5R0GBIL96dVVNNuVacyWUjDpS9lzy2qPpfYjrorlhdPyHA7b/T dUfSdbELueZHb5YHsQjZUgHfVWlA1qpvf5LH51Nd4Qa429L3Ym/3LTVU2SThGf2PlqrQSF QmcTIaxZ9w6AAZLanva1JYb1OrbdHdOG+teu3U41OsFFjvsLOmbrqUxXMeO4OzwSLj38/k XTe1cPUiZ0z27x9FEgAzSSPiadJebBn+dU1p7zY57J8c5rIeDJBReRZkf8/cvc1ayTzJNx bt5aPQ8ZwKSGok6VFskHC3iizHASUKt4CfRXOYVOwt0iOn4l31nD8t0Y1Zzcih/+702jM6 RKB3n5RAzuufULpYnXFqi0R/tG7gNPo+NaYq7jnQDGaPOsiBGHea9jhnAgn1W6EfNWnbuT HA7Na9DLqxfSKQozIVmhZbykJDE4aqZFhDMBVicvxOoeHhS8SELQWkIyw5m/NHVvqI1w2S qQC+wDNnuXd3hO90A90HyZ4GMdSDdd21V10ady1eoPQxL4d9jJ4/iFQ95GyltlRccWDhsw 1lCezqHuCOPWEL/y3IkNMcZz8jhJm3UArNUzgOKWQAwsqbCM9xa1SjgflJog+0s6sUck+B FAnlG/ZfABec2Mhgw5rRnewcAl19dnIAl2kQoNlrvYGFkD5TOAM5CVb4LeTESfFhQ1ARgm XH5h139ZlgZ1sA3Om73LcyLjJjlLPMiEWPXwDSy42aO7fglENs6L2n2STCZSJaPSjNFQfL pMNoR/HSzKmH5pFzo8I5tbTNDoqNWTA5yJELBqe0rSv53yw4iVVoLCZO2j Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a01:b747:3005:200::3f; envelope-from=mohamed@unpredictable.fr; helo=outbound.ci.icloud.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @unpredictable.fr) X-ZM-MESSAGEID: 1794184994194158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 43 +++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 19a552c456..8e2b7eaa24 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -101,16 +101,6 @@ static const WHV_REGISTER_NAME whpx_register_names[] = =3D { WHvX64RegisterCr3, WHvX64RegisterCr4, =20 - /* X64 Debug Registers */ - /* - * WHvX64RegisterDr0, - * WHvX64RegisterDr1, - * WHvX64RegisterDr2, - * WHvX64RegisterDr3, - * WHvX64RegisterDr6, - * WHvX64RegisterDr7, - */ - /* X64 MSRs */ WHvX64RegisterEfer, #ifdef TARGET_X86_64 @@ -126,7 +116,12 @@ static const WHV_REGISTER_NAME whpx_register_names[] = =3D { WHvX64RegisterCstar, WHvX64RegisterSfmask, #endif - + WHvX64RegisterDr0, + WHvX64RegisterDr1, + WHvX64RegisterDr2, + WHvX64RegisterDr3, + WHvX64RegisterDr6, + WHvX64RegisterDr7 /* Interrupt / Event Registers */ /* * WHvRegisterPendingInterruption, @@ -686,6 +681,19 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel = level) vcxt.values[idx++].Reg64 =3D env->fmask; #endif =20 + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr0); + vcxt.values[idx++].Reg64 =3D env->dr[0]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr1); + vcxt.values[idx++].Reg64 =3D env->dr[1]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr2); + vcxt.values[idx++].Reg64 =3D env->dr[2]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr3); + vcxt.values[idx++].Reg64 =3D env->dr[3]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr6); + vcxt.values[idx++].Reg64 =3D env->dr[6]; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr7); + vcxt.values[idx++].Reg64 =3D env->dr[7]; + /* Interrupt / Event Registers - Skipped */ =20 assert(idx =3D=3D RTL_NUMBER_OF(whpx_register_names)); @@ -1070,6 +1078,19 @@ void whpx_get_registers(CPUState *cpu, WHPXStateLeve= l level) env->fmask =3D vcxt.values[idx++].Reg64; #endif =20 + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr0); + env->dr[0] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr1); + env->dr[1] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr2); + env->dr[2] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr3); + env->dr[3] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr6); + env->dr[6] =3D vcxt.values[idx++].Reg64; + assert(whpx_register_names[idx] =3D=3D WHvX64RegisterDr7); + env->dr[7] =3D vcxt.values[idx++].Reg64; + /* Interrupt / Event Registers - Skipped */ =20 assert(idx =3D=3D RTL_NUMBER_OF(whpx_register_names)); --=20 2.54.0 (Apple Git-157)