From nobody Tue Apr 21 14:38:20 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=1776551785; cv=none; d=zohomail.com; s=zohoarc; b=nQch215V9NVvudKiMaEs7dDMA7eHry0MtGAK+VT7VDwCLChNfYaOeS6QEKXQKGeTWZ+p/aD/N9m7hagumUc4Yhw790683Y9j0GPUDyC4+nUgjSuQIXltlvHznpTru12ZJQLt6SvDxxf6ltqMJX3OYxXeRqKh6Ok47RygBlS+DkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551785; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jSFEY3OW57r5Gmf0SB6G349rIgUNCT10rXc1M/CBSww=; b=aSC+U0iLZe2IwSin9wxk9qvC5KIHCzGOtbPfuSH7ADYRIj1EfswrmdWYfUfvThRg7iSZ3nvm326yet3wc86WJiNVgT+v4hoU31sXWBxNMT2IPPeWK2CyHn6wa2aGox9DvWNTsNIC7TejpqUjIjcmMEt+iVS2Ve335qbLJDcmqDU= 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 1776551785772891.193032377199; Sat, 18 Apr 2026 15:36:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEK-00060Z-VD; Sat, 18 Apr 2026 18:33:36 -0400 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 1wEEEJ-0005yZ-AM for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:35 -0400 Received: from p-east2-cluster5-host1-snip4-10.eps.apple.com ([57.103.79.13] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEG-0004ni-RM for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:35 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 07FB718000DA; Sat, 18 Apr 2026 22:33:27 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 6B9D618000B4; Sat, 18 Apr 2026 22:33:25 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551611; x=1779143611; bh=jSFEY3OW57r5Gmf0SB6G349rIgUNCT10rXc1M/CBSww=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=YmFCPvOq0bVJOuuF9FcdQr0FHRSGpb7sEwk5rWG6ZbiWJS7WNBYW+kaOfY3CCKR3Ygdl1uahohfBl1BPqbg6KE6QiU+vBD0okv5vtSo7wriuxgU9w8CyfcA8ax5BaZbx0ZdWr9EPP8rGrfQJyl1BeIA9Qyx6cJeFUsPLOYP9ov1pa8dnch3L6YUoU5LA4SwSoFXxhjONAH92b6nNDr+xLyb2Kee7BwOBMIF4EBDNzQSF3UMQNajeR8+/09tMUpkt93ZM3u3IHLkSPmHWVU1ybuURFxXSKjiqtqEPRouNA8XtewUggJLf8K4bI16uHlk8M+5Pm2AMOHcSsR5vAivCAA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 01/38] target/i386: emulate: include name of unhandled instruction Date: Sun, 19 Apr 2026 00:32:43 +0200 Message-ID: <20260418223320.51330-2-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: vaelIETl6ub8dSJcbBAp2zD2jtFNN4yo X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX4RXSX5APzg+C hD6AJYqt1VoIzAqoXdavtFb0Fre+EtvHDcnP2lRWl5mlmezM0J7vxgL8wKUa4ymGmijV58x+Wpr OmjQ6kUgJyQI2/bwk+Rp61VFvI8OjT9DGYtiK0SddLII8BrxVlLeGEHkxJyIf5J/baLNjEON6xK 6HrbL5LnKSIZmSixZRxVh0Y5CmSJAtqEehofR8zpzlfusB96OEMOYU5CDLnHVuunZM+J7UcW22F VC3eEtT+3ZKstAz0j0dcExDY3pAjI1y1iK6ginCAsczh6LqHm/+oITShQ2Vd0KemsqUFItCzpTZ 2bpNhxJ1y4hl5tgK/O/LOoKWsKn+Mkv1jhArfOjVhig9ExBaFa4AcS6QVOQ+aA= X-Authority-Info-Out: v=2.4 cv=WPxyn3sR c=1 sm=1 tr=0 ts=69e406b9 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=x0iqa3ucmZZh0HPruXgA:9 X-Proofpoint-ORIG-GUID: vaelIETl6ub8dSJcbBAp2zD2jtFNN4yo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 bulkscore=0 suspectscore=0 adultscore=0 clxscore=1030 lowpriorityscore=0 mlxlogscore=972 phishscore=0 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.79.13; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551789067154100 Content-Type: text/plain; charset="utf-8" Instead of just the command number, include the instruction name to make de= bugging easier. Signed-off-by: Mohamed Mediouni --- target/i386/emulate/x86_emu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/emulate/x86_emu.c b/target/i386/emulate/x86_emu.c index 55b1a68eb6..c2da1a133f 100644 --- a/target/i386/emulate/x86_emu.c +++ b/target/i386/emulate/x86_emu.c @@ -1399,8 +1399,8 @@ static void init_cmd_handler(void) bool exec_instruction(CPUX86State *env, struct x86_decode *ins) { if (!_cmd_handler[ins->cmd].handler) { - printf("Unimplemented handler (" TARGET_FMT_lx ") for %d (%x %x)\n= ", - env->eip, + printf("Unimplemented handler (" TARGET_FMT_lx ") for %s - %d (%x = %x)\n", + env->eip, decode_cmd_to_string(ins->cmd), ins->cmd, ins->opcode[0], ins->opcode_len > 1 ? ins->opcode[1] : 0); env->eip +=3D ins->len; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551886; cv=none; d=zohomail.com; s=zohoarc; b=T4z9/iHQeVSRdfg6DW2IyiKEL3xHik1J1RjJ+CnqboQMUPwEegsEEIH9VwwylErgLLo0k+cSdW05cXiD4I4cbl9Ld+jWAF8gk9V8LnrkLMVPQUNmSI8nk8YZU5XgtkNXIPKLrKiWp6tGws587zvrPTkOWnPDfp5BHJ1mXbifvsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551886; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zl2db1VwfCW29E4LtwT7zz4buZdQP1VZYTXVu1kcs+o=; b=Zz4m/Ny0rvgc/FjYabtmbbmYcVISsI78Ckich1cA9BcsZNW4FEFdO5WKbg3AVVbc7TI2DI1KHpruNrHlhsRLFVKXxajZYhlfywSeGfVVxRIMcWaqFhCESVm3geY9uTF8kd05CcFUqtEQ85Si2WNOyCG1fGhrGTfb0u7o2HNU8xQ= 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 1776551886077880.6909249842603; Sat, 18 Apr 2026 15:38:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEM-00062X-GN; Sat, 18 Apr 2026 18:33:38 -0400 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 1wEEEK-00060D-Iq for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:36 -0400 Received: from p-east2-cluster5-host3-snip4-5.eps.apple.com ([57.103.79.48] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEI-0004nw-ME for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:36 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id E0A6F180022B; Sat, 18 Apr 2026 22:33:29 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 3EE3E1800237; Sat, 18 Apr 2026 22:33:27 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551613; x=1779143613; bh=zl2db1VwfCW29E4LtwT7zz4buZdQP1VZYTXVu1kcs+o=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=LehRpElk+OBfcbbyr3S8dQgmy68VCN4bqOijzJ896SZlaSwF1Im/7yP0Jqh6zokHwJh9LP6jZ9B2PSpE5qi7zjmpGufAEoQZKvoe2EoT8vflYH+fpbF4oOs4BcuoDHEmwFEc7uEsGmcVx08/MO8Vey/ryaGc5QWO2L4KNtFlTgOoiyrhOBOU2GZrOSEqWzrf3AoYYljHmzQTy8EvyqjtLGcJM8R1Xu6BWW01Iq0mG9xXK8gXBqd7eZoH+RbTHEoSfby84317u+GnSaoqvFlsxb2vkpNFauQEO84XPE5+55vyjr9Ca2HOezyy8hZ6U1Pgtw/PEzyF4gbB7x+YnbQBFw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 02/38] whpx: i386: x2apic emulation Date: Sun, 19 Apr 2026 00:32:44 +0200 Message-ID: <20260418223320.51330-3-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=f/NFxeyM c=1 sm=1 tr=0 ts=69e406bb cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=nj4AhdDZwDx412jv8JQA:9 X-Proofpoint-GUID: psl1O-HCSDin6bUYttGCsivXnWd9zHYw X-Proofpoint-ORIG-GUID: psl1O-HCSDin6bUYttGCsivXnWd9zHYw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX0ZGQhTZAIME8 BpZ74ZrTEhZXDn0Na9OewkcYKthMze5hphCLB3GMOBpsHSaXT+x2MNUk7U5rGiy2ZcUDFyn4NG9 fYd4jkmdDhL8ku8e679uUdTUmzQxKruatGSIU7l40c7jxa4YCZdJnAarhZCbm8pgqCagPQL0RUR BwrfqRfmxmnKKNcRvKTGB+3grHMyT3Rhh8o24BsFXscnUItC7RD+1WI5OJ11Z2zeCu7gNtRbc6l sOJvxeQ6lXpe4dC2S3AKEiSYL+BsNRorcQ2t9Kn7DLhXbOsZWOVFEKZGk/by+fAErL78DcrcaP0 3M8N+QcB49InRPV0ozcmFQqFT6JYxUk3nJFR1rBerGQilpWM3+RxVUw9IMUBYk= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=800 mlxscore=0 adultscore=0 malwarescore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.79.48; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551887054158500 Content-Type: text/plain; charset="utf-8" Add x2apic emulation to WHPX for the kernel-irqchip=3Doff case. Unfortunately, it looks like there isn't a workaround available for proper behavior of PIC interrupts when kernel-irqchip=3Don for Windows 10. The OS is out of support outside of extended security updates so this will not be addressed. The performance boost is quite visible for multicore guests. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 134 +++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index e56ae2b343..4127440c0c 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1082,6 +1082,8 @@ HRESULT whpx_set_exception_exit_bitmap(UINT64 excepti= ons) /* Register for MSR and CPUID exits */ memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); prop.ExtendedVmExits.X64MsrExit =3D 1; + prop.ExtendedVmExits.X64CpuidExit =3D 1; + if (exceptions !=3D 0) { prop.ExtendedVmExits.ExceptionExit =3D 1; } @@ -1898,6 +1900,18 @@ int whpx_vcpu_run(CPUState *cpu) WHV_REGISTER_NAME reg_names[3]; UINT32 reg_count; bool is_known_msr =3D 0;=20 + uint64_t val; + + if (vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { + val =3D ((uint32_t)vcpu->exit_ctx.MsrAccess.Rax) | + ((uint64_t)(vcpu->exit_ctx.MsrAccess.Rdx) << 32); + } else { + /* + * Workaround for [-Werror=3Dmaybe-uninitialized] + * with GCC. Not needed with Clang. + */ + val =3D 0; + } =20 reg_names[0] =3D WHvX64RegisterRip; reg_names[1] =3D WHvX64RegisterRax; @@ -1911,7 +1925,47 @@ int whpx_vcpu_run(CPUState *cpu) && !vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite && !whpx_irqchip_in_kernel()) { is_known_msr =3D 1; - reg_values[1].Reg32 =3D (uint32_t)X86_CPU(cpu)->env.apic_b= us_freq; + val =3D X86_CPU(cpu)->env.apic_bus_freq; + } + + if (!whpx_irqchip_in_kernel() && + vcpu->exit_ctx.MsrAccess.MsrNumber =3D=3D MSR_IA32_APICBAS= E) { + is_known_msr =3D 1; + if (!vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { + /* Read path unreachable on Hyper-V */ + abort(); + } else { + WHV_REGISTER_VALUE reg =3D {.Reg64 =3D val}; + int msr_ret =3D cpu_set_apic_base(X86_CPU(cpu)->apic_s= tate, val); + if (msr_ret < 0) { + x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0= D_GPF, 0); + } + whpx_set_reg(cpu, WHvX64RegisterApicBase, reg); + } + } + + if (!whpx_irqchip_in_kernel() && + vcpu->exit_ctx.MsrAccess.MsrNumber >=3D MSR_APIC_START && + vcpu->exit_ctx.MsrAccess.MsrNumber <=3D MSR_APIC_END) { + int index =3D vcpu->exit_ctx.MsrAccess.MsrNumber - MSR_API= C_START; + int msr_ret; + is_known_msr =3D 1; + if (!vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { + bql_lock(); + msr_ret =3D apic_msr_read(X86_CPU(cpu)->apic_state, in= dex, &val); + bql_unlock(); + reg_values[1].Reg64 =3D val; + if (msr_ret < 0) { + x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0= D_GPF, 0); + } + } else { + bql_lock(); + msr_ret =3D apic_msr_write(X86_CPU(cpu)->apic_state, i= ndex, val); + bql_unlock(); + if (msr_ret < 0) { + x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0= D_GPF, 0); + } + } } /* * For all unsupported MSR access we: @@ -1921,6 +1975,11 @@ int whpx_vcpu_run(CPUState *cpu) reg_count =3D vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite ? 1 : 3; =20 + if (!vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { + reg_values[1].Reg32 =3D (uint32_t)val; + reg_values[2].Reg32 =3D (uint32_t)(val >> 32); + } + if (!is_known_msr) { trace_whpx_unsupported_msr_access(vcpu->exit_ctx.MsrAccess= .MsrNumber, vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite); @@ -1939,6 +1998,47 @@ int whpx_vcpu_run(CPUState *cpu) ret =3D 0; break; } + case WHvRunVpExitReasonX64Cpuid: { + WHV_REGISTER_VALUE reg_values[5] =3D {0}; + WHV_REGISTER_NAME reg_names[5]; + UINT32 reg_count =3D 5; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + + reg_names[0] =3D WHvX64RegisterRip; + reg_names[1] =3D WHvX64RegisterRax; + reg_names[2] =3D WHvX64RegisterRcx; + reg_names[3] =3D WHvX64RegisterRdx; + reg_names[4] =3D WHvX64RegisterRbx; + + reg_values[0].Reg64 =3D + vcpu->exit_ctx.VpContext.Rip + + vcpu->exit_ctx.VpContext.InstructionLength; + + reg_values[1].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRax; + reg_values[2].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRcx; + reg_values[3].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRdx; + reg_values[4].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRbx; + + if (vcpu->exit_ctx.CpuidAccess.Rax =3D=3D 1) { + if (cpu_has_x2apic_feature(env)) { + reg_values[2].Reg64 |=3D CPUID_EXT_X2APIC; + } + } + + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters( + whpx->partition, + cpu->cpu_index, + reg_names, reg_count, + reg_values); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set CpuidAccess state " + " registers, hr=3D%08lx", hr); + } + ret =3D 0; + break; + } case WHvRunVpExitReasonException: whpx_get_registers(cpu, WHPX_LEVEL_FULL_STATE); =20 @@ -2136,6 +2236,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) WHV_PROCESSOR_FEATURES_BANKS processor_features; WHV_PROCESSOR_PERFMON_FEATURES perfmon_features; bool is_legacy_os =3D false; + UINT32 cpuidExitList[] =3D {1}; =20 whpx =3D &whpx_global; =20 @@ -2354,6 +2455,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) /* Register for MSR and CPUID exits */ memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); prop.ExtendedVmExits.X64MsrExit =3D 1; + prop.ExtendedVmExits.X64CpuidExit =3D 1; =20 hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, @@ -2366,6 +2468,36 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 + memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); + prop.X64MsrExitBitmap.UnhandledMsrs =3D 1; + if (!whpx_irqchip_in_kernel()) { + prop.X64MsrExitBitmap.ApicBaseMsrWrite =3D 1; + } + + hr =3D whp_dispatch.WHvSetPartitionProperty( + whpx->partition, + WHvPartitionPropertyCodeX64MsrExitBitmap, + &prop, + sizeof(WHV_PARTITION_PROPERTY)); + if (FAILED(hr)) { + error_report("WHPX: Failed to set MSR exit bitmap, hr=3D%08lx", hr= ); + ret =3D -EINVAL; + goto error; + } + + hr =3D whp_dispatch.WHvSetPartitionProperty( + whpx->partition, + WHvPartitionPropertyCodeCpuidExitList, + cpuidExitList, + RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32)); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set partition CpuidExitList hr=3D%08= lx", + hr); + ret =3D -EINVAL; + goto error; + } + /* * We do not want to intercept any exceptions from the guest, * until we actually start debugging with gdb. --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551826; cv=none; d=zohomail.com; s=zohoarc; b=CLaIEn81MDg3jHc7n+pM9iksLsQI2fybLnhskMtv6WoKkgEwaAUMMSAGS6pFyb5AQDB07e9vlnDr1w/OjGgnjJMU5NRdB34XywOAW0DvKwPBIMVXaVntpQ6qn1yhwxfxK9RRU9ZUevzhR1uXV+dy4QhFFvIc4Dkv7ZuNY1gTk40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551826; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ash1yi3VlTyxdP0Aar5CNwwUDY+XErFVJjyfbU7EpDA=; b=Re3U4ks85xSB/PCyHMLFVtEkowDKvbMcuxfhLS1PvWJ592RPJ9zjXgWDCXdQBUME3ctITk68LDtfdAAAZ9Oa3Jni2As3obXtV1LVMIkR0q9DXf2qLbaoIi6Db5SQ8+FjCnhXddlRLIr6BjNJbJqvCrBvl7hXbCovwUKfrMR1uVI= 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 1776551826839336.531947147495; Sat, 18 Apr 2026 15:37:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEN-00063p-Hl; Sat, 18 Apr 2026 18:33:39 -0400 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 1wEEEL-000626-US for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:37 -0400 Received: from p-east2-cluster5-host6-snip4-8.eps.apple.com ([57.103.79.101] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEK-0004oY-6N for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:37 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id A707818000FC; Sat, 18 Apr 2026 22:33:31 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 2449C180022D; Sat, 18 Apr 2026 22:33:29 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551615; x=1779143615; bh=Ash1yi3VlTyxdP0Aar5CNwwUDY+XErFVJjyfbU7EpDA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=eAlS6dwvAavNaC3fWB0kL6xKmU+lZ66SHwIhlKA38CeQcj+7r6NFYTFjxwdac0CgPQTfH59fIrIe9yHb1z3OhO/O9DH1s7Kcr0ivaTGEOBcjuzmKGknQ0xIhRLQAS/E0B3q7o26MGMO5wx4LJhtx5qh/RMhhQjJ/yDTMM/Z/WDs8MMGUk2YNZTqDAZY8n3/UTIiCPd+yqiJT5FEi2HtlYoR3Jo8ieXNGlhyEXqXxaKIEXPXyvEXnmLUEUvOlTS5G7RA+MNHn236mcxLEMbrAIzZEF1V6gHI67l7T0R6aGlmUpXPn98T2FAp6YKMx5OMVhc/oIoXwwUY+BYR8uavkow== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 03/38] whpx: i386: wire up feature probing Date: Sun, 19 Apr 2026 00:32:45 +0200 Message-ID: <20260418223320.51330-4-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 03KB5OIJDHfZXxLE-S1nZCVn6xjlRQhv X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX3U5YeIozKKsJ AE3GQNwwxnV6uy8T1aJEjSD0aWh2xVudnpSoeMdGDx6YJxMcnOM1R/kxsUS+LeNT5bEgfzA4JIu cDirKFRvYFm8z5xGfrs9aGm4exAfJqaNaWEByA3Pag81uF5vSiMq5/ip/tsqsGglbkkzcgT3BKQ o9KZJ7Bru0B3XwZZBc8wlseIGRW0iuwXgIn7p+9I9opLVh1xdHqrQZNNn9RUy0Y7bQWFJZ51ig6 sfYAeVTalcTwLkX9oCpP8YA6J5AjZaP/F36rj0JzjwvnqmTRRC673BJDBhQuVpe15xCJklt8m35 CpXUXy1ljoOyzhk08Vn18KSwnl5pJ5KOfOaNayHTOGa6DjV8oTYRGuxYq6yDXE= X-Proofpoint-ORIG-GUID: 03KB5OIJDHfZXxLE-S1nZCVn6xjlRQhv X-Authority-Info-Out: v=2.4 cv=GP0F0+NK c=1 sm=1 tr=0 ts=69e406bd cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Gr33WSPopR-aU8k7cJUA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1030 mlxscore=0 spamscore=0 malwarescore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.79.101; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551828768158500 Content-Type: text/plain; charset="utf-8" Windows 10 doesn't have the API for this, so using this only for Windows 11. Signed-off-by: Mohamed Mediouni --- include/system/whpx-internal.h | 9 ++++ target/i386/cpu.c | 25 ++++++++++++ target/i386/whpx/whpx-all.c | 75 ++++++++++++++++++++++++++++++++-- target/i386/whpx/whpx-i386.h | 4 ++ 4 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 target/i386/whpx/whpx-i386.h diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index 8482901f71..5902124b63 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -73,6 +73,14 @@ void whpx_apic_get(APICCommonState *s); X(HRESULT, WHvGetVirtualProcessorRegisters, (WHV_PARTITION_HANDLE Partit= ion, UINT32 VpIndex, const WHV_REGISTER_NAME* RegisterNames, UINT32 Registe= rCount, WHV_REGISTER_VALUE* RegisterValues)) \ X(HRESULT, WHvSetVirtualProcessorRegisters, (WHV_PARTITION_HANDLE Partit= ion, UINT32 VpIndex, const WHV_REGISTER_NAME* RegisterNames, UINT32 Registe= rCount, const WHV_REGISTER_VALUE* RegisterValues)) \ =20 +#ifdef __x86_64__ +#define LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL_ARCH(X) \ + X(HRESULT, WHvGetVirtualProcessorCpuidOutput, \ + (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, UINT32 Eax, \ + UINT32 Ecx, WHV_CPUID_OUTPUT *CpuidOutput)) +#else +#define LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL_ARCH(X) +#endif /* * These are supplemental functions that may not be present * on all versions and are not critical for basic functionality. @@ -89,6 +97,7 @@ void whpx_apic_get(APICCommonState *s); UINT32 StateSize)) \ X(HRESULT, WHvResetPartition, \ (WHV_PARTITION_HANDLE Partition)) \ + LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL_ARCH(X) =20 #define WHP_DEFINE_TYPE(return_type, function_name, signature) \ typedef return_type (WINAPI *function_name ## _t) signature; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c6fd1dc00e..0000093fa3 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -26,6 +26,8 @@ #include "tcg/helper-tcg.h" #include "exec/translation-block.h" #include "system/hvf.h" +#include "system/whpx.h" +#include "whpx/whpx-i386.h" #include "hvf/hvf-i386.h" #include "kvm/kvm_i386.h" #include "kvm/tdx.h" @@ -8087,6 +8089,17 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *= cpu, FeatureWord w) r =3D hvf_get_supported_cpuid(wi->cpuid.eax, wi->cpuid.ecx, wi->cpuid.reg); + } else if (whpx_enabled()) { + if (wi->type !=3D CPUID_FEATURE_WORD) { + return 0; + } + if (whpx_is_legacy_os()) { + r =3D wi->tcg_features; + } else { + r =3D whpx_get_supported_cpuid(wi->cpuid.eax, + wi->cpuid.ecx, + wi->cpuid.reg); + } } else if (tcg_enabled() || qtest_enabled()) { r =3D wi->tcg_features; } else { @@ -8168,6 +8181,18 @@ static void x86_cpu_get_supported_cpuid(uint32_t fun= c, uint32_t index, *ebx =3D hvf_get_supported_cpuid(func, index, R_EBX); *ecx =3D hvf_get_supported_cpuid(func, index, R_ECX); *edx =3D hvf_get_supported_cpuid(func, index, R_EDX); + } else if (whpx_enabled()) { + if (whpx_is_legacy_os()) { + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + } else { + *eax =3D whpx_get_supported_cpuid(func, index, R_EAX); + *ebx =3D whpx_get_supported_cpuid(func, index, R_EBX); + *ecx =3D whpx_get_supported_cpuid(func, index, R_ECX); + *edx =3D whpx_get_supported_cpuid(func, index, R_EDX); + } } else { *eax =3D 0; *ebx =3D 0; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 4127440c0c..2d527b90dd 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -36,6 +36,7 @@ #include "system/whpx-accel-ops.h" #include "system/whpx-all.h" #include "system/whpx-common.h" +#include "whpx-i386.h" =20 #include "emulate/x86_decode.h" #include "emulate/x86_emu.h" @@ -49,6 +50,8 @@ /* for kernel-irqchip=3Doff */ #define HV_X64_MSR_APIC_FREQUENCY 0x40000023 =20 +static bool is_modern_os =3D true; + static const WHV_REGISTER_NAME whpx_register_names[] =3D { =20 /* X64 General purpose registers */ @@ -1062,6 +1065,71 @@ static void whpx_init_emu(void) init_emu(&whpx_x86_emul_ops); } =20 +bool whpx_is_legacy_os(void) +{ + return !is_modern_os; +} + +uint32_t whpx_get_supported_cpuid(uint32_t func, uint32_t idx, int reg) +{ + WHV_CPUID_OUTPUT output; + uint32_t eax, ebx, ecx, edx; + uint32_t cpu_index =3D 0; + bool temp_cpu =3D true; + HRESULT hr; + + hr =3D whp_dispatch.WHvCreateVirtualProcessor( + whpx_global.partition, cpu_index, 0); + + /* This means that the CPU already exists... */ + if (FAILED(hr)) { + temp_cpu =3D false; + } + + hr =3D whp_dispatch.WHvGetVirtualProcessorCpuidOutput(whpx_global.part= ition, + cpu_index, func, idx, &output); + + if (FAILED(hr)) { + abort(); + } + + if (temp_cpu) { + hr =3D whp_dispatch.WHvDeleteVirtualProcessor(whpx_global.partitio= n, cpu_index); + if (FAILED(hr)) { + abort(); + } + } + + eax =3D output.Eax; + ebx =3D output.Ebx; + ecx =3D output.Ecx; + edx =3D output.Edx; + + /* + * We can emulate X2APIC even for the kernel-irqchip=3Doff case. + * CPUID_EXT_HYPERVISOR and CPUID_HT should be considered present + * always, so report them as unconditionally supported here. + */ + if (func =3D=3D 1) { + ecx |=3D CPUID_EXT_X2APIC; + ecx |=3D CPUID_EXT_HYPERVISOR; + edx |=3D CPUID_HT; + } + + switch (reg) { + case R_EAX: + return eax; + case R_EBX: + return ebx; + case R_ECX: + return ecx; + case R_EDX: + return edx; + default: + return 0; + } +} + /* * Controls whether we should intercept various exceptions on the guest, * namely breakpoint/single-step events. @@ -2235,7 +2303,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms) WHV_CAPABILITY_FEATURES features =3D {0}; WHV_PROCESSOR_FEATURES_BANKS processor_features; WHV_PROCESSOR_PERFMON_FEATURES perfmon_features; - bool is_legacy_os =3D false; UINT32 cpuidExitList[] =3D {1}; =20 whpx =3D &whpx_global; @@ -2395,7 +2462,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) if (FAILED(hr)) { warn_report("WHPX: Failed to get performance " "monitoring features, hr=3D%08lx", hr); - is_legacy_os =3D true; + is_modern_os =3D false; } else { hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, @@ -2435,7 +2502,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) synthetic_features.Bank0.DirectSyntheticTimers =3D 1; } =20 - if (!is_legacy_os && whpx->hyperv_enlightenments_allowed) { + if (is_modern_os && whpx->hyperv_enlightenments_allowed) { hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks, @@ -2446,7 +2513,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) ret =3D -EINVAL; goto error; } - } else if (is_legacy_os && whpx->hyperv_enlightenments_required) { + } else if (!is_modern_os && whpx->hyperv_enlightenments_required) { error_report("Hyper-V enlightenments not available on legacy Windo= ws"); ret =3D -EINVAL; goto error; diff --git a/target/i386/whpx/whpx-i386.h b/target/i386/whpx/whpx-i386.h new file mode 100644 index 0000000000..6db9a75d39 --- /dev/null +++ b/target/i386/whpx/whpx-i386.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +uint32_t whpx_get_supported_cpuid(uint32_t func, uint32_t idx, int reg); +bool whpx_is_legacy_os(void); --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551673; cv=none; d=zohomail.com; s=zohoarc; b=muJ26Cq00W+OkybkLf9+v3JGJysvGNQqBexahTq5yin6zrLBJeUvO4pjnnoxmPw0xrig1lzvSwsAEYNWtYWOoOvs79InM9HEn2vGjGCsGyYTCGwgifYNZV+gH3tO8CTOTWp9khp5GTUWFt3U9S1KjiMI0KyXZv6+pwaO/rTuAT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551673; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LeCfULzXVq8eMeXoD4HoazACVFGuCL5m06fQgObX99k=; b=CKaCZ1gX1+5pgy+XYOGRFnKtHX7EShTJkOpPFwxHgkgUoNpV4wJBPwUyC7T1lMCPZoQK860iiCj9nfSnGlXv6nyDq6xYxuQPVxffdTyqolUqaVw+/xMYKqUmtcGomOT522e3zFLc+N3fFySgYDvSRGmSQBnG6kMCijvKVU7xQfQ= 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 1776551673133963.8627344434598; Sat, 18 Apr 2026 15:34:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEP-00064L-0T; Sat, 18 Apr 2026 18:33:41 -0400 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 1wEEEN-00063I-21 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:39 -0400 Received: from p-east2-cluster5-host5-snip4-5.eps.apple.com ([57.103.79.88] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEL-0004ou-He for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:38 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 871A31800226; Sat, 18 Apr 2026 22:33:33 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id E37B818000A8; Sat, 18 Apr 2026 22:33:30 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551616; x=1779143616; bh=LeCfULzXVq8eMeXoD4HoazACVFGuCL5m06fQgObX99k=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=YecgrCAjwcpFWLshUV7a3YCFOs3Zu2gBxRuS6mxp2GVm/oLA2qWGCFw8Qe9zH+MvczPsvAycKYwIWnLcvErPGjoK2m7eA1UiYNSlq0ls8gST9NwUdoNYMLHywBWW2uFiB+sloyrrm0mBHDmf7XL0G8BNiO5dbhgUk1g/XiaPtJSBXp51uSGctjK4AlJbUatbFol1nU4XFwxfmcj6OOQjdexKDWssVOA79bBlHkcjksv3czssPrgTLYvBnRcS80lsAJnnc/SqicDxtHKlzNO8hBTqRftdEZJuKNjbPZQa0dMDP/AH4RNt/H3+sIwROfkqgj3zm0kAuefaPAtC0KvKZA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 04/38] whpx: i386: disable TbFlushHypercalls for emulated LAPIC Date: Sun, 19 Apr 2026 00:32:46 +0200 Message-ID: <20260418223320.51330-5-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=QIRlhwLL c=1 sm=1 tr=0 ts=69e406bf cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Rm0zj2O9plGGl-KjdfMA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX4Wpczo0CCtF5 dZCi+5/wJmCDai17CoPMp7QvFWL7lVuxEgQhE1I1VKDx5Bhng2vyGzl9TVffNKiur5Hyth4b8Wn Xam6NnvgNw7X+crhNG3sFTP+w+BGLdZ6+ZjP7hAnQ4QQXdZQGwNi7zmcnyfXZx6I8x3CRXHWyKz RdyFvwZod9EhE/2JkMkx3zP01MMI/kyv3d7+3bnTbcB4JpRDl1lNTm7L8r47uB6uHC+WArRtzMD MG8nQMonvMAFs56dmhyoOH8gxZEq9xpHh0mel37yjvBHxmmbMKarJAPyxCrnJTM/hU2oJygK7X4 g6iv5yUj5qo0lVYOuKlPPDkSr3X1W1D96zQ1pouSsTpVugYWHP9SCD/nzFqp18= X-Proofpoint-ORIG-GUID: Q3CceVXSqfdkQqn1sTKjbfIyOQJBJDLh X-Proofpoint-GUID: Q3CceVXSqfdkQqn1sTKjbfIyOQJBJDLh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=777 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1030 phishscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.79.88; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551677454158500 Content-Type: text/plain; charset="utf-8" AccessHypercallRegs was present twice so clean that up. Remove TbFlushHypercalls (and its extended Gva range sub-feature) from the user-mode LAPIC case as it behaves oddly there. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 2d527b90dd..0908dfd134 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2489,10 +2489,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) synthetic_features.Bank0.AccessPartitionReferenceTsc =3D 1; synthetic_features.Bank0.AccessHypercallRegs =3D 1; synthetic_features.Bank0.AccessFrequencyRegs =3D 1; - synthetic_features.Bank0.EnableExtendedGvaRangesForFlushVirtualAddress= List =3D 1; synthetic_features.Bank0.AccessVpIndex =3D 1; - synthetic_features.Bank0.AccessHypercallRegs =3D 1; - synthetic_features.Bank0.TbFlushHypercalls =3D 1; =20 if (whpx_irqchip_in_kernel()) { synthetic_features.Bank0.AccessSynicRegs =3D 1; @@ -2500,6 +2497,12 @@ int whpx_accel_init(AccelState *as, MachineState *ms) synthetic_features.Bank0.AccessIntrCtrlRegs =3D 1; synthetic_features.Bank0.SyntheticClusterIpi =3D 1; synthetic_features.Bank0.DirectSyntheticTimers =3D 1; + /* + * These technically work without the Hyper-V LAPIC + * but behave oddly for multi-core VMs. + */ + synthetic_features.Bank0.TbFlushHypercalls =3D 1; + synthetic_features.Bank0.EnableExtendedGvaRangesForFlushVirtualAdd= ressList =3D 1; } =20 if (is_modern_os && whpx->hyperv_enlightenments_allowed) { --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551673; cv=none; d=zohomail.com; s=zohoarc; b=muB/wcT/HBfoCoKgrj8p8Zp1klmewVRmFfyLo/1Rkg6aCunvW8MSIumjAfIntKmmCZRJ2hH+yepAHxW7tcDrs8Ptvwvgg9VaVNNiuXnq91Hw/J9jHuQZj/JsPULfkMQviQemkyUyRK/nQadVpU2voI6HCPe0haewikMhhvDxoRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551673; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dugTy6Mycl0V8PO55M7zjkrIKW6irE2gkRf+Eg5CDxE=; b=H/cC3zmTcyI7tBA/eYAPCH/JA7cIciZ2dju4c9dKDYMMAKFImc0sgpn5Apb5CUdINtmdl4DBDQmCfJvk5Ug3bS54xqBtijFGRYeApf2/ZRJTk3UC9yQzD3V8IMomKBZtB4r2KZS8zU/3aBS4reWN8KIN1PHJAge6lABhSa9Axt4= 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 1776551673565145.4268323835371; Sat, 18 Apr 2026 15:34:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEQ-00065Z-G2; Sat, 18 Apr 2026 18:33:42 -0400 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 1wEEEO-00064K-Fh for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:40 -0400 Received: from p-east2-cluster5-host7-snip4-2.eps.apple.com ([57.103.79.25] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEN-0004pK-0b for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:40 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 406171800219; Sat, 18 Apr 2026 22:33:35 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id C466218000DE; Sat, 18 Apr 2026 22:33:32 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551618; x=1779143618; bh=dugTy6Mycl0V8PO55M7zjkrIKW6irE2gkRf+Eg5CDxE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Ov32bxAUpLzISBo7yWBHfr16OM4Xd/BfWYX2av65YqIbEjew8OKx4opkrseqUkgw/6r6a8YPFUBVuU3JXP3GE3VfXnOojRHqw0gkpZpJpp50anWmK5Ys/lY49JXH+XYvUw73cof22s8uFa+Sci7UoV1hrq/TwzumdT3Eb5wgEtlt0W3WbsL7eq5IRk3FQrcYNLMgyglKJNfZ9993fo2k/TL0H6ql1ga38BrL+NNXZSBqk1QItT9CXpSsG/UF5jcMynIGa2grbTU8/TkMrkrobTsqiPbdJBZzzgMQDxcCiqnIqFA7xou8bCHlDYXUIbFjnCSOQ9NdAmAuPXJH761BBQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 05/38] whpx: i386: enable x2apic by default for user-mode LAPIC Date: Sun, 19 Apr 2026 00:32:47 +0200 Message-ID: <20260418223320.51330-6-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: QnGnmFB-uRiUcWJwu5_j8JDS27RZUMr9 X-Authority-Info-Out: v=2.4 cv=NKzYOk6g c=1 sm=1 tr=0 ts=69e406c0 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=uAk9FrDoCeqUxh5yT_MA:9 X-Proofpoint-GUID: QnGnmFB-uRiUcWJwu5_j8JDS27RZUMr9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX4T2t42ZDMmSo NNbMsGx5z0mO9sv2ImYT4AH/+YXXoBSv6n2gWQ2MI1S84fzJObe2h6R6z0tp5Vzmgh8MiqhKaur SNQOFbAFeLdQRrN7dE1+nGt2U4I7ohnsvFjwqQSHg5zG+xcE0zLru3Ep1/FigovaTPjtrDHjpF0 kK2A0Is6bhRqHo/khNaW6a69Y5E6OiMgRFZwvbyBhy6UmjTvJCWvMdPFZJB2JYO537C1b4Tc+vJ 9vqNNm0wVc5r7tE2xi0ae1RLPZ8ajv9hQXsELseR8cPi62BALChTR/+0g+QfhURBxpl2SkrruRi 0/iBFEy3uvY/oG03Vs3hzwombQok7FUgdhkuWGf39raShxqf9k/TMoC8prBTOQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 adultscore=0 suspectscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxlogscore=999 clxscore=1030 spamscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.79.25; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551677438158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 0908dfd134..66f263558f 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2281,11 +2281,18 @@ error: return ret; } =20 +static PropValue whpx_default_props[] =3D { + { "x2apic", "on" }, + { NULL, NULL }, +}; + + void whpx_cpu_instance_init(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); =20 host_cpu_instance_init(cpu); + x86_cpu_apply_props(cpu, whpx_default_props); } =20 /* --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551684; cv=none; d=zohomail.com; s=zohoarc; b=hR/ZWmZvtoda8C2069QhGIckq82H8xd1ADoiaXHSW6NIjXmVUj6yucpimH0BXbSGrcLsLQoIBwE8FbacTNax+k7Ex4Wa57dcLibqjiq2RFtAUigBdkwh47GAOgV9UDcug+j/fcYw4g6e7ht9OLg177ouIpJwfX8L46r8Izwxda0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551684; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oQob0705w1vpsKwSbilmxpp8KQiyruObQqebQ5RZ0Dc=; b=D/vOUmD78Ei82gtCZSJ4bJqXe1DLOWLD/JrNUeo9t7gI3ypiYZY8R6wjs5z732zS5DbbcjAG72uGOv78N8sw0D2i+xVVfF8W1DTNmXLjqiXTvW6TYoYngJaVrfDh4H749wREhj4Z08tIgmuGkx46JFGW5oB/4ghHLGQ2p49DMvs= 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 177655168376939.89065787323284; Sat, 18 Apr 2026 15:34:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEU-000679-Aj; Sat, 18 Apr 2026 18:33:46 -0400 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 1wEEER-00066Q-G9 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:44 -0400 Received: from p-east2-cluster3-host5-snip4-2.eps.apple.com ([57.103.77.193] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEP-0004sm-O1 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:43 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 3678018000A8; Sat, 18 Apr 2026 22:33:36 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 983831800237; Sat, 18 Apr 2026 22:33:34 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551621; x=1779143621; bh=oQob0705w1vpsKwSbilmxpp8KQiyruObQqebQ5RZ0Dc=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=EV4ME5lUQtB8GNvmpYdGSgdeiZNfsOWrPw4aUlJSH4Uj3o9b0GCH9+n86G65xlOoNMyaxdhg6HcQfKhDiu4OPqfxCcpC9AH52ZWvpNTDi9IOWc5xvJw04W7mEt1W5Njtebw9KD7PsCIMyJQoezyeool8NBYnDySx4OA7si8onqbkbWASRGY/+DYAa3TpSzJBVtc5a39AqjRQl5Pmt6UUqYE3KjkybWhjLqeXDIEyGUOYAtvOJuQpWenQdSteJnH/NHm8X+fWqRuzqcuxMt47P7VMzpbYt6b3d2VsubvUzSpY6R4y4TXVDT49cPX/GTTreYe7ZuXynpnpmJEhLGjfFQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 06/38] whpx: i386: reintroduce enlightenments for Windows 10 Date: Sun, 19 Apr 2026 00:32:48 +0200 Message-ID: <20260418223320.51330-7-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=K5sv3iWI c=1 sm=1 tr=0 ts=69e406c3 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=hfWBbujXMTx1PmRkPVYA:9 X-Proofpoint-GUID: Yyx6wYkYqJCPjF6KUu7reyyD2VjAcuRi X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX01oEqOSqUEmR SAUzBmAOY/baygguEeVCuJ8e8oF2Qv2kdwrZ8RBpfIXpLXfo71GFuUqmmr4UmyLtxe8LS2YwbOn oWUxqHc5s+GSSP4jkOiSKTqxUue8M8jdg3um/uUhjLLwDJq8z5ctvijEeeJ4YZHXVGQTdGO8G8y zL0qrrP26+qmZPsDHu7M/rmwLtkoWlqxIsuUoNjkpAecR0a99rBnwi5uw+TATyByCoKmXE7C8iy PXJsPXNiXmxGEZwPhf+XFgexdl4lQzT1L0foUay5NYtSNbvS70ODX/PRTQB/WaL1LwnB1Cby4TF QLy/pdoa2MzQwclsLKeitvWAAou/Fqn8O79pY5fz0fH6+sNqzctv2DqBH+P8dc= X-Proofpoint-ORIG-GUID: Yyx6wYkYqJCPjF6KUu7reyyD2VjAcuRi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 clxscore=1030 lowpriorityscore=0 spamscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.193; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551686708158500 Content-Type: text/plain; charset="utf-8" Was removed in 2c08624 but it's still useful for Windows 10 so reintroduce it there. And this time, actually make it work by reporting the hypervisor bit in CPUID. Pretend to be vmware to be able to use vmport's functionality. If the vmware frequency leaf is disabled, pretend to be KVM, with the only capability reported being X2APIC support. Signed-off-by: Mohamed Mediouni --- accel/whpx/whpx-common.c | 2 ++ include/system/whpx-internal.h | 1 + target/arm/whpx/whpx-all.c | 1 + target/i386/whpx/whpx-all.c | 63 +++++++++++++++++++++++++++++----- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index b813a5d9d2..59be996aef 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -550,6 +550,8 @@ static void whpx_accel_instance_init(Object *obj) =20 whpx->hyperv_enlightenments_allowed =3D true; whpx->hyperv_enlightenments_required =3D false; + /* Value determined at whpx_accel_init */ + whpx->hyperv_enlightenments_enabled =3D false; } =20 static const TypeInfo whpx_accel_type =3D { diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index 5902124b63..cf782cf5f8 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -45,6 +45,7 @@ struct whpx_state { =20 bool hyperv_enlightenments_allowed; bool hyperv_enlightenments_required; + bool hyperv_enlightenments_enabled; =20 }; =20 diff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c index bbf0f6be96..4019a513aa 100644 --- a/target/arm/whpx/whpx-all.c +++ b/target/arm/whpx/whpx-all.c @@ -968,6 +968,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) * as they're not needed for performance. */ if (whpx->hyperv_enlightenments_required) { + whpx->hyperv_enlightenments_enabled =3D true; hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks, diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 66f263558f..c2a78312f8 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2083,14 +2083,57 @@ int whpx_vcpu_run(CPUState *cpu) vcpu->exit_ctx.VpContext.Rip + vcpu->exit_ctx.VpContext.InstructionLength; =20 - reg_values[1].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRax; - reg_values[2].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRcx; - reg_values[3].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRdx; - reg_values[4].Reg64 =3D vcpu->exit_ctx.CpuidAccess.DefaultResu= ltRbx; - - if (vcpu->exit_ctx.CpuidAccess.Rax =3D=3D 1) { - if (cpu_has_x2apic_feature(env)) { - reg_values[2].Reg64 |=3D CPUID_EXT_X2APIC; + if (whpx_is_legacy_os()) { + reg_values[1].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRax; + reg_values[2].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRcx; + reg_values[3].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRdx; + reg_values[4].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRbx; + } else { + cpu_x86_cpuid(env, vcpu->exit_ctx.CpuidAccess.Rax, + vcpu->exit_ctx.CpuidAccess.Rcx, + (UINT32 *)®_values[1].Reg32, + (UINT32 *)®_values[4].Reg32, (UINT32 *)®_values[= 2].Reg32, + (UINT32 *)®_values[3].Reg32); + } + + if (!whpx->hyperv_enlightenments_enabled) { + switch (vcpu->exit_ctx.CpuidAccess.Rax) { + case 1: + reg_values[2].Reg64 |=3D CPUID_EXT_HYPERVISOR; + break; + case 0x40000000: + /* + * Use vmware_cpuid_freq as a proxy to report VMware. + * This is to get the TSC/APIC frequency query functio= nality + * provided through vmport, as Linux doesn't use leaf + * 0x40000010 for getting those frequencies. + */ + if (x86_cpu->vmware_cpuid_freq) { + reg_values[1].Reg64 =3D 0x40000010; + reg_values[4].Reg64 =3D 0x61774d56; + reg_values[2].Reg64 =3D 0x4d566572; + reg_values[3].Reg64 =3D 0x65726177; + } else { + /* report KVM otherwise if that's disabled */ + reg_values[1].Reg64 =3D 0x40000001; + reg_values[4].Reg64 =3D 0x4b4d564b; + reg_values[2].Reg64 =3D 0x564b4d56; + reg_values[3].Reg64 =3D 0x4d; + } + break; + case 0x40000001: + if (!x86_cpu->vmware_cpuid_freq) { + /* KVM reporting of X2APIC support */ + reg_values[1].Reg64 =3D reg_values[4].Reg64 =3D + reg_values[2].Reg64 =3D 1 << 15; + } + break; + case 0x40000010: + if (x86_cpu->vmware_cpuid_freq) { + reg_values[1].Reg64 =3D env->tsc_khz; + reg_values[4].Reg64 =3D env->apic_bus_freq / 1000;= /* Hz to KHz */ + } + break; } } =20 @@ -2311,6 +2354,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) WHV_PROCESSOR_FEATURES_BANKS processor_features; WHV_PROCESSOR_PERFMON_FEATURES perfmon_features; UINT32 cpuidExitList[] =3D {1}; + UINT32 cpuidExitList_nohyperv[] =3D {1, 0x40000000, 0x40000001, 0x4000= 0010}; =20 whpx =3D &whpx_global; =20 @@ -2513,6 +2557,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) } =20 if (is_modern_os && whpx->hyperv_enlightenments_allowed) { + whpx->hyperv_enlightenments_enabled =3D true; hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks, @@ -2565,7 +2610,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeCpuidExitList, - cpuidExitList, + whpx->hyperv_enlightenments_enabled ? cpuidExitList : cpuidExitLis= t_nohyperv, RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32)); =20 if (FAILED(hr)) { --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551827; cv=none; d=zohomail.com; s=zohoarc; b=F96FJwLHp2zkCCggKTYrTbcPwYorudnYFAMvfEHIq0SsyHmqWq+JL14xpsTcnPf2M3IFrXTdSsuK6St5+LLarBrV+nGTxMTxfAHO913HfYI8JudWkRLGiiEoCjKoUSLhdAnCtp4PY4SIFoB6WVoULFiy/8fU1hjNN6PAez/l+Co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551827; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rzH0nfvQx4HDQyGiqHq24GYidgrGqENXmeSSBmYWI5k=; b=nsKOssOAKweF9QHBVyfcKLZwarjI1XvkHaJnpvbTY1MWurPh/dNrhf/ZLIMT6fX6YRS/zRf3yxLIuivAVzfnFJsn+nWNXxifVmPMtukLSQ4rSyRHiNkJCo7THUWKP2qrfBWKWDweYvCOAcAu/TMcPrsV+j4XJQTlncR6f2XD+lw= 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 1776551827284135.25588081661851; Sat, 18 Apr 2026 15:37:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEX-000685-Lo; Sat, 18 Apr 2026 18:33:49 -0400 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 1wEEET-00066v-LJ for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:45 -0400 Received: from p-east2-cluster3-host7-snip4-5.eps.apple.com ([57.103.77.236] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEER-0004t0-TL for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:45 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 1BD361800229; Sat, 18 Apr 2026 22:33:38 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 6C1841800231; Sat, 18 Apr 2026 22:33:36 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551622; x=1779143622; bh=rzH0nfvQx4HDQyGiqHq24GYidgrGqENXmeSSBmYWI5k=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=g9gW7qVl4jGNMqDrz4BwIwenFPbqZsNITZTsrnxcGZuB8yfxfW54/dTzigdpaDrcKDdnBy6DSAe+iEGzBfwBK9t1lpd4dz/CHGu2pqZNiRKJLna6+EEr8ioZtuMax2aKp5AMvz2BiDyWUxpX0QYYbjqXvEMqbS0ks6IYKYKwgCqBSgN/upWMgxetIavJ9FBMyK5X+nHFntB636DrwH8VAGQkYesJC7uTL+0gmyZFvgQmzcdcnCultpwkSd4TV15XJaYAW0vs5q9IgxHfkrbQNQPS8XSIyTgsu90mefd6/yE35uqtuO2BuHHRPXENYSaFXRGki+lk0s/HsyM061Vu7g== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 07/38] whpx: i386: introduce proper cpuid support Date: Sun, 19 Apr 2026 00:32:49 +0200 Message-ID: <20260418223320.51330-8-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX85+QISQCKozK gE2hGcmamTpLKl1I3Ld38WnrP3SBN9l6D0y6dglxWXLEt2/0XP25RzagQFACGZeExjuNUMNQ9LM O1bOBj5QdcowRJUHwTHjq11jzQiFDRjFvSKh+MOjc7UKkRselnpnffylB57Hu0NHyMg33oNEpsM MG3VvWopK1qKL5gPVLpwTgKmP3roG9udvBz+znFG6JabJ0B68vA4/YhJK72lZh9ozoWBmgifFD+ 7V/hSWakQLUvF1UDWpG9pJTIPrflE7JMR8OI2JXannx3CJ43Luu44IIdm+7Yqd8TXGLeranJoMQ 2e+pLY05eFPH/N1IOhawknk4SL5cu9GLRGnZTJP/rKEdjvB87UIwskc5AkaWJ4= X-Proofpoint-ORIG-GUID: TBmiioz8NB7CSzwCqUHkDjm6p5ThG1Xv X-Authority-Info-Out: v=2.4 cv=KJ9XzVFo c=1 sm=1 tr=0 ts=69e406c4 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=n8cRCUxqL_yedgTzvKUA:9 X-Proofpoint-GUID: TBmiioz8NB7CSzwCqUHkDjm6p5ThG1Xv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 clxscore=1030 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.236; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551829711154100 Content-Type: text/plain; charset="utf-8" Unlike the implementation in QEMU 10.2, this one works. It's not optimal though as it doesn't use the Hyper-V support for this. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 123 ++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 4 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index c2a78312f8..53b59a98b9 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2071,6 +2071,7 @@ int whpx_vcpu_run(CPUState *cpu) WHV_REGISTER_NAME reg_names[5]; UINT32 reg_count =3D 5; X86CPU *x86_cpu =3D X86_CPU(cpu); + X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); CPUX86State *env =3D &x86_cpu->env; =20 reg_names[0] =3D WHvX64RegisterRip; @@ -2083,7 +2084,15 @@ int whpx_vcpu_run(CPUState *cpu) vcpu->exit_ctx.VpContext.Rip + vcpu->exit_ctx.VpContext.InstructionLength; =20 - if (whpx_is_legacy_os()) { + /* + * On Windows 10 we can't query features from + * the Hyper-V interface. + * + * On Windows 11, if using xcc->max_features + * just pass through what the hypervisor + * provides without any QEMU filtering. + */ + if (whpx_is_legacy_os() || xcc->max_features) { reg_values[1].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRax; reg_values[2].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRcx; reg_values[3].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRdx; @@ -2135,6 +2144,60 @@ int whpx_vcpu_run(CPUState *cpu) } break; } + } else { + switch (vcpu->exit_ctx.CpuidAccess.Rax) { + case 0x40000000: + case 0x40000001: + case 0x40000010: + reg_values[1].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Def= aultResultRax; + reg_values[2].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Def= aultResultRcx; + reg_values[3].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Def= aultResultRdx; + reg_values[4].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Def= aultResultRbx; + break; + } + } + + if (vcpu->exit_ctx.CpuidAccess.Rax =3D=3D 0x1) { + if (cpu_has_x2apic_feature(env)) { + reg_values[2].Reg64 |=3D CPUID_EXT_X2APIC; + } else { + reg_values[2].Reg32 &=3D ~CPUID_EXT_X2APIC; + } + } + + /* Dynamic depending on XCR0 and XSS, so query DefaultResult */ + if (vcpu->exit_ctx.CpuidAccess.Rax =3D=3D 0x07 + && vcpu->exit_ctx.CpuidAccess.Rcx =3D=3D 0) { + if (vcpu->exit_ctx.CpuidAccess.DefaultResultRdx + & CPUID_7_0_EDX_CET_IBT) { + reg_values[3].Reg32 |=3D CPUID_7_0_EDX_CET_IBT; + } else { + reg_values[3].Reg32 &=3D ~CPUID_7_0_EDX_CET_IBT; + } + + if (vcpu->exit_ctx.CpuidAccess.DefaultResultRcx + & CPUID_7_0_ECX_CET_SHSTK) { + reg_values[2].Reg32 |=3D CPUID_7_0_ECX_CET_SHSTK; + } else { + reg_values[2].Reg32 &=3D ~CPUID_7_0_ECX_CET_SHSTK; + } + + if (vcpu->exit_ctx.CpuidAccess.DefaultResultRcx + & CPUID_7_0_ECX_OSPKE) { + reg_values[2].Reg32 |=3D CPUID_7_0_ECX_OSPKE; + } else { + reg_values[2].Reg32 &=3D ~CPUID_7_0_ECX_OSPKE; + } + } + + /* OSXSAVE is dynamic. Do this instead of syncing CR4 */ + if (vcpu->exit_ctx.CpuidAccess.Rax =3D=3D 1) { + if (vcpu->exit_ctx.CpuidAccess.DefaultResultRcx + & CPUID_EXT_OSXSAVE) { + reg_values[2].Reg32 |=3D CPUID_EXT_OSXSAVE; + } else { + reg_values[2].Reg32 &=3D ~CPUID_EXT_OSXSAVE; + } } =20 hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters( @@ -2324,6 +2387,45 @@ error: return ret; } =20 +static void whpx_cpu_xsave_init(void) +{ + static bool first =3D true; + int i; + + if (!first) { + return; + } + first =3D false; + + /* x87 and SSE states are in the legacy region of the XSAVE area. */ + x86_ext_save_areas[XSTATE_FP_BIT].offset =3D 0; + x86_ext_save_areas[XSTATE_SSE_BIT].offset =3D 0; + + for (i =3D XSTATE_SSE_BIT + 1; i < XSAVE_STATE_AREA_COUNT; i++) { + ExtSaveArea *esa =3D &x86_ext_save_areas[i]; + + if (esa->size) { + int sz =3D whpx_get_supported_cpuid(0xd, i, R_EAX); + if (sz !=3D 0) { + assert(esa->size =3D=3D sz); + esa->offset =3D whpx_get_supported_cpuid(0xd, i, R_EBX); + } + } + } +} + +static void whpx_cpu_max_instance_init(X86CPU *cpu) +{ + CPUX86State *env =3D &cpu->env; + + env->cpuid_min_level =3D + whpx_get_supported_cpuid(0x0, 0, R_EAX); + env->cpuid_min_xlevel =3D + whpx_get_supported_cpuid(0x80000000, 0, R_EAX); + env->cpuid_min_xlevel2 =3D + whpx_get_supported_cpuid(0xC0000000, 0, R_EAX); +} + static PropValue whpx_default_props[] =3D { { "x2apic", "on" }, { NULL, NULL }, @@ -2333,9 +2435,18 @@ static PropValue whpx_default_props[] =3D { void whpx_cpu_instance_init(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); + X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); =20 host_cpu_instance_init(cpu); x86_cpu_apply_props(cpu, whpx_default_props); + + if (!whpx_is_legacy_os() && xcc->max_features) { + whpx_cpu_max_instance_init(cpu); + } + + if (!whpx_is_legacy_os()) { + whpx_cpu_xsave_init(); + } } =20 /* @@ -2353,8 +2464,12 @@ int whpx_accel_init(AccelState *as, MachineState *ms) WHV_CAPABILITY_FEATURES features =3D {0}; WHV_PROCESSOR_FEATURES_BANKS processor_features; WHV_PROCESSOR_PERFMON_FEATURES perfmon_features; - UINT32 cpuidExitList[] =3D {1}; - UINT32 cpuidExitList_nohyperv[] =3D {1, 0x40000000, 0x40000001, 0x4000= 0010}; + + UINT32 cpuidExitList[] =3D {0x0, 0x1, 0x6, 0x7, 0x14, 0x24, 0x29, 0x1E, + 0x40000000, 0x40000001, 0x40000010, 0x80000000, 0x80000001, + 0x80000002, 0x80000003, 0x80000004, 0x80000007, 0x80000008, + 0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001}; + UINT32 cpuidExitList_legacy_os[] =3D {1, 0x40000000, 0x40000001, 0x400= 00010}; =20 whpx =3D &whpx_global; =20 @@ -2610,7 +2725,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeCpuidExitList, - whpx->hyperv_enlightenments_enabled ? cpuidExitList : cpuidExitLis= t_nohyperv, + !whpx_is_legacy_os() ? cpuidExitList : cpuidExitList_legacy_os, RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32)); =20 if (FAILED(hr)) { --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551907; cv=none; d=zohomail.com; s=zohoarc; b=LHK/acKK6ykbcbFl2d3qi1zYUyhqXPUKCNm9BwFqakXEdTz2Wc15v5B/DhRz7MPwdwHBdOHvGEIzS98d8nfXa8NALqOBbiqaIKbeiTwBwIAn3dwVhTOSdG2hFe+QnfoZ6heuxYnfdh1sMthqNkxSZqwr1A0CGGTCoYZcbT5S4ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551907; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dqy8GVOg6Vy5Bj3rQXQsRJvMspD1oQZRo/6wY+UsQGM=; b=UmLZDSDr05UoaooTxT24QtCovG8XURCBI+arkkwFbNUf1r1dzEv+pCntkhBGt3VhpIM9qpbjUIU3ctOUzEA3UeiN52bar5WJflH9TrwzPh8Ln+X9Ubx2AjDUzFACDiw3Qsp4EbIJwab/r0heST7ZNJ18+Ryma+1c9qdNME/jj1s= 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 1776551907802378.3304821822288; Sat, 18 Apr 2026 15:38:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEZ-000696-G8; Sat, 18 Apr 2026 18:33:51 -0400 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 1wEEEU-00067D-DK for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:46 -0400 Received: from p-east2-cluster3-host12-snip4-8.eps.apple.com ([57.103.77.189] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEES-0004tQ-Py for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:46 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id AAF2E180022F; Sat, 18 Apr 2026 22:33:40 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 3C29A1800208; Sat, 18 Apr 2026 22:33:38 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551623; x=1779143623; bh=Dqy8GVOg6Vy5Bj3rQXQsRJvMspD1oQZRo/6wY+UsQGM=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=cFlL6npOtaoMArzOJrhzsRLJ55oWJVe7VuNbkGuccfhQlCwVcAFE2c7G3ShrR+oVm7E4//klcIAAiR8En3sNt+1prGjmYG9OfscEzdE8wY0OPCFtg0a/zGzrrRztijw+GInfZoaxE6pRmO0MSYX6diKAcKwDikhD8972iqBb8SQG5PBPU5o5rhQ2oWa/cbXmaMk551WW+bLmz79GMw5ECE+uBMCzIGh+ah4BDCtC1kmn4AQ9TJ2OthNBdT4R0/FIWmZAKtxJAQ7zIHNqS1SDFRDI3vn2CYYUyDSoJ25B7vJ1O2rOdvqbqjcGfeQNNpwrvpxUMFHwreB6q3M11EQlVQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 08/38] whpx: i386: kernel-irqchip=off fixes Date: Sun, 19 Apr 2026 00:32:50 +0200 Message-ID: <20260418223320.51330-9-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX/w2avdAHS4Bz T5RKAAP+wETEhoSOr8q5wDfbgHXqLcySOGCIQISVgtPX7inLJ0Lrh31E93b39T66XqILyk5NDEr CkZqW9IujQpnip3w9SMQy0kAF2DCFQ9q/C/Qteo7noXm2SeGlQocgYkRp3uNeS+xy7uYsYoPVvh nU1DZfpLCPG08qC8DbSsyEvH/f1LPlXr5dwu/ATFGPBe3MoD3M90uJw9JrLN9JV85do7Gf4s1bj xS26lX9pNUzach8POXzkawMulpG7nEPe53uqofKvNNQw5mRtXn4QV7RVY7OhBY9SGbUO/ccJgwi 4yZjp7ZXeIbo5CvL9V24Dqt3XWPspilXsEbTD6eqpvJeClKl/dd5yYammE4DYI= X-Authority-Info-Out: v=2.4 cv=UqJu9uwB c=1 sm=1 tr=0 ts=69e406c6 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=gP1GEkNOX-MqffGxZ4oA:9 X-Proofpoint-GUID: 0umByWHxODrtxuxgPX1rsvpRfg6LA3aB X-Proofpoint-ORIG-GUID: 0umByWHxODrtxuxgPX1rsvpRfg6LA3aB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 phishscore=0 spamscore=0 clxscore=1030 mlxscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.189; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551908935158500 Content-Type: text/plain; charset="utf-8" This was really... quite broken. After fixing this, Windows boots with kernel-irqchip=3Doff. Signed-off-by: Mohamed Mediouni --- include/system/whpx-common.h | 1 + target/i386/whpx/whpx-all.c | 43 +++++------------------------------- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/include/system/whpx-common.h b/include/system/whpx-common.h index 04289afd97..3406c20fec 100644 --- a/include/system/whpx-common.h +++ b/include/system/whpx-common.h @@ -4,6 +4,7 @@ =20 struct AccelCPUState { bool window_registered; + int window_priority; bool interruptable; bool ready_for_pic_interrupt; uint64_t tpr; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 53b59a98b9..1d99003a4a 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -22,6 +22,8 @@ #include "qemu/main-loop.h" #include "hw/core/boards.h" #include "hw/intc/ioapic.h" +#include "hw/intc/i8259.h" +#include "hw/i386/x86.h" #include "hw/i386/apic_internal.h" #include "qemu/error-report.h" #include "qapi/error.h" @@ -371,28 +373,6 @@ static int whpx_set_tsc(CPUState *cpu) return 0; } =20 -/* - * The CR8 register in the CPU is mapped to the TPR register of the APIC, - * however, they use a slightly different encoding. Specifically: - * - * APIC.TPR[bits 7:4] =3D CR8[bits 3:0] - * - * This mechanism is described in section 10.8.6.1 of Volume 3 of Intel 64 - * and IA-32 Architectures Software Developer's Manual. - * - * The functions below translate the value of CR8 to TPR and vice versa. - */ - -static uint64_t whpx_apic_tpr_to_cr8(uint64_t tpr) -{ - return tpr >> 4; -} - -static uint64_t whpx_cr8_to_apic_tpr(uint64_t cr8) -{ - return cr8 << 4; -} - void whpx_set_registers(CPUState *cpu, WHPXStateLevel level) { struct whpx_state *whpx =3D &whpx_global; @@ -421,7 +401,7 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel l= evel) v86 =3D (env->eflags & VM_MASK); r86 =3D !(env->cr[0] & CR0_PE_MASK); =20 - vcpu->tpr =3D whpx_apic_tpr_to_cr8(cpu_get_apic_tpr(x86_cpu->apic_stat= e)); + vcpu->tpr =3D cpu_get_apic_tpr(x86_cpu->apic_state); vcpu->apic_base =3D cpu_get_apic_base(x86_cpu->apic_state); =20 idx =3D 0; @@ -692,17 +672,6 @@ void whpx_get_registers(CPUState *cpu, WHPXStateLevel = level) hr); } =20 - if (whpx_irqchip_in_kernel()) { - /* - * Fetch the TPR value from the emulated APIC. It may get overwrit= ten - * below with the value from CR8 returned by - * WHvGetVirtualProcessorRegisters(). - */ - whpx_apic_get(x86_cpu->apic_state); - vcpu->tpr =3D whpx_apic_tpr_to_cr8( - cpu_get_apic_tpr(x86_cpu->apic_state)); - } - idx =3D 0; =20 /* Indexes for first 16 registers match between HV and QEMU definition= s */ @@ -751,7 +720,7 @@ void whpx_get_registers(CPUState *cpu, WHPXStateLevel l= evel) tpr =3D vcxt.values[idx++].Reg64; if (tpr !=3D vcpu->tpr) { vcpu->tpr =3D tpr; - cpu_set_apic_tpr(x86_cpu->apic_state, whpx_cr8_to_apic_tpr(tpr)); + cpu_set_apic_tpr(x86_cpu->apic_state, tpr); } =20 /* 8 Debug Registers - Skipped */ @@ -1690,7 +1659,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } =20 /* Sync the TPR to the CR8 if was modified during the intercept */ - tpr =3D whpx_apic_tpr_to_cr8(cpu_get_apic_tpr(x86_cpu->apic_state)); + tpr =3D cpu_get_apic_tpr(x86_cpu->apic_state); if (tpr !=3D vcpu->tpr) { vcpu->tpr =3D tpr; reg_values[reg_count].Reg64 =3D tpr; @@ -1737,7 +1706,7 @@ static void whpx_vcpu_post_run(CPUState *cpu) if (vcpu->tpr !=3D tpr) { vcpu->tpr =3D tpr; bql_lock(); - cpu_set_apic_tpr(x86_cpu->apic_state, whpx_cr8_to_apic_tpr(vcpu->t= pr)); + cpu_set_apic_tpr(x86_cpu->apic_state, vcpu->tpr); bql_unlock(); } =20 --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551679; cv=none; d=zohomail.com; s=zohoarc; b=f2Nu9mMV25vfOzRZQpo74RdAvqYkREwQOUjqf43OVEn8Xx4NH4F20yMlchetFMmQKYaKbJBElvhvhrotZYyzgYYpAd1Fj4wee65/ot06uI3SjkX4ZPiY08f58L/m73TVNS7I5NuvK2HLqsF7ytKd3qnBlXkPIzB8PzmxRPd7Gfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551679; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8EZPZlRm+WeBpG+PY8ABc8ic+4NnvhCRuAoI2d7ubQQ=; b=hFNgdd82T7+suRByWgpdHbR7uGbE48AEgToZQduou4NSjmADM/NKIdjqTG3Hvprkf+Gd8C4HJsRiF0oG7GEah2dXQKieJJCJyH553DKZ8ryyQqrmatpyDxKxOXbQY07g17ZywSVwqTTLMzkSO9vcBgac4kSu9nNYweV5DadkOfw= 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 1776551679001178.53613235745706; Sat, 18 Apr 2026 15:34:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEa-0006Bf-Jt; Sat, 18 Apr 2026 18:33:52 -0400 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 1wEEEX-00068M-LR for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:49 -0400 Received: from p-east2-cluster3-host11-snip4-2.eps.apple.com ([57.103.77.173] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEV-0004ty-Jp for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:49 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 8D7261800219; Sat, 18 Apr 2026 22:33:42 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 07B7618000BB; Sat, 18 Apr 2026 22:33:39 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551626; x=1779143626; bh=8EZPZlRm+WeBpG+PY8ABc8ic+4NnvhCRuAoI2d7ubQQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=gU9qNfCy9/LVk0/dibZX0so9eoXa1aRpCaMyKmnj5tXTM9L8I1PXTa9bfgVIFCNO/y2IuVQf+oSRsNv3zmC6fQbfpQzmxTdEtWIYw+sW/NrlNPpciHD2FST8pJAyRNO74k2Ztub9fBHEvuQRGfVoo1+71ILlnOzcBBFfv1XqTD9ZgRQJnt+neI37PkA7YjwNA7rRimdKpOKJGBvBIpgRo2tfdUO8dRUI2Q07OwQOklUhjhXkF9KHBVxh0O6XJD3a/rMPA7UA2xn8k+H4CcMhLxgrKHQAJ+eY+1+hU7kBmaUYkbgUDe464lZVvKXj+jtXrC+Lm2FvrbizRjo+n9/33w== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 09/38] whpx: i386: use WHvX64RegisterCr8 only when kernel-irqchip=off Date: Sun, 19 Apr 2026 00:32:51 +0200 Message-ID: <20260418223320.51330-10-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX8S7LpYcxsbkm NfahpoiTuN5AZ2RkyOE6VHJv4tHynNipzgPE8Go67F4p/XwdeiYMnn/WZvRfJn5X+uYX6Y7j7JE Eg3RCyrMxna+hpBGVMbxdTfZTm9iTP33iuuAEsS5nxq6eZBlEOKcOymcnVQXGugJjKSAmQT+EbE cbCcvb8o91s3QL8Cntl8nDopeilaqpjdEq7KLuZAu8VPVeXhfEHNhMGYHoV9VO1c7gYdKD6I5B9 O0JVA6yx53wLgiqy2eQDz70DfPlrRmPUverj+oDu0qbVY1nvLtH8OEWnu58Z9G1+k1sY8I+h71E xtOD4jJ2kSjRdFkw2tltpKBI9r6Q6qdT7QZ+MWgP6wtDK9pFlLRAumQgOfA06Y= X-Proofpoint-GUID: QHg8zqBOFqmtRme37BTVeHGFT4AJXXSQ X-Proofpoint-ORIG-GUID: QHg8zqBOFqmtRme37BTVeHGFT4AJXXSQ X-Authority-Info-Out: v=2.4 cv=b9q/I9Gx c=1 sm=1 tr=0 ts=69e406c8 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=4IdwVP5-j8YZXVcKM5MA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 phishscore=0 mlxlogscore=934 malwarescore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1030 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.173; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551681782154100 Content-Type: text/plain; charset="utf-8" When kernel-irqchip=3Don, manage TPR as part of the APIC state instead enti= rely. This fixes some failure to set state errors. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 1d99003a4a..03f490804b 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -95,7 +95,6 @@ static const WHV_REGISTER_NAME whpx_register_names[] =3D { WHvX64RegisterCr2, WHvX64RegisterCr3, WHvX64RegisterCr4, - WHvX64RegisterCr8, =20 /* X64 Debug Registers */ /* @@ -459,8 +458,11 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel = level) vcxt.values[idx++].Reg64 =3D env->cr[3]; assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr4); vcxt.values[idx++].Reg64 =3D env->cr[4]; - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr8); - vcxt.values[idx++].Reg64 =3D vcpu->tpr; + /* For kernel-irqchip=3Don, TPR is managed as part of APIC state */ + if (!whpx_irqchip_in_kernel()) { + WHV_REGISTER_VALUE cr8 =3D {.Reg64 =3D vcpu->tpr}; + whpx_set_reg(cpu, WHvX64RegisterCr8, cr8); + } =20 /* 8 Debug Registers - Skipped */ =20 @@ -716,11 +718,14 @@ void whpx_get_registers(CPUState *cpu, WHPXStateLevel= level) env->cr[3] =3D vcxt.values[idx++].Reg64; assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr4); env->cr[4] =3D vcxt.values[idx++].Reg64; - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterCr8); - tpr =3D vcxt.values[idx++].Reg64; - if (tpr !=3D vcpu->tpr) { - vcpu->tpr =3D tpr; - cpu_set_apic_tpr(x86_cpu->apic_state, tpr); + + /* For kernel-irqchip=3Don, TPR is managed as part of APIC state */ + if (!whpx_irqchip_in_kernel()) { + tpr =3D vcpu->exit_ctx.VpContext.Cr8; + if (tpr !=3D vcpu->tpr) { + vcpu->tpr =3D tpr; + cpu_set_apic_tpr(x86_cpu->apic_state, tpr); + } } =20 /* 8 Debug Registers - Skipped */ @@ -1660,7 +1665,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) =20 /* Sync the TPR to the CR8 if was modified during the intercept */ tpr =3D cpu_get_apic_tpr(x86_cpu->apic_state); - if (tpr !=3D vcpu->tpr) { + if (!whpx_irqchip_in_kernel() && tpr !=3D vcpu->tpr) { vcpu->tpr =3D tpr; reg_values[reg_count].Reg64 =3D tpr; qatomic_set(&cpu->exit_request, true); @@ -1702,12 +1707,14 @@ static void whpx_vcpu_post_run(CPUState *cpu) =20 env->eflags =3D vcpu->exit_ctx.VpContext.Rflags; =20 - uint64_t tpr =3D vcpu->exit_ctx.VpContext.Cr8; - if (vcpu->tpr !=3D tpr) { - vcpu->tpr =3D tpr; - bql_lock(); - cpu_set_apic_tpr(x86_cpu->apic_state, vcpu->tpr); - bql_unlock(); + if (!whpx_irqchip_in_kernel()) { + uint64_t tpr =3D vcpu->exit_ctx.VpContext.Cr8; + if (vcpu->tpr !=3D tpr) { + vcpu->tpr =3D tpr; + bql_lock(); + cpu_set_apic_tpr(x86_cpu->apic_state, vcpu->tpr); + bql_unlock(); + } } =20 vcpu->interruption_pending =3D --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551845; cv=none; d=zohomail.com; s=zohoarc; b=mhxpj4afBrJSQv7EahW1mWZlw/g3x4rj2Im/h1kPXqzA+oOj5ArWHLL2KvWnh+EmIlSvrwu6W+VAYJxE6Z1Vh03+5b0/YJpObuYjre8tmCuReUhcKpSDay/sAtblqGTFY9NhSR2JL7OC2Fn6vILb5Yl/jKQ6v9JRl7u0N4CWVd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551845; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HdVAIoica2OqP4cKWuMYnvVU1VqaziOIo3sBb38zdzU=; b=ha3t6GHtCdQA8jhDEpJtQEcb2iMajOCxYac3Q16sqqZ0p/Ca2rAzcN4s8b9g3n/P8IG24qR6CA93hdVyL4Xt2LesV4ST/2lLsfmYVXOLvTN4qrm3tc3VqwiuPrIul5NIMz9fe5q2lUPPZkxIVP8eKdVyDAgardJAWqZk+ty7fec= 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 177655184568398.01775136386959; Sat, 18 Apr 2026 15:37:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEe-0006GQ-MC; Sat, 18 Apr 2026 18:33:56 -0400 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 1wEEEa-0006BA-EK for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:52 -0400 Received: from p-east2-cluster3-host9-snip4-6.eps.apple.com ([57.103.77.137] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEX-0004u8-Am for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:51 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 5F030180022B; Sat, 18 Apr 2026 22:33:44 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id C49E518000C4; Sat, 18 Apr 2026 22:33:41 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551628; x=1779143628; bh=HdVAIoica2OqP4cKWuMYnvVU1VqaziOIo3sBb38zdzU=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Iggo9eD86V2tdPXw9YbQmql4six5zJlH5cPnnRvpfmQB088dQOC6o1SxKwA2OMX7/dyHtfAOi6OXgpDFEK+RuFi/ZojOL+8vVfqumH5/48gQ3107SkHvv0FS7KpkcktqFqgsyEaf24GWYeaOsRUgP5RBM4xPVybtSic6TJCMV3m6AVO5r2cXDH1B3tII6XbtrWLCjLRsgaGjhuk1Jd//ebfmH1fzCs8YQhvOrRqcRpUs1oy7OH8bB7RKvttoghcQwoNJ1J60q3JeYUrGxUwIXCrT58t/avK/i2ws5sGrlVXY7MIb8XsCUuxjLuHkuoFi7b+KZrxIISfvwEr0ppeF8g== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 10/38] whpx: i386: disable kernel-irqchip on Windows 10 when PIC enabled Date: Sun, 19 Apr 2026 00:32:52 +0200 Message-ID: <20260418223320.51330-11-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=QIRlhwLL c=1 sm=1 tr=0 ts=69e406ca cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=nUl_a9z44qMLw6SsMv4A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX/CMr3wtoRg8G r/L54LqVKeW8rarAvRyB1x6JGcqdSUBnDjJ9BKHVTvDByexCEsu5a2TsD9xtiumlOAgHdzToWKB FUwtWfi+bkgR4ir8XRd8oJ/RQPn31lLDsp+LyikfzP0DhuutCYS4gEyzVewfGdHseUd7GR5O0vA E/uRLsEpgOtcJUrG4T6S6+m3cjTcvNzv/S4tqBmKN5scLd1xHWAFwNTrJp44fpM6H3CNhcTg8p8 zvQy3q96bOwJ4Js78c8gwC1o+NQKuFTbimcUcr4PBD8P4f9htkNiCRagiIvV5FuTmaU5hRZAg1+ H06d9Nc8KXuCyN1YhmNJIByZqiSbaLMe9rJgt+Ingk5WlE1uF+Nh01c4N9pbC4= X-Proofpoint-ORIG-GUID: 7HTTc7bKpyYwqiC68cIdXsm2ZMQAfT80 X-Proofpoint-GUID: 7HTTc7bKpyYwqiC68cIdXsm2ZMQAfT80 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=867 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1030 phishscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.137; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551846757158500 Content-Type: text/plain; charset="utf-8" Move WHvCapabilityCodeProcessorPerfmonFeatures queries as that's how we distinguish if on a legacy OS. Now that Windows guests are booting, disable kernel-irqchip=3Don by default for Windows 10 when the PIC is enabled. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 69 +++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 03f490804b..4d1a151db5 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2447,6 +2447,13 @@ int whpx_accel_init(AccelState *as, MachineState *ms) 0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001}; UINT32 cpuidExitList_legacy_os[] =3D {1, 0x40000000, 0x40000001, 0x400= 00010}; =20 + X86MachineState *x86ms =3D X86_MACHINE(ms); + bool pic_enabled =3D false; + + if (x86ms->pic =3D=3D ON_OFF_AUTO_ON || x86ms->pic =3D=3D ON_OFF_AUTO_= AUTO) { + pic_enabled =3D true; + } + whpx =3D &whpx_global; =20 if (!init_whp_dispatch()) { @@ -2518,6 +2525,35 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 + /* Enable supported performance monitoring capabilities */ + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodeProcessorPerfmonFeatures, &perfmon_features, + sizeof(WHV_PROCESSOR_PERFMON_FEATURES), &whpx_cap_size); + /* + * Relying on this is a crutch to maintain Windows 10 support. + * + * WHvCapabilityCodeProcessorPerfmonFeatures and + * WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks + * are implemented starting from Windows Server 2022 (build 20348). + */ + if (FAILED(hr)) { + warn_report("WHPX: Failed to get performance " + "monitoring features, hr=3D%08lx", hr); + is_modern_os =3D false; + } else { + hr =3D whp_dispatch.WHvSetPartitionProperty( + whpx->partition, + WHvPartitionPropertyCodeProcessorPerfmonFeatures, + &perfmon_features, + sizeof(WHV_PROCESSOR_PERFMON_FEATURES)); + if (FAILED(hr)) { + error_report("WHPX: Failed to set performance " + "monitoring features, hr=3D%08lx", hr); + ret =3D -EINVAL; + goto error; + } + } + /* * Error out if WHP doesn't support apic emulation and user is requiri= ng * it. @@ -2530,8 +2566,9 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 - if (whpx->kernel_irqchip_allowed && features.LocalApicEmulation && - whp_dispatch.WHvSetVirtualProcessorInterruptControllerState2) { + if (whpx->kernel_irqchip_allowed && !(whpx_is_legacy_os() && pic_enabl= ed + && !whpx->kernel_irqchip_required) && features.LocalApicEmulation + && whp_dispatch.WHvSetVirtualProcessorInterruptControllerState2) { WHV_X64_LOCAL_APIC_EMULATION_MODE mode =3D WHvX64LocalApicEmulationModeX2Apic; hr =3D whp_dispatch.WHvSetPartitionProperty( @@ -2590,34 +2627,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 - /* Enable supported performance monitoring capabilities */ - hr =3D whp_dispatch.WHvGetCapability( - WHvCapabilityCodeProcessorPerfmonFeatures, &perfmon_features, - sizeof(WHV_PROCESSOR_PERFMON_FEATURES), &whpx_cap_size); - /* - * Relying on this is a crutch to maintain Windows 10 support. - * - * WHvCapabilityCodeProcessorPerfmonFeatures and - * WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks - * are implemented starting from Windows Server 2022 (build 20348). - */ - if (FAILED(hr)) { - warn_report("WHPX: Failed to get performance " - "monitoring features, hr=3D%08lx", hr); - is_modern_os =3D false; - } else { - hr =3D whp_dispatch.WHvSetPartitionProperty( - whpx->partition, - WHvPartitionPropertyCodeProcessorPerfmonFeatures, - &perfmon_features, - sizeof(WHV_PROCESSOR_PERFMON_FEATURES)); - if (FAILED(hr)) { - error_report("WHPX: Failed to set performance " - "monitoring features, hr=3D%08lx", hr); - ret =3D -EINVAL; - goto error; - } - } =20 /* Enable synthetic processor features */ WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS synthetic_features; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551889; cv=none; d=zohomail.com; s=zohoarc; b=auId08/GSxL90h89TwCsJLqt5mIDksOUGVWQ+q5XPKApeVz/K9WazCm9na9kAtjTQ8f1nUEnx2mLPZf8Te0+77oe4XeFDtP3N2WTdPINzQj7PcEPJf5A+ZC21maijdESU3c2BBqwX5GqYI2jlgv33tEeW3RCoEx04amYALBp5jc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551889; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nQndBaUP3p2GZXyo2M9Kbvf88ZtsTTUcXFr9tOFWW7A=; b=lae91OD6/OdhGeveFbm/VJjGjGNcavlhUFMr5V5Pk9velz6GJxmDC21JdB4HhqqgnsatiUMxJMvNTO87sKi4/W5KCCkjXbfpuVAUbFORv1m5N+NKwoU9+Hex3gtBYB77p6wmNpc/y8mk4Jji84afy7QdO5LvwVScLKU8lP7696c= 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 1776551889248463.860881562341; Sat, 18 Apr 2026 15:38:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEg-0006Hj-C3; Sat, 18 Apr 2026 18:33:58 -0400 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 1wEEEa-0006CS-NU for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:52 -0400 Received: from p-east2-cluster3-host6-snip4-1.eps.apple.com ([57.103.77.202] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEY-0004ug-Qc for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:52 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 2605418000E2; Sat, 18 Apr 2026 22:33:45 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 9414B1800222; Sat, 18 Apr 2026 22:33:43 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551630; x=1779143630; bh=nQndBaUP3p2GZXyo2M9Kbvf88ZtsTTUcXFr9tOFWW7A=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=boKGwfFsCmtfwzZOtiHefW4S+3kgCyrdGwoswCbWFhifOZMl7hzPz10rks2rbuBAZpgs4emZiLnRtji6ok3XIfaZEvpOBcfGRxGawEXWiWue6+iqcY7tKNmhxvqOPY3MjHsbnBS9JPr7YgSdqfaGjxiCxQW0DhqESQmdD1/dLoPx/FsORx6fbU/v3KhDrVH/5L4yI6bDEDJT6Jxfh7e+E2v7cgL3T4m85sYhQZ79jROletPnJVHeIZKAhiMbyY95y52/LinpX0tGA4m3zdcB3CJPIl9e736tedvB/e4HrsdlY29ti+jB+L3pOBMbhnTMo43hGNuaW0R6AQ3lu0LqEw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 11/38] whpx: i386: IO port fast path cleanup Date: Sun, 19 Apr 2026 00:32:53 +0200 Message-ID: <20260418223320.51330-12-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=Bf3VE7t2 c=1 sm=1 tr=0 ts=69e406cb cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Vrzv6M8N8vcM0KmfSJEA:9 X-Proofpoint-ORIG-GUID: xHKOkSL623PWbeDDLlJdz86npNkCflNn X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfXx9IoADgprsVH DQbxggkxhe8RvTFScnZO3cRh4p7kcWeBuCfhSIvmmmbIBz9sECs2vYy3uG7CM5oS9VB4AReBRmT 4g3zwEFR36PVqYYn7qEciLrMSoEk+G8OANIDZbU+NDjc6ZON/QXW9/ZxySZBGTRNeHx8AGfYh9+ pQqHHzeumU+vnlSpgYVlkBkHpg6PxDNurfOH1nc84cT++7ZGFjj+0i/ZqjfPTzvFB5X9MK3mD6x wJIoWQWNuAtBX5PV91gaBSTtcB2YC7tCncnw1bMswrMeC5DHAyREj1IYDwM2mKVfOlzBFy+N3pG aa9zct39J6kPx9fxGsUho/JU97BYD8ZTvsQ1lvupqldUJNUczlx6yaEGTa9rMQ= X-Proofpoint-GUID: xHKOkSL623PWbeDDLlJdz86npNkCflNn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 clxscore=1030 adultscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=872 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.202; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551890781154100 Content-Type: text/plain; charset="utf-8" vmport calls synchronise_state within an I/O port read. Support that properly. What was there before worked because of a side effect of whpx_get_reg synchronising context if cpu->vcpu_dirty. Remove that whpx_get_reg call in whpx_bump_rip too as it's no longer needed now. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 4d1a151db5..4deeffbcfc 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -862,7 +862,6 @@ static void handle_io(CPUState *env, uint16_t port, voi= d *buffer, static void whpx_bump_rip(CPUState *cpu, WHV_RUN_VP_EXIT_CONTEXT *exit_ctx) { WHV_REGISTER_VALUE reg; - whpx_get_reg(cpu, WHvX64RegisterRip, ®); reg.Reg64 =3D exit_ctx->VpContext.Rip + exit_ctx->VpContext.Instructio= nLength; whpx_set_reg(cpu, WHvX64RegisterRip, reg); } @@ -890,13 +889,23 @@ static int whpx_handle_portio(CPUState *cpu, } else { reg.Reg64 =3D (uint64_t)val; } - whpx_bump_rip(cpu, exit_ctx); - whpx_set_reg(cpu, WHvX64RegisterRax, reg); + /* vmport calls cpu_synchronize_state on an I/O port read */ + if (!cpu->vcpu_dirty) { + whpx_bump_rip(cpu, exit_ctx); + whpx_set_reg(cpu, WHvX64RegisterRax, reg); + } else { + env->eip =3D exit_ctx->VpContext.Rip + exit_ctx->VpContext.Ins= tructionLength; + env->regs[R_EAX] =3D reg.Reg64; + } return 0; } else if (!ctx->AccessInfo.StringOp && ctx->AccessInfo.IsWrite) { RAX(env) =3D ctx->Rax; handle_io(cpu, ctx->PortNumber, &RAX(env), 1, ctx->AccessInfo.Acce= ssSize, 1); - whpx_bump_rip(cpu, exit_ctx); + if (!cpu->vcpu_dirty) { + whpx_bump_rip(cpu, exit_ctx); + } else { + env->eip =3D exit_ctx->VpContext.Rip + exit_ctx->VpContext.Ins= tructionLength; + } return 0; } =20 --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551674; cv=none; d=zohomail.com; s=zohoarc; b=PoU4xWoKWYqHetKkFM9AV+3+xPlVGshPQQxbPwMUJljAeHORyUnBY1ka4YRXOv5B1CRMtfYwEbL/3ikHDLjOkajSHmCNEzXQ+iNjLTFA/FlReJqv0PU02yiYc6n7pQI/t+IhwsOkGWLgnRRq5+Makh9g6v2o06B1ZRgXhQoEAtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551674; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oAkt/0X2iO3/a4xMYFMpgz9ibOxymnsHVlwLVxvLdU8=; b=Nbnhy+DibXArlOyJma7gK1A0DWmlOPmgoNkUXiyTLgKAelpRf1cB5mudlN0qIS8WbD1i5+VWIoYRdcO/xiIRdhZEF+9vEhQaLGcbFjWsNnOIMU6YbjIAxi9NUKHJNjxsdytutjEyJGTgUEcFngzVJ9/FsTbdOS317TKsPGAdWfc= 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 1776551674215153.04957050118287; Sat, 18 Apr 2026 15:34:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEc-0006EC-2T; Sat, 18 Apr 2026 18:33:54 -0400 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 1wEEEa-0006B7-DH for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:52 -0400 Received: from p-east2-cluster3-host2-snip4-8.eps.apple.com ([57.103.77.229] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEX-0004uH-FA for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:51 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 7719218000B2; Sat, 18 Apr 2026 22:33:47 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 5E0181800238; Sat, 18 Apr 2026 22:33:45 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551628; x=1779143628; bh=oAkt/0X2iO3/a4xMYFMpgz9ibOxymnsHVlwLVxvLdU8=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=KVy+KVNEk6NliTfmwz8/cdjHI5v3F1WSwsofUYkrQx8HFfsehf5j7d1HoLxyS7rzag0X4Ag/MkVtrclkYLQ+pVRuOtXWeptOCv85HOCJAl/15b0u4BwDmkJmr3aCiEhO6WuOzZyutpu7UbJzlX2/y2bCB0r139sWikqQzTjkA5pFyyuVyMC2ZhsMr3wwAP1mk9ugEEp7MB90pS1r5X2droVNST+v7xEeCa/pzhq12g+pUthzuf8nA/7PtEXCWl38ZuTM472hPj+b/bwrTodAcU2kxDL5t6k8cqyO1ls4WhAqfsjLJAcA4EdVxcifWfO1Sl+z1LGmk644UmhgitRF4Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 12/38] whpx: i386: disable enlightenments and LAPIC for isapc Date: Sun, 19 Apr 2026 00:32:54 +0200 Message-ID: <20260418223320.51330-13-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfXwmVNFf7K1e+I NenzSUQQ4oWTwFBanZNmD4INnlZ65fvlvwh8ioW1fd7bK+DLzifkCP9LsA+OOJV8YALu3f/h0j7 sbuCbDUrO3uFuZH6Qup3QmskMwq75sKoj0/gMT9RzTRSOYsvVeifTgq5cODiJZPG6oC6ipSDWUW q4qaEMeyBJHE36c+ksWLl3QnBrdPtrZyTS62/VCpRUfEWGLOb09Ox14mL6a4YjCv+0L5ib882Se NPavjrplfcQBvs+E88EpozpAYjD9krFSlUkIQyEfVi/AONLzs9KtMoiA49UaZQNQ9tMEHDoPma1 rrXEQ5jA4j3IRe5qLYJxkXJ3a5Rsf+Htke7Yr5v2wnwgbs3SsiIC7MwTEQVlyk= X-Proofpoint-ORIG-GUID: GP6nFPvUdfyTmlR7fKenDHqNKTmmGWVI X-Authority-Info-Out: v=2.4 cv=KJ9XzVFo c=1 sm=1 tr=0 ts=69e406cc cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=kaNVauZA35-AGszze7oA:9 X-Proofpoint-GUID: GP6nFPvUdfyTmlR7fKenDHqNKTmmGWVI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 clxscore=1030 mlxlogscore=890 lowpriorityscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.229; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551678575154100 Content-Type: text/plain; charset="utf-8" The isapc machine doesn't have an APIC. And Hyper-V enlightenments don't sound too useful to have there so disable those. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 4deeffbcfc..d38b83d274 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2470,6 +2470,14 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 + /* for isapc, disable Hyper-V enlightenments and LAPIC */ + if (!strcmp(MACHINE_GET_CLASS(ms)->name, "isapc")) { + whpx->kernel_irqchip_allowed =3D false; + whpx->kernel_irqchip_required =3D false; + whpx->hyperv_enlightenments_allowed =3D false; + whpx->hyperv_enlightenments_required =3D false; + } + whpx->mem_quota =3D ms->ram_size; =20 hr =3D whp_dispatch.WHvGetCapability( --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551815; cv=none; d=zohomail.com; s=zohoarc; b=heibwrJxJaiQ83nNXyMw1/CzzqsgYh2ta5uGRvBxlnRLGZo6TialiqvxlvQ5FIsUUdOELWXvMzpoCuUQRxoZcbmbNCMYHHSc/Aoy189oVOufCJpjNDOb9Y3vo7HHBCW3qRWfIbwE17ijGvR5BKG7tlIX1wmOIyLKqw6BD56yydM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551815; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3V2AbGdIbRhzhb8qduzZPT33vmWH+5zkQKA9bxE3tcA=; b=VQWdRoSRuBcCAQyaCGL3OJa1TFSjYCmwyfhgrGmyx7YHl4rG7Wa7tjioCnGiSJo4stqa8mzfBbDj3a6nNcsF+wlJkSTgYmksd/lT9IfpgylhZG9ivKd0MfdH2eXfsOexpDORwQrivKrUF4bPo+DPA0+bf990s7MPJzfs2Nrbf/s= 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 1776551815799616.2184454853356; Sat, 18 Apr 2026 15:36:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEj-0006J1-De; Sat, 18 Apr 2026 18:34:01 -0400 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 1wEEEb-0006DW-GH for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:53 -0400 Received: from p-east2-cluster3-host3-snip4-10.eps.apple.com ([57.103.77.161] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEZ-0004ur-FZ for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:53 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 3EE59180022A; Sat, 18 Apr 2026 22:33:49 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 28D261800200; Sat, 18 Apr 2026 22:33:47 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551630; x=1779143630; bh=3V2AbGdIbRhzhb8qduzZPT33vmWH+5zkQKA9bxE3tcA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=LdBrrHUjaQM7p7X9Njp30ae8XCY9L/x4Bnt2kOyKWuyxe504h4O0brOtZ5Dbm3F/WXFNKcoMIm2Ir6HmgJqvN1gdOYh9PD31PSDb8mAQC3QZdCKOzY/T1XutsC8oyRzlaaZ8LMcWBSuL+xIatsX4Fx46JjJpgji+MZl7Og72zOxWNvRts95u9J0VEPCC3zg9As4WmEniGXqk7lap6mYbhgsuhWzdbYy8CMuOQ3lCv5m3V8NyjyEc0DW5c4nUCf10DJu/DlocLEm0hZhPfSi47sy9MSJNk+gEeLjg+IDdd2PIENBHMBbL3jmQ8zamqYlZ7fVQpV5qgrijq4ha43IDEA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 13/38] whpx: i386: interrupt priority support Date: Sun, 19 Apr 2026 00:32:55 +0200 Message-ID: <20260418223320.51330-14-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: 6keKHzrZYixi3iuVNBkbZ6sWg-pcv3S4 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfXx0LDJau9D5WO jVm8pd8vuxc1TbQ0X2x3eS4kBsQ4AD0pLv3ZKaWRfuUhudlBFCaopHmRUJPvZqqC0mUWjTB4b01 Cl1+HW38zsHM3fmhgqZTEqLxofE4EFSi8xhoT3DZAdE424JH3XppJfInIZNXcj4f/V9c4IXc5eH n351NrTSjC5bPrmSNivtyr0Fci5a+dpo1DBF0dNaNWzfBKvVwhqZUVtVG8kk+/61rrGYviTAo4D P1uo3hbiGSdba4I/XQQVAdGg3Nnujp5lVyG1NLxp/AUK1KMerl6oULdxfj9IC+he+nw2CU2RK6N wFmaVzjZFXTEpvT1AWLyCj0AucTMzEQqcalZ/BkRFtwVNwKLAppoEi5RbRv7/I= X-Authority-Info-Out: v=2.4 cv=GplPO01C c=1 sm=1 tr=0 ts=69e406ce cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=NuKELtICf0aykZwt-QIA:9 X-Proofpoint-ORIG-GUID: 6keKHzrZYixi3iuVNBkbZ6sWg-pcv3S4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1030 mlxlogscore=686 spamscore=0 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.161; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551817021158500 Content-Type: text/plain; charset="utf-8" Implement APIC IRR interrupt priorities. Even with kernel-irqchip=3Doff, Hyper-V is aware of interrupt priorities and implements CR8/TPR, with the InterruptPriority field being followed. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index d38b83d274..930731e4bf 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1588,6 +1588,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) UINT32 reg_count =3D 0; WHV_REGISTER_VALUE reg_values[3]; WHV_REGISTER_NAME reg_names[3]; + int irr =3D apic_get_highest_priority_irr(x86_cpu->apic_state); =20 memset(&new_int, 0, sizeof(new_int)); memset(reg_values, 0, sizeof(reg_values)); @@ -1623,10 +1624,20 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } } =20 + if (irr =3D=3D -1) { + if (isa_pic !=3D NULL && pic_get_output(isa_pic)) { + /* In case it's a PIC interrupt */ + irr =3D 0; + } else if (cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD)) { + abort(); + } + } + /* Get pending hard interruption or replay one that was overwritten */ if (!whpx_irqchip_in_kernel()) { if (!vcpu->interruption_pending && - vcpu->interruptable && (env->eflags & IF_MASK)) { + vcpu->interruptable && (env->eflags & IF_MASK) + && (vcpu->tpr < irr || irr =3D=3D 0)) { assert(!new_int.InterruptionPending); if (cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD)) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_HARD); @@ -1683,13 +1694,17 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } =20 /* Update the state of the interrupt delivery notification */ - if (!vcpu->window_registered && + if ((!vcpu->window_registered || + (vcpu->window_priority < irr && vcpu->window_priority !=3D 0) || + (irr =3D=3D 0 && vcpu->window_priority !=3D 0)) && cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD)) { reg_values[reg_count].DeliverabilityNotifications =3D (WHV_X64_DELIVERABILITY_NOTIFICATIONS_REGISTER) { - .InterruptNotification =3D 1 + .InterruptNotification =3D 1, + .InterruptPriority =3D irr >> 4 }; vcpu->window_registered =3D 1; + vcpu->window_priority =3D irr; reg_names[reg_count] =3D WHvX64RegisterDeliverabilityNotifications; reg_count +=3D 1; } @@ -1703,7 +1718,7 @@ static void whpx_vcpu_pre_run(CPUState *cpu) reg_names, reg_count, reg_values); if (FAILED(hr)) { error_report("WHPX: Failed to set interrupt state registers," - " hr=3D%08lx", hr); + " hr=3D%08lx, InterruptPriority=3D%i", hr, irr >>= 4); } } } @@ -1919,6 +1934,7 @@ int whpx_vcpu_run(CPUState *cpu) case WHvRunVpExitReasonX64InterruptWindow: vcpu->ready_for_pic_interrupt =3D 1; vcpu->window_registered =3D 0; + vcpu->window_priority =3D 0; ret =3D 0; break; =20 --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551689; cv=none; d=zohomail.com; s=zohoarc; b=T1pKM8poPRUQgy06O6/ObEERnbW8mvAJCuPIGYoGLwvbimLshKvAewrgUlDI/vNlzuIjEKDIcSJh3vHRu/QY8/gvAvVVFJGioA6lOlmEWgAh9sq8h4WxrB24n7l0tx+U9nklcdFtRf8/qfNRv5sNwAwMUicFyUsaFxiT01dIUQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551689; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZKPoujWieITU4lFOoYMwoz+Ev2hRigYtFeWxrkrjtmk=; b=aHzHUpivvB6Qaq3ZAVqw2drSYqsOHFWTVcFZ3eJR4B7cgP/Dvdt8dZW74lqZwjzqXoTIKZLFI7dtBhNJKGaC6TQQnPZhsl6OnlO54qs2IaHEnLTAyckECpm0tqFWgg1Y2e2jg8vf6TdeTWa04Mcu4ewrGjbzHWca2kRvJtCNKbM= 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 1776551689255897.3340255987542; Sat, 18 Apr 2026 15:34:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEEd-0006Fe-VB; Sat, 18 Apr 2026 18:33:56 -0400 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 1wEEEc-0006EX-BJ for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:54 -0400 Received: from p-east2-cluster3-host12-snip4-10.eps.apple.com ([57.103.77.191] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEa-0004vR-WB for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:54 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 1425418000B4; Sat, 18 Apr 2026 22:33:50 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id E83E31800208; Sat, 18 Apr 2026 22:33:48 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551632; x=1779143632; bh=ZKPoujWieITU4lFOoYMwoz+Ev2hRigYtFeWxrkrjtmk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=CxF8QgQW+tStUw6ukGlpap0waEGdhTnrkGVxquGmIRODwfjuQbNVAZnf+vsvigXaO5keIf8Rnb3owTmtC3d/KHhQ/U+6u612iI8y/uclPePEP//6S96UC2LK5S5WQ9T7eAOfoO1vLTmcZqqxFnJFiFnodp+xOJKl4jUsfN/urvJPKKz9TuPOBbg7AZG0JOTlWRMeM1Fzy6NiF3eC9t4Ntd9rn7lhyj1ts2Y8jrFjnypivZxpRwT80RejQ8y74Y+/9T/TD9qa2zn/H1DxEpRUus2TUIO5FDfWGxEbpYao3uceR1mN5a6lWBWsUJh8g6adKR32uHESdvWhvPO9wVtO1w== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 14/38] hw/intc: apic: disallow APIC reads when disabled Date: Sun, 19 Apr 2026 00:32:56 +0200 Message-ID: <20260418223320.51330-15-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: CoVy3Xd7475ZqhG64IkpEEKn__iMH0xs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX6mgpljENIahD Euh/ON6z/z1qWQxFeftQyAdhwC2GBqJHjV8aJQ+yesn19jvfiGgfiY960l1ribU+7CKehv5DzNy Mu4MLz12jtK3lKED5NLL9WCSD+ENNlRwW4kKAh6AaQa2w3PnPUSmPeK/AYR+MdYrcKP/qh+alys OQjNrB6RzAt2WuTziG0HyLw4T9JMXgMT39qYOxbIsUo+eBLs9hk+XYzWTCJoIQYG4oaRfwUh4Np nPidC/04MkcUVEZp7pXtaQFrYQVMyRi+IQSQLRVd7TisopapFK4iHDw2gFS1UVUJo0oEfFBGY2x F9Sk40PO+Qzy803AhdN9uAsPLxsxOywBUMklc87Gasow7c+WMRia0F8yvsqmJo= X-Proofpoint-ORIG-GUID: CoVy3Xd7475ZqhG64IkpEEKn__iMH0xs X-Authority-Info-Out: v=2.4 cv=T9mBjvKQ c=1 sm=1 tr=0 ts=69e406d0 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=JYwUPf56aOQolOdNqfgA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=821 clxscore=1030 lowpriorityscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.191; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551692436158500 Content-Type: text/plain; charset="utf-8" !APICBASE_ENABLE + attempting to read xAPIC registers is not an allowed com= bination. And neither is x2APIC enabled + attempting to read xAPIC registers Signed-off-by: Mohamed Mediouni --- hw/intc/apic.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 8766ed00b9..e5ea831261 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -875,6 +875,15 @@ static uint64_t apic_mem_read(void *opaque, hwaddr add= r, unsigned size) return -1; } =20 + /* if the xAPIC is disabled, return early. */ + if (!(s->apicbase & MSR_IA32_APICBASE_ENABLE)) { + return 0xffffffff; + } + + if (is_x2apic_mode(s)) { + return 0xffffffff; + } + index =3D (addr >> 4) & 0xff; apic_register_read(s, index, &val); =20 --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551900; cv=none; d=zohomail.com; s=zohoarc; b=MxQU6HdhZVqbPZTYjncECcXCLDr52NwEsgBbiOEVNdbdfqEmy00Y/t/p0pBhLmvuPYmQGLlxgmlanl1mN6VZgfB3LJMkQKsHysoBohTHvyu6kHmYWP/zWulfZFsSLDthQcjaeIAGP7OAU909KtXVg/g5AttyHlkbdQ81KpcevvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551900; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hYF1YTmYdf5ICiuf6ALK6IwLbtpP7J/JdnQnOFIIsbo=; b=PDy5wj8SCsBCzhCm431zGmvidXk7DTRjnN7KP+yqZkUEM5y/gvalRdCHkjSFpoCxR3cB31ck25h2L30uIheprTagscC+ULzIwhxDJ8+a6H5Q08chquDt4zIZXEiZNvtEOkSlSVF4waWKO+dWjEFxa/w5tMf2z4lV9m53CRKRC6w= 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 1776551900402370.4932607883102; Sat, 18 Apr 2026 15:38:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEF7-0006Xu-79; Sat, 18 Apr 2026 18:34:25 -0400 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 1wEEEh-0006IV-UQ for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:00 -0400 Received: from p-east2-cluster3-host10-snip4-3.eps.apple.com ([57.103.77.144] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEf-0004x5-V3 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:33:59 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 5C5EE1800200; Sat, 18 Apr 2026 22:33:53 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id BED1A18000FC; Sat, 18 Apr 2026 22:33:50 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551637; x=1779143637; bh=hYF1YTmYdf5ICiuf6ALK6IwLbtpP7J/JdnQnOFIIsbo=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=chwHqxapMD4vCfhjyo3Azu/SCUpbIYWcMRhAdug4R6gl6ZUKOL/PXqRixP2H+GlhIlotXso0EMcouEzBH5gzOPEK5DYPbK0/O9yRhr8+ZrzZ3XA5y0Jdf0RwG9l+IXwmiN8lThAkoZO2sye4E04KeUWXs8zwXdD3HFx4G/cYsBoawtLCLdsAWzinO5HIwiwQQzSyCKVuw0/pDta3nEvIt0R9HxxJUh9mloykHLULuMJMbkTW5RQ2X1VDY/as2n98HtVXRyNoOthkHhy90QOvQSuVzPltIP75sLdPpLUbUk64Eu55/lD8uMNxbSvU6+XmBszpwhB093+/h9zMFTjQWQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 15/38] whpx: i386: fix CPUID[1:EDX].APIC reporting Date: Sun, 19 Apr 2026 00:32:57 +0200 Message-ID: <20260418223320.51330-16-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX2ZRcgagM5rqO rr9nU4B6K3Y44WQzNnIH+azS7BRiNjRJGhsd80s9MIldUXHGXpFc9ddf3ErvEfMLRHdeTEwQC7Y QG2UpzvIwHTwpTiYQXJDQdDKKDwHOIzBkBn8FXIvbke/nEh58E9y+57RF1xiN6HHF1K/0Exlx/p /ZSbUE7q3HbfN0+FAvwAkyyEishBBrzzlvEmoll6chb+wCsvoNeL4+7wTyPuH7si+nes7yxTg92 SFgnWF9WWAGhWKMFy+Rd1KeOG5+A8Qob1fUw9NKR23IystIsv/OYE2hPpLt5Lw992t/KI/KnwLJ KdQ6AXDYnV9x4j7ccAqng+RRw4GhQxRCsC8n0WRiiWfjIm8RRCUX5lM170niRs= X-Proofpoint-ORIG-GUID: M4NPjTwZ_Fza2HwYf56v7tVaBSPGNyi2 X-Proofpoint-GUID: M4NPjTwZ_Fza2HwYf56v7tVaBSPGNyi2 X-Authority-Info-Out: v=2.4 cv=co2WUl4i c=1 sm=1 tr=0 ts=69e406d3 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=ljJ9V6m273jqBh-Cp98A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 lowpriorityscore=0 spamscore=0 clxscore=1030 adultscore=0 malwarescore=0 mlxlogscore=922 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.144; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551900963158500 Content-Type: text/plain; charset="utf-8" Hyper-V always has CPUID[1:EDX].APIC set, even when the APIC isn't enabled = yet. Work around this by also using the APICBASE trap for kernel-irqchip=3Don. Signed-off-by: Mohamed Mediouni --- include/system/whpx-common.h | 1 - target/i386/whpx/whpx-all.c | 34 ++++++++--------- target/i386/whpx/whpx-apic.c | 71 ++++++++++++++++++++++++++++++++++-- 3 files changed, 84 insertions(+), 22 deletions(-) diff --git a/include/system/whpx-common.h b/include/system/whpx-common.h index 3406c20fec..79710e2fb3 100644 --- a/include/system/whpx-common.h +++ b/include/system/whpx-common.h @@ -8,7 +8,6 @@ struct AccelCPUState { bool interruptable; bool ready_for_pic_interrupt; uint64_t tpr; - uint64_t apic_base; bool interruption_pending; /* Must be the last field as it may have a tail */ WHV_RUN_VP_EXIT_CONTEXT exit_ctx; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 930731e4bf..c6f4041515 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -139,7 +139,6 @@ static const WHV_REGISTER_NAME whpx_register_names[] = =3D { #ifdef TARGET_X86_64 WHvX64RegisterKernelGsBase, #endif - WHvX64RegisterApicBase, /* WHvX64RegisterPat, */ WHvX64RegisterSysenterCs, WHvX64RegisterSysenterEip, @@ -401,7 +400,6 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel l= evel) r86 =3D !(env->cr[0] & CR0_PE_MASK); =20 vcpu->tpr =3D cpu_get_apic_tpr(x86_cpu->apic_state); - vcpu->apic_base =3D cpu_get_apic_base(x86_cpu->apic_state); =20 idx =3D 0; =20 @@ -519,9 +517,6 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel l= evel) vcxt.values[idx++].Reg64 =3D env->kernelgsbase; #endif =20 - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterApicBase); - vcxt.values[idx++].Reg64 =3D vcpu->apic_base; - /* WHvX64RegisterPat - Skipped */ =20 assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterCs); @@ -556,6 +551,12 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel = level) error_report("WHPX: Failed to set virtual processor context, hr=3D= %08lx", hr); } + + if (level >=3D WHPX_LEVEL_FULL_STATE) { + WHV_REGISTER_VALUE apic_base =3D {}; + apic_base.Reg64 =3D cpu_get_apic_base(X86_CPU(cpu)->apic_state); + whpx_set_reg(cpu, WHvX64RegisterApicBase, apic_base); + } } =20 static int whpx_get_tsc(CPUState *cpu) @@ -647,7 +648,7 @@ void whpx_get_registers(CPUState *cpu, WHPXStateLevel l= evel) X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; struct whpx_register_set vcxt; - uint64_t tpr, apic_base; + uint64_t tpr; HRESULT hr; int idx; int idx_next; @@ -779,13 +780,6 @@ void whpx_get_registers(CPUState *cpu, WHPXStateLevel = level) env->kernelgsbase =3D vcxt.values[idx++].Reg64; #endif =20 - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterApicBase); - apic_base =3D vcxt.values[idx++].Reg64; - if (apic_base !=3D vcpu->apic_base) { - vcpu->apic_base =3D apic_base; - cpu_set_apic_base(x86_cpu->apic_state, vcpu->apic_base); - } - /* WHvX64RegisterPat - Skipped */ =20 assert(whpx_register_names[idx] =3D=3D WHvX64RegisterSysenterCs); @@ -1997,8 +1991,7 @@ int whpx_vcpu_run(CPUState *cpu) val =3D X86_CPU(cpu)->env.apic_bus_freq; } =20 - if (!whpx_irqchip_in_kernel() && - vcpu->exit_ctx.MsrAccess.MsrNumber =3D=3D MSR_IA32_APICBAS= E) { + if (vcpu->exit_ctx.MsrAccess.MsrNumber =3D=3D MSR_IA32_APICBAS= E) { is_known_msr =3D 1; if (!vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { /* Read path unreachable on Hyper-V */ @@ -2164,6 +2157,13 @@ int whpx_vcpu_run(CPUState *cpu) } else { reg_values[2].Reg32 &=3D ~CPUID_EXT_X2APIC; } + + /* CPUID[1:EDX].APIC is dynamic */ + if (env->features[FEAT_1_EDX] & CPUID_APIC) { + reg_values[3].Reg32 |=3D CPUID_APIC; + } else { + reg_values[3].Reg32 &=3D ~CPUID_APIC; + } } =20 /* Dynamic depending on XCR0 and XSS, so query DefaultResult */ @@ -2725,9 +2725,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) =20 memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); prop.X64MsrExitBitmap.UnhandledMsrs =3D 1; - if (!whpx_irqchip_in_kernel()) { - prop.X64MsrExitBitmap.ApicBaseMsrWrite =3D 1; - } + prop.X64MsrExitBitmap.ApicBaseMsrWrite =3D 1; =20 hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c index f26ecaf6e8..65629ca45f 100644 --- a/target/i386/whpx/whpx-apic.c +++ b/target/i386/whpx/whpx-apic.c @@ -90,9 +90,70 @@ static void whpx_get_apic_state(APICCommonState *s, apic_next_timer(s, s->initial_count_load_time); } =20 -static int whpx_apic_set_base(APICCommonState *s, uint64_t val) +static int apic_set_base_check(APICCommonState *s, uint64_t val) { - s->apicbase =3D val; + /* Enable x2apic when x2apic is not supported by CPU */ + if (!cpu_has_x2apic_feature(&s->cpu->env) && + val & MSR_IA32_APICBASE_EXTD) { + return -1; + } + + /* + * Transition into invalid state + * (s->apicbase & MSR_IA32_APICBASE_ENABLE =3D=3D 0) && + * (s->apicbase & MSR_IA32_APICBASE_EXTD) =3D=3D 1 + */ + if (!(val & MSR_IA32_APICBASE_ENABLE) && + (val & MSR_IA32_APICBASE_EXTD)) { + return -1; + } + + /* Invalid transition from disabled mode to x2APIC */ + if (!(s->apicbase & MSR_IA32_APICBASE_ENABLE) && + !(s->apicbase & MSR_IA32_APICBASE_EXTD) && + (val & MSR_IA32_APICBASE_ENABLE) && + (val & MSR_IA32_APICBASE_EXTD)) { + return -1; + } + + /* Invalid transition from x2APIC to xAPIC */ + if ((s->apicbase & MSR_IA32_APICBASE_ENABLE) && + (s->apicbase & MSR_IA32_APICBASE_EXTD) && + (val & MSR_IA32_APICBASE_ENABLE) && + !(val & MSR_IA32_APICBASE_EXTD)) { + return -1; + } + + return 0; +} + +static int apic_set_base(APICCommonState *s, uint64_t val) +{ + if (apic_set_base_check(s, val) < 0) { + return -1; + } + + s->apicbase =3D (val & MSR_IA32_APICBASE_BASE) | + (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE)); + if (!(val & MSR_IA32_APICBASE_ENABLE)) { + s->apicbase &=3D ~MSR_IA32_APICBASE_ENABLE; + cpu_clear_apic_feature(&s->cpu->env); + } + + /* Transition from disabled mode to xAPIC */ + if (!(s->apicbase & MSR_IA32_APICBASE_ENABLE) && + (val & MSR_IA32_APICBASE_ENABLE)) { + s->apicbase |=3D MSR_IA32_APICBASE_ENABLE; + cpu_set_apic_feature(&s->cpu->env); + } + + /* Transition from xAPIC to x2APIC */ + if (cpu_has_x2apic_feature(&s->cpu->env) && + !(s->apicbase & MSR_IA32_APICBASE_EXTD) && + (val & MSR_IA32_APICBASE_EXTD)) { + s->apicbase |=3D MSR_IA32_APICBASE_EXTD; + } + return 0; } =20 @@ -235,6 +296,10 @@ static void whpx_apic_mem_write(void *opaque, hwaddr a= ddr, static const MemoryRegionOps whpx_apic_io_ops =3D { .read =3D whpx_apic_mem_read, .write =3D whpx_apic_mem_write, + .impl.min_access_size =3D 1, + .impl.max_access_size =3D 4, + .valid.min_access_size =3D 1, + .valid.max_access_size =3D 4, .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 @@ -262,7 +327,7 @@ static void whpx_apic_class_init(ObjectClass *klass, co= nst void *data) =20 k->realize =3D whpx_apic_realize; k->reset =3D whpx_apic_reset; - k->set_base =3D whpx_apic_set_base; + k->set_base =3D apic_set_base; k->set_tpr =3D whpx_apic_set_tpr; k->get_tpr =3D whpx_apic_get_tpr; k->post_load =3D whpx_apic_post_load; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551680; cv=none; d=zohomail.com; s=zohoarc; b=B+bvsdB5NWRuZrMRDO7akUlxp1m0ZPF/VwKtT48msgUZYAdZkZySItAFDLfF32EHNKfPkB48ezxWgEHuckhu5QUz8TAXFXmLygUE7A0L2c8e5+R2WyrK82YvBkKK37QOuGvmZXHtfb7PHLDuXUm7oBrj2yvGRSExm0XNXu91g8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551680; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4624USsR0p7NklevhZpyiOMKAkWt2GrauvKzkoCskVE=; b=KN+CwEvAuOj1P0Pe3sosYFNDFgidLHnQnBc4zbm7KKjm6ERszT9PSuv1QrRSk8oPUqPRbwVckkAQVXREETdWyKVoRpb0o9cq3noHCiI6WyPJfF/Ou4dPknaCNhIzt0IXuFLYPNuTcgAeP8NK8UNfXSbCiqMM+Zg4Vc7XZYDYOuw= 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 17765516799901022.3954044374766; Sat, 18 Apr 2026 15:34:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEF2-0006O9-0a; Sat, 18 Apr 2026 18:34:23 -0400 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 1wEEEj-0006J5-DT for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:01 -0400 Received: from p-east2-cluster3-host1-snip4-7.eps.apple.com ([57.103.77.218] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEh-0004xO-M9 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:00 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 3403F180022D; Sat, 18 Apr 2026 22:33:54 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 9515018000DE; Sat, 18 Apr 2026 22:33:52 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551638; x=1779143638; bh=4624USsR0p7NklevhZpyiOMKAkWt2GrauvKzkoCskVE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=RAMoMLPA3CPmVMfMZxnMGbp+KmhW7TWeoo0EiTToDYOMnduynxvaA9VyF9ONzHh8uLa3Ki744I1Q/3qGgqwSqnHcAUe7yXGWv4nd/NgXx0KL8y6VsVXQ8jZ3zoRWnnhKR3ZgqpW1U7yJSxsNOpdnxqc2oXhhkYDTNmNDOdqsx1faZ8KIy1YVPQTP68QO6G99aFjcTVcvO33hx8kC287a6aLZqb+s5oqp+fBdGBQ+i0r2gxDPMiAPmoPwEL0mFSpYG/LdhS6vzKYHwElKe+ELFUlagToC+1hoQG6xFya8wBGj2PZkIeWdJZ+ssO7bDqKnwCnT3bYLjziGlZY4agRHgw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 16/38] whpx: i386: set apicbase value only on success Date: Sun, 19 Apr 2026 00:32:58 +0200 Message-ID: <20260418223320.51330-17-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: ath6hSxmO0vdrhsd7QiH7xi9SuHyLSxy X-Proofpoint-GUID: ath6hSxmO0vdrhsd7QiH7xi9SuHyLSxy X-Authority-Info-Out: v=2.4 cv=AqXjHe9P c=1 sm=1 tr=0 ts=69e406d5 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=uh2sygq7LFHjsVUyvz4A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX3GdIRHfLQlUg xQlYg6EJS6IztzIDOzQ3z4W5Bv8AmJW4bTcgDlg36MI8SOr20lzyFtx4ur4U3sCRkp9OuWuwDOe HmlGsIFDcHBG92y4AGXDYuC/PzUiXuZB18nBf29qR0rRNw+jA10MYV5C1wGslkyuxdU3/87kBGy 7l9RPI0qdR73+YtD2Lw+Nj489MFSwL9kdYk9akamwpB0VIB5MD3lnez+A9wHfIF/Bx6qX0QB1v6 9vQ04p6gh9gMJdQNzX9gQjckJqo7c2JdyODOIGZOp5/wLJreohWRBnhTjwMaTJa6MQ56z7t3BF6 /D+tsKxcf4rRy9lGKLoNbQTUEeO0PKkZWdpVnR78jFj62ohptPTX8hWGNyTkOo= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxlogscore=676 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.218; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551681790154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index c6f4041515..0d72e93621 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2001,8 +2001,9 @@ int whpx_vcpu_run(CPUState *cpu) int msr_ret =3D cpu_set_apic_base(X86_CPU(cpu)->apic_s= tate, val); if (msr_ret < 0) { x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0= D_GPF, 0); + } else { + whpx_set_reg(cpu, WHvX64RegisterApicBase, reg); } - whpx_set_reg(cpu, WHvX64RegisterApicBase, reg); } } =20 --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551894; cv=none; d=zohomail.com; s=zohoarc; b=IZA0qR2zjhB8H7uJ0T/wu0Z7ia7Au+KSMgcnnVoodZERRlEAA2cTRn1zCOzYCUjZADG/8Uh/MuiRiKgG9Z7Q5qx++vjfEeURIhGHs28e4nWhEfzxuBjNReBo/yLF2CXf7It3SU3p3RmF07syyYxDT/UZfvJYhDvppbD9jYQn2BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551894; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6dRDJ5VEmS78xsRk6kMHBpp9Wu7kQoHjBWY816Egd9Q=; b=JnssTlMeCUmP8h7/mb9YyO/ZtbAUwU5GgEoWVeNJiVQ8XexldQEzSitHKgwwrPcRvaoaYwFqgnI2Tdu/4PhQukH7xeSGkS6rPYowZdgtTnhJyGTwSfKLlPoTzB9zqlEkk51YtjtGJfPGtmEjA0THsy8RsPAotx55uDO50kfCoVY= 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 1776551894417874.5442030588084; Sat, 18 Apr 2026 15:38:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEF8-0006gg-2U; Sat, 18 Apr 2026 18:34:26 -0400 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 1wEEEj-0006J4-Cd for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:01 -0400 Received: from p-east2-cluster3-host11-snip4-3.eps.apple.com ([57.103.77.174] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEg-0004xF-GC for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:00 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 8AAB518000C4; Sat, 18 Apr 2026 22:33:56 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 6E81F18000A8; Sat, 18 Apr 2026 22:33:54 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551637; x=1779143637; bh=6dRDJ5VEmS78xsRk6kMHBpp9Wu7kQoHjBWY816Egd9Q=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=YtlC/9Y56yhtbRa+XjmzSFOtZubmXQ7B0DiMIJSCkJz5/6NSToVdu36Kq+NSjcb4hgw2pGMEMxM4aJlCXePkr7x7enN4Eg6xpUl2KdjaSEZo7UaglUY2AK6UnT5GudmpH21IWA2KmjIis1T1buCN8/cznv/z+xh8FpGQXVMEPrQqSMIngL6/7safzGN1DcC7HYG9soPXJamTFOlilqEXCm0VDnr0vYXsaAh0pkdLTy8bPxR60U1Zl3nWBauy3kqwvdvSBMYF9laOiBplDCbwtneT6QxA5Bkcx7UbnfXwd7YC54bUY8U9YicHfHejfgl5As1rNNQ297KeSWW1KKr5Lg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 17/38] whpx: i386: unknown MSR configurability Date: Sun, 19 Apr 2026 00:32:59 +0200 Message-ID: <20260418223320.51330-18-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: X8uOZ2NOvbwt4S0PKLmgUNdWFjWuG6Hb X-Proofpoint-GUID: X8uOZ2NOvbwt4S0PKLmgUNdWFjWuG6Hb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX/s5O1QghGj4+ akGzB9x2JL+q7ZeCKF27hpVmpzdq28M+Lcw+5PM20TKKEgVnaGKAa0Kfnf85GN0POpVzI+wk8w2 xP/eZLbGvUQ7FnbxdBaHdC1r4M9q+yuNWD5DFypuysKOF97afvzkdFHvGRP2T8hs25d+ONNzQ2x 7ShUvMU01HnRRKRoIwDHkC7ySo3hAKVTrxX+sQb8TExdbl0C8WzBJnzlQBvv6MduAM6/lpkixtf hL4weVO8dNDDHgF7C2hG3bw/+Yo7JznO9nvsjDqKFoZ562K8eEKNgsH/C7NqssJwPC+pmOow+oF TH9WDWCAFVil6mi79kp2jL6ldsDY3LxpPMlohzcAohnGkPCcaZ3y8uHWZogpaw= X-Authority-Info-Out: v=2.4 cv=L78QguT8 c=1 sm=1 tr=0 ts=69e406d5 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=9z_AL-2ZILZrMqfKHsQA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 clxscore=1030 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.174; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551896613154100 Content-Type: text/plain; charset="utf-8" Add an option to inject back a GPF for unknown MSRs. Keep it on by default for now as Linux expects accesses to some AMD-specific MSRs to always succeed when on an AMD host. Signed-off-by: Mohamed Mediouni --- accel/whpx/whpx-common.c | 38 ++++++++++++++++++++++++++++++++++ include/system/whpx-internal.h | 1 + target/i386/whpx/whpx-all.c | 4 ++++ 3 files changed, 43 insertions(+) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index 59be996aef..706871f138 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -505,6 +505,38 @@ static void whpx_set_hyperv(Object *obj, Visitor *v, } } =20 +static void whpx_set_unknown_msr(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + struct whpx_state *whpx =3D &whpx_global; + OnOffAuto mode; + + if (!visit_type_OnOffAuto(v, name, &mode, errp)) { + return; + } + + switch (mode) { + case ON_OFF_AUTO_ON: + whpx->ignore_unknown_msr =3D true; + break; + + case ON_OFF_AUTO_OFF: + whpx->ignore_unknown_msr =3D false; + break; + + case ON_OFF_AUTO_AUTO: + whpx->ignore_unknown_msr =3D true; + break; + default: + /* + * The value was checked in visit_type_OnOffAuto() above. If + * we get here, then something is wrong in QEMU. + */ + abort(); + } +} + static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data) { AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); @@ -538,6 +570,11 @@ static void whpx_accel_class_init(ObjectClass *oc, con= st void *data) NULL, NULL); object_class_property_set_description(oc, "hyperv", "Configure Hyper-V enlightenments"); + object_class_property_add(oc, "ignore-unknown-msr", "OnOffAuto", + NULL, whpx_set_unknown_msr, + NULL, NULL); + object_class_property_set_description(oc, "ignore-unknown-msr", + "Configure unknown MSR behavior"); } =20 static void whpx_accel_instance_init(Object *obj) @@ -552,6 +589,7 @@ static void whpx_accel_instance_init(Object *obj) whpx->hyperv_enlightenments_required =3D false; /* Value determined at whpx_accel_init */ whpx->hyperv_enlightenments_enabled =3D false; + whpx->ignore_unknown_msr =3D true; } =20 static const TypeInfo whpx_accel_type =3D { diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index cf782cf5f8..86639627b3 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -47,6 +47,7 @@ struct whpx_state { bool hyperv_enlightenments_required; bool hyperv_enlightenments_enabled; =20 + bool ignore_unknown_msr; }; =20 extern struct whpx_state whpx_global; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 0d72e93621..550f30d50a 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2048,6 +2048,10 @@ int whpx_vcpu_run(CPUState *cpu) vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite); } =20 + if (!is_known_msr && !whpx->ignore_unknown_msr) { + x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GPF, 0= ); + } + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters( whpx->partition, cpu->cpu_index, --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551871; cv=none; d=zohomail.com; s=zohoarc; b=UhX2e/KCK5R2ztGf50/wIzXaud+tzpTLx3K+Fkx/0vj9H3f5JAfHMOiZkWdI0VfU+VgUCLNecQnvphBgJ3b/FtcUazBxyd+qUPfGNM37WDULghRe1ZY7HF1R1KOs+8i76Wy2NMCrFyRsmZJgSQnIvQ0sDZPI50MzegYQyFfm0P0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551871; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IShay1Ni0PZxOVHY3UdoELgY8h3uyJIPv2UhTb9vE4s=; b=FpmtIVQwHBkSWxdU5tfcr2rvwDkWnvOvD8fXZ5rnY6VX21E+NpYmIVheY6Hkk7LUYQ+YbvSS6vG67Nj4ichtkGAdKd2hwX+zoM7upowWuf5v2neqXG85PrKcY6SnNrzyhsCP9cEpTUJmUE9JPCAJtVQYwa0oulQWPSDqocVhaMY= 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 1776551871922295.7613245274554; Sat, 18 Apr 2026 15:37:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFA-0006uu-JM; Sat, 18 Apr 2026 18:34:28 -0400 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 1wEEEq-0006O5-Mw for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:10 -0400 Received: from p-east2-cluster3-host12-snip4-10.eps.apple.com ([57.103.77.191] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEl-0004yR-BI for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:05 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id C8DFF18000E2; Sat, 18 Apr 2026 22:33:58 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 412F718000B2; Sat, 18 Apr 2026 22:33:56 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551642; x=1779143642; bh=IShay1Ni0PZxOVHY3UdoELgY8h3uyJIPv2UhTb9vE4s=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=foPkY30M5cRhZRT3cILXj41N+1Vm/Zvuyvs14almptyG/6EsH2/C+K1RvojkWLcCkTg0WZK79i/5PBfYtan7Gb6cTwHnHss6G9dhm+wzf4af3doPl9pNB6UtmHuFv4PhIfk+XJr8mNlaHzQWXO502rsI8tr0ze9CwU6WxDmHoJPj9Ix4aoBuQ9FuiGHeGK9BhGY00Rb1AHEKY/7v87pXw4UUBk4E99j9WsKho3OsQAQanlVMK8/zxfLs13UbLA/CBmqtR8zlYboZqs+VP9OfIJjLB5F71ffhIMFJ1hfZZnRAVIHF7vyjMRuTvrIKa0KEgz7/+TnLnpaokcLW8X8NWw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 18/38] whpx: i386: enable GuestIdleReg enlightenment Date: Sun, 19 Apr 2026 00:33:00 +0200 Message-ID: <20260418223320.51330-19-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: lr3D4EwNRaeDvwZp3yMyj5heHmSQJdV1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX6HMIG+Zo+/Rt qolfK9F1dh8duRHZDDYWhhkLZYfjsNzelLopF9fEONrXJL92qPP/O/PTpzeIySciuNhQi10TD5c hEuSVZFObhP0vi6egBkGana2iyxsgVLWl+V6j4ZZAJKwRy90TWPKLLw//kEbNAAfr2FRLZfDUnR 4mrnBmeZ/9ixgcbb6Ox2KtrvuqwayoqUYL8+KIFjWBWId/cdpExK0YWdLwcoRvsu/VN7F4oI7KJ Fm2tiMCdqvhXysRB57la4peX4N+I9InNGS2OMJEtCoiyUlj9JtM/QuxQRdKu0FB0Y9KfKgocex/ iWiG7EXJwam+g+OEMFM1XoQFpGqPMOVJ6QjeQqNsGr00a4h/vrBkt/js+FH7/w= X-Proofpoint-GUID: lr3D4EwNRaeDvwZp3yMyj5heHmSQJdV1 X-Authority-Info-Out: v=2.4 cv=W9M1lBWk c=1 sm=1 tr=0 ts=69e406d8 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=givlr1pFTcEyfNb0yRoA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=981 lowpriorityscore=0 clxscore=1030 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.191; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551872787158500 Content-Type: text/plain; charset="utf-8" This corresponds to HV_X64_MSR_GUEST_IDLE (0x400000f0). This enlightenment is only available by the HV when using the Hyper-V LAPIC. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 550f30d50a..f856022a87 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2686,6 +2686,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) synthetic_features.Bank0.AccessIntrCtrlRegs =3D 1; synthetic_features.Bank0.SyntheticClusterIpi =3D 1; synthetic_features.Bank0.DirectSyntheticTimers =3D 1; + synthetic_features.Bank0.AccessGuestIdleReg =3D 1; /* * These technically work without the Hyper-V LAPIC * but behave oddly for multi-core VMs. --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551828; cv=none; d=zohomail.com; s=zohoarc; b=VWywNueL6xPDPDAgCTHO8v2reXRFhhN+OcKVTwtgESH05XOBsSZkI8irV7o+8IN88m+J+jgDDePrk9zHNcd640PnQbL/z5xE6Qmg4KY5uFjVQyd9pmv3vC2Tla3zaux5erS/LvyKm7/+U/+Ofub5KUAMM7ZnZ8qv0ExzFwSf11s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551828; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XYfcVLNP4XKUf3qEh2m3HXpH6E0h6AgTscZ6AUjxiTg=; b=EluM0GPs8KEnQxMp3jHrWjsUP4KkkHvCSuEJ+ItWwEDEnV4D4lWpnIMNR1ug4aEMQ8KxlwS7Jf/aiSbB33f6QJuheBVvK6xyF44Y4uTO4MRVDdQFR1q1RlrsnAKQaVnLlnowAIZJGuGzgRZK8e1x9kkQu/0vAcg2t/XjS0CLl2M= 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 1776551828520638.3120537760768; Sat, 18 Apr 2026 15:37:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFC-00075r-7E; Sat, 18 Apr 2026 18:34:30 -0400 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 1wEEEm-0006Ke-P5 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:10 -0400 Received: from p-east2-cluster3-host5-snip4-3.eps.apple.com ([57.103.77.194] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEk-0004yD-MD for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:04 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 2CB981800208; Sat, 18 Apr 2026 22:34:00 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 09F381800219; Sat, 18 Apr 2026 22:33:57 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551641; x=1779143641; bh=XYfcVLNP4XKUf3qEh2m3HXpH6E0h6AgTscZ6AUjxiTg=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Itbuvod/Rjn/3BdJcy93m+CoKuhi9XYM88j7kIfjxudpMd7BpjbuXFRr/AyVvz0pJMlDAZAEkYPPjVxp8cRdPbd/QaJI2P5Dl/1Cd/F3PUdKujGU9vA8FK62NgN3AL02KBLl+wtZPFh9NTUCS+ZngE20Jt/g+bseVXlhm+tqjYo+Iu49V4onAX8moW8d0JWEg4GxMP0i6MRIErbiAoOICGtX8luiD3+Na6qId+KIjH9/+Le+pnpzCAQKIs5urv/wQPRXnnxwE1tZZAaQgE55TJwNBpUzA5u17R7prdE16DH2Q1o/eB4q9SsEqQ0M4Qmr1tH4GyGIPqkvjyKxHc9QUg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 19/38] whpx: i386: tighten APIC base validity check Date: Sun, 19 Apr 2026 00:33:01 +0200 Message-ID: <20260418223320.51330-20-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: AoEA7PRthxS3YNrHZnqeqpVyNva14PgQ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfXzYRUxd/l6Amp z69Nk+1AD+L63PF+8FOp4oxz+p30RFgDMPH3UtYu2Tl32VnvCPfwANJcXo4LAJrVtfHGFpoqSUM iXsXRp3RpaLI4fVo2A0x+vemZXM2i8f3PeLm0QR+i7NSHHU1qSwD2aMEpbcgsWklE+gErD7UAov SF9iEBQ+OLymyNFrno0pGy1d5aFjjKcN6jlYk+MMd0JtxYWw2MS0OxdwBe+qT8ZFk2PJBAcpO0y 2JP5TsSeLDQTv8Lcf31XyvbNeITDtjorQxhm2Mn4Yfgmh9ULfsat328PyXVduTUvV2ho8X3NOy/ 3AtZ/r+tzsJ6KYc10hL1Lo/mSjxGZIVPYxhLpf7nfjFawK4s75wuuNwq+9f4p0= X-Proofpoint-ORIG-GUID: AoEA7PRthxS3YNrHZnqeqpVyNva14PgQ X-Authority-Info-Out: v=2.4 cv=T9mBjvKQ c=1 sm=1 tr=0 ts=69e406d9 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=uh2sygq7LFHjsVUyvz4A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=687 clxscore=1030 lowpriorityscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.77.194; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551829726154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index f856022a87..f31eabce37 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1993,6 +1993,9 @@ int whpx_vcpu_run(CPUState *cpu) =20 if (vcpu->exit_ctx.MsrAccess.MsrNumber =3D=3D MSR_IA32_APICBAS= E) { is_known_msr =3D 1; + if (val & MSR_IA32_APICBASE_RESERVED) { + x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GP= F, 0); + } if (!vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { /* Read path unreachable on Hyper-V */ abort(); --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551906; cv=none; d=zohomail.com; s=zohoarc; b=FYqDP2bBShsXlZ05w1LBG0l+kC9TeUEX/TNxTZffxXyxvRQWt4Til5Tll+gQz1PZPnwLS+Qhkpv+3thdJjq/nmCcbJPULpBjTByOnKuucueK/GwURja3F9i3OHCdv864qV0+bS1UVxwszifKEnWNtqj+HsyY8ylCmK7OVv5ht5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551906; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=shO+Mw/9k0xyNmUmIAPxgO00PEUmcfuq7ZIwrGpWZBo=; b=G8I5+lgXJzJVGdxmev6W1sVG7Li2AyMwdrtK7+TEcibLPSQXDgDff9Ui6lpa8e2RxuzFdsyxkyjzCgX3PIo/vw3nGuvE05WB1ioB9lMsi6uRstiHcZHOF58Val48xQQ5Ry0Iwtr/E3pK2ZToruBOIcXfp3+tOEI8aAVfFEOn9xA= 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 1776551906355910.2574591851126; Sat, 18 Apr 2026 15:38:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEF7-0006bP-L9; Sat, 18 Apr 2026 18:34:25 -0400 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 1wEEEs-0006OR-Ql for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:15 -0400 Received: from p-east2-cluster1-host8-snip4-10.eps.apple.com ([57.103.76.83] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEr-0004z9-0D for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:10 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id EDB591800229; Sat, 18 Apr 2026 22:34:04 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id D68E618000DA; Sat, 18 Apr 2026 22:33:59 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551646; x=1779143646; bh=shO+Mw/9k0xyNmUmIAPxgO00PEUmcfuq7ZIwrGpWZBo=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=P8ogNtW11uyTDugs6TN1DixQ9knSAh36dreSmanDPJrwJlcissnb4wW4ynTBReY8MYgxCvqdLsY43qlhLz2DF/5dCCe/xYmZGgx7ibycCrPHOj4EHg18m53euXWYBGxG/g/p1j/O0Q1YhbQlZ5ekllXyf1wr7HNGtv0JnoCYMTcZ30oI8K4Wi9LB3LBivtSoV1OVnVZ+/C2VKvTdW9KqVDv8o8LuGdrHJ7p1DZOZPa7oYm5/MhOIYPKs6Eo1hrnhFyGziFZDXQ2Gx2+0SWATY/She+ySAXHYfKil23+dd+pDq/qBv+Ht8IJFRSpxMBtykrXhRefCzNL0ufRgCAMMbA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 20/38] whpx: i386: ignore vpassist when kernel-irqchip=off Date: Sun, 19 Apr 2026 00:33:02 +0200 Message-ID: <20260418223320.51330-21-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: tb9FNmFn8VJuI6NQhH6jxdi83KenN05U X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX7bJaz0kMqF6b FqBOHAcGdHYBCrBcfWlfKYrqxighp0hbkgwhIzgR3GvG0U+w2E3FE3cEkWHrV8ofaqUkC9KqZXL NGlQNT91rSCiUiPPUf+2ypulP+l7OafLQ6HhrvaQWjPFQ5z7K0fnSeR295bRjOds3M5n1Bb/7qA LeRQas7snBaVuzjPa5KoZG2ZqBRSScO/O0vl/sDV+xSD1FCJoNqbiEzcYLzKBmUludiKaYuVgSq PCwtT881cr5oJgukgfwnvYptV3kb0Gwrln3ckju7+Eet+PPvhz3xZgm3aOBJldQ5Bn8yOUfQnmD XAwHO2p6wleCA4S6XagyeGNYehLv6zw4L7yhm0IVx2BXcec3cPHHso2+UU1Ihc= X-Authority-Info-Out: v=2.4 cv=D8ZK6/Rj c=1 sm=1 tr=0 ts=69e406de cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=HmN67jXOOwgiugJlUbgA:9 X-Proofpoint-ORIG-GUID: tb9FNmFn8VJuI6NQhH6jxdi83KenN05U X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 clxscore=1030 adultscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.83; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551906879158500 Content-Type: text/plain; charset="utf-8" Linux tries to set vpassist even when none of the enlightenments using it are available. So ignore the page it sets. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index f31eabce37..3af5f936d4 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -51,6 +51,7 @@ #define HYPERV_APIC_BUS_FREQUENCY (200000000ULL) /* for kernel-irqchip=3Doff */ #define HV_X64_MSR_APIC_FREQUENCY 0x40000023 +#define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073 =20 static bool is_modern_os =3D true; =20 @@ -2033,6 +2034,18 @@ int whpx_vcpu_run(CPUState *cpu) } } } + + /* + * Linux tries to use it anyway even when not exposed.=20 + * Ignore the write as the VP assist page is not used. + */ + if (vcpu->exit_ctx.MsrAccess.MsrNumber =3D=3D HV_X64_MSR_VP_AS= SIST_PAGE + && vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite + && !whpx_irqchip_in_kernel() + && whpx->hyperv_enlightenments_enabled) { + is_known_msr =3D 1; + } + /* * For all unsupported MSR access we: * ignore writes --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551748; cv=none; d=zohomail.com; s=zohoarc; b=QdTfpIl8UVltk2V9IuLjPcmw008JifBG9hreQ6yC8Uf6bfEfJM5i7wSj/vJXGz9OJLROqhg9HwfDpvFLob4nz16wgCca6lCKg7CvFBZixi/sjGrRMehxxwbm8ub1+j7J5IECyZQVVQXypzer/KDN0MJpMI5o/uTRJvkp4hcsec8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551748; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tT4F++bSuONbY+c7bgtCCb6QKbPZ19v7x1ehrozqyHo=; b=kq1LUlPq0JT0WCXsQ+oYc2zXATlZlZVoi+4PNrqTPZCDzU5evsQioWfLXVJHZQFTKiyAnOKBVeSQIu1XL/9d8mhSYRMSlTYAQ2+7B3rP0XnLXpdC4thhCl3Am7xg7P+SFRn2vgsWScOnNJ0vA1N1m4H/1zLUZr6EYScMckasYQM= 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 1776551747990848.0566967307851; Sat, 18 Apr 2026 15:35:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEF9-0006nd-7i; Sat, 18 Apr 2026 18:34:27 -0400 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 1wEEEw-0006Or-6G for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:17 -0400 Received: from p-east2-cluster1-host11-snip4-8.eps.apple.com ([57.103.76.51] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEs-0004zY-JF for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:12 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id C70BF1800231; Sat, 18 Apr 2026 22:34:05 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id A08971800219; Sat, 18 Apr 2026 22:34:01 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551648; x=1779143648; bh=tT4F++bSuONbY+c7bgtCCb6QKbPZ19v7x1ehrozqyHo=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=O8w4/47D4XZskitdcX2YOeuBuQ12/ujwKhcENAlau9q5kOEe89QzGWivavsGd0X8jWc4kVFHyY65OoqGBrHRsWDIGpSXg51tAFkcIUODPKKFr4+vwZMDr4lhJwiCz2C9QNlYHWtwy0ikKJBbLJpXWWw/Tw8vwOjaT2e4t0uqtvxonWkhcvfxNj8evmuKAeMnBZnO1RzUBCynf0vbI4OwsnFoqfNDuumYfrADZRXlU0C00A2e65eRoLl0aAzj0f8wXfKPG1NttPSTiISxW4u5XB1v+m9vxRyDrdlKhwrAmmTUn5svEhJ1WaoN9vi7NhFnzkWjfOpYuB1WFkX+rLSjIA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 21/38] target: i386: HLT type that ignores EFLAGS.IF Date: Sun, 19 Apr 2026 00:33:03 +0200 Message-ID: <20260418223320.51330-22-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: a6BJh7fyF4zeEZ00KtYypgFWOSnNrQyK X-Proofpoint-ORIG-GUID: a6BJh7fyF4zeEZ00KtYypgFWOSnNrQyK X-Authority-Info-Out: v=2.4 cv=I+Bohdgg c=1 sm=1 tr=0 ts=69e406df cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=ZtXhj7NgbhMgH__AbsQA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX8cCnHyQ5HXSV Pv2GiKFlPk/Vy8eSD+8ZwY8L/6PPm+1VCUXHHCe6oOYdLqRsLuAQicHI7wNpWOspYa4hTRWh3EJ PsbTw2E90/PFfLYvgc9jQ7AS8LiCwzDpSfrSRGpGbTWNQq4Dq0sZl78hTlA5yi/S1pX+p/1+3Xe prL+mDYsB6jB+3HzsOBSlKB5Gbe3D8XPB3Y6T7JGNpeEDXg5JdiC7z5hZhb35eubryziyWO4n3K dr/X2chuD3hnpt/1uRXRjo3aZ9VmIABaCvik7h0//aBN+uhLX83lWpqoKyzS//VOMwd5k+jYOYh ra/1Cwk1vWYTaB36yexXsaN4tC85MOwoxRkRSsjI+arUoBzqhFceGAw4SboD3c= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=959 phishscore=0 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 spamscore=0 clxscore=1030 lowpriorityscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.51; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551750603154100 Content-Type: text/plain; charset="utf-8" The TLFS says: > A partition which possesses the AccessGuestIdleMsr privilege may trigger > entry into the virtual processor idle sleep state through a read to the > hypervisor-defined MSR HV_X64_MSR_GUEST_IDLE. The virtual processor will > be woken when an interrupt arrives, regardless of whether the interrupt > is enabled on the virtual processor or not. Meanwhile, Windows 24H2+ calls this MSR anyway without the privilege being = set. Add the infrastructure to support it on the generic QEMU side. Signed-off-by: Mohamed Mediouni --- target/i386/cpu.c | 10 ++++++---- target/i386/cpu.h | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0000093fa3..b18e40666e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -10482,13 +10482,15 @@ int x86_cpu_pending_interrupt(CPUState *cs, int i= nterrupt_request) (((env->hflags2 & HF2_VINTR_MASK) && (env->hflags2 & HF2_HIF_MASK)) || (!(env->hflags2 & HF2_VINTR_MASK) && - (env->eflags & IF_MASK && - !(env->hflags & HF_INHIBIT_IRQ_MASK))))) { + ((env->eflags & IF_MASK && + !(env->hflags & HF_INHIBIT_IRQ_MASK)) + || env->hflags2 & HF2_HYPERV_HLT_MASK)))) { return CPU_INTERRUPT_HARD; } else if (env->hflags2 & HF2_VGIF_MASK) { if((interrupt_request & CPU_INTERRUPT_VIRQ) && - (env->eflags & IF_MASK) && - !(env->hflags & HF_INHIBIT_IRQ_MASK)) { + ((env->eflags & IF_MASK && + !(env->hflags & HF_INHIBIT_IRQ_MASK)) + || env->hflags2 & HF2_HYPERV_HLT_MASK)) { return CPU_INTERRUPT_VIRQ; } } diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0b539155c4..67f508dc10 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -225,6 +225,7 @@ typedef enum X86Seg { #define HF2_NPT_SHIFT 6 /* Nested Paging enabled */ #define HF2_IGNNE_SHIFT 7 /* Ignore CR0.NE=3D0 */ #define HF2_VGIF_SHIFT 8 /* Can take VIRQ*/ +#define HF2_HYPERV_HLT_SHIFT 9 /* Hyper-V HV_X64_MSR_GUEST_IDLE */ =20 #define HF2_GIF_MASK (1 << HF2_GIF_SHIFT) #define HF2_HIF_MASK (1 << HF2_HIF_SHIFT) @@ -235,6 +236,7 @@ typedef enum X86Seg { #define HF2_NPT_MASK (1 << HF2_NPT_SHIFT) #define HF2_IGNNE_MASK (1 << HF2_IGNNE_SHIFT) #define HF2_VGIF_MASK (1 << HF2_VGIF_SHIFT) +#define HF2_HYPERV_HLT_MASK (1 << HF2_HYPERV_HLT_SHIFT) =20 #define CR0_PE_SHIFT 0 #define CR0_MP_SHIFT 1 --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551826; cv=none; d=zohomail.com; s=zohoarc; b=dZdhEpE0W7nNbYawzaTfzHapcJezc/vYDD3ERwyITpf/wAzCqSPms1RqmHGTgYChdXiIGmuph/DXTqSwR8ppMd+J2T/4mOFxU9uCXP8Rd4cIbmELQawVucmohpEUXHw2KR93flbv1snlXj+fByWvgx8sWmDaeDhFXCGCII6G/ZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551826; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=35AwHuK3FNutlfTTq4p+Vg27ixeNuT9FvPY378EVDsQ=; b=AKrWzt47tVDAMQOo+Pll/Athrb/3aVvUZ8sp6fiYcQlOaGmtEYUT8XB+H9AgaBT66P76ZEWaQDvGCUOEJuNmq9lGqB5hactb1l4/14lX3RUooWmYX2GiGY4e6mGdMbkTCs8X0Bf6xlDhYJ/hYG7zy5lupOHTU9mqEh534WWrH8U= 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 1776551826333212.3822229672718; Sat, 18 Apr 2026 15:37:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFE-0007HK-4w; Sat, 18 Apr 2026 18:34:32 -0400 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 1wEEEz-0006Py-Ue for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:23 -0400 Received: from p-east2-cluster1-host9-snip4-10.eps.apple.com ([57.103.76.113] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEs-0004ze-JG for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:13 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 105451800234; Sat, 18 Apr 2026 22:34:05 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 8C49D18000DE; Sat, 18 Apr 2026 22:34:03 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551649; x=1779143649; bh=35AwHuK3FNutlfTTq4p+Vg27ixeNuT9FvPY378EVDsQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=HGy6m1DhbjBukFEOW1YuZ+3TUSCKAi+4JIBtmGn/5uL/7By9TiE1gOykoaNe8PXzdRYkMZTWc9QPd/pApMcnAyUaD5m9ds35D/i3BS3qT3phzDz/RYn1gA4oGmjBC/KE8XHULdbGjSYc7lKxEjT9098phT/7HL1IdcsWoXwBMx9kPGRkzF7NhbU+YskrbnJLOs9hx/Fp9II9k9LiGSP3YJ1Da1YitgG1K4RWjsss7uqbrvH219D8FlvP1wd2qFzPZKTj3A6FGX5/p4xnWCG0fYnvxDXLRw2AcqnJ68TFtBoUfou8+Nt+1CMHLZupPhmtooPnDHZwqFUpfsycbTXJbQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 22/38] whpx: i386: add HV_X64_MSR_GUEST_IDLE when !kernel-irqchip Date: Sun, 19 Apr 2026 00:33:04 +0200 Message-ID: <20260418223320.51330-23-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX1bE1zHSsZxLm yGlZnC2zf7EhAcaKCQcmAQ2g1WKn94XpPMtCR12Ost5wuWqSovE+YbrplqgqZvu9e5AjjIS1AL1 gYe/1zyiw7BRvfFS9IwkxNphyrV3FwTT4S12BDoleCbKYt6y171nZqBFltoLyfLTB/9PkKyKFgP 6Yw2tzd2y+sMxAAcG6liTzce53KiWvRPS8xkW6QgRLiIgxV1eWRsm/HMbuiWdp7X/owszuFB3Lp G+Pp5mMuzjfiI74r5/ymEFWR3IK3PMmAbBm1qIw0RXlw1ULQ8wI623YoPRTFLQtpDOWPThu6s2t 9vGy1Ri9gOZLGV+BAiFhRbLzb4+4YLiTVFhpxNHRGTtItEe3rug3Ug44Zc+1qQ= X-Proofpoint-GUID: jRXotVJqI9qHq2FwVkaH6UPAxDpP2uYB X-Proofpoint-ORIG-GUID: jRXotVJqI9qHq2FwVkaH6UPAxDpP2uYB X-Authority-Info-Out: v=2.4 cv=b9q/I9Gx c=1 sm=1 tr=0 ts=69e406df cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=mSEN7FZ2dYRJNo9PPvgA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1030 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.113; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551827626154100 Content-Type: text/plain; charset="utf-8" Add support for an oddball HV_X64_MSR_GUEST_IDLE not-quite-an-HLT that wakes the vCPU even if EFLAGS.IF is set. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 46 ++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 3af5f936d4..4dc4030d87 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -52,6 +52,7 @@ /* for kernel-irqchip=3Doff */ #define HV_X64_MSR_APIC_FREQUENCY 0x40000023 #define HV_X64_MSR_VP_ASSIST_PAGE 0x40000073 +#define HV_X64_MSR_GUEST_IDLE 0x400000f0 =20 static bool is_modern_os =3D true; =20 @@ -1543,13 +1544,16 @@ static vaddr whpx_vcpu_get_pc(CPUState *cpu, bool e= xit_context_valid) } } =20 -static int whpx_handle_halt(CPUState *cpu) +static int whpx_handle_halt_generic(CPUState *cpu) { + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + int ret =3D 0; =20 bql_lock(); if (!(cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD) && - (cpu_env(cpu)->eflags & IF_MASK)) && + ((cpu_env(cpu)->eflags & IF_MASK) || env->hflags2 & HF2_HYPERV_H= LT_MASK)) && !cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) { cpu->exception_index =3D EXCP_HLT; cpu->halted =3D true; @@ -1560,6 +1564,27 @@ static int whpx_handle_halt(CPUState *cpu) return ret; } =20 +static int whpx_handle_halt(CPUState *cpu) +{ + int ret =3D 0; + + ret =3D whpx_handle_halt_generic(cpu); + + return ret; +} + +static int whpx_handle_hyperv_guestidle(CPUState *cpu) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + int ret =3D 0; + + env->hflags2 |=3D HF2_HYPERV_HLT_MASK; + ret =3D whpx_handle_halt_generic(cpu); + + return ret; +} + static void whpx_vcpu_kick_out_of_hlt(CPUState *cpu)=20 { WHV_REGISTER_VALUE reg; @@ -1763,9 +1788,10 @@ static void whpx_vcpu_process_async_events(CPUState = *cpu) } =20 if ((cpu_test_interrupt(cpu, CPU_INTERRUPT_HARD) && - (env->eflags & IF_MASK)) || + ((env->eflags & IF_MASK) || env->hflags2 & HF2_HYPERV_HLT_MASK)) = || cpu_test_interrupt(cpu, CPU_INTERRUPT_NMI)) { cpu->halted =3D false; + env->hflags2 &=3D ~HF2_HYPERV_HLT_MASK; } =20 if (cpu_test_interrupt(cpu, CPU_INTERRUPT_SIPI)) { @@ -2035,6 +2061,20 @@ int whpx_vcpu_run(CPUState *cpu) } } =20 + /* + * Windows and Linux both use this MSR. + * Windows 11 25H2 uses it even when not advertised. + */ + if (vcpu->exit_ctx.MsrAccess.MsrNumber =3D=3D HV_X64_MSR_GUEST= _IDLE + && !vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite + && !whpx_irqchip_in_kernel() + && whpx->hyperv_enlightenments_enabled) { + is_known_msr =3D 1; + whpx_bump_rip(cpu, &vcpu->exit_ctx); + ret =3D whpx_handle_hyperv_guestidle(cpu); + break; + } + /* * Linux tries to use it anyway even when not exposed.=20 * Ignore the write as the VP assist page is not used. --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551894; cv=none; d=zohomail.com; s=zohoarc; b=GqMe/MikODq+kESseUngHzgXdUFknNtnrcmdVH77GR27bkeXltwD9uOl1Xe+MQ5pJveYAYHJD3suid0Q2tJyn8hQ69EiP3ZoRrZkkxIEqY14ggSa3DCXTo6pb00/WTYJBqgLKkstYw5tfygJ7oP7TAhWtnE6B27lsH76nA+I5Ok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551894; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Sw+c1/Szq2U+GFUwZJhzpKe2Oxhd+T8qz2/AUdFCjpA=; b=YlXJcjIjmw1DcEI5kfjKxGzJx4lJjxurd2bdbXvXnw2eHbXNBjxcblmuTWNFpzC6p5+qSlKO7Zgum70hpt6dLpI9P0B5rgUJLOkbdyADI4o2s1AwIcWbqDzuNSH0j7p4ustGxxzhSM3ZMQmoWlkEZVY8gOlp9VY4YecT77/WttM= 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 1776551894601715.9978170738863; Sat, 18 Apr 2026 15:38:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEF8-0006m3-VP; Sat, 18 Apr 2026 18:34:27 -0400 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 1wEEF0-0006Q4-3V for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:23 -0400 Received: from p-east2-cluster1-host7-snip4-1.eps.apple.com ([57.103.76.64] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEt-000502-Ph for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:15 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id C0861180022A; Sat, 18 Apr 2026 22:34:07 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 6551C1800216; Sat, 18 Apr 2026 22:34:05 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551650; x=1779143650; bh=Sw+c1/Szq2U+GFUwZJhzpKe2Oxhd+T8qz2/AUdFCjpA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=AkE4p1pvpaIP4gLHDnKRyYXSVDbd8oDIMXXZIiNGfiWk14fve8tTuJueSdqqDmXmJo56iOiBevX9k52SAJfSoccLPqksJbDxR7w+l4vmaR9bbYd3yM2gPc5WhUvDpJuoTYB5IDb6DvOY4mYd/mb8Z+sSRqhbBXmCyDDYbJTXeEW1nt/9JkEJEhamIq3l4cm2P+DUXe/fxgxnTqsseEwenL5AQqiEnkfX9Gep6RggF3v2sUNz6qo/x2LKXVI2X8x74wd3HRa6PTGVhecRbWbE/qkciOhSAIDvyKqnUiKjYkPg84DmDIcmBH5j1pmxyqHqIydURPTR+aTZ0ezvb7ILXA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 23/38] whpx: i386: one more CPUID Date: Sun, 19 Apr 2026 00:33:05 +0200 Message-ID: <20260418223320.51330-24-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: NPMvtsQwQNLiuSPQFQxELSsZpAZe5sva X-Authority-Info-Out: v=2.4 cv=KIRXzVFo c=1 sm=1 tr=0 ts=69e406e1 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=zJD0qBlfmizEQV4F3ZsA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX++qfVw00K/Qt Mo+YM7nZ2qbfauVuVE62E/iaMeSXzMhpJHnwxwJOV6HD/3a2MYd5iaPnHT4S9U/C7lhiOsclHL7 wyJAk2FRkqhREmGBc6gihHaQ8H3cwlwGuVqNkGSHIfu/BaAb1M7b8Rq/No0FG3ZXuj8hyZvpF1+ 0ROyauezEOklnlftvthdNXUyJ8QK/Qhia0XR3vRE+Sg0kmhjFXQMVbFaNn1s1Nxdj7Po22aL4np 8N+QESU5a8GZX5lpH0GECuG9MomiWQtPEjscl5SgM+hNJwaR0TOFsbb7XeqFQTFg5NscOOe+zsR wl04XUeMnDEVTiO1X+X7NSt8NMhrC1UWeL7BmyQRzE2yfbsDGPoRAZ0WyG5CK0= X-Proofpoint-ORIG-GUID: NPMvtsQwQNLiuSPQFQxELSsZpAZe5sva X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=821 mlxscore=0 suspectscore=0 clxscore=1030 phishscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 spamscore=0 malwarescore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.64; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551894831158500 Content-Type: text/plain; charset="utf-8" Trap cpuid_0xb as it has x2APIC topology information. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 4dc4030d87..5c2a9bb8ad 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2527,7 +2527,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) WHV_PROCESSOR_FEATURES_BANKS processor_features; WHV_PROCESSOR_PERFMON_FEATURES perfmon_features; =20 - UINT32 cpuidExitList[] =3D {0x0, 0x1, 0x6, 0x7, 0x14, 0x24, 0x29, 0x1E, + UINT32 cpuidExitList[] =3D {0x0, 0x1, 0x6, 0x7, 0xb, 0x14, 0x24, 0x29,= 0x1E, 0x40000000, 0x40000001, 0x40000010, 0x80000000, 0x80000001, 0x80000002, 0x80000003, 0x80000004, 0x80000007, 0x80000008, 0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001}; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551848; cv=none; d=zohomail.com; s=zohoarc; b=jLRZAQwOA7WE/smlcfm5aAmUIl2OJRKvvZomaMTsXxl+TpY7tnSAm5RxFjWFHgGOu45X9uvs8wVXboW8DI8rCEz0PbKNLr47cdPI3gluDXSvdwzpckcRc7mP3s94uRRIZvkBjSfDLPVyph0UwXqx32i+Uv8yCGl/6wJ2MVo61cQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551848; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9xbxyGGfjNH/HWQDHlAQCg/qgFyvlvlu7VNj5bZOFog=; b=RgfolBKjm1JlSK2i5l+i4T5MEQV1rlJxT5ueQkwFSNhUa8+q6j5EqIFZG/a0/wEnhxJHPEdXIwhjZnwvRJvOkMOvt1zV4V+cybhJ0yi+mgeamXjjkEs+VmF9CXjwTlnlqnjQgLY1iTGWzydIgdygpF9EIXlz8E8pBGpY9wqbOqI= 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 177655184827122.352001575299482; Sat, 18 Apr 2026 15:37:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFA-0006tg-C7; Sat, 18 Apr 2026 18:34:28 -0400 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 1wEEEz-0006Pw-Uh for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:21 -0400 Received: from p-east2-cluster1-host4-snip4-8.eps.apple.com ([57.103.76.21] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEEt-000506-O7 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:14 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 5638D1800226; Sat, 18 Apr 2026 22:34:09 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 308C61800208; Sat, 18 Apr 2026 22:34:07 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551650; x=1779143650; bh=9xbxyGGfjNH/HWQDHlAQCg/qgFyvlvlu7VNj5bZOFog=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=X4DbNyAvhnyc1TYKUBm79a/2cSJtgwwo55QDa7SgyILldWispOxAyn2qtPagGQB8FztkQd0JC9MN+zOfipDvgldkChV9e6pJQb67zHDIN0bTw/yf2+fO0dnTbB2V6kZvcEAKvJIDfwVYHzVOhwQuQpbxKqfc1uMTXYAwoiQauTaKohnSrr0JlQrGqF1Ww9FDEWuEJiDz4ikwh5oY0E7WJjrFz980GsFKURW2SSRWUvdW09cdPV81wcnAEM2ZpmAwejti/61cIbZW0MMXaAUstGNJ7hoNF5TuMS//pi5WUxbQOJXRGU4sh7NsacPSi8RbnDEwWwD2M4D+sB+T+P50fg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 24/38] whpx: i386: some x2APIC awareness Date: Sun, 19 Apr 2026 00:33:06 +0200 Message-ID: <20260418223320.51330-25-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=N+sk1m9B c=1 sm=1 tr=0 ts=69e406e2 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=IZZkQHPJHa8VUPCOrf4A:9 X-Proofpoint-ORIG-GUID: rhbC89PkxUdCKecS-P4BR2gsNUj_nxov X-Proofpoint-GUID: rhbC89PkxUdCKecS-P4BR2gsNUj_nxov X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX75BrXgECD2fO 5eLJewz/WbMwPoo/uogEDtfwlJlI7tpv5jkV2pSX14GMFFnxGdi6nJw3pSyYSuxwHFnC0wp2QJD 1bVEgogIQpt2ECYtjRGZN8zco7lrYHjUq/jEyCxydSp4w5zVXngogHVgIVwtPBlzd4BA2nMpGox uvZRQL0DqMrc3YHRjZBz1nu1m3IoN8WPtXbGoAsTzeTjnL9iKRz6Wq3CZqFa2GYO6eV7aN9Czgr IfRMoztQGAUrZKp0YoK9IbAfYy+4/jGiy5Ysr/kOjSMZUuGJ8FYr4vfJRmvJidjgaQLdjM3FJ3j yOUyes6jUW21r+sNZIS7ZGpTxX9kLETr3gAR0RoNJaId098inDMpaM1/MVE1sg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 lowpriorityscore=0 adultscore=0 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.21; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551850713158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-apic.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c index 65629ca45f..cc272f82a5 100644 --- a/target/i386/whpx/whpx-apic.c +++ b/target/i386/whpx/whpx-apic.c @@ -33,7 +33,11 @@ static void whpx_put_apic_state(APICCommonState *s, int i; =20 memset(kapic, 0, sizeof(*kapic)); - kapic->fields[0x2].data =3D s->id << 24; + if (s->apicbase & MSR_IA32_APICBASE_EXTD) { + kapic->fields[0x2].data =3D s->initial_apic_id; + } else { + kapic->fields[0x2].data =3D s->id << 24; + } kapic->fields[0x3].data =3D s->version | ((APIC_LVT_NB - 1) << 16); kapic->fields[0x8].data =3D s->tpr; kapic->fields[0xd].data =3D s->log_dest << 24; @@ -61,7 +65,11 @@ static void whpx_get_apic_state(APICCommonState *s, { int i, v; =20 - s->id =3D kapic->fields[0x2].data >> 24; + if (s->apicbase & MSR_IA32_APICBASE_EXTD) { + assert(kapic->fields[0x2].data =3D=3D s->initial_apic_id); + } else { + s->id =3D kapic->fields[0x2].data >> 24; + } s->tpr =3D kapic->fields[0x8].data; s->arb_id =3D kapic->fields[0x9].data; s->log_dest =3D kapic->fields[0xd].data >> 24; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551856; cv=none; d=zohomail.com; s=zohoarc; b=GfkIwpnIm3/NrOgfDqhYVdF2+W2vK9ZBx0/eAF90WclWEMFU/RQInMapERc2XkG4e2VoqFucghiEepGZbCdNq+L/hPw4JaT4n06kvgyUGvsYHqlDO7h3ZB5vQSOrkiIZ/5wiMSuDh8cGF3nDXd2BZA4fs1p4r+coZ9Dk2QGHSUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551856; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cbyw4J9p3BxQsYUbbf+71GgW3JjwCzY5skdqOd0TL1w=; b=eGOiz6Mqr89I1tF1u+sZ7mvX8gP0Tq+S+k3rHrp5uX5hMkCaGYb8jIakMzUynLZ5XD86mkPFKM5XCbqd4RTMuvSv3u+u12d7LUWeDfvu498iTjVm8Be0xN1yK3snshv6aBMdtTFzGf/nwtMNC/6FnJWGyx6jD3Cj7pLZ0YPVk/8= 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 1776551856123527.7960105336657; Sat, 18 Apr 2026 15:37:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFA-0006qZ-0o; Sat, 18 Apr 2026 18:34:28 -0400 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 1wEEF3-0006TP-MG for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:24 -0400 Received: from p-east2-cluster1-host7-snip4-10.eps.apple.com ([57.103.76.73] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF1-00050y-6b for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:21 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 9B5671800200; Sat, 18 Apr 2026 22:34:11 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 0B66418000B2; Sat, 18 Apr 2026 22:34:08 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551655; x=1779143655; bh=cbyw4J9p3BxQsYUbbf+71GgW3JjwCzY5skdqOd0TL1w=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=XwNacDEQNwddzkJEiAH1ziZJ0LbR9GUWflcseBC5zZ5x041M1mTpjxsUhhR2liZcPbREjhhxJ6q1ANjzTLpr1FDhEfH+/IQU/ZSpkPuchlq+OoMGkpcVp9lH4olxG/EOMGIhV7OHNJe1jRpzkOfTeMyy0+db0NlYidqIwWpCpKRT8X0AtA2RL3lt0RW06vSfAs2yitsQ1RGfVzNwZ0nqpv+XQl68pBQKR8ddq0q28WeSrc7W/55qDo98CuV9S6FSPSoOnQb/Yw47lu4D5NW6X4csXQaqJ5i96VVGCzTN4W7Vb4z+BPXi4hfS1CM337SueLnYYk/VUERh2Vq98295Qg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 25/38] whpx: i386: set WHvX64RegisterInitialApicId Date: Sun, 19 Apr 2026 00:33:07 +0200 Message-ID: <20260418223320.51330-26-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX52ks4epzl7T9 CejhoMK5GH0JsraSAMGyawfZ/3kuejk9Z+1e1mVIYLJB47Xbsu0x0v33qQViICfPenY3VvD26Yr A10FcvFM6eND64KtLu2j2njT1/MaBPVQhc77z5J0eWxSiXlJQC8sdttXqQpVPriXJ3rGb5g+atd lIb6VLIbevbkFhXL7s8/2t3Z+Gt8u+AD5OF43n835B2l6hmWqNJZU+8EVZl9njr4ihjIvgV/yT5 /LKSpDjWxRVXCs/002/8E5T/060sfUj0YOyZ7OLKoSZD6Jj7HGOjteSxuf9Wiie1N86bGl3JYFP l8RU+ymD8wcG7fjZN3u/TFVIEUBq98zS0YN5/rmPICZHOEfYL+rgemzLNeVIQM= X-Authority-Info-Out: v=2.4 cv=c/WmgB9l c=1 sm=1 tr=0 ts=69e406e5 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=DsSKBDvzyVHF_5agjq4A:9 X-Proofpoint-GUID: z3rb19yKk9PDi52qeNbuo8FfIywsZqFX X-Proofpoint-ORIG-GUID: z3rb19yKk9PDi52qeNbuo8FfIywsZqFX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 adultscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=985 malwarescore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.73; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551858029154100 Content-Type: text/plain; charset="utf-8" Keep Hyper-V aware of the initial APIC ID chosen. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 5c2a9bb8ad..a7282eb96a 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2398,6 +2398,11 @@ int whpx_init_vcpu(CPUState *cpu) goto error; } =20 + if (!whpx_irqchip_in_kernel()) { + WHV_REGISTER_VALUE apic_id =3D {.Reg64 =3D x86_cpu->apic_state->in= itial_apic_id}; + whpx_set_reg(cpu, WHvX64RegisterInitialApicId, apic_id); + } + /* * vcpu's TSC frequency is either specified by user, or use the value * provided by Hyper-V if the former is not present. In the latter cas= e, we --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551863; cv=none; d=zohomail.com; s=zohoarc; b=aDLNxy+eNi1VjHkjm9aULuFWXnlssFOxT+qnIlDsoaSvkBFHCvwwf4Xv7uCl3FJCCP9Z/fZB3DP3SvPcOLV1wz/vECxwGeiNpLMBIAUA7p5woXnr27p91xrMwg3RzZSX+xYVS+u8yGbIm7oSBc3uIUEm4B4Op4pgwonM519gNfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551863; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3N10hCGUapdzhuKA3NU8ZhsH65avZvazfJzRL/H4ESk=; b=Vj8aufbOk4/F1Wb4CKICj3R2cmObG65EvsloJFM7tFtwMcQtNwtMLQIGScDoFap950qw4c6T0fhs0mYVj3HYAQGVGRYmyj16vJMdKc1+LGoR+CwZcw7nqBCLu6BjJv6pVUi6Pyq1y39xJhbfuv6lEdppjfDzgL/dEkfhII7/XSk= 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 1776551863058276.2362947448777; Sat, 18 Apr 2026 15:37:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFD-0007Cc-CK; Sat, 18 Apr 2026 18:34:31 -0400 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 1wEEF2-0006T5-BG for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:23 -0400 Received: from p-east2-cluster1-host12-snip4-10.eps.apple.com ([57.103.76.63] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF0-00051L-RU for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:20 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 4B0DC180022B; Sat, 18 Apr 2026 22:34:13 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id D28F318000B4; Sat, 18 Apr 2026 22:34:10 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551656; x=1779143656; bh=3N10hCGUapdzhuKA3NU8ZhsH65avZvazfJzRL/H4ESk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=cW1u5ByomZrVbmMDeUkIBa533lMoIiv8vBNnJf/GsU6y1WjF9tnQmmN/aCH9CvJkIZO4HPLxg5uq9Z16YtwqaAQNiRD8/v1cX7KRudkNEFokGBG3J411i117sVQ16vIeQy00hMeBnqXWQPAl/Bx0ToP8IInq+1Q9oBxtwW69tIyXWJbhPmHRaT0tkEw+DC5Mke3xm2Gqm64NK1ngtVE82zqvpQUDIeb5tkcSD/Dwr4xc2pYnCBVXRT3NkbmeR754MP5ELVLn166aB8vLodpwhT+vakG0/pApivuNBl7YK0TpS+kq1CK7T+usSGIBn5il4lFzHaXr0LyMN3Oq88PmlA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 26/38] whpx: i386: Pause VM on fatal exception to be able to inspect state Date: Sun, 19 Apr 2026 00:33:08 +0200 Message-ID: <20260418223320.51330-27-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: U9qEgvgQVm2v8uWLVRJn1DCGcJoHcmAy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX8hFRQiqC6K5m S/aE7G+3Iu+Qgb9W+VB5XciG7NkyjNbJVp8F2AFfTUp/5wOvwIEag3aUq1PDFsKaMibj6UuUs17 JFbeWOAwbZ8n9IOf9xmREXmpwN+ABucWO90Ooljvuu2Dg58wtsiD6J6qptpdt3VGRh48/fIaGuk VPBi5YR/weHbsJA2yhlcj9Teo3OLTwU4/2cNoV8AQFLSq9HSrgYBFS6JkWfJ/w6oGYCIIw4LgmF NoELQgNyGIPrsM0GjhSdGIJrtKR3bNJwEQi3DUNhPxucSIPO94IwXnW3tmQuQV3O0jmVNJAKwGh siDwy/jk7YAkbCkCMSr8UIvQyGwTTwc62Mlfgrs9J1Bbs3b4Rt/mF6jrBE3yws= X-Proofpoint-GUID: U9qEgvgQVm2v8uWLVRJn1DCGcJoHcmAy X-Authority-Info-Out: v=2.4 cv=W9M1lBWk c=1 sm=1 tr=0 ts=69e406e6 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=CGn8axfqn9I_s65QuTEA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=795 lowpriorityscore=0 clxscore=1030 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.63; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551864768158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index a7282eb96a..dee2a203b2 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2310,7 +2310,7 @@ int whpx_vcpu_run(CPUState *cpu) vcpu->exit_ctx.ExitReason); whpx_get_registers(cpu, WHPX_LEVEL_FULL_STATE); bql_lock(); - qemu_system_guest_panicked(cpu_get_crash_info(cpu)); + vm_stop(RUN_STATE_PAUSED); bql_unlock(); break; } --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551841; cv=none; d=zohomail.com; s=zohoarc; b=eA7s/CbWoJMWpAg7IuB7LUsH72+DDEztYlCjP4UJ4ADKDofj97AlOXN3yeyWFnTrWE92hR+hhCP32xQNx9Cdl1W6ncLoWDo2cHbQb9n6LsBQgpeYE/aQMYj9ncUh32mydkNCO44ja5EOu0GoghbX6kAQHa852vmbB/QK/iqGHaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551841; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MoioDyw9WNCdgAnpil2qVwmsqi0G9SAnV0FrCmNrGIk=; b=AlmCS78cD0xOrEE2JHlP+WtiA09gE/Bimg3OoL2ztI+IJFsMvv1h4DZzTrF2svmCubqntiY2ElRbXIuexgGJu+J2K5eXn17/KhU5e1y9D3tfo6YsobCyIy0/xQkLrWP9O0BP3Vf2nrD2+n8NURF6OeqoUtpRY+g6xxyL8zPTnCs= 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 1776551841422972.2139802468242; Sat, 18 Apr 2026 15:37:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFE-0007IL-7K; Sat, 18 Apr 2026 18:34:32 -0400 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 1wEEF3-0006TR-Ro for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:24 -0400 Received: from p-east2-cluster1-host6-snip4-3.eps.apple.com ([57.103.76.96] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF1-00051A-0I for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:21 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id C0AB61800233; Sat, 18 Apr 2026 22:34:14 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id A40DF18000DE; Sat, 18 Apr 2026 22:34:12 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551656; x=1779143656; bh=MoioDyw9WNCdgAnpil2qVwmsqi0G9SAnV0FrCmNrGIk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=NI3VEmUvUz7djUiMd3cwYD9n27bLbVeMX/F9UgneXD2E50UZzCAcH518vEdcGSyg9otViAW3SM5A8YnD1y1KbYruC1l8ihX0QkjrNNWqZ3pHOQN/oE5KqS+2vcbS/DMz7Y7yfh6i3ak8qQ3eBocIvZW1smN1Gjw1Ho5JJ1QJHPwBDyQUAyj2KVhXNSysTUMPiSXicqhggRd4lGShFj+fOXEY5FURPHLqxRidz58rDPxOZSHD4XQb6xP9aotSUqpCL567CO1cI6eq2W4BiUogj/wfshS5rHVmHJJ0k3YC6IHSUeRcq8zypfzzlHHEJlSrMaaexeSJs0/AkRbEkKgqvg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 27/38] target/i386: emulate: use exception_payload for fault address Date: Sun, 19 Apr 2026 00:33:09 +0200 Message-ID: <20260418223320.51330-28-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX6SKf308iUoHL ouXAclk8csGVPRazCJTzJ2zWH4Ezh0Zss4aulB7G0dZLV9I/6KLf3sJKchLLJ4+TmGWmU5W+ZBs 6vtyw9EMFAn3QL/BheU+suf96pq3nObohT6GYvALQG9Yiw7RGoGT0XQb0KCwCKUyDK42OK8X1/W m+y6+kz2ATfLW/a3k9xD7a628chvKs/qfd1RxqK4t1s2lcQGF99sZIijrX0rPqKPbdTTmqnMPY3 ASi7bf7rrsgohoEX2IQNyrQvHs+DfwwTTQLitjPizzYJ60vtFPZnFo7RsyO43uVs1WCYab1Rxvg rHAkKIZhR792Hrw1RgndvFDpsRI9kTA3VPF5O9gzpPJKpF1AuIDCyZ2IULx7Ww= X-Proofpoint-GUID: 8ht7CBbAtdti2zpb7UEFxVqnfWlYzRJ2 X-Proofpoint-ORIG-GUID: 8ht7CBbAtdti2zpb7UEFxVqnfWlYzRJ2 X-Authority-Info-Out: v=2.4 cv=JN42csKb c=1 sm=1 tr=0 ts=69e406e7 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=YcyI-53RcdBlrF1VUN8A:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 bulkscore=0 suspectscore=0 clxscore=1030 mlxlogscore=791 malwarescore=0 lowpriorityscore=0 adultscore=0 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.96; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551841820154100 Content-Type: text/plain; charset="utf-8" Instead of directly putting it in cr[2], put it in exception_payload. Signed-off-by: Mohamed Mediouni --- target/i386/emulate/x86_mmu.c | 3 ++- target/i386/whpx/whpx-all.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/target/i386/emulate/x86_mmu.c b/target/i386/emulate/x86_mmu.c index 007de582de..8d4371467f 100644 --- a/target/i386/emulate/x86_mmu.c +++ b/target/i386/emulate/x86_mmu.c @@ -277,7 +277,8 @@ static MMUTranslateResult x86_write_mem_ex(CPUState *cp= u, void *data, target_ulo translate_res =3D mmu_gva_to_gpa(cpu, gva, &gpa, translate_flags); if (translate_res) { int error_code =3D translate_res_to_error_code(translate_res, = true, is_user(cpu)); - env->cr[2] =3D gva; + env->exception_has_payload =3D 1; + env->exception_payload =3D gva; x86_emul_raise_exception(env, EXCP0E_PAGE, error_code); return translate_res; } diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index dee2a203b2..02235d5391 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1818,11 +1818,11 @@ static void whpx_inject_exceptions(CPUState* cpu) WHV_REGISTER_VALUE reg =3D {}; reg.ExceptionEvent.EventPending =3D 1; reg.ExceptionEvent.EventType =3D WHvX64PendingEventException; - reg.ExceptionEvent.DeliverErrorCode =3D 1; + reg.ExceptionEvent.DeliverErrorCode =3D env->has_error_code; reg.ExceptionEvent.Vector =3D env->exception_nr; reg.ExceptionEvent.ErrorCode =3D env->error_code; - if (env->exception_nr =3D=3D EXCP0E_PAGE) { - reg.ExceptionEvent.ExceptionParameter =3D env->cr[2]; + if (env->exception_has_payload) { + reg.ExceptionEvent.ExceptionParameter =3D env->exception_paylo= ad; } whpx_set_reg(cpu, WHvRegisterPendingEvent, reg); } --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551730; cv=none; d=zohomail.com; s=zohoarc; b=h3GdrgWg+p8zbfpJRyrIT4GSP3gPisUzeC8CknSzJ9cDwIDyoFpxznxoayRh9vcZcnZ0JLUofOaJWJS4cjPrrrAbMf0ZsgP2DNNTbO3PpUnmBQrx7cBbO+C1OMMLaZXcopjFaOaTtUrWEdPeOh+HFrerQaKgN7dop8pjfIRVEOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551730; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NjePHP/x5PK9n6m7HobdZ0wT/5aohBRW4KL4TqeRGZc=; b=oIx6KEHLoySLord7nfA5TB/aM8rIMWx3EqHiBQhOW7WbAD0MX5IS3kzQCd1aSq+yR/uFijpfeac+4RKKPm4RnzETOnhoXny25Qnqc4PeHT5KTjk2mdTjXqsHIbMWn9SCu8C0Es0mDRm0PsFkA2T+UQD/rnxxViJWI2ugJniNVfA= 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 1776551730121221.2168920507287; Sat, 18 Apr 2026 15:35:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEF9-0006nG-6f; Sat, 18 Apr 2026 18:34:27 -0400 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 1wEEF5-0006Th-Gj for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:24 -0400 Received: from p-east2-cluster1-host2-snip4-10.eps.apple.com ([57.103.76.43] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF3-000585-8d for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:23 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id EADBF1800219; Sat, 18 Apr 2026 22:34:16 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 77B7C1800231; Sat, 18 Apr 2026 22:34:14 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551660; x=1779143660; bh=NjePHP/x5PK9n6m7HobdZ0wT/5aohBRW4KL4TqeRGZc=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=M+9SXfHeDOfzww2YfTK65n88HcxX3uopnmXM8PaU0dELTKTaZ/gwsJsWzwaIUtu6SYAlKKD+j+n0Lai9Csa3MawqlT7rnOTxTWt/E8lY86VUVTuyS86ecRcayxB7ct0eDuH2DQBWh9B703HdvjDHGATpc4CprNtFqyYP/987Pb2uh35bvVQ/tkCI5ClqNCvCm7u4/mavdrlgk7jPE6Elxtvpok0tG02ajFK7fERGFnPCjRg2QjSAVbgNtzqZxQqc5uxrtgX9Kk/2ODFunmq4QxjYSdYL3klNOx0Ce6pw9D5ZJFnfDqgLejQ+49HyqQrUZp7zmsxGg7lnBjs65v/6RA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 28/38] whpx: i386: CPU features support for Windows 10 Date: Sun, 19 Apr 2026 00:33:10 +0200 Message-ID: <20260418223320.51330-29-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfX8B13bsxtV+FU GPLeKj33yK/eha2c4JOB2LjwUd71EkILMWp9KggJrvrftfbyKmDMyzNysZjz5co9K2dj2kvPUA8 RyXak8/gWpmVXXSyAYVc88FuR24vBzqgvqrNn9g+IHyWyJO7XAH1j2LSqyxvw2Yt9sj9i6GAXok s7j1egvgwGODbS0GX3F//LRGJiEf/nv6YMsZYcvlozjErAdgK46hVymTcsLAI1lIXfRwMuxz4ac rHLsVto74AFNeA350yIrrRqmfKo0n0M1EDq/BZ8MtmPPuj2F1ETPcPdJKiL6EexWObrUzaeZP4z VReykPF69IfAtmI7RKqp1G73v7yry4aG2IrHOYbIrgH6LYuwxJZe9gh5zrZK00= X-Proofpoint-GUID: f75Y3ARh1qCKeS4lx6b_l7_iifvSnYaD X-Authority-Info-Out: v=2.4 cv=WZMBqkhX c=1 sm=1 tr=0 ts=69e406ea cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=mDV3o1hIAAAA:8 a=_S2v2Z1saO19s7bx6VoA:9 X-Proofpoint-ORIG-GUID: f75Y3ARh1qCKeS4lx6b_l7_iifvSnYaD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 spamscore=0 mlxscore=0 clxscore=1030 malwarescore=0 bulkscore=0 lowpriorityscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.43; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551732610158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/cpu.c | 18 +-- target/i386/whpx/meson.build | 1 + target/i386/whpx/whpx-all.c | 38 ++++++- target/i386/whpx/whpx-cpu-legacy.c | 171 +++++++++++++++++++++++++++++ target/i386/whpx/whpx-i386.h | 7 ++ 5 files changed, 215 insertions(+), 20 deletions(-) create mode 100644 target/i386/whpx/whpx-cpu-legacy.c diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b18e40666e..8f090782bd 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -8092,9 +8092,6 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *c= pu, FeatureWord w) } else if (whpx_enabled()) { if (wi->type !=3D CPUID_FEATURE_WORD) { return 0; - } - if (whpx_is_legacy_os()) { - r =3D wi->tcg_features; } else { r =3D whpx_get_supported_cpuid(wi->cpuid.eax, wi->cpuid.ecx, @@ -8182,17 +8179,10 @@ static void x86_cpu_get_supported_cpuid(uint32_t fu= nc, uint32_t index, *ecx =3D hvf_get_supported_cpuid(func, index, R_ECX); *edx =3D hvf_get_supported_cpuid(func, index, R_EDX); } else if (whpx_enabled()) { - if (whpx_is_legacy_os()) { - *eax =3D 0; - *ebx =3D 0; - *ecx =3D 0; - *edx =3D 0; - } else { - *eax =3D whpx_get_supported_cpuid(func, index, R_EAX); - *ebx =3D whpx_get_supported_cpuid(func, index, R_EBX); - *ecx =3D whpx_get_supported_cpuid(func, index, R_ECX); - *edx =3D whpx_get_supported_cpuid(func, index, R_EDX); - } + *eax =3D whpx_get_supported_cpuid(func, index, R_EAX); + *ebx =3D whpx_get_supported_cpuid(func, index, R_EBX); + *ecx =3D whpx_get_supported_cpuid(func, index, R_ECX); + *edx =3D whpx_get_supported_cpuid(func, index, R_EDX); } else { *eax =3D 0; *ebx =3D 0; diff --git a/target/i386/whpx/meson.build b/target/i386/whpx/meson.build index c3aaaff9fd..1c6a4ce377 100644 --- a/target/i386/whpx/meson.build +++ b/target/i386/whpx/meson.build @@ -1,4 +1,5 @@ i386_system_ss.add(when: 'CONFIG_WHPX', if_true: files( 'whpx-all.c', 'whpx-apic.c', + 'whpx-cpu-legacy.c' )) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 02235d5391..9b48ef2914 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -270,11 +270,30 @@ typedef enum WhpxStepMode { static uint32_t max_vcpu_index; static WHV_PROCESSOR_XSAVE_FEATURES whpx_xsave_cap; =20 -static bool whpx_has_xsave(void) +bool whpx_has_xsave(void) { return whpx_xsave_cap.XsaveSupport; } =20 +bool whpx_has_xsaves(void) +{ + return whpx_xsave_cap.XsaveSupervisorSupport; +} + +static bool whpx_rdtsc_cap; + +bool whpx_has_rdtscp(void) +{ + return whpx_rdtsc_cap; +} + +static bool whpx_invpcid_cap; + +bool whpx_has_invpcid(void) +{ + return whpx_invpcid_cap; +} + static WHV_X64_SEGMENT_REGISTER whpx_seg_q2h(const SegmentCache *qs, int v= 86, int r86) { @@ -1057,6 +1076,11 @@ uint32_t whpx_get_supported_cpuid(uint32_t func, uin= t32_t idx, int reg) bool temp_cpu =3D true; HRESULT hr; =20 + /* Legacy OSes don't have WHvGetVirtualProcessorCpuidOutput */ + if (whpx_is_legacy_os()) { + return whpx_get_supported_cpuid_legacy(func, idx, reg); + } + hr =3D whp_dispatch.WHvCreateVirtualProcessor( whpx_global.partition, cpu_index, 0); =20 @@ -2147,7 +2171,7 @@ int whpx_vcpu_run(CPUState *cpu) * just pass through what the hypervisor * provides without any QEMU filtering. */ - if (whpx_is_legacy_os() || xcc->max_features) { + if (xcc->max_features) { reg_values[1].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRax; reg_values[2].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRcx; reg_values[3].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Default= ResultRdx; @@ -2507,11 +2531,11 @@ void whpx_cpu_instance_init(CPUState *cs) host_cpu_instance_init(cpu); x86_cpu_apply_props(cpu, whpx_default_props); =20 - if (!whpx_is_legacy_os() && xcc->max_features) { + if (xcc->max_features) { whpx_cpu_max_instance_init(cpu); } =20 - if (!whpx_is_legacy_os()) { + if (whpx_has_xsave()) { whpx_cpu_xsave_init(); } } @@ -2536,7 +2560,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms) 0x40000000, 0x40000001, 0x40000010, 0x80000000, 0x80000001, 0x80000002, 0x80000003, 0x80000004, 0x80000007, 0x80000008, 0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001}; - UINT32 cpuidExitList_legacy_os[] =3D {1, 0x40000000, 0x40000001, 0x400= 00010}; =20 X86MachineState *x86ms =3D X86_MACHINE(ms); bool pic_enabled =3D false; @@ -2700,6 +2723,9 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 + whpx_rdtsc_cap =3D processor_features.Bank0.RdtscpSupport; + whpx_invpcid_cap =3D processor_features.Bank0.InvpcidSupport; +=20 if (whpx_irqchip_in_kernel() && processor_features.Bank1.NestedVirtSup= port) { memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); prop.NestedVirtualization =3D 1; @@ -2808,7 +2834,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, WHvPartitionPropertyCodeCpuidExitList, - !whpx_is_legacy_os() ? cpuidExitList : cpuidExitList_legacy_os, + cpuidExitList, RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32)); =20 if (FAILED(hr)) { diff --git a/target/i386/whpx/whpx-cpu-legacy.c b/target/i386/whpx/whpx-cpu= -legacy.c new file mode 100644 index 0000000000..477429b460 --- /dev/null +++ b/target/i386/whpx/whpx-cpu-legacy.c @@ -0,0 +1,171 @@ +/* + * i386 CPUID helper functions + * + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2017 Google Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, see . + * + * cpuid + */ + +#include "qemu/osdep.h" +#include "qemu/cpuid.h" +#include "host/cpuinfo.h" +#include "cpu.h" +#include "emulate/x86.h" +#include "whpx-i386.h" + +static bool cached_xcr0; +static uint64_t supported_xcr0; + +static void cache_host_xcr0(void) +{ + if (cached_xcr0) { + return; + } + + if (whpx_has_xsave()) { + uint64_t host_xcr0 =3D xgetbv_low(0); + + /* Only show xcr0 bits corresponding to usable features. */ + supported_xcr0 =3D host_xcr0 & (XSTATE_FP_MASK | + XSTATE_SSE_MASK | XSTATE_YMM_MASK | + XSTATE_OPMASK_MASK | XSTATE_ZMM_Hi25= 6_MASK | + XSTATE_Hi16_ZMM_MASK); + if ((supported_xcr0 & (XSTATE_FP_MASK | XSTATE_SSE_MASK)) !=3D + (XSTATE_FP_MASK | XSTATE_SSE_MASK)) { + supported_xcr0 =3D 0; + } + } + + cached_xcr0 =3D true; +} + +uint32_t whpx_get_supported_cpuid_legacy(uint32_t func, uint32_t idx, + int reg) +{ + uint32_t eax, ebx, ecx, edx; + + cache_host_xcr0(); + host_cpuid(func, idx, &eax, &ebx, &ecx, &edx); + + switch (func) { + case 0: + eax =3D eax < (uint32_t)0xd ? eax : (uint32_t)0xd; + break; + case 1: + edx &=3D CPUID_FP87 | CPUID_VME | CPUID_DE | CPUID_PSE | CPUID_TSC= | + CPUID_MSR | CPUID_PAE | CPUID_MCE | CPUID_CX8 | CPUID_APIC | + CPUID_SEP | CPUID_MTRR | CPUID_PGE | CPUID_MCA | CPUID_CMOV | + CPUID_PAT | CPUID_PSE36 | CPUID_CLFLUSH | CPUID_MMX | + CPUID_FXSR | CPUID_SSE | CPUID_SSE2 | CPUID_SS | CPUID_HT; + ecx &=3D CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSSE3 | + CPUID_EXT_FMA | CPUID_EXT_CX16 | CPUID_EXT_PCID | + CPUID_EXT_SSE41 | CPUID_EXT_SSE42 | CPUID_EXT_MOVBE | + CPUID_EXT_POPCNT | CPUID_EXT_AES | + (supported_xcr0 ? CPUID_EXT_XSAVE : 0) | + CPUID_EXT_AVX | CPUID_EXT_F16C | CPUID_EXT_RDRAND; + ecx |=3D CPUID_EXT_HYPERVISOR; + ecx |=3D CPUID_EXT_X2APIC; + edx |=3D CPUID_HT; + break; + case 6: + eax =3D CPUID_6_EAX_ARAT; + ebx =3D 0; + ecx =3D 0; + edx =3D 0; + break; + case 7: + if (idx =3D=3D 0) { + ebx &=3D CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | + CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | + CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | + CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_RTM | + CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | + CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_AVX512IFMA | + CPUID_7_0_EBX_AVX512F | CPUID_7_0_EBX_AVX512PF | + CPUID_7_0_EBX_AVX512ER | CPUID_7_0_EBX_AVX512CD | + CPUID_7_0_EBX_CLFLUSHOPT | CPUID_7_0_EBX_CLWB | + CPUID_7_0_EBX_AVX512DQ | CPUID_7_0_EBX_SHA_NI | + CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512VL | + CPUID_7_0_EBX_INVPCID; + + if (!whpx_has_invpcid()) { + ebx &=3D ~CPUID_7_0_EBX_INVPCID; + } + + ecx &=3D CPUID_7_0_ECX_AVX512_VBMI | CPUID_7_0_ECX_AVX512_VPOP= CNTDQ | + CPUID_7_0_ECX_RDPID; + edx &=3D CPUID_7_0_EDX_AVX512_4VNNIW | CPUID_7_0_EDX_AVX512_4F= MAPS; + } else { + ebx =3D 0; + ecx =3D 0; + edx =3D 0; + } + eax =3D 0; + break; + case 0xD: + if (!supported_xcr0 || idx >=3D 63 || + (idx > 1 && !(supported_xcr0 & (UINT64_C(1) << idx)))) { + eax =3D ebx =3D ecx =3D edx =3D 0; + break; + } + + if (idx =3D=3D 0) { + eax =3D supported_xcr0; + } else if (idx =3D=3D 1) { + eax &=3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XGETBV1; + if (!whpx_has_xsaves()) { + eax &=3D ~CPUID_XSAVE_XSAVES; + } + } + break; + case 0x80000001: + /* LM only if HVF in 64-bit mode */ + edx &=3D CPUID_FP87 | CPUID_VME | CPUID_DE | CPUID_PSE | CPUID_TSC= | + CPUID_MSR | CPUID_PAE | CPUID_MCE | CPUID_CX8 | CPUID_APIC= | + CPUID_EXT2_SYSCALL | CPUID_MTRR | CPUID_PGE | CPUID_MCA | = CPUID_CMOV | + CPUID_PAT | CPUID_PSE36 | CPUID_EXT2_MMXEXT | CPUID_MMX | + CPUID_FXSR | CPUID_EXT2_FXSR | CPUID_EXT2_PDPE1GB | CPUID_= EXT2_3DNOWEXT | + CPUID_EXT2_3DNOW | CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPU= ID_EXT2_NX; + if (!(whpx_has_rdtscp())) { + edx &=3D ~CPUID_EXT2_RDTSCP; + } + ecx &=3D CPUID_EXT3_LAHF_LM | CPUID_EXT3_CMP_LEG | CPUID_EXT3_CR8L= EG | + CPUID_EXT3_ABM | CPUID_EXT3_SSE4A | CPUID_EXT3_MISALIGNSSE= | + CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_OSVW | CPUID_EXT3_XO= P | + CPUID_EXT3_FMA4 | CPUID_EXT3_TBM; + break; + case 0x80000007: + edx &=3D CPUID_APM_INVTSC; + eax =3D ebx =3D ecx =3D 0; + break; + default: + return 0; + } + + switch (reg) { + case R_EAX: + return eax; + case R_EBX: + return ebx; + case R_ECX: + return ecx; + case R_EDX: + return edx; + default: + return 0; + } +} diff --git a/target/i386/whpx/whpx-i386.h b/target/i386/whpx/whpx-i386.h index 6db9a75d39..9dc6837574 100644 --- a/target/i386/whpx/whpx-i386.h +++ b/target/i386/whpx/whpx-i386.h @@ -2,3 +2,10 @@ =20 uint32_t whpx_get_supported_cpuid(uint32_t func, uint32_t idx, int reg); bool whpx_is_legacy_os(void); + +uint32_t whpx_get_supported_cpuid_legacy(uint32_t func, uint32_t idx, + int reg); +bool whpx_has_xsave(void); +bool whpx_has_xsaves(void); +bool whpx_has_rdtscp(void); +bool whpx_has_invpcid(void); --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551814; cv=none; d=zohomail.com; s=zohoarc; b=L0/3LsbrJwKmd9ePStj0zBLqCxT1Sfee8VeVfFkmyyW0Ht5yD4D+83Rt6tt27fKRn8DrMndk7wYcj5IALdM4HLF9YnpdS9QSIfQjoFUosb7p9WbkWn9Ia3DfxuQDk1lTgxtGSibV5If9VMappSV+iRAl9L3ZGkIAGcSYBFsO+7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551814; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nflalHNpsd+cwF/uF35esRRPVFTNfgzM4VSaQ5bZG+E=; b=esGSEw2YNP3brry1bvN5ep+iVcr9nUWyaC3TGXCJsrpK/KH2gHrxBEMoA8FofpBT5qiuUZB6EZFiGq03/8TJlS7Hjg7TqgfiFSwHi8V2QEdwzvU+EqL+BUIIPIgyCOA9pBGkK63sngqfcFk2oeL0LhtP8f9SbmCHouMoNZOVens= 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 1776551814869546.2601518554205; Sat, 18 Apr 2026 15:36:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFE-0007HV-6B; Sat, 18 Apr 2026 18:34:32 -0400 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 1wEEF7-0006Xi-2A for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:25 -0400 Received: from p-east2-cluster1-host9-snip4-9.eps.apple.com ([57.103.76.112] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF5-0005Bm-GQ for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:24 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id EB30418000AA; Sat, 18 Apr 2026 22:34:18 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 4F61818000DE; Sat, 18 Apr 2026 22:34:16 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551662; x=1779143662; bh=nflalHNpsd+cwF/uF35esRRPVFTNfgzM4VSaQ5bZG+E=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=aFpJkBZuwzC6z3madhJ/bixatLHz207Fx+ckUwdqsP4T7UggdsCjs7OQan0KJjb9CBJQDqF23uqGUqGuZ7KSslIboEfRAnaWTinyKS/+iJV6S+Siy+pgyIwt0kLT5iwH/I6VIZ6+ZjBesVO8opE1NfPoojReKf3FpsBwaB0sOJRwbiGPMm1V4KJM3Va6XARmpR6mTHAc7g+faS/sCIHq8gk2KxHFs0tpN95oxHBSxa+yUSXUNHulU2k1xDMy/RjEp8gWEu/+RIrmyjzixntlIs/xn99EESQvQljt/Vq8Uk5aqHHlfFXyCKmcEQQ4x4eldg7ckKlrGEJaGKc0kriMPQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 29/38] target/i386: make xsave_buf present unconditionally Date: Sun, 19 Apr 2026 00:33:11 +0200 Message-ID: <20260418223320.51330-30-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: yLiIeA2uDg1T-Aq9fbq_G9yDw4pnTHJP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfXygUo6bQHEO37 EgQK7OhUUdGrPBpP9iAnLhPp5jOUMl4Mn7NzBROz40+K89Ynk/vZ+t4AvCcZmdmw+xOuwvP2BKs UsLAuyoof4utrCaHtS0o/LgLv+lNxIvzBhv046KCzKDeHH5iNjFX6C7zG7eNgqWuqDw1TNdGZ3k BS5HqWN5U+LXaUb2b+jRGJ9Pn8FWi/ULy+hX0HbYeTMH5GEXEc01GlzWZ+s9W6uQQt/W6mqx52M cwWI0Nq/JxGFldvcL/JYoVFFXQ+IFaFE0hxhiWY7JLrFxtAMhkw4R80P2XUE0gr9+9nSJdm6C0D sGqPR8GToUacc02ff4QbVUpSeO4etKZrCsBL/cCcGz+N7og4Px8QWXGNtEMMwQ= X-Authority-Info-Out: v=2.4 cv=QPllhwLL c=1 sm=1 tr=0 ts=69e406ec cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EWkIHKX3_8ZzwOJz1Y8A:9 X-Proofpoint-GUID: yLiIeA2uDg1T-Aq9fbq_G9yDw4pnTHJP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 phishscore=0 clxscore=1030 mlxlogscore=872 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.112; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551816991158500 Content-Type: text/plain; charset="utf-8" This is necessary for the xsave_helper helpers to compile. Signed-off-by: Mohamed Mediouni --- target/i386/cpu.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 67f508dc10..0af7bdf85a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2269,10 +2269,8 @@ typedef struct CPUArchState { int64_t user_tsc_khz; /* for sanity check only */ uint64_t apic_bus_freq; uint64_t tsc; -#if defined(CONFIG_KVM) || defined(CONFIG_HVF) void *xsave_buf; uint32_t xsave_buf_len; -#endif #if defined(CONFIG_KVM) struct kvm_nested_state *nested_state; MemoryRegion *xen_vcpu_info_mr; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551749; cv=none; d=zohomail.com; s=zohoarc; b=lNwzK3rCZjjp6oqNDlrj0q16vAhooeavA3p9jV+DyMcVzz5L3GGgm/u2OuAioNGF0pSJfouzACG4ZBx3wMnx/jfH3dOK6cZ2NG9Scd107ZNlmKgd9eP2cJY3wpCzGCdwaI5H5lptwNP1CU0IcHMxVhewD93/FRQ92NBlVk1MVm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551749; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=maUs5hD4ZFBbp6kUsVKDGtuJCsMxM+d+qMlkC+QlVLE=; b=XaBhvbjN6iSSb+eLjlO4EOKwCyD2qK+3ZkcIUr85umLQPyfZ5HUNyPYJL2jvqnrGHcMivmJm7Nv4KMDzDoxUMHUEztm/RXIi3YkCXLVPTDweeudaRMm07WxC2kByrqj7TGDf+/x8hQwJaa0Cz1QfRPz4g+OjbrrJIkdDxJJl7y0= 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 1776551749123342.8631507137394; Sat, 18 Apr 2026 15:35:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFB-00070k-Du; Sat, 18 Apr 2026 18:34:29 -0400 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 1wEEF6-0006WN-T0 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:24 -0400 Received: from p-east2-cluster1-host10-snip4-1.eps.apple.com ([57.103.76.114] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF4-0005BP-IK for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:24 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 6975B1800222; Sat, 18 Apr 2026 22:34:20 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 2BC9518000B4; Sat, 18 Apr 2026 22:34:18 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551661; x=1779143661; bh=maUs5hD4ZFBbp6kUsVKDGtuJCsMxM+d+qMlkC+QlVLE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=NThp5/HYoPDyUOJT3+ubBKmikHFhn43XdztoQp5jHgVEq2SVtw9Bkua2pwWDX2Kcvy8QTgb/bYV/0V8JrY9byFJA93fo/2GdJ5wwd6d+FfwHirXuSLhM9SGA+VEryEdJYrr7Vjbo3Ko6PXJhbXWXdyVzMISMFVUECWzJIl5MpvmtQTTLaXuOa2E0SU26aZW0ASW3NdSON0jhtAIamdbGCZ8ZVNOIEOV7me5XlVPn48ykF+R7EI2x9FZzeGp/QJ/oN8NxEvuZKkljX+6/fXs4UXHB7kzONQooB8W/CXTHEbpHHYfBVQfYhrzD89brnYfCoqKPAF4+4/NyvTqiAlUIWA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan , Magnus Kulke Subject: [PATCH 30/38] target/i386: add de/compaction to xsave_helper Date: Sun, 19 Apr 2026 00:33:12 +0200 Message-ID: <20260418223320.51330-31-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: ZC1NUv8wdYkPaY7XBHCPs_XS3CO1jRl_ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfXzyvk5gwfIOGr X7+PW1/h6lTDlQ54kXhfCxo/3EXY0NcZxHCa+TQN3RJQkCFi+hQKDZWTT+9QOD7C9WTlcOGXTXe ChaI3aHf026ab5H70y3aMdFYdNfpCnKcfA5NjVuY1bTkxs5ckbzPQZ4TwsniZWEoOdaRicYOZYU sG383F9rv5FgH9S0KnRnqizsdD4HcylBXKGLxHKghPwuURGQO1vHq82ViPpknv9ZupNnvmlo7fG YUkSoaCVunOJQbzt1lNVFUt7ApmhwWfCN+leunIMoBhDaCDiq1M2I1ko/BtK/ctU0xXMnsWCxbB hJ9R15W3feZJs/ig2wRj5uG4RAvquGGGSnEZHrw4KZZzVpy/uQw3zXLqY+BPfA= X-Authority-Info-Out: v=2.4 cv=QPllhwLL c=1 sm=1 tr=0 ts=69e406ed cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=yMhMjlubAAAA:8 a=SWS4GvfA19jorXXodEoA:9 X-Proofpoint-GUID: ZC1NUv8wdYkPaY7XBHCPs_XS3CO1jRl_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 phishscore=0 clxscore=1030 mlxlogscore=999 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.114; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551750847158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke HyperV use XSAVES which stores extended state in compacted format in which components are packed contiguously, while QEMU's internal XSAVE representation use the standard format in which each component is places at a fixed offset. Hence for this purpose we add two conversion fn's to the xsave helper to roundtrip XSAVE state in a migration. - decompact_xsave_area(): converts compacted format to standard. XSTATE_BV is masked to host XCR0 since IA32_XSS is managed by the hypervisor. - compact_xsave_area(): converts standard format back to compacted format. XCOMP_BV is set from the host's CPUID 0xD.0 rather than the guest's XCR0, as this is what the hypervisor expects. Both functions use the host's CPUID leaf 0xD subleaves to determine compone= nt sizes, offsets, and alignment requirements. There are situations when the host advertises features that we want to disable for the guest, e.g. AMX TILE. In this case we cannot rely on the host's xcr0, but instead we use the feature mask that has been generated in as part of the CPU realization process (x86_cpu_expand_features). Signed-off-by: Magnus Kulke Reviewed-by: Mohamed Mediouni --- target/i386/cpu.h | 2 + target/i386/xsave_helper.c | 255 +++++++++++++++++++++++++++++++++++++ 2 files changed, 257 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0af7bdf85a..80cdc1cb2a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -3023,6 +3023,8 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void= *buf, uint32_t buflen); void x86_cpu_xsave_all_areas(X86CPU *cpu, void *buf, uint32_t buflen); uint32_t xsave_area_size(uint64_t mask, bool compacted); void x86_update_hflags(CPUX86State* env); +int decompact_xsave_area(const void *buf, size_t buflen, CPUX86State *env); +int compact_xsave_area(CPUX86State *env, void *buf, size_t buflen); =20 static inline bool hyperv_feat_enabled(X86CPU *cpu, int feat) { diff --git a/target/i386/xsave_helper.c b/target/i386/xsave_helper.c index bab2258732..2272b83f5f 100644 --- a/target/i386/xsave_helper.c +++ b/target/i386/xsave_helper.c @@ -3,6 +3,7 @@ * See the COPYING file in the top-level directory. */ #include "qemu/osdep.h" +#include "qemu/error-report.h" =20 #include "cpu.h" =20 @@ -293,3 +294,257 @@ void x86_cpu_xrstor_all_areas(X86CPU *cpu, const void= *buf, uint32_t buflen) } #endif } + +#define XSTATE_BV_IN_HDR offsetof(X86XSaveHeader, xstate_bv) +#define XCOMP_BV_IN_HDR offsetof(X86XSaveHeader, xcomp_bvo) + +typedef struct X86XSaveAreaView { + /* 512 bytes */ + X86LegacyXSaveArea legacy; + /* 64 bytes */ + X86XSaveHeader header; + /* ...followed by individual xsave areas */ +} X86XSaveAreaView; + +#define XSAVE_XSTATE_BV_OFFSET offsetof(X86XSaveAreaView, header.xstate_b= v) +#define XSAVE_XCOMP_BV_OFFSET offsetof(X86XSaveAreaView, header.xcomp_bv) +#define XSAVE_EXT_OFFSET (sizeof(X86LegacyXSaveArea) + \ + sizeof(X86XSaveHeader)) + +/** + * decompact_xsave_area - Convert compacted XSAVE format to standard format + * @buf: Source buffer containing compacted XSAVE data + * @buflen: Size of source buffer + * @env: CPU state where the standard format buffer will be written to + * + * Accelerator backends like MSHV might return XSAVE state in compacted fo= rmat + * (XSAVEC). The state components have to be packed contiguously without g= aps. + * The XSAVE qemu buffers are in standard format where each component has a + * fixed offset. + * + * Returns: 0 on success, negative errno on failure + */ +int decompact_xsave_area(const void *buf, size_t buflen, CPUX86State *env) +{ + uint64_t compacted_xstate_bv, compacted_xcomp_bv, compacted_layout_bv; + uint64_t xsave_offset, *xcomp_bv; + size_t i; + uint32_t eax, ebx, ecx, edx; + uint32_t size, dst_off; + bool align64; + uint64_t guest_xcr0, *xstate_bv; + + compacted_xstate_bv =3D *(uint64_t *)(buf + XSAVE_XSTATE_BV_OFFSET); + compacted_xcomp_bv =3D *(uint64_t *)(buf + XSAVE_XCOMP_BV_OFFSET); + + /* This function only handles compacted format (bit 63 set) */ + assert((compacted_xcomp_bv >> 63) & 1); + + /* Low bits of XCOMP_BV describe which components are in the layout */ + compacted_layout_bv =3D compacted_xcomp_bv & ~(1ULL << 63); + + /* Zero out buffer, then copy legacy region (FP + SSE) and header as-i= s */ + memset(env->xsave_buf, 0, env->xsave_buf_len); + memcpy(env->xsave_buf, buf, XSAVE_EXT_OFFSET); + + /* + * We mask XSTATE_BV with the guest's supported XCR0 because: + * 1. Supervisor state (IA32_XSS) is hypervisor-managed, we don't use + * this state for migration. + * 2. Features disabled at partition creation (e.g. AMX) must be exclu= ded + */ + guest_xcr0 =3D ((uint64_t)env->features[FEAT_XSAVE_XCR0_HI] << 32) | + env->features[FEAT_XSAVE_XCR0_LO]; + xstate_bv =3D (uint64_t *)(env->xsave_buf + XSAVE_XSTATE_BV_OFFSET); + *xstate_bv &=3D guest_xcr0; + + /* Clear bit 63 - output is standard format, not compacted */ + xcomp_bv =3D (uint64_t *)(env->xsave_buf + XSAVE_XCOMP_BV_OFFSET); + *xcomp_bv =3D *xcomp_bv & ~(1ULL << 63); + + /* + * Process each extended state component in the compacted layout. + * Components 0 and 1 (FP and SSE) are in the legacy region, so we + * start at component 2. For each component: + * - Calculate its offset in the compacted source (contiguous layout) + * - Get its fixed offset in the standard destination from CPUID + * - Copy if the component has non-init state (bit set in XSTATE_BV) + */ + xsave_offset =3D XSAVE_EXT_OFFSET; + for (i =3D 2; i < 63; i++) { + if (((compacted_layout_bv >> i) & 1) =3D=3D 0) { + continue; + } + + /* Query guest CPUID for this component's size and standard offset= */ + cpu_x86_cpuid(env, 0xD, i, &eax, &ebx, &ecx, &edx); + + size =3D eax; + dst_off =3D ebx; + align64 =3D (ecx & (1u << 1)) !=3D 0; + + /* Component is in the layout but unknown to the guest CPUID model= */ + if (size =3D=3D 0) { + /* + * The hypervisor might expose a component that has no + * representation in the guest CPUID model. We query the host = to + * retrieve the size of the component, so we can skip over it. + */ + host_cpuid(0xD, i, &eax, &ebx, &ecx, &edx); + size =3D eax; + align64 =3D (ecx & (1u << 1)) !=3D 0; + if (size =3D=3D 0) { + error_report("xsave component %zu: size unknown to both " + "guest and host CPUID", i); + return -EINVAL; + } + + if (align64) { + xsave_offset =3D QEMU_ALIGN_UP(xsave_offset, 64); + } + + if (xsave_offset + size > buflen) { + error_report("xsave component %zu overruns source buffer: " + "offset=3D%zu size=3D%u buflen=3D%zu", + i, xsave_offset, size, buflen); + return -E2BIG; + } + + xsave_offset +=3D size; + continue; + } + + if (align64) { + xsave_offset =3D QEMU_ALIGN_UP(xsave_offset, 64); + } + + if ((xsave_offset + size) > buflen) { + error_report("xsave component %zu overruns source buffer: " + "offset=3D%zu size=3D%u buflen=3D%zu", + i, xsave_offset, size, buflen); + return -E2BIG; + } + + if ((dst_off + size) > env->xsave_buf_len) { + error_report("xsave component %zu overruns destination buffer:= " + "offset=3D%u size=3D%u buflen=3D%zu", + i, dst_off, size, (size_t)env->xsave_buf_len); + return -E2BIG; + } + + /* Copy components marked present in XSTATE_BV to guest model */ + if (((compacted_xstate_bv >> i) & 1) !=3D 0) { + memcpy(env->xsave_buf + dst_off, buf + xsave_offset, size); + } + + xsave_offset +=3D size; + } + + return 0; +} + +/** + * compact_xsave_area - Convert standard XSAVE format to compacted format + * @env: CPU state containing the standard format XSAVE buffer + * @buf: Destination buffer for compacted XSAVE data (to send to hyperviso= r) + * @buflen: Size of destination buffer + * + * Accelerator backends like MSHV might expect XSAVE state in compacted fo= rmat + * (XSAVEC). The state components are packed contiguously without gaps. + * The XSAVE qemu buffers are in standard format where each component has a + * fixed offset. + * + * This function converts from standard to compacted format, it accepts a + * pre-allocated destination buffer of sufficient size, it is the + * responsibility of the caller to ensure the buffer is big enough. + * + * Returns: total size of compacted XSAVE data written to @buf + */ +int compact_xsave_area(CPUX86State *env, void *buf, size_t buflen) +{ + uint64_t *xcomp_bv; + size_t i; + uint32_t eax, ebx, ecx, edx; + uint32_t size, src_off; + bool align64; + size_t compact_offset; + uint64_t host_xcr0_mask, guest_xcr0; + + /* Zero out buffer, then copy legacy region (FP + SSE) and header as-i= s */ + memset(buf, 0, buflen); + memcpy(buf, env->xsave_buf, XSAVE_EXT_OFFSET); + + /* + * Set XCOMP_BV to indicate compacted format (bit 63) and which + * components are in the layout. + * + * We must explicitly set XCOMP_BV because x86_cpu_xsave_all_areas() + * produces standard format with XCOMP_BV=3D0 (buffer is zeroed and on= ly + * XSTATE_BV is set in the header). + * + * XCOMP_BV must reflect the partition's XSAVE capability, not the + * guest's current XCR0 (env->xcr0). These differ b/c: + * - A guest's XCR0 is what the guest OS has enabled via XSETBV + * - The partition's XCR0 mask is the hypervisor's save/restore capabi= lity + * + * The hypervisor uses XSAVES which saves based on its capability, so = the + * XCOMP_BV value in the buffer we send back must match that capabilit= y. + * + * We intersect the host XCR0 with the guest's supported XCR0 features + * (FEAT_XSAVE_XCR0_*) so that features disabled at partition creation + * (e.g. AMX) are excluded from the compacted layout. + */ + host_cpuid(0xD, 0, &eax, &ebx, &ecx, &edx); + host_xcr0_mask =3D ((uint64_t)edx << 32) | eax; + guest_xcr0 =3D ((uint64_t)env->features[FEAT_XSAVE_XCR0_HI] << 32) | + env->features[FEAT_XSAVE_XCR0_LO]; + host_xcr0_mask &=3D guest_xcr0; + xcomp_bv =3D buf + XSAVE_XCOMP_BV_OFFSET; + *xcomp_bv =3D host_xcr0_mask | (1ULL << 63); + + /* + * Process each extended state component in the host's XCR0. + * The compacted layout must match XCOMP_BV (host capability). + * + * For each component: + * - Get its size and standard offset from host CPUID + * - Apply 64-byte alignment if required + * - Copy data only if guest has this component (bit set in env->xcr0) + * - Always advance offset to maintain correct layout + */ + compact_offset =3D XSAVE_EXT_OFFSET; + for (i =3D 2; i < 63; i++) { + if (!((host_xcr0_mask >> i) & 1)) { + continue; + } + + /* Query host CPUID for this component's size and standard offset = */ + host_cpuid(0xD, i, &eax, &ebx, &ecx, &edx); + size =3D eax; + src_off =3D ebx; + align64 =3D (ecx >> 1) & 1; + + if (size =3D=3D 0) { + /* Component in host xcr0 but unknown - shouldn't happen */ + continue; + } + + /* Apply 64-byte alignment if required by this component */ + if (align64) { + compact_offset =3D QEMU_ALIGN_UP(compact_offset, 64); + } + + /* + * Only copy data if guest has this component enabled in XCR0. + * Otherwise the component remains zeroed (init state), but we + * still advance the offset to maintain the correct layout. + */ + if ((env->xcr0 >> i) & 1) { + memcpy(buf + compact_offset, env->xsave_buf + src_off, size); + } + + compact_offset +=3D size; + } + + return compact_offset; +} --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551885; cv=none; d=zohomail.com; s=zohoarc; b=QWQTSxFgQWdXYg1jCUoNierprmXpKk4SG2YmE7KhlWw8wRHIY8E4xZPH8Tl4t8V38/Gc/jKdv1ewfBdnlOh92sLwAoiZsj5xhxQvJCoTZrxhK1ho1H8x8jRTmMWFautp3NN0GvG/KUwUDGMZJVWd3ij0loRlJv58v8RA8fNxswI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551885; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NU6vB4RQLvZwUhI2aX1+Ev3JneiodRGuRMbbnDBdfJc=; b=Q3rgBthP6q2NcXmN8tSpoh9SZoKI/5xt1MvVJZOGustqlI9KbHzWUDsn4tK+M09Xqg6K4Z2gCBuXPn7Xx1wrHP04PeSEBtgXhX6AWAb9nzzwIxkehy/CUYhuPRW4rEDspZnHynRqbTByUMWrcIMCylNo4dV9ajhkIQBa3wW8ITg= 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 1776551885884691.6969026509335; Sat, 18 Apr 2026 15:38:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFH-0007c3-3y; Sat, 18 Apr 2026 18:34:35 -0400 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 1wEEFC-0007AY-Vs for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:31 -0400 Received: from p-east2-cluster1-host5-snip4-10.eps.apple.com ([57.103.76.93] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF9-0005D7-Fb for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:30 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 9C72518000B2; Sat, 18 Apr 2026 22:34:22 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 13EED18000C4; Sat, 18 Apr 2026 22:34:19 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551666; x=1779143666; bh=NU6vB4RQLvZwUhI2aX1+Ev3JneiodRGuRMbbnDBdfJc=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=LXTGnazi4iAKXrP6C/KRd+sOXlLiuWeD9GZ2Pki80yRQ1et1aHxpqgB+0B+JSzhBvowj38y1YXKtyvPQDCsK0bRtlq6M1EWWGIeAR2k25KjBufLuKPYIymJX/HXm412SckI4DMkoSfMIhNOZ6ONUNbTVN3LCYxrx63dtADMINEmBdbx8Qqsdq/pwuiV5vJO3eFKin5yEW8f5GiSNPLVlJzn+Yr3kZr+TqKNbO9u+RSk/9Ne6D9GQ+dURf0ZpBn2oCOEunkmOGg79MI1TgnsuTBgR50flGga2Rf+qjSk5bC1+/ztzonr+bpU12A+zHmA+VKEXzSGUGzJZ0vPwwYvj9w== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 31/38] whpx: xsave support Date: Sun, 19 Apr 2026 00:33:13 +0200 Message-ID: <20260418223320.51330-32-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: P7jNGpFk84r_8dJ9MCh6QF5hFR9Yeasb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOCBTYWx0ZWRfXy7I4Xx7onuJm Mvx7YfNCRXb/8+5C3x+450N+OPG1S7DlPV1qpn3p4rePaQZ9NsIfZvPDPY6mgx4kaatSGB6OMGm Fudgbk+2+U2UUwkytjU43wQO7r0jHiRqNj8TZP0+yGeOe0dRUAFGzSaXXnooB7/wIx9CpxfWMGi Fd2La1SMdUiL3EYcOVaahDeHmvCjQ05MWCzI//j5m5RImtRHmZD7lqbTB3Cim0evSAq0Ee9zVP8 FlMPDP3SkegHh2r5rcPIyzeKMwpx2Yd91lfIkTXa5RTG2hfp9V0e70jFbCAISZWglYRwNg59bdA 0NGN1OwpSRSDmMJII1vGWEFAyrg1nqCgqT5EJZxKT/eGpzlZrKP0alTTYN522M= X-Proofpoint-ORIG-GUID: P7jNGpFk84r_8dJ9MCh6QF5hFR9Yeasb X-Authority-Info-Out: v=2.4 cv=T9mBjvKQ c=1 sm=1 tr=0 ts=69e406f0 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=pIzSZyhXsI4QXQPOM_AA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxlogscore=999 clxscore=1030 lowpriorityscore=0 phishscore=0 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180228 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=57.103.76.93; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551887265158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- include/system/whpx-internal.h | 16 ++ target/i386/whpx/whpx-all.c | 378 ++++++++++++++++++++++++--------- 2 files changed, 291 insertions(+), 103 deletions(-) diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index 86639627b3..0aae83bd7c 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -99,6 +99,22 @@ void whpx_apic_get(APICCommonState *s); UINT32 StateSize)) \ X(HRESULT, WHvResetPartition, \ (WHV_PARTITION_HANDLE Partition)) \ + X(HRESULT, WHvGetVirtualProcessorXsaveState, \ + (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, \ + PVOID Buffer, \ + UINT32 BufferSizeInBytes, UINT32 *BytesWritten)) \ + X(HRESULT, WHvSetVirtualProcessorXsaveState, \ + (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, \ + PVOID Buffer, \ + UINT32 BufferSizeInBytes)) \ + X(HRESULT, WHvGetVirtualProcessorState, \ + (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, \ + WHV_VIRTUAL_PROCESSOR_STATE_TYPE StateType, PVOID Buffer, \ + UINT32 BufferSizeInBytes, UINT32 *BytesWritten)) \ + X(HRESULT, WHvSetVirtualProcessorState, \ + (WHV_PARTITION_HANDLE Partition, UINT32 VpIndex, \ + WHV_VIRTUAL_PROCESSOR_STATE_TYPE StateType, PVOID Buffer, \ + UINT32 BufferSizeInBytes)) \ LIST_WINHVPLATFORM_FUNCTIONS_SUPPLEMENTAL_ARCH(X) =20 #define WHP_DEFINE_TYPE(return_type, function_name, signature) \ diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 9b48ef2914..cd0bc3d54e 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -10,6 +10,7 @@ =20 #include "qemu/osdep.h" #include "cpu.h" +#include "qemu/typedefs.h" #include "system/address-spaces.h" #include "system/ioport.h" #include "gdbstub/helpers.h" @@ -20,6 +21,7 @@ #include "system/cpus.h" #include "system/runstate.h" #include "qemu/main-loop.h" +#include "qemu/memalign.h" #include "hw/core/boards.h" #include "hw/intc/ioapic.h" #include "hw/intc/i8259.h" @@ -108,34 +110,6 @@ static const WHV_REGISTER_NAME whpx_register_names[] = =3D { * WHvX64RegisterDr7, */ =20 - /* X64 Floating Point and Vector Registers */ - WHvX64RegisterXmm0, - WHvX64RegisterXmm1, - WHvX64RegisterXmm2, - WHvX64RegisterXmm3, - WHvX64RegisterXmm4, - WHvX64RegisterXmm5, - WHvX64RegisterXmm6, - WHvX64RegisterXmm7, - WHvX64RegisterXmm8, - WHvX64RegisterXmm9, - WHvX64RegisterXmm10, - WHvX64RegisterXmm11, - WHvX64RegisterXmm12, - WHvX64RegisterXmm13, - WHvX64RegisterXmm14, - WHvX64RegisterXmm15, - WHvX64RegisterFpMmx0, - WHvX64RegisterFpMmx1, - WHvX64RegisterFpMmx2, - WHvX64RegisterFpMmx3, - WHvX64RegisterFpMmx4, - WHvX64RegisterFpMmx5, - WHvX64RegisterFpMmx6, - WHvX64RegisterFpMmx7, - WHvX64RegisterFpControlStatus, - WHvX64RegisterXmmControlStatus, - /* X64 MSRs */ WHvX64RegisterEfer, #ifdef TARGET_X86_64 @@ -182,6 +156,36 @@ static const WHV_REGISTER_NAME whpx_register_names_for= _vmexit[] =3D { WHvX64RegisterR15, }; =20 +static const WHV_REGISTER_NAME whpx_register_names_legacy_fp[] =3D{ + /* X64 Floating Point and Vector Registers (non-xsave) */ + WHvX64RegisterXmm0, + WHvX64RegisterXmm1, + WHvX64RegisterXmm2, + WHvX64RegisterXmm3, + WHvX64RegisterXmm4, + WHvX64RegisterXmm5, + WHvX64RegisterXmm6, + WHvX64RegisterXmm7, + WHvX64RegisterXmm8, + WHvX64RegisterXmm9, + WHvX64RegisterXmm10, + WHvX64RegisterXmm11, + WHvX64RegisterXmm12, + WHvX64RegisterXmm13, + WHvX64RegisterXmm14, + WHvX64RegisterXmm15, + WHvX64RegisterFpMmx0, + WHvX64RegisterFpMmx1, + WHvX64RegisterFpMmx2, + WHvX64RegisterFpMmx3, + WHvX64RegisterFpMmx4, + WHvX64RegisterFpMmx5, + WHvX64RegisterFpMmx6, + WHvX64RegisterFpMmx7, + WHvX64RegisterFpControlStatus, + WHvX64RegisterXmmControlStatus, +}; + struct whpx_register_set { WHV_REGISTER_VALUE values[RTL_NUMBER_OF(whpx_register_names)]; }; @@ -392,6 +396,123 @@ static int whpx_set_tsc(CPUState *cpu) return 0; } =20 +static bool whpx_is_xsave_enabled(CPUState *cpu) +{ + CPUX86State *env =3D &X86_CPU(cpu)->env; + return env->cr[4] & CR4_OSXSAVE_MASK; +} + +static size_t whpx_get_xsave_max_len(void) +{ + return whpx_get_supported_cpuid(0xd, 0, R_ECX); +} + +static int whpx_set_xsave_state(const CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + HRESULT hr; + void *xsavec_buf; + size_t page =3D qemu_real_host_page_size(); + size_t xsavec_buf_len; + + /* allocate and populate compacted buffer */ + xsavec_buf_len =3D whpx_get_xsave_max_len(); + xsavec_buf =3D qemu_memalign(page, xsavec_buf_len); + + /* save registers to standard format buffer */ + x86_cpu_xsave_all_areas(x86cpu, env->xsave_buf, env->xsave_buf_len); + + /* store compacted version of xsave area in xsavec_buf */ + compact_xsave_area(env, xsavec_buf, xsavec_buf_len); + + if (!whpx_is_legacy_os()) { + hr =3D whp_dispatch.WHvSetVirtualProcessorState( + whpx->partition, cpu->cpu_index, + WHvVirtualProcessorStateTypeXsaveState, + xsavec_buf, + xsavec_buf_len); + } else { + hr =3D whp_dispatch.WHvSetVirtualProcessorXsaveState( + whpx->partition, cpu->cpu_index, + xsavec_buf, + xsavec_buf_len); + } + + qemu_vfree(xsavec_buf); + if (FAILED(hr)) { + error_report("WHPX: Failed to get virtual processor context, hr=3D= %08lx", + hr); + } + + return 0; +} + +static void whpx_set_legacy_fp_registers(CPUState *cpu, WHPXStateLevel lev= el) +{ + struct whpx_state *whpx =3D &whpx_global; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + struct whpx_register_set vcxt; + HRESULT hr; + int idx =3D 0; + int i; + int idx_next; + + assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); + + /* 16 XMM registers */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterXmm0); + idx_next =3D idx + 16; + for (i =3D 0; i < sizeof(env->xmm_regs) / sizeof(ZMMReg); i +=3D 1, id= x +=3D 1) { + vcxt.values[idx].Reg128.Low64 =3D env->xmm_regs[i].ZMM_Q(0); + vcxt.values[idx].Reg128.High64 =3D env->xmm_regs[i].ZMM_Q(1); + } + idx =3D idx_next; + + /* 8 FP registers */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterFpMmx0); + for (i =3D 0; i < 8; i +=3D 1, idx +=3D 1) { + vcxt.values[idx].Fp.AsUINT128.Low64 =3D env->fpregs[i].mmx.MMX_Q(0= ); + /* vcxt.values[idx].Fp.AsUINT128.High64 =3D + env->fpregs[i].mmx.MMX_Q(1); + */ + } + + /* FP control status register */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterFpContr= olStatus); + vcxt.values[idx].FpControlStatus.FpControl =3D env->fpuc; + vcxt.values[idx].FpControlStatus.FpStatus =3D + (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; + vcxt.values[idx].FpControlStatus.FpTag =3D 0; + for (i =3D 0; i < 8; ++i) { + vcxt.values[idx].FpControlStatus.FpTag |=3D (!env->fptags[i]) << i; + } + vcxt.values[idx].FpControlStatus.Reserved =3D 0; + vcxt.values[idx].FpControlStatus.LastFpOp =3D env->fpop; + vcxt.values[idx].FpControlStatus.LastFpRip =3D env->fpip; + idx +=3D 1; + + /* XMM control status register */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterXmmCont= rolStatus); + vcxt.values[idx].XmmControlStatus.LastFpRdp =3D 0; + vcxt.values[idx].XmmControlStatus.XmmStatusControl =3D env->mxcsr; + vcxt.values[idx].XmmControlStatus.XmmStatusControlMask =3D 0x0000ffff; + idx +=3D 1; + + hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters( + whpx->partition, cpu->cpu_index, + whpx_register_names_legacy_fp, + idx, + &vcxt.values[0]); + + if (FAILED(hr)) { + error_report("WHPX: Failed to set virtual processor context, hr=3D= %08lx", + hr); + } +} + void whpx_set_registers(CPUState *cpu, WHPXStateLevel level) { struct whpx_state *whpx =3D &whpx_global; @@ -491,45 +612,11 @@ void whpx_set_registers(CPUState *cpu, WHPXStateLevel= level) */ whpx_set_xcrs(cpu); =20 - /* 16 XMM registers */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmm0); - idx_next =3D idx + 16; - for (i =3D 0; i < sizeof(env->xmm_regs) / sizeof(ZMMReg); i +=3D 1= , idx +=3D 1) { - vcxt.values[idx].Reg128.Low64 =3D env->xmm_regs[i].ZMM_Q(0); - vcxt.values[idx].Reg128.High64 =3D env->xmm_regs[i].ZMM_Q(1); - } - idx =3D idx_next; - - /* 8 FP registers */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpMmx0); - for (i =3D 0; i < 8; i +=3D 1, idx +=3D 1) { - vcxt.values[idx].Fp.AsUINT128.Low64 =3D env->fpregs[i].mmx.MMX= _Q(0); - /* vcxt.values[idx].Fp.AsUINT128.High64 =3D - env->fpregs[i].mmx.MMX_Q(1); - */ - } - - /* FP control status register */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpControlStat= us); - vcxt.values[idx].FpControlStatus.FpControl =3D env->fpuc; - vcxt.values[idx].FpControlStatus.FpStatus =3D - (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; - vcxt.values[idx].FpControlStatus.FpTag =3D 0; - for (i =3D 0; i < 8; ++i) { - vcxt.values[idx].FpControlStatus.FpTag |=3D (!env->fptags[i]) = << i; + if (whpx_is_xsave_enabled(cpu)) { + whpx_set_xsave_state(cpu); + } else { + whpx_set_legacy_fp_registers(cpu, level); } - vcxt.values[idx].FpControlStatus.Reserved =3D 0; - vcxt.values[idx].FpControlStatus.LastFpOp =3D env->fpop; - vcxt.values[idx].FpControlStatus.LastFpRip =3D env->fpip; - idx +=3D 1; - - /* XMM control status register */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmmControlSta= tus); - vcxt.values[idx].XmmControlStatus.LastFpRdp =3D 0; - vcxt.values[idx].XmmControlStatus.XmmStatusControl =3D env->mxcsr; - vcxt.values[idx].XmmControlStatus.XmmStatusControlMask =3D 0x0000f= fff; - idx +=3D 1; - /* MSRs */ assert(whpx_register_names[idx] =3D=3D WHvX64RegisterEfer); vcxt.values[idx++].Reg64 =3D env->efer; @@ -662,6 +749,109 @@ static void whpx_get_registers_for_vmexit(CPUState *c= pu, WHPXStateLevel level) x86_update_hflags(env); } =20 +static void whpx_get_legacy_fp_registers(CPUState *cpu, WHPXStateLevel lev= el) { + struct whpx_state *whpx =3D &whpx_global; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + struct whpx_register_set vcxt; + HRESULT hr; + int i; + int idx; + int idx_next; + + assert(cpu_is_stopped(cpu) || qemu_cpu_is_self(cpu)); + + hr =3D whp_dispatch.WHvGetVirtualProcessorRegisters( + whpx->partition, cpu->cpu_index, + whpx_register_names_legacy_fp, + RTL_NUMBER_OF(whpx_register_names_legacy_fp), + &vcxt.values[0]); + + if (FAILED(hr)) { + error_report("WHPX: Failed to get virtual processor context, hr=3D= %08lx", + hr); + } + + idx =3D 0; + /* 16 XMM registers */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterXmm0); + idx_next =3D idx + 16; + for (i =3D 0; i < sizeof(env->xmm_regs) / sizeof(ZMMReg); i +=3D 1, id= x +=3D 1) { + env->xmm_regs[i].ZMM_Q(0) =3D vcxt.values[idx].Reg128.Low64; + env->xmm_regs[i].ZMM_Q(1) =3D vcxt.values[idx].Reg128.High64; + } + idx =3D idx_next; + + /* 8 FP registers */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterFpMmx0); + for (i =3D 0; i < 8; i +=3D 1, idx +=3D 1) { + env->fpregs[i].mmx.MMX_Q(0) =3D vcxt.values[idx].Fp.AsUINT128.Low6= 4; + /* env->fpregs[i].mmx.MMX_Q(1) =3D + vcxt.values[idx].Fp.AsUINT128.High64; + */ + } + + /* FP control status register */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterFpContr= olStatus); + env->fpuc =3D vcxt.values[idx].FpControlStatus.FpControl; + env->fpstt =3D (vcxt.values[idx].FpControlStatus.FpStatus >> 11) & 0x7; + env->fpus =3D vcxt.values[idx].FpControlStatus.FpStatus & ~0x3800; + for (i =3D 0; i < 8; ++i) { + env->fptags[i] =3D !((vcxt.values[idx].FpControlStatus.FpTag >> i)= & 1); + } + env->fpop =3D vcxt.values[idx].FpControlStatus.LastFpOp; + env->fpip =3D vcxt.values[idx].FpControlStatus.LastFpRip; + idx +=3D 1; + + /* XMM control status register */ + assert(whpx_register_names_legacy_fp[idx] =3D=3D WHvX64RegisterXmmCont= rolStatus); + env->mxcsr =3D vcxt.values[idx].XmmControlStatus.XmmStatusControl; + idx +=3D 1; +} + +static int whpx_get_xsave_state(CPUState *cpu) +{ + struct whpx_state *whpx =3D &whpx_global; + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + int ret; + HRESULT hr; + void *xsavec_buf; + const size_t page =3D qemu_real_host_page_size(); + size_t xsavec_buf_len =3D whpx_get_xsave_max_len(); + UINT32 bytes_written; + + xsavec_buf =3D qemu_memalign(page, xsavec_buf_len); + memset(xsavec_buf, 0, xsavec_buf_len); + + 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); + } + if (FAILED(hr) || bytes_written =3D=3D 0) { + error_report("failed to get xsave state: %s", strerror(errno)); + return -errno; + } + + ret =3D decompact_xsave_area(xsavec_buf, xsavec_buf_len, env); + qemu_vfree(xsavec_buf); + if (ret < 0) { + error_report("failed to decompact xsave area"); + return ret; + } + x86_cpu_xrstor_all_areas(x86cpu, env->xsave_buf, env->xsave_buf_len); + + return 0; +} + void whpx_get_registers(CPUState *cpu, WHPXStateLevel level) { struct whpx_state *whpx =3D &whpx_global; @@ -758,40 +948,11 @@ void whpx_get_registers(CPUState *cpu, WHPXStateLevel= level) */ whpx_get_xcrs(cpu); =20 - /* 16 XMM registers */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmm0); - idx_next =3D idx + 16; - for (i =3D 0; i < sizeof(env->xmm_regs) / sizeof(ZMMReg); i +=3D 1, id= x +=3D 1) { - env->xmm_regs[i].ZMM_Q(0) =3D vcxt.values[idx].Reg128.Low64; - env->xmm_regs[i].ZMM_Q(1) =3D vcxt.values[idx].Reg128.High64; - } - idx =3D idx_next; - - /* 8 FP registers */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpMmx0); - for (i =3D 0; i < 8; i +=3D 1, idx +=3D 1) { - env->fpregs[i].mmx.MMX_Q(0) =3D vcxt.values[idx].Fp.AsUINT128.Low6= 4; - /* env->fpregs[i].mmx.MMX_Q(1) =3D - vcxt.values[idx].Fp.AsUINT128.High64; - */ - } - - /* FP control status register */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterFpControlStatus); - env->fpuc =3D vcxt.values[idx].FpControlStatus.FpControl; - env->fpstt =3D (vcxt.values[idx].FpControlStatus.FpStatus >> 11) & 0x7; - env->fpus =3D vcxt.values[idx].FpControlStatus.FpStatus & ~0x3800; - for (i =3D 0; i < 8; ++i) { - env->fptags[i] =3D !((vcxt.values[idx].FpControlStatus.FpTag >> i)= & 1); + if (whpx_is_xsave_enabled(cpu)) { + whpx_get_xsave_state(cpu); + } else { + whpx_get_legacy_fp_registers(cpu, level); } - env->fpop =3D vcxt.values[idx].FpControlStatus.LastFpOp; - env->fpip =3D vcxt.values[idx].FpControlStatus.LastFpRip; - idx +=3D 1; - - /* XMM control status register */ - assert(whpx_register_names[idx] =3D=3D WHvX64RegisterXmmControlStatus); - env->mxcsr =3D vcxt.values[idx].XmmControlStatus.XmmStatusControl; - idx +=3D 1; =20 /* MSRs */ assert(whpx_register_names[idx] =3D=3D WHvX64RegisterEfer); @@ -1525,6 +1686,9 @@ void whpx_arch_destroy_vcpu(CPUState *cpu) X86CPU *x86cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86cpu->env; g_free(env->emu_mmio_buf); + qemu_vfree(env->xsave_buf); + env->xsave_buf =3D NULL; + env->xsave_buf_len =3D 0; } =20 /* Returns the address of the next instruction that is about to be execute= d. */ @@ -2393,6 +2557,9 @@ int whpx_init_vcpu(CPUState *cpu) Error *local_error =3D NULL; X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; + X86XSaveHeader *header; + size_t page_size =3D qemu_real_host_page_size(); + size_t xsave_len; UINT64 freq =3D 0; int ret; =20 @@ -2469,6 +2636,15 @@ int whpx_init_vcpu(CPUState *cpu) qemu_add_vm_change_state_handler(whpx_cpu_update_state, env); =20 env->emu_mmio_buf =3D g_new(char, 4096); + /* Initialize XSAVE buffer page-aligned */ + xsave_len =3D whpx_get_xsave_max_len(); + env->xsave_buf =3D qemu_memalign(page_size, xsave_len); + env->xsave_buf_len =3D xsave_len; + memset(env->xsave_buf, 0, env->xsave_buf_len); + + /* we need to set the compacted format bit in xsave header for Hyper-V= */ + header =3D (X86XSaveHeader *)(env->xsave_buf + sizeof(X86LegacyXSaveAr= ea)); + header->xcomp_bv =3D header->xstate_bv | (1ULL << 63); =20 return 0; =20 @@ -2628,10 +2804,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms) error_report("WHPX: Failed to query XSAVE capability, hr=3D%08lx",= hr); } =20 - if (!whpx_has_xsave()) { - printf("WHPX: Partition is not XSAVE capable\n"); - } - memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); prop.ProcessorCount =3D ms->smp.cpus; hr =3D whp_dispatch.WHvSetPartitionProperty( --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551792; cv=none; d=zohomail.com; s=zohoarc; b=Zmm11JX1TTo+BDik8G2zPDtEMOeMRaNM9P2neSXQko/B6C5qcumkfCj6L3iBKiDaV0S/swXIsct18L+32OYwuJ48O4Y/kuzGnv2I6ITDf/Re7SH/wvHTVfFlsJRFSRe+bBRQ7CO+q2ITP+rMjup6nlZDY+VUHK7viKcZeSjcQEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551792; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AZNfvHRegyH4f70Ia13TlEC2emrhVTeWmibfHx3edKk=; b=OhSeRB9a3+VDAwRky2sPsXtgf/wluqPuZ2evKqDFEnChfIjQrKEBQuDiYw+74HwCxyDLyuuMEHRFxvg/bxGW0KSp6mJ3UQOwzoHk04px7Ot7yA271EDiQ0EeMaa1Zu5zwwVL8g+9DiPfK0jKnNymug0Vs55huzUCRr0SIqe4opw= 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 1776551792249737.0402057851526; Sat, 18 Apr 2026 15:36:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFF-0007PU-0Y; Sat, 18 Apr 2026 18:34:33 -0400 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 1wEEF9-0006nq-6G for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:27 -0400 Received: from p-east2-cluster1-host8-snip4-10.eps.apple.com ([57.103.76.83] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF7-0005Cf-Iz for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:26 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id BB9DF18000DA; Sat, 18 Apr 2026 22:34:23 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id D4CF118000B4; Sat, 18 Apr 2026 22:34:21 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551664; x=1779143664; bh=AZNfvHRegyH4f70Ia13TlEC2emrhVTeWmibfHx3edKk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=ejmpLXt5qpvauUoKZ6uumWxTk0cpeURi9zK5/Gf4qk0Tg68cmKGRFGYE+8nk/8wilksVYZODvY1UerE9/T4IXDH5DMfjvfoojG1Brt9e+L5yFu06hdljjBdGsTGu8g3xx9tspeFtZVUKVxw27YtKYDu5eU26szeWq+gScbGqsywiESe8nXbiRN5L2/gr1D5ghJrLPlGKHwlosaA141z0ToA/wQbNwt1E72+OMpqH/AHa5FPUhffx90zS79MY/afujNq+8V9PbGdrGSM72BSEQ+t+zLW41zOIUsTYrGGDxAFugIFlQbr3A/yQVACF+PFr23j8v692I9h8Nc4Y2kf+0A== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 32/38] whpx: i386: set APIC ID only when APIC present Date: Sun, 19 Apr 2026 00:33:14 +0200 Message-ID: <20260418223320.51330-33-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOSBTYWx0ZWRfX9BaruJKWq7+I 2TW2AX42esNfValEfAnwoBPgME4lDp8mvwzr4ZEkhOITCSEdGoFHI5uFLE9Ggaal+XXJp/bcnj5 4z44e6G3Ingj/9dvg+P7flqcjXHNWuAdfg+xNGMfJd7FGH1iJXlgYTVYXUvBFiLZBclDKegfRNg Y2um/N1mz/wm5wlajTdE5Tm9diV4mo8f0SNxrm14++6/Bi2Zsllo12HVWY4HDBQQ+yeL/OFtyYA P5XmyHEdDf/mJ/EHeL7+p27Rhia3nDCl33ACKIWRg7SfyolwnkG8CORu/ILOoRh6pOPD21mTvfO 6W2rSaG0d/AnO0bOn56x+0EGcq5DwunjJmFuE4psIaS3okRY4BUSQnDXQNen4g= X-Proofpoint-ORIG-GUID: 50gl7cHmAjd8bQ56s2IUstAy5Mzs8F9N X-Authority-Info-Out: v=2.4 cv=ApPjHe9P c=1 sm=1 tr=0 ts=69e406f0 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=WHe3jrWR342bzmf78BwA:9 X-Proofpoint-GUID: 50gl7cHmAjd8bQ56s2IUstAy5Mzs8F9N X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 suspectscore=0 malwarescore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 adultscore=0 mlxlogscore=869 phishscore=0 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180229 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=57.103.76.83; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551795149154100 Content-Type: text/plain; charset="utf-8" -M isapc doesn't have an APIC Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index cd0bc3d54e..0f50cf098a 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2589,7 +2589,7 @@ int whpx_init_vcpu(CPUState *cpu) goto error; } =20 - if (!whpx_irqchip_in_kernel()) { + if (!whpx_irqchip_in_kernel() && x86_cpu->apic_state !=3D NULL) { WHV_REGISTER_VALUE apic_id =3D {.Reg64 =3D x86_cpu->apic_state->in= itial_apic_id}; whpx_set_reg(cpu, WHvX64RegisterInitialApicId, apic_id); } --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551855; cv=none; d=zohomail.com; s=zohoarc; b=M3cKZSJ32SVvM1qV4MPpCKh/AOIJDxB0mWrJ3C/ihXrxMMaeM0kdbAzrmx8Kx7uqpQrIu8Kz8ys99Fb1du3psTUe6pXSLQEnX/LdLfI3XNRkCwZro/23Y5ObZodtVrO3KKX+OzpXCugitadzmz9WeDf+4eNs8ZxC9rMIzT6Dooo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551855; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MdExfT43UhW0TEktVljSUoe2lp3EKCmf2xhHSOPb+jk=; b=knWUg2YW6XJZOgiRYxGtCpmGgjlq2VeCg7Rm1/sXJYccmpRMVkWiZ+QNbTypL9ED+gdHnABOQKAWi89tyWRewNHs0fc6L+pHLt4Q80Jh8NbpRug7qlteCrO3dYCN3eFRxI7Gzivpb6CH4ZExcGop5dCEyqSsaX2UHn+jt4swGS0= 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 1776551855714742.719178699932; Sat, 18 Apr 2026 15:37:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFD-0007BC-6q; Sat, 18 Apr 2026 18:34:31 -0400 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 1wEEFA-0006uy-H4 for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:28 -0400 Received: from p-east2-cluster1-host10-snip4-10.eps.apple.com ([57.103.76.123] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEF8-0005Cx-Uo for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:28 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 8FECD1800223; Sat, 18 Apr 2026 22:34:25 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id B364818000BB; Sat, 18 Apr 2026 22:34:23 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551666; x=1779143666; bh=MdExfT43UhW0TEktVljSUoe2lp3EKCmf2xhHSOPb+jk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=RHSeQFJXEaQc/01mwAgfszUCMPCwIBhULA4qa7hIhOPOAgTQ8uPKhui3Ktf2fa2BIQdQOWZYPaXOwyiRW+KQwtPaHFaKM4mCPqInJ7k8VmERfN2yuuLGdZNzA7nRxd9Eiw67CVg9dNG57cGAL853QhDaOAuQrhK/QudiKJhdZvGnaL0F2Qzc1AdpLLQ8b7r9o6sTvLQ83ox/0RHSocaSWPtWXQkRew6kDYh4wisBLuveWRyLCu5S5emwPUHpe6UmSQ2ge2zQpgfb7O5gsKBbyFxJtqkmIWD2IzQF+qStPpVIaI3JbTpj7Xzpy9Pz/iJRM8fxsY0tE6UJb9kEFnge8Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 33/38] whpx: i386: update migration blocker message Date: Sun, 19 Apr 2026 00:33:15 +0200 Message-ID: <20260418223320.51330-34-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=OoNCCi/t c=1 sm=1 tr=0 ts=69e406f2 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=0IeqtQ1xXW1zzRo-U5sA:9 a=ZXulRonScM0A:10 X-Proofpoint-GUID: YM4rWn84DvxPSWo21FB10KB-tJvTSdU8 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOSBTYWx0ZWRfXz6up2eHRnzXT S9Npb9zDQanA/RIEDPU0XJyr+nHuZgR2svynkraNrNoZyoN/DC2A3hd8/4NYeg+cppiyT5n2eMt UrPh6j56YFV9YATxrI6yYt2BNC0IcsaVwJ6YbBmYbinXP/CAeawxmmydCG6qXz7LAsiv1aB/OzW m/zQy4S6GslDTsOdizW26ijrVVgYTMf3URVrmrbb1vtP8FZbAe1zDhyq2DpzsK3VEpxEcamRDPx KDNtmkGJXb2F20XmPY8ycPNJ7Nz0bJJ8pIUq4p9XB2ZJ5Uqp/JeX2awlvFQ1FFvUhInwFO/ZOkk ki9hf/HBvy9dNqwJ0SN8ZJT8t7e+1RmQFKOZ1Lw+RrDvMXfsiiR3e8qWI8u1Pg= X-Proofpoint-ORIG-GUID: YM4rWn84DvxPSWo21FB10KB-tJvTSdU8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 clxscore=1030 phishscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=637 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180229 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=57.103.76.123; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551858031154100 Content-Type: text/plain; charset="utf-8" Quite a part of it is from older times... Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 0f50cf098a..98b13676ba 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2568,8 +2568,8 @@ int whpx_init_vcpu(CPUState *cpu) */ if (whpx_migration_blocker =3D=3D NULL) { error_setg(&whpx_migration_blocker, - "State blocked due to non-migratable CPUID feature support," - "dirty memory tracking support, and XSAVE/XRSTOR support"); + "State blocked due to missing dirty memory tracking support= ," + "And some system register/state save-restore "); =20 if (migrate_add_blocker(&whpx_migration_blocker, &local_error) < 0= ) { error_report_err(local_error); --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551827; cv=none; d=zohomail.com; s=zohoarc; b=Ac22ktS6+QBQTdVMWn60pKT7nhTgA58JIzj8wlEcsyi7bJDNfajmMZdr+4gRgK0jrsIBFxopzJUsCWdSy5xCSsdL9lvy011eEM1oNvf0fIaL4jI+9lAKKjgTS7+unq5HSuH9cbZ+OVaZ0+qS41HtO+LdXk9zODRTfq69ROoIyDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551827; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kGhBK4LCPtYSYe6aojWD51bIwGxqBS+1pxUsdaVHLfk=; b=lS6qIRSLIsxIJpTRbUvKBKynQGJz2GQzSLHdI3niadl3KklACXC9U91xnsMlmer+1ruA4njkKutuDl/HL6WcZxKDXm05QSWBjPH4hcXvst9WkdJxF8syhzcimKgweEIDzbnMoXie2PlLBzChxIo/1LPxbpp0v690KD6F+vIGmxA= 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 1776551827540214.1896849632716; Sat, 18 Apr 2026 15:37:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFG-0007Zo-Id; Sat, 18 Apr 2026 18:34:34 -0400 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 1wEEFC-00077j-IN for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:30 -0400 Received: from p-east2-cluster1-host4-snip4-10.eps.apple.com ([57.103.76.23] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEFA-0005Df-Vz for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:30 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 8BCB418000E2; Sat, 18 Apr 2026 22:34:27 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 89DF71800219; Sat, 18 Apr 2026 22:34:25 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551668; x=1779143668; bh=kGhBK4LCPtYSYe6aojWD51bIwGxqBS+1pxUsdaVHLfk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=HWWz826Phui9dviZ5wpRDaIsKTOPsi6eLmN/PAta3epWjFjdLUtUGx35YdAgYTIpuTDW+PE6WCWZauRsNVjGO3J1qBbFy50fDLF5//DjUu9vDXixFFg6o4AiVN997BO+nDTIOEcyOt8AuTpm02WgRbXulGPnDtwW3wNXrtasyvqv4MbLt3GeVVbU7IiJBRxeJ315cCa9hGvAhB6nUerm1U6EgWxXGdj4GxFLgQRCm2fc6CR7KZO042RA3OCGWJoziiRYzJsM6jMvlJ1uZiNCWEHm3FTjFr/DJ6LRsXOsby6wtlcSzXFAVaZQoGDgpFmXXRBtEWLuj68PmjzIc0zRmA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 34/38] whpx: i386: don't increment eip on MSR access raising GPF Date: Sun, 19 Apr 2026 00:33:16 +0200 Message-ID: <20260418223320.51330-35-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=OoNCCi/t c=1 sm=1 tr=0 ts=69e406f4 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=N0YEvnU7VqbRQIRMxcMA:9 a=+jEqtf1s3R9VXZ0wqowq2kgwd+I=:19 X-Proofpoint-GUID: GDJvuNSI7pJlzRThvRB8l-5JT5pKqFIe X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOSBTYWx0ZWRfXxDg/Xy1RFHX0 UIqif8DSy91Y8yqNykv0f5nAx3ixDpoUB24ozRp80wAge5tht174LiA0MS2POVLuy0CXr2VIF6R XGMmq4K/7YkbouBr1dw2hJO0Otbt27UAmln1DAPq9yeKu+8Cq4OvlO6kOFXwtebfNXlfy6U0jNt Ifx8JH9/LrKRXZFxJUuKpzkX/4HRxEbrAaEkR1IjSjPG32LEBfiRqAVpAgvOmVX9lGrdUBZ+T/A IvlYsDdIq24slYS5xSfwrq07Ayo30y6ZP6CUyTj9CH2gqwoUDc/TI+Rg3O0CLCMFV5w3anlu6GO I1llOrI+ykTb36tydkwZShmCxPaE08yme8d4qW9IUNOTfgfF2qX3orX1Lws+bE= X-Proofpoint-ORIG-GUID: GDJvuNSI7pJlzRThvRB8l-5JT5pKqFIe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 clxscore=1030 phishscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=757 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180229 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=57.103.76.23; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551829640154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 98b13676ba..de254e236b 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2178,6 +2178,7 @@ int whpx_vcpu_run(CPUState *cpu) WHV_REGISTER_NAME reg_names[3]; UINT32 reg_count; bool is_known_msr =3D 0;=20 + bool raises_gpf =3D false; uint64_t val; =20 if (vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { @@ -2210,6 +2211,7 @@ int whpx_vcpu_run(CPUState *cpu) is_known_msr =3D 1; if (val & MSR_IA32_APICBASE_RESERVED) { x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GP= F, 0); + raises_gpf =3D true; } if (!vcpu->exit_ctx.MsrAccess.AccessInfo.IsWrite) { /* Read path unreachable on Hyper-V */ @@ -2219,6 +2221,7 @@ int whpx_vcpu_run(CPUState *cpu) int msr_ret =3D cpu_set_apic_base(X86_CPU(cpu)->apic_s= tate, val); if (msr_ret < 0) { x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0= D_GPF, 0); + raises_gpf =3D true; } else { whpx_set_reg(cpu, WHvX64RegisterApicBase, reg); } @@ -2238,6 +2241,7 @@ int whpx_vcpu_run(CPUState *cpu) reg_values[1].Reg64 =3D val; if (msr_ret < 0) { x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0= D_GPF, 0); + raises_gpf =3D true; } } else { bql_lock(); @@ -2245,6 +2249,7 @@ int whpx_vcpu_run(CPUState *cpu) bql_unlock(); if (msr_ret < 0) { x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0= D_GPF, 0); + raises_gpf =3D true; } } } @@ -2294,6 +2299,13 @@ int whpx_vcpu_run(CPUState *cpu) =20 if (!is_known_msr && !whpx->ignore_unknown_msr) { x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GPF, 0= ); + raises_gpf =3D true; + } + + /* When a GPF is raised, do not change Rip. */ + if (raises_gpf) { + reg_values[0].Reg64 =3D + vcpu->exit_ctx.VpContext.Rip; } =20 hr =3D whp_dispatch.WHvSetVirtualProcessorRegisters( --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551871; cv=none; d=zohomail.com; s=zohoarc; b=D3YI6nrv9DyN0nI1scA4HOyBc/Ld09dGwoyiH7tpNT5G7lbZISQXhlzFRI440cLx0Iklsn7Y8ST/q1uYT+uBElKjEUhFEROQBfonswSjFdus9PWdvOk9Na7vr0Zc/s8G/+/m3FDlvv3eeBAgTk0QFOHTPabJ12XZX3+HXOqXS2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551871; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IdjugA9xaHsg2nQQQ2yDxOQbJO+pfnS1V2J1m3byuQQ=; b=R905ihnzKWqvvwX02gp9gC649F0nki1gJQTFsCJf+05vxjJYLypArIzLzih9eph/XDMxieWsCT78bFayj5wA1kocD32SSm8nhB1g+NBoaYKULynFAPYk15BiYUx5czxaWzPrSiQHQz65Qz82vXn5YKb7rhrUWTEJJwh3JKpeKAc= 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 1776551871606203.70699672345847; Sat, 18 Apr 2026 15:37:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFM-0008CC-TK; Sat, 18 Apr 2026 18:34:40 -0400 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 1wEEFL-00086A-Go for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:39 -0400 Received: from p-east2-cluster1-host12-snip4-9.eps.apple.com ([57.103.76.62] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEFJ-0005FL-Ps for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:39 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 27F4418000FC; Sat, 18 Apr 2026 22:34:32 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 56EA418000C4; Sat, 18 Apr 2026 22:34:27 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551677; x=1779143677; bh=IdjugA9xaHsg2nQQQ2yDxOQbJO+pfnS1V2J1m3byuQQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=a4z+863NLCY/pk5Ci0Ocdvvsm9s/V/H7GtFjDWUWtBlHkLwOf+3YhEoL2yb+mltaNtkc6ma1pmy7DLiMZpLmF0/lGwqZWtyVsZ/0G1mn74oykbB2vrtcfmri9mGlGjzRNeOSeA7RBqJZjLVV+es8cii7MZfqCy42lkEMy+ZgFrUtgJvb9EhCWF2w22qjnT/ObV3cTb/lrRcT09KsvX2EaIZA4CXoWzIG8z78rLWgzSOsDcEM+iAhAyfI7efKc1V2LrmJdDw34fpJokKgTthVnyeMAslffwrBRJmLny/SwmC1cYMBrIoUBOUBy7Zi9VWdz/M2INuIevO6C9TARvS3tw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 35/38] target/i386: emulate, hvf: rdmsr/wrmsr GPF handling Date: Sun, 19 Apr 2026 00:33:17 +0200 Message-ID: <20260418223320.51330-36-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 7Qp_TFdQSh-AecfZVKQKi9wOybeSg3Bf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOSBTYWx0ZWRfXylI5f6QgvWm3 hccw+XSHHF6qrZaaXPg7YqUNP67fYJFoKrw+8y/Lf4nzGpZmMQwaa+eIEN+KMu9OYosKx1WzzaX 49Nknp28P2p/7qeuYbSvN/dBP2vxQK22WNmKDN9jRTkpWP3eeCUPBA0uDwG9sanHIYhLBHUDqZ/ 9PZ2seme0bdTeXLbr83dHPJhea1HF44s2omv9iV6CUeIhEvZ74cjt7tkXW5+KGOiZ1P2Hn3+eyN hby9ljBhbx80O7ByHUq1QwPJE1BOOhzhUFYl8aGW4mydxKrnt9sVv4wqJERnYD9eZTgVeJDSDMl GFvWc+Wg9uzWzsJZaJhWct65+34nuARwUoSADN7LBwGXpYTltgvxUuL4+p4ye0= X-Proofpoint-GUID: 7Qp_TFdQSh-AecfZVKQKi9wOybeSg3Bf X-Authority-Info-Out: v=2.4 cv=W9M1lBWk c=1 sm=1 tr=0 ts=69e406fb cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=183X19KWV2qSZiVN73EA:9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=697 lowpriorityscore=0 clxscore=1030 adultscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180229 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=57.103.76.62; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551872255154100 Content-Type: text/plain; charset="utf-8" In that case, the instruction pointer mustn't be incremented. Signed-off-by: Mohamed Mediouni --- target/i386/emulate/x86_emu.c | 10 ++++++---- target/i386/emulate/x86_emu.h | 4 ++-- target/i386/hvf/hvf.c | 9 +++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/target/i386/emulate/x86_emu.c b/target/i386/emulate/x86_emu.c index c2da1a133f..c6ea854290 100644 --- a/target/i386/emulate/x86_emu.c +++ b/target/i386/emulate/x86_emu.c @@ -792,15 +792,17 @@ void x86_emul_raise_exception(CPUX86State *env, int e= xception_index, int error_c =20 static bool exec_rdmsr(CPUX86State *env, struct x86_decode *decode) { - emul_ops->simulate_rdmsr(env_cpu(env)); - env->eip +=3D decode->len; + if (!emul_ops->simulate_rdmsr(env_cpu(env))) { + env->eip +=3D decode->len; + } return 0; } =20 static bool exec_wrmsr(CPUX86State *env, struct x86_decode *decode) { - emul_ops->simulate_wrmsr(env_cpu(env)); - env->eip +=3D decode->len; + if (!emul_ops->simulate_wrmsr(env_cpu(env))) { + env->eip +=3D decode->len; + } return 0; } =20 diff --git a/target/i386/emulate/x86_emu.h b/target/i386/emulate/x86_emu.h index a8d4c93098..b985240b90 100644 --- a/target/i386/emulate/x86_emu.h +++ b/target/i386/emulate/x86_emu.h @@ -31,8 +31,8 @@ struct x86_emul_ops { target_ulong (*read_cr) (CPUState *cpu, int cr); void (*handle_io)(CPUState *cpu, uint16_t port, void *data, int direct= ion, int size, int count); - void (*simulate_rdmsr)(CPUState *cs); - void (*simulate_wrmsr)(CPUState *cs); + bool (*simulate_rdmsr)(CPUState *cs); + bool (*simulate_wrmsr)(CPUState *cs); bool (*is_protected_mode)(CPUState *cpu); bool (*is_long_mode)(CPUState *cpu); bool (*is_user_mode)(CPUState *cpu); diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index c0d028b147..dfe7500010 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -536,7 +536,7 @@ void hvf_store_regs(CPUState *cs) macvm_set_rip(cs, env->eip); } =20 -void hvf_simulate_rdmsr(CPUState *cs) +bool hvf_simulate_rdmsr(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; @@ -557,6 +557,7 @@ void hvf_simulate_rdmsr(CPUState *cs) ret =3D apic_msr_read(cpu->apic_state, index, &val); if (ret < 0) { x86_emul_raise_exception(env, EXCP0D_GPF, 0); + return 1; } =20 break; @@ -639,9 +640,10 @@ void hvf_simulate_rdmsr(CPUState *cs) =20 RAX(env) =3D (uint32_t)val; RDX(env) =3D (uint32_t)(val >> 32); + return 0; } =20 -void hvf_simulate_wrmsr(CPUState *cs) +bool hvf_simulate_wrmsr(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; @@ -657,6 +659,7 @@ void hvf_simulate_wrmsr(CPUState *cs) r =3D cpu_set_apic_base(cpu->apic_state, data); if (r < 0) { x86_emul_raise_exception(env, EXCP0D_GPF, 0); + return 1; } =20 break; @@ -668,6 +671,7 @@ void hvf_simulate_wrmsr(CPUState *cs) ret =3D apic_msr_write(cpu->apic_state, index, data); if (ret < 0) { x86_emul_raise_exception(env, EXCP0D_GPF, 0); + return 1; } =20 break; @@ -746,6 +750,7 @@ void hvf_simulate_wrmsr(CPUState *cs) g_hypervisor_iface->wrmsr_handler(cs, msr, data); =20 printf("write msr %llx\n", RCX(cs));*/ + return 0; } =20 static int hvf_handle_vmexit(CPUState *cpu) --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551785; cv=none; d=zohomail.com; s=zohoarc; b=nF48HZat6/s6FONUoExJIQwaWMBLCyb4Kd4KMa/myxwwQrbzgT0ZoxTMtOcfnndwBH0is56zgPlhGW1HeIC6EeYrY9dPbma/b3KIr9/ofzVb+JCaBYG/G45h8w96Ih0P/TtQ+c5CzNIrqfqqIc2ghkJNvKoEXVHZfi4e2XALXyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551785; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mEtPVQ71C4UScAWJmuCY+zr2oGidklaoc0eP3+xM4is=; b=UYfZkoQfd6f4WFCpfE5KKbykvAo1ozys2reZFcGnOnFNkDWagGbIU3g0b9SvAHkwIvqUbKZqFOP+eRtNJtUlohKyQKpG/exmCGYXbiobd5Mci6m3gHo+RsNSHIM2anUlDrk9FdoIei8g9s/38ruiZZWulQOM33ytcqABbpBVu30= 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 177655178562021.65854049622783; Sat, 18 Apr 2026 15:36:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFK-0007x3-5l; Sat, 18 Apr 2026 18:34:38 -0400 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 1wEEFG-0007aj-NU for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:34 -0400 Received: from p-east2-cluster1-host9-snip4-8.eps.apple.com ([57.103.76.111] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEFE-0005EP-Gf for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:34 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 0426A1800207; Sat, 18 Apr 2026 22:34:30 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 2D3DD18000B4; Sat, 18 Apr 2026 22:34:29 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551671; x=1779143671; bh=mEtPVQ71C4UScAWJmuCY+zr2oGidklaoc0eP3+xM4is=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=GjdYZ6LCS54tpAFFzLS92OOIoHFCrys4eipv6hRmn2t7b/DLxvxthKy6BQ6D/HFRAxgs80xY+D33S0jxTGypII4x9Z+26wr2FVBmhm5C9VFIBdVKA9YGewTTdshUQ+XQO0kJyv0Nssn+sX1lROAc8Qm7cFoLslvJS4yLcCI/dTafmmLb6LXzZ2dDd8eD0wOI8bgKu5O93ep6FR9yi/6LvVD11wQ8xK/ZoWjST6P7wy11tZt98i6XLM4KJPgSBtqadK3YiIcdpQ7U7o9HS91+8SMCr4cxnxbzEYraWggz+1xf10VB3YlCZskvNHKEn1wiG0EaWihsM/bFri6j6HLDeA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 36/38] whpx: i386: add feature to intercept #GP MSR accesses Date: Sun, 19 Apr 2026 00:33:18 +0200 Message-ID: <20260418223320.51330-37-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: Itua0K9TnWYP_PBkNoydkQuFVi1X7BrR X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOSBTYWx0ZWRfX+lMp3c75ChYq flO5SUImcpbz0wsVC2RXHnoc3zzox4QpMHgr2GQa8ojTUgEPYC6CfsRTARWZLQWF+iGjw4R8Zc+ cQ3oIyCzLLEYUwj3W3wjFDUHFjCopbviVKTjvQZNXt1H9IEbMPgglRfQ3RSFW5TFgFIhjzd/Vg1 z4mQJkF1uD5fgoz9Ll8LKgzT8yJZ7uROyBA/yGG8YPHjBRPo2kl/s3T5G3DFDII9zwsSAhICHfl nktgL5vB9rGUBOhzznz7JXldKiII1z0iqmzKr8mRwwzwMY9iU16Shrf9ia2y1Lm9TuS8rD+WMio xZ4dqZkDqxjWYjsriRET5MOwJK1vpDxNd4mX988QeQD42cj01G1capeVXumd2c= X-Authority-Info-Out: v=2.4 cv=KLxXzVFo c=1 sm=1 tr=0 ts=69e406f7 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=CoAbg4nstuYx8jGKVk0A:9 X-Proofpoint-ORIG-GUID: Itua0K9TnWYP_PBkNoydkQuFVi1X7BrR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 malwarescore=0 lowpriorityscore=0 mlxscore=0 suspectscore=0 bulkscore=0 adultscore=0 clxscore=1030 mlxlogscore=999 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180229 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=57.103.76.111; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551786663158500 Content-Type: text/plain; charset="utf-8" It turns out they're not that uncommon, so have a feature around to log those. Signed-off-by: Mohamed Mediouni --- accel/whpx/whpx-common.c | 38 +++++++++ include/system/whpx-internal.h | 1 + target/i386/whpx/whpx-all.c | 144 ++++++++++++++++++++++++++++----- 3 files changed, 164 insertions(+), 19 deletions(-) diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c index 706871f138..8f28b1d617 100644 --- a/accel/whpx/whpx-common.c +++ b/accel/whpx/whpx-common.c @@ -537,6 +537,38 @@ static void whpx_set_unknown_msr(Object *obj, Visitor = *v, } } =20 +static void whpx_set_intercept_msr_gp(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + struct whpx_state *whpx =3D &whpx_global; + OnOffAuto mode; + + if (!visit_type_OnOffAuto(v, name, &mode, errp)) { + return; + } + + switch (mode) { + case ON_OFF_AUTO_ON: + whpx->intercept_msr_gp =3D true; + break; + + case ON_OFF_AUTO_OFF: + whpx->intercept_msr_gp =3D false; + break; + + case ON_OFF_AUTO_AUTO: + whpx->intercept_msr_gp =3D false; + break; + default: + /* + * The value was checked in visit_type_OnOffAuto() above. If + * we get here, then something is wrong in QEMU. + */ + abort(); + } +} + static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data) { AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); @@ -575,6 +607,11 @@ static void whpx_accel_class_init(ObjectClass *oc, con= st void *data) NULL, NULL); object_class_property_set_description(oc, "ignore-unknown-msr", "Configure unknown MSR behavior"); + object_class_property_add(oc, "intercept-msr-gp", "OnOffAuto", + NULL, whpx_set_intercept_msr_gp, + NULL, NULL); + object_class_property_set_description(oc, "intercept-msr-gp", + "Intercept #GP to log erroring MSR accesses."); } =20 static void whpx_accel_instance_init(Object *obj) @@ -590,6 +627,7 @@ static void whpx_accel_instance_init(Object *obj) /* Value determined at whpx_accel_init */ whpx->hyperv_enlightenments_enabled =3D false; whpx->ignore_unknown_msr =3D true; + whpx->intercept_msr_gp =3D false; } =20 static const TypeInfo whpx_accel_type =3D { diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h index 0aae83bd7c..15027a7d52 100644 --- a/include/system/whpx-internal.h +++ b/include/system/whpx-internal.h @@ -48,6 +48,7 @@ struct whpx_state { bool hyperv_enlightenments_enabled; =20 bool ignore_unknown_msr; + bool intercept_msr_gp; }; =20 extern struct whpx_state whpx_global; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index de254e236b..e79d085da8 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1007,6 +1007,25 @@ static int emulate_instruction(CPUState *cpu, const = uint8_t *insn_bytes, size_t return 0; } =20 +static int emulate_msr_instruction(CPUState *cpu, const uint8_t *insn_byte= s, size_t insn_len) { + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + struct x86_decode decode =3D { 0 }; + x86_insn_stream stream =3D { .bytes =3D insn_bytes, .len =3D insn_len = }; + + whpx_get_registers(cpu, WHPX_LEVEL_FAST_RUNTIME_STATE); + decode_instruction_stream(env, &decode, &stream); + + if (decode.cmd !=3D X86_DECODE_CMD_RDMSR=20 + && decode.cmd !=3D X86_DECODE_CMD_WRMSR) { + return 1; + } + + exec_instruction(env, &decode); + whpx_set_registers(cpu, WHPX_LEVEL_FAST_RUNTIME_STATE); + return 0; +} + static int whpx_handle_mmio(CPUState *cpu, WHV_RUN_VP_EXIT_CONTEXT *exit_c= tx) { WHV_MEMORY_ACCESS_CONTEXT *ctx =3D &exit_ctx->MemoryAccess; @@ -1021,6 +1040,45 @@ static int whpx_handle_mmio(CPUState *cpu, WHV_RUN_V= P_EXIT_CONTEXT *exit_ctx) return 0; } =20 +static int whpx_handle_msr_from_gpf(CPUState *cpu) +{ + WHV_VP_EXCEPTION_CONTEXT *ctx =3D &cpu->accel->exit_ctx.VpException; + int ret; + + ret =3D emulate_msr_instruction(cpu, ctx->InstructionBytes, ctx->Instr= uctionByteCount); + if (ret =3D=3D 1) { + /* Not an MSR instruction */ + return 1; + } + + return 0; +} + +static void whpx_inject_back_gpf(CPUState* cpu) +{ + WHV_VP_EXCEPTION_CONTEXT* ctx =3D &cpu->accel->exit_ctx.VpException; + WHV_REGISTER_VALUE reg =3D {}; + + if (ctx->ExceptionInfo.SoftwareException) { + /* TODO */ + warn_report("Was asked to inject software exception."); + return; + } + + if (ctx->ExceptionType !=3D EXCP0D_GPF) { + warn_report("Was asked to inject exception other than GPF."); + return; + } + + reg.ExceptionEvent.EventPending =3D 1; + reg.ExceptionEvent.EventType =3D WHvX64PendingEventException; + reg.ExceptionEvent.DeliverErrorCode =3D ctx->ExceptionInfo.ErrorCodeVa= lid; + reg.ExceptionEvent.Vector =3D ctx->ExceptionType; + reg.ExceptionEvent.ErrorCode =3D ctx->ErrorCode; + reg.ExceptionEvent.ExceptionParameter =3D ctx->ExceptionParameter; + whpx_set_reg(cpu, WHvRegisterPendingEvent, reg); +} + static void handle_io(CPUState *env, uint16_t port, void *buffer, int direction, int size, int count) { @@ -1209,13 +1267,54 @@ static target_ulong read_cr(CPUState *cpu, int cr) return val.Reg64; } =20 +static bool whpx_simulate_rdmsr(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + uint32_t msr =3D ECX(env); + uint64_t val =3D 0; + + switch (msr) { + default: + error_report("WHPX: unknown msr 0x%x\n", msr); + x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GPF, 0); + return 1; + break; + } + + RAX(env) =3D (uint32_t)val; + RDX(env) =3D (uint32_t)(val >> 32); + + return 0; +} + +static bool whpx_simulate_wrmsr(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + uint32_t msr =3D ECX(env); + uint64_t data =3D ((uint64_t)EDX(env) << 32) | EAX(env); + + switch (msr) { + default: + error_report("WHPX: unknown msr 0x%x val %llx\n", msr, data); + x86_emul_raise_exception(&X86_CPU(cpu)->env, EXCP0D_GPF, 0); + return 1; + break; + } + + return 0; +} + static const struct x86_emul_ops whpx_x86_emul_ops =3D { .read_segment_descriptor =3D read_segment_descriptor, .handle_io =3D handle_io, .is_protected_mode =3D is_protected_mode, .is_long_mode =3D is_long_mode, .is_user_mode =3D is_user_mode, - .read_cr =3D read_cr + .read_cr =3D read_cr, + .simulate_rdmsr =3D whpx_simulate_rdmsr, + .simulate_wrmsr =3D whpx_simulate_wrmsr }; =20 static void whpx_init_emu(void) @@ -1294,6 +1393,18 @@ uint32_t whpx_get_supported_cpuid(uint32_t func, uin= t32_t idx, int reg) } } =20 +static UINT64 whpx_get_default_exceptions(void) +{ + struct whpx_state *whpx =3D &whpx_global; + UINT64 intercepts =3D 0; + + if (whpx->intercept_msr_gp) { + intercepts |=3D 1UL << WHvX64ExceptionTypeGeneralProtectionFault; + } + + return intercepts; +} + /* * Controls whether we should intercept various exceptions on the guest, * namely breakpoint/single-step events. @@ -1316,7 +1427,7 @@ HRESULT whpx_set_exception_exit_bitmap(UINT64 excepti= ons) prop.ExtendedVmExits.X64MsrExit =3D 1; prop.ExtendedVmExits.X64CpuidExit =3D 1; =20 - if (exceptions !=3D 0) { + if (exceptions !=3D 0 || whpx_get_default_exceptions() !=3D 0) { prop.ExtendedVmExits.ExceptionExit =3D 1; } =20 @@ -1331,7 +1442,7 @@ HRESULT whpx_set_exception_exit_bitmap(UINT64 excepti= ons) } =20 memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); - prop.ExceptionExitBitmap =3D exceptions; + prop.ExceptionExitBitmap =3D exceptions | whpx_get_default_exceptions(= ); =20 hr =3D whp_dispatch.WHvSetPartitionProperty( whpx->partition, @@ -1341,6 +1452,8 @@ HRESULT whpx_set_exception_exit_bitmap(UINT64 excepti= ons) =20 if (SUCCEEDED(hr)) { whpx->exception_exit_bitmap =3D exceptions; + } else { + error_report("WHPX: Failed to set exception exit bitmap, hr=3D%08l= x", hr); } =20 return hr; @@ -2476,6 +2589,15 @@ int whpx_vcpu_run(CPUState *cpu) break; } case WHvRunVpExitReasonException: + if (vcpu->exit_ctx.VpException.ExceptionType =3D=3D + WHvX64ExceptionTypeGeneralProtectionFault) { + if (whpx_handle_msr_from_gpf(cpu)) { + whpx_inject_back_gpf(cpu); + } + ret =3D 0; + break; + } + whpx_get_registers(cpu, WHPX_LEVEL_FULL_STATE); =20 if ((vcpu->exit_ctx.VpException.ExceptionType =3D=3D @@ -2984,22 +3106,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms) goto error; } =20 - /* Register for MSR and CPUID exits */ - memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); - prop.ExtendedVmExits.X64MsrExit =3D 1; - prop.ExtendedVmExits.X64CpuidExit =3D 1; - - hr =3D whp_dispatch.WHvSetPartitionProperty( - whpx->partition, - WHvPartitionPropertyCodeExtendedVmExits, - &prop, - sizeof(WHV_PARTITION_PROPERTY)); - if (FAILED(hr)) { - error_report("WHPX: Failed to enable extended VM exits, hr=3D%08lx= ", hr); - ret =3D -EINVAL; - goto error; - } - memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY)); prop.X64MsrExitBitmap.UnhandledMsrs =3D 1; prop.X64MsrExitBitmap.ApicBaseMsrWrite =3D 1; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551702; cv=none; d=zohomail.com; s=zohoarc; b=il2K6+QgLOs0AWYIyHgJAkxiPoUGGDBv3976ccCu5RKEgbpSDYoEF7GbEZHLL0zcNwBL3HePYbE1VfxGBuHniGRarWllkmabplJbX9RyBJUd01nWnGoAwpLYr/iEhTGjQOQnC4nGHKXH0lUdwWdMVm1Zn4fnQZ8Qn/e3p2xksRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551702; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Jrr2HbYb7vJ4wfjMglfbzSz74bDnkcrrxHCDfoOvAtE=; b=eJxzdJeZwABIf7ilyWwQV5gV0Sgt08eHUaa+GeaonBzvekzrpIKEeGxHId54W49HZ4bxz7jW2FSm3j7niZAFNUCfZGpOBm1Rq+t/CTJNDvgBs9i5tYJ0LldtKgHCpSY0HKuFCWDTyAXF+8fzujYMxHRPF2Pg6vEyj5u8rHr73jY= 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 1776551702066351.78931019740264; Sat, 18 Apr 2026 15:35:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFR-0000KW-Id; Sat, 18 Apr 2026 18:34:45 -0400 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 1wEEFP-0008QK-9A for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:43 -0400 Received: from p-east2-cluster1-host6-snip4-8.eps.apple.com ([57.103.76.101] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEFN-0005G9-LL for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:42 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 22EE718000E2; Sat, 18 Apr 2026 22:34:32 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id EC7061800200; Sat, 18 Apr 2026 22:34:30 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551680; x=1779143680; bh=Jrr2HbYb7vJ4wfjMglfbzSz74bDnkcrrxHCDfoOvAtE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=M4lO701fFWvcEOuOyjRpdDBSe23wd7QSkE1l/XZNL2gmrvI31nP3d/By77vo8EI2CINCHzREld2sE/vj2ke+WUfkkvcu57r34nawYgHwOSP8mM+TUrxvDNP0l0BQ406DRm3t3Do1rS4J9cFW7TIk3x+Vfr339ONQkEwDmVck57fsE+jd9dal0+78v40QU8/1KIQwtuqNRPxSqkdy1T0q1EjIq0guoGq7K+o5yj9dZ9fv5oJMfj1NWNGk7VunXjor/jQcEyuuR1oS+NHSk2ksum/CI6ramd4ZLS5R+AVcHah+YBGa+U+Tn9ErPSA/u0ZgVKJf1h3xBaimS3fB04RTPA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 37/38] whpx: i386: intercept CPUID 0xD too Date: Sun, 19 Apr 2026 00:33:19 +0200 Message-ID: <20260418223320.51330-38-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: fYKU3_LEMS1ZFi5XLamKHf63XH9gci88 X-Authority-Info-Out: v=2.4 cv=L6MQguT8 c=1 sm=1 tr=0 ts=69e406fe cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=7r31mvdhAh4OVJ8YR2QA:9 X-Proofpoint-ORIG-GUID: fYKU3_LEMS1ZFi5XLamKHf63XH9gci88 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOSBTYWx0ZWRfX/jUqKB2fB3bc FkRh0FzcuoYndeD7o0vv/8xYujs+fxoqktvTRt73s4JL3NdbI0jBNw+GHeGjtvfr/duo0v/LpMT IiL3Sefbq+HpeZTZEiN1i1P550dlc7tweFyFouhkGC0oCSz67qTf4OSf7rr0rd1Wtpo/PZpB46p zsOINere2YOnVqUJwdxvhF8oIsbVBVwUOlfTY1yssluroavK57BjELLJs2JRRx+wRbuybqXDco6 8qATku8WKITdd+OpdcNq+PSI/xLpb2wYUfghAnX1Qr4MZOE5Nh7/s4HUWpv/WN62KHlMHKMvmUG uXlGNwo0TwSFJDeXZm9aoGDEl7TmdhKcu9Vfr7TUqUjlhrOhl5qdUDGTVD6qtY= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 mlxlogscore=869 adultscore=0 bulkscore=0 suspectscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180229 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=57.103.76.101; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551702502158500 Content-Type: text/plain; charset="utf-8" To have a more accurate CPU model. Signed-off-by: Mohamed Mediouni --- target/i386/whpx/whpx-all.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index e79d085da8..d50f0a57fa 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -2565,6 +2565,14 @@ int whpx_vcpu_run(CPUState *cpu) } } =20 + /* CPUID[0xD,{1,2}].EBX are dynamic depending on guest feature= s. */ + 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) { + reg_values[4].Reg64 =3D vcpu->exit_ctx.CpuidAccess.Def= aultResultRbx; + } + } + /* OSXSAVE is dynamic. Do this instead of syncing CR4 */ if (vcpu->exit_ctx.CpuidAccess.Rax =3D=3D 1) { if (vcpu->exit_ctx.CpuidAccess.DefaultResultRcx @@ -2866,7 +2874,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms) WHV_PROCESSOR_FEATURES_BANKS processor_features; WHV_PROCESSOR_PERFMON_FEATURES perfmon_features; =20 - UINT32 cpuidExitList[] =3D {0x0, 0x1, 0x6, 0x7, 0xb, 0x14, 0x24, 0x29,= 0x1E, + UINT32 cpuidExitList[] =3D {0x0, 0x1, 0x6, 0x7, 0xb, 0xd, 0x14, 0x24, = 0x29, 0x1E, 0x40000000, 0x40000001, 0x40000010, 0x80000000, 0x80000001, 0x80000002, 0x80000003, 0x80000004, 0x80000007, 0x80000008, 0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001}; --=20 2.50.1 (Apple Git-155) From nobody Tue Apr 21 14:38:20 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=1776551776; cv=none; d=zohomail.com; s=zohoarc; b=IihBm/s5FMUlvVxkyW/m8K47FjjGnctBSGRf/TWLHRCecS9E2oqSL5d+wMyZKWrsB9oTBfJjJnjpVKCWvouXu1NKjamwMyaMMsFt2VQ07GSHZCSPjLlzuHwtStlVHEeiVx98VCT77shyc92LFL5LmAxd0BwVhKrd5BTKNaIQbT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776551776; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=807zz0/7sYSsB/HXM1SaVwEK4Bcpla9/VhldGOyRpbY=; b=JQo71XYwgTzwujIfY6UGkzX9pkPHkhq8ixiuZGpeBlvVX1Jrbi6QNXuGAQ8cYs/rvD1N3RyugpoK5qIcaujVgO6tW7lbmgLfX6DxtiJ4N3FY0wb0F1kEhQokGEX1UPMRpclnqCKWDzI1ng3rggA4xoeB8H04I32VWw9e44Hm1j0= 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 1776551776402103.95373284093273; Sat, 18 Apr 2026 15:36:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wEEFN-0008CI-0B; Sat, 18 Apr 2026 18:34:41 -0400 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 1wEEFJ-0007u3-HM for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:37 -0400 Received: from p-east2-cluster1-host9-snip4-10.eps.apple.com ([57.103.76.113] helo=outbound.st.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wEEFH-0005F6-Sf for qemu-devel@nongnu.org; Sat, 18 Apr 2026 18:34:37 -0400 Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPS id 7C6EB18000B2; Sat, 18 Apr 2026 22:34:34 +0000 (UTC) Received: from localhost.localdomain (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-1 (Postfix) with ESMTPSA id 9CF8F18000B4; Sat, 18 Apr 2026 22:34:32 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1776551675; x=1779143675; bh=807zz0/7sYSsB/HXM1SaVwEK4Bcpla9/VhldGOyRpbY=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=TVEtyC2jzYjMIdwyCFdVcCztJ+Z5H8DU2TodVSORS6yCevdHpxg/I16eBmWlM/k5HUwSz7OO/FdxZrMuOQR60yzu5jF4ZCKIUOZS+h30lCcIZkXvvn2Dg2bNo92swURFA2g95i/01UdERvZdZyVkZgqzm6y9zGDr63l8cK64mkHX9C5JzCz3YQjY5cxstXFBKlTFZWvqs85rFewH+/xKPJ7Wc8o6CYDYQtywlLtyQeDOhRlpxr0C5U4l7sMs3KpMLFsxWNJw7mk6FmCouJnBHN+QFDrvvplrztiX8G5En3+hcgWcM73tJkKhXo7/p/LUEXbiIaMGKaxFKKAc4np73Q== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , "Michael S. Tsirkin" , Paolo Bonzini , Zhao Liu , Pedro Barbuda , Roman Bolshakov , qemu-arm@nongnu.org, Pierrick Bouvier , Peter Maydell , Wei Liu , Phil Dennis-Jordan Subject: [PATCH 38/38] whpx: i386: documentation update Date: Sun, 19 Apr 2026 00:33:20 +0200 Message-ID: <20260418223320.51330-39-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260418223320.51330-1-mohamed@unpredictable.fr> References: <20260418223320.51330-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDE4MDIyOSBTYWx0ZWRfXzM5660FGPlj9 ibFjL9TqC2pLSTtBvXdLENeT2+XQKkhuxQeP4asQLQovBJM+OIVSIbKt4Rq/4BvbuJexkPtkTI7 WfOYo4FLGLYgo/X0qA59iDXmceVzSxq9Tdzp38Fstc6ekIr5TG85cWasYjY2k+nmf9USjZe2/Zt KmsJsj1kCPILKAkOfqmLseMRVhymiKXCjcsUZrJ36grUrfbzAo7PhWd2V2wdrOfk0hwaWSb6Fcf 4AeRZ7/MHWd3Nxs9AIReDqQ0pXxkbBMvgeemeWpG5ehBceUpBg9qQdFp5gl+/VEgDcuPVyeEKOX J+w5K1Q1u5CzW5nmZoXfTbYVIogv+RLFfK5hTkNPH0voifTQX3U9g3DJN91+j8= X-Proofpoint-ORIG-GUID: pxljc2Geb056nBLqDszJi9NQoVgEbJ0o X-Authority-Info-Out: v=2.4 cv=YvwChoYX c=1 sm=1 tr=0 ts=69e406fa cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=w2p0zGFWpCDavkAFAbUA:9 X-Proofpoint-GUID: pxljc2Geb056nBLqDszJi9NQoVgEbJ0o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-18_06,2026-04-17_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 mlxlogscore=690 suspectscore=0 mlxscore=0 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604180229 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=57.103.76.113; envelope-from=mohamed@unpredictable.fr; helo=outbound.st.icloud.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1776551779156154100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Mohamed Mediouni --- docs/system/whpx.rst | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/docs/system/whpx.rst b/docs/system/whpx.rst index 3e1979028c..8c9fea883e 100644 --- a/docs/system/whpx.rst +++ b/docs/system/whpx.rst @@ -96,38 +96,18 @@ MMX, SSE or AVX instructions for access to MMIO memory = ranges. Attempts to run such guests will result in an ``Unimplemented handler`` warning for MMX and a failure to decode for newer instructions. =20 -``-M isapc`` -^^^^^^^^^^^^ - -``-M isapc`` doesn't disable the Hyper-V LAPIC on its own yet. To -be able to use that machine, use ``-accel whpx,hyperv=3Doff,kernel-irqchip= =3Doff``. - -However, in QEMU 11.0, the guest will still be a 64-bit x86 -ISA machine with all the corresponding CPUID leaves exposed. - -gdbstub -^^^^^^^ - -As save/restore of xsave state is not currently present, state -exposed through GDB will be incomplete. - -The same also applies to ``info registers``. - -``-cpu type`` ignored -^^^^^^^^^^^^^^^^^^^^^ - -In this release, -cpu is an ignored argument.=20 - PIC interrupts on Windows 10 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ =20 On Windows 10, a legacy PIC interrupt injected does not wake the guest from an HLT when using the Hyper-V provided interrupt controller. =20 -This has been addressed in QEMU 11.0 on Windows 11 platforms but -functionality to make it available on Windows 10 isn't present. +As such, on Windows 10, using the Hyper-V interrupt controller is=20 +disabled by default. You can enable it via ``-M q35,pic=3Doff`` which +disables the PIC. In that configuration, using a UEFI is recommended. =20 -Workaround: for affected use cases, use ``-M kernel-irqchip=3Doff``. +On this release, ``-M kernel-irqchip=3D`` is not expected to be manually +set during normal operation. It remains as a debugging option. =20 Known issues on Windows 11 ^^^^^^^^^^^^^^^^^^^^^^^^^^ --=20 2.50.1 (Apple Git-155)