From nobody Sat Apr 11 18:37:59 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=1775589867; cv=none; d=zohomail.com; s=zohoarc; b=JA9KBp1bYm3Rk3b7Xee7cvdN18CaKNFa5OM5CXovYqwbrpO7OkpaMmv3Ioe5crlgG44TcO/Fzrkc43uvzVm8N+OAFs6Gqaidz/TOAxsZJ63Kk8y2VH1vFIt5Gza2hpiekxRnxzpPhiK5a5Alq5HcKnTOaNpvWuE/7/bXCo1KNZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589867; 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=lH3uberNhD3suh9WjBmXdskdDCiS1Sn4tM7GRq2yB1F6uLsts/0jjzKXyP5EEMRxzV1aA8vt/U/Ja6dTEGtBVcxmATWACzzpbj9tEa4l3GccwbmO97p83H1J48eU3SybdUpYkFHoENAc3qn7retkgSrCxEKayXxlprClButExQQ= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775589867541137.79276549835072; Tue, 7 Apr 2026 12:24:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUt-0006ld-Dj; Tue, 07 Apr 2026 14:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0003JO-MP for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006l-snip4-11.eps.apple.com ([57.103.85.251] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7Fz-000584-EM for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:21 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 906451800178; Tue, 07 Apr 2026 14:18:14 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 300061800123; Tue, 07 Apr 2026 14:18:13 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571495; x=1778163495; bh=jSFEY3OW57r5Gmf0SB6G349rIgUNCT10rXc1M/CBSww=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=UIGmfFbDvJ5JETJ7V8FA8LaJGdqcEBYToMwMxka0ApLnB8sF+vgNQUz89jFaKYFNnCXE5kS2tzm63KIZSMbQvSbe1m+F/aanNALlOwqKDkVUTqiUQxPh4iuaBnbdbeu9IcOfbee5HyfW0kmtu2T0uB10bcWLwGBziHGq/TaQbroZVbaBsEwMmSb/ARJh6cPRZVVkUuT0VL6DgiyXdBBTHGbHkxGmbY4w8rpy7YHRagHvJnSjTlj8NyHtStbgncN4nkdxb7pxjEocZpj49C38jad9bsdigvoSVqxxtIXx81TBag5mVvlJn4ZE006CTtdCs2j17eLiOnw0u3WByt6mMw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 01/13] target/i386: emulate: include name of unhandled instruction Date: Tue, 7 Apr 2026 16:17:57 +0200 Message-ID: <20260407141809.16862-2-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=B4u0EetM c=1 sm=1 tr=0 ts=69d51226 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=x0iqa3ucmZZh0HPruXgA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfXy7NjJV0CQncu VMpK50+TyGz5PML+lWaeBzAY3D+YCL+LP4mC3VzErG4H9Bqn/l9nZIg+MPIKlLb8qesKKfdz7DI d0EDSqDC1KwxJ1ICyAXPy0XpSYqbywT355Lgu+Yonzmow9JgMJb5T9xyi4Cq04Tnp8J1otjF7z/ QfNr/SbVAOSLeIjh5h7/IWEfK5BnhOGmWYFmboL32z17XqnBI+iXLLt9cOlyoeAA1Y6By9pTktn lLSpB8/dNI+hppvXPR33q6d9syJS1ZbrP3AKQpwc6PBEEty/P1TEzk/MXqBAae9xK7fUE4VwE4r TbKT7qvf60HEDu/zN1L01CN1KYl8fmLuwwk0IDJT2gXylifRHF7eikc+vbI1qA= X-Proofpoint-ORIG-GUID: vYU6fsI_UukJ51yT5zelFf3rKe5U0z8X X-Proofpoint-GUID: vYU6fsI_UukJ51yT5zelFf3rKe5U0z8X 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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 adultscore=0 mlxlogscore=900 suspectscore=0 clxscore=1030 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.251; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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_H5=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: 1775589869168158500 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 Sat Apr 11 18:37:59 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=1775590678; cv=none; d=zohomail.com; s=zohoarc; b=EZ8CnRUsTE1PVf5JTHouABDM1w57Tv9dtf+5MLzGRKs8vZdAgIgxm3mfatgYOAHnztd4nv18KHLGlxMzNwsgI8FVkcCcdU497flivYKsnYoaM/FhmJtF+rgIIomZMC6a2/U0SkXzY2xd8PE5BRxc47ctIzwGhDP7XyHkMw/93ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775590678; 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=J8RvBJqtXcfJpGe5hN3K+hAPvTlPmPBgcagZ/EKqgqQZup+KbOCCZ/BQUeVjzR/iHrwN/oSo/cPBc+qh8boKFmPHPJSh7Id09hikjIrEwfHno/fLVlSQasBliYaFGv79a+6FXphxa2MEJp/ABSSqdjVUj+kIfzkCuHh0ICrWpkY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775590678842789.127575367191; Tue, 7 Apr 2026 12:37:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABVH-0006ss-FB; Tue, 07 Apr 2026 14:50:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0003Pl-MS for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006f-snip4-11.eps.apple.com ([57.103.85.191] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G1-00058M-Ut for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:23 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 1B8501800190; Tue, 07 Apr 2026 14:18:15 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 70897180012D; Tue, 07 Apr 2026 14:18:14 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571498; x=1778163498; bh=zl2db1VwfCW29E4LtwT7zz4buZdQP1VZYTXVu1kcs+o=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=deEWgri2vVDjLAY4hWdOJbWTfrEXKKQBk6iasDGo/l54h7LOZdWOTd3Lz0eLqLszTI0USxpVIPM4kOVy3znwnl6jlrnmWKyVuKAfYiRkHBuJDF3uK2x8v4Pq28zsSi/ouC59dU/6xqwLC3dUO0C+qwX726iZd2Ebs7ndRNLCHRvGPyyY9nlUUMoscdGycj0CCpH59VH4oF19hzcJTyuiQ46wB6Nx6Yru3i7KwEq2a9bw/6F3CLZLT8gdEdygpEjBy/eyNth6qFouE959oCmB0AyQxygQaWkup0zY0Kb4WVWllPsAXFAxTuf0KpPydoOnBMAVxQRxLi08Z3D12Pm6hA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 02/13] whpx: i386: x2apic emulation Date: Tue, 7 Apr 2026 16:17:58 +0200 Message-ID: <20260407141809.16862-3-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfX6NowsKP+9Mpv knhJli49wHUwyPYmZXvog8JYyWVrZzfp1bnU7ilp6taZAVcmzMCiM8CupusKact1QCMNwwzOHgy PYhm/TczslS+47LaQH+pLcqe6VBcWhzoSZXSHdzjwM7G5UrcBzKTxJOakUyvjwWrG+PuumwG3WL pmRRz2PdJd0+xvtewSYH8Oc4FWEOLdOR0EeoQlOKwtO19Hh7415YEnBps+JpiFYERQRHTnCdTV0 hCcMAeCWiVd+eZvwTDIsTYCyztG6ylD1sG+dNsUqg3Qxtny+RsV/SyP81hiGWSWcT7kZuZB9qik ifZgfA9jyH8PzBK3HwspzFtPUYT598E8vfa9AZX4A4vtGYJMKels1/4OmXOQEs= X-Authority-Info-Out: v=2.4 cv=JvD8bc4C c=1 sm=1 tr=0 ts=69d51228 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=nj4AhdDZwDx412jv8JQA:9 X-Proofpoint-GUID: ki3zBTZ5cwSYWaEC6GaDoAiM1IjC6bpu X-Proofpoint-ORIG-GUID: ki3zBTZ5cwSYWaEC6GaDoAiM1IjC6bpu 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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=733 clxscore=1030 malwarescore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.191; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775590679941158500 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 Sat Apr 11 18:37:59 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=1775589555; cv=none; d=zohomail.com; s=zohoarc; b=nhCBZOwttvzYbnvxpl6CDGyguwIi575bt+L1dtLuIpEGO1BGGVfgBnCQGCEPBIRdJzasBMRYqEukKWWG3Rnx8Gll6m5j9gN3rXNtac+s+T2TABc3yt0Ib55Io4V9aLEp9oqokVV26DO0frCoPlDW+cQHlJDiqErj3pte8kfvsiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589555; 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=H3q+L35Zldk4aypjcvneQrceB1O/HI9NbNWwmMKzNuIch923xfkaNlSPfzzwlu7vc4FlA/pVFc3x9SZxIbCvFFbbjtPMf0jH68HKIVLHGdhjMP3TGx4l3olygBvGoLc6euavFClGqGyahg0S0AxVvcaEi2YpOyC4FV8/kkxoePg= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775589555181541.8841614249196; Tue, 7 Apr 2026 12:19:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUr-0006k8-Ai; Tue, 07 Apr 2026 14:49:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-00042B-Mx for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006c-snip4-11.eps.apple.com ([57.103.85.161] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G0-00058W-Ii for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:23 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 627C61800177; Tue, 07 Apr 2026 14:18:17 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id A81DD180010A; Tue, 07 Apr 2026 14:18:15 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571499; x=1778163499; bh=Ash1yi3VlTyxdP0Aar5CNwwUDY+XErFVJjyfbU7EpDA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=FCDP8BKd1YRUgknnYFDBPaFVEhc0COkqcgJSZSBMf+CMUG67o7vd7sz8MVl+3HsxBofyUGNboUUcq/RVYcNslqIA+HwppIbZMzH0N9cJumGoryhRAIt6YWEp6O9tRQ7AeFrDTR6dHd9t3luxPFRu8Kd4YUsroi3Y9rz7zxKkK/RXP2SFRmH+oKvXhi0x8B0IEztNlFOtlVYBESF1D40NLzKbns6tKKBCEksNYn/GYAhtTCLidI4PCfW7AWNRXrGPQwQmZxecfTF4Y2QGpdm1WRlStSr268iKvuW2ILj2Z5PmYvnDxTketMQKR3bFhWhP/b2B9dAioC868eHJbquLVg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 03/13] whpx: i386: wire up feature probing Date: Tue, 7 Apr 2026 16:17:59 +0200 Message-ID: <20260407141809.16862-4-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=LZYxKzfi c=1 sm=1 tr=0 ts=69d5122a cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Gr33WSPopR-aU8k7cJUA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfXxUA7sq52AQIP 5LHXinJ3sxcyQBlGA13gIRV3f89IPpF8EC9FTa6QNdf8d09hymqH3AAi5TcnNwtCPT6OITL5cJ+ mkUIq/F4QQblH3hJAfeLbUk4Uut9vRX8AIW+K3SFaBL6uoxXvmSa2C28vd4nuBLWEitHe4Z/P2S KpnB0GZ6NYhAR6dPQiUZ5Fe1HwWxtWCRRo1Zz8LrjehtvsnO36BZTjuKC8X3NUR56QZmbP4CaR7 ak5QVpBkJtSc3Kcx7h9j+68RQZgdhwJcMXROYUjmoXDmSPiRcHhsGB4sXew9xZCNhqz2Kp9BoSd BFGwbkxo/LZ1yXikvHAUjlThKuQzCF85aq0WueWThoM8vHZ4/GB4EM8FuulBLA= X-Proofpoint-GUID: hLIwM0K-BWdd4TNn5id5En7VKZfyjcN- X-Proofpoint-ORIG-GUID: hLIwM0K-BWdd4TNn5id5En7VKZfyjcN- 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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 malwarescore=0 clxscore=1030 mlxlogscore=985 mlxscore=0 lowpriorityscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.161; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775589557754158500 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 Sat Apr 11 18:37:59 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=1775590180; cv=none; d=zohomail.com; s=zohoarc; b=kyBLSMEGuwPth4p7ERKV5RMp7U1gUKS1E6/m/cNp1lGsnLT6MNDfTKfKYIfBuPvd6fHEywa1ikPXBg7p7+KfN/OMdbxsbcKqONEG5hLLx25wa76GyOCf3NZwOk0Z7VtvVpyAljKtnjkqr1lCfbzfwwYC+2YcAMulCXWFicZUz5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775590180; 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=hTW3nPUf1kaVlhfqut+MZ0FJME1pYBsEk6U1nqvKQbuzjLf1oXCfwrQVExYa0CVI8wsvG1IDym0K4F/fY7Nl/Q488Lk4Z3ofdJbPzfI0Wk6PRKDgw91GBfthfeMx3pIF6W9Sks07bGaf6TjtB19MDiK7wzcj/mPlj5axAXInToc= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775590180630614.3728399512086; Tue, 7 Apr 2026 12:29:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUk-0006av-Tw; Tue, 07 Apr 2026 14:49:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0002am-MV for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006k-snip4-1.eps.apple.com ([57.103.85.232] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G1-00058f-Q3 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:23 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id ACB391800107; Tue, 07 Apr 2026 14:18:18 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id E08A81800192; Tue, 07 Apr 2026 14:18:16 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571501; x=1778163501; bh=LeCfULzXVq8eMeXoD4HoazACVFGuCL5m06fQgObX99k=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=fQetEviDz/Z1TSdvZpZbM8EcwF3GBFf4R7xb9Vf+tnc2vrhsRef+oXuWJgC9jWTTzkHbItxMUEi4/K4tbCD80h6+7IiWB/uWumY0jWWDUGMTkS98sVPCpTMnKJM3fSQtYEafQ3aEI4Wya1hFYyisojv7mfFJwnuY/8KAyUWVL5kYCCDw+cLdAp79ehK7f9lVW1x7/SmFMviIS3ic/xw7hQc4Y4OfTcFbVp91Km0cW7KDD8+LXjFT3ADcNpJkP6ZNM0sM2gtaB9XAw9AVnEo2eGD5D12X5Ua6ikfJg/GcxpclYgfSPkfPCB/hWlyXPaBSFWze1dPim9JwrK6h2zg1Tg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 04/13] whpx: i386: disable TbFlushHypercalls for emulated LAPIC Date: Tue, 7 Apr 2026 16:18:00 +0200 Message-ID: <20260407141809.16862-5-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: HHvBL6j8nU7t3cxlIND7nOYGseoCf_2L X-Proofpoint-GUID: HHvBL6j8nU7t3cxlIND7nOYGseoCf_2L X-Authority-Info-Out: v=2.4 cv=T5CBjvKQ c=1 sm=1 tr=0 ts=69d5122b cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Rm0zj2O9plGGl-KjdfMA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfX+RMrl3cq+uME zOWAlH3/m+9wLXVqodcb24FtkAFTRKz1GYFGyPHzyCtR5iSxELVxRf4fVrI4hKH5jrHOf3yk9Oe rRS50UsjRXoFesxqEFylXFSSgIiwu2LsT/P0nuYVeSaMvrjzdrKPSkadgh446r5cs7rWNVvyf7v 2K49QP2jYaDOwkA5o6cg4tyAGDGg/tnCQv69Sx3jFKg/sRbs5cZco7gn5Whu78gll2UTAfEJJP5 Ee6+y0rad2A+XwfRkABhM91zYsBKxMzn37mbfObSbB7NIhTwEND/ENOYqAdbXGRt4XXsP60d7Cz d938rDKOvVCB5II+SreeiEJBAu2kWGvjOMbUME/ianUHwF3GfOGizskEgaMTfc= 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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 lowpriorityscore=0 mlxlogscore=709 spamscore=0 phishscore=0 bulkscore=0 clxscore=1030 suspectscore=0 mlxscore=0 malwarescore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.232; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775590182972158500 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 Sat Apr 11 18:37:59 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=1775590205; cv=none; d=zohomail.com; s=zohoarc; b=LNsf4/Rlqzp1t8QEU2L+m4TU9uX00IC4xKc/Kqrrsee+EpoOojma0ioSnxihb7tRlvE+f3nyXC4vr5dhB6LekfIhu3CLU5J0GqiaeVmN9wJWB3EyX1mGu3NE+7gSUF+cR1RoEBPPwVGTtJXmITNcqaPL9BpkBBlLhj61STrt4mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775590205; 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=PIpNT8/rS6Apxv5OnjNVGkXK/Z4TEo0+1C3xU8fM9+fNmchasbPM74Tdk9Z1DMpGlU8BQDPaMMQCmw8KCLBuZq6ECnAUGXHGql26EmR7QvYgAil7zUR+VWcQYoO378+qyIRCbRrEnQ4YQXsKbZVEpLKMIr2s3OY0/nIQVCnE5ls= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775590205361862.1267778580282; Tue, 7 Apr 2026 12:30:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABRP-0002qG-AY; Tue, 07 Apr 2026 14:46:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABQt-0002em-F3 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:45:53 -0400 Received: from qs-2006f-snip4-5.eps.apple.com ([57.103.85.186] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G4-00059G-HI for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:25 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 329341800180; Tue, 07 Apr 2026 14:18:19 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 213011800109; Tue, 07 Apr 2026 14:18:18 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571503; x=1778163503; bh=dugTy6Mycl0V8PO55M7zjkrIKW6irE2gkRf+Eg5CDxE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=ckhBIy3iDjPiBdBJk87Ecs78e/79xL4wf+KFNhGA8PfTsLcNNd1majJJB6IVXdH79i2TZT+lRJ3JYui7pcwA4CdQnc1bE8ygqzzJHQJz28sMonSkPMfoZIbgeeoQLmiYt9wEs+1REiD91oyyFMUo7CukuWSxdUVEtVBJSviLPNolp9jdwVgLIiR2MsfZv4IGoyiSR9t282wwpW7deWXl9TGk4wEKbmUgOlB4T+XoR61maMTdaLTQqmbSeuUXk1ovvJYAM6GFe6Zk6jcAcd0jXC7cSkxKLnf2SIgdgTbr8B9BLkFsRo7SxyW1vxbb8TncJoCnogQ7LiWsDgRChc4OqQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 05/13] whpx: i386: enable x2apic by default for user-mode LAPIC Date: Tue, 7 Apr 2026 16:18:01 +0200 Message-ID: <20260407141809.16862-6-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: RjACTSaADDZUR_HJNvlitdzQ1smywFn6 X-Proofpoint-GUID: RjACTSaADDZUR_HJNvlitdzQ1smywFn6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfX7mXCM6PhnwCM V+amG9iAOcQa0fYFPULoaW5rXMfG/mR6VXWw3uyHfBzDXNEBLOM38t2gPwO0PzgQOq7X14a6Lx+ skMgp96RSVcdcg/B2mvl6USn+nwFAMa651Zgm/nO8D8TwqjLb9x/qqpXkxbfqCjXTz36I+MRhZP GbQyKYdqVoJTW5TYRJW7gE8Wq7YlenHOQAgxM+nFGWy4BF+LI4kQZTbJLap4SNo84HPXUQEd20W 6YH9WL17To1AVjUPqtliy6eKQ6LHi4Q4PMc9wTZEQi8hYpaXZH6aWR6Xb1jFeZ9YtFD0bGwauI9 isVPQb7NZ9J74jZqR9/yCpdL73+4ykR3gye1EZpVsZoBEhjfMQ7MPGoMgQFSws= X-Authority-Info-Out: v=2.4 cv=RpvI7SmK c=1 sm=1 tr=0 ts=69d5122d cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=uAk9FrDoCeqUxh5yT_MA: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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 phishscore=0 bulkscore=0 clxscore=1030 malwarescore=0 mlxlogscore=999 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.186; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775590208521154100 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 Sat Apr 11 18:37:59 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=1775589814; cv=none; d=zohomail.com; s=zohoarc; b=jqcb84HwcoWYajP1lDmWufBsJD0ck5G0MC3qufHwR73ZQK4NZ/8pz2UTip4bluxXv90ZdgqaIG7+LwKhhkuurI6m0fbmHznzkDmDenT0kXywD5AGSKz3dYXMBvwWBxQib3HRpqly/zrAEZw787sgxLnrPIowfDmtWfoanMYLvfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589814; 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=JKu4lOeUiA93uedaXjB7yB7x6Es/ZT2hcpLixIFEUCjnPHj7nf4HJmrVsWvmlfx3yEkeq4PN6GY0VwrKQEVuGEWQXajyxmcejJ8zL16o4MxfpShdbMdvP3DWHyZ7GQsHK2yAMok6P99nHVcyY7h7gUY4+2+YDqpCuYB28XDCQUA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775589814073330.15748154920107; Tue, 7 Apr 2026 12:23:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUb-0006Vf-0i; Tue, 07 Apr 2026 14:49:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0003uc-L9 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006g-snip4-11.eps.apple.com ([57.103.85.201] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G6-00059P-5p for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:27 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id C7A591800133; Tue, 07 Apr 2026 14:18:21 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 618A81800181; Tue, 07 Apr 2026 14:18:19 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571504; x=1778163504; bh=oQob0705w1vpsKwSbilmxpp8KQiyruObQqebQ5RZ0Dc=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=fyJ3Q9ZukWkhmXY6Vw2mQtsQNA4k7dosCRTh0qhuGe+1dfzST6NVTXIpK3OC8eTZagC94EYB/dBWD2r7kFwho7GOoF2G0e9F/BuEE1kJzHHL5YmAIauhb+EjNNLXQ8KVMqgxaAMNWOqUas5MDaqm53y+ADYSJJf7FJAy2SOjYKTDwOB8WuyFgKgtqfUBXBlr+AegyPsTb2QJp8xNrwQKpivttmdb1AIAoo3bIjFpD0Vvb/jFdy8d7oIL6RSmOJcIAjQTQe5Ge+wMqgppZYn+yrNsIx9bEHq4xnVr8hby8tpN6+HitRLbFU9fGZud2Ub9661dFZGFbtsQ+AJIwb7oGQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 06/13] whpx: i386: reintroduce enlightenments for Windows 10 Date: Tue, 7 Apr 2026 16:18:02 +0200 Message-ID: <20260407141809.16862-7-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfX1qZWK8t4OJAh /WpxV5bBOYGaDavSeqzq+fIGmzEE30Xxc+k0YrSG5NeaVk+r6UJJiAAxfXL/8ffI+Z+FSpiK2TT n6YlzlBknb3BEYFFdn8pgAslye94uM88FCA9381W8EgGtywExIGVOBt1xovqq0BekZtCNtI190j lTpo/wVvC8Iux6VCLT8fzXdeOhJyqC03tXPdWa0b0eEJg3eKuD2+f7xG1Z1X35R7ERY5dE9d++1 vpz6imn/aVxzX64y8XTN8Bp6z8Ua7e9GsHP3nBcSTYZtaRmMQfhavQuq5G6L5JpeF2RrE46xgCf gH4poulSYBjgYSmSRfCFIuTBvep9Q+2lsmN9mhiYVOWxTYS2nh1d+mRB/OHIx8= X-Proofpoint-ORIG-GUID: rs-LssNGkjuP91ycWxOK7j7Rr3cePTGY X-Proofpoint-GUID: rs-LssNGkjuP91ycWxOK7j7Rr3cePTGY X-Authority-Info-Out: v=2.4 cv=I/pohdgg c=1 sm=1 tr=0 ts=69d5122e cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=hfWBbujXMTx1PmRkPVYA: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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 malwarescore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.201; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775589814946158500 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 Sat Apr 11 18:37:59 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=1775589609; cv=none; d=zohomail.com; s=zohoarc; b=m6sKMl+zWU0VrSaYv9eCeNgkgYZp/R82ZLPAQdRqGX3AGA/9SXtA4TKeHLDUM9VlWjFo3yNJV7gLiQll0fia0KevqmTLnl0gI4uHwM1rFQ01u20kRWyDgn2LUQvaINk0tfwuCzlHoRs1Mq8ZTg1V1Myj9k1Z1RdRTcCFOuhwBU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589609; 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=6tmGSEaUrE0Q7MlYX6psbx8TA0g5EcgDAZR7bSJpGEE=; b=X0dCRbDNxzrBYXtvkeCNN+uLzcreMbi02OnIQhGg+cuvbX/hQrg46buw/EYzeCpI+06+995gHj/JutCdz1a0/hYhCoOQcc+P+6lc3Y/D6OdrZ6RSQkk4D7SJx6pSdr7AymWKjB7zO+aHO73qFlawz8FKx/HDUkFkMKf7Ju7Y0EA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775589609195735.2805748447436; Tue, 7 Apr 2026 12:20:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUq-0006jD-O2; Tue, 07 Apr 2026 14:49:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0002iK-Kq for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006j-snip4-6.eps.apple.com ([57.103.85.227] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G6-00059R-5b for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:27 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 982C718000B8; Tue, 07 Apr 2026 14:18:22 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 99C0D180019A; Tue, 07 Apr 2026 14:18:20 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571505; x=1778163505; bh=6tmGSEaUrE0Q7MlYX6psbx8TA0g5EcgDAZR7bSJpGEE=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=D7mhpOiQa55B75wp+njK62Qx9Oz49f9iWWkNw/gdryzypKNCTcub6a5vCNsoAd3AcVQ2lrD+JjHoo61r4cg82mBovUpNO/9KyjMim30sMcUdx/4cvlDSCur3BW9COUcGanBcGKPvuj/YyYHm+LtD417cULHNXPMVwIviERx2gO/DY9IFNuR2naxCY5XPdZmnig5hD5QL8KawbJN4HiwIBj21KAtkTl6DsDdlZZfXZQwPjZUvtNhNfz9A1beUmAlQx6KKcrrHjyf35wjs4mA1p5jDxAwedWWebMZCKLP9dMPxONMveJG9OAQp0GAo7xtcsXBXD0+zWW6UMBZXr4u48g== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 07/13] whpx: i386: introduce proper cpuid support Date: Tue, 7 Apr 2026 16:18:03 +0200 Message-ID: <20260407141809.16862-8-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfXyKKOXW2H9DaJ hAF+eyedr2Rb3JpT0DvqmuOb3MCPAAINPXeYMUYsp1VdysO6yypQTUcsU4iP308w+dukuXZFTVA gnY5D3TZaQnyLwOV3qKujTGZjjklTNxdvch+3tyeyMXhxM57hOfr42za/FcyZvU/iNb/AFTykDx BHH1qwOTZNJ47HOd89DSQe9/XXKPp4GHgCF9NQDbnf55uLOgOdQTCr2pksjcT078hsNvMyqLpc4 qPnpBeoS4Vu1DobWu2qeXTZoFchomaABZjnF0XwlyLtX0TXXDCEygkXZS6lwkzbSE3/oBRU9Voy mKgAOCWMEAcyX3f+Zf3c8YJ8MS3mH1BzV1iWZGZjK5mUH17sTPtjO6CIOwZMOg= X-Proofpoint-ORIG-GUID: V4rqMbyjpvREpansZRO9arDBRlVTg7va X-Proofpoint-GUID: V4rqMbyjpvREpansZRO9arDBRlVTg7va X-Authority-Info-Out: v=2.4 cv=I/pohdgg c=1 sm=1 tr=0 ts=69d5122f cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=n8cRCUxqL_yedgTzvKUA: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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 malwarescore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.227; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775589610950154101 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..9827c93df1 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 Sat Apr 11 18:37:59 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=1775589655; cv=none; d=zohomail.com; s=zohoarc; b=VUIrkEkAgKan04NVtaG5D7o6WUvyDc0s8LCMfHkLT47Ym9WD88Mkkp6zN44vC3DYfaD/gyOsCR1FrQ/kVQfmnc8alHoKhnVPQCQmTjCADKR9bdc/Io574izYKW9P+8Q8IEcK1S95I85dJFfkxAFFI0j1ooy2Il77W2coa8Z39RM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589655; 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=T/ylQnS/te0fMXN5QyRAvae93avWDOZqU0zT/KgDwLQ=; b=de74mkKP6NOwLZqVlV7vSGwV/wgiPi2LYvdOfV5GuQ+XRbYm16a4JQ9v/KJif9k+kvFCbJr0TjI7oHTXHO/wG1FZv14bL02dzZVFDHVAbCzXK87el2iqKhJTbA6UQvfzmOZneDs9BGWQX0QIdKoFYVsFUkQ0AY7R95NwweASRVM= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775589655429659.56750246686; Tue, 7 Apr 2026 12:20:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUt-0006lm-Iy; Tue, 07 Apr 2026 14:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0003xC-Ix for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006h-snip4-10.eps.apple.com ([57.103.85.210] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G7-00059g-DS for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:29 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 8AEB91800109; Tue, 07 Apr 2026 14:18:23 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id D374C1800160; Tue, 07 Apr 2026 14:18:21 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571506; x=1778163506; bh=T/ylQnS/te0fMXN5QyRAvae93avWDOZqU0zT/KgDwLQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Pv2bNqGZX0cabiZJZbYHvniM2IR/ovff8TkV2dXCTMLm7q6dDSJrIykEuq2PNRsPrGwmTCsviMY4b2zaN8w30TPwhBU8aUNFY22r/cLMjVJkfJro9V8ifeGBl10xK8HYduLMH+ac5DYu/BFLEMgg0pWfsX1QwviId0hhsYsWe0APOykA7Cbuvjikv+INty4ntObfuN4jP6YaTYeRNTs/v2RfDSnCsop5AK2vdgZASuG6GXO9tc3aiP110LvtjUVaMA+Jl/yAmj5Mvuq2fA8EkVH1LjOstm45EQhZQELfcC2cVZMXpAWyNaUdz7xYAntF14mFTK5Emh//il0P36ospQ== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 08/13] whpx: i386: kernel-irqchip=off fixes Date: Tue, 7 Apr 2026 16:18:04 +0200 Message-ID: <20260407141809.16862-9-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfXz++1crmV8DaK lj3av04D7kqEEeUYlrx0jlVt2ocPXbXlc2wFP8CMk5lJdK0OcRw58PSRfdpJ9+te9AjvlWF413H MFqiQXfrL+xGXO999Hw+NUJuYXEwyVkDSEcLkwZIKw1USu8mYkaYcq8P5oxEUvbGzaZwAAedU7c 5FAyGYpRhoUyI1qVewVWK2sBIAqiu0kFaMa/NeTqpgC99BAidqOKfABJ1FTiu40xNGC4winuBKr u+vGUbOvrdrsKAI/OzKEdMK8YYag735Ibx96fzrNK+K6zLMgaU93CNrEBBY7scBRYL8gWwEJDRX SQ4TmxCzMwtPjGkrwY6U2zB7ZE1sMBzYtXCtC5Kv9mvcWyAaN7TXwAPOkrfHhU= X-Proofpoint-GUID: gcj6y5iMyQrTSLDJLj-NwZ6f7yKbpM3M X-Proofpoint-ORIG-GUID: gcj6y5iMyQrTSLDJLj-NwZ6f7yKbpM3M X-Authority-Info-Out: v=2.4 cv=f9FFxeyM c=1 sm=1 tr=0 ts=69d51230 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=gP1GEkNOX-MqffGxZ4oA: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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1030 phishscore=0 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.210; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775589658603158500 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 9827c93df1..62542922a4 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 Sat Apr 11 18:37:59 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=1775589724; cv=none; d=zohomail.com; s=zohoarc; b=Ls8cJe7PhWszZo8NbwBe+cQNsX4IVp2t0c2SJuoZOfRtzLh4Muh/YEVg9SByFPBcsLlOYFRmf1o5zisBZGsDvrCHUKSi5LkKGbJ+yedQDKyEZS0TfITNs3r0sqIvp6uTsxyf6tCyWLI+vOOzJ/Dq29sqmSzjhfWEJNBKi1dJYKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589724; 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=9UzhbHGn3KNjJvwbSrpYXcynAdkRNKmx/7n4duVcxcA=; b=oLkjax8bbHEuC59TGK39fLiKEpqkJQVUyr/s4oqUHpyWAjR8ICxt1GHH9hqpYmyVWGGT+QfUovAE6JEdi4WFaJ8HkcVXOiCRNbzSXFULaejCRfz4HkSImXKEMTpyXviQz5Hjtb7wUt8zFPJarnJqmSM2N967WmUGpxbWPv0QuUI= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775589724197996.9459324564309; Tue, 7 Apr 2026 12:22:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUv-0006o2-I1; Tue, 07 Apr 2026 14:50:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0002em-K1 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:18 -0400 Received: from qs-2006h-snip4-5.eps.apple.com ([57.103.85.206] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7G8-00059m-I2 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:29 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id DEAC6180018E; Tue, 07 Apr 2026 14:18:24 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 154B91800162; Tue, 07 Apr 2026 14:18:22 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571507; x=1778163507; bh=9UzhbHGn3KNjJvwbSrpYXcynAdkRNKmx/7n4duVcxcA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=fePju6CVOt4Y+lpulM3PNNFMG920b5K9q1U3OKRVkTDGQwJwmGyj/SeoHiLYSKj3Cb0hM0OxuK4DihJfaCICPs+Ow4x3FgrOLJKkv4yJa2FXFlc7Kr13ZkPoLLfUHhoO1VcpjLuEAt2CCPNnnxjIVV9+d/SvXqGnKzK2YlTLEuPgdvd3udEeM5fyWvgrNAvI2NwV6k8U9EYLK0QIcm+uwZE9RWEl+wuAr4wPxM4PLFWAAnAxVCdZhaobdEdiBP2E+zccRQ77gW1AeH1IdZ9z2uIWh7A6yiKGvyhdApNt3iqZf2mrxa7eU9lV44tLUqQXd0nT+OCSdEoYofbwwdMXbw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 09/13] whpx: i386: use WHvX64RegisterCr8 only when kernel-irqchip=off Date: Tue, 7 Apr 2026 16:18:05 +0200 Message-ID: <20260407141809.16862-10-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfX8fLFBggUnyjL jEYFHX5aX3aROGqYFaMcc+uQAlF52I+Fw5xYWBOdvQFTWLuiK51eXmiVG+9UdqIgBlf923qyusN RvwXaRFBtNfsNdW1TVKzUUIdbU5ZhfopiC48anF8HRa3hQ7VsIhjdVdfi2mA8EjqBEc3KssXHQB cS21Nc6e/oy5+rIideJPJ4hTtFqJ21PRUj5yQgglEds0tv+G1GjOzFplVGEIHAEkYJCuxQRjgei +s60vFOuERV6yT2zyB9CjOY/4/Wj+Y3Nu3eXpP/5I/DswTEW02NpctB+5eB1XeFhV3vML6wAkYX xe1d5C1Qu/w8MqHFTEzvxC5k8cwUyOpMRazZQiK1M3JiTDgrOUVmDHKwB89jsQ= X-Proofpoint-GUID: XPz25bKZu085xQATc-keOKb_R39Pj66R X-Proofpoint-ORIG-GUID: XPz25bKZu085xQATc-keOKb_R39Pj66R X-Authority-Info-Out: v=2.4 cv=f9FFxeyM c=1 sm=1 tr=0 ts=69d51231 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==: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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=866 clxscore=1030 phishscore=0 adultscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.85.206; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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_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: 1775589724540158500 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 62542922a4..74b94b799e 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 Sat Apr 11 18:37:59 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=1775589955; cv=none; d=zohomail.com; s=zohoarc; b=OX3KI+/F8va7EyRoRUQ6jaScWV9mn3VJvnWIG3Ig4maGR6lncDvwpna8fDZG9ribc68pR7UWp7UodUew9VPmgzNAbKLEL31ahh0pvSQ3hDC2WQiraNDqPhTeOOKxenkdnUgHlv5tEOfVD//YgxOhF73IGLxm4vatCr4Q0AFUIi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589955; 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=UDUDDhSNImOkwjgegNmDYFGV0Ws4YLT0V61YNwqVXjA=; b=YL9PUTbO1jGVuR0MsM2DNZpQO4hvjOLtN9sTRF0Au3otVARrDKyj1A4YOSAJQESouCDUSOkOksaWZ+1P75A64zP821oFrD3XsBE38T5eRe5tercWYKnRH2SepZkvl13VWfOa5XvZTEMKQ36pNvJBUoRbbBpgmgk5nNADLqrnNWQ= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177558995559479.95906408519602; Tue, 7 Apr 2026 12:25:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUg-0006Xd-MA; Tue, 07 Apr 2026 14:49:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABT6-0002em-AA for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:15 -0400 Received: from qs-2004a-snip4-11.eps.apple.com ([57.103.84.13] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7GA-0005AD-4q for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:31 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 4E1C618000B0; Tue, 07 Apr 2026 14:18:26 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 4E00F180019C; Tue, 07 Apr 2026 14:18:24 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571509; x=1778163509; bh=UDUDDhSNImOkwjgegNmDYFGV0Ws4YLT0V61YNwqVXjA=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=Tq3N7FdpnmNLXJX0jpZBT0s+t2EvwT7yRhsKh/fJXUS2yeWOGmlC9fEF0E4eS2qHNC+Oo/eiDEOHoMP2FdXp6VmQ5a3qql7M8/AwYjyTfx2l1Bo/VEhNmiK8k8GI5+Tx2C73pfy6su9a14rwTSsugdMy+HmcK9wYHZdzQvzY1EH8Uo6pzWaSpvgv18+5nYZp5M/a82psLFl0KiPhb5Tv3hPGvH84TR8HAmNMUevJo50OM/QlWo4XJ6r++/wWJ3VZyQkBLJs0WQQoi6WpCw5WPVX8n3Vs1xxdWmCB/L2F2s8Rm+8g6UlIxlKoTMOHaS+dqSrFQirhsEMTzPVGGFI/wA== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 10/13] whpx: i386: disable kernel-irqchip on Windows 10 when PIC enabled Date: Tue, 7 Apr 2026 16:18:06 +0200 Message-ID: <20260407141809.16862-11-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfXyhGj6WSMsPAL dLLvodwltheO0s3yNL0HciUKn9pUpodkdmsEsdyfF9pRqsTN5sVgVtLy8emQYpkgOm6n5jMQXCQ lR4Gp6KZ8CWqoRrOQYakVRnXm324W70LjTxw6QnSrsRmmXtjiy9MqFZtWKxLE1c/GuRq4hB4eO0 TdRciY8AHQX+u2hPD7o+MYI2NyAOdXr4cIh+aIIpnUJrwgvqrnIJjL0MrfQjFnRBPtw6Yfi+AIL XfQdApz4zTpQZVjdmwyr5s3HA59jcS3U05zlFjHHqPd8nzXEZZCNpH86v7vbmFp1OqkSliNplKK gPKAqmufv0E1rlHC+eGyEH23U292slmc+3RB4yHyovDCL5z93TxvpbsxlfM9Qc= X-Authority-Info-Out: v=2.4 cv=BIS+bVQG c=1 sm=1 tr=0 ts=69d51233 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=nUl_a9z44qMLw6SsMv4A:9 X-Proofpoint-ORIG-GUID: oZrhKIqlmiIj_AO72301vg7aSd98f-2C X-Proofpoint-GUID: oZrhKIqlmiIj_AO72301vg7aSd98f-2C 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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=778 clxscore=1030 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.84.13; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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_H5=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: 1775589958567154100 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 74b94b799e..7c80d653d1 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 Sat Apr 11 18:37:59 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=1775590862; cv=none; d=zohomail.com; s=zohoarc; b=Acg4UTwTcWaLs4Oqh9HSeOKuTGkpEdQU//flbcJA6nocnTHekuK+SIYn2La2JRQm9clTJNuBpB6GYkJiuEsAFMyh+mKFu8fUpT/fjaqIf6ULWsEJiVoFKTgBLQiSMPObexVMDiKd+zEwJ0KiOXU2rBtLEqcCVM0IFu+ZoWy96UE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775590862; 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=G89W4sMC3YwwxzvqsgVypuGjICEkNIb9nBQsRfciAZw=; b=Vx7exkBzMnHO6p8ErcY2UvsLNvUzTNMOe9nbScGKKsOrwXuUaay34JjVPHbNxhEbFLZzHe+qqHJB/n0HvJo4LL42n8e26fs2Um2I3co/TZA3Y1v+3FXv9LT/UU4ryYmuYUayCC7Q/C9vYFz5fGFoMr2R7B5ZcEl9ilxGnEpl4lo= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775590862682915.9999929860279; Tue, 7 Apr 2026 12:41:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUs-0006ko-ES; Tue, 07 Apr 2026 14:49:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABTD-0002LR-G5 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:17 -0400 Received: from qs-2004l-snip4-11.eps.apple.com ([57.103.84.123] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7GA-0005AF-49 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:31 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 3E8F81800160; Tue, 07 Apr 2026 14:18:27 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id 860D41800184; Tue, 07 Apr 2026 14:18:25 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571509; x=1778163509; bh=G89W4sMC3YwwxzvqsgVypuGjICEkNIb9nBQsRfciAZw=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=EGGfebCzgyYMeEvdGw3oYEGVJA+ru4SgFlZb1N8YVwKfo34LX+aPum4QT1H6ZdHMQ6tNti6xoymEuOcw4YtM9EaZ7l06YJ2veJiBhw1QLEpBrKbueb12i7uyGGaznXjx2Ud7iJmec/XTajRlMRBEPl5m1PWV4XRrJuj2k55MpeAsLyE2POKrv1jiI6rybHI6CDG3UmmfMF65Eunu7TKqjIaxjl/5Be4lc38CmsqeVboCPd/CWo5OWN1MJHVG2sLNpQLPmlk0aQJlGkCznW+eti0gBIc+aurrF+8HOJ8JuwjUJAQ0gS3tog0P9S5zLyt/pm2rDiCaB3O0HljD+9WPCw== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 11/13] whpx: i386: IO port fast path cleanup Date: Tue, 7 Apr 2026 16:18:07 +0200 Message-ID: <20260407141809.16862-12-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: JsqwFwGgBY1TkEDUFMLX8cDVEvBrponw X-Proofpoint-GUID: JsqwFwGgBY1TkEDUFMLX8cDVEvBrponw X-Authority-Info-Out: v=2.4 cv=T4eBjvKQ c=1 sm=1 tr=0 ts=69d51233 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Vrzv6M8N8vcM0KmfSJEA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfXzooscxe3CZgU iK8BZQSEBwQe/jZnlONXtqAMrh5hjKXn8/Pcv7m0leX6VvXeQp9HrziKipLq1G2SrlZzT01QmE9 hZrzSj3ImPoqe3U27XHziYm5N6nMGPt8uLoOh369CypuxSwDVsQrs7VSivQzOwA2DmsJSYepR3H rCxYk3Otlq4G/EfgomR27XIb8gLeaFWX8oqsIxNIE87u+MqcwXORONvyzRbBik3H0GmfxHfhmi8 xDPnfrbSIgo+iYIhenGeeDG1x8SYaC16NKxdNQAQmwSDoAbmmxkPRnfDC4SaZKGJvJWY57SnDAP 2Q4+FN5p4q5GcqSGyme1sgMRT/CRuuBQqHj/CxgaW6UudoL2cb+LzxIH6YeC2s= 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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 phishscore=0 mlxlogscore=812 spamscore=0 malwarescore=0 mlxscore=0 clxscore=1030 suspectscore=0 lowpriorityscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.84.123; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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_H5=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: 1775590863095158500 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 7c80d653d1..61aec98e66 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 Sat Apr 11 18:37:59 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=1775589893; cv=none; d=zohomail.com; s=zohoarc; b=eGa8ddkti3WyHMI9+NZKRaIgEeqW6F+WKvAqP0Cl8r8wF3EsS8fu9NJCZlgeSZVVBKg4i/wpqV6OmPrxcDBf8XxWGqZiyP7RL+FKM3dUEJM9+ybyIN3O8xAK8EPK8maQRL75ft2T4i+wdKxDUrtEWvOH8p/oQ7SvjqhDuywN+WY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775589893; 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=zcmYD8sBYnUVL4imQw8BkyvhG03VGFAjf3wzcMF8rtM=; b=nXvA2ZF1toBWq8jkOzL2k/wBlQ2cIz6k2u7nxbHoeCFVIdZrc2dve5nrFjm1jvCsQ/Dgz703MsOzSHbIpDyRoO3vj50zO185WyHZpZmmFWbaB2TvhbZaY57+rqNJ7VZmWcXvxLJWnwEavQKlZztu3Cj4LfYGlG18/9hFplXNwOI= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177558989350210.215005745125723; Tue, 7 Apr 2026 12:24:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABWg-0008C5-SV; Tue, 07 Apr 2026 14:51:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABT6-0002eY-8o for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:15 -0400 Received: from qs-2004e-snip4-5.eps.apple.com ([57.103.84.48] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7GC-0005Ae-Dd for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:33 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id C2AE41800188; Tue, 07 Apr 2026 14:18:28 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id BBEA918000A2; Tue, 07 Apr 2026 14:18:26 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571511; x=1778163511; bh=zcmYD8sBYnUVL4imQw8BkyvhG03VGFAjf3wzcMF8rtM=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=CN57hilbY1GJPkzfag4TT6/NuPL27CUhHWsSCAzmD3asj7YndgdZK3/lrCMpxA8iGx5ejO5RQ9SkQKnu6JD7dLCx4UxfVA1goK/4ByQfQ/McFmM8PJ4nyOMtfZG9S+PPXk691dl7AWVO/YTUd0pn+vwsOoRNf/H3RWHpDyJ6ICoEauH1MEMTDlHoeUkIDiaAlJu7Zw7nhNqgi7GoVUAkXmu4o07ifpLmZSTw0HxqF176Ber3qnhvcpO6hGfSRFGLm0KUo8G64TUwwsQO3AtrrL9en1XZnOMK49IXGEQZvib9N8cw3nYF6abgU49gE9ejHlrYg08eWWrJyZBAbJPElg== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 12/13] whpx: i386: disable enlightenments and LAPIC for isapc Date: Tue, 7 Apr 2026 16:18:08 +0200 Message-ID: <20260407141809.16862-13-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Info-Out: v=2.4 cv=F55at6hN c=1 sm=1 tr=0 ts=69d51236 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=kaNVauZA35-AGszze7oA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfX+vyQVNrQ3fPe AnZfqq+5XhHGqhMDX6N2ytkSDo3f0NaM3nJGgeOZjW7Ay6XqFegINgbh9YeJ5zkW6DHWYgwlfNS oyhwAp+HC7RIBR5dd+9QkxVQp5/un/u7Dmeo1t0/ng//xP3jxQruPlJ4Kr8WEm4A6FVmFrmY9f6 O0CLoCKa98vrs0XKvjqffbtxmLQQErLJXisASFXyrsZxn7Wbk9gQT8M8u6TKjBnQf20sf02PiON D2vNP58haNFmeSZtEkTJTPUGuouIxd+0CA1liMJeLF9BUPdwjnK1HYHCdhe2FtPOHPPfnpPjDS9 vDKpuSq33ziiJ00OELNr6c9Lc4FPTavFYrsw2Qy+nwsY4oy19kPh+C9zuKdYcY= X-Proofpoint-GUID: V5fibUAqVqortwuEGVvmGpmf9QU3LAIi X-Proofpoint-ORIG-GUID: V5fibUAqVqortwuEGVvmGpmf9QU3LAIi 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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1030 mlxlogscore=815 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 spamscore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.84.48; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775589895320154100 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 61aec98e66..7a31dc6427 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 Sat Apr 11 18:37:59 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=1775590475; cv=none; d=zohomail.com; s=zohoarc; b=U2ZRIdsRZc35+aLygbtyBrmsaIZZ0UK7rNPacZHfjPK+MujsnVtmfiNdzpewA4bq0xu2vCeqgvAqalcsjsN2/vXAfmGDdTuYWiwldZLgRdi/2Fii7u/LoHEUWmogki/PE1vt2VYRu0MYtw7SbYLi/1zNBb6bQ/U9UB29ILOSN/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775590475; 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=Fwf2hc0HM6piMD7inQigrhq7YGVI+KQPRiX4MHhsvB8=; b=C5WfynOG3lSq2Rx+b//Acy1QvWVFUzauOjKuSpM+v5cmyXpEncqMS7Q9svyHTgt/2UMaYBJtNVqhHQDCXsRbW30l7n70j4tpFHx4Ox1t95K/JeftZL+xgHUg6coKQpeOxoix5TuY5ctegCRdYr4D045i7lyULdU3U+ClOf+HNZ4= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1775590475474336.7921255124651; Tue, 7 Apr 2026 12:34:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wABUp-0006hH-Pk; Tue, 07 Apr 2026 14:49:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wABT6-0003uc-A1 for qemu-devel@nongnu.org; Tue, 07 Apr 2026 14:48:15 -0400 Received: from qs-2004g-snip4-11.eps.apple.com ([57.103.84.73] helo=outbound.qs.icloud.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wA7GE-0005An-1b for qemu-devel@nongnu.org; Tue, 07 Apr 2026 10:18:35 -0400 Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPS id 52D4A1800162; Tue, 07 Apr 2026 14:18:30 +0000 (UTC) Received: from localhost.localdomain (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-100-percent-9 (Postfix) with ESMTPSA id F24C61800170; Tue, 07 Apr 2026 14:18:27 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unpredictable.fr; s=sig1; t=1775571513; x=1778163513; bh=Fwf2hc0HM6piMD7inQigrhq7YGVI+KQPRiX4MHhsvB8=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=UM/3yrGIkgNj7jgYmuqAnQr3JrbtXnM8vqfB2GhPxfY7FxxebRxxbA9spPOz2m64xREYi8PUyZuIPLd4M6GEHf+d4bGc/wxK50o7OeY4cLJlJpwD32oLG/wzc1AZKRbIS2jJTFSE4P+qDbq3I1bDDLulxuT6Ozgv4gpJGijynMPx8S5LAaASIWPe4KZmh1rsJSQKTmGs//WyoWXYygEwwqshASUcb5Gqr/CzIcc7Zg/XIHNGxeIJP8yZy8W982360+GDrrkFDIbd+RieapoKn3wPOZDn+Kmny8PRyWNq/ibi6lFUB9Y1oZM/u5C/4/PCh7BL5LNV1STL19YfdWIE0g== mail-alias-created-date: 1752046281608 From: Mohamed Mediouni To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , Roman Bolshakov , Phil Dennis-Jordan , Zhao Liu , Paolo Bonzini , Wei Liu , Pedro Barbuda Subject: [PATCH v8 13/13] whpx: i386: interrupt priority support Date: Tue, 7 Apr 2026 16:18:09 +0200 Message-ID: <20260407141809.16862-14-mohamed@unpredictable.fr> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260407141809.16862-1-mohamed@unpredictable.fr> References: <20260407141809.16862-1-mohamed@unpredictable.fr> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 1gZlW2i7FudcfQaZmlM67Y0bnWx2_PPp X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA3MDEzMSBTYWx0ZWRfX3ol8t+dfO4en FsdpHuSL8m0FxrHvqtIi/YACgnFI75BFjJf+ve7tH/FfGFGN+N9OThUxyuYbRc5eOIJbNhlZ41a iGRFDxQpcyKNpJBMlzg+9iRglatuTlgIFNH1klQqfZFLY3W2SC1NITEYrLaD0648YJZICBrLCv5 OlVE0mRwisDDanvjAGQlc5lp2HOF7+jV/lBQfLyn9au76ptZQkq3omvekAaEA7kC1MxEXSWBHg5 2xht8i7zRiiNT1fTA9gZDD828l4KHJQZlsBxezrrlUP8K3F8snEb9xNU6twqEOweUKpfUUl9tHm H+gMHAEo0XQTe9/pP/+1fOw5s+0qn5QMY0ipMFeDZQPksq1LeLxpfSsTVNXAX8= X-Proofpoint-GUID: 1gZlW2i7FudcfQaZmlM67Y0bnWx2_PPp X-Authority-Info-Out: v=2.4 cv=Wf0BqkhX c=1 sm=1 tr=0 ts=69d51237 cx=c_apl:c_pps:t_out a=bsP7O+dXZ5uKcj+dsLqiMw==:117 a=bsP7O+dXZ5uKcj+dsLqiMw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=NuKELtICf0aykZwt-QIA: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-07_03,2026-04-07_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 clxscore=1030 adultscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=667 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604070131 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=lists.gnu.org; Received-SPF: pass client-ip=57.103.84.73; envelope-from=mohamed@unpredictable.fr; helo=outbound.qs.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: 1775590476579154100 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 | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 7a31dc6427..569da3b90d 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,23 @@ static void whpx_vcpu_pre_run(CPUState *cpu) } } =20 + if (irr =3D=3D -1) { + if (!(!apic_accept_pic_intr(x86_cpu->apic_state) || !pic_get_outpu= t(isa_pic))) { + /* In case it's a PIC interrupt not going through APIC */ + irr =3D 0; + } else if (whpx_irqchip_in_kernel()) { + /* if kernel-irqchip=3Don, APIC interrupts aren't injected her= e. */ + 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 +1697,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 +1721,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 +1937,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)