From nobody Mon Nov 23 04:44:09 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1792102690; cv=none; d=zohomail.com; s=zohoarc; b=OoE7N3YWU1td8olDYtHpZytOuztkXGsjENFoVx+WhEs5i6WH0hjUHHfXnUXE7tQzthDQCWS/jnza7R4WLPa2WYoOZfE4GvxdMkxcObOqhc1dzmcV3xtHTRG2FuVTfwdLUUe2nX7Dn1+n5hPbZ8Cgi4d4+H2bkxbrVzSqsv/XPb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792102690; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dNWHiGApJYClZFP7L84aXNGH1QcEQcjuRJ/iMB90xVg=; b=mDIykUrJA9W4Og8ZGSdxkkI5VlK7z/p0VzL6qkjKviLaOQORtfYHYBco/ehkY1uoXW7KrsEKya+zOYUz5FZJqngz/x89/3yrlXLdFq1LzATZY6IXIHKtRqp+xNOGDkT0u/UNPNlfUoNdR+x8xXVcYHqu4EEp2ZKKl4I5pvvxfUA= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792102690123775.8414337428213; Thu, 15 Oct 2026 15:18:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xHTlU-0002E5-KV; Thu, 15 Oct 2026 18:17:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xHOqv-0007CN-Bj for qemu-devel@nongnu.org; Thu, 15 Oct 2026 13:02:51 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xHOqs-0003wu-6V for qemu-devel@nongnu.org; Thu, 15 Oct 2026 13:02:49 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-cd623dfe420so1842379a12.0 for ; Thu, 15 Oct 2026 10:02:45 -0700 (PDT) Received: from STA-DBBJ1B4 (c-73-254-235-207.hsd1.wa.comcast.net. [73.254.235.207]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ac9474b52fsm5893712a91.9.2026.10.15.10.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2026 10:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792083764; x=1792688564; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=dNWHiGApJYClZFP7L84aXNGH1QcEQcjuRJ/iMB90xVg=; b=Vms+eIbhpBt71zKScTJa+r0ht5ajstXlNMRBH89dFaSeczEkbsKz+vjcD8LXjfwsg+ alh75vqLCjIPJ5pERZKmEGc+T82SynsinejUfT3tPy9Fqr3fqwnl9l1at5+vi6lB7EvU YfBcut+W0BIychSR2wpg99B6bL5r3EC657zzGU7pU6GEvO+cWxisEkbz7mwVsPlJb5aI MPEEOC68M8+lUpn74gkJMXyoPjMyAs4NcJeWa+eaXy7rR2+gdLrjNEpINpSZhXD6Gj4u /IiF7JSFJcWrlEy8FpniamWnbBfUDwO37O3NiCoYhIfMu02jxR36pGQrEZbkOPBXAdax HllQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792083764; x=1792688564; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=dNWHiGApJYClZFP7L84aXNGH1QcEQcjuRJ/iMB90xVg=; b=0urUxI9bobTqPm19A6k7KJmugLXOE/f3K1ACNr8IKY4NIujJkSkjhsD/zjlxujnAOS C6CfCe0Q8/UGM36g8lRGuSG7QJuQrg8wGR2TfE3hhWk/s+nUvelzO+z00RUdiQkwttJb 0PSmyR9M73ofXGp3NnwUJ+x+cSq42cEgqI87uyezL4XEkhV3FEeuc2FntenItMor5vMH +QHqv7303KV4vLJPuv9gJptIXx6k2OT+lcjlF0Lj+b2S/2T3t6jQCEhhKFW+efdcZdz1 n9cTrgG+D9HHN1/d3i9mAYBx9xYkpAj51bZefBSGMJTcO+GzJt1rCZw7N0DBoNQ+E1rB Tzxg== X-Gm-Message-State: AFq9FYIkaoX4c6I/IIwul/0EcsuoDuv0M2Cf78owUp2ZNeqgznfmSVC7 gUoy6W80UFDLGq7HwU3OOppjlAtzrZrDHKQQrNP/1o+A8CPK56/qDEPaticliQ== X-Gm-Gg: AYBFou26I59LieZ+wPZaMQqcyNiBQZckVqmZsr65Inend7j/8PSU1hoKwoQDWFhEeAX RRXYXbs1NfvpOaNSuxP+ylDZYQtuCN27c+HPuHf2WOeQx0KQ0CX/7fon8KA2C3u33cVl7mnXpm7 O4nS2YCFt9eBX/yuxr4xTB7QCuZ5wQyw3Ej6DGx2c7JJDXsA+eSyd1Ery3gvWGwpPF31eSDY7N0 mqSd8Fphnv31uMpdH+VvTcEiBmp78s+o7iLBSZsujFPRIdh0olMlgwF33vxQPgh4pN7y/UAzz6r LVXUBN2VAoVxfvaqgsrJeRKe5GCVAkDMLzcmdogB12F4iMetg1OA9dZ017cXy/fD6HSz/hO93LI dk+CgDN1akxowS7KG+B6mJAeChF4yUJS4vcCrm2ZvlBwiZe07psLappwfppwWcI1rsCxeU5Faeq BUPjfFa+Vh98J2mbSMvfBS+mvMKLwGZsKzTae4vwwz5TEq0rozaqqjw4yyFBCJUbHyaTDmbRnH0 DudlyGv+6UIwiVUMT9/8GMBT06qwUtv247TYlZFSNK6vOG3yhjA+4HOrjxhAr8eDZUyq2X7/uyo 7HVShgWH1VkW08Bh/bpJ4Q== X-Received: by 2002:a17:90b:4b05:b0:3aa:ff19:42b8 with SMTP id 98e67ed59e1d1-3ab3a9aaab6mr18997841a91.27.1792083764510; Thu, 15 Oct 2026 10:02:44 -0700 (PDT) From: Akshey Taneja To: qemu-devel@nongnu.org Cc: Akshey Taneja Subject: [PATCH 1/2] whpx: i386: do not require ProcessorFeaturesBanks on legacy Windows Date: Thu, 15 Oct 2026 10:02:15 -0700 Message-ID: <20261015170216.6895-2-aksheynew.tanejanew@gmail.com> X-Mailer: git-send-email 2.50.1.windows.1 In-Reply-To: <20261015170216.6895-1-aksheynew.tanejanew@gmail.com> References: <20261015170216.6895-1-aksheynew.tanejanew@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=aksheynew.tanejanew@gmail.com; helo=mail-pg1-x530.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 15 Oct 2026 18:17:31 -0400 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 @gmail.com) X-ZM-MESSAGEID: 1792102692433158500 Content-Type: text/plain; charset="utf-8" WHvCapabilityCodeProcessorFeaturesBanks and the matching partition property are only implemented from Windows Server 2022 (build 20348), the same cutoff already handled for the perfmon capability in commit 68438cb3cb ("whpx: i386: workaround for Windows 10 support"). On Windows 10 the capability query returns WHV_E_UNKNOWN_CAPABILITY (0x80370300) and whpx_accel_init() aborts with -ENOSPC, reported to the user as the misleading "failed to initialize whpx: No space left on device". This regressed Windows 10 hosts in 8b87283ce4 ("whpx: i386: enable all supported host features"). Fall back to the original single-bank WHvCapabilityCodeProcessorFeatures on legacy hosts and skip the corresponding SetPartitionProperty, which restores the pre-8b87283ce4 behaviour there. Reported-on: Windows 10 Enterprise LTSC 17763, Intel i7-6700 Signed-off-by: Akshey Taneja --- target/i386/whpx/whpx-all.c | 61 +++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 113f79afb9..9a9fc7d974 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -3193,13 +3193,35 @@ int whpx_accel_init(AccelState *as, MachineState *m= s) memset(&processor_features, 0, sizeof(WHV_PROCESSOR_FEATURES_BANKS)); processor_features.BanksCount =3D 2; =20 - hr =3D whp_dispatch.WHvGetCapability( - WHvCapabilityCodeProcessorFeaturesBanks, &processor_features, - sizeof(WHV_PROCESSOR_FEATURES_BANKS), &whpx_cap_size); - if (FAILED(hr)) { - error_report("WHPX: Failed to get processor features, hr=3D%08lx",= hr); - ret =3D -ENOSPC; - goto error; + if (whpx_is_legacy_os()) { + /* + * WHvCapabilityCodeProcessorFeaturesBanks, like the perfmon capab= ility + * probed above, is only implemented from Windows Server 2022 (bui= ld + * 20348) onwards. Fall back to the original single-bank capabilit= y, + * which Windows 10 does implement, and treat failure as non-fatal: + * the banked feature set is an optimisation, not a requirement. + */ + WHV_PROCESSOR_FEATURES legacy_features =3D {0}; + + processor_features.BanksCount =3D 1; + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodeProcessorFeatures, &legacy_features, + sizeof(legacy_features), &whpx_cap_size); + if (FAILED(hr)) { + warn_report("WHPX: Failed to get legacy processor features, " + "hr=3D%08lx", hr); + } else { + processor_features.Bank0 =3D legacy_features; + } + } else { + hr =3D whp_dispatch.WHvGetCapability( + WHvCapabilityCodeProcessorFeaturesBanks, &processor_features, + sizeof(WHV_PROCESSOR_FEATURES_BANKS), &whpx_cap_size); + if (FAILED(hr)) { + error_report("WHPX: Failed to get processor features, hr=3D%08= lx", hr); + ret =3D -ENOSPC; + goto error; + } } =20 whpx_rdtsc_cap =3D processor_features.Bank0.RdtscpSupport; @@ -3246,15 +3268,22 @@ int whpx_accel_init(AccelState *as, MachineState *m= s) } } =20 - hr =3D whp_dispatch.WHvSetPartitionProperty( - whpx->partition, - WHvPartitionPropertyCodeProcessorFeaturesBanks, - &processor_features, - sizeof(WHV_PROCESSOR_FEATURES_BANKS)); - if (FAILED(hr)) { - error_report("WHPX: Failed to set processor features, hr=3D%08lx",= hr); - ret =3D -EINVAL; - goto error; + /* + * The matching partition property is also Windows Server 2022 and lat= er. + * Legacy hosts simply keep the features the hypervisor gave them, whi= ch + * is how WHPX behaved before the banked feature set was introduced. + */ + if (!whpx_is_legacy_os()) { + hr =3D whp_dispatch.WHvSetPartitionProperty( + whpx->partition, + WHvPartitionPropertyCodeProcessorFeaturesBanks, + &processor_features, + sizeof(WHV_PROCESSOR_FEATURES_BANKS)); + if (FAILED(hr)) { + error_report("WHPX: Failed to set processor features, hr=3D%08= lx", hr); + ret =3D -EINVAL; + goto error; + } } =20 =20 --=20 2.50.1.windows.1 From nobody Mon Nov 23 04:44:09 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1792102690; cv=none; d=zohomail.com; s=zohoarc; b=CmydmQcHIm8mI9DrGDzxC8Ny/HnkZvS7kjzhve+8zGrTgeTJCA0yAjTVBjP9WvFGRFy7Aw8IVPYkjoU3Ifrefb9WDsSlXgspfFTTlBe+F34nd97/Gjud4UJUGeUPIB8jJ/631911aJ4GxUG/uug8sssH8WLIG4EWGGQx+xYCJ9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792102690; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g5sCj4amkDsYs1pfyEUgpMCDKBamRT7BGjJoSHqaXC4=; b=f4Lmugvn1k1bEFu1VIpkB3h3MYj3AKIHGPWWE2b5C9dch6gPUXoUL12ZDiNwZOxbLnekNSRSN9L0TLGH6wxZE+q7NxJx+ZzZJEFDGKlwVke71HdLpPwfoWMxOyP2tJSulKfxlzshzeBkVIEH26BoJSZkBVXq5fc2VycMm/EmZmI= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792102690309556.7006671209698; Thu, 15 Oct 2026 15:18:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xHTlU-0002E4-KG; Thu, 15 Oct 2026 18:17:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xHOr3-0007D5-Vx for qemu-devel@nongnu.org; Thu, 15 Oct 2026 13:02:58 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xHOqv-0003x2-4p for qemu-devel@nongnu.org; Thu, 15 Oct 2026 13:02:51 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-cd5c9e52398so2514578a12.1 for ; Thu, 15 Oct 2026 10:02:47 -0700 (PDT) Received: from STA-DBBJ1B4 (c-73-254-235-207.hsd1.wa.comcast.net. [73.254.235.207]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ac9474b52fsm5893712a91.9.2026.10.15.10.02.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Oct 2026 10:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792083766; x=1792688566; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g5sCj4amkDsYs1pfyEUgpMCDKBamRT7BGjJoSHqaXC4=; b=HL0szVNzQ8983/R+6RNhHwEBhf7A5NRn6TWS4+xLwz52e2Q+v1Fy4Tn1tef/FX6Rr3 bbdePi3wE530He3aMeCG7P1DSrjct6n5QR3RRjX1sS+cCVMOhppfrtBbWVS4Ox+XF1BE chW+NtKY2IlgKNpX8zr7gQOSSt7Krm832KX0RjIahyGTdT61mgvFbdS8m9XtBT4DU31n CrZ8Yu80cz7rsdYx5vTpeFxe/EQqRydYzKNzYg2Bnv99QtZDszanYE36wBAmEv4PK2p9 uc5Fu/1OLLIj4Fv62BDY3Vi3KfIz4Fad+nlS5Ob8kYhKAJ+dByS8Eaoj9Hv1Pm3wZav5 4Ybw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792083766; x=1792688566; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=g5sCj4amkDsYs1pfyEUgpMCDKBamRT7BGjJoSHqaXC4=; b=qVESNNN9dG8uWRfcbtLXaMEBRxWwol/zexZtlN9RYwTVFl1lUon0Mmtb6HDlnSkNGV BwmtSNMHO+HUHQaazaGHcpFymlXM+9f458/uyUoTUdEsvnmgEVSUIG2+VjTaFTFFTwe8 VNir/V133hol7kGszAVa4vjsDli7vSlF9n2lelpmclxkWx3VM9kxg+VNtnmHpTpL3mkq dzKarcccYV5Ql1RBcJjLp+GGvT8sjvdTZG63s5eZ5b9kIGLEIEChHZqf0tyuVAiVayHd 4gmr1FCyVGsYgJJG7dB2+FTOwa58r5eDxOwk4YaTCOw5fhpXOk+GgkrhBa6DjpRmUEc8 FFtw== X-Gm-Message-State: AFq9FYI6Kj4XKnyMB8Dd7WG/bSwy5fSUwTYYhXtJd8VBFqc/mKcl72CY 8kx2ILojlL3BbPDV7c0FuPjtZKyrzfwReGeNndV4Nb4jgIAKIqHEA6K2OQP6bw== X-Gm-Gg: AYBFou0tmgrU4umZc/nPr0wmq+wTdvNmy+TIoR9BTRldrxrnWus+BTW/bjEMbcGZeX/ rgOb6K+9a7erH0+cNb3RnqF7i6yVvp2LvZJ/E8SjzpUr8UkkUxD4lLiEoZqVVzcqNExq2nkAJ71 JOTUW1jqufmMvfUuxC3eDjz/W5osmogh1p9JrTV57tPLNXZS63xjhAbi4710EwXjVIaWFyU9bBK j4XG/CupzVuYxKeuZE5v3TD+A+oMyXuV6NNVHS9cM97XPfC7eS4GSsS2wFGpyrxVljhfhPiViM+ fq8hps4Mz59sqGlnd4r19QWtvvGBtv3iFQltvmTU3g9PsqhFN73kM9+CONsjo4fz3XFFIIewzlz AAP87kbdb3kzs5Fi5s3AsfjvungSN7h30zWIu0AsOJPVDUUnxhHDlzDjriRZxBBokJJgLSXx6FL Eqb567Dk4ujwM4k1AkVyyQK02RVfeuJXYUt+JHAoW9rieMWTfxzvRNNZvg5yfohq8LYktCo6Qzw 5hY57vbqRmfnbe8Ky/WEjMKSLKR4rDJBiLPGmR6CsL/+Jez8nUIhulWFMrQrFeciyRPXtKNakkF suMbAY1+7698KYliViTYmw== X-Received: by 2002:a17:90b:2786:b0:3ab:b39f:41cd with SMTP id 98e67ed59e1d1-3abb39f44eamr12881111a91.60.1792083765271; Thu, 15 Oct 2026 10:02:45 -0700 (PDT) From: Akshey Taneja To: qemu-devel@nongnu.org Cc: Akshey Taneja Subject: [PATCH 2/2] whpx: i386: fall back to xAPIC when the MSR exit bitmap is unavailable Date: Thu, 15 Oct 2026 10:02:16 -0700 Message-ID: <20261015170216.6895-3-aksheynew.tanejanew@gmail.com> X-Mailer: git-send-email 2.50.1.windows.1 In-Reply-To: <20261015170216.6895-1-aksheynew.tanejanew@gmail.com> References: <20261015170216.6895-1-aksheynew.tanejanew@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=aksheynew.tanejanew@gmail.com; helo=mail-pg1-x52e.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 15 Oct 2026 18:17:31 -0400 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 @gmail.com) X-ZM-MESSAGEID: 1792102692417158500 Content-Type: text/plain; charset="utf-8" WHvPartitionPropertyCodeX64MsrExitBitmap is not implemented on Windows 10, where WHvSetPartitionProperty() returns WHV_E_UNKNOWN_PROPERTY (0x80370302) and whpx_accel_init() aborts with -EINVAL. QEMU started requesting it in ba1bda25b7 ("whpx: i386: x2apic emulation"). Treating the failure as non-fatal is not sufficient on its own: whpx_default_props unconditionally enables x2apic, and x2APIC is reached through MSRs, so without MSR exits the userspace LAPIC never observes the guest's APIC accesses and the guest hangs immediately after the firmware hands over. Observed as a black screen with an Ubuntu 24.04 guest that otherwise boots in about 40 seconds. Record whether the MSR exit bitmap was accepted and, when it was not, apply x2apic=3Doff so the guest uses the MMIO based xAPIC, which is still intercepted normally. Reported-on: Windows 10 Enterprise LTSC 17763, Intel i7-6700 Signed-off-by: Akshey Taneja --- target/i386/whpx/whpx-all.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 9a9fc7d974..3e59aacf31 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -57,7 +57,7 @@ #define HV_X64_MSR_GUEST_IDLE 0x400000f0 =20 static bool is_modern_os =3D true; - +static bool whpx_msr_exits_available =3D true; static const WHV_REGISTER_NAME whpx_register_names[] =3D { =20 /* X64 General purpose registers */ @@ -2889,6 +2889,16 @@ static PropValue whpx_default_props[] =3D { { NULL, NULL }, }; =20 +/* + * x2APIC is reached through MSRs, so emulating it in userspace requires t= he + * MSR exit bitmap. Hosts without that property must fall back to xAPIC, + * which is MMIO based and therefore still intercepted. + */ +static PropValue whpx_no_msr_exit_props[] =3D { + { "x2apic", "off" }, + { NULL, NULL }, +}; + =20 void whpx_cpu_instance_init(CPUState *cs) { @@ -2896,7 +2906,8 @@ void whpx_cpu_instance_init(CPUState *cs) X86CPUClass *xcc =3D X86_CPU_GET_CLASS(cpu); =20 host_cpu_instance_init(cpu); - x86_cpu_apply_props(cpu, whpx_default_props); + x86_cpu_apply_props(cpu, whpx_msr_exits_available ? whpx_default_props + : whpx_no_msr_exit_p= rops); =20 if (xcc->max_features) { whpx_cpu_max_instance_init(cpu); @@ -3344,10 +3355,22 @@ int whpx_accel_init(AccelState *as, MachineState *m= s) WHvPartitionPropertyCodeX64MsrExitBitmap, &prop, sizeof(WHV_PARTITION_PROPERTY)); + /* + * Windows 10 does not implement this property. Without the MSR exits = the + * guest simply gets the behaviour QEMU had before commit ba1bda25b7 + * ("whpx: i386: x2apic emulation") started asking for them, so treat = an + * unknown property as non-fatal rather than refusing to start. + */ if (FAILED(hr)) { - error_report("WHPX: Failed to set MSR exit bitmap, hr=3D%08lx", hr= ); - ret =3D -EINVAL; - goto error; + if (hr =3D=3D WHV_E_UNKNOWN_PROPERTY) { + whpx_msr_exits_available =3D false; + warn_report("WHPX: MSR exit bitmap unsupported on this Windows= " + "version, falling back to xAPIC"); + } else { + error_report("WHPX: Failed to set MSR exit bitmap, hr=3D%08lx"= , hr); + ret =3D -EINVAL; + goto error; + } } =20 hr =3D whp_dispatch.WHvSetPartitionProperty( --=20 2.50.1.windows.1