{"id":2231457,"url":"http://patchwork.ozlabs.org/api/patches/2231457/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430172204.1006673-29-pbonzini@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260430172204.1006673-29-pbonzini@redhat.com>","list_archive_url":null,"date":"2026-04-30T17:21:34","name":"[PULL,28/58] whpx: i386: reintroduce enlightenments for Windows 10","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5f36908c30fc5e893be2e7e514552e6683c72ab5","submitter":{"id":2701,"url":"http://patchwork.ozlabs.org/api/people/2701/?format=json","name":"Paolo Bonzini","email":"pbonzini@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430172204.1006673-29-pbonzini@redhat.com/mbox/","series":[{"id":502347,"url":"http://patchwork.ozlabs.org/api/series/502347/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502347","date":"2026-04-30T17:21:16","name":"[PULL,01/58] pythondeps: bump to meson 1.11.1","version":1,"mbox":"http://patchwork.ozlabs.org/series/502347/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231457/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231457/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=hlDF4LoA;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=PDjvzOR/;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g61RM4ld1z1yGq\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 03:30:55 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wIV7e-0006lM-35; Thu, 30 Apr 2026 13:24:22 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pbonzini@redhat.com>)\n id 1wIV6y-0005ZJ-KT\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 13:23:47 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.129.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pbonzini@redhat.com>)\n id 1wIV6w-0004cm-KQ\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 13:23:40 -0400","from mail-qv1-f70.google.com (mail-qv1-f70.google.com\n [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-475-XuUWmEiHMo6D22x66pFAMw-1; Thu, 30 Apr 2026 13:23:36 -0400","by mail-qv1-f70.google.com with SMTP id\n 6a1803df08f44-8a22dbeeb96so25824296d6.3\n for <qemu-devel@nongnu.org>; Thu, 30 Apr 2026 10:23:36 -0700 (PDT)","from [192.168.10.48] ([151.49.85.67])\n by smtp.gmail.com with ESMTPSA id\n 6a1803df08f44-8b3ff307a48sm23204516d6.8.2026.04.30.10.23.32\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 30 Apr 2026 10:23:33 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1777569817;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=cl5a3vj9rnwbfPX/dYSVMjKJHNNMYrzpW3sXgWpfcTE=;\n b=hlDF4LoAY+syJ+Z9KqDplemjAvv+USPv4kkX3vgQ7Ft9TuD/0nI1Z5BjMiBFeMet7TV1Ih\n HHgUTL9jYwAiKhAKT3unFoiJtuHiAi2edEAWIsMA7fiO/Bm3KU6CzP3Unv0cm9tLiiuTbB\n SDKmTdAP1nSV8wdDsl2jE34+/OgO8mc=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1777569815; x=1778174615; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=cl5a3vj9rnwbfPX/dYSVMjKJHNNMYrzpW3sXgWpfcTE=;\n b=PDjvzOR/Vo4S3etgFeUjmcvuDtKbIxF7kvt07Zt+Hx+n2y0zQpUJ4McaxefWeoTt7L\n LWJ89h65nMbLSlP+Ovd2xjTnnm/CH4TKUv8kZ3lEevhSNBWZOg2Lcg4SaOaHSve/o6A5\n dzjRXti/c3nGQGlmVETEMYHXQE3IADZughT2tDTfxcDr01Q8SZNeXjwNdH9JTR2Yr5M7\n vCGGSiI5nEAaaUN8pDs8ZiHvJE5k/K9lFk4LWsqgn7IRZsexLZ+myguScYMC23tOvhg6\n gUIA8h5tHJcT+SVoV9S5MwtUc5HkmENMOCask3lUJd9AnqQCwUeD3CNzFZnBbXBTInkO\n IRRw=="],"X-MC-Unique":"XuUWmEiHMo6D22x66pFAMw-1","X-Mimecast-MFC-AGG-ID":"XuUWmEiHMo6D22x66pFAMw_1777569816","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777569815; x=1778174615;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=cl5a3vj9rnwbfPX/dYSVMjKJHNNMYrzpW3sXgWpfcTE=;\n b=FCah4Rs482ImeRlaTxPSrBnJblvZedM45ybOVil5nITHBmm2d/yq9zf6YZ4spzTzHT\n 8e5jjlskKkfEo6YrKS/5/IjiHiRUFSWPU806iu0v0oLkvq/edX1QUcvHwLWaCxIm0Mo2\n Q9JqS+VLuv4PVM6rivwEA7RB5TC/q0UMIFeNwQXY3B7tWcvo4ct4sAg06CjpbLbvsxoH\n /yaTjOKCgH3XsHs4lfDE0Ddrwo8dV5nJBSeDGaV7kd6+WrSRfoI2148fbNI99lhSRNaM\n 3CALYT2jkCZimG+E1bTx1N+F9liqpuKNdJWRtXVAayw3nn34m7a6QbEX7YygpH5ujgAR\n eErw==","X-Gm-Message-State":"AOJu0YwwU8V5o2+EGDqKW3G6hzhHlM9xsGjVw0+f2rCM72PqK9GhY4cw\n bleVlSMLUtnx88svv1BVB6cnefhCYKQjU89tOHNuwyqCZvluF9KY6L+ggZtBLVl0fXOrG00Zn9a\n aOKZ6zF5gifZgJ/81gQIFq+aH1sdkPOw7RL1YPXlvtTTUPATBMf1F/FLcQT4Eb9ej+QdkzROL/f\n YFNogpkpkbkk9WpXl7dW571WKmpeYjs+/phfkeFz25","X-Gm-Gg":"AeBDietBuCL0a+lhTh7ZKcHp3jF0EkLbmbaF31HV2zFFbNGiBc6eP3dkzhQMPTBwCuE\n Z8/s3wa3MaDiZA5gfxaFcgfbe0WFyr+6Fd5raNpv77HXo45FCiKEVCNSlwqu0kT7hGaRSdy1Yh6\n umSrQSAxRSO+7yUVobT7C00V9S5BW15cJL5xtKQTPcvYYJptX9tIi7rZaatyt2XYTCFiJ3a/NMf\n bi6ZSGPP23umhN2VVaYeXHVKNWE8jTfh9g8EJq/dQDQwq2EPEIa/F/ToWXV/nbNjmb0H2a5UsyR\n jVCtn28VZu3Gm2tS9Ff7yjIf6taKFJlXtUdMe38mX0Gk+RRdmjRneFLFOG80IcQwq0t50a1XYZa\n k56lSxEm8ot5EkTPBUIAsCDDaotf7+8kiIabgbJ7+E7/ARjNFmaLbOTF2LI3jqrZfBrOWPx09AX\n w3eWgoy1MhmL8+zjQtkJE6XqL4I749D9NoPVc=","X-Received":["by 2002:a05:6214:600c:b0:8ac:801d:c3dc with SMTP id\n 6a1803df08f44-8b3fe6f7050mr51807866d6.9.1777569815179;\n Thu, 30 Apr 2026 10:23:35 -0700 (PDT)","by 2002:a05:6214:600c:b0:8ac:801d:c3dc with SMTP id\n 6a1803df08f44-8b3fe6f7050mr51807256d6.9.1777569814646;\n Thu, 30 Apr 2026 10:23:34 -0700 (PDT)"],"From":"Paolo Bonzini <pbonzini@redhat.com>","To":"qemu-devel@nongnu.org","Cc":"Mohamed Mediouni <mohamed@unpredictable.fr>","Subject":"[PULL 28/58] whpx: i386: reintroduce enlightenments for Windows 10","Date":"Thu, 30 Apr 2026 19:21:34 +0200","Message-ID":"<20260430172204.1006673-29-pbonzini@redhat.com>","X-Mailer":"git-send-email 2.54.0","In-Reply-To":"<20260430172204.1006673-1-pbonzini@redhat.com>","References":"<20260430172204.1006673-1-pbonzini@redhat.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.129.124;\n envelope-from=pbonzini@redhat.com;\n helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Mohamed Mediouni <mohamed@unpredictable.fr>\n\nWas removed in 2c08624 but it's still useful for\nWindows 10 so reintroduce it there.\n\nAnd this time, actually make it work by reporting\nthe hypervisor bit in CPUID.\n\nPretend to be vmware to be able to use vmport's functionality.\n\nIf the vmware frequency leaf is disabled, pretend to be\nKVM, with the only capability reported being X2APIC support.\n\nSigned-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>\nLink: https://lore.kernel.org/r/20260422214225.2242-7-mohamed@unpredictable.fr\nSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>\n---\n include/system/whpx-internal.h |  1 +\n accel/whpx/whpx-common.c       |  2 ++\n target/arm/whpx/whpx-all.c     |  1 +\n target/i386/whpx/whpx-all.c    | 61 +++++++++++++++++++++++++++++-----\n 4 files changed, 57 insertions(+), 8 deletions(-)","diff":"diff --git a/include/system/whpx-internal.h b/include/system/whpx-internal.h\nindex 5902124b637..cf782cf5f89 100644\n--- a/include/system/whpx-internal.h\n+++ b/include/system/whpx-internal.h\n@@ -45,6 +45,7 @@ struct whpx_state {\n \n     bool hyperv_enlightenments_allowed;\n     bool hyperv_enlightenments_required;\n+    bool hyperv_enlightenments_enabled;\n \n };\n \ndiff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c\nindex b813a5d9d25..59be996aefc 100644\n--- a/accel/whpx/whpx-common.c\n+++ b/accel/whpx/whpx-common.c\n@@ -550,6 +550,8 @@ static void whpx_accel_instance_init(Object *obj)\n \n     whpx->hyperv_enlightenments_allowed = true;\n     whpx->hyperv_enlightenments_required = false;\n+    /* Value determined at whpx_accel_init */\n+    whpx->hyperv_enlightenments_enabled = false;\n }\n \n static const TypeInfo whpx_accel_type = {\ndiff --git a/target/arm/whpx/whpx-all.c b/target/arm/whpx/whpx-all.c\nindex bbf0f6be961..4019a513aa7 100644\n--- a/target/arm/whpx/whpx-all.c\n+++ b/target/arm/whpx/whpx-all.c\n@@ -968,6 +968,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)\n      * as they're not needed for performance.\n      */\n     if (whpx->hyperv_enlightenments_required) {\n+        whpx->hyperv_enlightenments_enabled = true;\n         hr = whp_dispatch.WHvSetPartitionProperty(\n                 whpx->partition,\n                 WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks,\ndiff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c\nindex 4954e0557a7..f9f330c038f 100644\n--- a/target/i386/whpx/whpx-all.c\n+++ b/target/i386/whpx/whpx-all.c\n@@ -2168,14 +2168,57 @@ int whpx_vcpu_run(CPUState *cpu)\n                 vcpu->exit_ctx.VpContext.Rip +\n                 vcpu->exit_ctx.VpContext.InstructionLength;\n \n-            reg_values[1].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRax;\n-            reg_values[2].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRcx;\n-            reg_values[3].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRdx;\n-            reg_values[4].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRbx;\n+            if (whpx_is_legacy_os()) {\n+                reg_values[1].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRax;\n+                reg_values[2].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRcx;\n+                reg_values[3].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRdx;\n+                reg_values[4].Reg64 = vcpu->exit_ctx.CpuidAccess.DefaultResultRbx;\n+            } else {\n+                cpu_x86_cpuid(env, vcpu->exit_ctx.CpuidAccess.Rax,\n+                    vcpu->exit_ctx.CpuidAccess.Rcx,\n+                    (UINT32 *)&reg_values[1].Reg32,\n+                    (UINT32 *)&reg_values[4].Reg32, (UINT32 *)&reg_values[2].Reg32,\n+                    (UINT32 *)&reg_values[3].Reg32);\n+            }\n \n-            if (vcpu->exit_ctx.CpuidAccess.Rax == 1) {\n-                if (cpu_has_x2apic_feature(env)) {\n-                    reg_values[2].Reg64 |= CPUID_EXT_X2APIC;\n+            if (!whpx->hyperv_enlightenments_enabled) {\n+                switch (vcpu->exit_ctx.CpuidAccess.Rax) {\n+                case 1:\n+                    reg_values[2].Reg64 |= CPUID_EXT_HYPERVISOR;\n+                    break;\n+                case 0x40000000:\n+                    /*\n+                     * Use vmware_cpuid_freq as a proxy to report VMware.\n+                     * This is to get the TSC/APIC frequency query functionality\n+                     * provided through vmport, as Linux doesn't use leaf\n+                     * 0x40000010 for getting those frequencies.\n+                     */\n+                    if (x86_cpu->vmware_cpuid_freq) {\n+                        reg_values[1].Reg64 = 0x40000010;\n+                        reg_values[4].Reg64 = 0x61774d56;\n+                        reg_values[2].Reg64 = 0x4d566572;\n+                        reg_values[3].Reg64 = 0x65726177;\n+                    } else {\n+                        /* report KVM otherwise if that's disabled */\n+                        reg_values[1].Reg64 = 0x40000001;\n+                        reg_values[4].Reg64 = 0x4b4d564b;\n+                        reg_values[2].Reg64 = 0x564b4d56;\n+                        reg_values[3].Reg64 = 0x4d;\n+                    }\n+                    break;\n+                case 0x40000001:\n+                    if (!x86_cpu->vmware_cpuid_freq) {\n+                        /* KVM reporting of X2APIC support */\n+                        reg_values[1].Reg64 = reg_values[4].Reg64 =\n+                            reg_values[2].Reg64 = 1 << 15;\n+                    }\n+                    break;\n+                case 0x40000010:\n+                    if (x86_cpu->vmware_cpuid_freq) {\n+                        reg_values[1].Reg64 = env->tsc_khz;\n+                        reg_values[4].Reg64 = env->apic_bus_freq / 1000; /* Hz to KHz */\n+                    }\n+                    break;\n                 }\n             }\n \n@@ -2396,6 +2439,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)\n     WHV_PROCESSOR_FEATURES_BANKS processor_features;\n     WHV_PROCESSOR_PERFMON_FEATURES perfmon_features;\n     UINT32 cpuidExitList[] = {1};\n+    UINT32 cpuidExitList_nohyperv[] = {1, 0x40000000, 0x40000001, 0x40000010};\n \n     whpx = &whpx_global;\n \n@@ -2601,6 +2645,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)\n     }\n \n     if (is_modern_os && whpx->hyperv_enlightenments_allowed) {\n+        whpx->hyperv_enlightenments_enabled = true;\n         hr = whp_dispatch.WHvSetPartitionProperty(\n                 whpx->partition,\n                 WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks,\n@@ -2653,7 +2698,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)\n     hr = whp_dispatch.WHvSetPartitionProperty(\n         whpx->partition,\n         WHvPartitionPropertyCodeCpuidExitList,\n-        cpuidExitList,\n+        whpx->hyperv_enlightenments_enabled ? cpuidExitList : cpuidExitList_nohyperv,\n         RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32));\n \n     if (FAILED(hr)) {\n","prefixes":["PULL","28/58"]}