From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341504; cv=none; d=zohomail.com; s=zohoarc; b=cdVNwHPoWGvsvk2KCIVU1glMmvdC3xSNSWHwYpWZPT2bCIzf8YsunPvAWACS9yVJeXV4zMNO20YOByAsQ2G/iTrmYGPrRDh2ADqfoK22QHeh1VBeo3lMTU1emBGQFBwcvHtEJa3SeOMxhwMk/vNoHkgdPjen5tQZ1NJ2NqxjxcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341504; 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=UbQCp/z8d0UWo4lIFYXYd0mdek+SJnwAX0PfzqX1kKY=; b=bOA4pp0ingfIzevEw0QWd7hvOcNHYx6vYYHdUY+nf9RwL+HN3iyfW8DaEJhA0bODs0CKLC230C2kC3ZuvNgsTzjsxC0tUAN68cpFoVCILl6xbWI9TRD47gLCcmroV7IoR2vDsak2Y/vMq4J5tzsAm+8h7RwB0oIs3gBWRrZZjFs= 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 1776341504282915.8305129387232; Thu, 16 Apr 2026 05:11:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZF-0008OE-CO; Thu, 16 Apr 2026 08:11:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wDLZ9-0008Nb-T2 for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:29 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZ7-0002NR-M4 for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:27 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id 06DBD20B7129; Thu, 16 Apr 2026 05:11:22 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 06DBD20B7129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341484; bh=UbQCp/z8d0UWo4lIFYXYd0mdek+SJnwAX0PfzqX1kKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=biW8XN1LYlY/IzsUYTEhd6bNYy14k7ZNiaYxE/scgbsXMMMNVRYVAlT6S/DIlpQIT aFw+tdJqvyUkhoHIG+igYBEfpvz+CDnyCeiM/ilf0SieTudlhqs1ObFkBMkgqQNzR5 JFtXUZyJE5dNaT/6PhSEANg3lS6Z9nTWain2m/DQ= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 1/9] accel/mshv: use mshv_create_partition_v2 payload Date: Thu, 16 Apr 2026 14:11:08 +0200 Message-Id: <20260416121116.527927-2-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341506461158500 Content-Type: text/plain; charset="utf-8" When using the extended request format we can instruct the hypervisor to provision enough space for requested XSAVE features. This is required for supporting QEMU models provided via the -cpu flag properly. Signed-off-by: Magnus Kulke Acked-by: Wei Liu Reviewed-by: Anirudh Rayabharam (Microsoft) --- accel/mshv/mshv-all.c | 71 ++++++++++-- include/hw/hyperv/hvgdk_mini.h | 2 + include/hw/hyperv/hvhdk.h | 195 +++++++++++++++++++++++++++++++++ 3 files changed, 261 insertions(+), 7 deletions(-) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index d4cc7f5371..c50641f174 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -110,21 +110,78 @@ static int resume_vm(int vm_fd) return 0; } =20 +static int get_host_partition_property(int mshv_fd, uint32_t property_code, + uint64_t *value) +{ + int ret; + struct hv_input_get_partition_property in =3D {0}; + struct hv_output_get_partition_property out =3D {0}; + struct mshv_root_hvcall args =3D {0}; + + in.property_code =3D property_code; + + args.code =3D HVCALL_GET_PARTITION_PROPERTY; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t)∈ + args.out_sz =3D sizeof(out); + args.out_ptr =3D (uint64_t)&out; + + ret =3D ioctl(mshv_fd, MSHV_ROOT_HVCALL, &args); + if (ret < 0) { + error_report("Failed to get host partition property bank: %s", + strerror(errno)); + return -1; + } + + *value =3D out.property_value; + return 0; +} + static int create_partition(int mshv_fd, int *vm_fd) { int ret; - struct mshv_create_partition args =3D {0}; + uint64_t pt_flags, host_proc_features; + union hv_partition_processor_xsave_features disabled_xsave_features; + struct mshv_create_partition_v2 args =3D {0}; + + QEMU_BUILD_BUG_ON(MSHV_NUM_CPU_FEATURES_BANKS !=3D 2); =20 /* Initialize pt_flags with the desired features */ - uint64_t pt_flags =3D (1ULL << MSHV_PT_BIT_LAPIC) | - (1ULL << MSHV_PT_BIT_X2APIC) | - (1ULL << MSHV_PT_BIT_GPA_SUPER_PAGES); + pt_flags =3D (1ULL << MSHV_PT_BIT_LAPIC) | + (1ULL << MSHV_PT_BIT_X2APIC) | + (1ULL << MSHV_PT_BIT_GPA_SUPER_PAGES) | + (1ULL << MSHV_PT_BIT_CPU_AND_XSAVE_FEATURES); + + /* enable all */ + disabled_xsave_features.as_uint64 =3D 0; + + /* + * query host for supported processor features and disable unsupported + * features: (0 means supported, 1 means disabled, hence the negation) + */ + ret =3D get_host_partition_property(mshv_fd, + HV_PARTITION_PROPERTY_PROCESSOR_FEAT= URES0, + &host_proc_features); + if (ret < 0) { + error_report("Failed to get host processor feature bank 0"); + return -1; + } + args.pt_cpu_fbanks[0] =3D ~host_proc_features; =20 - /* Set default isolation type */ - uint64_t pt_isolation =3D MSHV_PT_ISOLATION_NONE; + ret =3D get_host_partition_property(mshv_fd, + HV_PARTITION_PROPERTY_PROCESSOR_FEAT= URES1, + &host_proc_features); + if (ret < 0) { + error_report("Failed to get host processor feature bank 1"); + return -1; + } + args.pt_cpu_fbanks[1] =3D ~host_proc_features; =20 + /* populate args structure */ args.pt_flags =3D pt_flags; - args.pt_isolation =3D pt_isolation; + args.pt_isolation =3D MSHV_PT_ISOLATION_NONE; + args.pt_disabled_xsave =3D disabled_xsave_features.as_uint64; + args.pt_num_cpu_fbanks =3D MSHV_NUM_CPU_FEATURES_BANKS; =20 ret =3D ioctl(mshv_fd, MSHV_CREATE_PARTITION, &args); if (ret < 0) { diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h index c3a8f33280..367519143e 100644 --- a/include/hw/hyperv/hvgdk_mini.h +++ b/include/hw/hyperv/hvgdk_mini.h @@ -454,6 +454,8 @@ typedef struct hv_input_set_vp_registers { struct hv_register_assoc elements[]; } QEMU_PACKED hv_input_set_vp_registers; =20 +#define MSHV_VP_MAX_REGISTERS 128 + union hv_interrupt_control { uint64_t as_uint64; struct { diff --git a/include/hw/hyperv/hvhdk.h b/include/hw/hyperv/hvhdk.h index 41af743847..9ad16c47da 100644 --- a/include/hw/hyperv/hvhdk.h +++ b/include/hw/hyperv/hvhdk.h @@ -11,6 +11,16 @@ =20 #define HV_PARTITION_SYNTHETIC_PROCESSOR_FEATURES_BANKS 1 =20 +struct hv_input_get_partition_property { + uint64_t partition_id; + uint32_t property_code; /* enum hv_partition_property_code */ + uint32_t padding; +} QEMU_PACKED; + +struct hv_output_get_partition_property { + uint64_t property_value; +} QEMU_PACKED; + struct hv_input_set_partition_property { uint64_t partition_id; uint32_t property_code; /* enum hv_partition_property_code */ @@ -161,6 +171,191 @@ union hv_partition_synthetic_processor_features { }; }; =20 +union hv_partition_processor_xsave_features { + struct { + uint64_t xsave_support:1; + uint64_t xsaveopt_support:1; + uint64_t avx_support:1; + uint64_t avx2_support:1; + uint64_t fma_support:1; + uint64_t mpx_support:1; + uint64_t avx512_support:1; + uint64_t avx512_dq_support:1; + uint64_t avx512_cd_support:1; + uint64_t avx512_bw_support:1; + uint64_t avx512_vl_support:1; + uint64_t xsave_comp_support:1; + uint64_t xsave_supervisor_support:1; + uint64_t xcr1_support:1; + uint64_t avx512_bitalg_support:1; + uint64_t avx512_i_fma_support:1; + uint64_t avx512_v_bmi_support:1; + uint64_t avx512_v_bmi2_support:1; + uint64_t avx512_vnni_support:1; + uint64_t gfni_support:1; + uint64_t vaes_support:1; + uint64_t avx512_v_popcntdq_support:1; + uint64_t vpclmulqdq_support:1; + uint64_t avx512_bf16_support:1; + uint64_t avx512_vp2_intersect_support:1; + uint64_t avx512_fp16_support:1; + uint64_t xfd_support:1; + uint64_t amx_tile_support:1; + uint64_t amx_bf16_support:1; + uint64_t amx_int8_support:1; + uint64_t avx_vnni_support:1; + uint64_t avx_ifma_support:1; + uint64_t avx_ne_convert_support:1; + uint64_t avx_vnni_int8_support:1; + uint64_t avx_vnni_int16_support:1; + uint64_t avx10_1_256_support:1; + uint64_t avx10_1_512_support:1; + uint64_t amx_fp16_support:1; + uint64_t reserved1:26; + }; + uint64_t as_uint64; +}; + +#define HV_PARTITION_PROCESSOR_FEATURES_BANKS 2 +#define HV_PARTITION_PROCESSOR_FEATURES_RESERVEDBANK1_BITFIELD_COUNT 4 + + +union hv_partition_processor_features { + uint64_t as_uint64[HV_PARTITION_PROCESSOR_FEATURES_BANKS]; + struct { + uint64_t sse3_support:1; + uint64_t lahf_sahf_support:1; + uint64_t ssse3_support:1; + uint64_t sse4_1_support:1; + uint64_t sse4_2_support:1; + uint64_t sse4a_support:1; + uint64_t xop_support:1; + uint64_t pop_cnt_support:1; + uint64_t cmpxchg16b_support:1; + uint64_t altmovcr8_support:1; + uint64_t lzcnt_support:1; + uint64_t mis_align_sse_support:1; + uint64_t mmx_ext_support:1; + uint64_t amd3dnow_support:1; + uint64_t extended_amd3dnow_support:1; + uint64_t page_1gb_support:1; + uint64_t aes_support:1; + uint64_t pclmulqdq_support:1; + uint64_t pcid_support:1; + uint64_t fma4_support:1; + uint64_t f16c_support:1; + uint64_t rd_rand_support:1; + uint64_t rd_wr_fs_gs_support:1; + uint64_t smep_support:1; + uint64_t enhanced_fast_string_support:1; + uint64_t bmi1_support:1; + uint64_t bmi2_support:1; + uint64_t hle_support_deprecated:1; + uint64_t rtm_support_deprecated:1; + uint64_t movbe_support:1; + uint64_t npiep1_support:1; + uint64_t dep_x87_fpu_save_support:1; + uint64_t rd_seed_support:1; + uint64_t adx_support:1; + uint64_t intel_prefetch_support:1; + uint64_t smap_support:1; + uint64_t hle_support:1; + uint64_t rtm_support:1; + uint64_t rdtscp_support:1; + uint64_t clflushopt_support:1; + uint64_t clwb_support:1; + uint64_t sha_support:1; + uint64_t x87_pointers_saved_support:1; + uint64_t invpcid_support:1; + uint64_t ibrs_support:1; + uint64_t stibp_support:1; + uint64_t ibpb_support:1; + uint64_t unrestricted_guest_support:1; + uint64_t mdd_support:1; + uint64_t fast_short_rep_mov_support:1; + uint64_t l1dcache_flush_support:1; + uint64_t rdcl_no_support:1; + uint64_t ibrs_all_support:1; + uint64_t skip_l1df_support:1; + uint64_t ssb_no_support:1; + uint64_t rsb_a_no_support:1; + uint64_t virt_spec_ctrl_support:1; + uint64_t rd_pid_support:1; + uint64_t umip_support:1; + uint64_t mbs_no_support:1; + uint64_t mb_clear_support:1; + uint64_t taa_no_support:1; + uint64_t tsx_ctrl_support:1; + uint64_t reserved_bank0:1; + + /* N.B. Begin bank 1 processor features. */ + uint64_t a_count_m_count_support:1; + uint64_t tsc_invariant_support:1; + uint64_t cl_zero_support:1; + uint64_t rdpru_support:1; + uint64_t la57_support:1; + uint64_t mbec_support:1; + uint64_t nested_virt_support:1; + uint64_t psfd_support:1; + uint64_t cet_ss_support:1; + uint64_t cet_ibt_support:1; + uint64_t vmx_exception_inject_support:1; + uint64_t enqcmd_support:1; + uint64_t umwait_tpause_support:1; + uint64_t movdiri_support:1; + uint64_t movdir64b_support:1; + uint64_t cldemote_support:1; + uint64_t serialize_support:1; + uint64_t tsc_deadline_tmr_support:1; + uint64_t tsc_adjust_support:1; + uint64_t fzl_rep_movsb:1; + uint64_t fs_rep_stosb:1; + uint64_t fs_rep_cmpsb:1; + uint64_t tsx_ld_trk_support:1; + uint64_t vmx_ins_outs_exit_info_support:1; + uint64_t hlat_support:1; + uint64_t sbdr_ssdp_no_support:1; + uint64_t fbsdp_no_support:1; + uint64_t psdp_no_support:1; + uint64_t fb_clear_support:1; + uint64_t btc_no_support:1; + uint64_t ibpb_rsb_flush_support:1; + uint64_t stibp_always_on_support:1; + uint64_t perf_global_ctrl_support:1; + uint64_t npt_execute_only_support:1; + uint64_t npt_ad_flags_support:1; + uint64_t npt1_gb_page_support:1; + uint64_t amd_processor_topology_node_id_support:1; + uint64_t local_machine_check_support:1; + uint64_t extended_topology_leaf_fp256_amd_support:1; + uint64_t gds_no_support:1; + uint64_t cmpccxadd_support:1; + uint64_t tsc_aux_virtualization_support:1; + uint64_t rmp_query_support:1; + uint64_t bhi_no_support:1; + uint64_t bhi_dis_support:1; + uint64_t prefetch_i_support:1; + uint64_t sha512_support:1; + uint64_t mitigation_ctrl_support:1; + uint64_t rfds_no_support:1; + uint64_t rfds_clear_support:1; + uint64_t sm3_support:1; + uint64_t sm4_support:1; + uint64_t secure_avic_support:1; + uint64_t guest_intercept_ctrl_support:1; + uint64_t sbpb_supported:1; + uint64_t ibpb_br_type_supported:1; + uint64_t srso_no_supported:1; + uint64_t srso_user_kernel_no_supported:1; + uint64_t vrew_clear_supported:1; + uint64_t tsa_l1_no_supported:1; + uint64_t tsa_sq_no_supported:1; + uint64_t lass_support:1; + uint64_t idle_hlt_intercept_support:1; + uint64_t msr_list_support:1; + }; +}; + enum hv_translate_gva_result_code { HV_TRANSLATE_GVA_SUCCESS =3D 0, =20 --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341516; cv=none; d=zohomail.com; s=zohoarc; b=KsZ3ulD+50UX8ECc1j2QCqJDlig/onYT3vZoqlFFt90LIlN8m1+plwgo4DnCpr6xMCkBqqga10+gASHK8QbjPnz7lauXc6F7bBxvJBPPDfJNNufJdrrozD1MJKpRPrE66RURpMzEe/87xg9EpUSMfIZrYteLk3rA01jl+EY50dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341516; h=Content-Type: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=FbXEXuqW8Bve0EgBTU0ARZN82HgvfmY8otXukE5Cjuw=; b=jB973enJ/H1pjd7GdtGpYI7XAye2l8b+6+41bs3j6CmHX8qvBlzq3ORE5LbF7vlW2xxqAETZW8WTJg+MYx12uzRvej8ilzNmfGa7e4WgMxR1Uz1hZ4v4+Ofq9yEcnm0dyi2Izg/8UA7r+wlW5u8FmMxlWQGatuHfDG7VLX74e2c= 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 1776341515895198.03677533480925; Thu, 16 Apr 2026 05:11:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZJ-0008OS-IY; Thu, 16 Apr 2026 08:11:37 -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 1wDLZB-0008Ng-7v for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:29 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZ9-0002Ne-Oc for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:28 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id 6919320B7128; Thu, 16 Apr 2026 05:11:25 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6919320B7128 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341486; bh=FbXEXuqW8Bve0EgBTU0ARZN82HgvfmY8otXukE5Cjuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cqg6fdyreB5+iZi/3N8R3Wj5yD8Gj7wp5l6JHGZpXEepfv4S184pgJJnhI6FaNwFg /UbRQ/N0VnXWTabGUlqZIxYOyhElUyzCfPVu9/KLgXMZ0MJyDmeWRMllVOmmyHul3/ V9E2Fd+++vMakqq264jEoiBDu8eosABySsRyMswk= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 2/9] target/i386/mshv: fix cpuid propagation bug Date: Thu, 16 Apr 2026 14:11:09 +0200 Message-Id: <20260416121116.527927-3-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341517816154100 The list argument was missing a pointer and hence e.g. -cpu qemu64 and -cpu EPYC would produce the same of cpuid leaves. Fixes: 4fa04dd1621 ("target/i386: Register CPUID entries with MSHV") Signed-off-by: Magnus Kulke Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Anirudh Rayabharam (Microsoft) --- target/i386/mshv/mshv-cpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 2bc978deb2..f1cc4abc5c 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -441,7 +441,7 @@ int mshv_load_regs(CPUState *cpu) return 0; } =20 -static void add_cpuid_entry(GList *cpuid_entries, +static void add_cpuid_entry(GList **cpuid_entries, uint32_t function, uint32_t index, uint32_t eax, uint32_t ebx, uint32_t ecx, uint32_t edx) @@ -456,10 +456,10 @@ static void add_cpuid_entry(GList *cpuid_entries, entry->ecx =3D ecx; entry->edx =3D edx; =20 - cpuid_entries =3D g_list_append(cpuid_entries, entry); + *cpuid_entries =3D g_list_append(*cpuid_entries, entry); } =20 -static void collect_cpuid_entries(const CPUState *cpu, GList *cpuid_entrie= s) +static void collect_cpuid_entries(const CPUState *cpu, GList **cpuid_entri= es) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; @@ -615,7 +615,7 @@ static int set_cpuid2(const CPUState *cpu) struct hv_cpuid_entry *entry; GList *entries =3D NULL; =20 - collect_cpuid_entries(cpu, entries); + collect_cpuid_entries(cpu, &entries); n_entries =3D g_list_length(entries); =20 cpuid_size =3D sizeof(struct hv_cpuid) --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341581; cv=none; d=zohomail.com; s=zohoarc; b=AY6im7oN6o2pgNnTExA2rB5ksVbB79bl1bSbuoTSBef8s/By3D/pWhU1ZMO5m/DOuPJBKOJ9asMHvHOVsoioRafwHHt4A76+0Xe38LMsuGSKOIDk3k+F3aQUQu0LKMRBy5fjdivtijZkJRTUuwDTK7MLteOCNqyBVKVyLQWG4Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341581; 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=ItrHOC5nPemd66dEK2NgZsgS7P6ajPcgEYGrhuuCrYE=; b=PlZqOLD2mO7bJYp82uWZds+UWpz5x0bYHxh40W6W7re2RBb2eafmXJuIJkCU9rpu/Wx/L4X5feYKZH6QiPyU0OHV9eeMw6RfbuPui9kTH6cfw3zSPDU7xXF+tAJAK8DMceN+GismC9BAAqcSl0QNvDYDHmCN71MY9lJ8nEzOQfc= 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 1776341581223271.1888331425466; Thu, 16 Apr 2026 05:13:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZN-0008PJ-9f; Thu, 16 Apr 2026 08:11:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wDLZF-0008OG-EJ for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:33 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZD-0002O1-AI for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:32 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id 7F96020B712B; Thu, 16 Apr 2026 05:11:27 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7F96020B712B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341489; bh=ItrHOC5nPemd66dEK2NgZsgS7P6ajPcgEYGrhuuCrYE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZ7Ew7ha/2gTcDEO019z57VIyEFqCP5+NuqkDCHpmfHueSOicCaTS2FE+U7It+tDs NMUmfpjIIYAr/d2zirH+qIuFdXJ/6ip8lp7k0LKhLwNpfF1unlphgkd5DZHEzsgXTG rMoYBEI9ng4oVuLEdmS1/gQ/vsjj3LAJ//4okEoI= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 3/9] target/i386/mshv: fix various cpuid traversal bugs Date: Thu, 16 Apr 2026 14:11:10 +0200 Message-Id: <20260416121116.527927-4-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341581966158500 Content-Type: text/plain; charset="utf-8" - Hardcoded max_leaf was not accurate. We query leaf 0x0 and 0x80000000 to get the actual max leaves - On all 0 zeroes on leaf 0x0d, we register 0-63 subleaves with zeros indicating XSAVE is disabled - Subleaf 0 was hardcoded, so the Hypervisor returned defaults for other subleaves - Subleaf 0 was hardcoded, so we were passing 0 instead of actual subleaf when adding entries. We now pass the correct subleaf value to add_cpuid_entry() - Leaves 0x04,0x07,0d,0f,10 weren't marked as subleaf-specific Signed-off-by: Magnus Kulke Acked-by: Wei Liu --- target/i386/mshv/mshv-cpu.c | 88 +++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index f1cc4abc5c..4183727a86 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -465,14 +465,17 @@ static void collect_cpuid_entries(const CPUState *cpu= , GList **cpuid_entries) CPUX86State *env =3D &x86_cpu->env; uint32_t eax, ebx, ecx, edx; uint32_t leaf, subleaf; - size_t max_leaf =3D 0x1F; - size_t max_subleaf =3D 0x20; - - uint32_t leaves_with_subleaves[] =3D {0x4, 0x7, 0xD, 0xF, 0x10}; + uint32_t max_basic_leaf, max_extended_leaf; + uint32_t max_subleaf =3D 0x20; + uint32_t leaves_with_subleaves[] =3D {0x04, 0x07, 0x0d, 0x0f, 0x10}; int n_subleaf_leaves =3D ARRAY_SIZE(leaves_with_subleaves); =20 - /* Regular leaves without subleaves */ - for (leaf =3D 0; leaf <=3D max_leaf; leaf++) { + /* Get maximum basic and and extended CPUID leaves */ + cpu_x86_cpuid(env, 0, 0, &max_basic_leaf, &ebx, &ecx, &edx); + cpu_x86_cpuid(env, 0x80000000, 0, &max_extended_leaf, &ebx, &ecx, &edx= ); + + /* Collect basic leaves (0x0 to max_basic_leaf) */ + for (leaf =3D 0; leaf <=3D max_basic_leaf; leaf++) { bool has_subleaves =3D false; for (int i =3D 0; i < n_subleaf_leaves; i++) { if (leaf =3D=3D leaves_with_subleaves[i]) { @@ -483,27 +486,40 @@ static void collect_cpuid_entries(const CPUState *cpu= , GList **cpuid_entries) =20 if (!has_subleaves) { cpu_x86_cpuid(env, leaf, 0, &eax, &ebx, &ecx, &edx); - if (eax =3D=3D 0 && ebx =3D=3D 0 && ecx =3D=3D 0 && edx =3D=3D= 0) { - /* all zeroes indicates no more leaves */ - continue; - } - add_cpuid_entry(cpuid_entries, leaf, 0, eax, ebx, ecx, edx); continue; } =20 + /* + * Valid XSAVE components can exist at a higher index se we need t= o set + * all subleaves for leaf 0x0d, even if we encounter an empty one. + */ + if (leaf =3D=3D 0x0d) { + for (subleaf =3D 0; subleaf <=3D 63; subleaf++) { + cpu_x86_cpuid(env, leaf, subleaf, &eax, &ebx, &ecx, &edx); + add_cpuid_entry(cpuid_entries, leaf, subleaf, + eax, ebx, ecx, edx); + } + continue; + } + subleaf =3D 0; while (subleaf < max_subleaf) { cpu_x86_cpuid(env, leaf, subleaf, &eax, &ebx, &ecx, &edx); =20 if (eax =3D=3D 0 && ebx =3D=3D 0 && ecx =3D=3D 0 && edx =3D=3D= 0) { - /* all zeroes indicates no more leaves */ break; } - add_cpuid_entry(cpuid_entries, leaf, 0, eax, ebx, ecx, edx); + add_cpuid_entry(cpuid_entries, leaf, subleaf, eax, ebx, ecx, e= dx); subleaf++; } } + + /* Collect extended leaves (0x80000000 to max_extended_leaf) */ + for (leaf =3D 0x80000000; leaf <=3D max_extended_leaf; leaf++) { + cpu_x86_cpuid(env, leaf, 0, &eax, &ebx, &ecx, &edx); + add_cpuid_entry(cpuid_entries, leaf, 0, eax, ebx, ecx, edx); + } } =20 static int register_intercept_result_cpuid_entry(const CPUState *cpu, @@ -576,22 +592,40 @@ static int register_intercept_result_cpuid(const CPUS= tate *cpu, subleaf_specific =3D 0; always_override =3D 1; =20 - /* Intel */ - /* 0xb - Extended Topology Enumeration Leaf */ - /* 0x1f - V2 Extended Topology Enumeration Leaf */ - /* AMD */ - /* 0x8000_001e - Processor Topology Information */ - /* 0x8000_0026 - Extended CPU Topology */ - if (entry->function =3D=3D 0xb - || entry->function =3D=3D 0x1f - || entry->function =3D=3D 0x8000001e - || entry->function =3D=3D 0x80000026) { + /* + * Intel + * 0xb - Extended Topology Enumeration Leaf + * 0x1f - V2 Extended Topology Enumeration Leaf + * AMD + * 0x8000_001e - Processor Topology Information + * 0x8000_0026 - Extended CPU Topology + */ + if (entry->function =3D=3D 0xb || + entry->function =3D=3D 0x1f || + entry->function =3D=3D 0x8000001e || + entry->function =3D=3D 0x80000026) { + subleaf_specific =3D 1; + always_override =3D 1; + /* + * Feature enumeration leaves (subleaf-specific) + * 0x04: Deterministic Cache Parameters + * 0x07: Structured Extended Feature Flags + * 0x0D: Processor Extended State Enumeration + * 0x0F: Platform QoS Monitoring + * 0x10: Platform QoS Enforcement + */ + } else if (entry->function =3D=3D 0x04 || + entry->function =3D=3D 0x07 || + entry->function =3D=3D 0x0d || + entry->function =3D=3D 0x0f || + entry->function =3D=3D 0x10) { subleaf_specific =3D 1; always_override =3D 1; - } else if (entry->function =3D=3D 0x00000001 - || entry->function =3D=3D 0x80000000 - || entry->function =3D=3D 0x80000001 - || entry->function =3D=3D 0x80000008) { + /* Basic feature leaves (no subleaves) */ + } else if (entry->function =3D=3D 0x00000001 || + entry->function =3D=3D 0x80000000 || + entry->function =3D=3D 0x80000001 || + entry->function =3D=3D 0x80000008) { subleaf_specific =3D 0; always_override =3D 1; } --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341585; cv=none; d=zohomail.com; s=zohoarc; b=mF2ToKAp+vdVRECJ5TmjeTJ0eMPdIkRgUL7djJYGtHL2XrZeL2QTAVgfFqevIh4FgGHkHiY96P9o4S8V4GCRCrMgM8t76S0kQaZfq5oQyd2EC21PfqGhTaGRv0QY77fhcUTXzeUwxKS+wns4ZMI3wWnSn/wKOKifGCkZZgbZrLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341585; 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=3qKH/AOjRjhm/x8a9eu7OnZ3TkDZ/w2V+YOycx7vrL0=; b=Vzcrxx7LP3Jqb+xHVesBh4ogWA0yTt+yqfyoPvsvjAOvd+B2kGqqfs8rFVBwTGlUyBT7XcSD82MXoHO8ae4d3Sp45A2XVcy0c8duLCVSuwcvpx8l9O4EaL/kwcPa/rL3s4I5DM6/m0IQTZmxTFnJ+7C52Jja8iMd4+WWKSDcUKk= 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 1776341585954360.31066621205446; Thu, 16 Apr 2026 05:13:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZN-0008PK-9t; Thu, 16 Apr 2026 08:11:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wDLZI-0008OZ-42 for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:37 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZF-0002OF-7i for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:35 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id BE8F820B7128; Thu, 16 Apr 2026 05:11:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BE8F820B7128 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341491; bh=3qKH/AOjRjhm/x8a9eu7OnZ3TkDZ/w2V+YOycx7vrL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S4m/pUfk8jF2DquPeXplktDHgBlLQj1uJFRWwuSN0LfaL5rLvMLKnd5z2WKGEKtNC Z6kmxKzgAgYPbaQqmeaXuRWrxVbBVmXCc4fn6/1QcqzQ37RsxxywreIBrb927UYsSB RkyDgTPQtErOVYZIN4XTRcf06ptdS5In3bulNONk= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 4/9] target/i386/mshv: change cpuid mask to UINT32_MAX Date: Thu, 16 Apr 2026 14:11:11 +0200 Message-Id: <20260416121116.527927-5-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341587936158500 Content-Type: text/plain; charset="utf-8" The current implementation would only override the feature bits that are enabled, however we also want to consider disabled features, hence all bits are set on the masks in the hypercall argument. Signed-off-by: Magnus Kulke Acked-by: Wei Liu --- target/i386/mshv/mshv-cpu.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 4183727a86..e42b5a614d 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -538,22 +538,17 @@ static int register_intercept_result_cpuid_entry(cons= t CPUState *cpu, .input.always_override =3D always_override, .input.padding =3D 0, /* - * With regard to masks - these are to specify bits to be overwrit= ten - * The current CpuidEntry structure wouldn't allow to carry the ma= sks - * in addition to the actual register values. For this reason, the - * masks are set to the exact values of the corresponding register= bits - * to be registered for an overwrite. To view resulting values the - * hypervisor would return, HvCallGetVpCpuidValues hypercall can be - * used. + * Masks specify which bits to override. Set to 0xFFFFFFFF to + * override all bits with the values from the QEMU CPU model. */ .result.eax =3D entry->eax, - .result.eax_mask =3D entry->eax, + .result.eax_mask =3D 0xFFFFFFFF, .result.ebx =3D entry->ebx, - .result.ebx_mask =3D entry->ebx, + .result.ebx_mask =3D 0xFFFFFFFF, .result.ecx =3D entry->ecx, - .result.ecx_mask =3D entry->ecx, + .result.ecx_mask =3D 0xFFFFFFFF, .result.edx =3D entry->edx, - .result.edx_mask =3D entry->edx, + .result.edx_mask =3D 0xFFFFFFFF, }; union hv_register_intercept_result_parameters parameters =3D { .cpuid =3D cpuid_params, --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341583; cv=none; d=zohomail.com; s=zohoarc; b=Mil7W9mCGRXiEXwuM5FB3GxGrGt08AJFLYg9jsnI7ufSXtZW3RLVObyOOvp4bVNR5jY+z4EnNYT2SfSKgLHhWsiQi59TB1kLiKatRgZFfeA4XHwBDDpc9c0S1o4WJzOsQrC2KThR6Sq19ZYZ93k/Qo//7URTY5LylTYZKQ2p0hg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341583; 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=xH4HagDCiBk6gATgsEXyD93463ehoI+ZwQqXAAzAVR4=; b=UWQE2a6uD8BhLL14HzURob9XE5ghTGz1cUJ9QtWL8tGoO+uv9dmhlPKPJET5O3+tw0bsGIoN51phHXkeTVss2MlRUavqZ3PRGfjlyUfIgPMLdWZw5iy2p+MQwetxVFIP85dfB5O8tPU54nGERJfKaGK7ghOE3bu3GlkoJT85g24= 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 177634158342842.697700386616475; Thu, 16 Apr 2026 05:13:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZN-0008PH-8P; Thu, 16 Apr 2026 08:11:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wDLZI-0008On-7K for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:37 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZG-0002Oj-Cx for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:35 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id ED4FC20B7129; Thu, 16 Apr 2026 05:11:31 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com ED4FC20B7129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341493; bh=xH4HagDCiBk6gATgsEXyD93463ehoI+ZwQqXAAzAVR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dxtw5F3UOXyCPiP/N3Rz0foQ/USdMs10pNfxn/kvp1cytj+ouDq3Hbn+eZIpXBSR4 +aGGqC4caRCpYmwVy5ujpf9/NbJso5Deg7pcDZXq3PemQHDsEK2SaR2B06WP5JCkpg p73+Merh9u6mo69mDOX1toL2NGoayrKP2kNvhqv4= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 5/9] target/i386/mshv: set cpu model name on -cpu host Date: Thu, 16 Apr 2026 14:11:12 +0200 Message-Id: <20260416121116.527927-6-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341584712154100 Content-Type: text/plain; charset="utf-8" By registering a cpu_accel_class for mshv, we can report an accurate model name on -cpu host. Signed-off-by: Magnus Kulke Acked-by: Wei Liu --- target/i386/mshv/mshv-cpu.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index e42b5a614d..09878ef357 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -24,10 +24,13 @@ #include "hw/i386/apic_internal.h" =20 #include "cpu.h" +#include "host-cpu.h" #include "emulate/x86_decode.h" #include "emulate/x86_emu.h" #include "emulate/x86_flags.h" =20 +#include "accel/accel-cpu-target.h" + #include "trace-accel_mshv.h" #include "trace.h" =20 @@ -1675,3 +1678,31 @@ int mshv_arch_post_init_vm(int vm_fd) =20 return ret; } + +static void mshv_cpu_instance_init(CPUState *cs) +{ + X86CPU *cpu =3D X86_CPU(cs); + + host_cpu_instance_init(cpu); +} + +static void mshv_cpu_accel_class_init(ObjectClass *oc, const void *data) +{ + AccelCPUClass *acc =3D ACCEL_CPU_CLASS(oc); + + acc->cpu_instance_init =3D mshv_cpu_instance_init; +} + +static const TypeInfo mshv_cpu_accel_type_info =3D { + .name =3D ACCEL_CPU_NAME("mshv"), + .parent =3D TYPE_ACCEL_CPU, + .class_init =3D mshv_cpu_accel_class_init, + .abstract =3D true, +}; + +static void mshv_cpu_accel_register_types(void) +{ + type_register_static(&mshv_cpu_accel_type_info); +} + +type_init(mshv_cpu_accel_register_types); --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341557; cv=none; d=zohomail.com; s=zohoarc; b=elX4Ka+lZo1UxG8zHFPpFMzXxA5vPiFj8Gr4NkgtKzY5uQIXbGzKiSOdfE7/t/AcrrEAGLbpxeKsls8/SPkV27fLoLG9spQ1nx+WwZwxOPk/UOA8G8K+1vcSn0zUS23VkHMz6dmMJY7YiRnWa5YVStan0KWAcTpcjD6LmdJAQL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341557; 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=d9/BQeP8wUYO1IyE343ZkHR9ZgOOFZiIbPXo9Fv94yA=; b=QWn/d6ZeztM0y7pRU8iTkJEYmFnzt56wLMdK1BzmVIc2KyvPTMkMI103pOrlV5DizM0zBTl63sieFuyMHuIIJ4fgZq2DYgO7OgvFPwhNnhgt5IFgWgA7YqqZujhgBZH3IZrVhA48ix2Nlco9JrmAl98EIkTDfz3VjHYdaleLeJs= 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 177634155731015.397372116497081; Thu, 16 Apr 2026 05:12:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZP-0008SA-R1; Thu, 16 Apr 2026 08:11:43 -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 1wDLZL-0008PI-Fk for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:40 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZI-0002Oj-Uw for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:38 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id 11D1220B712B; Thu, 16 Apr 2026 05:11:33 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 11D1220B712B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341495; bh=d9/BQeP8wUYO1IyE343ZkHR9ZgOOFZiIbPXo9Fv94yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U4hzwuqS+uL7Y3XWBB5GSPKGj7OLvjSgTQC9KpLu56suZyG7A9Idi9Fx+QxbsNh4d TkvSJ7PhTkcamrq2LmpPmWh8+quTAAGOZ9BIzFjiOWr3vBNdZcU4oEdQ6Us5I1YMLO kw2AwMc+muXJikSPEeO6vbOahmEhsIcAHwE+ZgDU= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 6/9] target/i386: query mshv accel for supported cpuids Date: Thu, 16 Apr 2026 14:11:13 +0200 Message-Id: <20260416121116.527927-7-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341558356154100 Content-Type: text/plain; charset="utf-8" We implement mshv_get_supported_cpuid() and invoke it in x86_cpu_get_supported_feature_word() retrieve the cpu features that the host is supporting. Initially we mask the virtualization capabilitities potentially we might need to mask more in the future. Signed-off-by: Magnus Kulke --- include/system/mshv.h | 3 +++ target/i386/cpu.c | 8 ++++++++ target/i386/mshv/mshv-cpu.c | 27 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/include/system/mshv.h b/include/system/mshv.h index 75286baf16..51b0420735 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -60,4 +60,7 @@ int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifi= er *n, const EventNotifier *rn, int virq); int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int vir= q); =20 +/* cpuid */ +uint32_t mshv_get_supported_cpuid(uint32_t func, uint32_t idx, int reg); + #endif diff --git a/target/i386/cpu.c b/target/i386/cpu.c index c6fd1dc00e..4dd9752fd0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -26,6 +26,7 @@ #include "tcg/helper-tcg.h" #include "exec/translation-block.h" #include "system/hvf.h" +#include "system/mshv.h" #include "hvf/hvf-i386.h" #include "kvm/kvm_i386.h" #include "kvm/tdx.h" @@ -8087,6 +8088,13 @@ 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 (mshv_enabled()) { + if (wi->type !=3D CPUID_FEATURE_WORD) { + return 0; + } + r =3D mshv_get_supported_cpuid(wi->cpuid.eax, + wi->cpuid.ecx, + wi->cpuid.reg); } else if (tcg_enabled() || qtest_enabled()) { r =3D wi->tcg_features; } else { diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 09878ef357..3b392533b4 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1639,6 +1639,33 @@ void mshv_arch_destroy_vcpu(CPUState *cpu) g_clear_pointer(&env->emu_mmio_buf, g_free); } =20 +uint32_t mshv_get_supported_cpuid(uint32_t func, uint32_t idx, int reg) +{ + uint32_t eax, ebx, ecx, edx; + uint32_t ret =3D 0; + + host_cpuid(func, idx, &eax, &ebx, &ecx, &edx); + switch (reg) { + case R_EAX: + ret =3D eax; break; + case R_EBX: + ret =3D ebx; break; + case R_ECX: + ret =3D ecx; break; + case R_EDX: + ret =3D edx; break; + } + + /* Disable nested virtualization features not yet supported by MSHV */ + if (func =3D=3D 0x80000001 && reg =3D=3D R_ECX) { + ret &=3D ~CPUID_EXT3_SVM; + } + if (func =3D=3D 0x01 && reg =3D=3D R_ECX) { + ret &=3D ~CPUID_EXT_VMX; + } + return ret; +} + /* * Default Microsoft Hypervisor behavior for unimplemented MSR is to send a * fault to the guest if it tries to access it. It is possible to override --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341582; cv=none; d=zohomail.com; s=zohoarc; b=Bco1hlJM231v2VaSkQOXnb+/c5C2cbzbxR/1MCgEWW3zDHR+NcCmYT/lJsvA3PM6p4RAkOS6nr+n+e+ZQjC9tYDBUkJj+HGCnOU/J9UnDA9lLUKdQBS3oFU5qVnKU5AWZ/Dq6xcSTiZzQp6pYGzQ5pNkqzkDuMakAbNOG9QM7MY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341582; 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=aTVxvEVz5lQHNdZmbaeb9TChVHr9SVG0hmQSZJZieN0=; b=JyzA16DOhZCqPYQNhNSfOzhv7GRg8wsqfOlmfvK6dWdzBizhOR0/Rky/bphBOa3BIg2E7LmpA/8efUlcyeYdE50Xgdsv/pDLjOtR//Z+n4Fwo1fcQ/Ya83NeLlnV02L0BPd3nO+yEkqULNZzKPqSWkYUlvwuvsTA6SYDEy7f8NQ= 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 1776341582008303.29130767346464; Thu, 16 Apr 2026 05:13:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZP-0008Qp-8t; Thu, 16 Apr 2026 08:11:43 -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 1wDLZM-0008PP-VX for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:41 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZL-0002Pm-8L for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:40 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id 6802720B7128; Thu, 16 Apr 2026 05:11:36 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 6802720B7128 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341498; bh=aTVxvEVz5lQHNdZmbaeb9TChVHr9SVG0hmQSZJZieN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dycYcJk4Yrs5dUJ/9VlczwO+vgC1457H2N8qCB0U9nw0eSLh3qxrB9V/A2cTk0WWC ySJruv41vTn9O/ib4RZkewCkNhBsDIUPB8wgaygNWYYE7VFKLjjYw9FHOnpvFJ4OTV Ip3edgRWyG6FeefS2E+lh5vyZR7b3VjC8PjiqeLw= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 7/9] target/i386/mshv: populate xsave area offsets Date: Thu, 16 Apr 2026 14:11:14 +0200 Message-Id: <20260416121116.527927-8-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341584748154100 Content-Type: text/plain; charset="utf-8" This function is copied verbatim from kvm_cpu_xsave_init(), for MSHV we need to populate the offsets similarly. Signed-off-by: Magnus Kulke Reviewed-by: Anirudh Rayabharam (Microsoft) --- target/i386/mshv/mshv-cpu.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 3b392533b4..ee25eb5f6f 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1706,11 +1706,42 @@ int mshv_arch_post_init_vm(int vm_fd) return ret; } =20 +static void mshv_cpu_xsave_init(void) +{ + static bool first =3D true; + uint32_t eax, ebx, ecx, edx; + 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) { + continue; + } + host_cpuid(0xd, i, &eax, &ebx, &ecx, &edx); + if (eax !=3D 0) { + assert(esa->size =3D=3D eax); + esa->offset =3D ebx; + esa->ecx =3D ecx; + } + } +} + static void mshv_cpu_instance_init(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); =20 host_cpu_instance_init(cpu); + mshv_cpu_xsave_init(); } =20 static void mshv_cpu_accel_class_init(ObjectClass *oc, const void *data) --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341522; cv=none; d=zohomail.com; s=zohoarc; b=XgpdmIjpVKFL3dDS9PpkSkvWZiSQGnTSuH3VqjWZkydzx6BbwwdPAXrHuwsVcKASxn4GV/IYVE7GPwpRZagJZscfdwEgmvEKQKpZhSKafSC3F6Hwa2QA/Dmnw2jLtj88UHC3XL5m2VW0FXoIcKXjg70sgCYRALGayuiBd4+f4DE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341522; 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=zdYRIkg+oa2YRSRRDin+ckBgXO9q8zPFkYu1dCSFXfQ=; b=UfD5et6UQs1aJSgV0uqYMEbXN+W2b9EC41d4EQqQU7O3xAeqjfsVfLv0NqUcpxMj47oHr0jJTD/vVBBnnZ2o0F5ch6Kre9zk/QDoq64LLk06imEbkZUAbQjsm09IeojXvk3EeFd8pMBsI9Ha7rTg4SQ8YeeJw9pWx0oJ78wzuBE= 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 1776341522367512.1197885834615; Thu, 16 Apr 2026 05:12:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZQ-0008Sn-6C; Thu, 16 Apr 2026 08:11:44 -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 1wDLZO-0008QP-Mq for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:42 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZM-0002Oj-Og for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:42 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id 9D59920B7129; Thu, 16 Apr 2026 05:11:38 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9D59920B7129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341500; bh=zdYRIkg+oa2YRSRRDin+ckBgXO9q8zPFkYu1dCSFXfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b1grMpiw8on1/7hA1D6Fx8F20wcgzNVUsyexkgCnNzx6nVZ3pRhzSfaNvNKNWaJP0 Otzs5X0Mve4GMCpUMpUrvuAV9vpBNJhAfLKsqwUdqrE03TsGJa0sKYcnsAUOEpH+1K 5vATUK3KAAEi5bLgjwdyWbnqlvJb9iR/VNPOEEk4= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 8/9] target/i386/mshv: use hv-provided [0xD,1+2].EBX Date: Thu, 16 Apr 2026 14:11:15 +0200 Message-Id: <20260416121116.527927-9-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341523799154100 Content-Type: text/plain; charset="utf-8" We cannot statically set the responses for CPUID[0xD,{1,2}].EBX, b/c those are dynamic, dependent on which features the guest enables. Hence we mask EBX when registering answers for those subleaves at the hypervisor, which will result in the hypervisor providing us answers, considering XCR0 and XSS. The reported size now reflects the field masks properly (without the mask they were 576 and 10728, which is wrong): $ cpuid -l 0xd -s 0 CPU 0: XSAVE features (0xd/0): XCR0 valid bit field mask =3D 0x00000000000600e7 ... bytes required by fields in XCR0 =3D 0x00002b00 (11008) bytes required by XSAVE/XRSTOR area =3D 0x00002b00 (11008) $ cpuid -l 0xd -s 1 CPU 0: XSAVE features (0xd/1): ... SAVE area size in bytes =3D 0x000029c0 (10688) IA32_XSS lower 32 bits valid bit field mask =3D 0x00001800 IA32_XSS upper 32 bits valid bit field mask =3D 0x00000000 Signed-off-by: Magnus Kulke --- target/i386/mshv/mshv-cpu.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index ee25eb5f6f..b90e2983c8 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -528,6 +528,7 @@ static void collect_cpuid_entries(const CPUState *cpu, = GList **cpuid_entries) static int register_intercept_result_cpuid_entry(const CPUState *cpu, uint8_t subleaf_specific, uint8_t always_override, + uint32_t ebx_mask, struct hv_cpuid_entry *en= try) { int ret; @@ -543,11 +544,12 @@ static int register_intercept_result_cpuid_entry(cons= t CPUState *cpu, /* * Masks specify which bits to override. Set to 0xFFFFFFFF to * override all bits with the values from the QEMU CPU model. + * A mask of 0 lets the hypervisor supply its own value. */ .result.eax =3D entry->eax, .result.eax_mask =3D 0xFFFFFFFF, .result.ebx =3D entry->ebx, - .result.ebx_mask =3D 0xFFFFFFFF, + .result.ebx_mask =3D ebx_mask, .result.ecx =3D entry->ecx, .result.ecx_mask =3D 0xFFFFFFFF, .result.edx =3D entry->edx, @@ -582,6 +584,7 @@ static int register_intercept_result_cpuid(const CPUSta= te *cpu, int ret =3D 0, entry_ret; struct hv_cpuid_entry *entry; uint8_t subleaf_specific, always_override; + uint32_t ebx_mask; =20 for (size_t i =3D 0; i < cpuid->nent; i++) { entry =3D &cpuid->entries[i]; @@ -589,6 +592,7 @@ static int register_intercept_result_cpuid(const CPUSta= te *cpu, /* set defaults */ subleaf_specific =3D 0; always_override =3D 1; + ebx_mask =3D 0xFFFFFFFF; =20 /* * Intel @@ -628,8 +632,22 @@ static int register_intercept_result_cpuid(const CPUSt= ate *cpu, always_override =3D 1; } =20 - entry_ret =3D register_intercept_result_cpuid_entry(cpu, subleaf_s= pecific, + /* + * CPUID[0xD,0].EBX and CPUID[0xD,1].EBX report the XSAVE area + * size based on features currently enabled in XCR0/XSS. These + * values are dynamic and must not be overridden with static + * results from the QEMU CPU model. Setting ebx_mask to 0 lets + * the hypervisor supply EBX based on the guest's actual state. + */ + if (entry->function =3D=3D 0x0d && + (entry->index =3D=3D 0 || entry->index =3D=3D 1)) { + ebx_mask =3D 0; + } + + entry_ret =3D register_intercept_result_cpuid_entry(cpu, + subleaf_specific, always_override, + ebx_mask, entry); if ((entry_ret < 0) && (ret =3D=3D 0)) { ret =3D entry_ret; @@ -1663,6 +1681,7 @@ uint32_t mshv_get_supported_cpuid(uint32_t func, uint= 32_t idx, int reg) if (func =3D=3D 0x01 && reg =3D=3D R_ECX) { ret &=3D ~CPUID_EXT_VMX; } + return ret; } =20 --=20 2.34.1 From nobody Sat Apr 18 01:59:03 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=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1776341560; cv=none; d=zohomail.com; s=zohoarc; b=JHHHAC5d19KmQ+J7F7DkNananyWGHoamq06fb3WaaQiHBXinOy3T6mgUzqAZZ/GymsUip2gZy9sSGmv4T51/vVKvUwfzTPwB+GdLqIgTXUdW40ML7HNLiHY+2qwY/NZIDoB/LTfLvoFnxB9BiacT5CTuGF1Y8gdDw9PM/bpoWso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776341560; 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=DZsSiTRYYYWERd2emTJ5lJqB6CAtgOgvEgvN3Gna9x4=; b=Al7NZyDqHTZla5Jkb/5KoPg4BcyCStI8p1UFB8Bfh3WD+X9DP03WrcSqj3uSpDW2POuz5ukfMp5soQY9eX8LtT5qdkVb3tmwy8I2kGoSkPBmw4oIO6kA2GBFkTOzICtmCQCHa5Egzv8W2CrOkt/HvtYTJ8l3bynrZa1eXP1Pg4E= 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 1776341560136937.7356172889713; Thu, 16 Apr 2026 05:12:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZS-0008V5-Fm; Thu, 16 Apr 2026 08:11:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wDLZQ-0008Ts-Ir for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:44 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wDLZO-0002Pm-TF for qemu-devel@nongnu.org; Thu, 16 Apr 2026 08:11:44 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.32]) by linux.microsoft.com (Postfix) with ESMTPSA id D532220B712B; Thu, 16 Apr 2026 05:11:40 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D532220B712B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1776341502; bh=DZsSiTRYYYWERd2emTJ5lJqB6CAtgOgvEgvN3Gna9x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=arGSoVhpZgU313kM7IngW55g7EMhtu7jh4vnhY8fa8uWSlks0QbTwTR3J87vQIvfv bqO0jJWxlNqPh8/KLmBwMih3QK8vyvX4Gv0y+RiYjNQjH7qq5b/zINPqSfnA+rkfOi mpGmuxDaTfH87Nb1azeYVsmipkgUU+BVNVx3HWlo= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Wei Liu , Magnus Kulke , Zhao Liu , Paolo Bonzini , Wei Liu , Magnus Kulke Subject: [PATCH v6 9/9] accel/mshv: disable la57 (5lvl paging) Date: Thu, 16 Apr 2026 14:11:16 +0200 Message-Id: <20260416121116.527927-10-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260416121116.527927-1-magnuskulke@linux.microsoft.com> References: <20260416121116.527927-1-magnuskulke@linux.microsoft.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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1776341561828158500 Content-Type: text/plain; charset="utf-8" This change disable la57 paging on the mshv hypervisor on both the mshv processor feature bitmap and mask the cpuid feature leaf to the guest. Since the removal of hypervisor-assisted gva=3D>gpa translation in 1c85a4a3d7 we have seen MMIO errors in guests on la57-enabled hw. We will have to investigate and test this further. Signed-off-by: Magnus Kulke Reviewed-by: Anirudh Rayabharam (Microsoft) Reviewed-by: Wei Liu --- accel/mshv/mshv-all.c | 7 +++++++ include/system/mshv_int.h | 2 ++ target/i386/mshv/mshv-cpu.c | 15 +++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index c50641f174..a557623531 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -142,6 +142,8 @@ static int create_partition(int mshv_fd, int *vm_fd) int ret; uint64_t pt_flags, host_proc_features; union hv_partition_processor_xsave_features disabled_xsave_features; + union hv_partition_processor_features disabled_partition_features =3D = {0}; + struct mshv_create_partition_v2 args =3D {0}; =20 QEMU_BUILD_BUG_ON(MSHV_NUM_CPU_FEATURES_BANKS !=3D 2); @@ -177,6 +179,11 @@ static int create_partition(int mshv_fd, int *vm_fd) } args.pt_cpu_fbanks[1] =3D ~host_proc_features; =20 + /* arch-specific features we disable regardless of host support */ + mshv_arch_disable_partition_proc_features(&disabled_partition_features= ); + args.pt_cpu_fbanks[0] |=3D disabled_partition_features.as_uint64[0]; + args.pt_cpu_fbanks[1] |=3D disabled_partition_features.as_uint64[1]; + /* populate args structure */ args.pt_flags =3D pt_flags; args.pt_isolation =3D MSHV_PT_ISOLATION_NONE; diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 35386c422f..ca156cdf4b 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -94,6 +94,8 @@ void mshv_arch_init_vcpu(CPUState *cpu); void mshv_arch_destroy_vcpu(CPUState *cpu); void mshv_arch_amend_proc_features( union hv_partition_synthetic_processor_features *features); +void mshv_arch_disable_partition_proc_features( + union hv_partition_processor_features *disabled_features); int mshv_arch_post_init_vm(int vm_fd); =20 typedef struct mshv_root_hvcall mshv_root_hvcall; diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index b90e2983c8..eb3e167c0d 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1129,6 +1129,12 @@ void mshv_arch_amend_proc_features( features->access_guest_idle_reg =3D 1; } =20 +void mshv_arch_disable_partition_proc_features( + union hv_partition_processor_features *disabled_features) +{ + disabled_features->la57_support =3D 1; +} + static int set_memory_info(const struct hyperv_message *msg, struct hv_x64_memory_intercept_message *info) { @@ -1682,6 +1688,15 @@ uint32_t mshv_get_supported_cpuid(uint32_t func, uin= t32_t idx, int reg) ret &=3D ~CPUID_EXT_VMX; } =20 + if (func =3D=3D 0x07 && idx =3D=3D 0 && reg =3D=3D R_ECX) { + /* + * LA57 (5-level paging) causes incorrect GVA=3D>GPA translations + * in the instruction decoder/emulator. Disable until page table + * walk in x86_mmu.c works w/ 5-level paging. + */ + ret &=3D ~CPUID_7_0_ECX_LA57; + } + return ret; } =20 --=20 2.34.1