From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469111; cv=none; d=zohomail.com; s=zohoarc; b=LBj0MumWpA91c7szp8ZzV25F3mTgqGQ7ESQAm5IWw7NN2MXo6t8DNW4ZQcYsiIipcsd1dyGqjvxf1VI8wzqMY5hvF/3WP9CkDCHP/cXEDMtabZenx7qheKiDVy2Va17cK+kis3uloRJ9btVvwEvQ89ElNV2PctXmXerim4kve9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469111; 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=b8dcwWu2KjTJzkePLo9NIeg2coLsOVWSLigxpeSSRN0=; b=GM6MlSv9W7a2uXuDAGIb9/fjEw6XUmEE089jPocg99fveE4ICBi4zOUgcuhsu/J2xFpNVMXmUINEMgOvlszT3evqTcg3DDMAZqC7YqSzYVjkQi1SspXxKifyPa0ru9YfFQtuRyh3BCnIa6DxzZUGj5gcY7cVoanCKmJq7tfZ7ek= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469111897514.4321878849757; Fri, 26 Jun 2026 03:18:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3dN-0006dS-O5; Fri, 26 Jun 2026 06:18:05 -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 1wd3dH-0006ZU-Sb for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:17:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dF-00056J-Ea for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:17:59 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-5jIyAzirOM2f8chVcEZOHg-1; Fri, 26 Jun 2026 06:17:54 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-46cfd1fe676so386315f8f.0 for ; Fri, 26 Jun 2026 03:17:54 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268f7670bsm66465645e9.0.2026.06.26.03.17.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b8dcwWu2KjTJzkePLo9NIeg2coLsOVWSLigxpeSSRN0=; b=dnNFF0KgdN6cupnRdN2rOYVcAydKlxucdu9+QoPWLA1vaXNQBD+0R65LlEAg5m0/0ABf79 yh80OhxVKJpT1uKjWspeio83PxIGOFTamEruIP43XA0+o7rZ4CoeN2glJsQpUjg5mQ2y+B 49Y+yHs8It69OhbhUPEdUyoFFEMkcTw= X-MC-Unique: 5jIyAzirOM2f8chVcEZOHg-1 X-Mimecast-MFC-AGG-ID: 5jIyAzirOM2f8chVcEZOHg_1782469073 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469073; x=1783073873; 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; bh=b8dcwWu2KjTJzkePLo9NIeg2coLsOVWSLigxpeSSRN0=; b=lt+kic/XHEs2okLaKcITvLavPxEUKciUYXsddiJ8znyq0TuhuWi5k7bKn/8JK20lwc YEaIi77hwzxfuPVu3cZQCbIu2pOjKQG+Ceh12grr4Masc21rD4DfRI2V9Wx0OFj0mIzv S8gGZTIUi+2ertXmUB+CGZdUriPHRPw7a2ElOVxfCtpfuDnyoy0fJ1n5OxAjcy+jprhg KEUX7Et0TyBp7s8bp82hVkcElS1uA6vIL92ngPWt5a/4n1brqdhXPi6JOPV/Ipx3snGI /5+3XE0tSdjjcJjBF0DSwQYC5QH3co8HAPq3eIcir5GJmbIvOz1yZI18kBkBYwRNrrSn WitQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469073; x=1783073873; 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; bh=b8dcwWu2KjTJzkePLo9NIeg2coLsOVWSLigxpeSSRN0=; b=dDtyVvV4jtXTeQs6muvEaqjyQ7YBDTOEOuZRe0vzZkTp0GtN57surwxlaf5rh2N9r8 rnKYIcMC8lrczwyoYerOIxZ5Rw/b3/GrqPuCaOim5RiAM+wZZMkHb+ULEPpM8Jt4pNCn XfdZzKLyk1Dy/TeIUhauUN7lE9K4d5+T1rytK/5zxIgxB/hTYOmeZowi2p0vi3tKSmHh 7tJEIpoPFWu0BywK2MZBdF/3KtcDzYpVAZdSOMKOs5JemcPl+HMoVSBuQYAjzYe0Ar1P coZbXi3Sub0wnudHYK4bws74rUilWIVELlw0U/c0e8I/GIU4DrXTFwch2lQqGSDOXtdI jt/w== X-Gm-Message-State: AOJu0YyVb1/FZwZ3kJExzJXzwGkQs+VojVIwxrQV3Q2qxS9Z5Oi945p7 imPwDK/6MZhJZ7PyegEQBu41ryC6L+VqY5Uaxt528fPM/eBdfpy1aUPHn4nINhFtZI+JQwWMH/p QuxyyqagogCf1PTkMqxIgb/jLI9hzEe6AfQ5NPLfWbvg5MpXeAfSkQMGCdW+zY+9TaixdktBWlz dPxe93DJUtB/37wk/G0vj1htaYFAfGJU1ZODKtoofa X-Gm-Gg: AfdE7cnDuWEYGMI7X/d4Ar3kLCjSe5iqovOmhxTwQdnkH2CNIXXMHpVlqJDU58dlvzC wFmytxMbmYeiTdcrHn793YIhECrTgoLtyjbG0xC9F8zBjE1HT17vvVogfHpvAPfqLp/oxdmdmta iAZZoPDzUyK7tcsaOAcnSvQqZ1cHMb0GpRY9BdD6R4aWNZqo72iXRo7wc1I6SggyxZVFwK5uHtS oMixQ9agytJIYbQzYJhFPLg+M0Vx1lH+z25xxykB4a8asV35Vj+D2dxLl6+f1dHnQSuW2qn8bn+ qPiXTkjjYJlinfyS9T1mNd/vYTkYyA1BMqwTHE/OAcjQ/hRYqAPnsKSL6HdzA2T9hpwgw1e6LBO 5ZVrWt+IrGGZFDfIkQQCKPSGVHP6HaUYthYSPOhmQ9WWbHMhMMqzhY+eHm0Ef1NrT7WfyxQGcrc KVo5B7d9mA1Rgz8faa X-Received: by 2002:a05:600c:3143:b0:492:4cce:53e2 with SMTP id 5b1f17b1804b1-4926683b1a2mr78599745e9.3.1782469072975; Fri, 26 Jun 2026 03:17:52 -0700 (PDT) X-Received: by 2002:a05:600c:3143:b0:492:4cce:53e2 with SMTP id 5b1f17b1804b1-4926683b1a2mr78599125e9.3.1782469072380; Fri, 26 Jun 2026 03:17:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , Wei Liu , "Anirudh Rayabharam (Microsoft)" , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 01/45] accel/mshv: use mshv_create_partition_v2 payload Date: Fri, 26 Jun 2026 12:17:04 +0200 Message-ID: <20260626101748.1728079-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469112881158500 From: Magnus Kulke 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) Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-2-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- include/hw/hyperv/hvgdk_mini.h | 2 + include/hw/hyperv/hvhdk.h | 195 +++++++++++++++++++++++++++++++++ accel/mshv/mshv-all.c | 71 ++++++++++-- 3 files changed, 261 insertions(+), 7 deletions(-) diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h index c3a8f33280a..367519143e2 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 41af7438471..9ad16c47da9 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 diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 58d8638c0c1..0f65b65d9ca 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); =20 - /* Set default isolation type */ - uint64_t pt_isolation =3D MSHV_PT_ISOLATION_NONE; + /* enable all */ + disabled_xsave_features.as_uint64 =3D 0; =20 + /* + * 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; + + 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; + + /* 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) { --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469109; cv=none; d=zohomail.com; s=zohoarc; b=iVPfRgOhxPlheJICygpxdG1qC0f/FYUcwS0OtUprmnS4iTQOnN+R5yovajls5IFqNRvEyai+FAGlVqvhB2/lTgtxt91NLkZBb6S//fZtqSD7wOva06ODhyxB2z+NdvyTyhV14cY/lgevlZilEPX8+K/f3sh+md8QYV3DjkNEolA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469109; 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=ThgqOymbZD2sNEeS7GzI8rxbBAg23a2WJXA/vUiJ6AU=; b=Aq2s0zZ97AZf62maDkmvFJsoK2NKmlFEGSE7/imunSF31iOKFberBXb01Qv2eXiAK+zonCZnLEnlPdDmC5PKxWLIQYwKi7pObd9fGG6q2PghegLwAbfl1/wizfX1Uyh9QKpIADYp9YtsOm65/tBaXGmxF/Mt1j9CCU8g5auw7So= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469109566138.33452662781542; Fri, 26 Jun 2026 03:18:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3dQ-0006fO-8u; Fri, 26 Jun 2026 06:18:09 -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 1wd3dK-0006bb-3E for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dG-00056T-Jy for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:00 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176-5LeMvdqpORepGqppNAA5sQ-1; Fri, 26 Jun 2026 06:17:56 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-490a767b782so6137375e9.2 for ; Fri, 26 Jun 2026 03:17:56 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c1ee018e8sm26100926f8f.11.2026.06.26.03.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ThgqOymbZD2sNEeS7GzI8rxbBAg23a2WJXA/vUiJ6AU=; b=DqoVzMvEoSouSnR+kfkPKSiaw46fEJnCO5FdYMSnTx6MmdHyQ3DTwg6RHAleCzNRk9/qvu CvNVgDIMompFtc9ruE41A95kCywrNoS8zV68QDxeCyWakMkg2uIh65vAl1F2/V7YQXUaAO k+qQbeL1m7UYAymLs+jJbQhjMpMWWBc= X-MC-Unique: 5LeMvdqpORepGqppNAA5sQ-1 X-Mimecast-MFC-AGG-ID: 5LeMvdqpORepGqppNAA5sQ_1782469075 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469075; x=1783073875; 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; bh=ThgqOymbZD2sNEeS7GzI8rxbBAg23a2WJXA/vUiJ6AU=; b=dLajj9ZPiLF7yf9iZ2WIWuAOHtyqStiqCcYyzPLLCZ31LoKVV9WD5imiKazMGzXPfy i5ugHvR3HW6Tnpjos5wLo/ZJsvF/x+6hqqc2GZxb2kz07aDJwMqYyXTeYRK5C1Sg0QSm XaQ9tQmzCUivxbLOfUDNtFuDs38MepuToRTY6KIuS0KxEXzw/RflMARt3aFyO3dgbcFz 5gD1xq3uxqeSETVMgOXf5w6zLLQyKANH1+L+D6e1+PFeQzyUdL1H4o+YZv+hhmNBLapW DJhLx4kSGLakr7rNGqe0VHeI8m0nJ6/V8tBwgRylmOpkVkx3H1HKkdu/pEzHsOlBBF1R eJ9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469075; x=1783073875; 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; bh=ThgqOymbZD2sNEeS7GzI8rxbBAg23a2WJXA/vUiJ6AU=; b=kdPiseEjiReyWRdSKvfKxyFJeRpuwxrOt+W1znF4irPBGZjqhlaA80vF798ZRqGjh/ mYuggSuNtuX4hTq7/t3uIp9JPCEiLjbtCKlV+navxcD5U3BmxjPrxtjzBVoZ1/HKa3Ev m/zagrvv8H2Zd6kBzOCiGzSmTThC96SowsW0OhnoTLvVE6gNKFy9X1vPCEfIe2m0lvSM PaoAec/YClJIiGsos49a9WDLBlZwKXcVmZKTr6sIM+PPFVizZvct1lpDkh59TXXAqBdt QfKMAg43DLiwKuSD8rfScmNj2W/4d9yYx1KMHoP/BiDQ4XXArHkj6d5/Wn19yhUKsUhO 2/ZA== X-Gm-Message-State: AOJu0YxLw6garzn907kmsu/u/cs340niQGFZweaYIoueDexM1Nrpq5h0 +Tl0EA6Zvu+5WAs8xDYbIgH/OINJTxgJevufpDFCskekTAsQ3hpqwM3Jp83NmsGM2I0UpHxd9Yd Ai80BPbt4I4BYa5I7biIpDU4zFSOd8uV+jdCfDzNH9h/31jbn2YWU/RWoYaqnWwj132I1JwPwkq Gw6BSFJWusSNSedXFspgUxYm1c884jyRQ21jnMYXFr X-Gm-Gg: AfdE7cnbqWaXxiYwP9Dlgf1ygk0qGcb0K2Tr17pfcGgxCVEb1wG9YWFUliQLHIfMpVV EsOEXmEOVnFAMqhmo9UPH2vdWQIdBilFFv118Ti3l1w8o0OEWoOS0CH2s+FSuOQ/YDBfYaXEgoM 8mrcgpWqiyVLB7R4eBu8lkH0FdI/kVLZQBfUQFBLRTjLs12fWDJfOR9gam3lBvwWnGgYrhTFCQe 9lsk6rytBIqzz6dq0mQ9aMj9Ge9suLrz7VWF2n1lr6r2kmwG29BKiSiqCUVE2eRyPHgPo5fvN7e 3BLMfq46q1bwZIt8gekghLrEItKjbitv67EuWatwXBXp3bte6Pus3U8Izg8OYqigX4vEcycGrqE PF9u3p9fJQh8jYTC1L5qPBLeU//MuhF3uIJLcdX5blrnZ9Bk0ZtjTc8IHLD0dVVhkf8RWkk7C8I XGF2dWcoRVHs7HRUDQ X-Received: by 2002:a05:600c:a013:b0:490:c032:ae92 with SMTP id 5b1f17b1804b1-49266892207mr92940175e9.33.1782469075465; Fri, 26 Jun 2026 03:17:55 -0700 (PDT) X-Received: by 2002:a05:600c:a013:b0:490:c032:ae92 with SMTP id 5b1f17b1804b1-49266892207mr92939755e9.33.1782469075047; Fri, 26 Jun 2026 03:17:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Anirudh Rayabharam (Microsoft)" , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 02/45] target/i386/mshv: fix cpuid propagation bug Date: Fri, 26 Jun 2026 12:17:05 +0200 Message-ID: <20260626101748.1728079-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469111144158500 From: Magnus Kulke 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) Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-3-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- 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 4ed6e7548f6..38994ed6cfd 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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469153; cv=none; d=zohomail.com; s=zohoarc; b=FVBBGStTOxp1y2dFS0Sc7e9eSBDUh3xgcsMsCVtpSUoM44v0p3sCkAvRJ5M4hDjnvjs5HPXyMMqaiNIT6x4o7SWSFfjfzTEdV75lB68+6OTqTV+SoMoq89WGCTcPGsR2T4rfKHC3PJujBcsL65ZWu/RDjbK2LXeT1FtIl2Dt8bM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469153; 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=13JInuR6vvT0uFXBtxBuI63SjRg5X86Fy21E7KX97Ic=; b=iBhdIO5bklBS5vkgMzPdW+2Tv5/YDwot7VOOjQqPqKYt+UQqdAykgMqp5d5pkwJ5qdxQuvXYmoSMaE5il1ZScNpyu/aUqbQNcWffP+go8PK8NytrFJKINzD8hrFJyIMl/p8sjchyJLH3VPTie/FatKtkQajvHzMVjzLkCcg30RM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469153861472.52827841549356; Fri, 26 Jun 2026 03:19:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3dV-0006hN-Fj; Fri, 26 Jun 2026 06:18:13 -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 1wd3dP-0006fS-PT for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dL-00056r-Nn for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:06 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-QJXxaww7MnOEmNPkqA50Aw-1; Fri, 26 Jun 2026 06:17:59 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490aadb1386so11095305e9.0 for ; Fri, 26 Jun 2026 03:17:59 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492690988e0sm71791375e9.14.2026.06.26.03.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=13JInuR6vvT0uFXBtxBuI63SjRg5X86Fy21E7KX97Ic=; b=b4ys5Xre7lt1krkEZoME/VXsqxbWkp1q8oAWfK6wanZX4XWsgcSk41776XJtnWWcsUOL7z tBcFMO3kM6Q9ryoJEQCZVt92mum3tknt+gS88HHdCRjwnIhmRYP1dL91LT4S4bQB2oZjQu d9AmIRiphCtvrjfLkgPm8KHsQ9d25q0= X-MC-Unique: QJXxaww7MnOEmNPkqA50Aw-1 X-Mimecast-MFC-AGG-ID: QJXxaww7MnOEmNPkqA50Aw_1782469078 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469078; x=1783073878; 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; bh=13JInuR6vvT0uFXBtxBuI63SjRg5X86Fy21E7KX97Ic=; b=TSM5GbB8ca/ikDVYE3Wy/lxIIT/EE0ZEmy/EAUIF5Uc/Hadjeygk5g7MVeCSxpusUB t66uqqJsah/H0j3AmwpMePvYR3RU1hcOHhZVE6qi4ialGz5a0yXdJttk2kaVAJCBTFDu 3ahOVfJ4vgBpyynDF9bzChcfJFkykFSfM1ODsIngn/cMbRMPvc+A6Kv6JTi1lfuRViT4 gMyryLTmjcBPrgzub6l1ptF46/43KAUBRc9SA6lLYfisAfnXlPU638LXjPrOuSnAZM3h ydgfdUavmoKYbpDt5WhLxV6lcrh1nuKYishkcIuPZ8PXDkZM5J2D8nBtI5p2iZUnwE+0 X2Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469078; x=1783073878; 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; bh=13JInuR6vvT0uFXBtxBuI63SjRg5X86Fy21E7KX97Ic=; b=kghd7ecWcJ7WpAvynS6xMidUb/pTt+1ZPOL4IZRl6Kwh9ID+EYgYl3C5gviuc+9hPv ZjvvYyJgXeEl3kMlfGaZb10/NMCao24aWnWtP/r9pYO/SUdKzT77unlNdI1FYQVFwSjg 3Qvuh85/x8PdOgS972JQTXThBOo7ca2QKw4o7K2NCY8T33p/S0L2XS56L6cb0Gu+Jy9h 0Wb4caPzimuY1rNgdtYFrsY0WylZZU+i2fRl60Ba8sByIVALOPNcKZnz0i5SDYBC9sSU HI3jw/+WoyiqbeBTJOf90GzU3+39i0KUamvEy0K9aPl0jE3bWkPasA+eO1brdYue2cC+ wQsQ== X-Gm-Message-State: AOJu0Ywd0QkFo/OL40WuyBKGVsvlOT/1v6TtbnO+YLLamCkVIG/Sbcaw 3Y2x0Hu0OCtG4DSVcVpQ0gms/GAHis4fhyyB+mu1l6+p+5mbadYtsUa6FwDDlAqjmWO1FLK2nhy 9A0VvfZdhmZnpPZLrtFxkALJX9803FVkFrkyhhRg2M3TDMwk3LO/AnGINvVbYGJc7Vct+w8eFOi mt+q64O9tznzFKhFj2O6QoVE6Bf6eXoc7c0qRA3QL3 X-Gm-Gg: AfdE7clv1AQvdZk/LODUS4YlhhrqdBzBuqgRkUu+03oxveUam33J2XT3E9GFdn4QMBd BnxGjSjbJd1Pd99FfWlaTYSkw9N1rEWOvhUKkMWqTAb3sYaAPucHxrngk3yLJ5C6o06KMxhj4gr Orglwwa/ugCwk+F63o56ELyzVQYC1IR2SI5uecOiqqBYfaIV53a8Jo0kHyeD1YLt+D4KFbwEiXI 5EsyXtiP8R3qWdaIQcF+Ogdj4VUTbbmOyKoDMvwndtYCjFZTIOK00Z5nPK9Hvx3GOvnC1Wq1/4R I1BHuwUVFc+0IP/tUSL73eqtOBNypuFuhR9amoRD0r3FcncAAWbdaPahPGqcFdjeyeW7EW40lIi PK3fVYOBvBh5mQ3Yp6ZtXkJbITr5XsF88BbU11B2FNsA2JxWBsJoqSWLEL8cod6iKXKeX/HP2ym QkUPXI5AOgG+41PBYg X-Received: by 2002:a05:600c:638e:b0:490:7df7:9190 with SMTP id 5b1f17b1804b1-492663ea3d3mr71783945e9.8.1782469078110; Fri, 26 Jun 2026 03:17:58 -0700 (PDT) X-Received: by 2002:a05:600c:638e:b0:490:7df7:9190 with SMTP id 5b1f17b1804b1-492663ea3d3mr71783335e9.8.1782469077561; Fri, 26 Jun 2026 03:17:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , Wei Liu , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 03/45] target/i386/mshv: fix various cpuid traversal bugs Date: Fri, 26 Jun 2026 12:17:06 +0200 Message-ID: <20260626101748.1728079-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469155207158500 From: Magnus Kulke - 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 Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-4-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- 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 38994ed6cfd..bfcccd19916 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; - } else if (entry->function =3D=3D 0x00000001 - || entry->function =3D=3D 0x80000000 - || entry->function =3D=3D 0x80000001 - || entry->function =3D=3D 0x80000008) { + /* + * 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; + /* 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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469164; cv=none; d=zohomail.com; s=zohoarc; b=cQ7RyIZMNRrCpI7NSdIrJvx4dFGNsRBBwhLmjL8A/x4Nk/xXCbEXOhOMwq73QASmISiDYtc4hwDznBdGCnLd9t5GYvSTeaoPyvfS0qf45e0TK11+nSbOR7u8BBUlWUfg/l95P30kzPuOcXg4HuW5L7A9kMmEqcTTxCgiSRrpHV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469164; 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=nEwm3fgpo3qUaz+yBGQLuR4QP9rx2aWp+MStI39TbBA=; b=VhWEB1hCQhrM62EEamQ2soTOikKaEvFSGVF7R2wpUuJU6VNiQj8czThBa6fwCIilYr7zvnTAJquq4wbDQUL3cKtVsCMxEF6jhWFhEt0Gcg9gogsSr8ImT7WPXPwhr69CIAgfmEiAyS8TkrJVfykJvy2rPjegN20FipoIDSmrR/c= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469164410528.0838563502791; Fri, 26 Jun 2026 03:19:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3dV-0006hM-Ep; Fri, 26 Jun 2026 06:18:13 -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 1wd3dP-0006fT-PU for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dL-00057u-Nv for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:06 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-_iE0Ade_Oiio7PGtYhV26Q-1; Fri, 26 Jun 2026 06:18:01 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490b2f22ea2so6705585e9.1 for ; Fri, 26 Jun 2026 03:18:01 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c221d93eesm22896620f8f.20.2026.06.26.03.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469083; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nEwm3fgpo3qUaz+yBGQLuR4QP9rx2aWp+MStI39TbBA=; b=S+XiqHhuPHp43ewldYaYOhsPAeqiQfD2bH6M0yqj7Y+efaifXIYh44dM0zxotVEokJH1ck +o08UjAj+cT7c9GvZUFhOaNNn0gR47UCuxeztrapxlB94ZT7XC2xUJG/F7D4k/lCi6/wZY cXsoFt7LX12GA0jjVSyHYZEJloFfKSY= X-MC-Unique: _iE0Ade_Oiio7PGtYhV26Q-1 X-Mimecast-MFC-AGG-ID: _iE0Ade_Oiio7PGtYhV26Q_1782469080 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469080; x=1783073880; 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; bh=nEwm3fgpo3qUaz+yBGQLuR4QP9rx2aWp+MStI39TbBA=; b=JyG1/wYPlLCPG98YfDf+/qgNX0XIxUsfl+diohFKtRbyKEEIxt4rl7wL51fuPH41K9 Ef+X198u/Hc3A/JcO5S16o6VYAdFsfyc3l1NHmSKusso+AAQwjntzAfZjo13GYtl48Mq ZCgeD0LL6lOzpsckf5M95tf/BeeoWfPUEt5bEVPcUdrAN1d90JmENX9dQr8uCZgmyzei FGzE8W8tV6ymz5OW3IgNeZXLG3iWrv0i1Ou+77KwZKqjCPBk8bCLheDVwLbjKuRCrqf2 59nrnjFKSkG2uMr+kp8Ff/++atMvMgWHxtNkaWCuQU/ccQZx+ZQCigUedrSNhrfH2uOw KJfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469080; x=1783073880; 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; bh=nEwm3fgpo3qUaz+yBGQLuR4QP9rx2aWp+MStI39TbBA=; b=pfJ3OCyv7YvRayFNvaOtohX87i/8r5BWS2UD69eYRefPaB8ZtEyoYFpqwNpvDXTASk BdhNchcw8MHnXie/HoU0TUINVpa6pFCCArI+c4DYVZUv645uPndjqEPa1XwQJXO5Tokv rqHB1n0yar1CQ9IaZ8zjzvlQ6Q2gHiMSpnZzrxGaC9n+E3ctNYCTC06OHmbadAjT4jXC 4LMWcjrHJuVpjC93PXJBMGjoE3hGhaMwmna3QOL6MECfPZqKHsb9HhGI1YeYgxm7G/4u 1BMkUwUk3UL/WWJRQ0qvzpdGnVVESvaWOJFEtq+cfbNXJJpeJKZwVVE+9MVbg03TTOGh T9Fg== X-Gm-Message-State: AOJu0YxMsAROpih61WjWyxCrOtooed3LjGawjEAZkSvXhPRfds5ktfCW 3MXbu81YuUwllruh0plvsy4F5QtSyh+4fmrYNy7AorgUM60MRGaYEvTYg2zyH3HkEsmfpjDfUUc wIsVybrfSiesSrJtWvE4m4zGyMFkkm2bm3l6AnNxDpKesbazXfuPDluyUd7H1Jtt25Y/mBQcmIX nZ2nUqrNuZkeUtgGa3Z6Bf1vBx1MNCuWJjTT43dQS0 X-Gm-Gg: AfdE7cmmDHPE+9caUf9kmVeYtGI5eMD5OltxCgwb3FTw759lRBfreL5JUHkX/N1EgDL ak+zBO7hHqmIPvTAzPRFiah04jpixEY/2ZrUQJSSQuTM9NxmhCQ5fLYqiBG9MV7id96Mnxx+CJe h9UFb2eDNRIwM97e8eF6/3muMW7zHR+c1pAXl9P7s+1WxZkTPBIU37Tts9qc/XzOCmbfRoGuMgk Z/jNa9qZtjH9duoxpClgOJfUFQa/kcqF2keJWvNBIK2ITD+GXqLTx98JGI0H/hPxrDOjh3JAK/N XXRH9tBgt1eEa0UCRnKlZLADrcSvlaBAsfYzFttY2XQB6in+4/BDMhFF9ne4sGL/aUc2FkGNMCb zSN8jfxMGbgUWfazNqXKztIHBbjbJTAgXbYcjKHRvSLaTejPgdL+QzwwcsWlT0xprxUFKJHmtAi 4JM9WzE0xaFCzqH55V X-Received: by 2002:a05:600c:3b28:b0:48a:906b:14ca with SMTP id 5b1f17b1804b1-4926687e77emr84931805e9.20.1782469080261; Fri, 26 Jun 2026 03:18:00 -0700 (PDT) X-Received: by 2002:a05:600c:3b28:b0:48a:906b:14ca with SMTP id 5b1f17b1804b1-4926687e77emr84931195e9.20.1782469079749; Fri, 26 Jun 2026 03:17:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , Wei Liu , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 04/45] target/i386/mshv: change cpuid mask to UINT32_MAX Date: Fri, 26 Jun 2026 12:17:07 +0200 Message-ID: <20260626101748.1728079-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469165195158500 From: Magnus Kulke 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 Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-5-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- 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 bfcccd19916..2ee46bd7025 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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469151; cv=none; d=zohomail.com; s=zohoarc; b=doNa0XVFAyMDRYowIDjdxTx6QzC+skVkyhJR2gk23jWJOa7Ik2XquWhlZh03sXake9lpJqHKq9It/EQrVzZz8IEQXzgmJFA/PWqTvkkAWqGB8ZBHTY0zghqFFkrO/jlENpNB9x5g92ofUUBebul+ei86NCJuVCN4prnmQ+r7rpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469151; 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=AwzXuwEdB0BbvXaBC7AB+nn3Hymet5lsLzgBQBOt6m0=; b=kqzgQiwlhOTOJ+3ga9YQSX/omsFnu2wAgwzc5drkbpu66WI6n/yylR42bPkT8SaAE9G2VFQcJoaM5LjRziR380N/KJh71dGG/FNVKGzSnHE7Hz3Ei94PzhRTG3FbRStbu0hTQnbJOx50nTkZyW3USXgEjqdrDDJ7L8gqf9z6CVo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469151858333.8725522335171; Fri, 26 Jun 2026 03:19:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3dV-0006hQ-Jc; Fri, 26 Jun 2026 06:18:15 -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 1wd3dR-0006ge-L1 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dP-00058c-IF for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:09 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-x_oe0q7iNkapuwzKdROMvw-1; Fri, 26 Jun 2026 06:18:04 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49244130073so5946735e9.1 for ; Fri, 26 Jun 2026 03:18:04 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268ffe204sm69038275e9.7.2026.06.26.03.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AwzXuwEdB0BbvXaBC7AB+nn3Hymet5lsLzgBQBOt6m0=; b=Jhz2JqywBIXEUJl1gHFYc2BDET+OPzOYBZzOQfkTAxtU08142uiUAtP6EijPyzOm2UURms fqkirywK1bUpeQ0cBaTFlt1ZtEqpKhv0/cv1ZVWvv3lya3jQI1zdYgvdjjudOVWaKmyedA N3TMKa3xKWyBP5NAW7I9AhclWqRrzqM= X-MC-Unique: x_oe0q7iNkapuwzKdROMvw-1 X-Mimecast-MFC-AGG-ID: x_oe0q7iNkapuwzKdROMvw_1782469083 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469083; x=1783073883; 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; bh=AwzXuwEdB0BbvXaBC7AB+nn3Hymet5lsLzgBQBOt6m0=; b=PtDe6EhAloduQyGpOeEO0b+JiFMnkVcPZDDkX8vtlqmsqD9f3jx1W3+LSh6raNLmcw beMAo/OYlR0+XWvFQGa6UsGz8A4G/l8TV1vrRa3r9khwypdSAc1jOt37VqpBuOxEt1kt LeusXZ60HZ6FCPddp398OvmF9qeea1/GAEdFnUvc6nl1nS42ASAJM6iy5s/+pvEdIYDN WcjhWcu/ferz7i9kBF+ls6m5+QqRfHCQi6GgmoZm7tVwMucRj3mls1hathYZZodtZ378 lqB3j3Hzuu6AThl2Wy/gyuwXs5/1vojYCu6VWw7TMVWQOkaHb9OiGpZQa9+OPvZOXjFW 1cZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469083; x=1783073883; 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; bh=AwzXuwEdB0BbvXaBC7AB+nn3Hymet5lsLzgBQBOt6m0=; b=gBBdE1DvtC5eGtv39pX+hPA+kIv2LQA2ja/6qIJ0XCUv73UYU4ROpaDDJqs7I8WC0Z 6RffoUPK9i0hkzHGEJZr9qZCuxgGsgQ73XdG4VOfCdcQRMyFhZ1ahV7VMQLTMy3GCqE2 s3Cl6sqKR6ioPIEsTY5hW4FGx9742VHQlqHW6s6juRLBCnq5UBOteSOzdmXPM0cU1hV0 BhAkCItAdUp9pLsic2KR45hQBrX0HncCVpQ2SzA2NRtuiEiOl9/gHngRg3ywutgBln9e +B6CitNtLWVoKMLBv8WobjNFAQf6/pJiWUpX21nehAbyWFyd8Z6micKf4/Zzo2mMlCIG 1ISw== X-Gm-Message-State: AOJu0YwtbsL0F5WnddRvCPK2k19JXIByKMSeQqbcK9JQsW1w/1NMr9i7 n6JUdO89xlynUsdpAT3DqIhve/XfAhhGrnhbb101PZ/w3ZehCsVMJSiA2hnDxHvNSPkWB8m0TWl HCLIqw1cab8u5Rl/L7bzmHEiSVatRDoP74FyH8uIPXs9aCkM6AXsAVEtLBj4ap6SP6vFpk4CFI/ CYDVOtzl3F2dvM9Q+VEWWxYoDTkj3Xvx8UE/2+EvD6 X-Gm-Gg: AfdE7cnRA5VKXAgubYnjW3EbeukWU2ZlHpt93USfg0vBUWLp0OlZgtmf3d4x3N/aFBg ZempRp0PrxqokN4GWI5MYUGQpBbDSZj7SAvydIqlJaVKPVa9lmZ5+afj4FA0lnukhZP7z4+MIDh iGClFTS42Wo/uVXzB1gocUdV6oybPPj1CxPr5rTjgYUyjIucsTmLhCnQlwcpY6bQ6iOb925QrDl H7Hjb/CviBaS5TzvThGHHEoBw4z42dXoPutw1f+B3CKE7wOOS4SJZ/haV33k18kFJlMaVuNqsOw Q/ipedv5dzHTR5on1zaYma020Y3xbT9A1Kb5rIXPJckh/CX+jRt7fkLW97RVpzSZwZLWvzo0Th2 gdTF40hcLk+zn0MU90x8b5U7SIYV++6ptdsERs4CkXBvfrcSXN1oDqxFMIdARs4907FB5ADsFoG mswxMtsvXV7Phg3xDk X-Received: by 2002:a05:600c:4e4b:b0:490:e196:eaee with SMTP id 5b1f17b1804b1-49266872cd7mr83715865e9.10.1782469082904; Fri, 26 Jun 2026 03:18:02 -0700 (PDT) X-Received: by 2002:a05:600c:4e4b:b0:490:e196:eaee with SMTP id 5b1f17b1804b1-49266872cd7mr83715385e9.10.1782469082347; Fri, 26 Jun 2026 03:18:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , Wei Liu , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 05/45] target/i386/mshv: set cpu model name on -cpu host Date: Fri, 26 Jun 2026 12:17:08 +0200 Message-ID: <20260626101748.1728079-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469153160158500 From: Magnus Kulke 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 Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-6-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- 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 2ee46bd7025..d65cba5de15 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 @@ -1700,3 +1703,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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469254; cv=none; d=zohomail.com; s=zohoarc; b=Ui62Y4iGM2cDRmmXK8x48ZzenDb4gTJjPltmIMM7QenStdv0+//fQYkUz2p+2DrIogFrunBnnX9OOkktyFd/Wx9C9QS2N7SIeC9/PY0xlOp6cPIn/6KhG/SpW3greEYGjF/7VdwAIXD1ENQ1RcaV+/+TvcwsYfFRTKaGoVAOI7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469254; 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=Aa+Xsjx5K5pDGJk98eX7HipvLYuuQX+T+6KcqPv4wgc=; b=SPtFsgGEIYWh6XHLAPyPx2IBL5ZOQvBmkGG3Q98UGX5v9n7yvbxp5qpEt4WVjCfOY4bnFPclCBqrvsYsiPyX3XbeauDaBMELHyiOPmR+lRxAvLbyq2twsxNlDnsoM5WKA8SNDOSh9nyQqddmkmNKqEwxc5bGTOKmTKrUjgCljDc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469254756978.0279009857823; Fri, 26 Jun 2026 03:20:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3dc-0006xa-9j; Fri, 26 Jun 2026 06:18:20 -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 1wd3dV-0006hV-P9 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dS-00059T-Or for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:12 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-8-ljq7ZIpnPjCcfZf6zhAt-w-1; Fri, 26 Jun 2026 06:18:08 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-49243626f15so6939245e9.1 for ; Fri, 26 Jun 2026 03:18:08 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268ffe204sm69041655e9.7.2026.06.26.03.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Aa+Xsjx5K5pDGJk98eX7HipvLYuuQX+T+6KcqPv4wgc=; b=a1uYjv73uA2aSm7UZoIQZFTMZg/EU9OcAdixJkm/uvZjofRCfT/7DQVmZGj6j91WpqNLcu bb7f7GbJxLWvcG0gKfK1sSYL50a7YLpRyelM3fSZGErFCh+o1wAA/A3j5Gfkj9QUa/WKio 3X9tk3nmrnULp5hvaIv44FnB6O6b2tk= X-MC-Unique: ljq7ZIpnPjCcfZf6zhAt-w-1 X-Mimecast-MFC-AGG-ID: ljq7ZIpnPjCcfZf6zhAt-w_1782469087 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469087; x=1783073887; 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; bh=Aa+Xsjx5K5pDGJk98eX7HipvLYuuQX+T+6KcqPv4wgc=; b=k40nWJPWrT1yCUph588MIChVlI+5jTVuNJrH3zoIxJCkRfcOGaZ7vkuWvGT+l/qldC dwJinJln+G3y17rB5mcsEwhHvrxPyV8POrktOb6tKVKerJE69iIIr7jHweWU9a9y99rl ZTgLEBdvayT9P0B81yQT09Klt59NASXW6KY39Zd4HlP2pxsKgb24lQIVBwOtDAdshWCn nNgkSVFa32xd9MlWx44ZTNpvO6bHntyi3GVcSUUj+1WJFmEyRqwVq8ltWMLhLdlDgJ0y l7pwt/zQZfo4gF+nYPGXIgy+M9F13GQU+BcoRRHAyxIgTHCWb2nQstIkopQgeYjwwyfx E6JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469087; x=1783073887; 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; bh=Aa+Xsjx5K5pDGJk98eX7HipvLYuuQX+T+6KcqPv4wgc=; b=O6rX6rikNmOhcJPVeKsPlz8DlZt5b8NY8Jdu5QjixjqRBycEsL6cCbdCE/PlyTYqyk EsvCmRal0yfRs6forCr9oOZ4PLK+9zIgLQTer73nDtKeuKaMmyQIlFF1LCl1oZ9YJekV Zlr5leW6tUqI4O2s8MP9uQ+5l0Xvktpi3azMGKtJPpXrRpCo+GOy+ckKj9H3ufWhMHVa 208Yq9BsbnWVz4zmENjwHc0AkCXCPHTYpiUHnZ8bevKWVBczrOYnBT47A9GY0lBGRreS QSZN144v3xnY1P+ulYoLzHFI9lbZ/eJ/WIAaVowS5XB/aeco9oXM7Csw9oAYkpjwToTU y9yg== X-Gm-Message-State: AOJu0YyGcaFT+gP4e5whztt/ea28Us/hoBuw8Ek7QN8zV8E9A0/FDxKg mKpxYNKNm7UwX0rbOknP1s8gWWWXt+xA528DUq4B/EeTvFkTl2RDcI/ZKGhpFdTyAeUl4AS3Oh4 +E4vp2h9TK7SaXLvE25Puw3FJ0bpFIUNSVlELEEfcyyycOTNL2swmB7zSUMdAL5GGWOED3rIrY6 +Q2f+sVW6XfJTgq71Oygr/XZ1WBwbMd7RhFcfQcO/u X-Gm-Gg: AfdE7cmythwUU/0EgLFWrR7KclfmKyiLE1k3qt+SXtqRFl9WtrHOm9B/QzSudIUP385 NpVmnI34gLlm2W/H5vP4Ns4WxRi9vMFvomEdX5iQNN8rtGlNyrqsHPMlPI9Q+733z71DuvE65to fXbTaTsp7wZLJgTU3BPJiurxHOsr1kLNc7g4geZo6+PXqOFWzjXKdag3V2zZ2/OGL+bKOVw0+MM V9hCA6+WqutCilQD7Frr/f7axFoauHqIF/BubAX6OYAcjQnyTbLCJpEROzLmOEQfQapaVSnpKY6 V0vuY2A0jwR01JDIN1c61Pu3zZTg25MK2EtbM/puKne95AMJ0xR0DaScEroTca0bTHf1/4WItd0 Wz/FEZoEbI8WoepP8gv088PesECRbKfZ7KI/Qx8DbrhHr1ucYdiQtCM9PeJnzv9Xs8y50dNG+nf rn4F/t4RiAsBDTqZgd X-Received: by 2002:a05:600c:a403:b0:490:9782:3eb8 with SMTP id 5b1f17b1804b1-4926689fab5mr73583595e9.25.1782469087152; Fri, 26 Jun 2026 03:18:07 -0700 (PDT) X-Received: by 2002:a05:600c:a403:b0:490:9782:3eb8 with SMTP id 5b1f17b1804b1-4926689fab5mr73583075e9.25.1782469086606; Fri, 26 Jun 2026 03:18:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 06/45] target/i386: query mshv accel for supported cpuids Date: Fri, 26 Jun 2026 12:17:09 +0200 Message-ID: <20260626101748.1728079-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469255768158500 From: Magnus Kulke 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 Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-7-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- 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 75286baf165..51b04207358 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 8929a75c7c9..5805d33ab92 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 "system/whpx.h" #include "whpx/whpx-i386.h" #include "hvf/hvf-i386.h" @@ -8233,6 +8234,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 (whpx_enabled()) { switch (wi->type) { case CPUID_FEATURE_WORD: diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index d65cba5de15..00b8ac18e46 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1664,6 +1664,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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469252; cv=none; d=zohomail.com; s=zohoarc; b=Fqhcz1sHuiJd9XR0uvPkr7hPRKJmXu3KPFOq8MBSLtD9lLD74FamNO00B5X0Ea2UxJcRoMfAj8DBh3rMgQeVqirPpM0zVg72O5cLhEQX/THzF6aINTl8ltvkskLaTX916uXc5lXhvXtYqaJ1YM59zsX9G0F1gQnEGYd0xZF4rnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469252; 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=KJ6Jhva/9BMAzE6GohjBEcGDjyJ5xP7a38OigOy2rm8=; b=I4flIAlrOkKM8oNKj8Xk7chP6DyDkHocVKnjwVdzyN4cI8X9vHKyJkAlh3cSVzP/9Pz4GvrL/7bswoE1iUPykkbdFL7mvDh3kRbs3TRI0lS6gSx/ki0Q1BaT6eu9HyZ3ABIij/Q1M9kibF30ur+tRjExyiFtjbAg/n/Ensl+fHA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469252923669.6014204832728; Fri, 26 Jun 2026 03:20:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3dd-00076q-Lg; Fri, 26 Jun 2026 06:18:21 -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 1wd3dX-0006kb-GS for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dV-00059d-BN for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:14 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-XzxnCCHIPFGX_DHC_lSe9A-1; Fri, 26 Jun 2026 06:18:10 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4924a7ae480so6762635e9.0 for ; Fri, 26 Jun 2026 03:18:09 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fd9f2esm60218135e9.5.2026.06.26.03.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469092; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KJ6Jhva/9BMAzE6GohjBEcGDjyJ5xP7a38OigOy2rm8=; b=ZlcIB7+vFVUimU4yT8nmd2EFQUGro74ufx0rEDApDgNjGK4zMP2ug17x0LOjxZgNLLwv5F bJ/yak1dAGkLEeaAJpBwPkGXU3s4qtrMstXXF63qNMfA0LFjIFSy2skUmxwqc2X6aUu80/ uxp82dXpenKAOaK3JEK4nkeyxsrNZQc= X-MC-Unique: XzxnCCHIPFGX_DHC_lSe9A-1 X-Mimecast-MFC-AGG-ID: XzxnCCHIPFGX_DHC_lSe9A_1782469089 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469089; x=1783073889; 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; bh=KJ6Jhva/9BMAzE6GohjBEcGDjyJ5xP7a38OigOy2rm8=; b=Rda13KxWUZcqrXl7QB56ZsA7B1PGn2fDs1YeCFXUTWlmxQkoaMliLBMZtKuXRaQIzI /cInjJmVg7u8c9p+6s8WJ9FL1X8MIRGnQjOzLn20Q2BnWnq3D5F9hh6+drS4rjLPQbb2 UlhjpVq6b+07VTO7OKeA9dAyR33G0Gfs4Suralp8+E6Cj8pheF+D9303PgPoSXrrMRCi TJtLIpphAVlmaasjwXMdxDgtIihbr3Zjm0xsAtZXmZgMOrm3ex2bcxVj81jfuaVussi4 jogViLBczR212qH5SSbShsYN+rZGEGc+T8olVKaLbcjzwikWu+SeCZfcD8ENNjTma0s4 D/SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469089; x=1783073889; 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; bh=KJ6Jhva/9BMAzE6GohjBEcGDjyJ5xP7a38OigOy2rm8=; b=P35OVtF3E46ktmXo7C++w6ZNE/4iRM1y6K7hje0lopKbWEKl/XCLmCCt5I5bMjpg/M 9IveNzOGqjNFKXCiaW25AP8o+Y1ZHpwczI87P9b8MJv+m7Is8a2sflgzGwezYznizr+l TfzuaQcHYZ/UvoB31sLCzZfbz2kAhDo6PlAtChx4nF/fNurBN6ZgEiUu6H7aeRlKhQc1 7yFKTEsBHUHm8m8oPAegwp0+TZbFHdYocsEGnwcWldnOtujYZOGnyJmSxusM6pAiKOOD pzz49Vk3wT6EY4ANGsmyaQJbeiIBXXtNuHfEj2zRdx0m3DFOcgIhLtkMh3hZ3O6kJeU1 qjmQ== X-Gm-Message-State: AOJu0YxhM8EpPKyIbca73XFtO4PiQZnjEtqgSy4yI0oE+Em9qmFMfNoO nF5HB25vKGbYsFEDN0ZZz5krmmNDMO4IcvqxLMYH9SvkcWyrqkLXkU5eM6PjusZ28M5Xk+sEyMU Jmy4HefKAYDMK9rZ3HAh2ipbUJI2mQBPT1sX+R+1jycbgQ9s2mqc3wrAWHvJ4Yga5QUcdbw34aq wA3KutAWqcvpj5jbH3DrttRuRdJqWservbrkn2UZY4 X-Gm-Gg: AfdE7cn+yGtJFomDOnnwSlFdPANQ2oKbIINr5cmf/rBWvl1GqTCv+xN72P8DLQ/N67X fyBN/C9L2TleH/wrT6+UhReDcJwqPzKdZqQtTTjh1pzyTgMUiu0FnVgp0KAMRm0kf8a3qOWjn4p j2YblD8SLBrGt5uFQ9DyP/rQjPeE0CccMG47GmwqCzXgEoaA4tYRepWjPGtXJqYf0Bm8ptRnWNE M8+mWeW/spM07CNlDptl89aMUnJLfrkiZhGP3bgcbSiqHzVFHfYDIY+KLk6LzCP4fAEAKEDCgj5 Orh8+lua/4wMbvLjHKrCFxS18xTKrN28O3UfgDvEMaO3Z1GNLo3XkapNPAGtlkB1yxx6IpYbcQ/ Mhbm6iiw18Z0/QWpAlrqrAoCtSlu782uIdu9zoa9OegXLRgAjYtApamekKktBQccVjsLgjdmDTA wL5/PiSpTg09F8PyUV X-Received: by 2002:a05:600c:6085:b0:490:44eb:c1dd with SMTP id 5b1f17b1804b1-4926689f39cmr95147435e9.29.1782469088824; Fri, 26 Jun 2026 03:18:08 -0700 (PDT) X-Received: by 2002:a05:600c:6085:b0:490:44eb:c1dd with SMTP id 5b1f17b1804b1-4926689f39cmr95146865e9.29.1782469088394; Fri, 26 Jun 2026 03:18:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , "Anirudh Rayabharam (Microsoft)" , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 07/45] target/i386/mshv: populate xsave area offsets Date: Fri, 26 Jun 2026 12:17:10 +0200 Message-ID: <20260626101748.1728079-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469253744158500 From: Magnus Kulke 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) Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-8-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- 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 00b8ac18e46..66733390c3e 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1731,11 +1731,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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469126; cv=none; d=zohomail.com; s=zohoarc; b=ZW9XG3r0eb9Pv5ScqHrJjEUf4mHsp4w/dVDbkn/34gtCj9s6rL9HgaI4q2oBCci4W4549z1DrYk48G61MJKnK0ZTpg6pR/ZoApjlS9Q4Kkkdc3HIuJTezPJKczdcJM2/rOj3UeZ4zCgu3dc8t7URdwQNuAozLaNZ/mi87nHxQiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469126; 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=0/SUZ46ILgMpKxSzRAlv4EG43tnwctwIT3ZzriqakKg=; b=EEtNPmklD0abAyRbLNIbnmEYgWvMfBMcAY7k61x3JUQ057TDDxlBPh5YLauqEf1LYpDUZ6QviprsKmXJqbuAHEcVs3ivFQNKUC7wc6GgkXccr9IGAuY3cY5RF47di/p3D0mTweYrY8MyraN3QFqTt5G7yPmWIyZTyJlfnwPJ9cU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469126124346.7627009895631; Fri, 26 Jun 2026 03:18:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3df-0007B4-6a; Fri, 26 Jun 2026 06:18:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3db-0006wb-9L for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dY-0005AF-6Y for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:18 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-442-vfiC5pkrODW2kziXLqdvnw-1; Fri, 26 Jun 2026 06:18:14 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490ae461f8dso5122995e9.1 for ; Fri, 26 Jun 2026 03:18:14 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46cf775a4f0sm17463314f8f.17.2026.06.26.03.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469095; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0/SUZ46ILgMpKxSzRAlv4EG43tnwctwIT3ZzriqakKg=; b=VDElvQqRbPLuelZij5imSGCpijkF2hsNds4snpNu3DR6zHikRlBNMa+oNmuyIn5RD0m2Ld oPFc+kR9OTXEak7Kvl5pdJb0/TdKr7kMwMeE0qYyl09YNnsuQBt4RDwAtDELP5TSK4VLTH 2NGolwf+gbGns/jI7Cv3hz5nziNFaQU= X-MC-Unique: vfiC5pkrODW2kziXLqdvnw-1 X-Mimecast-MFC-AGG-ID: vfiC5pkrODW2kziXLqdvnw_1782469093 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469093; x=1783073893; 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; bh=0/SUZ46ILgMpKxSzRAlv4EG43tnwctwIT3ZzriqakKg=; b=BQoGu+SjeXIi8BeGha8O87pxH+CWIetnLmEOxwsN4z5RMUyWFgT00pW63BcwwLMUeE bajQsegCx4O27aa2mZnUdXSJVY6cAppFA2QlvWGZqzt+N++eXjHJEl0ydzU15uMuZHbO JgXv+inwqAC7TngVeByhHxn600sW9liJzctzOHkQJlyAJjvi6Xg8tzp1IDaFVHH3lhue HCRgHEnokT+Qy0UK2FSdFMZ9FCkK5/4Gso9763KDTZz9sOSizeE66mRjE9Bh/+rPGZJS ajlpayQUbv/opkcFFjQNeRWnVpqxufxQ4iYN4ssAfKOvzQUgDG/ShvbLNcP3waTnGx48 02kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469093; x=1783073893; 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; bh=0/SUZ46ILgMpKxSzRAlv4EG43tnwctwIT3ZzriqakKg=; b=EpVfausHiQkI44LG309V38VPi4cAm3uIDtJQaJzXimGdR7GwTRaxDhaY/RjxoELD24 Z0x/zCcASPbZH/zYJtN7w3ACNXEpkemnswenan/0b021lo8V8YOkFHjebTrEZVTeHrnd AqrYn8tB83ZBTvvGmcLPiosgifMIg+83bYpqWN4qOz/cRVBsYK0MgesJyHJAa3NyYbRT pQnDOFbq8l4ejbACZSQKoyTFD9oiy8pyS2ZjIqxUJcMAYc8clx4Z54Cjk+CeUyr59Bwb GyxEWa6aQSEZstCpY+4zk1mvUlvMv+e7FuYucGXSQKbMuVH/Cp4/UXoyn7yzCvc/M0Fa RkIw== X-Gm-Message-State: AOJu0YzcHlqlHTZXAzmMlWeWwpLph0/o/gXtg/8nqWtWneGwRBp5h7RO tDvEPEiE4aMKVxL4Rq58mK5qfoHeStiVIBQkXXfIkg2m1/BkkCR8aZ6n/aV33UwTJXBL9s9foQb 4T4Z83HXMFuI2s1SGRF81taGm+Zb/rhbx5ptbD1MNmBytc7HytiiVi+Tx8yw/jJuDkFLn0qg7tf l9QGAkZhM4tZGl4B0eFnEbQxDsjulrmgEBJGOiuILC X-Gm-Gg: AfdE7cnmHzkLQe4BI/2cr9vPZjkk+LL4ud1b8LsZW4C7Jv/fofVzk9wQduwCYJhiykR 71vWGUByulPUh7J4asJr6+omd/loj1A5GBrMl3blat60BNHhZlZzOGDLIxODJAbHdGGM9fs9FQi 5N4nMF96WLJWJ0T9h/Kap89BFyXK+nThy5AcE+LZS84Pd2Th8HG5nlOwjPlFD5r9JkiYql5Qx3I eS0P6Psb2ssZEzFBqxyrXwnaCn1vMgq1KYJpqv5LB/JOZg18C6EgaqttiQlv8mIP8+pTt/MIK7d XM14AQO6pd7slRej5nqU4Vzur+wI6ZJedspzwkI/E8hHCA74bQHl631YR/NVd1MtRHiDBskPDSh QqOiFQ4Zb51yhD5t/YrQC7qLCuQmFJP17eVb1XRM8HaOKnfqyvu1QueFXIvSXGWKZHTbI5yDxda pLPA6NWKUhBIbxJW6z X-Received: by 2002:a05:600c:a403:b0:492:4e1c:120 with SMTP id 5b1f17b1804b1-4926689988fmr77417575e9.32.1782469093163; Fri, 26 Jun 2026 03:18:13 -0700 (PDT) X-Received: by 2002:a05:600c:a403:b0:492:4e1c:120 with SMTP id 5b1f17b1804b1-4926689988fmr77417135e9.32.1782469092703; Fri, 26 Jun 2026 03:18:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 08/45] target/i386/mshv: use hv-provided [0xD,1+2].EBX Date: Fri, 26 Jun 2026 12:17:11 +0200 Message-ID: <20260626101748.1728079-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469127432158500 From: Magnus Kulke 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 Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-9-magnuskulke@linux.m= icrosoft.com Signed-off-by: Paolo Bonzini --- 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 66733390c3e..e85311af2af 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; @@ -1688,6 +1706,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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469155; cv=none; d=zohomail.com; s=zohoarc; b=Pqz+DgWXIPlD6JkPJI7caJo6IRzkI+Ahjl4hkjVTfo+cuxfntuKiJSALF+L4U1c6CwrX7cEb14tU57OwVWlmMZoUhgDNe7oBWzP7CeyVHEx74Hx0SMXBwmvBjBJMxh6okM6y1Jd2ohPUDolgxf8UfU3WGJUJo+hJidU+j+22tKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469155; 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=9jpxIFYk+jJh1Eu2hO0yA4J0IN9FE9t7jWDg+Y5ix4I=; b=cklcKWHRrsg4YKe6ig2npAydb3MDU/phA/Ex2N5Q784zhiBWFg1LZpGSILHtiLxFifD30gI2BpgJ1impjKNzS0XDFwtJ8IqM3ais3tBMJjVUmW0q0EDRrlawrfCyDrlVsMyTKuiAcnVIgdBfJkNu4P51eY5nxgkUoveyyv/ANfI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469155697399.0783525877157; Fri, 26 Jun 2026 03:19:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3e0-0007GN-Pj; Fri, 26 Jun 2026 06:18:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dd-00074X-2n for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3db-0005AR-3h for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:20 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-X4K65HJCM0eOyqamf_Jm6Q-1; Fri, 26 Jun 2026 06:18:16 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-46e4153b193so861107f8f.1 for ; Fri, 26 Jun 2026 03:18:16 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c1ee01c3bsm25046563f8f.10.2026.06.26.03.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469098; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9jpxIFYk+jJh1Eu2hO0yA4J0IN9FE9t7jWDg+Y5ix4I=; b=eDIxtzd4EQYCEV7nhJ2eUSGUq22hGwMMjdGK/3f3GG9Ow6a11+7yym3usyt2D2VWfwA7wP T9/r92++A04eF38XcpCwAeLVzTL9qpzLXVHcF71Qp4cDDUmM58DUE7luP1h+A5a9Z8zzEP 4nUXnHdpDNJB63DQWdiCQOmIrtTp8Ow= X-MC-Unique: X4K65HJCM0eOyqamf_Jm6Q-1 X-Mimecast-MFC-AGG-ID: X4K65HJCM0eOyqamf_Jm6Q_1782469095 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469095; x=1783073895; 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; bh=9jpxIFYk+jJh1Eu2hO0yA4J0IN9FE9t7jWDg+Y5ix4I=; b=Yv1I2EunWtiNX9PLmr7iI4FjyOdPfwI2qtOWQgmEqUveiTXfECDN64st+p7zoq/yBX +EVvd/DkMFyUhqiQS7W3h6M8y4iQzX0m3sEz4sQT2Z2P9WNnaUnB25AatqLH7w+lpfEt bk85IcOgUrbL1aNP72Bcj5WzgVat0mM/b2VzX1/BEVH7xFkUN1SUR/JMAMN/VyqRz4a0 kdl/h4qTRfXf0sSHqQKKNRtTeA7f5kW9wCSGVsZ6fHPJK3l9vYsh85QZG+KuiWubg7mq N+v+aR5UkhyIJpvUTX3ZRiRhGG7gUk0b7QuyDWkpRAfQONGZJ8aQbS/abds/P+sOYvRZ kSaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469095; x=1783073895; 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; bh=9jpxIFYk+jJh1Eu2hO0yA4J0IN9FE9t7jWDg+Y5ix4I=; b=hwIQAXAvy+TKD5Qt1cDC4/Ky9e+0G5NsPnrgZa9q+D7MhEoGXCA6vWEtGdPtyrxG8Y vBN5HSCmbONMAAK1E+tSj+zwaY/sfzLB7FHdsCWfYnI6SCDg9VOQFkTkfTPhsDrBuaXR X6okqecB/XEzxoRxwQf3NTYxhN2xaUtsdTdNenaUNAF0wZkoeNlG+mlEc8Jb0Y4785j6 it0ArxEED/WWputZIDOYABZpaOp50lOh/gG0zzGsHyEU7XQdmUsveY7fS+Luh35f3Sh3 22cK/sgWGXY4oZPvGQm2Qia3yYBW+XGcHa3okCR6O9Gosc9t5cU3oyDj18kLcY7i4cS6 OHlg== X-Gm-Message-State: AOJu0Yyy0OYYwamlizqwCrOrkA6bZ66KZHh4Tgs/Lt9+cJDRkDPzw84K mz/q1dW+rXGq9Aty5q05CCbSxbgRMl43A8pwC95cBqPrNPOaQdl/qz6RF5ueHn3nSw5YBqpjXMl GI1WiE+V1qjAOCUyL5iMnNIYx7Wa/q8PNufMG/bMSvWPt4uBJZ2HL/+dtP3fDj8yEO+9Ec1/uop eDdY3fjUOTXt9dU+ICgH9S91lBES2q0ikx2EpyFjtL X-Gm-Gg: AfdE7cnbWd26ePk1LUSrJn11b0PWrNJ2Jmg5KcXOAnH16Zdz3wg+T3GR4t/gFhWwcor a7TaB1Uw0xCan8KHTyr8HZAg9xhbkGhgTCsnq9t4yFIB40jY4PuuV0oNE0sqWcnVQt/Xvzz7LCM HvAIhbjWO0XQRtch37TQrfW+Zfq/KEYfiFnjkhouSSulIKKhRJ3iZnJr9A12vaK1xQm7a99Cy03 4izICy+Mvglds72bLa4KEXLqnEEWU25PLjBT8PKtLcrE3yx3gOyOdxPGvLMC84ak3xAV6hexh2X pGqavaKD8o1ZE+NSsGPkpHYvyOD6ZbNg+OUAVqSYodGyXuflIDynsZORIGvK4fAioEHzDA5jpCL EGTc0ZnfUVJcXeIjReYMXEq/Gzwpli1ViUHOOMkU+/SDl3d6+PD/zkMJ2F4PCOEv6tM14tQOn1u h+bOMKUa2wrGnVetrh X-Received: by 2002:a05:6000:2489:b0:460:10f6:a554 with SMTP id ffacd0b85a97d-46a806bc9e7mr27745607f8f.14.1782469094962; Fri, 26 Jun 2026 03:18:14 -0700 (PDT) X-Received: by 2002:a05:6000:2489:b0:460:10f6:a554 with SMTP id ffacd0b85a97d-46a806bc9e7mr27745531f8f.14.1782469094409; Fri, 26 Jun 2026 03:18:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke , "Anirudh Rayabharam (Microsoft)" , Wei Liu , =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= Subject: [PULL 09/45] accel/mshv: disable la57 (5lvl paging) Date: Fri, 26 Jun 2026 12:17:12 +0200 Message-ID: <20260626101748.1728079-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469157400158500 From: Magnus Kulke 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 Reviewed-by: Doru Bl=C3=A2nzeanu Link: https://lore.kernel.org/r/20260416121116.527927-10-magnuskulke@linux.= microsoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 2 ++ accel/mshv/mshv-all.c | 7 +++++++ target/i386/mshv/mshv-cpu.c | 15 +++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 35386c422fa..ca156cdf4be 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/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 0f65b65d9ca..52623be5d93 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/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index e85311af2af..3523cfcb70c 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) { @@ -1707,6 +1713,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.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469246; cv=none; d=zohomail.com; s=zohoarc; b=iQj2xKzzLX3eYLF4bXR25ym70B8Tfs4abdBGO8IjuaDvCabX/t0jWx/4N76o5BNEztFHmnAuktmo+ofTGf1L5GDhFaIWsQJtBOOz21ccPzc92eDTFIc9JLQMjRmHSykFt2mmiZ+OiAuv37doufeS+VxPq+F/D2oZeD3Jg57VocQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469246; 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=YDk/PP2EpHiCfKWGuR3JeDRX3vI+ycdJA1d8xSPIUgU=; b=W6DYUABMGLRkis5xsZOB4nAjzcnSiRhwpQMgxqkItGuXqeI/t6kkHkIc5bi4k2v4GVNdt7MADpOm+QVqWO0EC4IAs0nI2kKe3G4jvmMA98LbA8L2KLvfjuTpiN/xm1M2fOHOCh7he0/59dPq4yT/tI0d4t+6Xe9Ww1fC8aQv3A8= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178246924620839.288081157656165; Fri, 26 Jun 2026 03:20:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3e5-0007Ye-Np; Fri, 26 Jun 2026 06:18:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dl-0007GM-TK for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3de-0005Ar-39 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:23 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-6jABUwHQOxelqmSYCLqJUA-1; Fri, 26 Jun 2026 06:18:20 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4625b4f54c6so584991f8f.0 for ; Fri, 26 Jun 2026 03:18:19 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46f4ffc11d9sm2810904f8f.37.2026.06.26.03.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YDk/PP2EpHiCfKWGuR3JeDRX3vI+ycdJA1d8xSPIUgU=; b=Ei2hiN23eUcniXe0p6Sx/u6FVF/5dkoRJp3amf4NV2wcEGCKxRm8JfB9ZU2andW4TST+q6 NiO83x4qSqR9oDv8z1QODdgCJka5iLFGCZsGVNCh7KiMNarl1MyuPopfPh5MHrGX1zCLjg c/ykpfsxw0Ybd3TDoaM2HYfLUa2oBfU= X-MC-Unique: 6jABUwHQOxelqmSYCLqJUA-1 X-Mimecast-MFC-AGG-ID: 6jABUwHQOxelqmSYCLqJUA_1782469099 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469099; x=1783073899; 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; bh=YDk/PP2EpHiCfKWGuR3JeDRX3vI+ycdJA1d8xSPIUgU=; b=B2AWnpm5QPrpREj33x4BQXuKTX9QHVFlgy4vRPokTz36kIRKBBqZk36wfR/DcxofH/ f2iFNDtbTd+BHXAGDOUNswARfig3ygWl+eraa8/c74z6zDBtEu7BYD3eyaCjmgNBSv1U rVzZBkOEFFG48gnd0Qc8WO2vqC838vmoOEF0jOuODs3Dl3iXRGkqIm+6YodVNY3rkNTj 8RTaJOAjbpTdVL+jJcgdxo5JYvzE8Upmi4yGtfw2Vx5Vzo2vX9CbyNopyGODZNkIRSjE EVbaYQS4V7GAcl5bGCu5Kxarp6YzJr8fIuvuZ2me5XbIAc11q9ZNSShDgssMxUxFBDJT boug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469099; x=1783073899; 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; bh=YDk/PP2EpHiCfKWGuR3JeDRX3vI+ycdJA1d8xSPIUgU=; b=bFhKV4J7i2bDsXup9LOyzIPdS3pZ2lbF4kM74OcuIJNJCaOrH7SxEk/yTKnRBJr6Qx RsZgcHDmG48/RE2sIAKtI13IGPJ8k/lbIyhuBwMVwm+txC8xUgajj6xP9/QcwAoaX6p9 F4WDtuj8Y0J+gJ/pVISWLAQoo2ieTA3oVsCIn9HUn7GBbWLfBcDajW1G5CYCZ85jhEfr bXl3blKAGk0aBMHhEw6esYvzaKMhGiOMp1vYL+cJCkSNLaItdpZq6vsWmUM0K50uQIeJ pKNbc6NN1XVYc8XE3Gbl6wuycYlSkjVklQrRU2LKBxynvAdi85Dw6pNWHn1BVizPUB80 Q8vA== X-Gm-Message-State: AOJu0YxPIea0feDBPri7bqsyunBhOQZBO1Z+dwUILqEoaVrNBeM0e+oE yg3aV+izGUGsAynDx8wAwv6q19zXaqx3kvdtd3SWJcjN1x2+CFneXj8B+iH/kiFgZV5bmJRpWPN ZvIlVh6Xqt+7Poc65Up1tyQVKMNiPDXq6BSTJNMA2ASiyS8wVhC+v/C3fWrz0kUGFxkIV3qyRPM ZUT1fx2hxRd9XkfD3ul7kYyihZ8yBzkj9t3MVgk6Wt X-Gm-Gg: AfdE7clBgYt9nydDzWr+EtDIrZbVUqzn1zjPWAHzVNfWp+JW3HFAq6ra+k10G7tBcO1 CmDqaaGobHCCSU8TmbDpOlxEuCpGPXl8A+nUA/7heCplf+C5obSVgmemhrvAGATEvcfCjT6Ao+R ie2IzhLstbhtMVNYOxFR4TtbKy+gRvZAocxzapeRhBmVC8A6nUjaiZojK7dek8RBVyg31YqCbin vh6oUejrBPEchI8cfHJyfz87N6jojPL1yQkgY3oFou6MvYeyOQTo3pSIWSRBf0k3izEZalW7DpY fQ4HokNlQ4tm9XtrxxAlWccDuexh6uiIejpXojjMYHFK2yyL9cG8BfGRCO3EprU0Spjm93YkWaS MUf7kn3312vzZfUfCL2PmdCDTpS/YpUQcRCrruB1YLtCkj+XVZVXFudQ40wCXJvcOdPPBi+Zbhv LfQ4ags34aZofuMJ29 X-Received: by 2002:a05:6000:250d:b0:460:6a13:9131 with SMTP id ffacd0b85a97d-46dbfab5605mr10531735f8f.19.1782469098779; Fri, 26 Jun 2026 03:18:18 -0700 (PDT) X-Received: by 2002:a05:6000:250d:b0:460:6a13:9131 with SMTP id ffacd0b85a97d-46dbfab5605mr10531672f8f.19.1782469098268; Fri, 26 Jun 2026 03:18:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 10/45] target/i386/mshv: use arch_load/store_reg fns Date: Fri, 26 Jun 2026 12:17:13 +0200 Message-ID: <20260626101748.1728079-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469247837158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Improved consistency around the naming of load/store register fn's. this is required since we want to roundtrip more registers in a migration than what's currently required for MMIO emulation. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-2-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 6 ++--- accel/mshv/mshv-all.c | 2 +- target/i386/mshv/mshv-cpu.c | 52 ++++++++++++++----------------------- 3 files changed, 23 insertions(+), 37 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index ca156cdf4be..bf0fe571f01 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -82,11 +82,9 @@ void mshv_init_mmio_emu(void); int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd); void mshv_remove_vcpu(int vm_fd, int cpu_fd); int mshv_configure_vcpu(const CPUState *cpu, const MshvFPU *fpu, uint64_t = xcr0); -int mshv_get_standard_regs(CPUState *cpu); -int mshv_get_special_regs(CPUState *cpu); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); -int mshv_load_regs(CPUState *cpu); -int mshv_store_regs(CPUState *cpu); +int mshv_arch_load_regs(CPUState *cpu); +int mshv_arch_store_regs(CPUState *cpu); int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, size_t n_regs); int mshv_arch_put_registers(const CPUState *cpu); diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 52623be5d93..ec9c90cddda 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -729,7 +729,7 @@ static void mshv_cpu_synchronize_pre_loadvm(CPUState *c= pu) static void do_mshv_cpu_synchronize(CPUState *cpu, run_on_cpu_data arg) { if (!cpu->accel->dirty) { - int ret =3D mshv_load_regs(cpu); + int ret =3D mshv_arch_load_regs(cpu); if (ret < 0) { error_report("Failed to load registers for vcpu %d", cpu->cpu_index); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 3523cfcb70c..fba95392b9d 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -110,6 +110,8 @@ static enum hv_register_name FPU_REGISTER_NAMES[26] =3D= { HV_X64_REGISTER_XMM_CONTROL_STATUS, }; =20 +static int set_special_regs(const CPUState *cpu); + static int translate_gva(const CPUState *cpu, uint64_t gva, uint64_t *gpa, uint64_t flags) { @@ -288,7 +290,7 @@ static int set_standard_regs(const CPUState *cpu) return 0; } =20 -int mshv_store_regs(CPUState *cpu) +int mshv_arch_store_regs(CPUState *cpu) { int ret; =20 @@ -298,6 +300,12 @@ int mshv_store_regs(CPUState *cpu) return -1; } =20 + ret =3D set_special_regs(cpu); + if (ret < 0) { + error_report("Failed to store speical registers"); + return ret; + } + return 0; } =20 @@ -326,7 +334,7 @@ static void populate_standard_regs(const hv_register_as= soc *assocs, rflags_to_lflags(env); } =20 -int mshv_get_standard_regs(CPUState *cpu) +static int get_standard_regs(CPUState *cpu) { struct hv_register_assoc assocs[ARRAY_SIZE(STANDARD_REGISTER_NAMES)]; int ret; @@ -404,8 +412,7 @@ static void populate_special_regs(const hv_register_ass= oc *assocs, cpu_set_apic_base(x86cpu->apic_state, assocs[16].value.reg64); } =20 - -int mshv_get_special_regs(CPUState *cpu) +static int get_special_regs(CPUState *cpu) { struct hv_register_assoc assocs[ARRAY_SIZE(SPECIAL_REGISTER_NAMES)]; int ret; @@ -425,17 +432,17 @@ int mshv_get_special_regs(CPUState *cpu) return 0; } =20 -int mshv_load_regs(CPUState *cpu) +int mshv_arch_load_regs(CPUState *cpu) { int ret; =20 - ret =3D mshv_get_standard_regs(cpu); + ret =3D get_standard_regs(cpu); if (ret < 0) { error_report("Failed to load standard registers"); return -1; } =20 - ret =3D mshv_get_special_regs(cpu); + ret =3D get_special_regs(cpu); if (ret < 0) { error_report("Failed to load special registers"); return -1; @@ -1159,16 +1166,16 @@ static int emulate_instruction(CPUState *cpu, int ret; x86_insn_stream stream =3D { .bytes =3D insn_bytes, .len =3D insn_len = }; =20 - ret =3D mshv_load_regs(cpu); + ret =3D mshv_arch_load_regs(cpu); if (ret < 0) { - error_report("failed to load registers"); + error_report("Failed to load registers"); return -1; } =20 decode_instruction_stream(env, &decode, &stream); exec_instruction(env, &decode); =20 - ret =3D mshv_store_regs(cpu); + ret =3D mshv_arch_store_regs(cpu); if (ret < 0) { error_report("failed to store registers"); return -1; @@ -1347,25 +1354,6 @@ static int handle_pio_non_str(const CPUState *cpu, return 0; } =20 -static int fetch_guest_state(CPUState *cpu) -{ - int ret; - - ret =3D mshv_get_standard_regs(cpu); - if (ret < 0) { - error_report("Failed to get standard registers"); - return -1; - } - - ret =3D mshv_get_special_regs(cpu); - if (ret < 0) { - error_report("Failed to get special registers"); - return -1; - } - - return 0; -} - static int read_memory(const CPUState *cpu, uint64_t initial_gva, uint64_t initial_gpa, uint64_t gva, uint8_t *data, size_t len) @@ -1485,9 +1473,9 @@ static int handle_pio_str(CPUState *cpu, hv_x64_io_po= rt_intercept_message *info) X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; =20 - ret =3D fetch_guest_state(cpu); + ret =3D mshv_arch_load_regs(cpu); if (ret < 0) { - error_report("Failed to fetch guest state"); + error_report("Failed to load registers"); return -1; } =20 @@ -1518,7 +1506,7 @@ static int handle_pio_str(CPUState *cpu, hv_x64_io_po= rt_intercept_message *info) =20 ret =3D set_x64_registers(cpu, reg_names, reg_values); if (ret < 0) { - error_report("Failed to set x64 registers"); + error_report("Failed to set RIP and RAX registers"); return -1; } =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469374; cv=none; d=zohomail.com; s=zohoarc; b=kJvcBv8ChVNu13aXeoMsL1S/Fnv2CGUF2FQwQXXbaDybj8bp/e5ALq32t1vzOY0DanK3nP11qQLUtNiR6Jrss7J58XgcvrzZ9+yD9BWJZ5VuLyUAQgiC4lDypPGgtS9NzGDXRMuPUga6u2kj8OqEDfmMF2+hyQvBUIDxCe09PHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469374; 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=XHg+sFyNMes+caI8HycqYBS24olay+Ktvlo3gmk/XWo=; b=MxqEHWzGiEo1JN5EzJV+ihrGjwyhHq6mYphbhtE3IRo7m2WBwiglDXAq9pUe1VI7auDu2EgwaLzC8yPerFZ2woxsJfwFkf6FFHl2W8ddMB+iq+GxirfUXJJHrUlAzrTSjW9qtfzAgvrXwOjhIjKHJEzDjrA8x8Gq0SqPu9obyKA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469374748575.622841034032; Fri, 26 Jun 2026 03:22:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eM-0007up-AU; Fri, 26 Jun 2026 06:19:06 -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 1wd3dn-0007JR-Nu for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dl-0005B1-B1 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:31 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-8XfL0QFzPpOEcluXIhpBkw-1; Fri, 26 Jun 2026 06:18:21 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-46315372c3eso584273f8f.0 for ; Fri, 26 Jun 2026 03:18:21 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46d3ba68d8dsm17696085f8f.27.2026.06.26.03.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469103; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XHg+sFyNMes+caI8HycqYBS24olay+Ktvlo3gmk/XWo=; b=U+JTxbpnALvaW4JrdvMoKCj3HeiFTiMhPO27rMnbiUANfy98LBvMSlT3zeyvOjVCyZcsat ouY+evG5e7ofzVDtEHT6ASV80n5/NC8s2G6i+jB8a8og3WgnxifYhAS/lfDk8ahobXg1Qo JWUGTt07dz713K+neGKg+ETjyDdTpHY= X-MC-Unique: 8XfL0QFzPpOEcluXIhpBkw-1 X-Mimecast-MFC-AGG-ID: 8XfL0QFzPpOEcluXIhpBkw_1782469100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469100; x=1783073900; 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; bh=XHg+sFyNMes+caI8HycqYBS24olay+Ktvlo3gmk/XWo=; b=o99og3bgJPuTPeRJe/MY6TLN1PuCXZqMO80KJobUB86e7JL7FNwVRJzxCh1TBtsoD3 oQgdYrocyChfein+6ycClyC/Fpznt4HrNDWZaTkL9ObUMJbh7c0IzvLz3tzkhBAUmvzv 7mzrWGIdJNcw0ZcAV3kdiRC1phc5E2ync5UMXXjquzAguJXXAYKHj221I5S4V3P6TSZ6 g3QkRhyAhcieAahw3Tm//7K0Q36GztX91V/RGaz6uOyUwOCyxME+7NLlTdjBSCqBhmGb 3yIBJOL2kC+EGV825IsjyLUAA9bgwJZRXkudb+LdpwF3z25keEvTPpsLjJAK+aliVvMD RmrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469100; x=1783073900; 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; bh=XHg+sFyNMes+caI8HycqYBS24olay+Ktvlo3gmk/XWo=; b=QAgan0I3M/JG1yfwD77Bahc6ggCOBi538MZYjf5jNpoeUjdRVwDaTemKd9de7zN74N TEmxftxtzkrIL+F6blReoJgUF4dnw+YYXgTdZhwY2F4S/MTpdj1R08BnN2Wrg2bA8wZL UOeDGEjf327h0EMzHeNUp54AXaYi58Cia2gOaXa6BCoJVAzNcmXKyaioE3uvMG49ObA+ wtHExQaCHzUH3ss3SVT5Vd4z0DRSLjGviN50+0Bjelk6thVBbdRM8Yj37J1kYDvxUlwM CusFIMtc4xJx3jhWcIiNzBV6D9SIzjN9tD2y4szk8M8KSDP8ReYzuukf8DXmqPiHFgC7 aqHQ== X-Gm-Message-State: AOJu0Yya62hYNd3nm90Pl+vIkY5PS5hEy5vfj0BQjuDFNSachEs6BVLy Fsfxrp9uJYSBzR1xPx9rR9id6Un/4/YrDsGpmRWkm4gaJMAtR2lpTq18PFDxmdo/zMFY0Tp+wIJ hdGQp+Hx48Qkvj95OAU1qaDjl0anAGt6J4lzYzHbBVEbgphJfPso0HbPsHqsCGVmgC3qFVTqyy4 w2K6pVXsBDoCG35DFrtaUshvRTRV3OdpWeAuK43gsT X-Gm-Gg: AfdE7clyhIY6gK8nldrGDS6CwnuqqknVeaTgzcjkaoI6ZOgRk37F5RCdwVXXcRf2jTr G4hHhC2+yAXpS+LNII8i5Q52MrpF2dU9ze3ai3Nx81bYVMiZmHlM75mT8uRwhvyruqZvv+xm8fn Zc+ctUKy+TucbpRDfSwVS19WI4HbJ/E3kt51tB4Z9dpCnl2WeqiGTDvEMeJZtLBoUHkUUZcZUiA 1Wfz13d1Qiru9BJThUVJ1I8Fe0dpsm3eAuytNFOHtx1wCMnQoJ4x6831/1CUnlfrLWWvmMcxxea 6xl1AnPSpTdi2hWl2DiqQYuKHn/tLOznCCMtCOhHIcgO2XyXhlJjpebeH8WSi0XSRZX+wDd392q JtH0gzyjB4Q/jrWFMONmRmvGk7MGNbHwNRX9/G5aWrSIdErJ6A8xVPloiQdsvYtPve52lA34X38 XFFZ+PDPSaB5OIlH58 X-Received: by 2002:a5d:5d81:0:b0:461:cd9e:2368 with SMTP id ffacd0b85a97d-46dc0e050f2mr10233773f8f.27.1782469100333; Fri, 26 Jun 2026 03:18:20 -0700 (PDT) X-Received: by 2002:a5d:5d81:0:b0:461:cd9e:2368 with SMTP id ffacd0b85a97d-46dc0e050f2mr10233717f8f.27.1782469099844; Fri, 26 Jun 2026 03:18:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 11/45] target/i386/mshv: use generic FPU/xcr0 state Date: Fri, 26 Jun 2026 12:17:14 +0200 Message-ID: <20260626101748.1728079-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469376397158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke Instead of using an mshv-specific FPU state representation we switch to the generic i386 representation of the registers. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-3-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 15 +------- target/i386/mshv/mshv-cpu.c | 76 ++++++++++++++++++++++--------------- 2 files changed, 47 insertions(+), 44 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index bf0fe571f01..bb7f6740bba 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -58,19 +58,6 @@ typedef struct MshvMsiControl { #define mshv_vcpufd(cpu) (cpu->accel->cpufd) =20 /* cpu */ -typedef struct MshvFPU { - uint8_t fpr[8][16]; - uint16_t fcw; - uint16_t fsw; - uint8_t ftwx; - uint8_t pad1; - uint16_t last_opcode; - uint64_t last_ip; - uint64_t last_dp; - uint8_t xmm[16][16]; - uint32_t mxcsr; - uint32_t pad2; -} MshvFPU; =20 typedef enum MshvVmExit { MshvVmExitIgnore =3D 0, @@ -81,7 +68,7 @@ typedef enum MshvVmExit { void mshv_init_mmio_emu(void); int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd); void mshv_remove_vcpu(int vm_fd, int cpu_fd); -int mshv_configure_vcpu(const CPUState *cpu, const MshvFPU *fpu, uint64_t = xcr0); +int mshv_configure_vcpu(const CPUState *cpu); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); int mshv_arch_load_regs(CPUState *cpu); int mshv_arch_store_regs(CPUState *cpu); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index fba95392b9d..b5c0c504cb1 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -111,6 +111,9 @@ static enum hv_register_name FPU_REGISTER_NAMES[26] =3D= { }; =20 static int set_special_regs(const CPUState *cpu); +static int get_generic_regs(CPUState *cpu, + struct hv_register_assoc *assocs, + size_t n_regs); =20 static int translate_gva(const CPUState *cpu, uint64_t gva, uint64_t *gpa, uint64_t flags) @@ -767,48 +770,65 @@ static int set_special_regs(const CPUState *cpu) return 0; } =20 -static int set_fpu(const CPUState *cpu, const struct MshvFPU *regs) +static int set_fpu(const CPUState *cpu) { struct hv_register_assoc assocs[ARRAY_SIZE(FPU_REGISTER_NAMES)]; union hv_register_value *value; - size_t fp_i; union hv_x64_fp_control_status_register *ctrl_status; union hv_x64_xmm_control_status_register *xmm_ctrl_status; int ret; size_t n_regs =3D ARRAY_SIZE(FPU_REGISTER_NAMES); + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + size_t i, fp_i; + bool valid; =20 /* first 16 registers are xmm0-xmm15 */ - for (size_t i =3D 0; i < 16; i++) { + for (i =3D 0; i < 16; i++) { assocs[i].name =3D FPU_REGISTER_NAMES[i]; value =3D &assocs[i].value; - memcpy(&value->reg128, ®s->xmm[i], 16); + value->reg128.low_part =3D env->xmm_regs[i].ZMM_Q(0); + value->reg128.high_part =3D env->xmm_regs[i].ZMM_Q(1); } =20 /* next 8 registers are fp_mmx0-fp_mmx7 */ - for (size_t i =3D 16; i < 24; i++) { - assocs[i].name =3D FPU_REGISTER_NAMES[i]; + for (i =3D 16; i < 24; i++) { fp_i =3D (i - 16); + assocs[i].name =3D FPU_REGISTER_NAMES[i]; value =3D &assocs[i].value; - memcpy(&value->reg128, ®s->fpr[fp_i], 16); + value->fp.mantissa =3D env->fpregs[fp_i].d.low; + value->fp.biased_exponent =3D env->fpregs[fp_i].d.high & 0x7FFF; + value->fp.sign =3D (env->fpregs[fp_i].d.high >> 15) & 0= x1; + value->fp.reserved =3D 0; } =20 /* last two registers are fp_control_status and xmm_control_status */ assocs[24].name =3D FPU_REGISTER_NAMES[24]; value =3D &assocs[24].value; ctrl_status =3D &value->fp_control_status; - ctrl_status->fp_control =3D regs->fcw; - ctrl_status->fp_status =3D regs->fsw; - ctrl_status->fp_tag =3D regs->ftwx; + + ctrl_status->fp_control =3D env->fpuc; + /* bits 11,12,13 are the top of stack pointer */ + ctrl_status->fp_status =3D (env->fpus & ~0x3800) | ((env->fpstt & 0x7)= << 11); + + ctrl_status->fp_tag =3D 0; + for (i =3D 0; i < 8; i++) { + valid =3D (env->fptags[i] =3D=3D 0); + if (valid) { + ctrl_status->fp_tag |=3D (1u << i); + } + } + ctrl_status->reserved =3D 0; - ctrl_status->last_fp_op =3D regs->last_opcode; - ctrl_status->last_fp_rip =3D regs->last_ip; + ctrl_status->last_fp_op =3D env->fpop; + ctrl_status->last_fp_rip =3D env->fpip; =20 assocs[25].name =3D FPU_REGISTER_NAMES[25]; value =3D &assocs[25].value; xmm_ctrl_status =3D &value->xmm_control_status; - xmm_ctrl_status->xmm_status_control =3D regs->mxcsr; - xmm_ctrl_status->xmm_status_control_mask =3D 0; - xmm_ctrl_status->last_fp_rdp =3D regs->last_dp; + xmm_ctrl_status->xmm_status_control =3D env->mxcsr; + xmm_ctrl_status->xmm_status_control_mask =3D 0x0000ffff; + xmm_ctrl_status->last_fp_rdp =3D env->fpdp; =20 ret =3D mshv_set_generic_regs(cpu, assocs, n_regs); if (ret < 0) { @@ -819,12 +839,15 @@ static int set_fpu(const CPUState *cpu, const struct = MshvFPU *regs) return 0; } =20 -static int set_xc_reg(const CPUState *cpu, uint64_t xcr0) +static int set_xc_reg(const CPUState *cpu) { int ret; + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + struct hv_register_assoc assoc =3D { .name =3D HV_X64_REGISTER_XFEM, - .value.reg64 =3D xcr0, + .value.reg64 =3D env->xcr0, }; =20 ret =3D mshv_set_generic_regs(cpu, &assoc, 1); @@ -835,8 +858,7 @@ static int set_xc_reg(const CPUState *cpu, uint64_t xcr= 0) return 0; } =20 -static int set_cpu_state(const CPUState *cpu, const MshvFPU *fpu_regs, - uint64_t xcr0) +static int set_cpu_state(const CPUState *cpu) { int ret; =20 @@ -848,11 +870,11 @@ static int set_cpu_state(const CPUState *cpu, const M= shvFPU *fpu_regs, if (ret < 0) { return ret; } - ret =3D set_fpu(cpu, fpu_regs); + ret =3D set_fpu(cpu); if (ret < 0) { return ret; } - ret =3D set_xc_reg(cpu, xcr0); + ret =3D set_xc_reg(cpu); if (ret < 0) { return ret; } @@ -1001,8 +1023,7 @@ static int setup_msrs(const CPUState *cpu) * CPUX86State *env =3D &x86cpu->env; * X86CPUTopoInfo *topo_info =3D &env->topo_info; */ -int mshv_configure_vcpu(const CPUState *cpu, const struct MshvFPU *fpu, - uint64_t xcr0) +int mshv_configure_vcpu(const CPUState *cpu) { int ret; int cpu_fd =3D mshv_vcpufd(cpu); @@ -1019,7 +1040,7 @@ int mshv_configure_vcpu(const CPUState *cpu, const st= ruct MshvFPU *fpu, return -1; } =20 - ret =3D set_cpu_state(cpu, fpu, xcr0); + ret =3D set_cpu_state(cpu); if (ret < 0) { error_report("failed to set cpu state"); return -1; @@ -1036,14 +1057,9 @@ int mshv_configure_vcpu(const CPUState *cpu, const s= truct MshvFPU *fpu, =20 static int put_regs(const CPUState *cpu) { - X86CPU *x86cpu =3D X86_CPU(cpu); - CPUX86State *env =3D &x86cpu->env; - MshvFPU fpu =3D {0}; int ret; =20 - memset(&fpu, 0, sizeof(fpu)); - - ret =3D mshv_configure_vcpu(cpu, &fpu, env->xcr0); + ret =3D mshv_configure_vcpu(cpu); if (ret < 0) { error_report("failed to configure vcpu"); return ret; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469152; cv=none; d=zohomail.com; s=zohoarc; b=HyoYlIP6W8WI1WLWZD+qtdeYPBB6MpEAYoAeua/KqUHNrD8MuE+iBz2170IKasS7P0g+ncNxpISO18ug3Qlw3SHQkG9x2eFe8H2si1JX/wBfZUxOn+80RARWOPPgGxvEM/KdnM5aLNOnkA+OldX0QLVnIjkFQ+LuP673Mk6jvyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469152; 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=pYOdt8vPElmwHVGL0UnCvccem7xXYiPrBcnKUVsbS/U=; b=ecX87f9MXwtPjHskJQy7u5t0Dmh5qp4x5vQlIxnpUTn1uviMbpal1dLNHGBUAgs+ZcnB+wqSJGOzuz1TzfXk2dYCfTkMbpVvCQFbtAHSFHSUhXne0M6RSj4xl4ODXT5uZO3HKAV9+q4LUuujxDmudTEIJSUJx8uvUjVlPSayXiw= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178246915223351.080131340742355; Fri, 26 Jun 2026 03:19:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eF-0007af-9V; Fri, 26 Jun 2026 06:19:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ds-0007O3-S5 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dp-0005Bu-F9 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:36 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122--vCTcLwEMNSGG26Kvp-iIQ-1; Fri, 26 Jun 2026 06:18:29 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490b37e1f48so4955535e9.0 for ; Fri, 26 Jun 2026 03:18:29 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49269002511sm66840155e9.8.2026.06.26.03.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pYOdt8vPElmwHVGL0UnCvccem7xXYiPrBcnKUVsbS/U=; b=U2xXnsdFa7Ok9P/ftCJeRHl+4ybMDdbBh/In7KItYf3Q8hn02GXmpltBI0UCtYeoye2kyx wu8IoOzBfY/HPcUVBd+yJf/irIWxxjbuXeZP9YhvEF9c5YVErDWqYsxGX79/jVjrE6+j9S 5YN5X2Y5foN3YOVmo/xiBjhK8vjriBQ= X-MC-Unique: -vCTcLwEMNSGG26Kvp-iIQ-1 X-Mimecast-MFC-AGG-ID: -vCTcLwEMNSGG26Kvp-iIQ_1782469106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469106; x=1783073906; 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; bh=pYOdt8vPElmwHVGL0UnCvccem7xXYiPrBcnKUVsbS/U=; b=mnvKbkeqLqAkW5uHA4/BhGkezshNkrNDvvqMrHQIWC7Rbji7wUIcEk182F6FyE1B6z Sr6ZMlOPgrF6w06cDplxVDq7ptyb/iWuwKBQalJ0Yi9a9i2YqMw+LkFRGEXbfO2Ve3TB adwwwErfxyt/Dhb66WODiznqaHWCHnOi7PvK3Cx21N+CUk4onkdpjNazzsWN2S5AFOp8 zH0LOI8n68U6AP08FJaIh6ugT0rjMHzT+6cOHmoA88tKUprPCKfiTAfGfbvrcRlAe0Af dAriIpjCnRlKtcn0pXPbKk5nQs0fBJLhqBPF/5Ey/cg6GtO8wp9VJKO8nMnHZIwYkSdy SnlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469106; x=1783073906; 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; bh=pYOdt8vPElmwHVGL0UnCvccem7xXYiPrBcnKUVsbS/U=; b=OR10q80NdnpnuNYu8AYpVLx90hm3P5L/mfAyCv5xOSk4xXt4da4uVmKTP4vCuTbRe0 XGQ5D964EVQFg5HHe3wCUkuvHot6JXGapRTrRFUkp0RjO3pKj4urU1IlqnFRA4/aAG1e hPAhwFrmkW2GOly2Y3A4mgKJLRixVpM96mfdXZ5Pxi3hpOCtcnGA7mrTDOkANbN+EyKi J5H93K863hAq2E7x83YoCVQC5EsO6/BlcDnhmvEtdR37m6n/bzh7vYBYEiE1d2xAYePW a3yEO6KBkkg/m52XzXreIBNyTExjfIFYcOfTJcU5/PMBYY1i+Il/101Hds/DP8sxG4Fr D9VQ== X-Gm-Message-State: AOJu0YySrzd7EE+hEO8HSxwyVmMvnWzbShaVSEIzyY5rLLfseBnU8kVM 6a0iFW6dX4z+tLaJBD3adsiE85ZVLLZInKbhg1WWqctRVVtqsG7Tltgr4BUeEiphdlu2+cCnImA EeNnVHJDRgqgUKmGaSHbSZwLriTuNHljF99bJfJpJ41LEPRhLXaAluU/2h323Y9Bza2MvIpPBAi wzV6s+bGuEewD/P3KwDRlz6dZT0XylNds+ktc1B/kk X-Gm-Gg: AfdE7cmSAdbhdWQyiIkyi+vzBmP4QeMQ46DETkiDmTtbV4WCzIDTaYY2TZhksr3FWPq O3rEK/r7o89f+7JFsTiyklgoeCxQpNvy2qesxrdZT8hnYKbkUGkM6z0JAAV2267KegitfxlUCZN GylIL5k0y6tNecG70H9QjYi4wJG/JYc+JHKr8eqwVyqsV/VGrvT/KFh2woD5277R56OV3tW4j8w Z1dMxXkQZbdKakO2rQGjhWEu8ZpQ1HRnbTKyc8OoPTTjKZqn/v7nhQKkQbcb/7R6qFDtDsBGlq0 Zqed9p2gkRAoatzjkPDbjqzM9fnnUo+hX9EvfylpHe0dizTpD+0i+M8KKaY0DRL0rIOqwnHWubN XYWpxYCUU9+PHD+4aCN+ZhFzuCjxLzxAOGcVgX1nFovDLdcD3scSSiTQLBfSgevVDrYhTZliqyY seMJgTDH3TZ/CXeqxs X-Received: by 2002:a05:600c:4689:b0:492:6f9b:572e with SMTP id 5b1f17b1804b1-4926f9b5780mr3603365e9.37.1782469105881; Fri, 26 Jun 2026 03:18:25 -0700 (PDT) X-Received: by 2002:a05:600c:4689:b0:492:6f9b:572e with SMTP id 5b1f17b1804b1-4926f9b5780mr3602025e9.37.1782469104455; Fri, 26 Jun 2026 03:18:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 12/45] target/i386/mshv: impl init/load/store_vcpu_state Date: Fri, 26 Jun 2026 12:17:15 +0200 Message-ID: <20260626101748.1728079-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469153107158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke In migration we will handle more than registers, so we rework the routines that were used to load & store CPU registers from/to the hypervisor into more explicit init/load/store_vcpu_state() functions that can be called from the appropriate hooks. load/store_regs() still exists for the purpose of MMIO emulation, but it will only address standard and special x86 registers. Functions to retrieve FPU and XCR0 state from the hypervsisor have been introduced. MSR and APIC state covered are covered only as part of init_vcpu(). They are not yet part of the load/store routines. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-4-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 5 +- accel/mshv/mshv-all.c | 10 +- target/i386/mshv/mshv-cpu.c | 360 ++++++++++++++++++------------------ 3 files changed, 188 insertions(+), 187 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index bb7f6740bba..1d9902c9bbe 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -70,11 +70,10 @@ int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *= cpu_fd); void mshv_remove_vcpu(int vm_fd, int cpu_fd); int mshv_configure_vcpu(const CPUState *cpu); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); -int mshv_arch_load_regs(CPUState *cpu); -int mshv_arch_store_regs(CPUState *cpu); int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, size_t n_regs); -int mshv_arch_put_registers(const CPUState *cpu); +int mshv_arch_store_vcpu_state(const CPUState *cpu); +int mshv_arch_load_vcpu_state(CPUState *cpu); void mshv_arch_init_vcpu(CPUState *cpu); void mshv_arch_destroy_vcpu(CPUState *cpu); void mshv_arch_amend_proc_features( diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index ec9c90cddda..a6263effa41 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -479,13 +479,13 @@ static int mshv_init_vcpu(CPUState *cpu) int ret; =20 cpu->accel =3D g_new0(AccelCPUState, 1); - mshv_arch_init_vcpu(cpu); =20 ret =3D mshv_create_vcpu(vm_fd, vp_index, &cpu->accel->cpufd); if (ret < 0) { return -1; } =20 + mshv_arch_init_vcpu(cpu); cpu->accel->dirty =3D true; =20 return 0; @@ -567,7 +567,7 @@ static int mshv_cpu_exec(CPUState *cpu) =20 do { if (cpu->accel->dirty) { - ret =3D mshv_arch_put_registers(cpu); + ret =3D mshv_arch_store_vcpu_state(cpu); if (ret) { error_report("Failed to put registers after init: %s", strerror(-ret)); @@ -689,7 +689,7 @@ static void mshv_start_vcpu_thread(CPUState *cpu) static void do_mshv_cpu_synchronize_post_init(CPUState *cpu, run_on_cpu_data arg) { - int ret =3D mshv_arch_put_registers(cpu); + int ret =3D mshv_arch_store_vcpu_state(cpu); if (ret < 0) { error_report("Failed to put registers after init: %s", strerror(-r= et)); abort(); @@ -705,7 +705,7 @@ static void mshv_cpu_synchronize_post_init(CPUState *cp= u) =20 static void mshv_cpu_synchronize_post_reset(CPUState *cpu) { - int ret =3D mshv_arch_put_registers(cpu); + int ret =3D mshv_arch_store_vcpu_state(cpu); if (ret) { error_report("Failed to put registers after reset: %s", strerror(-ret)); @@ -729,7 +729,7 @@ static void mshv_cpu_synchronize_pre_loadvm(CPUState *c= pu) static void do_mshv_cpu_synchronize(CPUState *cpu, run_on_cpu_data arg) { if (!cpu->accel->dirty) { - int ret =3D mshv_arch_load_regs(cpu); + int ret =3D mshv_arch_load_vcpu_state(cpu); if (ret < 0) { error_report("Failed to load registers for vcpu %d", cpu->cpu_index); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index b5c0c504cb1..e3f163ef630 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -115,6 +115,92 @@ static int get_generic_regs(CPUState *cpu, struct hv_register_assoc *assocs, size_t n_regs); =20 +static void populate_fpu(const hv_register_assoc *assocs, X86CPU *x86cpu) +{ + union hv_register_value value; + const union hv_x64_fp_control_status_register *ctrl_status; + const union hv_x64_xmm_control_status_register *xmm_ctrl; + CPUX86State *env =3D &x86cpu->env; + size_t i, fp_i; + bool valid; + + /* first 16 registers are xmm0-xmm15 */ + for (i =3D 0; i < 16; i++) { + value =3D assocs[i].value; + env->xmm_regs[i].ZMM_Q(0) =3D value.reg128.low_part; + env->xmm_regs[i].ZMM_Q(1) =3D value.reg128.high_part; + } + + /* next 8 registers are fp_mmx0-fp_mmx7 */ + for (i =3D 16; i < 24; i++) { + fp_i =3D i - 16; + value =3D assocs[i].value; + env->fpregs[fp_i].d.low =3D value.fp.mantissa; + env->fpregs[fp_i].d.high =3D (value.fp.sign << 15) + | (value.fp.biased_exponent & 0x7FFF); + } + + /* last two registers are fp_control_status and xmm_control_status */ + ctrl_status =3D &assocs[24].value.fp_control_status; + env->fpuc =3D ctrl_status->fp_control; + + env->fpus =3D ctrl_status->fp_status & ~0x3800; + /* bits 11,12,13 are the top of stack pointer */ + env->fpstt =3D (ctrl_status->fp_status >> 11) & 0x7; + + for (i =3D 0; i < 8; i++) { + valid =3D ctrl_status->fp_tag & (1 << i); + env->fptags[i] =3D valid ? 0 : 1; + } + + env->fpop =3D ctrl_status->last_fp_op; + env->fpip =3D ctrl_status->last_fp_rip; + + xmm_ctrl =3D &assocs[25].value.xmm_control_status; + env->mxcsr =3D xmm_ctrl->xmm_status_control; + env->fpdp =3D xmm_ctrl->last_fp_rdp; +} + +static int get_fpu(CPUState *cpu) +{ + struct hv_register_assoc assocs[ARRAY_SIZE(FPU_REGISTER_NAMES)]; + int ret; + X86CPU *x86cpu =3D X86_CPU(cpu); + size_t n_regs =3D ARRAY_SIZE(FPU_REGISTER_NAMES); + + for (size_t i =3D 0; i < n_regs; i++) { + assocs[i].name =3D FPU_REGISTER_NAMES[i]; + } + ret =3D get_generic_regs(cpu, assocs, n_regs); + if (ret < 0) { + error_report("failed to get special registers"); + return -errno; + } + + populate_fpu(assocs, x86cpu); + + return 0; +} + +static int get_xc_reg(CPUState *cpu) +{ + int ret; + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + struct hv_register_assoc assocs[1]; + + assocs[0].name =3D HV_X64_REGISTER_XFEM; + + ret =3D get_generic_regs(cpu, assocs, 1); + if (ret < 0) { + error_report("failed to get xcr0"); + return -1; + } + env->xcr0 =3D assocs[0].value.reg64; + + return 0; +} + static int translate_gva(const CPUState *cpu, uint64_t gva, uint64_t *gpa, uint64_t flags) { @@ -293,7 +379,7 @@ static int set_standard_regs(const CPUState *cpu) return 0; } =20 -int mshv_arch_store_regs(CPUState *cpu) +static int store_regs(CPUState *cpu) { int ret; =20 @@ -435,20 +521,45 @@ static int get_special_regs(CPUState *cpu) return 0; } =20 -int mshv_arch_load_regs(CPUState *cpu) +static int load_regs(CPUState *cpu) { int ret; =20 ret =3D get_standard_regs(cpu); if (ret < 0) { - error_report("Failed to load standard registers"); - return -1; + return ret; } =20 ret =3D get_special_regs(cpu); if (ret < 0) { - error_report("Failed to load special registers"); - return -1; + return ret; + } + + return 0; +} + +int mshv_arch_load_vcpu_state(CPUState *cpu) +{ + int ret; + + ret =3D get_standard_regs(cpu); + if (ret < 0) { + return ret; + } + + ret =3D get_special_regs(cpu); + if (ret < 0) { + return ret; + } + + ret =3D get_xc_reg(cpu); + if (ret < 0) { + return ret; + } + + ret =3D get_fpu(cpu); + if (ret < 0) { + return ret; } =20 return 0; @@ -667,7 +778,7 @@ static int register_intercept_result_cpuid(const CPUSta= te *cpu, return ret; } =20 -static int set_cpuid2(const CPUState *cpu) +static int init_cpuid2(const CPUState *cpu) { int ret; size_t n_entries, cpuid_size; @@ -858,29 +969,6 @@ static int set_xc_reg(const CPUState *cpu) return 0; } =20 -static int set_cpu_state(const CPUState *cpu) -{ - int ret; - - ret =3D set_standard_regs(cpu); - if (ret < 0) { - return ret; - } - ret =3D set_special_regs(cpu); - if (ret < 0) { - return ret; - } - ret =3D set_fpu(cpu); - if (ret < 0) { - return ret; - } - ret =3D set_xc_reg(cpu); - if (ret < 0) { - return ret; - } - return 0; -} - static int get_vp_state(int cpu_fd, struct mshv_get_set_vp_state *state) { int ret; @@ -894,7 +982,7 @@ static int get_vp_state(int cpu_fd, struct mshv_get_set= _vp_state *state) return 0; } =20 -static int get_lapic(int cpu_fd, +static int get_lapic(const CPUState *cpu, struct hv_local_interrupt_controller_state *state) { int ret; @@ -902,6 +990,7 @@ static int get_lapic(int cpu_fd, /* buffer aligned to 4k, as *state requires that */ void *buffer =3D qemu_memalign(size, size); struct mshv_get_set_vp_state mshv_state =3D { 0 }; + int cpu_fd =3D mshv_vcpufd(cpu); =20 mshv_state.buf_ptr =3D (uint64_t) buffer; mshv_state.buf_sz =3D size; @@ -938,7 +1027,7 @@ static int set_vp_state(int cpu_fd, const struct mshv_= get_set_vp_state *state) return 0; } =20 -static int set_lapic(int cpu_fd, +static int set_lapic(const CPUState *cpu, const struct hv_local_interrupt_controller_state *sta= te) { int ret; @@ -946,6 +1035,7 @@ static int set_lapic(int cpu_fd, /* buffer aligned to 4k, as *state requires that */ void *buffer =3D qemu_memalign(size, size); struct mshv_get_set_vp_state mshv_state =3D { 0 }; + int cpu_fd =3D mshv_vcpufd(cpu); =20 if (!state) { error_report("lapic state is NULL"); @@ -967,13 +1057,13 @@ static int set_lapic(int cpu_fd, return 0; } =20 -static int set_lint(int cpu_fd) +static int init_lint(const CPUState *cpu) { int ret; uint32_t *lvt_lint0, *lvt_lint1; =20 struct hv_local_interrupt_controller_state lapic_state =3D { 0 }; - ret =3D get_lapic(cpu_fd, &lapic_state); + ret =3D get_lapic(cpu, &lapic_state); if (ret < 0) { return ret; } @@ -986,161 +1076,31 @@ static int set_lint(int cpu_fd) =20 /* TODO: should we skip setting lapic if the values are the same? */ =20 - return set_lapic(cpu_fd, &lapic_state); + return set_lapic(cpu, &lapic_state); } =20 -static int setup_msrs(const CPUState *cpu) -{ - int ret; - uint64_t default_type =3D MSR_MTRR_ENABLE | MSR_MTRR_MEM_TYPE_WB; - - /* boot msr entries */ - MshvMsrEntry msrs[9] =3D { - { .index =3D IA32_MSR_SYSENTER_CS, .data =3D 0x0, }, - { .index =3D IA32_MSR_SYSENTER_ESP, .data =3D 0x0, }, - { .index =3D IA32_MSR_SYSENTER_EIP, .data =3D 0x0, }, - { .index =3D IA32_MSR_STAR, .data =3D 0x0, }, - { .index =3D IA32_MSR_CSTAR, .data =3D 0x0, }, - { .index =3D IA32_MSR_LSTAR, .data =3D 0x0, }, - { .index =3D IA32_MSR_KERNEL_GS_BASE, .data =3D 0x0, }, - { .index =3D IA32_MSR_SFMASK, .data =3D 0x0, }, - { .index =3D IA32_MSR_MTRR_DEF_TYPE, .data =3D default_type, }, - }; - - ret =3D mshv_configure_msr(cpu, msrs, 9); - if (ret < 0) { - error_report("failed to setup msrs"); - return -1; - } - - return 0; -} - -/* - * TODO: populate topology info: - * - * X86CPU *x86cpu =3D X86_CPU(cpu); - * CPUX86State *env =3D &x86cpu->env; - * X86CPUTopoInfo *topo_info =3D &env->topo_info; - */ -int mshv_configure_vcpu(const CPUState *cpu) -{ - int ret; - int cpu_fd =3D mshv_vcpufd(cpu); - - ret =3D set_cpuid2(cpu); - if (ret < 0) { - error_report("failed to set cpuid"); - return -1; - } - - ret =3D setup_msrs(cpu); - if (ret < 0) { - error_report("failed to setup msrs"); - return -1; - } - - ret =3D set_cpu_state(cpu); - if (ret < 0) { - error_report("failed to set cpu state"); - return -1; - } - - ret =3D set_lint(cpu_fd); - if (ret < 0) { - error_report("failed to set lpic int"); - return -1; - } - - return 0; -} - -static int put_regs(const CPUState *cpu) +int mshv_arch_store_vcpu_state(const CPUState *cpu) { int ret; =20 - ret =3D mshv_configure_vcpu(cpu); + ret =3D set_standard_regs(cpu); if (ret < 0) { - error_report("failed to configure vcpu"); return ret; } =20 - return 0; -} - -struct MsrPair { - uint32_t index; - uint64_t value; -}; - -static int put_msrs(const CPUState *cpu) -{ - int ret =3D 0; - X86CPU *x86cpu =3D X86_CPU(cpu); - CPUX86State *env =3D &x86cpu->env; - MshvMsrEntries *msrs =3D g_malloc0(sizeof(MshvMsrEntries)); - - struct MsrPair pairs[] =3D { - { MSR_IA32_SYSENTER_CS, env->sysenter_cs }, - { MSR_IA32_SYSENTER_ESP, env->sysenter_esp }, - { MSR_IA32_SYSENTER_EIP, env->sysenter_eip }, - { MSR_EFER, env->efer }, - { MSR_PAT, env->pat }, - { MSR_STAR, env->star }, - { MSR_CSTAR, env->cstar }, - { MSR_LSTAR, env->lstar }, - { MSR_KERNELGSBASE, env->kernelgsbase }, - { MSR_FMASK, env->fmask }, - { MSR_MTRRdefType, env->mtrr_deftype }, - { MSR_VM_HSAVE_PA, env->vm_hsave }, - { MSR_SMI_COUNT, env->msr_smi_count }, - { MSR_IA32_PKRS, env->pkrs }, - { MSR_IA32_BNDCFGS, env->msr_bndcfgs }, - { MSR_IA32_XSS, env->xss }, - { MSR_IA32_UMWAIT_CONTROL, env->umwait }, - { MSR_IA32_TSX_CTRL, env->tsx_ctrl }, - { MSR_AMD64_TSC_RATIO, env->amd_tsc_scale_msr }, - { MSR_TSC_AUX, env->tsc_aux }, - { MSR_TSC_ADJUST, env->tsc_adjust }, - { MSR_IA32_SMBASE, env->smbase }, - { MSR_IA32_SPEC_CTRL, env->spec_ctrl }, - { MSR_VIRT_SSBD, env->virt_ssbd }, - }; - - if (ARRAY_SIZE(pairs) > MSHV_MSR_ENTRIES_COUNT) { - error_report("MSR entries exceed maximum size"); - g_free(msrs); - return -1; - } - - for (size_t i =3D 0; i < ARRAY_SIZE(pairs); i++) { - MshvMsrEntry *entry =3D &msrs->entries[i]; - entry->index =3D pairs[i].index; - entry->reserved =3D 0; - entry->data =3D pairs[i].value; - msrs->nmsrs++; - } - - ret =3D mshv_configure_msr(cpu, &msrs->entries[0], msrs->nmsrs); - g_free(msrs); - return ret; -} - - -int mshv_arch_put_registers(const CPUState *cpu) -{ - int ret; - - ret =3D put_regs(cpu); + ret =3D set_special_regs(cpu); if (ret < 0) { - error_report("Failed to put registers"); - return -1; + return ret; } =20 - ret =3D put_msrs(cpu); + ret =3D set_xc_reg(cpu); if (ret < 0) { - error_report("Failed to put msrs"); - return -1; + return ret; + } + + ret =3D set_fpu(cpu); + if (ret < 0) { + return ret; } =20 return 0; @@ -1182,7 +1142,7 @@ static int emulate_instruction(CPUState *cpu, int ret; x86_insn_stream stream =3D { .bytes =3D insn_bytes, .len =3D insn_len = }; =20 - ret =3D mshv_arch_load_regs(cpu); + ret =3D load_regs(cpu); if (ret < 0) { error_report("Failed to load registers"); return -1; @@ -1191,7 +1151,7 @@ static int emulate_instruction(CPUState *cpu, decode_instruction_stream(env, &decode, &stream); exec_instruction(env, &decode); =20 - ret =3D mshv_arch_store_regs(cpu); + ret =3D store_regs(cpu); if (ret < 0) { error_report("failed to store registers"); return -1; @@ -1489,7 +1449,7 @@ static int handle_pio_str(CPUState *cpu, hv_x64_io_po= rt_intercept_message *info) X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; =20 - ret =3D mshv_arch_load_regs(cpu); + ret =3D load_regs(cpu); if (ret < 0) { error_report("Failed to load registers"); return -1; @@ -1660,6 +1620,33 @@ void mshv_init_mmio_emu(void) init_emu(&mshv_x86_emul_ops); } =20 +static int init_msrs(const CPUState *cpu) +{ + int ret; + uint64_t d_t =3D MSR_MTRR_ENABLE | MSR_MTRR_MEM_TYPE_WB; + + const struct hv_register_assoc assocs[] =3D { + { .name =3D HV_X64_REGISTER_SYSENTER_CS, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_SYSENTER_ESP, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_SYSENTER_EIP, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_STAR, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_CSTAR, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_LSTAR, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_KERNEL_GS_BASE, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_SFMASK, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_MSR_MTRR_DEF_TYPE, .value.reg64 =3D d_= t }, + }; + QEMU_BUILD_BUG_ON(ARRAY_SIZE(assocs) > MSHV_MSR_ENTRIES_COUNT); + + ret =3D mshv_set_generic_regs(cpu, assocs, ARRAY_SIZE(assocs)); + if (ret < 0) { + error_report("failed to put msrs"); + return -1; + } + + return 0; +} + void mshv_arch_init_vcpu(CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); @@ -1667,6 +1654,7 @@ void mshv_arch_init_vcpu(CPUState *cpu) AccelCPUState *state =3D cpu->accel; size_t page =3D HV_HYP_PAGE_SIZE; void *mem =3D qemu_memalign(page, 2 * page); + int ret; =20 /* sanity check, to make sure we don't overflow the page */ QEMU_BUILD_BUG_ON((MAX_REGISTER_COUNT @@ -1679,6 +1667,20 @@ void mshv_arch_init_vcpu(CPUState *cpu) state->hvcall_args.output_page =3D (uint8_t *)mem + page; =20 env->emu_mmio_buf =3D g_new(char, 4096); + + /* + * TODO: populate topology info: + * X86CPUTopoInfo *topo_info =3D &env->topo_info; + */ + + ret =3D init_cpuid2(cpu); + assert(ret =3D=3D 0); + + ret =3D init_msrs(cpu); + assert(ret =3D=3D 0); + + ret =3D init_lint(cpu); + assert(ret =3D=3D 0); } =20 void mshv_arch_destroy_vcpu(CPUState *cpu) --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469191; cv=none; d=zohomail.com; s=zohoarc; b=Hi1rmcYaOTCj+bS++PVaqZl4xItj/BZmzte5oEfERY1ZCaFeQmPwi9IH3SVqRdOPH5RZdnVdxkimOIK6H5KLDtX1PQOEcjZCtvy7HOl7/vDqFq4VU1AwrQbQxv0UT1ACa9DrAHAE9uspVZUbo/s+VjpuiHTTP4+qbi8NLn6u4DU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469191; 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=yRDoIIHI0iG+p6GAMRLZ6L4UMThvOSl8GSRYPnDHN5g=; b=fBz4zo5MLwrMH7gIg3L79kGxjfo5+u9l/gTHwS8UyWPIHg4yY6pfHBYNnoOVXw+Vpd1s55rHHA3YU7xnUdy2VQPgroZytWe6RouyP179R6ouy4aeAkgKlDOt/ZpSXwK9xLYy+XWXPHYS6jzxRf7pr2PNu2H2ExXzP1/cmRaP8DM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469191272635.777368755227; Fri, 26 Jun 2026 03:19:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eL-0007sr-5Z; Fri, 26 Jun 2026 06:19:05 -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 1wd3dq-0007LS-Bc for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dn-0005BY-01 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:33 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-BllTUYpMPNeh94R935q4iQ-1; Fri, 26 Jun 2026 06:18:29 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490aadb1386so11098055e9.0 for ; Fri, 26 Jun 2026 03:18:28 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492690988e0sm71825775e9.14.2026.06.26.03.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yRDoIIHI0iG+p6GAMRLZ6L4UMThvOSl8GSRYPnDHN5g=; b=aciaGw08d80AnUh+/1NGaOALCgYwAVc4Divpdf0wgr+7OVW8c0ZwWppiAGgNrardCNSJ2D vc3ZwK/VfREV3rk5XmJvGmqBt+rL7WTWOsD+4hLgVfT9+kYylnwaL4lAdxHlj1RFl4A1wY y1wIvNOTpgcsWghZR65u3L1SwG65iD0= X-MC-Unique: BllTUYpMPNeh94R935q4iQ-1 X-Mimecast-MFC-AGG-ID: BllTUYpMPNeh94R935q4iQ_1782469108 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469108; x=1783073908; 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; bh=yRDoIIHI0iG+p6GAMRLZ6L4UMThvOSl8GSRYPnDHN5g=; b=nT2EeY7TBL+YrnO8kNe/AWFftiCpX6SebZH/IhgfUlFBcoBJglgExmfqwQRk/f9W3l mX30lfklz9/iXMjlboO6U8sS/WULDDNvLu9FTrtZcUEfw4nT/G9nbINhDF5V2uCN/MUX 6U37uuRxU4iJgnkTWYjTYJFirI3AeeVcj8YGzQj71X7fwbUSVUvFjKw9e8mqpy5WnI0t bITBiTfAAr6nQ4Uj+IdpVOPdbimCylguPi/whDWCb/EKsUGmAremOPArJuykainOz+xT yfS53AdqchjU61WrWK/q5luE7tHecCC9UPbILwnuvdFGc0WUPrqweE9sXDfqkWQ/4Urb tezw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469108; x=1783073908; 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; bh=yRDoIIHI0iG+p6GAMRLZ6L4UMThvOSl8GSRYPnDHN5g=; b=P4D2IdOKBJkoMOh9OLTSNcvHRvkirLEPGcPgATtbEUNqvlTzF1F9tvn0arnEx5GKxl EYYcngSorzWv8p32Y8ifZICmM4drv62s4fTyeNtJh8NuZQc9aPZAQ6YUyamT5L21uXS2 cGguL3KNDGkLSUIkfGdzxJ1KMp+ZfRE3pLv3/B1yfH7ixQ3OaQGWNcYKB04Rdsm5zWZJ RNI9Vl+c7hJdNlVVUO9SlAe8je+A8XRzqIdX4Jasz+FhgO3v7AoIxCeGaI80xfRIU4HG hoNTsU71rmx98RCsSVg24LXFSZ1uY7HHQYJeT3ThaP9mP5ue94l0zYeoZV/IWbq7hYu2 /Tgg== X-Gm-Message-State: AOJu0Yxna6gEJSczKyWMgwSdmmdcZCrpUcET9V9/d3cPHs4enUeiI9e9 qWjMuV3yLjHs5GwOQrGzUdkRXXabwjPW/6Tn5YFoEU9YWVPvUIXtod5p+qrOEZlwqhPUh0q+mtH znU831WLC95v52Z4ilB8pRnvlFGhLSEScokmmIqQr2YJgaSwuCUujNwM2JpF1YUk8we5mKgMkzN zmOLuGyXSAEO6BAYpXsRiw59lu09bVFOt6JxTVWNlh X-Gm-Gg: AfdE7ck7dW1xKv1wDCUNCZAd2LgDklKKT+Bvk1DKkrYlDQb7ZTUoaV5TM/iXqvys3+K 4uNU0hBBEuyyueVyTqThHMeMy4Qvm9VJSwfDoGnivxkjs00rBs4Ao/VXuWJmRtXpaZ6jbpSh8xG UN48SNhTds7w9rBnwwpNKzf8mzzCYH+3QCfAW+cPBMo/nTz1NtJd4vdgC7d0dT2z12C1Aa4KWRH 2/ff80zZYlo0AMTjvhZuThwsfJWO7dXtcJ1FPhEy9ymVSmIJvmJik/dpTB+0q1Bk/OtH80/aJL4 S7VEcTLFcz8Nw1lD4/ciU8ounfi6yBIbiX1XmSB+CdYm35X3c9jHuMOIyef0C7PHcraYiFhDHW5 XKC4mWFn2O9GflsIshyjek14Y6To7czNBI3U6KUu/dIKVHzvQ0zPwvcoo0gCwgBK/+DfpTY2okB qX9OfCwyEWNbjVmemV X-Received: by 2002:a05:600c:1551:b0:490:3cf0:8d81 with SMTP id 5b1f17b1804b1-492664241a4mr79260215e9.13.1782469107673; Fri, 26 Jun 2026 03:18:27 -0700 (PDT) X-Received: by 2002:a05:600c:1551:b0:490:3cf0:8d81 with SMTP id 5b1f17b1804b1-492664241a4mr79259525e9.13.1782469107027; Fri, 26 Jun 2026 03:18:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 13/45] accel/accel-irq: add AccelRouteChange abstraction Date: Fri, 26 Jun 2026 12:17:16 +0200 Message-ID: <20260626101748.1728079-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469193443158501 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke The accelerated irqchip routines use a record of changes to batch changes when programming routes. Currently this mechanism is coupled to the KVM accelerator, this change introduces an abstraction that replaces KVMRouteChange and keeps a pointer to an abstract AccelState instead of the concrete type, converting the state where necessary. This is done to further align the irqchip programming in the MSHV accelerator with the existing KVM code in QEMU. Subsequent commits will introduce AccelRouteChange to the MSHV accelerator code. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-5-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/accel/accel-route.h | 17 +++++++++++++++++ include/system/accel-irq.h | 5 +++-- include/system/kvm.h | 21 ++++++++++----------- include/system/mshv.h | 1 + accel/accel-irq.c | 4 ++-- accel/kvm/kvm-all.c | 6 +++--- accel/stubs/kvm-stub.c | 2 +- hw/misc/ivshmem-pci.c | 2 +- hw/vfio/pci.c | 2 +- hw/virtio/virtio-pci.c | 3 +-- target/i386/kvm/kvm.c | 2 +- 11 files changed, 41 insertions(+), 24 deletions(-) create mode 100644 include/accel/accel-route.h diff --git a/include/accel/accel-route.h b/include/accel/accel-route.h new file mode 100644 index 00000000000..07fac27e2a7 --- /dev/null +++ b/include/accel/accel-route.h @@ -0,0 +1,17 @@ +/* + * Accelerator MSI route change tracking + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef ACCEL_ROUTE_H +#define ACCEL_ROUTE_H + +#include "qemu/accel.h" + +typedef struct AccelRouteChange { + AccelState *accel; + int changes; +} AccelRouteChange; + +#endif /* ACCEL_ROUTE_H */ diff --git a/include/system/accel-irq.h b/include/system/accel-irq.h index a2caa06f547..a1489207113 100644 --- a/include/system/accel-irq.h +++ b/include/system/accel-irq.h @@ -25,9 +25,10 @@ static inline bool accel_irqchip_is_split(void) return mshv_msi_via_irqfd_enabled() || kvm_irqchip_is_split(); } =20 -int accel_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *= dev); +int accel_irqchip_add_msi_route(AccelRouteChange *c, int vector, + PCIDevice *dev); int accel_irqchip_update_msi_route(int vector, MSIMessage msg, PCIDevice *= dev); -void accel_irqchip_commit_route_changes(KVMRouteChange *c); +void accel_irqchip_commit_route_changes(AccelRouteChange *c); void accel_irqchip_commit_routes(void); void accel_irqchip_release_virq(int virq); int accel_irqchip_add_irqfd_notifier_gsi(EventNotifier *n, EventNotifier *= rn, diff --git a/include/system/kvm.h b/include/system/kvm.h index 5fa33eddda3..ccf90b83416 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -18,6 +18,7 @@ =20 #include "exec/memattrs.h" #include "qemu/accel.h" +#include "accel/accel-route.h" #include "qom/object.h" =20 #ifdef COMPILING_PER_TARGET @@ -183,11 +184,6 @@ extern KVMState *kvm_state; typedef struct Notifier Notifier; typedef struct NotifierWithReturn NotifierWithReturn; =20 -typedef struct KVMRouteChange { - KVMState *s; - int changes; -} KVMRouteChange; - /* external API */ =20 unsigned int kvm_get_max_memslots(void); @@ -466,7 +462,7 @@ void kvm_init_cpu_signals(CPUState *cpu); =20 /** * kvm_irqchip_add_msi_route - Add MSI route for specific vector - * @c: KVMRouteChange instance. + * @c: AccelRouteChange instance. * @vector: which vector to add. This can be either MSI/MSIX * vector. The function will automatically detect whether * MSI/MSIX is enabled, and fetch corresponding MSI @@ -475,20 +471,23 @@ void kvm_init_cpu_signals(CPUState *cpu); * as @NULL, an empty MSI message will be inited. * @return: virq (>=3D0) when success, errno (<0) when failed. */ -int kvm_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *de= v); +int kvm_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *= dev); int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg, PCIDevice *dev); void kvm_irqchip_commit_routes(KVMState *s); =20 -static inline KVMRouteChange kvm_irqchip_begin_route_changes(KVMState *s) +static inline AccelRouteChange kvm_irqchip_begin_route_changes(KVMState *s) { - return (KVMRouteChange) { .s =3D s, .changes =3D 0 }; + return (AccelRouteChange) { + .accel =3D ACCEL(s), + .changes =3D 0, + }; } =20 -static inline void kvm_irqchip_commit_route_changes(KVMRouteChange *c) +static inline void kvm_irqchip_commit_route_changes(AccelRouteChange *c) { if (c->changes) { - kvm_irqchip_commit_routes(c->s); + kvm_irqchip_commit_routes(KVM_STATE(c->accel)); c->changes =3D 0; } } diff --git a/include/system/mshv.h b/include/system/mshv.h index 51b04207358..8dd77a76241 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -21,6 +21,7 @@ #include "qapi/qapi-types-common.h" #include "system/memory.h" #include "accel/accel-ops.h" +#include "accel/accel-route.h" =20 #ifdef COMPILING_PER_TARGET #ifdef CONFIG_MSHV diff --git a/accel/accel-irq.c b/accel/accel-irq.c index 7f864e35c4e..0aa04c033d4 100644 --- a/accel/accel-irq.c +++ b/accel/accel-irq.c @@ -16,7 +16,7 @@ #include "system/mshv.h" #include "system/accel-irq.h" =20 -int accel_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *= dev) +int accel_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice= *dev) { #ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { @@ -42,7 +42,7 @@ int accel_irqchip_update_msi_route(int vector, MSIMessage= msg, PCIDevice *dev) return -ENOSYS; } =20 -void accel_irqchip_commit_route_changes(KVMRouteChange *c) +void accel_irqchip_commit_route_changes(AccelRouteChange *c) { #ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f4f0e64fbd0..7217baf8d40 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2359,11 +2359,11 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage ms= g) return kvm_vm_ioctl(s, KVM_SIGNAL_MSI, &msi); } =20 -int kvm_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *de= v) +int kvm_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *= dev) { struct kvm_irq_routing_entry kroute =3D {}; int virq; - KVMState *s =3D c->s; + KVMState *s =3D KVM_STATE(c->accel); MSIMessage msg =3D {0, 0}; =20 if (pci_available && dev) { @@ -2506,7 +2506,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg) abort(); } =20 -int kvm_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *de= v) +int kvm_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *= dev) { return -ENOSYS; } diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index c4617caac6b..32b4b074035 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -44,7 +44,7 @@ int kvm_on_sigbus(int code, void *addr) return 1; } =20 -int kvm_irqchip_add_msi_route(KVMRouteChange *c, int vector, PCIDevice *de= v) +int kvm_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *= dev) { return -ENOSYS; } diff --git a/hw/misc/ivshmem-pci.c b/hw/misc/ivshmem-pci.c index c987eebb983..aa8f2717555 100644 --- a/hw/misc/ivshmem-pci.c +++ b/hw/misc/ivshmem-pci.c @@ -424,7 +424,7 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, i= nt vector, Error **errp) { PCIDevice *pdev =3D PCI_DEVICE(s); - KVMRouteChange c; + AccelRouteChange c; int ret; =20 IVSHMEM_DPRINTF("ivshmem_add_kvm_msi_virq vector:%d\n", vector); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 9c06b25e637..1817f39cde7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -50,7 +50,7 @@ #include "vfio-helpers.h" =20 /* Protected by BQL */ -static KVMRouteChange vfio_route_change; +static AccelRouteChange vfio_route_change; =20 static void vfio_disable_interrupts(VFIOPCIDevice *vdev); static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index fd9719547f9..90df7bf3a1a 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -869,7 +869,7 @@ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy = *proxy, int ret; =20 if (irqfd->users =3D=3D 0) { - KVMRouteChange c =3D kvm_irqchip_begin_route_changes(kvm_state); + AccelRouteChange c =3D kvm_irqchip_begin_route_changes(kvm_state); ret =3D accel_irqchip_add_msi_route(&c, vector, &proxy->pci_dev); if (ret < 0) { return ret; @@ -2669,4 +2669,3 @@ static void virtio_pci_register_types(void) } =20 type_init(virtio_pci_register_types) - diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 9e352882c8c..478a5573cd2 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6678,7 +6678,7 @@ void kvm_arch_init_irq_routing(KVMState *s) kvm_gsi_routing_allowed =3D true; =20 if (kvm_irqchip_is_split()) { - KVMRouteChange c =3D kvm_irqchip_begin_route_changes(s); + AccelRouteChange c =3D kvm_irqchip_begin_route_changes(s); int i; =20 /* If the ioapic is in QEMU and the lapics are in KVM, reserve --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469171; cv=none; d=zohomail.com; s=zohoarc; b=KmFGk5LDnfeEE0bpUbPSm9zYjWPDsDgFo+G8tzBVq3k4vy2ge8idK531d3bUfKaGP1Rf5qVAzhtl8weSBmdkkO49uzT8RWrSOA5NIX2qojWHUbUOrxbGO62s2IJG1ypSasVj+wMqttxnFahVROOXbvJFGop2snsEi2fUU9wT+rM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469171; 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=LjjbSWd3wzg6wKy/nHkbp/LpCSoNcT1KOWYYF7ZfsKs=; b=DNdH1Sr/7rdgkNTg1Egj5c9/luk4Q7LILQcnQrcVlZLfugdPQWZ4BOO+BBW53LN85v/aZaGhwryyei/wXyJD6INO/ROVAO/JwcLD/fCv82fFtWtaaHSdJLkNk3m1prmkGGvtGsaO+5HuCMGbfCqMO5kNvc7FT+aKh9F/Fg+MyvY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469171553193.54832691227796; Fri, 26 Jun 2026 03:19:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ea-0000ta-T7; Fri, 26 Jun 2026 06:19:20 -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 1wd3ds-0007O1-6I for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dq-0005Bw-3v for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:35 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-p8fRSnqdMAadhLoUdLvJSA-1; Fri, 26 Jun 2026 06:18:31 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49244130073so5949795e9.1 for ; Fri, 26 Jun 2026 03:18:31 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c221d93eesm22899912f8f.20.2026.06.26.03.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LjjbSWd3wzg6wKy/nHkbp/LpCSoNcT1KOWYYF7ZfsKs=; b=H5qus9oMVoTpQR9xMWNLy0P1SDEmF0Z6x82aJxxCkU21lGb/hVBWI1P78LNEtRLugHOY/B XBfdbCsJIGS57tbc+Ql4v7jeOJcFQ+CZEQjbnbKFCauXyOtwoomGKI2L7DUyTpCV4kn6Hn JZYieds3/67J4AWI7l6x3zuWfoWrHn8= X-MC-Unique: p8fRSnqdMAadhLoUdLvJSA-1 X-Mimecast-MFC-AGG-ID: p8fRSnqdMAadhLoUdLvJSA_1782469110 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469110; x=1783073910; 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; bh=LjjbSWd3wzg6wKy/nHkbp/LpCSoNcT1KOWYYF7ZfsKs=; b=fpv+VquRUo+y600+sy7R7f3EgyG4FXUugbAA++qz6rt9AW+ymXe9k6/AreYu79fcTb G72zfJ/dGk1kDVxSYk+K4ul+4gaPxDJUdqyn6YlabMyyoceqrVyfVChy3gC2dqeS6yRj FCVbxx8OfuDfNGlQVl9iXQfTvUFmy+UnUPfiOARVGlD0ICSh+BdylcofYHQ9PY/3BKRq 7Q4ShjwUYlfMdAf2O/ptYP7MhoWoH+gFp3lpy2Gu/fkpiZo9jGK79TLEa9sGRqzwwbiP bd/x8WEi2xcGjd/2OFF51sfD/77F/QDfOBZzHqR+awxMtDdypl/FTo2aqrRUpsTDyhYO 9DJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469110; x=1783073910; 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; bh=LjjbSWd3wzg6wKy/nHkbp/LpCSoNcT1KOWYYF7ZfsKs=; b=iI9EiHfcIoPP7Ovu4Vyo45/ms+Jm7t0Et+ZTBAG2R9aeOYve4iwqlDsviKiPW82G2v UXnzP1QyGUGtFqoWMTJNiQc15yVFZPknHqim1I1AqQckQKHdlCwPsoMrt9/W1tGwiC2E Y8vxlMexebtynSpSo8dZ7iIJhWo4MBQEQWn0EU4mKoBm/2yRLMDzxbChXsdE/r0WY+7C k1guc5xKNuTY8rHFJQ5ofQx9C2EO0grdIPhWiu3JnNzW5Jpu0pDhfnDhK9yowP80Ze9r +D0HewAE//P0NWW1LAGCngYsncRolkMTDRPZ9noyR/n7vakk63p9lk2ogblvaqTfhhA8 IxBw== X-Gm-Message-State: AOJu0YxYQg7w1jBnaRDxEpWcigxBllKmK+3wfSDGD78BTAQDX877REGN YgAHZD7d04o5YyzxbnBzFM2+bHdCclXaInlQQo+KLt8xFnn3lY70uBkuozHK7n2XrPrO6XdRljw NUtnd2wbXU/QTUoZLEY1qSpTnqMHD7zQBBzf1Say92SLVKS1qNj1hvBaQjhQfwNgreXg5ZIBzuo ORZuHGRP8hqbp2cKNJ1qHHiM5LMo5hEmeyc18xLX+R X-Gm-Gg: AfdE7cmak5QauqPaFDYk4bwVt8RUYzai+rOiSLGm7/CujKZ8CuHoZ14jioTH31oRrGZ Ugs5a07ZUbTnq4jM7bSH+7gosYDPeB7w223rO7d/q6RoAUDfEJFQz65I7aBUKbijxmzivmqQtQK eH4kbV/jzS2nNbdkd3SDp0Er9ti5fWdCVHpsvHG4eGBG8sVyleLDzMkkXdzFaFymP+fUsp7HQD5 HHoAnwYJWEFPPVS1gzANwf2oa2GUF834UjNd6jc9w/8JmGyah+9oLT1IzzKSodA1IdBF9YJRtMf dvK81HlrTONoWStq/1McfpujdjPVC8fWsFP9wr24oViEcAHHOmaRqU7EDBD9hFOPWtOkd4Q7vjB 0CBismjfacICjHxispEo3Gzx2lyG/clcSsaM5gbe6DFoyzA0X7n7xbS0cfi5fkPuBAitDEuSEpX djfvOoY4UsXyr6Nyke X-Received: by 2002:a05:600c:c1d7:10b0:492:4667:8c40 with SMTP id 5b1f17b1804b1-492668638c1mr71801195e9.8.1782469110047; Fri, 26 Jun 2026 03:18:30 -0700 (PDT) X-Received: by 2002:a05:600c:c1d7:10b0:492:4667:8c40 with SMTP id 5b1f17b1804b1-492668638c1mr71800785e9.8.1782469109593; Fri, 26 Jun 2026 03:18:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 14/45] accel/accel-irq: add generic begin_route_changes Date: Fri, 26 Jun 2026 12:17:17 +0200 Message-ID: <20260626101748.1728079-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469173299158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke A generic accel_irqchip_begin_route_change() fn has been introduced for usage in the MSHV accelerator. It replaces the respective kvm_ fn. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-6-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/system/accel-irq.h | 1 + include/system/kvm.h | 8 -------- accel/accel-irq.c | 21 +++++++++++++++++++++ hw/misc/ivshmem-pci.c | 4 ++-- hw/vfio/pci.c | 5 +++-- hw/virtio/virtio-pci.c | 2 +- target/i386/kvm/kvm.c | 3 ++- 7 files changed, 30 insertions(+), 14 deletions(-) diff --git a/include/system/accel-irq.h b/include/system/accel-irq.h index a1489207113..fc94c54264b 100644 --- a/include/system/accel-irq.h +++ b/include/system/accel-irq.h @@ -25,6 +25,7 @@ static inline bool accel_irqchip_is_split(void) return mshv_msi_via_irqfd_enabled() || kvm_irqchip_is_split(); } =20 +AccelRouteChange accel_irqchip_begin_route_changes(void); int accel_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice *dev); int accel_irqchip_update_msi_route(int vector, MSIMessage msg, PCIDevice *= dev); diff --git a/include/system/kvm.h b/include/system/kvm.h index ccf90b83416..fec24d2135a 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -476,14 +476,6 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq= , MSIMessage msg, PCIDevice *dev); void kvm_irqchip_commit_routes(KVMState *s); =20 -static inline AccelRouteChange kvm_irqchip_begin_route_changes(KVMState *s) -{ - return (AccelRouteChange) { - .accel =3D ACCEL(s), - .changes =3D 0, - }; -} - static inline void kvm_irqchip_commit_route_changes(AccelRouteChange *c) { if (c->changes) { diff --git a/accel/accel-irq.c b/accel/accel-irq.c index 0aa04c033d4..3815f6727c6 100644 --- a/accel/accel-irq.c +++ b/accel/accel-irq.c @@ -10,6 +10,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "hw/pci/msi.h" =20 #include "system/kvm.h" @@ -104,3 +105,23 @@ int accel_irqchip_remove_irqfd_notifier_gsi(EventNotif= ier *n, int virq) } return -ENOSYS; } + +inline AccelRouteChange accel_irqchip_begin_route_changes(void) +{ +#ifdef CONFIG_MSHV_IS_POSSIBLE + if (mshv_msi_via_irqfd_enabled()) { + return (AccelRouteChange) { + .accel =3D ACCEL(mshv_state), + .changes =3D 0, + }; + } +#endif + if (kvm_enabled()) { + return (AccelRouteChange) { + .accel =3D ACCEL(kvm_state), + .changes =3D 0, + }; + } + error_report("can't initiate route change, no accel irqchip available"= ); + abort(); +} diff --git a/hw/misc/ivshmem-pci.c b/hw/misc/ivshmem-pci.c index aa8f2717555..fa23562886b 100644 --- a/hw/misc/ivshmem-pci.c +++ b/hw/misc/ivshmem-pci.c @@ -26,7 +26,7 @@ #include "hw/core/qdev-properties-system.h" #include "hw/pci/msi.h" #include "hw/pci/msix.h" -#include "system/kvm.h" +#include "system/accel-irq.h" #include "migration/blocker.h" #include "migration/vmstate.h" #include "qemu/error-report.h" @@ -430,7 +430,7 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, i= nt vector, IVSHMEM_DPRINTF("ivshmem_add_kvm_msi_virq vector:%d\n", vector); assert(!s->msi_vectors[vector].pdev); =20 - c =3D kvm_irqchip_begin_route_changes(kvm_state); + c =3D accel_irqchip_begin_route_changes(); ret =3D kvm_irqchip_add_msi_route(&c, vector, pdev); if (ret < 0) { error_setg(errp, "kvm_irqchip_add_msi_route failed"); diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 1817f39cde7..3a6e17c9d77 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -38,6 +38,7 @@ #include "qemu/module.h" #include "qemu/range.h" #include "qemu/units.h" +#include "system/accel-irq.h" #include "system/kvm.h" #include "system/runstate.h" #include "pci.h" @@ -688,7 +689,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, if (vdev->defer_kvm_irq_routing) { vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true); } else { - vfio_route_change =3D kvm_irqchip_begin_route_changes(kvm_= state); + vfio_route_change =3D accel_irqchip_begin_route_changes(); vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true); kvm_irqchip_commit_route_changes(&vfio_route_change); vfio_connect_kvm_msi_virq(vector, nr); @@ -789,7 +790,7 @@ void vfio_pci_prepare_kvm_msi_virq_batch(VFIOPCIDevice = *vdev) { assert(!vdev->defer_kvm_irq_routing); vdev->defer_kvm_irq_routing =3D true; - vfio_route_change =3D kvm_irqchip_begin_route_changes(kvm_state); + vfio_route_change =3D accel_irqchip_begin_route_changes(); } =20 void vfio_pci_commit_kvm_msi_virq_batch(VFIOPCIDevice *vdev) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 90df7bf3a1a..6f5db5fc42b 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -869,7 +869,7 @@ static int kvm_virtio_pci_vq_vector_use(VirtIOPCIProxy = *proxy, int ret; =20 if (irqfd->users =3D=3D 0) { - AccelRouteChange c =3D kvm_irqchip_begin_route_changes(kvm_state); + AccelRouteChange c =3D accel_irqchip_begin_route_changes(); ret =3D accel_irqchip_add_msi_route(&c, vector, &proxy->pci_dev); if (ret < 0) { return ret; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 478a5573cd2..03312922d50 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -32,6 +32,7 @@ #include "vmsr_energy.h" #include "system/system.h" #include "system/hw_accel.h" +#include "system/accel-irq.h" #include "system/kvm_int.h" #include "system/runstate.h" #include "system/ramblock.h" @@ -6678,7 +6679,7 @@ void kvm_arch_init_irq_routing(KVMState *s) kvm_gsi_routing_allowed =3D true; =20 if (kvm_irqchip_is_split()) { - AccelRouteChange c =3D kvm_irqchip_begin_route_changes(s); + AccelRouteChange c =3D accel_irqchip_begin_route_changes(); int i; =20 /* If the ioapic is in QEMU and the lapics are in KVM, reserve --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469388; cv=none; d=zohomail.com; s=zohoarc; b=VEm/d7eT21cbkIheYWwljwHyHMNcEZlbu1S2Vd3mme4WH5EgqGWqUS89CjmvSfhctzoN1vlpMLl8JyUygzN98ud5hB1onWezkItlFR35wWiXnOfvNZuazEX/K2Fw5f9Rt8MdpEbgsPgVW/7A9zDCGnT+m0AFv1QpF1moe5sNRs4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469388; 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=p+gLFg/KCZl9YS09p+/cGqgOKgC1kYOxDJsSPMp/QV8=; b=K83g1wkErjZUf4Inx2OIseZtrlHh9b9nJfYLVknMhd1VtJRc3LhmKJngWbPgasAYmHcX0WmEcYp7Fg7ei84t1JkAdp3TBgU274pRkaJzpPmWaWU1VKX93F7iXVy1zdANr6u49juNTLxZqCubRjHHUQLVo7I2miYpTUkW119UgOQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469388532170.52945324913912; Fri, 26 Jun 2026 03:23:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eM-00086Z-RL; Fri, 26 Jun 2026 06:19:06 -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 1wd3dz-0007Ov-KM for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dt-0005CU-Ch for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:42 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-mzbtAGYsOxGJWMPbTVfMCw-1; Fri, 26 Jun 2026 06:18:35 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-46f5d62dd1cso79426f8f.3 for ; Fri, 26 Jun 2026 03:18:35 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46f978dc0a9sm936421f8f.15.2026.06.26.03.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p+gLFg/KCZl9YS09p+/cGqgOKgC1kYOxDJsSPMp/QV8=; b=H9cDAxREEIAAe3omPFBqtCXbze/zMR773boslNAAsQP+odWfZzTBDzyxNyhpq+1Cg2XWiE fvpsp63yjn/5h7yC6LMR7YnIrBShG+cUYbIidghr4vt+O6LgTSUSncbxIZHUnFTNks7P/t tWfZlNqT2Dv+YXYo7if5kbfIa5JmHtk= X-MC-Unique: mzbtAGYsOxGJWMPbTVfMCw-1 X-Mimecast-MFC-AGG-ID: mzbtAGYsOxGJWMPbTVfMCw_1782469114 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469114; x=1783073914; 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; bh=p+gLFg/KCZl9YS09p+/cGqgOKgC1kYOxDJsSPMp/QV8=; b=K+P80yZ2CkwBUJ6eCxuUNW+NTAkMSVxnY220b35ah0RL9K9Vfz+9VVzxvtnS1Fw7Gp zyFE9kFqOV1IidpRsYrMQMg0bXdW7vMWs+5afD+N70spjX6SbieKWVNZRax/Ndt12mqT sclXFWD+6svl1GZL2FMgkwgcwrRu08kLPihWhKjynj31MklYQQBVrq+tQXv7RAQiMN+F GuUIyYYRQfX3pTWDS+2zKKOwiWiUBHj5rslW7p0q+q797lZIO3xxbVIvbeWksihw+w0i 7AgpmefqnFv8ME+ZHuqlBuV7qo8/2/EBFQguasko/sTJ5Z3pTV/7CijaJ3x13tF5NZnK W7Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469114; x=1783073914; 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; bh=p+gLFg/KCZl9YS09p+/cGqgOKgC1kYOxDJsSPMp/QV8=; b=M/c+KSfBPt40QqnXGXbVIS85FaTN+LwOn1L1DFXchfL6MUrwBw+5Su2JHMOw2G9ntc dy9nvsXohaWfCs35lF8WjjvLRncAYB2wi0h4ZOhUW7NPUB7vevvJJzmgQeVmBfUi8C6t So0p/uKIJoBsuyY4jJZGRCP8McLvTSU2VHMVJn0Rsy7VmfilPPHnc7/GpvkGlPoWErP/ VhnldLF3OWV+Magkew9Q0e7lqbq+NzF9q17aOymyhSvggNXxEBWXxnojng3U2cV7uiIK jkeCuL/UIf/9PeQJoSUqIyxMEd1WCJEIH1PfTbN0aqMtC83GW7/EMQItqRWVxJ8AWT6H e03g== X-Gm-Message-State: AOJu0YxKNsmq1xMqW6Ko90sB/UIqgIHLhfftlg3xlFC+dO6r2q5KgCWj gY7B3cjzjsriuMfdJY0ISqqSPMN+crja/3kCNmLdNg5JLWUD1Ul5egAeZTgPh3I5CM7Lo2VDtB0 LXq+xQ9q+sTVsvKHXE+nzHw+QkF5aZFXThQIi2IHn3C5eS8Uwy1M3aAKKCiCFgn77Le59Lz/qyq 2dSYYA4Xfn3GRlt0cqFmoY6UNiZy16Ls/RRR7xbAor X-Gm-Gg: AfdE7cmd2X0KHfjRBuc7G58ZSsJjAioGYJbzzEm0xa1Tl0UWB48wTwf96IbB3Kbb8ga w99P7/iB3NfNPB0bIJrjAHruufge1K0ZEfEYm1KX1+PyLii7lTLUQ1CahYZAP0Ve4674jBipLUm A6UauiCeiVuCbmTU28XCvbeSAhwQprGIs+S6tHRBTDG8hoeYyO7OmX0rSvhE3L6ppHNCDDdgB2C n8IWUQaGGZjkGiYoNyK8TzUu6JVqP79g50mLyj8PtPtCNA8N2IBtTEl4MC7/3Ux4Z8zOhkK9OSp tD0On/I6ajxF61PkFJws9PTrqaSTlFH9vVBgJwlTwzA7frWp1k2rucpZo8lKMh5yV4lu2/vfGDW XoK9LPZ19s6qnkYhXMYqBx/6xwTsBMUHb8KfIB2MyWP26WmfG2XFbx4PW5RSy4cAHSJs3sPksYl 7A75XFQKB2DB3BmzNT X-Received: by 2002:a05:6000:46d8:b0:46e:7f72:b6fe with SMTP id ffacd0b85a97d-46e7f72b845mr3905819f8f.19.1782469114212; Fri, 26 Jun 2026 03:18:34 -0700 (PDT) X-Received: by 2002:a05:6000:46d8:b0:46e:7f72:b6fe with SMTP id ffacd0b85a97d-46e7f72b845mr3905760f8f.19.1782469113615; Fri, 26 Jun 2026 03:18:33 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 15/45] accel/accel-irq: add generic commit_route_changes Date: Fri, 26 Jun 2026 12:17:18 +0200 Message-ID: <20260626101748.1728079-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469390527158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke A generic accel_irqchip_commit_route_changes() fn has been introduced for usage in the MSHV accelerator. The respective kvm_ fn can be removed since we handle the commit op in a generic way. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-7-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/system/kvm.h | 8 -------- accel/accel-irq.c | 10 +++------- hw/misc/ivshmem-pci.c | 2 +- hw/vfio/pci.c | 4 ++-- target/i386/kvm/kvm.c | 2 +- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/include/system/kvm.h b/include/system/kvm.h index fec24d2135a..cdd1856ac5f 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -476,14 +476,6 @@ int kvm_irqchip_update_msi_route(KVMState *s, int virq= , MSIMessage msg, PCIDevice *dev); void kvm_irqchip_commit_routes(KVMState *s); =20 -static inline void kvm_irqchip_commit_route_changes(AccelRouteChange *c) -{ - if (c->changes) { - kvm_irqchip_commit_routes(KVM_STATE(c->accel)); - c->changes =3D 0; - } -} - int kvm_irqchip_get_virq(KVMState *s); void kvm_irqchip_release_virq(KVMState *s, int virq); =20 diff --git a/accel/accel-irq.c b/accel/accel-irq.c index 3815f6727c6..7e71b525557 100644 --- a/accel/accel-irq.c +++ b/accel/accel-irq.c @@ -45,13 +45,9 @@ int accel_irqchip_update_msi_route(int vector, MSIMessag= e msg, PCIDevice *dev) =20 void accel_irqchip_commit_route_changes(AccelRouteChange *c) { -#ifdef CONFIG_MSHV_IS_POSSIBLE - if (mshv_msi_via_irqfd_enabled()) { - mshv_irqchip_commit_routes(); - } -#endif - if (kvm_enabled()) { - kvm_irqchip_commit_route_changes(c); + if (c->changes) { + accel_irqchip_commit_routes(); + c->changes =3D 0; } } =20 diff --git a/hw/misc/ivshmem-pci.c b/hw/misc/ivshmem-pci.c index fa23562886b..536475e9de8 100644 --- a/hw/misc/ivshmem-pci.c +++ b/hw/misc/ivshmem-pci.c @@ -436,7 +436,7 @@ static void ivshmem_add_kvm_msi_virq(IVShmemState *s, i= nt vector, error_setg(errp, "kvm_irqchip_add_msi_route failed"); return; } - kvm_irqchip_commit_route_changes(&c); + accel_irqchip_commit_route_changes(&c); =20 s->msi_vectors[vector].virq =3D ret; s->msi_vectors[vector].pdev =3D pdev; diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 3a6e17c9d77..d2aba8aaf50 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -691,7 +691,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, uns= igned int nr, } else { vfio_route_change =3D accel_irqchip_begin_route_changes(); vfio_pci_add_kvm_msi_virq(vdev, vector, nr, true); - kvm_irqchip_commit_route_changes(&vfio_route_change); + accel_irqchip_commit_route_changes(&vfio_route_change); vfio_connect_kvm_msi_virq(vector, nr); } } @@ -800,7 +800,7 @@ void vfio_pci_commit_kvm_msi_virq_batch(VFIOPCIDevice *= vdev) assert(vdev->defer_kvm_irq_routing); vdev->defer_kvm_irq_routing =3D false; =20 - kvm_irqchip_commit_route_changes(&vfio_route_change); + accel_irqchip_commit_route_changes(&vfio_route_change); =20 for (i =3D 0; i < vdev->nr_vectors; i++) { vfio_connect_kvm_msi_virq(&vdev->msi_vectors[i], i); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 03312922d50..64cc421abe6 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6690,7 +6690,7 @@ void kvm_arch_init_irq_routing(KVMState *s) exit(1); } } - kvm_irqchip_commit_route_changes(&c); + accel_irqchip_commit_route_changes(&c); } } =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469181; cv=none; d=zohomail.com; s=zohoarc; b=fqzaGlP5sQjfyT6zanM3LJ9w+9EFhXtskOHFojeAxMGSaKp8XwWgDGPY0uq4/lQABbNVU8rR7DAgR+BMyOUWTxBptOYyql7Eg2mvZ0imoPQnlNCG96gUTc84BkuHRNWCcN0qHqXP/JJqlcNxo8SnI38uYGlH/yMyBlHNK8sQjWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469181; 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=PUsDLLw3f+BtqliRgCOEc8pOa9czxBjabKlNn2cuJDs=; b=Btk/zqKfu9pdJEEyCpmqI6S/Moch6nd2iWOSXh7P0LfJSM4yR2X7pQwVvZi6KQEa7U5sppC0nNKDjWFYSiBwwamCFnZJxCvb88YcucGICGhqZXsskZVU7DUTVDu11Zp+NYabfsG3x4ma840Pl1OvG39/qvlgq03k6MoYaCWYXFU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469181680477.022763315396; Fri, 26 Jun 2026 03:19:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eO-0008Fx-1u; Fri, 26 Jun 2026 06:19:08 -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 1wd3e1-0007Qf-7j for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dz-0005Cf-BD for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:44 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-WiQRO7l_P-SaTGhnwYSHtQ-1; Fri, 26 Jun 2026 06:18:37 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490b7959b9fso6343145e9.2 for ; Fri, 26 Jun 2026 03:18:37 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492690168d5sm92157205e9.14.2026.06.26.03.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PUsDLLw3f+BtqliRgCOEc8pOa9czxBjabKlNn2cuJDs=; b=cnn5DaqXQXilmmXekeVD+YW/yEdw+xwrjFIG9s9UX0qtLzYpvlitubLNM9Socxs4AwWQeF I//wQwyAaBLP4rZdldPuxAYS1dxxGZb6Rddw47VEMsFy9eX+KO49ah4xZr1C0kIe2MJhb7 K+jj+Ou6GDS6+u+4Blf9Df9EJybZH+M= X-MC-Unique: WiQRO7l_P-SaTGhnwYSHtQ-1 X-Mimecast-MFC-AGG-ID: WiQRO7l_P-SaTGhnwYSHtQ_1782469116 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469116; x=1783073916; 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; bh=PUsDLLw3f+BtqliRgCOEc8pOa9czxBjabKlNn2cuJDs=; b=UKL3mqKtiBrtbPZjicxJ1uQlt8sXGUXzEcutOeuMSlaaQ/h3n194Jcu79NpQPmnVNi YSpQBabD3lPS6YI0/h0ugKRg5EdTNakGeehFXnhC+LuahghDWWUb2CgDJvm3HCXsbq/o IlR1mWPVoPiVD9tZRp0FSd0hB3lPIRsJOeQYX9iHONi2J/TnrGFT9JgddiZlZ4H/SPEs da9rcaI+QntYv9oReIn3SyE7M0gPjpXQlqL3wlAJkAgSLR/r9OpBV7LGnq2wVzLAFqw6 QHjVjhiiyQBifloRZHa+BN2PNIpSCaq/B9O4pgn5vRmNCrhquLsJgTa36zstdwt1aHEz oO4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469116; x=1783073916; 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; bh=PUsDLLw3f+BtqliRgCOEc8pOa9czxBjabKlNn2cuJDs=; b=KxztAbWArcl7sH3NODvcrnACPKk11racgn+H5MgulLN0BsQWZUjYK+XGCwyS6zK4SY qRjf/+/LiYBfx511d+oVhqsoT/e5E3sUu3h8QP0xOERAF1nQWMwPMw+zHBzGGR9leXk8 sEXLj29gfT5UeQn9Lzrr7z+qx3olUx++d8R5L0MJQwWtlALhhdcv9Fzk0UBrYURRokNq frfbcRqe40O5OXQDR1KMIDBoAD+k/fvgaC8FYIuUTalvolO28Pmomup55He8PdDCgkCJ rVXumthhzjNHFVN2L2lTlEluCivbg/UQ1M9jKId/6DOoWtHCQGNsKHyUbyLZBpFWNyKX H0Mw== X-Gm-Message-State: AOJu0YwPHn9QsBFL5S/7mFhNVmZ4jvt0f1oVricFEtminUeuOFARMyym b+65T/SbTpsJ/ZBk4+pWkEAGmqfjxXV++Qbegghv+56JRBGIl5MOXeRDZHzW+mC2MXzpEWBXe/8 VOTOKi2bzoH/x9we2c5rdESHW3zijvFOuqYYusBwkQf273OUVzzeQqvDUrUZh6NDfs4Lf5EiWR4 9WibLu/9L1YfKZpfKwojYDG55s7oJC/7TZglt0HijI X-Gm-Gg: AfdE7cnDA2yEK2wnkJwnnHgMOaGxWaRyqjn0fhh3+paj0vvfWZ6pPBANuaSUwscrTr5 Q16dQT4cuP3QUZ4PGcEmzcxZc2Cc2kYdPbWrAZYgaQuLZWFWdXaoDpt79FKWwkNYq0LmXkjE4py +XsWA+Lv/K1+EU/Pdl6kNQu8/W4+0BgW/AWWPNzqfM4hDsHuXNjkGIrY47fi1NXBsCf5+PpdsaL fpAIS/TfqzTwINucZANrV4splDKCCriLkHLkEQR+z5K4r7oCjeL3F9OcC+Xywmu0ZIYMSX9Lv2C qjCLQoInZ2lLCFE4p1R8AWmr20VN2wOIDQ2ifUfrQwbMzqpzgZyr7eKYlGZ6GH6AnSQh7gYMEGY t4UgdKdSUpsiFiDWM8NTHNVDWJgQ9Zzss5pkcShFG/8l4PSshLmfqLfQgxJVAqAkzocEKQysiQP Nu8rAuw/1ldrpY0Mm7 X-Received: by 2002:a05:600c:3f18:b0:490:c6c2:52 with SMTP id 5b1f17b1804b1-4926686b4c0mr91158765e9.3.1782469115641; Fri, 26 Jun 2026 03:18:35 -0700 (PDT) X-Received: by 2002:a05:600c:3f18:b0:490:c6c2:52 with SMTP id 5b1f17b1804b1-4926686b4c0mr91158325e9.3.1782469115147; Fri, 26 Jun 2026 03:18:35 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 16/45] accel/mshv: add irq_routes to state Date: Fri, 26 Jun 2026 12:17:19 +0200 Message-ID: <20260626101748.1728079-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469183311158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke This change adds fields related to irq routing to the MSHV state, following similar fields in the KVM implementation. So far the fields are only initialized, they will be used in subsequent commits for bookkeeping purposes and storing uncommitted interrupt routes. The TYPE_MSHV_ACCEL defines have been moved to the header. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-8-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 7 +++++++ include/system/mshv_int.h | 5 +++++ accel/mshv/irq.c | 10 ++++++++++ accel/mshv/mshv-all.c | 6 ++---- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/include/system/mshv.h b/include/system/mshv.h index 8dd77a76241..1e9bcc1b0b6 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -45,7 +45,13 @@ extern bool mshv_allowed; #define mshv_msi_via_irqfd_enabled() mshv_enabled() #endif =20 +#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv") + typedef struct MshvState MshvState; + +DECLARE_INSTANCE_CHECKER(MshvState, MSHV_STATE, + TYPE_MSHV_ACCEL) + extern MshvState *mshv_state; =20 /* interrupt */ @@ -60,6 +66,7 @@ void mshv_irqchip_release_virq(int virq); int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n, const EventNotifier *rn, int virq); int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int vir= q); +void mshv_init_irq_routing(MshvState *s); =20 /* cpuid */ uint32_t mshv_get_supported_cpuid(uint32_t func, uint32_t idx, int reg); diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 1d9902c9bbe..a0fa9a50f76 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -48,6 +48,11 @@ struct MshvState { int nr_as; MshvAddressSpace *as; int fd; + /* irqchip routing */ + struct mshv_user_irq_table *irq_routes; + int nr_allocated_irq_routes; + unsigned long *used_gsi_bitmap; + unsigned int gsi_count; }; =20 typedef struct MshvMsiControl { diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 3c238c33c33..82f2022c7c3 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -396,3 +396,13 @@ int mshv_reserve_ioapic_msi_routes(int vm_fd) =20 return 0; } + +void mshv_init_irq_routing(MshvState *s) +{ + int gsi_count =3D MSHV_MAX_MSI_ROUTES; + + s->irq_routes =3D g_malloc0(sizeof(*s->irq_routes)); + s->nr_allocated_irq_routes =3D 0; + s->gsi_count =3D gsi_count; + s->used_gsi_bitmap =3D bitmap_new(gsi_count); +} diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index a6263effa41..2ed3ef4b841 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -43,10 +43,6 @@ #include #include =20 -#define TYPE_MSHV_ACCEL ACCEL_CLASS_NAME("mshv") - -DECLARE_INSTANCE_CHECKER(MshvState, MSHV_STATE, TYPE_MSHV_ACCEL) - bool mshv_allowed; =20 MshvState *mshv_state; @@ -536,6 +532,8 @@ static int mshv_init(AccelState *as, MachineState *ms) =20 mshv_state =3D s; =20 + mshv_init_irq_routing(s); + register_mshv_memory_listener(s, &s->memory_listener, &address_space_m= emory, 0, "mshv-memory"); memory_listener_register(&mshv_io_listener, &address_space_io); --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469399; cv=none; d=zohomail.com; s=zohoarc; b=ce1M9XF0ZOeazGjsBIvGbXjzcbgy+li6iHP2oSidSeMaVGSzMnBpv8h5K1wdeOr7emhVFqKUqBqrGa++3UTKxnpjpIN5ye1pTHza6coiR+gKwh6PcJnWghcqeLXnF9RB9TAhu5xb3Ipb1+o6QcR7WYy5UKlhnTh5dz2FGqtqjeI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469399; 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=mhiC52oMwva++W28QseFLMsKqB/LHrv1Okp1RGXU2gI=; b=WJZTHQwxvLykSgDXr8NXrNcAhgw/ID4CvTMegk3LcFQyCGNi3E2hZhFyoHTnyKYvp5AXIo1YXt8nYPyOH6ENvnUGvR/XWtd2ZhWswyNZtO9U39RdzvikMr3tvWYBBZAAw+SUwnUNz4BhKjqB0zUuh8gbXz94pixEimoUmZV6HX0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469399801446.4579920059939; Fri, 26 Jun 2026 03:23:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eN-0008DB-P1; Fri, 26 Jun 2026 06:19:07 -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 1wd3e2-0007UN-O6 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dz-0005Cy-Bx for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:45 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-U0aWHmHUPFODR76_zNbZPA-1; Fri, 26 Jun 2026 06:18:39 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4924207e640so5998235e9.3 for ; Fri, 26 Jun 2026 03:18:39 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fe949csm79304185e9.5.2026.06.26.03.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mhiC52oMwva++W28QseFLMsKqB/LHrv1Okp1RGXU2gI=; b=DrnhxLCEUm15/gzHrokWu84sZL730NiW07MT5fTmh+TdI7MXUehvg1xBAxELLQ8Hlacu6D p/LLuhR9PeroMnQT+DJhdT8H82CTOSfadIG2Xb2P0xshGSSUfZjyI3MEPH4h+/XHVdKgt8 KsKgzpLR1onAX8lWN7rtnK4T2VXV+jQ= X-MC-Unique: U0aWHmHUPFODR76_zNbZPA-1 X-Mimecast-MFC-AGG-ID: U0aWHmHUPFODR76_zNbZPA_1782469118 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469118; x=1783073918; 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; bh=mhiC52oMwva++W28QseFLMsKqB/LHrv1Okp1RGXU2gI=; b=e+AjS5deDWKtzn0uVuCQQRc+xH7JqaT/NWYKlqT6fqLn0Q24/O0vJSea34KSYVKHWU EXl51Td8g2XyktaiH+pWj9TxFEDg2RrEq4LQRYoYvIWiP82mU7ZJQPLm9HvoUzLB0ejf 1iQT0d3VK+xGn0gQ91dflSwoAzuSzj3gRHCljqzWIW5FUkDYe5zO/GKfyqJoK9K8rSAU 43nwEYXAg96TpneZ1ghInEA7CO7LpVV46VAAUvYsZIFxffqyYJLbTGPbEi1tOhCJKhOv iAQkSJv/lflGnddp+GHoU96O36Xs4xQhkAmb+A8+sx8W3fidZJQjSsZRjYkD4oeygBJa at0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469118; x=1783073918; 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; bh=mhiC52oMwva++W28QseFLMsKqB/LHrv1Okp1RGXU2gI=; b=lh44vD9JJ/7Ia2KLiVk+RMvRYl3obKrgC1uMjPQay2jsT/mRsqQ7DrLw81FrTN8ejq KG5Uw/KzGHIJkizEu1cy9j8JtHUTMohzz6BZO7RA1zKuC2hoWRhhXRR9rIE0fq7Rwn3Z zSiybqMuBkiXubbr/lvFkKqfN0jLADrk4r0b5fNuQYkbvRKeSgg35TCgIQnS1k9rKu9t EUKNn5CA8hVKVjib4UvIRSzS8/z1oBZR6Kqekw2j1uVVXDHhyONe43FBheYS/7HPPlgH rsJCCHbDT7QyBwVSIN5zz+jlK+5NGZukrZPRK6lfJTr1r3d5NEK2DvkAxs2gJkaj6L4u QLBg== X-Gm-Message-State: AOJu0YzLrLRLd6XUwZcQ/3/HxQVrtUUTKHgBoPlQG11vK5/5WT95CFDF 1R3qXt209dL+4cdpMaQzlYMYq26U7ww64ef/T4J1WSIYcr/94UKmm5k4BucctYZd6iuTV+r0nEa MYMNr3SXRIYgZfurT0HD6jGFVww/yL7ABPY7LpuoIUr7ZZsWE+4wKo9fGeRMR5P4lgXtLKmjJPY h9ewUmcxDy7XWZvslXrDROcpaGmLwVsXN4WycZWIXI X-Gm-Gg: AfdE7cm3ze2z8XDHJoDXLOPe+p0mrdOObYESjzr2IZbbIy1MOJWIZW427+fCgWuO4KU aetRf9KyD0fmrB8tHTXqdbWBsyeGOVmGv9kCe9jS8vlCROMMpvYwwruU1H3hNAam2+NuY48b151 AsJsKLGIE/COXplhfr3VrwthF+8+XrbF2FeXofxvTnwrl1GKLUy4kmBfDBd5Lo2TPThZ2wgqOkw KQgCYZGKicy8kTRPT/vTfH3xDADXalWC0cf/yUUeSChpJzvUlaFoLZhPw9YNj5hTW07PoCLUHEf DSlM5xoZp6RfdxuKSS0J0SYu3e0zD+lFHd2mHjR6wyrBxE9F3kQvMBpSJvU/aAzcw+JJJHINZZ6 f4VRzloIlS/WNCkKxCicNUIXcx1JPuVc5AHdSMiTmBBAqx0iyZn3iG76rm/NSXxnTNIcdfuEtNf JavlerkRIJ7fSILmDY X-Received: by 2002:a05:600c:a05:b0:492:2c87:3d4b with SMTP id 5b1f17b1804b1-4926fc3a645mr2130865e9.12.1782469118265; Fri, 26 Jun 2026 03:18:38 -0700 (PDT) X-Received: by 2002:a05:600c:a05:b0:492:2c87:3d4b with SMTP id 5b1f17b1804b1-4926fc3a645mr2130295e9.12.1782469117813; Fri, 26 Jun 2026 03:18:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 17/45] accel/mshv: update s->irq_routes in add_msi_route Date: Fri, 26 Jun 2026 12:17:20 +0200 Message-ID: <20260626101748.1728079-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469400644158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke The irq_routes field of the state is populated with native mshv irq route entries. The allocation logic is modelled after the KVM implementation: we will always allocate a minumum of 64 entries and use a bitmask to find/set/clear GSIs. The old implementation of add_msi_routes will be removed in a subsequent commit. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-9-magnuskulke@linux.mic= rosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 3 +- accel/accel-irq.c | 2 +- accel/mshv/irq.c | 89 +++++++++++++++++++++++++++++++++++++---- accel/stubs/mshv-stub.c | 2 +- 4 files changed, 85 insertions(+), 11 deletions(-) diff --git a/include/system/mshv.h b/include/system/mshv.h index 1e9bcc1b0b6..d22f82982d0 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -33,6 +33,7 @@ #endif =20 #define MSHV_MAX_MSI_ROUTES 4096 +#define MSHV_MIN_ALLOCATED_MSI_ROUTES 64 =20 #define MSHV_PAGE_SHIFT 12 =20 @@ -59,7 +60,7 @@ int mshv_request_interrupt(MshvState *mshv_state, uint32_= t interrupt_type, uint3 uint32_t vp_index, bool logical_destination_mod= e, bool level_triggered); =20 -int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev); +int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice = *dev); int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev= ); void mshv_irqchip_commit_routes(void); void mshv_irqchip_release_virq(int virq); diff --git a/accel/accel-irq.c b/accel/accel-irq.c index 7e71b525557..5a97a345b23 100644 --- a/accel/accel-irq.c +++ b/accel/accel-irq.c @@ -21,7 +21,7 @@ int accel_irqchip_add_msi_route(AccelRouteChange *c, int = vector, PCIDevice *dev) { #ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { - return mshv_irqchip_add_msi_route(vector, dev); + return mshv_irqchip_add_msi_route(c, vector, dev); } #endif if (kvm_enabled()) { diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 82f2022c7c3..9d6bdde27ac 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -278,18 +278,91 @@ static int irqchip_update_irqfd_notifier_gsi(const Ev= entNotifier *event, return register_irqfd(vm_fd, fd, virq); } =20 - -int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev) +static int irqchip_allocate_gsi(MshvState *s, int *gsi) { - MSIMessage msg =3D { 0, 0 }; - int virq =3D 0; + int next_gsi; =20 - if (pci_available && dev) { - msg =3D pci_get_msi_message(dev, vector); - virq =3D add_msi_routing(msg.address, le32_to_cpu(msg.data)); + /* Return the lowest unused GSI in the bitmap */ + next_gsi =3D find_first_zero_bit(s->used_gsi_bitmap, s->gsi_count); + if (next_gsi >=3D s->gsi_count) { + return -ENOSPC; } =20 - return virq; + *gsi =3D next_gsi; + + return 0; +} + +static void irqchip_release_gsi(MshvState *s, int gsi) +{ + clear_bit(gsi, s->used_gsi_bitmap); +} + +static void add_routing_entry(MshvState *s, struct mshv_user_irq_entry *en= try) +{ + struct mshv_user_irq_entry *new; + int n, size; + + if (s->irq_routes->nr =3D=3D s->nr_allocated_irq_routes) { + n =3D s->nr_allocated_irq_routes * 2; + if (n < MSHV_MIN_ALLOCATED_MSI_ROUTES) { + n =3D MSHV_MIN_ALLOCATED_MSI_ROUTES; + } + size =3D sizeof(struct mshv_user_irq_table); + size +=3D n * sizeof(*new); + s->irq_routes =3D g_realloc(s->irq_routes, size); + s->nr_allocated_irq_routes =3D n; + } + + n =3D s->irq_routes->nr; + s->irq_routes->nr++; + new =3D &s->irq_routes->entries[n]; + + *new =3D *entry; + + set_bit(entry->gsi, s->used_gsi_bitmap); + + trace_mshv_add_msi_routing(entry->address_lo | entry->address_hi, + entry->data); +} + +int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice = *dev) +{ + struct mshv_user_irq_entry entry =3D { 0 }; + MSIMessage msg =3D { 0 }; + uint32_t data, high_addr, low_addr; + int gsi, ret; + MshvState *s =3D MSHV_STATE(c->accel); + + if (!pci_available || !dev) { + return 0; + } + + msg =3D pci_get_msi_message(dev, vector); + + ret =3D irqchip_allocate_gsi(mshv_state, &gsi); + if (ret < 0) { + error_report("Could not allocate GSI for MSI route"); + return -1; + } + high_addr =3D msg.address >> 32; + low_addr =3D msg.address & 0xFFFFFFFF; + data =3D le32_to_cpu(msg.data); + + entry.gsi =3D gsi; + entry.address_hi =3D high_addr; + entry.address_lo =3D low_addr; + entry.data =3D data; + + if (s->irq_routes->nr < s->gsi_count) { + add_routing_entry(s, &entry); + c->changes++; + } else { + irqchip_release_gsi(s, gsi); + return -ENOSPC; + } + + return gsi; } =20 void mshv_irqchip_release_virq(int virq) diff --git a/accel/stubs/mshv-stub.c b/accel/stubs/mshv-stub.c index e499b199d9d..998c9e2fc6c 100644 --- a/accel/stubs/mshv-stub.c +++ b/accel/stubs/mshv-stub.c @@ -14,7 +14,7 @@ =20 bool mshv_allowed; =20 -int mshv_irqchip_add_msi_route(int vector, PCIDevice *dev) +int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice = *dev) { return -ENOSYS; } --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469373; cv=none; d=zohomail.com; s=zohoarc; b=QEMLwwQ7MZPuDsjDXyfePM5Qh9Wc+yt+/5oTwK86fQNM6hXZrPlm4eo3R4crKkapSK50lHrQu0Y7wtzGnZI0Pde2UghcEp3/w/iKEVUAhkpgP0NnU/hwwnhRdUMQThtH7+Saxqlb4ArnxGu7A9BXsrsIOGaLZYqkXdPOU/uLcT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469373; 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=vGBTAmxVNFMohgUHn4BgV598/C/xE9KDsqsNliQz3JU=; b=XzQBaVOhFU9FBPlyyPdfuzi3d2MBGjGAXcPhM9fzycBF/ND6YXQzD7uZMeglm7F1IPjNXGtYC2abllcpezL7ybjaMGkIVh8stnGbc7gxWTMC0lUMIHfgtRpzcnjJLRZ/vkWJ1joLpBiN8u1oXc7SvpvknSrvuviaDWiox1IUnuI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469373646367.8200958862625; Fri, 26 Jun 2026 03:22:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eM-00083W-Dx; Fri, 26 Jun 2026 06:19:06 -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 1wd3e2-0007UM-Nd for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3dz-0005D9-D6 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:45 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-UgqN0ma4O-e8-rbYqJ4MmA-1; Fri, 26 Jun 2026 06:18:41 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4926fa2cb17so464855e9.1 for ; Fri, 26 Jun 2026 03:18:41 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fcee16sm74119075e9.2.2026.06.26.03.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469122; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vGBTAmxVNFMohgUHn4BgV598/C/xE9KDsqsNliQz3JU=; b=a1WIBnBzwyBqmmJoZrCZRBT88+hOqd7DslaPujhRDW2ZowY+HOOcUA84YHMKHkMb/xM7jY aH1XabkeXHrvMsFZXQq05s1ACq7zMN1qMoUjeMFV8RCfLbHRu8QOkfqqf2bRkqdmFmoSMq VRT7yTky/t4CRZ8BRhppe634pxWzoyg= X-MC-Unique: UgqN0ma4O-e8-rbYqJ4MmA-1 X-Mimecast-MFC-AGG-ID: UgqN0ma4O-e8-rbYqJ4MmA_1782469120 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469120; x=1783073920; 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; bh=vGBTAmxVNFMohgUHn4BgV598/C/xE9KDsqsNliQz3JU=; b=SOZOxtOW7RQjlWomW5cf/vMyLGYfoHTpQaAwvpCvz440DERC8TmlMksaKMAgnFnhru 5iUB2JiTirRHSRh8rnTkPo0+AmwrUAXoDTFdWAvJcSlAFHR/dvlAFT+xhOOW2e+R9wA8 GRBj883tqaglXClk6DvlWH1mj3e/1ql7b68gjZl7JZFPiUVwuHApNp3w0JP9LJA9sU32 L67vwdVWYYRS2ZHprJr65mz6dY4MJUBg8Y+ajpiL5smI5lY6esJYJ7CRJNyPlMB7Ys01 U7N6wHgGLTFtJz554ACMS6tcjeQ8Ejd4j3CgfOni6hs4BGMaBy1uSTWsG+k8pnFesozh xJig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469120; x=1783073920; 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; bh=vGBTAmxVNFMohgUHn4BgV598/C/xE9KDsqsNliQz3JU=; b=tGR7+SxBTUK7Se8GNf+tHtNIBvQogLpZF/i9ZREqBDCwHFq6nmXr2hslTYy76kYR4p VIB88ENKA8Vrf3GiVX4JC0oUOgfqJ8WFqDMV34BoccJN69yw6gp/Mrc3RMFt1IyR2ppa EAgUhlmuWbVfd9Gw1pIrUBxW/g2g6itjfK+pmbjIeQwS7leclVgXCMV7USpXIizmudEH JA5K0+jrrtRkpbIJPMURG8QeD2X0oyrXgGw9F5my06DlBWB1SDsKc8IDT9hCT7yuVkLN v4viupwLzHyu4CuL5/PXqp7fFskNAYjBorn+zf3+Nws9siiOrzuzTNjprdhjnTLuRaEy Oy0A== X-Gm-Message-State: AOJu0YzQLgYnpl+8UZy+tZP5FBFItFY47uUe0I7iEl9Oi3J3CXxT28iD O9BEUvbMP/JFPcTfJhTkoIOTiRDCMHWm8eLfHfMvnOI91Hw76PIfKXUB/8S6Vsub9KEfyhw9J5M 08HBhcG4UaKSBgJQpF/H56HDdMv/MQmpCTVuWm+0cDwGpUJvAo7oEDmaURD8UdqFfYSzesTCkXx LxvPBjyNXYxGpe51IQBLBZLItmLfPNmulRN94Cv0zB X-Gm-Gg: AfdE7ckCktHwonXwiUqWjp4+kVlxODv5Dgia88WaUN+q0SLyq51qEFqZCdyeiqroX2Z qvLmVhmzaUNTEh3yTXU4J1Z477zSy5BX+wPDRQjHCi18FpUISk0U67eBCWZnpBx4ZCGe9CG4CXX c8BxXAhqb5IN+uLY9URlWiOCeGmtU/3UIF/yn+D/pwg4oMHwT3JUazoS2Sxi+gQKtAxnW4iSfuo L9s47pVLGIQ2njKX2M3fYWaqEQ1eNQX9g2nVjd0grPj9zjRjJjo/mLxL09f+buVk2WecLaWDvcU OLdNWGUaNNN1fZhbAP1bv2k4DvjOdUqM/X5sVFexxj4plv/UQNCUYPcir5RnNjMm7ny3NJjAQ7V JicGbZirBUpxkbzt3qqDy2qH7INEfDSz3O4gytj99eo+YpABGLDGT9mjJwB4mcI8xjugZK1FHic UWW07rlaNi//W7034y X-Received: by 2002:a05:600c:1551:b0:490:3cf0:8d81 with SMTP id 5b1f17b1804b1-492664241a4mr79272165e9.13.1782469120062; Fri, 26 Jun 2026 03:18:40 -0700 (PDT) X-Received: by 2002:a05:600c:1551:b0:490:3cf0:8d81 with SMTP id 5b1f17b1804b1-492664241a4mr79271685e9.13.1782469119488; Fri, 26 Jun 2026 03:18:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 18/45] accel/mshv: update s->irq_routes in update_msi_route Date: Fri, 26 Jun 2026 12:17:21 +0200 Message-ID: <20260626101748.1728079-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469374438158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke The state's irq_routes field will be updated when an irqchip's gsi is requested to be updated with a new dest/vector. The old set_msi_routing() fn is redundant and can be removed. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-10-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- accel/mshv/irq.c | 87 +++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 49 deletions(-) diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 9d6bdde27ac..b5a047b3672 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -36,52 +36,6 @@ void mshv_init_msicontrol(void) msi_control->updated =3D false; } =20 -static int set_msi_routing(uint32_t gsi, uint64_t addr, uint32_t data) -{ - struct mshv_user_irq_entry *entry; - uint32_t high_addr =3D addr >> 32; - uint32_t low_addr =3D addr & 0xFFFFFFFF; - GHashTable *gsi_routes; - - trace_mshv_set_msi_routing(gsi, addr, data); - - if (gsi >=3D MSHV_MAX_MSI_ROUTES) { - error_report("gsi >=3D MSHV_MAX_MSI_ROUTES"); - return -1; - } - - assert(msi_control); - - WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { - gsi_routes =3D msi_control->gsi_routes; - entry =3D g_hash_table_lookup(gsi_routes, GINT_TO_POINTER(gsi)); - - if (entry - && entry->address_hi =3D=3D high_addr - && entry->address_lo =3D=3D low_addr - && entry->data =3D=3D data) - { - /* nothing to update */ - return 0; - } - - /* free old entry */ - g_free(entry); - - /* create new entry */ - entry =3D g_new0(struct mshv_user_irq_entry, 1); - entry->gsi =3D gsi; - entry->address_hi =3D high_addr; - entry->address_lo =3D low_addr; - entry->data =3D data; - - g_hash_table_insert(gsi_routes, GINT_TO_POINTER(gsi), entry); - msi_control->updated =3D true; - } - - return 0; -} - static int add_msi_routing(uint64_t addr, uint32_t data) { struct mshv_user_irq_entry *route_entry; @@ -370,16 +324,51 @@ void mshv_irqchip_release_virq(int virq) remove_msi_routing(virq); } =20 +static int update_routing_entry(MshvState *s, + struct mshv_user_irq_entry *new_entry) +{ + struct mshv_user_irq_entry *entry; + int n; + + for (n =3D 0; n < s->irq_routes->nr; n++) { + entry =3D &s->irq_routes->entries[n]; + if (entry->gsi !=3D new_entry->gsi) { + continue; + } + + if (!memcmp(entry, new_entry, sizeof *entry)) { + return 0; + } + + *entry =3D *new_entry; + + return 0; + } + + return -ESRCH; +} + int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev) { + uint32_t addr_hi =3D msg.address >> 32; + uint32_t addr_lo =3D msg.address & 0xFFFFFFFF; + uint32_t data =3D le32_to_cpu(msg.data); + struct mshv_user_irq_entry entry =3D { + .gsi =3D virq, + .address_hi =3D addr_hi, + .address_lo =3D addr_lo, + .data =3D data, + }; int ret; =20 - ret =3D set_msi_routing(virq, msg.address, le32_to_cpu(msg.data)); + ret =3D update_routing_entry(mshv_state, &entry); if (ret < 0) { - error_report("Failed to set msi routing"); - return -1; + error_report("Failed to set msi routing for gsi %d", virq); + abort(); } =20 + trace_mshv_set_msi_routing(virq, msg.address, data); + return 0; } =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469398; cv=none; d=zohomail.com; s=zohoarc; b=Nmp3xmRHAH0flbABVXVu/4RJA+D/VBtVMFDTTd5vnCpeeDROn2dJrZ7e3CbDMr4CnDOql8vFiA1AKGPaI3z/kijTuxMid001kYofAtiiaILWE4SZEvT4Rx1tiMuVH4VCaS63SFRYpqCDqmsmIiIy6PHNOXIMmtm1ueX72BzSvqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469398; 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=OWP9XDpj+EGYpU1Ify8+MzQOA8NeeXt9VeHs8FaCu1A=; b=fOlx+CiEhtQDNQLPIgshq6HwcgSRX5sXb0WV3uVq6W1aecoKZhDTjB9v6t8zyGaiAHKjrxWyNTeTAGIMfeI/N4mx/wavZGNTcNfaYI8J5OXvbJWOYViFoZ3U+o+ZIcen74kbR5Mqksx2DpjPD7mWH+hk9Urflej6PzGIYyIF7bU= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469398229187.6456152376686; Fri, 26 Jun 2026 03:23:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eP-0008OD-Ev; Fri, 26 Jun 2026 06:19:09 -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 1wd3e5-0007Zd-6X for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3e3-0005E5-Cl for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:48 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-688-zQeLGFxNOJiKtKWCoQ4n7w-1; Fri, 26 Jun 2026 06:18:45 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-46f48f2d9cbso238383f8f.2 for ; Fri, 26 Jun 2026 03:18:44 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c9f240c3dsm22417257f8f.35.2026.06.26.03.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469126; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OWP9XDpj+EGYpU1Ify8+MzQOA8NeeXt9VeHs8FaCu1A=; b=Qw4vCGd9DsAwgfmLzb72PGasNc/4pdcxrmXXxa5h10LMcjEwO8lqZgJ5de6PANUBm/j+Gr V7l8ZPaGLPgZ7mdM80XKCy1vrkvUXeordWTcTu2UbGHjljQN7KOYksdDdunRg68j/ckAZq HmchBfxX72lVEBfgmMN4vOLvRVRIyV0= X-MC-Unique: zQeLGFxNOJiKtKWCoQ4n7w-1 X-Mimecast-MFC-AGG-ID: zQeLGFxNOJiKtKWCoQ4n7w_1782469124 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469124; x=1783073924; 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; bh=OWP9XDpj+EGYpU1Ify8+MzQOA8NeeXt9VeHs8FaCu1A=; b=GGFA1H049JyFpKJ4bxYhvlAKUWpmgtlce/+q4cEOQQijXnzYQ0svCyfyka6yUr1kmM BcCnh28LMMWvhydtsP1kXcOCgZx7pwFM3lpuw9CZwG6nFoiFQhnZxksGfMS6YqWekJ/Z Mc5bGh4uyU9JfErotXb1SecaVN8v8of9RPf8/OZp7itHZ2d9HtqUMo7sbCsx0+Raui8h sbAiqOqqqqGjO8/JgshYbj565mAvyIePjcSqD/c4LIslBrhRBqykNO3ufe/ZUslZlOHo Oi4kz2VKJaRng8tAZfPy1VaQB8OCvcKP2LAs3LjRFlCPQ+bInWTU3alRHeHf8JpvPqJZ opFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469124; x=1783073924; 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; bh=OWP9XDpj+EGYpU1Ify8+MzQOA8NeeXt9VeHs8FaCu1A=; b=GtY8+IO2NstJMt0rkMq7vg647XNunT9H5rHfswDnIQ3CF82HNh8YfSZ+zuKUHZDesR DYkBHZhzxf3KK2GIQ7Q2EDo/Osquvw5eq2TB73pIsgfPV6wGX4wU03N3iWsfb/3g6v1B atMSYoJh3ewegKNl0gzt8VsLSefslXR1v+rDzZVuqw1OkpfePg+hektdhdcDHAzMJ5P0 7PnW+ksWXWu3CEc0QUPJ3IMpsFxPFPyzgWh+17Be2pLkkcAv67CLX5i/XxqIubMwQ95R C4fELaBMA2B8dbRUP/0nkcUozdI3bM5BVcH02xqATkVR7H3TP/uHTuixKx2etWKXP3YB JL1g== X-Gm-Message-State: AOJu0YxiLwcfQZNHkYxeMiDW1evSnx2pvxvCZXM7kunftGnHe2U6Y/Th mQ+I7Exbz+qbw5Dp9CIrD1Nf+3xQrd+0zEHNfTkaxxTvipp/LNHSkleNM8uKCkkwxfOytjlOerx tEvIiKCY38cRwqsPsGIuAEMne8eb5AuAwcMbJNjqjo/EwuO4Xa5sE24APy2HwVW2OYMOE9i0pAI Q1EP0bvV2MJIhxEerOqo5Q15RAr6RbVaxs2G9fBT9v X-Gm-Gg: AfdE7cnjzgp3GntLjXrEcoU/ZFg8gMokPnceQMPumX4HzWZE8+IkCeD+O6gNGopqo0d NNRfWytBF/xUU7pmtoXdiU06Sl/2TX2XgirioL082u1ndsJ7DSRk/dIwiqEcI08uyZf27bP18Wh fqFaugcJQ+ZX6gWheCWtXfivARp+zFydpgs72cJiAea9bAUGxffwkrK1aejVKqKvC4i8ImPJpbi s0cZ1JrImQsCtOfdx26VE0TUiV+Kj1afVndXFNMHz9EbtdUmKA7Pob8YI4/VEJmSvoE079SCO2U evT1JeEZjgAv8OvJ0cDuoYjxKSf0ft+Q5QEW9XQjr6yi7susHHRd+0hRRY8qL410xrpXU6j193N NCMRLwtj2A+W9F0J3KsG0cOZnEeG++QN05O4y10dYB3oKOsHxBdgV4kkLqmXTxWlkaaBLRtHh/j 46eneVlhLQ7GPF5GgX X-Received: by 2002:a05:600d:6447:20b0:492:259d:567 with SMTP id 5b1f17b1804b1-4926689869amr70885165e9.23.1782469123854; Fri, 26 Jun 2026 03:18:43 -0700 (PDT) X-Received: by 2002:a05:600d:6447:20b0:492:259d:567 with SMTP id 5b1f17b1804b1-4926689869amr70884695e9.23.1782469123325; Fri, 26 Jun 2026 03:18:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 19/45] accel/mshv: update s->irq_routes in release_virq Date: Fri, 26 Jun 2026 12:17:22 +0200 Message-ID: <20260626101748.1728079-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469398539158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke The state's irq_routes field will be updated when an irqchip's gsi is requested to be released. The old remove_msi_routing() fn is redundant and can be removed. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-11-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 2 +- accel/accel-irq.c | 2 +- accel/mshv/irq.c | 43 ++++++++++++++--------------------------- accel/stubs/mshv-stub.c | 2 +- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/include/system/mshv.h b/include/system/mshv.h index d22f82982d0..fa716c1ee97 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -63,7 +63,7 @@ int mshv_request_interrupt(MshvState *mshv_state, uint32_= t interrupt_type, uint3 int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice = *dev); int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev= ); void mshv_irqchip_commit_routes(void); -void mshv_irqchip_release_virq(int virq); +void mshv_irqchip_release_virq(MshvState *s, int virq); int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n, const EventNotifier *rn, int virq); int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int vir= q); diff --git a/accel/accel-irq.c b/accel/accel-irq.c index 5a97a345b23..0cb3ef78d3a 100644 --- a/accel/accel-irq.c +++ b/accel/accel-irq.c @@ -67,7 +67,7 @@ void accel_irqchip_release_virq(int virq) { #ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { - mshv_irqchip_release_virq(virq); + mshv_irqchip_release_virq(mshv_state, virq); } #endif if (kvm_enabled()) { diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index b5a047b3672..990ce346204 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -123,33 +123,6 @@ static int commit_msi_routing_table(int vm_fd) return 0; } =20 -static int remove_msi_routing(uint32_t gsi) -{ - struct mshv_user_irq_entry *route_entry; - GHashTable *gsi_routes; - - trace_mshv_remove_msi_routing(gsi); - - if (gsi >=3D MSHV_MAX_MSI_ROUTES) { - error_report("Invalid GSI: %u", gsi); - return -1; - } - - assert(msi_control); - - WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { - gsi_routes =3D msi_control->gsi_routes; - route_entry =3D g_hash_table_lookup(gsi_routes, GINT_TO_POINTER(gs= i)); - if (route_entry) { - g_hash_table_remove(gsi_routes, GINT_TO_POINTER(gsi)); - g_free(route_entry); - msi_control->updated =3D true; - } - } - - return 0; -} - /* Pass an eventfd which is to be used for injecting interrupts from userl= and */ static int irqfd(int vm_fd, int fd, int resample_fd, uint32_t gsi, uint32_t flags) @@ -319,9 +292,21 @@ int mshv_irqchip_add_msi_route(AccelRouteChange *c, in= t vector, PCIDevice *dev) return gsi; } =20 -void mshv_irqchip_release_virq(int virq) +void mshv_irqchip_release_virq(MshvState *s, int virq) { - remove_msi_routing(virq); + struct mshv_user_irq_entry *e; + int i; + + for (i =3D 0; i < s->irq_routes->nr; i++) { + e =3D &s->irq_routes->entries[i]; + if (e->gsi =3D=3D virq) { + s->irq_routes->nr--; + *e =3D s->irq_routes->entries[s->irq_routes->nr]; + } + } + irqchip_release_gsi(s, virq); + + trace_mshv_remove_msi_routing(virq); } =20 static int update_routing_entry(MshvState *s, diff --git a/accel/stubs/mshv-stub.c b/accel/stubs/mshv-stub.c index 998c9e2fc6c..dadf05511a6 100644 --- a/accel/stubs/mshv-stub.c +++ b/accel/stubs/mshv-stub.c @@ -19,7 +19,7 @@ int mshv_irqchip_add_msi_route(AccelRouteChange *c, int v= ector, PCIDevice *dev) return -ENOSYS; } =20 -void mshv_irqchip_release_virq(int virq) +void mshv_irqchip_release_virq(MshvState *s, int virq) { } =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469169; cv=none; d=zohomail.com; s=zohoarc; b=iBbNJIJ1VXGH/3e5xMatfhD7EI64PmYzveohu8/GKaou/8Vykt7nZtfKG4OevKuawzjrh9Ya40fMMJHQSQbVdnnq1psXlfgxjnWLGf2UEPXYMtHK4u0o8GXxiFcmLg3pYo7YJjnRbFNzxexj5OTgEf248su/2z7VP1mMtnqQs4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469169; 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=snBBnAie5esZAHoCWC4JMDNV1oLlXJBK6vDWPhbHwtI=; b=YuV+tpp/XSxKm2I+q/OaqWJJu95u9Nx9t5+VnHW7IYLVjYtdFCrH961I88f0j3yc6KSr1NHpLeVdXJX9OW8rZrLmNfmO32UHJkixoRSrLBJc74G6dGTXqDYY07CAXXuZghthrxzYh+GO+ZneQc7JWEeOBFPXCDX5IuUHy55nZe0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469169707533.350527887452; Fri, 26 Jun 2026 03:19:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eU-0000VB-Kj; Fri, 26 Jun 2026 06:19:14 -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 1wd3e6-0007bp-5L for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3e4-0005EQ-KL for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:49 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-NaUPYyEDN_eV9VnyZYKpZA-1; Fri, 26 Jun 2026 06:18:46 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-46e18156b61so730532f8f.1 for ; Fri, 26 Jun 2026 03:18:46 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268ffe204sm69088185e9.7.2026.06.26.03.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469128; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=snBBnAie5esZAHoCWC4JMDNV1oLlXJBK6vDWPhbHwtI=; b=ePZEp6m8fInDn+NN1ewdoYDrLiaJpbqXe74nRjiLcYzNPboSBinStDPzqcOBJLEu8A0gUQ JIC+FiQQo3tl/XxPtyDs+Rc+2V6MBM5Kjh7eZPe4mI71mbMlIAVgIsW1Hv5jCfYLbNn49z 4/s7uSEIU4yaCunaTo99/1xj0PubmVs= X-MC-Unique: NaUPYyEDN_eV9VnyZYKpZA-1 X-Mimecast-MFC-AGG-ID: NaUPYyEDN_eV9VnyZYKpZA_1782469126 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469125; x=1783073925; 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; bh=snBBnAie5esZAHoCWC4JMDNV1oLlXJBK6vDWPhbHwtI=; b=TFwLHtkbrJx1csiH14Bs/6dTgIiJGRQimrqOyX4m3sPVF1gIQ7EY6HN5OLKvSSuLwe Qt6DWtE61zKTmZZ3K3xJhb9ErjLwZcz8FFwLfqsGi8jQqZggUchfB4NIIXgJDciZz7Pp 1sZ7iksVzduINHrfZiujCyAOOtSL+xG9Pt6NPthAT8vb4cwD8NW71gOb16n6UZKJkEZ6 gJWWqJkY8wtN56JRnj5rXfpQ6DV4jGQ9jAkR5xV74JdjoSt6DsAqyCa/fxEkV7+fbrEZ Bln1mHuMmdozeTfq9zysNU5egtdS42EahIQ5hww3cF9pE4IWvJGvGmlm1s05tVROri9I Jg7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469125; x=1783073925; 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; bh=snBBnAie5esZAHoCWC4JMDNV1oLlXJBK6vDWPhbHwtI=; b=WlnE7X2Op+vxHc/56OhG+evbdET+JT+6DEtGKWu86+9uXSzr+bGHrD7VVx7ivpxo1l cvXt5e1I6hDj2S9aq1CnEBhJVR/bKKXpeNzimba54Zrlm/bQlZwLLvvsxThZii5L3SaW ul5hd7JEspMUVQqGKUmldaG778PzS+MXBbXL6YFDIc9vH+xyaLUDt3F1qFCri4TpwxiM DPwnOYe/tgYpoR73OeB3mpQN3lybfEM3dMskTtrZJgTKZZUaLLPRWG+UzD7nf4XWlTB5 JgPlao79zDQAHzTlkgjnRfBmeRjKt55dc7//LgoVtacR7322O8jIUhjBPgrkoJ4njYm4 /RCA== X-Gm-Message-State: AOJu0YwY1cWrHffzqlwHxj/s5UAC0EcI3l/mm55+12x1uaDiPj9II8Nx OZpG5GQpX3nhARcHgMRGLzEXvivQbJIu8SBZPut3llbVPhc2W7DgwDFks5Lw8tTXUHDKvd4f4Xu IVMOl1+goQCusl3eWj8NoilhaPe4UOdq/Zm4mboWzGcHJXZQydsWZfcoJw2v0CYxuBhIdiDvyVW dgWCz9tfM0l0pDqShDtTXPzywbgjDqmKrKDXQ21Oo9 X-Gm-Gg: AfdE7cmQGLapC2s2IPWkQouv8CxGB2cyhbhu4QysHuetI0X44qSZeKCXIVnDNsMHSGe 0JVesL+nXi7dnScPufqNTH2QevtgN8f5uVxFJTO9aIA43vWVPsFJAZa3j3ntHpoICcbnw8rPLyG 7juemLO/HjKmRSoQKCm7gDnnX+BgUxW2W4C7coyiklBtfhTAEzhqzvhQOxBEHddyQvHdV6NQMbg c/XfYrChwQx24BQ58iTaeapA8BwRtXO8LXLDyqXReBFXOjJ4ehTGxJxt6uD4sPJWYetCcEI9cxe DR9hlHvrkwnQCsbABH0fcCk/LFkKA8SuipmftojW6qwjny8KMWk85oqLBqAjRezLCYdssiSAtem Su605/iysnFQpXViCvePehEgxhxERzDyn1SufSWA6HwC952LSMrhOw1tdvWkIVRrctbkBO6ZzG+ j6F/mwTuSMoeKA4eO7 X-Received: by 2002:a05:600c:8b78:b0:492:38c8:c426 with SMTP id 5b1f17b1804b1-49267198492mr82561615e9.13.1782469125521; Fri, 26 Jun 2026 03:18:45 -0700 (PDT) X-Received: by 2002:a05:600c:8b78:b0:492:38c8:c426 with SMTP id 5b1f17b1804b1-49267198492mr82561235e9.13.1782469125034; Fri, 26 Jun 2026 03:18:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 20/45] accel/mshv: use s->irq_routes in commit_routes Date: Fri, 26 Jun 2026 12:17:23 +0200 Message-ID: <20260626101748.1728079-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469171242158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke In mshv_irqchip_commit_routes() the entries that have been accumulated in s->irq_routes are committed directly to MSHV's irqchip. The old commit_msi_routing_table() fn will be removed in a subsquent commit. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-12-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv.h | 2 +- accel/accel-irq.c | 2 +- accel/mshv/irq.c | 7 ++++--- accel/stubs/mshv-stub.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/system/mshv.h b/include/system/mshv.h index fa716c1ee97..46fe3fcebc2 100644 --- a/include/system/mshv.h +++ b/include/system/mshv.h @@ -62,8 +62,8 @@ int mshv_request_interrupt(MshvState *mshv_state, uint32_= t interrupt_type, uint3 =20 int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice = *dev); int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev= ); -void mshv_irqchip_commit_routes(void); void mshv_irqchip_release_virq(MshvState *s, int virq); +void mshv_irqchip_commit_routes(MshvState *s); int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *n, const EventNotifier *rn, int virq); int mshv_irqchip_remove_irqfd_notifier_gsi(const EventNotifier *n, int vir= q); diff --git a/accel/accel-irq.c b/accel/accel-irq.c index 0cb3ef78d3a..4303e10e408 100644 --- a/accel/accel-irq.c +++ b/accel/accel-irq.c @@ -55,7 +55,7 @@ void accel_irqchip_commit_routes(void) { #ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { - mshv_irqchip_commit_routes(); + mshv_irqchip_commit_routes(mshv_state); } #endif if (kvm_enabled()) { diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 990ce346204..9ba837f0e2e 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -394,16 +394,17 @@ int mshv_request_interrupt(MshvState *mshv_state, uin= t32_t interrupt_type, uint3 return 0; } =20 -void mshv_irqchip_commit_routes(void) +void mshv_irqchip_commit_routes(MshvState *s) { int ret; - int vm_fd =3D mshv_state->vm; + int vm_fd =3D s->vm; =20 - ret =3D commit_msi_routing_table(vm_fd); + ret =3D ioctl(vm_fd, MSHV_SET_MSI_ROUTING, s->irq_routes); if (ret < 0) { error_report("Failed to commit msi routing table"); abort(); } + trace_mshv_commit_msi_routing_table(vm_fd, s->irq_routes->nr); } =20 int mshv_irqchip_add_irqfd_notifier_gsi(const EventNotifier *event, diff --git a/accel/stubs/mshv-stub.c b/accel/stubs/mshv-stub.c index dadf05511a6..8b69539a85a 100644 --- a/accel/stubs/mshv-stub.c +++ b/accel/stubs/mshv-stub.c @@ -28,7 +28,7 @@ int mshv_irqchip_update_msi_route(int virq, MSIMessage ms= g, PCIDevice *dev) return -ENOSYS; } =20 -void mshv_irqchip_commit_routes(void) +void mshv_irqchip_commit_routes(MshvState *s) { } =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469177; cv=none; d=zohomail.com; s=zohoarc; b=IlShRpYuOf2lzyGXEvSkwQvT3T1+rUMdRtmApvgzSYBgnI0ZAIRul0TLZZ3nzwAhxjsIVjcH7adlrmN/+A+FWubobFPQLY7NBCuOBk6ZGRV8BfeCWamvPHePkp+Za/IXV/eqxx3xT19eKsud31i4BIGYXHLS6ETfG4v/yR4x/7s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469177; 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=6CzWwZ3dSbLJuGwdtwknO1r7WLWkHJidTJ1w1I1/ImI=; b=QlakWW7UYuQGyqlfFquhRzj+X2VXgjwB0kJ97Lbdwd2Fb01aReTzAFHLqrjVQK+5lrScGYoHy4pDBAYLyhyK2fSS5iAt+4O7wuLl7cHLkDcfbx12JZmm+Bk9jW81wB+yMIacKYMx5rgzVRJEUUP7IgbQDvd1QC5qpjdm/1f+HJI= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469177247604.4860211691837; Fri, 26 Jun 2026 03:19:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eU-0000Uu-IQ; Fri, 26 Jun 2026 06:19:14 -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 1wd3eC-0007iR-Kz for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eA-0005ID-OR for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:56 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-178-l3zoOEJiMpe3s2R2Ct8EYw-1; Fri, 26 Jun 2026 06:18:50 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490ab3f6e55so3791655e9.0 for ; Fri, 26 Jun 2026 03:18:50 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4926c02081bsm33033005e9.0.2026.06.26.03.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6CzWwZ3dSbLJuGwdtwknO1r7WLWkHJidTJ1w1I1/ImI=; b=FKOEe/fYs0zo7xDbU7yYFP5ZZWPTwIiTNfpOdQa4NVPuCAUz9fl0fDrrdfq4xuYgPn07qq hyq+VJ7Gg0Tc/k4O8KTe6OYXkxR9ONgNEu+vsO3rZvbVzs39PMxnzUr9BLarZ6Vmrt7Q3L v9/vV11GKm11hbyJfjxmAfzBaOT4ld8= X-MC-Unique: l3zoOEJiMpe3s2R2Ct8EYw-1 X-Mimecast-MFC-AGG-ID: l3zoOEJiMpe3s2R2Ct8EYw_1782469130 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469129; x=1783073929; 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; bh=6CzWwZ3dSbLJuGwdtwknO1r7WLWkHJidTJ1w1I1/ImI=; b=RLG23Zmj32wKpb88xyH0DsFtvyV2ewg73AKCjhLvfDNOkwkJOG9XT1TepUBSyctJfo Wn6YNNmdsIfrJsyyuosFKTIa4n7IbMTcleOyjUkn4Hjb9FQqWTqcZ9eIVU8pwr7gtthN FgWcoCV9tF39WvLKDcnjUIiApNO+Wg0fsT/nnI7E7zxnS0QntIkvlF0tkUNjVS47tpF3 WC4r2+2SeMJrLD37d2MlB+1wZ4yNxuDa3CJVMQCOGdh/vNmHxWzbhWU18vm8JGl5eg1v ipsN3XFLyY1XnGD8SxeahPq8AUvrimWKYgDqR0CwL7zenabPdUzoY+9gf5L0jzl9IjF3 GBPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469129; x=1783073929; 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; bh=6CzWwZ3dSbLJuGwdtwknO1r7WLWkHJidTJ1w1I1/ImI=; b=nn/qxjeHCMyi9YvtZM1hMmRcXs6O+aszL1QOKqXTcAfvsoRlPbU43+O16/ux3/wNha 7vB/yjAKWr2f5kITlqPElzSUsj+SMKMeZUPzkB6rxva1sbM5zQbHpmFsR/uWmE4TsqLN xCqYhHn0drCP6NZWVbfiv354mjbchV5ZpdruFkQNCM7x1DphfilhsiY6ZkKH/b35ojtV gSprSDSVHnk1dDegbLonWNKOOTtsmvd0PBHeGZg1EC+/ChFFr4WqkfEtcLqj9UiLI4Ja 7f9kJRIlvzjHRCiuNmkqlHMjebhRYmyoGePrGfdZuuGwoJxP60sQ5acP5jlgmznDftb0 tIfA== X-Gm-Message-State: AOJu0YwAYo+lWIyRcBN9Q1cRJsA4pS0F9hDpbOJF52pnWKXHODSvFGXP Gk/uPzJRY88F+4GESmRMwbDW76x2xgOE7NPHhdVz3YT9I6O1UhQhjkR64y1SwKuZNtc8RtZFL9h 7gjY0T1au26OqiojOkbydGgAr6QV58qRHHLkazAYplNVSZlzPxqU4OkShxtKByxODfAw84A4I2m 94Ame3FV5QVkfPiuNmrydKoptU0tnQ0zN1Cl8Jw0hn X-Gm-Gg: AfdE7cnbENh5/29YdHqjYeq+MiuC64ytgS4HVQ7j4LHVIUjHHoFw4N/bmACKQu38E58 AFdK/WAE4i+mIGPmpdNcvKGCBwXhJczCPxTYIzzyQ2/gAEGDJnCyJk8rh7wNnpt5CdkSVtRBnVW QEcW1DMDxr6fIElllKa4D7NafauD3KS4XBUF5dmL+fTdlh49Jg6C9tE7F3g0kxU0W6pSPXL8tm2 l5bYyWrNMG6y2k05Qa3Bc/hOUbTRzVxywfc7r0cMV2HWQ9vZcfHS6dv/9Nb+ZvoCdG00sfULlzk K6+nI5GVMqkG7FI1V29V6dqHwGQ9T0/KMe6JfYgAlf04tPH7KuoW/HfOPp0FT5H9nj8cQ8ktIVz CRjPdaptnf8bczpsv1pxhsxepDVfvvLBgKfHNGHoEs3Spy9MLa008RHezgJp6nnch7tT8rpbJId VD3q/D8iNq1mn1nTw1 X-Received: by 2002:a05:600c:4e45:b0:492:6f6f:fa42 with SMTP id 5b1f17b1804b1-4926f6ffa8emr7319445e9.37.1782469129567; Fri, 26 Jun 2026 03:18:49 -0700 (PDT) X-Received: by 2002:a05:600c:4e45:b0:492:6f6f:fa42 with SMTP id 5b1f17b1804b1-4926f6ffa8emr7318835e9.37.1782469129127; Fri, 26 Jun 2026 03:18:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 21/45] accel/mshv: reserve ioapic routes on s->irq_routes Date: Fri, 26 Jun 2026 12:17:24 +0200 Message-ID: <20260626101748.1728079-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469179336158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke We reserve 24 ioapic routes using the new functions that operate on the mshv apic state. commit/add_msi_routing() fn's can be removed now. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-13-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 1 - accel/mshv/irq.c | 115 ++++++-------------------------------- accel/mshv/mshv-all.c | 5 -- 3 files changed, 18 insertions(+), 103 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index a0fa9a50f76..68b84ce2c8d 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -122,6 +122,5 @@ int mshv_configure_msr(const CPUState *cpu, const MshvM= srEntry *msrs, =20 /* interrupt */ void mshv_init_msicontrol(void); -int mshv_reserve_ioapic_msi_routes(int vm_fd); =20 #endif diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 9ba837f0e2e..52b8ac94790 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -36,93 +36,6 @@ void mshv_init_msicontrol(void) msi_control->updated =3D false; } =20 -static int add_msi_routing(uint64_t addr, uint32_t data) -{ - struct mshv_user_irq_entry *route_entry; - uint32_t high_addr =3D addr >> 32; - uint32_t low_addr =3D addr & 0xFFFFFFFF; - int gsi; - GHashTable *gsi_routes; - - trace_mshv_add_msi_routing(addr, data); - - assert(msi_control); - - WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { - /* find an empty slot */ - gsi =3D 0; - gsi_routes =3D msi_control->gsi_routes; - while (gsi < MSHV_MAX_MSI_ROUTES) { - route_entry =3D g_hash_table_lookup(gsi_routes, GINT_TO_POINTE= R(gsi)); - if (!route_entry) { - break; - } - gsi++; - } - if (gsi >=3D MSHV_MAX_MSI_ROUTES) { - error_report("No empty gsi slot available"); - return -1; - } - - /* create new entry */ - route_entry =3D g_new0(struct mshv_user_irq_entry, 1); - route_entry->gsi =3D gsi; - route_entry->address_hi =3D high_addr; - route_entry->address_lo =3D low_addr; - route_entry->data =3D data; - - g_hash_table_insert(gsi_routes, GINT_TO_POINTER(gsi), route_entry); - msi_control->updated =3D true; - } - - return gsi; -} - -static int commit_msi_routing_table(int vm_fd) -{ - guint len; - int i, ret; - size_t table_size; - struct mshv_user_irq_table *table; - GHashTableIter iter; - gpointer key, value; - - assert(msi_control); - - WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { - if (!msi_control->updated) { - /* nothing to update */ - return 0; - } - - /* Calculate the size of the table */ - len =3D g_hash_table_size(msi_control->gsi_routes); - table_size =3D sizeof(struct mshv_user_irq_table) - + len * sizeof(struct mshv_user_irq_entry); - table =3D g_malloc0(table_size); - - g_hash_table_iter_init(&iter, msi_control->gsi_routes); - i =3D 0; - while (g_hash_table_iter_next(&iter, &key, &value)) { - struct mshv_user_irq_entry *entry =3D value; - table->entries[i] =3D *entry; - i++; - } - table->nr =3D i; - - trace_mshv_commit_msi_routing_table(vm_fd, len); - - ret =3D ioctl(vm_fd, MSHV_SET_MSI_ROUTING, table); - g_free(table); - if (ret < 0) { - error_report("Failed to commit msi routing table"); - return -1; - } - msi_control->updated =3D false; - } - return 0; -} - /* Pass an eventfd which is to be used for injecting interrupts from userl= and */ static int irqfd(int vm_fd, int fd, int resample_fd, uint32_t gsi, uint32_t flags) @@ -420,37 +333,45 @@ int mshv_irqchip_remove_irqfd_notifier_gsi(const Even= tNotifier *event, return irqchip_update_irqfd_notifier_gsi(event, NULL, virq, false); } =20 -int mshv_reserve_ioapic_msi_routes(int vm_fd) +static int mshv_reserve_ioapic_msi_routes(MshvState *s) { - int ret, gsi; + int ret, i; + int gsi =3D 0; + struct mshv_user_irq_entry blank_entry =3D { 0 }; =20 /* * Reserve GSI 0-23 for IOAPIC pins, to avoid conflicts of legacy * peripherals with MSI-X devices */ - for (gsi =3D 0; gsi < IOAPIC_NUM_PINS; gsi++) { - ret =3D add_msi_routing(0, 0); + for (i =3D 0; i < IOAPIC_NUM_PINS; i++) { + /* ret =3D add_msi_routing(0, 0); */ + ret =3D irqchip_allocate_gsi(s, &gsi); if (ret < 0) { - error_report("Failed to reserve GSI %d", gsi); + error_report("Failed to reserve GSI %d: %s", gsi, strerror(-re= t)); return -1; } + blank_entry.gsi =3D gsi; + add_routing_entry(s, &blank_entry); } =20 - ret =3D commit_msi_routing_table(vm_fd); - if (ret < 0) { - error_report("Failed to commit reserved IOAPIC MSI routes"); - return -1; - } + mshv_irqchip_commit_routes(s); =20 return 0; } =20 void mshv_init_irq_routing(MshvState *s) { + int ret; int gsi_count =3D MSHV_MAX_MSI_ROUTES; =20 s->irq_routes =3D g_malloc0(sizeof(*s->irq_routes)); s->nr_allocated_irq_routes =3D 0; s->gsi_count =3D gsi_count; s->used_gsi_bitmap =3D bitmap_new(gsi_count); + + ret =3D mshv_reserve_ioapic_msi_routes(s); + if (ret < 0) { + error_report("Failed to reserve IOAPIC MSI routes"); + abort(); + } } diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 2ed3ef4b841..19a44bb13de 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -264,11 +264,6 @@ static int create_vm(int mshv_fd, int *vm_fd) return -1; } =20 - ret =3D mshv_reserve_ioapic_msi_routes(*vm_fd); - if (ret < 0) { - return -1; - } - ret =3D mshv_arch_post_init_vm(*vm_fd); if (ret < 0) { return -1; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469303; cv=none; d=zohomail.com; s=zohoarc; b=c1bmUslJq2ZBEcQJsC+Ae1iry2EPCzhc36KZHTcN+vJ8yY17nVlzcL2t7TmjQBNzfAJMxfDtJritkNUzZIF5blpvQ+SVNxIPm3yXzmG4nS8GMs38MZL27SCkxv8yBfOpaV0/BPuumbn+j58jQO6exSoV9phPEfkGAJbftjwnAOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469303; 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=EUildyp3TUPi9XOxQ9Vei4gm0RWYOEVpQJ4nVR0PZPc=; b=aHOOug9QphRSgicI2dHtNTLguniyJsZAyw+3fbfiShtDpGhnM7VZI6dD7NiySBRjzm3tpJG7fBloAQZKOh6cyEX305EQtSWABMrTArHlleHQDraIaHpnztg3eKAMB5swWLdwguEvYmeDoBdIQpgeVxQv9wBmx7ijZmpZJ1QSFrM= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469303044421.52586096318214; Fri, 26 Jun 2026 03:21:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eO-0008Ir-TX; Fri, 26 Jun 2026 06:19:09 -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 1wd3eC-0007iQ-47 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eA-0005I9-E1 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:55 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-torXdF0YOvyD5SAy-nWG5A-1; Fri, 26 Jun 2026 06:18:52 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490a060eb84so5386355e9.0 for ; Fri, 26 Jun 2026 03:18:52 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49269086ab7sm96886425e9.13.2026.06.26.03.18.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EUildyp3TUPi9XOxQ9Vei4gm0RWYOEVpQJ4nVR0PZPc=; b=GCBZZRpCMIUSyo/SOZiFzdExtmr5IHNy18eyLYnma15VW73Hv+/jfSw0No2bn+DyOctbxU 3r0xz2pCvDwqx4PS3kD6Q8HBdqNv2XykgZjU3oku90o+krSxBUIfjUSpHtryb2cOgeKOey fwLhBg5BIwpwlALVjQKHWT9UdPHf2VA= X-MC-Unique: torXdF0YOvyD5SAy-nWG5A-1 X-Mimecast-MFC-AGG-ID: torXdF0YOvyD5SAy-nWG5A_1782469131 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469131; x=1783073931; 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; bh=EUildyp3TUPi9XOxQ9Vei4gm0RWYOEVpQJ4nVR0PZPc=; b=AisAVjHToxNvyrNWWAn8SXcA3uDZ9B9VNEQR/SB07oi6sQdU1u1oS/gwId7+VD/eag hkacfXwmPY1a93aCIuzoW55g+/0ZhJl2db3OniDV2aj4vGco8HiZP2C34XFfUgAxokeD WJ3jvSUhmILwHNm7cRz0tfB8y2dOmwHWWEmcbVKCjLma/SmKX3q2QNtMFqqfbZVigbO3 VZoZO6ZPd5Y9iB7KP5vpGn6MvOqFxPPmEVl6kfXCkm9cclo/wNQhFBmp3R5R6glmYnVU g22RMxICe2FoW4yhQZ+Zeqy+lU2HobYbfgggoidlymLmZ12njoztOZ5m5MFiI+RVXYJZ G7iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469131; x=1783073931; 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; bh=EUildyp3TUPi9XOxQ9Vei4gm0RWYOEVpQJ4nVR0PZPc=; b=c/aB1MUVJweIBMeQq59ADR8f4BovKJGpc5V1D23eMB1lq+cgEgflmUFqAGjy1Xhhka lxEuyoA/GjAtzHgsM3/1ElnS0w+gRc0n4VEizVlG16D3p9RZiqG6OxCIOr3HDYkAvxCF 9Pheb0Jf/kPGEs5pevcaNJL8oOOwTvMcQzOj/4d9w3d4ZEuH3dbUdU092VxBoY1DWNsY H6WxKbxL2cnmz70VLyvPnV0Z4oBkxXxyUYQbKpYs4qRMB1n2gpNgf5gRkwRUaHZToYSl Ik+j4fuynKuyL0XuiPDXVmbq+vEODfcGGJ68A8qjKSzGqpOgZGGHO0VkVwSH0lHddFoS IDjg== X-Gm-Message-State: AOJu0Yxxcu40U7yUlSsghbu/XIP0T3LLpjbohLJgg6iHWPZEG7pLIAYM L46xz+DEwjQLUj35Pv0hPXe+bKWakWtg+dhT3++wqa7zHZkB1sATAf8RpheAWhWa2kbJI0fiTfT +EDnw2cadfr6ZQk3wFyrh+NuS8CACADqxrt0maVNPj7I0aE8mf74/KQg4uGQfUB7s0wqmi6BKKI Mb4l8GNyFMCGkDlPIE1qgWqi+2k0RqIxA5h2DKEMDt X-Gm-Gg: AfdE7cmboT/NKwknGdLeWZReetHswArtIFLbDbuweRcwuxbCs8IGag3UaMRJupjZfND Gej2wc1ixMKiRzdOd1Oe9X1OSBAQyJ+sJTP05mac4/e+FtnOtTRz3EQIxlMZTF/YFxgXGkuBSuh jFPT1X8tFST3wNU5yTP2z0nLMzFHqseOFvdWwdcpuT22PAu7VCjfPPvQReTrB5cVNID3m1JZbfQ fsHxdDIBiObGEZqM6e32TzBFyhn0d/biHg0c2gmboXOdl1NvgZ4K8rjN+FChKQb8/tH72MYPAz6 5wxjZGbZ13xLC6Jc948LivH7Sk+YP2m2SAygO0RIvbBad5vvikIel1Ezj1/wHo3UqnEYhOweU1a 5P5hWHY/TuAQIAjr9G1u45kpM6e/Z4OtLv+JqbQOWNbLZK/GFe9KzN9HQtzW4uJyt0rvPO4+A4M F9v6L0Ls8SFpw/pYse X-Received: by 2002:a05:600c:1c05:b0:490:ea8a:32da with SMTP id 5b1f17b1804b1-4926689ee78mr82398625e9.26.1782469131439; Fri, 26 Jun 2026 03:18:51 -0700 (PDT) X-Received: by 2002:a05:600c:1c05:b0:490:ea8a:32da with SMTP id 5b1f17b1804b1-4926689ee78mr82398205e9.26.1782469130997; Fri, 26 Jun 2026 03:18:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 22/45] accel/mshv: remove redundant msi controller Date: Fri, 26 Jun 2026 12:17:25 +0200 Message-ID: <20260626101748.1728079-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469304045158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke The remaining MsiControl infrastructure can be removed now Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-14-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 3 --- accel/mshv/irq.c | 11 ----------- accel/mshv/mshv-all.c | 2 -- 3 files changed, 16 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 68b84ce2c8d..5eef2e6e2cb 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -120,7 +120,4 @@ typedef struct MshvMsrEntries { int mshv_configure_msr(const CPUState *cpu, const MshvMsrEntry *msrs, size_t n_msrs); =20 -/* interrupt */ -void mshv_init_msicontrol(void); - #endif diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 52b8ac94790..4828ac51ac2 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -25,17 +25,6 @@ #define MSHV_IRQFD_RESAMPLE_FLAG (1 << MSHV_IRQFD_BIT_RESAMPLE) #define MSHV_IRQFD_BIT_DEASSIGN_FLAG (1 << MSHV_IRQFD_BIT_DEASSIGN) =20 -static MshvMsiControl *msi_control; -static QemuMutex msi_control_mutex; - -void mshv_init_msicontrol(void) -{ - qemu_mutex_init(&msi_control_mutex); - msi_control =3D g_new0(MshvMsiControl, 1); - msi_control->gsi_routes =3D g_hash_table_new(g_direct_hash, g_direct_e= qual); - msi_control->updated =3D false; -} - /* Pass an eventfd which is to be used for injecting interrupts from userl= and */ static int irqfd(int vm_fd, int fd, int resample_fd, uint32_t gsi, uint32_t flags) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 19a44bb13de..b06eea2a5e9 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -505,8 +505,6 @@ static int mshv_init(AccelState *as, MachineState *ms) =20 mshv_init_mmio_emu(); =20 - mshv_init_msicontrol(); - ret =3D create_vm(mshv_fd, &vm_fd); if (ret < 0) { close(mshv_fd); --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469399; cv=none; d=zohomail.com; s=zohoarc; b=A9UpFp+dg9KZsnujRxJMbfN7ikm5m70HYweIPQuOA5o6Nf52fvIJvEgwuZy7buhEdpjkHHN+gjZABBK14TZn99fHraQKnVO7gcLdXkkIwd+XsjqfX6A1cuaROAUVQtwavuY6NS6kw9VhekNknApjWzrWT1ExAlXLuifxJlbnIIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469399; 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=OvQe6R2LGaw8AiLW+OHgbam2GHSnybOj9jdYYtFJyIg=; b=DdbwawsTu1qL98xhby5g7N2569vOPMMQFQuYt98MX0vvH9xSFb/GjZFgYn2kHG1VHWtDBrfAFpCPGQGRqwd8ZtN1Kk5rGA0J7vAtuoAKn//V9uI431ZVTkGjPnGSRV39ikRcpUmGxSUYTmpu+xIZ8uRuh7mq91TVpMo5cLRuM4k= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469399822327.01142989567006; Fri, 26 Jun 2026 03:23:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eP-0008SJ-Tz; Fri, 26 Jun 2026 06:19:09 -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 1wd3eE-0007j0-FH for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eC-0005J5-KT for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:18:58 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-2aY4LuXsPuaj3gevvPAnKA-1; Fri, 26 Jun 2026 06:18:54 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490b2f22ea2so6712375e9.1 for ; Fri, 26 Jun 2026 03:18:54 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c1b754471sm22956676f8f.0.2026.06.26.03.18.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OvQe6R2LGaw8AiLW+OHgbam2GHSnybOj9jdYYtFJyIg=; b=UCg0mKheWAwgxGZuqvmlmxK0P18tiR292M3yWdvFhn5DrMT9wHzzezkJVoTbx/gyJs1luO BiJsWC5Ov3m/LPCeGvsEuP1vdSpo+nivI/0kqiA+Y+m9kqyAnQLPoi7nqoM6LfgRPDpbbD hv9v7LZl4PQrTAS7PZmeAPHySyZFusU= X-MC-Unique: 2aY4LuXsPuaj3gevvPAnKA-1 X-Mimecast-MFC-AGG-ID: 2aY4LuXsPuaj3gevvPAnKA_1782469133 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469133; x=1783073933; 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; bh=OvQe6R2LGaw8AiLW+OHgbam2GHSnybOj9jdYYtFJyIg=; b=pkXY86aRW7CoA9oWQlQiWWzXhCsT+aWoCWaHkPdzWJeWLfLeaDudATG5TvlE+Y9ULn Ei/D0m+m63zZqMCEnfu9K1zJ1C1n514Do7+u7TZMii3KWUoqKbTxJ8q701yqv9qXCmML DMcyt6WQsBHVmKZc6Ri1/7e4COVXgu6aam1rGw1Uxp/B+EPc73y8qsWXBX1U0RzbTzuU mR48TMzKeWfJZ06dS90Cg0QahGhTEsvwtjxcuWwgOKSe5dR4gGfYQBNGKG0a7LSxNp9P blZgPUylLJ5hw/LzVJphcCWGO0ZQOrQXuX5W6KxbuV8OsNeuhhdKPlFxiPs/Pt5XD4wy UrLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469133; x=1783073933; 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; bh=OvQe6R2LGaw8AiLW+OHgbam2GHSnybOj9jdYYtFJyIg=; b=VIZUOgmMJegD9zuEeuSl22HOKX6y5FJDN5fRQ+P3NbNp3xRMX9tKFqKvGVPpN6EO90 elBUHFjVo1XwXvl4nWZM1FI38K6NYT3OStKRtNOPI9Nu5dx/az01CZgXvvDtu5xjMB61 QPW9P2iq8ehNfoMHKlzZvWQdymA1CWZS4O3CDVTg04gURRiOpyCGv2P4Wsc94NK5fGLm qnabtYfw7E+cmrQ1hZpKvz0UOux/9GlILPyvwfLH2FqtTxudZAXeWYE72oQ+nXt6ibSu lMQT+lQw7k/CuvSh8VCGo5fC2+GQ3XKY0n+yA+XnLSz/dHACYVk/mle/VDcqULf6l5TM 2E/A== X-Gm-Message-State: AOJu0YyGuUJckI9vDOX/rOzrst6YiUBut/yY1Zf6JrJUNEr0N9rggzij mRCZnDIAJtp0uSTelriQFj5LsSbkJaL3wYJQMtPD0lgquclhsl7PkDdoC9p3fLZLuhL/Sd32LCm D7e4cbd8NbTvhzBVwuInMtdC1Y87J6rRxXVFqnYjkmP4AbDma9Up48X40CvQ3tGcT8rDHzjeLL7 ktzfXzGJEzDFoK8nekTNZbFQNcRmgNVsGgbODIE8Jp X-Gm-Gg: AfdE7clwBTY3Jh5GgbA+95/ObEDD67K0b4dmUUWOordDe4EdNUis/SM8RpHtNAgPVhG jffP8HDEOJikDgBv0A1aeDyt13j3gOPVOYQfLpZRnS1UV+vdYkPy3Q9I/+QFDJ1axgllnpWh8ed XWvGM6yBp3JeJcIQHVQ2osZWpq1b6W2EKgw9B3KYrVPW74ahxOasE6e7yBKpP3aAblAuTGChsNw R0qaFWZo5zU8Ds9t2S1znzjy231ck1PHcEzPjpGjT//x6I8GdIM/Zg7HEkz6ZTdGpSQ/939wgZK PD4XhXIdSmIYCY1IdeEfvL/ld9k9xILawMO9zVttVYRyyamyc6fi5aTuGobNgvXfuyM731k+ait aO1flAyw7F3PXDbzAMoYTbFQkLvQT56p3wttHscJrW5wSh3ZjJtefe2HpTGQtvhIJ6VtzQ8DO6R /FMcR2kBQ21XNe6JEj X-Received: by 2002:a05:600d:8653:10b0:492:4e09:9fc1 with SMTP id 5b1f17b1804b1-4926684c8c0mr71441145e9.15.1782469133453; Fri, 26 Jun 2026 03:18:53 -0700 (PDT) X-Received: by 2002:a05:600d:8653:10b0:492:4e09:9fc1 with SMTP id 5b1f17b1804b1-4926684c8c0mr71440665e9.15.1782469132910; Fri, 26 Jun 2026 03:18:52 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 23/45] accel/mshv: store partition proc features Date: Fri, 26 Jun 2026 12:17:26 +0200 Message-ID: <20260626101748.1728079-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469400627158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke We retrieve and store processor features on the state, so we can query them later when deciding which MSRs to migrate. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-19-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/hw/hyperv/hvhdk.h | 2 +- include/system/mshv_int.h | 3 +++ accel/mshv/mshv-all.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/include/hw/hyperv/hvhdk.h b/include/hw/hyperv/hvhdk.h index 9ad16c47da9..9e6dcb22f61 100644 --- a/include/hw/hyperv/hvhdk.h +++ b/include/hw/hyperv/hvhdk.h @@ -353,7 +353,7 @@ union hv_partition_processor_features { uint64_t lass_support:1; uint64_t idle_hlt_intercept_support:1; uint64_t msr_list_support:1; - }; + } QEMU_PACKED; }; =20 enum hv_translate_gva_result_code { diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 5eef2e6e2cb..0cf68d2879e 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -14,6 +14,8 @@ #ifndef QEMU_MSHV_INT_H #define QEMU_MSHV_INT_H =20 +#include "hw/hyperv/hvhdk.h" + #define MSHV_MSR_ENTRIES_COUNT 64 =20 typedef struct hyperv_message hv_message; @@ -53,6 +55,7 @@ struct MshvState { int nr_allocated_irq_routes; unsigned long *used_gsi_bitmap; unsigned int gsi_count; + union hv_partition_processor_features processor_features; }; =20 typedef struct MshvMsiControl { diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index b06eea2a5e9..d939982eb79 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -133,6 +133,57 @@ static int get_host_partition_property(int mshv_fd, ui= nt32_t property_code, return 0; } =20 +static int get_partition_property(int vm_fd, uint32_t feature_bank, + uint64_t *value) +{ + 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}; + int ret; + + in.property_code =3D feature_bank; + + 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(vm_fd, MSHV_ROOT_HVCALL, &args); + if (ret < 0) { + error_report("Failed to get guest partition property bank: %s", + strerror(errno)); + return -1; + } + + *value =3D out.property_value; + return 0; +} + +static int get_proc_features(int vm_fd, + union hv_partition_processor_features *featur= es) +{ + int ret; + + ret =3D get_partition_property(vm_fd, + HV_PARTITION_PROPERTY_PROCESSOR_FEATURES0, + features[0].as_uint64); + if (ret < 0) { + error_report("Failed to get processor features bank 0"); + return -1; + } + + ret =3D get_partition_property(vm_fd, + HV_PARTITION_PROPERTY_PROCESSOR_FEATURES1, + features[1].as_uint64); + if (ret < 0) { + error_report("Failed to get processor features bank 1"); + return -1; + } + + return 0; +} + static int create_partition(int mshv_fd, int *vm_fd) { int ret; @@ -520,6 +571,12 @@ static int mshv_init(AccelState *as, MachineState *ms) =20 s->vm =3D vm_fd; s->fd =3D mshv_fd; + + ret =3D get_proc_features(vm_fd, &s->processor_features); + if (ret < 0) { + return -1; + } + s->nr_as =3D 1; s->as =3D g_new0(MshvAddressSpace, s->nr_as); =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469399; cv=none; d=zohomail.com; s=zohoarc; b=QU1qYyTeFX29/aCAQIuBtXUD0QT99rHFOFP1iKsqDaOmwOXf2746ogUh4oW39lg0Qv76Svx8iQ3yjx7XhQGj7O/NkBDDMd4FcPziGkw5/N7WQ436i4jeOTHZWdwSkyGZZX3EzDay7H+XVe7z4NY/rHYvO0nkSUwqVDpoqSaAWZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469399; 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=+kj0eRBswti/AsFqB8XmuAgtDzPuzUfAZcA79+C8npY=; b=Rja6AHdEXTO5zAN7B0LGNczxykdvtfLsggkVtqnh/nO8yl9H06n7WIc/YruJxADbCpd9ml+ErehPM7jtT4AlIo4mjn+46cxDnqV5U6qBWlP6CCB5nyLymSOB8lhiyAkIxv71fKZ2rygiOSMUSUUbCkJjztYxaxUmO7Q6z81kWd0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469399575980.3442916197373; Fri, 26 Jun 2026 03:23:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eN-0008Bb-Gy; Fri, 26 Jun 2026 06:19:07 -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 1wd3eJ-0007su-7I for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eH-0005Lk-Gp for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:02 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-150-o0mm5g9QNNm-QGfV1eFRqA-1; Fri, 26 Jun 2026 06:18:59 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-490c56e2576so5481065e9.3 for ; Fri, 26 Jun 2026 03:18:59 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46f8d6f10absm1739431f8f.5.2026.06.26.03.18.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+kj0eRBswti/AsFqB8XmuAgtDzPuzUfAZcA79+C8npY=; b=RfhijZnBMtRzcguImaWxRgCYWsMljrsSIgj2Ym1o8kpmcg4Lca6l2ifntzc+iCCURBJuWP j4CzyNovxMUk+0GlgBfQVojElXv2T5rCH8jc12PssTTqHQAi7iJ8uC1YPX1cNmI33iEse5 AMOOj6DZSmO/yOGL57/mSrd+Hy2KN10= X-MC-Unique: o0mm5g9QNNm-QGfV1eFRqA-1 X-Mimecast-MFC-AGG-ID: o0mm5g9QNNm-QGfV1eFRqA_1782469138 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469138; x=1783073938; 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; bh=+kj0eRBswti/AsFqB8XmuAgtDzPuzUfAZcA79+C8npY=; b=JGDjok6DSMtw9yDsF141VeS0ubEyQy3Tn+gHmn5XZsPDiSu/Tsdk8aoZlbfy5ZjjWH KuFoKqfb80DuPzWC7KpJ+PYYsn3GZN5S2UQBOASSMAKtweFnUY5l1HDSsdbonBooKY74 ROtW3ueL/HGKVPfCmKuCbJsodZZDEXQegD7G/202w79SROcq1Eb/DwOmjZpDs264GYi8 9z0bwrBt6pxFmQUeKQqaLP4fayB5wM4ESS8gQ8a26Y/OS1vPysCDx0NZb1Wl6ATYovPE aOgnZ+ZB5iPHf8510oi5IEQ4oguceycv7YaJHkryOXBAOa7USc9KFfGkdXXnnDUtGDD/ 4iLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469138; x=1783073938; 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; bh=+kj0eRBswti/AsFqB8XmuAgtDzPuzUfAZcA79+C8npY=; b=H6H3LC6p7HpOPOJOxnA8yay5z87bkvZlOJYfKUkLWm//UZI8lEUy3jErybCo5jVAh/ YsikiZf9fVS0cZbAJue4mG8CodLpo/VVjuS/AEWyi6aytnkc7FFjBVY/0vlMQ5ZovLPg HWPtgdvoOlf+b5iPqVL6WCOQf0hoGXoxbZtF6sezgo4Dxn37ml5DM3vWeJcGLpUPHE+K kEOVQK2LynoUcccvmdtxwQ/HngCaJI5P8/+mN8B/HYlsvtOQbtuTalcTGNbsXsoJCcXg dpnRPDL6gDLWTHu/3yKOQJW9bwKuGAE+VIsDONNqUW9zx1FgQoElmoVfu1VX1ZAdbrB2 5g+A== X-Gm-Message-State: AOJu0YwVDU8br9N/2lD5i/E2AkLorWS3qKFGoBlUQKAeKgogc2LQvpR+ KBkVts/MswWTvmu28MZAxcMy8YEFXs5gqsx78ys0VNP79uDDdXQKmw9WsQXC94I4jViSsaxS//6 8cvTgYfD7VNrGAHlWAVsw3YPovE+iMrOONvkZAcVgsD1kdj+2mDPvIt6HEwj0xzxd2mQaCm3cZG aRcWJJ2SZNwEJ5fyJ1VH216b8KPrlLXSQUYeGwtamA X-Gm-Gg: AfdE7cnoSo8PMRNk1PICJwIQYJYWJ7HmDIHqoRxVbdz/6ADTgFRlnH716YHvTuE1jDn OfPSSC1yYUOVStx8jEcm7omuQ6bMJOiUHPw8m2/zvfysjp1MsqrYrxFjmkvIRGfzoE4HJF50nE9 59/D5UbQdnDbNCXA+YJFPJsuVFeGPaGoB1lH00z+42guM4zQ+EePaAcNWKC4Mjnk1dIIO57hCPR F+/8s/ROW3hBPb9qFNp81Bk38APImQNcjoP3Y+YjhwKyL1+MENU3DBjLqhMtgh13nO/47x82VTk ItDcRLBTgbB5Lz89Ao2TBWCDemlWAg1mq1Vh+hN4BM+XgcWFMs0smn3PFq3kS5yjobJL7i6WNlB /Afs+D2OAHFiBPIUG35Wbj0WKz166FLVCY7nnbMsWd1UbvkWfrXITFHO1HzK6+BTpgBJOMxCJLu 0A/PLOikMdY4rAuOVr X-Received: by 2002:a05:600c:6748:b0:490:c024:2eba with SMTP id 5b1f17b1804b1-4926688598fmr86669495e9.22.1782469138144; Fri, 26 Jun 2026 03:18:58 -0700 (PDT) X-Received: by 2002:a05:600c:6748:b0:490:c024:2eba with SMTP id 5b1f17b1804b1-4926688598fmr86668875e9.22.1782469137590; Fri, 26 Jun 2026 03:18:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 24/45] target/i386/mshv: expose mshv_get_generic_regs Date: Fri, 26 Jun 2026 12:17:27 +0200 Message-ID: <20260626101748.1728079-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469400619158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke We expose the fn, so we can call them from the other source files (msr.c). Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-20-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 2 ++ target/i386/mshv/mshv-cpu.c | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 0cf68d2879e..ac26bfafe48 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -80,6 +80,8 @@ int mshv_configure_vcpu(const CPUState *cpu); int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *e= xit); int mshv_set_generic_regs(const CPUState *cpu, const hv_register_assoc *as= socs, size_t n_regs); +int mshv_get_generic_regs(CPUState *cpu, hv_register_assoc *assocs, + size_t n_regs); int mshv_arch_store_vcpu_state(const CPUState *cpu); int mshv_arch_load_vcpu_state(CPUState *cpu); void mshv_arch_init_vcpu(CPUState *cpu); diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index e3f163ef630..a0a25cd2c05 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -111,9 +111,6 @@ static enum hv_register_name FPU_REGISTER_NAMES[26] =3D= { }; =20 static int set_special_regs(const CPUState *cpu); -static int get_generic_regs(CPUState *cpu, - struct hv_register_assoc *assocs, - size_t n_regs); =20 static void populate_fpu(const hv_register_assoc *assocs, X86CPU *x86cpu) { @@ -171,7 +168,7 @@ static int get_fpu(CPUState *cpu) for (size_t i =3D 0; i < n_regs; i++) { assocs[i].name =3D FPU_REGISTER_NAMES[i]; } - ret =3D get_generic_regs(cpu, assocs, n_regs); + ret =3D mshv_get_generic_regs(cpu, assocs, n_regs); if (ret < 0) { error_report("failed to get special registers"); return -errno; @@ -191,7 +188,7 @@ static int get_xc_reg(CPUState *cpu) =20 assocs[0].name =3D HV_X64_REGISTER_XFEM; =20 - ret =3D get_generic_regs(cpu, assocs, 1); + ret =3D mshv_get_generic_regs(cpu, assocs, 1); if (ret < 0) { error_report("failed to get xcr0"); return -1; @@ -284,8 +281,8 @@ int mshv_set_generic_regs(const CPUState *cpu, const hv= _register_assoc *assocs, return 0; } =20 -static int get_generic_regs(CPUState *cpu, hv_register_assoc *assocs, - size_t n_regs) +int mshv_get_generic_regs(CPUState *cpu, hv_register_assoc *assocs, + size_t n_regs) { int cpu_fd =3D mshv_vcpufd(cpu); int vp_index =3D cpu->cpu_index; @@ -434,7 +431,7 @@ static int get_standard_regs(CPUState *cpu) for (size_t i =3D 0; i < n_regs; i++) { assocs[i].name =3D STANDARD_REGISTER_NAMES[i]; } - ret =3D get_generic_regs(cpu, assocs, n_regs); + ret =3D mshv_get_generic_regs(cpu, assocs, n_regs); if (ret < 0) { error_report("failed to get standard registers"); return -1; @@ -511,7 +508,7 @@ static int get_special_regs(CPUState *cpu) for (size_t i =3D 0; i < n_regs; i++) { assocs[i].name =3D SPECIAL_REGISTER_NAMES[i]; } - ret =3D get_generic_regs(cpu, assocs, n_regs); + ret =3D mshv_get_generic_regs(cpu, assocs, n_regs); if (ret < 0) { error_report("failed to get special registers"); return -errno; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469324; cv=none; d=zohomail.com; s=zohoarc; b=F5c8amu8vit3UM9RS/cakhGlBXFWBEuLQQ6ANwaGrxxm1hx7x2UxHaAg3aF1thIoNM4rNTCRYHBoJqpy8BbW8Zul5ZKNAHFtM+7EqP8+P5bDYPtJOge7EvMA1BEmwUCYO0HJwo111GMmTdmZ6q0lBqkOP51FNty/3PP8xnpOHnM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469324; 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=0u6ciU5ce4UtTHQKayfuwLUVLLB0WirqzZ3GmCWZzlE=; b=fDB1HUyfJ3A2bhrjrnEa15GJt2joAjDFPKEWWPLK7MJoCOtzIAh98f2B1efmdot0rJulsqEuUF6dD2/VjPGBXMoL11o0TPyUlBXG6QVzoDJ4XxsOtrQTtX4UHUGJ9zJg8XzRwYopudPkSKo3scx2ujnC+shh/Wm+LyVnKZet1Xg= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469324915276.71353260623346; Fri, 26 Jun 2026 03:22:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eR-0000Dh-8d; Fri, 26 Jun 2026 06:19:11 -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 1wd3eL-0007uo-Fz for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eJ-0005Ly-Dq for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:05 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-218-tvjc_KBRM4aBdWoqIbpd-A-1; Fri, 26 Jun 2026 06:19:01 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490b61243easo9180635e9.2 for ; Fri, 26 Jun 2026 03:19:01 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49269086ab7sm96897515e9.13.2026.06.26.03.18.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469142; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0u6ciU5ce4UtTHQKayfuwLUVLLB0WirqzZ3GmCWZzlE=; b=Qs+XDaKjM4luc/hIAhoKKVNBkMZU5qgULliVTgFk+IH0SV3oIYy8F2nRtzDXbocz8tfEWx N87UQeBoflp4LOHqcr7aMSywDaNp0nb4oaJNdhPKkAdx22LtLD3zuOZ5blk9IxLcl5XyfK bmpo+N7/4+MVHFDSoCK0+6SevL1iZcg= X-MC-Unique: tvjc_KBRM4aBdWoqIbpd-A-1 X-Mimecast-MFC-AGG-ID: tvjc_KBRM4aBdWoqIbpd-A_1782469140 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469140; x=1783073940; 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; bh=0u6ciU5ce4UtTHQKayfuwLUVLLB0WirqzZ3GmCWZzlE=; b=I/BNsW3pNc2TB0YREV2qBMazWGv+7emE7HiRLE7c1kAVhcMfXMMoH4UtIniWxCy7Cq R6JG1tOvXGoN6LmqaBxSQyz8ScpNvasbJHVVL1uJ0Ha9DbtvJ78kIzEbjIB4CUP9v7bh ZPfAEkS3th/+IA7xND+Z+JawcAVUQrxcypB0erqrtGtDYyuHrzAhA7aDHNCHcUhMdmGF cW5MCBMHEIr4n/zTWJkWdxLlydVsOpU2bNGOZgTbeYmACOqy4dRuVpUG49F7bIIafknG PML4QM5nDJgX2HeqSHTri6hJpT/sB2FihUokl+RasTRT0hvCTWFteQfC52BSADFWDjlo mW0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469140; x=1783073940; 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; bh=0u6ciU5ce4UtTHQKayfuwLUVLLB0WirqzZ3GmCWZzlE=; b=tER9VI4skLiOCtk5XsLqmySMcXb5IgljwVHM7FspAY4rhEk9WnDc7Ma/c83SgGP/6l p4H6KoFxgMwp71SyCzGyUvQJa9yNTCakPsWLUEouqPvbAiapBK1UZONTN3VC5hEa6es7 poJEHxs3hDNan17WF9aEF2pPun98QJ1jADYEs3gVz/ZrX7VaEoHppjbQSWESo6Dp6EXp KuoINgQWfpmUv/tkYkj1PPf3/b2lPqRypaCl7SXbllhP55PgMxEu9NuVTPN9Xf9wksPf GgmrvOmx8n3rQQ9cz/eHvOisobONjY5gMlgHlIGkl+izst0f/2o1sGN16kXb7RngHyuZ KyTg== X-Gm-Message-State: AOJu0YyJuejjY3oXg+BoCRft/xCZvA/6utLP5aBo9+aqJHnsGh0sxOcA 5Jg8VElKBo7/AVDargOfsC/p4J70mGDcojaGssMD/FAsQheDuMp4BmvEJ7iX2zNbaaayl6cfSjS ShMHX3vI48FHYc28vVbsL2QJxckE2b2GF9j/hD6xCbPHDCP+Psmb71iFljsg9zEk8tuU4yf4ka/ ClMgW6QOBO3Sx+AfIy/s6s8vuPtBo/tVMQtH/fa5Hl X-Gm-Gg: AfdE7cm0SNe2G95MdWtdjDvcz2l+F1sV5Hxwpj+8FQmAzsLypyk3UIjUxemsVz/7nBK WQeXxtd1nQ2ZHc0ifvG575HnYukuFBfagqt6V1Z8U+APkdRXKjVlqTh2mGTvxTQa5LIKwukJgRU iFA8lO6Al3Wt2VMz0zKybn9KqaDQ3m0jLKBpXIKlLo8AVAuS/Yw4sVjrRhz9cz4eh2YWX4H+som 0+A47Qo5VkGMi8K4BJJSpHKLO+yj+XklXAwOXNjtDr/e+Ua1JCQ/nMs5134eDY1ckN5Q1bacKQJ y2wct7WD/aARxHvs2YTqy3DW69qsQywZ+aMEI60y/aSTqKABzr9z51pABGJcoyGzYXwkU/0YbOA iFLNLnFSiXApZzW5V9cSUYmFg5sITn7Moa52RsW68RysrhyaTPa9cxxigDeSgF2YBu0eIB5fbI6 8K64b9u8Jte1xsljvs X-Received: by 2002:a05:600c:3f06:b0:492:33a8:5499 with SMTP id 5b1f17b1804b1-492668858a8mr93112855e9.17.1782469139907; Fri, 26 Jun 2026 03:18:59 -0700 (PDT) X-Received: by 2002:a05:600c:3f06:b0:492:33a8:5499 with SMTP id 5b1f17b1804b1-492668858a8mr93112185e9.17.1782469139279; Fri, 26 Jun 2026 03:18:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 25/45] accel/mshv: enable dirty page tracking Date: Fri, 26 Jun 2026 12:17:28 +0200 Message-ID: <20260626101748.1728079-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469326269158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke This change introduces the functions required to perform dirty page tracking to speed up migrations. We are using the sync, global_start, and global_stop hooks. The sync is implemented in batches. Before we can disable the dirty page tracking we have to set all dirty bits. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-35-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/system/mshv_int.h | 4 + accel/mshv/mem.c | 211 ++++++++++++++++++++++++++++++++++++++ accel/mshv/mshv-all.c | 3 + 3 files changed, 218 insertions(+) diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index ac26bfafe48..3bdf16ecd35 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -17,6 +17,7 @@ #include "hw/hyperv/hvhdk.h" =20 #define MSHV_MSR_ENTRIES_COUNT 64 +#define MSHV_DIRTY_PAGES_BATCH_SIZE 0x10000 =20 typedef struct hyperv_message hv_message; =20 @@ -109,6 +110,9 @@ int mshv_guest_mem_write(uint64_t gpa, const uint8_t *d= ata, uintptr_t size, bool is_secure_mode); void mshv_set_phys_mem(MshvMemoryListener *mml, MemoryRegionSection *secti= on, bool add); +void mshv_log_sync(MemoryListener *listener, MemoryRegionSection *section); +bool mshv_log_global_start(MemoryListener *listener, Error **errp); +void mshv_log_global_stop(MemoryListener *listener); =20 /* msr */ typedef struct MshvMsrEntry { diff --git a/accel/mshv/mem.c b/accel/mshv/mem.c index e55c38d4db9..820f87ef0c9 100644 --- a/accel/mshv/mem.c +++ b/accel/mshv/mem.c @@ -12,10 +12,13 @@ =20 #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "linux/mshv.h" #include "system/address-spaces.h" #include "system/mshv.h" #include "system/mshv_int.h" +#include "hw/hyperv/hvhdk_mini.h" +#include "system/physmem.h" #include "exec/memattrs.h" #include #include "trace.h" @@ -211,3 +214,211 @@ void mshv_set_phys_mem(MshvMemoryListener *mml, Memor= yRegionSection *section, abort(); } } + +static int enable_dirty_page_tracking(int vm_fd) +{ + int ret; + struct hv_input_set_partition_property in =3D {0}; + struct mshv_root_hvcall args =3D {0}; + + in.property_code =3D HV_PARTITION_PROPERTY_GPA_PAGE_ACCESS_TRACKING; + in.property_value =3D 1; + + args.code =3D HVCALL_SET_PARTITION_PROPERTY; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t)∈ + + ret =3D mshv_hvcall(vm_fd, &args); + if (ret < 0) { + error_report("Failed to enable dirty page tracking: %s", + strerror(errno)); + return -1; + } + + return 0; +} + +/* + * Retrieve dirty page bitmap for a GPA range, clearing the dirty bits + * atomically. Large ranges are handled in batches. + */ +static int get_dirty_log(int vm_fd, uint64_t base_pfn, uint64_t page_count, + unsigned long *bitmap, size_t bitmap_size) +{ + uint64_t batch, bitmap_offset, completed =3D 0; + struct mshv_gpap_access_bitmap args =3D {0}; + int ret; + + QEMU_BUILD_BUG_ON(MSHV_DIRTY_PAGES_BATCH_SIZE % BITS_PER_LONG !=3D 0); + assert(bitmap_size >=3D ROUND_UP(page_count, BITS_PER_LONG) / 8); + + while (completed < page_count) { + batch =3D MIN(MSHV_DIRTY_PAGES_BATCH_SIZE, page_count - completed); + bitmap_offset =3D completed / BITS_PER_LONG; + + args.access_type =3D MSHV_GPAP_ACCESS_TYPE_DIRTY; + args.access_op =3D MSHV_GPAP_ACCESS_OP_CLEAR; + args.page_count =3D batch; + args.gpap_base =3D base_pfn + completed; + args.bitmap_ptr =3D (uint64_t)(bitmap + bitmap_offset); + + ret =3D ioctl(vm_fd, MSHV_GET_GPAP_ACCESS_BITMAP, &args); + if (ret < 0) { + error_report("Failed to get dirty log (base_pfn=3D0x%" PRIx64 + " batch=3D%" PRIu64 "): %s", + base_pfn + completed, batch, strerror(errno)); + return -1; + } + completed +=3D batch; + } + + return 0; +} + +bool mshv_log_global_start(MemoryListener *listener, Error **errp) +{ + int ret; + + ret =3D enable_dirty_page_tracking(mshv_state->vm); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to enable dirty page tracking= "); + return false; + } + return true; +} + +static int disable_dirty_page_tracking(int vm_fd) +{ + int ret; + struct hv_input_set_partition_property in =3D {0}; + struct mshv_root_hvcall args =3D {0}; + + in.property_code =3D HV_PARTITION_PROPERTY_GPA_PAGE_ACCESS_TRACKING; + in.property_value =3D 0; + + args.code =3D HVCALL_SET_PARTITION_PROPERTY; + args.in_sz =3D sizeof(in); + args.in_ptr =3D (uint64_t)∈ + + ret =3D mshv_hvcall(vm_fd, &args); + if (ret < 0) { + error_report("Failed to disable dirty page tracking: %s", + strerror(errno)); + return -1; + } + + return 0; +} + +static int set_dirty_pages(int vm_fd, uint64_t base_pfn, uint64_t page_cou= nt) +{ + uint64_t batch, completed =3D 0; + unsigned long bitmap[MSHV_DIRTY_PAGES_BATCH_SIZE / BITS_PER_LONG]; + struct mshv_gpap_access_bitmap args =3D {0}; + int ret; + + while (completed < page_count) { + batch =3D MIN(MSHV_DIRTY_PAGES_BATCH_SIZE, page_count - completed); + + args.access_type =3D MSHV_GPAP_ACCESS_TYPE_DIRTY; + args.access_op =3D MSHV_GPAP_ACCESS_OP_SET; + args.page_count =3D batch; + args.gpap_base =3D base_pfn + completed; + args.bitmap_ptr =3D (uint64_t)bitmap; + + ret =3D ioctl(vm_fd, MSHV_GET_GPAP_ACCESS_BITMAP, &args); + if (ret < 0) { + error_report("Failed to set dirty pages (base_pfn=3D0x%" PRIx64 + " batch=3D%" PRIu64 "): %s", + base_pfn + completed, batch, strerror(errno)); + return -1; + } + completed +=3D batch; + } + + return 0; +} + +static bool set_dirty_bits_cb(Int128 start, Int128 len, const MemoryRegion= *mr, + hwaddr offset_in_region, void *opaque) +{ + int ret, *errp =3D opaque; + hwaddr gpa, size; + uint64_t page_count, base_pfn; + + gpa =3D int128_get64(start); + size =3D int128_get64(len); + page_count =3D size >> MSHV_PAGE_SHIFT; + base_pfn =3D gpa >> MSHV_PAGE_SHIFT; + + if (!mr->ram || mr->readonly) { + return false; + } + + if (page_count =3D=3D 0) { + return false; + } + + ret =3D set_dirty_pages(mshv_state->vm, base_pfn, page_count); + + /* true aborts the iteration, which is what we want if there's an erro= r */ + if (ret < 0) { + *errp =3D ret; + return true; + } + + return false; +} + +void mshv_log_global_stop(MemoryListener *listener) +{ + int err =3D 0; + /* MSHV requires all dirty bits to be set before disabling tracking. */ + FlatView *fv =3D address_space_to_flatview(&address_space_memory); + flatview_for_each_range(fv, set_dirty_bits_cb, &err); + + if (err < 0) { + error_report("Failed to set dirty bits before disabling tracking"); + } + + disable_dirty_page_tracking(mshv_state->vm); +} + +void mshv_log_sync(MemoryListener *listener, MemoryRegionSection *section) +{ + hwaddr size, start_addr, mr_offset; + uint64_t page_count, base_pfn; + size_t bitmap_size; + unsigned long *bitmap; + ram_addr_t ram_addr; + int ret; + MemoryRegion *mr =3D section->mr; + + if (!memory_region_is_ram(mr) || memory_region_is_rom(mr)) { + return; + } + + size =3D align_section(section, &start_addr); + if (!size) { + return; + } + + page_count =3D size >> MSHV_PAGE_SHIFT; + base_pfn =3D start_addr >> MSHV_PAGE_SHIFT; + bitmap_size =3D ROUND_UP(page_count, BITS_PER_LONG) / 8; + bitmap =3D g_malloc0(bitmap_size); + + ret =3D get_dirty_log(mshv_state->vm, base_pfn, page_count, bitmap, + bitmap_size); + if (ret < 0) { + g_free(bitmap); + return; + } + + mr_offset =3D section->offset_within_region + start_addr - + section->offset_within_address_space; + ram_addr =3D memory_region_get_ram_addr(mr) + mr_offset; + + physical_memory_set_dirty_lebitmap(bitmap, ram_addr, page_count); + g_free(bitmap); +} diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index d939982eb79..9452504ac28 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -477,6 +477,9 @@ static MemoryListener mshv_memory_listener =3D { .region_del =3D mem_region_del, .eventfd_add =3D mem_ioeventfd_add, .eventfd_del =3D mem_ioeventfd_del, + .log_sync =3D mshv_log_sync, + .log_global_start =3D mshv_log_global_start, + .log_global_stop =3D mshv_log_global_stop, }; =20 static MemoryListener mshv_io_listener =3D { --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469188; cv=none; d=zohomail.com; s=zohoarc; b=aC551a9jYqj3yaDi4l1GAaMuz5P+AckxNmC+0fZrao0PSC9j1bOdokgRmJ/QaE6HvWBCM3GRtg8eVxGfL6kKZy0lLJnUrawf0CnUhgvRbHpmVSRWBPurUq3odg1w/LIumlwv5a8+UPn6hsGqCRRUCdyzb7VIxOM+UM9HGmy8Jwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469188; 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=XMJTWCQgasnt3uwwNSi7XCS5So8lwAHMFw+1U5QkCu4=; b=kQ4QCnZF8omzG7/LDgu1nS15FOIITyM5juvScNOjIgH9QKTTvAMXktdAY7laXw+r9JDALjUeTJcy0X82ElkzMvBpd6SXnnSKSXS3OQlNpEBmSWYgv04ao1PbAT+/eVOJwmq5eeIXh8P4RJMStCimNRXInyb6Sj5SAVOxIsis0jE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17824691879937.524348107027322; Fri, 26 Jun 2026 03:19:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eY-0000ks-TO; Fri, 26 Jun 2026 06:19:19 -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 1wd3eO-0008K8-KK for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eM-0005MF-TJ for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:08 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-mlPgwHUbNq-qfyAxfRIo_Q-1; Fri, 26 Jun 2026 06:19:04 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-46010392f89so569324f8f.2 for ; Fri, 26 Jun 2026 03:19:04 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fde98csm72616895e9.6.2026.06.26.03.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XMJTWCQgasnt3uwwNSi7XCS5So8lwAHMFw+1U5QkCu4=; b=Bv/cAxIb1JdrXJMY7+QTByoX1cYMZkBR1wa47U1Xj5+915Ce/owFUcDEF3ikOuwbDluAJH mOHFp4ua04yL3coY7SV0214CKwp8zbuXKTSDqC7GBRgkr6AyYmrYTMDxSSYSVBOW7Au5L8 aMZv5LKXOm+mLtYpN3Bw2eLIXKMEtkg= X-MC-Unique: mlPgwHUbNq-qfyAxfRIo_Q-1 X-Mimecast-MFC-AGG-ID: mlPgwHUbNq-qfyAxfRIo_Q_1782469144 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469143; x=1783073943; 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; bh=XMJTWCQgasnt3uwwNSi7XCS5So8lwAHMFw+1U5QkCu4=; b=qa0V9aaOZapwqW494zhV2mo0+g97jRqy/AyJrsBSs1S6NYFvHYiMoTQVXpYdFPzGwU vdcuNYi3xuTMt7islQIguzwx2sKWcLltRCsb8GQPr9PqHcnktIjDorSQ09/dJrw0gu7T H+5YJWyPEwGu6H5b3h3dLFeJQSVv9PkIjWnH/m65N1CMRCguhtwAaczJ1fgpjYr52QAJ BAZ64gHuAiZONnWIgmLWA6W498dPkafNYsN/457wuKJlCRCfGAmCF7tMHHec6u9REZn1 9NM+hoZSbOZQnO1OuQ0/jsZUBvtSpkfLbBs0eOxOjdNVTyrDiWK4A4rhJG4RvxE4Amho 3jPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469143; x=1783073943; 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; bh=XMJTWCQgasnt3uwwNSi7XCS5So8lwAHMFw+1U5QkCu4=; b=VqCSKO5PryIQpyF9TPTzBKi2jdMdI7jU11hXBzt8JF7Rjjrk0S3pawfIL4DfcTtJZT SqWl965sd/TVybQhZMt8DhfuRYv/B/Op1F8o1dAFP8zONJnUcxeh4m6yo/tvGR89jQA8 QC+cKT9A7rCgKieWnPp/eCflisHx7iaKYNrvneBLI95xsxX6RB7+fbwNgo9gGU/8YmcI VAzNIRkE8VnDLXmFrbhpURM78ztGR07l29YfsKxWS4trvKrzwUp/zjr3sZ6ZPTloV0o5 GP2q5BeUOAR6t7mo0lsGkk9nt8CqbQsngQ4xAnWK68STdwruQu9iPoOeqOY10ttzUziK GXng== X-Gm-Message-State: AOJu0YxXoAFn451E8l8I2mbMbEvFE0c15O/ORxxecSDdrOt8ZPVI/fEw ftJT7q982QSscOFRe6YlT4huV1JQNsrKX9tKl0UPjamxp1mK777osQHTlDbez2yVhbEdka4tyWG HIPUcQRU0+9VKM8LEhadrhItHl+/o+6j2XnhrYofHQbf0trNuyyB7MLg5WJQg6AdZWfFg2Ob51d 2QwBCApQD+35Rh7pSORuoRlldv4G9WQXA4LoudI06n X-Gm-Gg: AfdE7ckzXSEUKLDxRRU309T2B2IeQWC4UHmXOPwFlcY5cb+WfJzlhLuYnDt9EVlGx3x vaeoDU3O6xQraW3RBFQiF+/K66wV7riWZ5wdwKiLQTh3Q6wwWGKH96vj+rdEzFAq29KJxlmk5xi PN/shytNL98X1onW6XysVn8r+dLF/5sCws1mywqKTBAnN8lQB2JmaoVfxzl2lT5oG2ZXbhOssL5 dxwwfQb0QAUamFvRRGoihRflAjvrHmkjEiRj8VNXVDihzTm9Cj3ZGCOHKUwwv1aWUujh5k/rW3I PihWKNSIHTjL+SylqzYGcTy5M9FSJLBNtL5PDF2geybmo9g2CexIj3Gknca6Fhqfs1yTM/51ss3 7OAXYQPP0IKz9qIp4Sjiq6xyjw0KrYIXwHBd0rmIyeN6y10wWc2c/X0/3TdW4E6O1oh6EVxOYL/ JHApkdhxllSbiMmRUC X-Received: by 2002:a05:600c:620d:b0:492:30f2:963a with SMTP id 5b1f17b1804b1-492667e849fmr90059845e9.0.1782469143715; Fri, 26 Jun 2026 03:19:03 -0700 (PDT) X-Received: by 2002:a05:600c:620d:b0:492:30f2:963a with SMTP id 5b1f17b1804b1-492667e849fmr90059305e9.0.1782469143249; Fri, 26 Jun 2026 03:19:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 26/45] target/i386/mshv: move msr code to arch Date: Fri, 26 Jun 2026 12:17:29 +0200 Message-ID: <20260626101748.1728079-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469189278158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke The MSR code is x86 specific, hence it's better suited in the arch tree. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-18-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- {accel =3D> target/i386}/mshv/msr.c | 0 accel/mshv/meson.build | 1 - target/i386/mshv/meson.build | 1 + 3 files changed, 1 insertion(+), 1 deletion(-) rename {accel =3D> target/i386}/mshv/msr.c (100%) diff --git a/accel/mshv/msr.c b/target/i386/mshv/msr.c similarity index 100% rename from accel/mshv/msr.c rename to target/i386/mshv/msr.c diff --git a/accel/mshv/meson.build b/accel/mshv/meson.build index c1b1787c5e6..e433187cde0 100644 --- a/accel/mshv/meson.build +++ b/accel/mshv/meson.build @@ -1,6 +1,5 @@ system_ss.add(when: 'CONFIG_MSHV', if_true: files( 'irq.c', 'mem.c', - 'msr.c', 'mshv-all.c' )) diff --git a/target/i386/mshv/meson.build b/target/i386/mshv/meson.build index 49f28d4a5b9..6091c218874 100644 --- a/target/i386/mshv/meson.build +++ b/target/i386/mshv/meson.build @@ -2,6 +2,7 @@ i386_mshv_ss =3D ss.source_set() =20 i386_mshv_ss.add(files( 'mshv-cpu.c', + 'msr.c', )) =20 i386_system_ss.add_all(when: 'CONFIG_MSHV', if_true: i386_mshv_ss) --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469362; cv=none; d=zohomail.com; s=zohoarc; b=bOPlxf6gRtSI/hVJPcgEdvvmdjyFUyeVS/rL5LyXdX0wSz8YDYHT8zSf4YvsQSp0xrskO2FAY1+3KOCtjfp8gRoRykSA5ZKvszn1TNlsQW0qf/7tOzJPy+IhrfJzfzvHx9cNd8WwOxrkfAcbDHyB+HyExzttuY7qBXOpGM3w5Hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469362; 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=Dz1pu6mWfW58JROqNGnbicb8BcOiLwuqIScXaYTXhqU=; b=ikO6iu5IXuAldeBUMc1kpLYRkqUhIwZQ32XnnNRDX1oKwK0cWnni4qGCWcltXq2ysp5aLu9aPWnn/jKOXXmiYBzj0I/sbjk/KHv3Tsu1Y4palUt9zerhnkubc8Kao2sD1DoS1qm+gbkyEDn3QPyJh+GBrWBkTnK4C1f0T9cgbB0= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469362359815.6372479642838; Fri, 26 Jun 2026 03:22:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eZ-0000lI-2m; Fri, 26 Jun 2026 06:19:19 -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 1wd3eQ-0000BB-W4 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eO-0005MP-NA for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:10 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-454-MbhXTfb8NfiQANkN0o2l1w-1; Fri, 26 Jun 2026 06:19:06 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-46fb9079a04so901f8f.3 for ; Fri, 26 Jun 2026 03:19:06 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46e3d6ba143sm10718446f8f.33.2026.06.26.03.19.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Dz1pu6mWfW58JROqNGnbicb8BcOiLwuqIScXaYTXhqU=; b=GNSY8CVy4ATqtpO48BWuhR81V51gRW8MKCSNnmVDzXK4FnhclBkaZc17zoTG5WDusqmOPl ma3fHYevwvpbwxzFcfdfuvdnVcKpKSMk10f8MYGdrpdRhj/idNAG9DubEfFaeUqhj67iY0 nQdLcJEhEZ4ijkpeGyyAtdT/5huT0y0= X-MC-Unique: MbhXTfb8NfiQANkN0o2l1w-1 X-Mimecast-MFC-AGG-ID: MbhXTfb8NfiQANkN0o2l1w_1782469146 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469145; x=1783073945; 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; bh=Dz1pu6mWfW58JROqNGnbicb8BcOiLwuqIScXaYTXhqU=; b=li2eQVVd0tst6vqugC6KFnxpOTpTGdA9MKm9z6qwBI2FK3eHZqhJXaP4Ttp8IJ4KUI pQ2jTF80K6sKnpjbSnoAd7LtcnABdtxEQUG31KGZ19E43PpEJvN7oNKtz+wxnrcJTRLu 4XI1jBM0/w7YXB9m60l0fbf02lxgougiKTbHsS7gQEsH79xmSczrKprCGckD1bmwWutb uT3fECf91d3MNKijwKcFYqurMyO+togdtpZLgdMO6tgnXSGJi2wD06HRoiTKKzhy2khH 3QZ6wxZlmukE20vP3hfVXDUUeCAluhNMobpCPoNlWikPR18U7jS1AKapJ4ZtV/J6PLf4 UXDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469145; x=1783073945; 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; bh=Dz1pu6mWfW58JROqNGnbicb8BcOiLwuqIScXaYTXhqU=; b=YpNLsDgP7M7d/5SkDwkzye2Lw/f09/iOECeM7n9CaMovHtR/J5+WJmzJaY0DC8wWF7 +mtWalVIRlgQW8BaxpdPtfusSQ5DVXoQcVwtmjuYwB/pelk4M3t2B6rPQZMienJysFcH 3sIQX5LNrOFZH7e8MlPX4ZsRn3xsbZGwi7SjBzJup2fyxiHGxL7iKbSOU26mdXitL5eh RJpF4TC+2lAb5Bvu2r3loAJHVBkGPgUHaiCCiAPo/E1NnUeSAODZwCRYdWulc4IJ525g kdo5Vc63pEXHKLfX324uE23Qkmiea4Lyq+X/WneFSSfCIoATENVeuYx6vx8aDE1aeKwE M48g== X-Gm-Message-State: AOJu0YwRuPqNU/Oi1g8JkchTpxFMGUiPtwLZdV7/vqzarEzVYuZJ8fJh UflA+XeOxe7D1H7LhrJRcld+Pd+3A2PjUKygejl4ZRtKLcr2X+RRpEWkXZDjsSKFScOFck5m2cF l7AFmlN8B+eT5EQWpzBYWVzphH3XIfWY6WZnZpTV9eldK/nKPMAF0e031qWtuNTsyyeF5iWDbNJ SAlyavr459auwE2sFFYC9JsaPV2BFnHQDxKCLTz/0C X-Gm-Gg: AfdE7clgFxwvhqijC657p0MXV73m7fOQccdtkW6Aj/wTTIh9HVJgfbOroHxaZiqzA+V lqBbCGRwaDb7QZBa8yls+jeLUpu7oiImHe5te5hlzPQvlvaQsq5ttLi+hGHGU5UWHcneaS9sXbK Jdss+HlfwiGSRh0Ju5ExV38GSJSAY70GhHTqJ4YeAENxF2xVdXYjC8WQYR797S056MfZUVNlQR3 GlTPKdxqn+BSmomih8S9O80miYe7Xr/rESvrhDEC8PscEb8B/KR+Rm3rcgtyh1w79FOzij5n/eZ noIn5KqF3ED6TdJi2ACxAEJlHWGmj3QvCKE8phJe0MXL6FytxOgLWF8bo0yT4Yvc2I7BHQmZsCR 9JDfVydydLjxY2skB1/pqDomlSPqFBxljSTgn6hBaAQmSicn4Wxf/iyu3zvxm4sOhVe1YljUkF+ QGtqI3/CufbGq5GVK4 X-Received: by 2002:a5d:6e54:0:b0:46f:558:a43e with SMTP id ffacd0b85a97d-46fb6bf2e92mr50999f8f.9.1782469145434; Fri, 26 Jun 2026 03:19:05 -0700 (PDT) X-Received: by 2002:a5d:6e54:0:b0:46f:558:a43e with SMTP id ffacd0b85a97d-46fb6bf2e92mr50934f8f.9.1782469144793; Fri, 26 Jun 2026 03:19:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 27/45] target/i386/mshv: migrate pending ints/excs Date: Fri, 26 Jun 2026 12:17:30 +0200 Message-ID: <20260626101748.1728079-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469364483158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke We use PENDING_INTERRUPTION, INTERRUPT_STATE, PENDING_EVENT hv registers to map and roundtrip from/to CPUX86State. We ignore HV_REGISTER_PENDING_EVENT1 which represent events for nested virt contexts, as we don't support nested virt with MSHV currently. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-30-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/hw/hyperv/hvgdk_mini.h | 3 + include/system/mshv_int.h | 14 +++ target/i386/mshv/mshv-cpu.c | 168 +++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+) diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h index 367519143e2..81fe7f7efb0 100644 --- a/include/hw/hyperv/hvgdk_mini.h +++ b/include/hw/hyperv/hvgdk_mini.h @@ -12,6 +12,9 @@ typedef enum hv_register_name { /* Pending Interruption Register */ HV_REGISTER_PENDING_INTERRUPTION =3D 0x00010002, + HV_REGISTER_INTERRUPT_STATE =3D 0x00010003, + HV_REGISTER_PENDING_EVENT0 =3D 0x00010004, + HV_REGISTER_PENDING_EVENT1 =3D 0x00010005, =20 /* X64 User-Mode Registers */ HV_X64_REGISTER_RAX =3D 0x00020000, diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 3bdf16ecd35..5a30dceeea8 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -17,6 +17,20 @@ #include "hw/hyperv/hvhdk.h" =20 #define MSHV_MSR_ENTRIES_COUNT 64 + +/* + * Interruption-type encoding, used by the hypervisor in + * hv_x64_pending_interruption_register.interruption_type + * See TLFS 6.0 section 7.9.2, p55 + * https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlf= s/tlfs + */ +#define MSHV_HV_INTERRUPTION_TYPE_EXT_INT 0 +#define MSHV_HV_INTERRUPTION_TYPE_NMI 2 +#define MSHV_HV_INTERRUPTION_TYPE_HW_EXC 3 +#define MSHV_HV_INTERRUPTION_TYPE_SW_INT 4 +#define MSHV_HV_INTERRUPTION_TYPE_PRIV_SW_EXC 5 +#define MSHV_HV_INTERRUPTION_TYPE_SW_EXC 6 + #define MSHV_DIRTY_PAGES_BATCH_SIZE 0x10000 =20 typedef struct hyperv_message hv_message; diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index a0a25cd2c05..9f513a0e436 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -535,6 +535,164 @@ static int load_regs(CPUState *cpu) return 0; } =20 +static int get_vcpu_events(CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + struct hv_register_assoc assocs[] =3D { + { .name =3D HV_REGISTER_PENDING_INTERRUPTION }, + { .name =3D HV_REGISTER_INTERRUPT_STATE }, + { .name =3D HV_REGISTER_PENDING_EVENT0 }, + }; + union hv_x64_pending_interruption_register pending_int; + union hv_x64_interrupt_state_register int_state; + union hv_x64_pending_exception_event pending_exc; + int ret; + + ret =3D mshv_get_generic_regs(cpu, assocs, ARRAY_SIZE(assocs)); + if (ret < 0) { + error_report("failed to get vcpu event registers"); + return -1; + } + + pending_int.as_uint64 =3D assocs[0].value.reg64; + int_state.as_uint64 =3D assocs[1].value.reg64; + pending_exc =3D assocs[2].value.pending_exception_event; + + /* Clear previous state. injected ints/excs are blanked w/ -1 */ + env->interrupt_injected =3D -1; + env->soft_interrupt =3D 0; + env->exception_injected =3D 0; + env->exception_pending =3D 0; + env->exception_nr =3D -1; + env->has_error_code =3D 0; + env->error_code =3D 0; + env->exception_has_payload =3D 0; + env->exception_payload =3D 0; + env->nmi_injected =3D 0; + + if (pending_int.interruption_pending) { + switch (pending_int.interruption_type) { + case MSHV_HV_INTERRUPTION_TYPE_EXT_INT: + env->interrupt_injected =3D pending_int.interruption_vector; + break; + case MSHV_HV_INTERRUPTION_TYPE_NMI: + env->nmi_injected =3D 1; + break; + case MSHV_HV_INTERRUPTION_TYPE_HW_EXC: + env->exception_injected =3D 1; + env->exception_nr =3D pending_int.interruption_vector; + env->has_error_code =3D pending_int.deliver_error_code; + env->error_code =3D pending_int.error_code; + break; + case MSHV_HV_INTERRUPTION_TYPE_SW_INT: + env->interrupt_injected =3D pending_int.interruption_vector; + env->soft_interrupt =3D 1; + break; + case MSHV_HV_INTERRUPTION_TYPE_SW_EXC: + case MSHV_HV_INTERRUPTION_TYPE_PRIV_SW_EXC: + env->exception_injected =3D 1; + env->exception_nr =3D pending_int.interruption_vector; + env->has_error_code =3D pending_int.deliver_error_code; + env->error_code =3D pending_int.error_code; + break; + default: + error_report("unknown interruption type %u", + pending_int.interruption_type); + return -EINVAL; + } + } + + /* disabled for one instr after STI, MOV/POP SS, see hvf_store_events(= ) */ + if (int_state.interrupt_shadow) { + env->hflags |=3D HF_INHIBIT_IRQ_MASK; + } else { + env->hflags &=3D ~HF_INHIBIT_IRQ_MASK; + } + + /* see kvm_get_vcpu_events(), hvf_store_events() */ + if (int_state.nmi_masked) { + env->hflags2 |=3D HF2_NMI_MASK; + } else { + env->hflags2 &=3D ~HF2_NMI_MASK; + } + + /* HV_REGISTER_PENDING_EVENT0: pending exception not yet injected */ + if (pending_exc.event_pending) { + env->exception_pending =3D 1; + env->exception_nr =3D pending_exc.vector; + env->has_error_code =3D pending_exc.deliver_error_code; + env->error_code =3D pending_exc.error_code; + env->exception_has_payload =3D (pending_exc.exception_parameter != =3D 0); + env->exception_payload =3D pending_exc.exception_parameter; + } + + /* + * Ignoring HV_REGISTER_PENDING_EVENT1, virtualization fault events, M= SHV + * does not support nested virtualization. + */ + + return 0; +} + +static int set_vcpu_events(const CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + union hv_x64_pending_interruption_register pending_int =3D { 0 }; + union hv_x64_interrupt_state_register int_state =3D { 0 }; + union hv_x64_pending_exception_event pending_exc =3D { 0 }; + struct hv_register_assoc assocs[3]; + int ret; + + /* build pending_int from CPUX86State */ + if (env->exception_injected) { + pending_int.interruption_pending =3D 1; + pending_int.interruption_type =3D MSHV_HV_INTERRUPTION_TYPE_HW_= EXC; + pending_int.interruption_vector =3D env->exception_nr; + pending_int.deliver_error_code =3D env->has_error_code; + pending_int.error_code =3D env->error_code; + } else if (env->nmi_injected) { + pending_int.interruption_pending =3D 1; + pending_int.interruption_type =3D MSHV_HV_INTERRUPTION_TYPE_NMI; + pending_int.interruption_vector =3D EXCP02_NMI; + } else if (env->interrupt_injected >=3D 0) { + pending_int.interruption_pending =3D 1; + pending_int.interruption_type =3D env->soft_interrupt + ? MSHV_HV_INTERRUPTION_TYPE_SW_INT + : MSHV_HV_INTERRUPTION_TYPE_EXT_INT; + pending_int.interruption_vector =3D env->interrupt_injected; + } + + /* build int_state, normalize to bool */ + int_state.interrupt_shadow =3D !!(env->hflags & HF_INHIBIT_IRQ_MASK); + int_state.nmi_masked =3D !!(env->hflags2 & HF2_NMI_MASK); + + /* build pending_exc */ + if (env->exception_pending) { + pending_exc.event_pending =3D 1; + pending_exc.vector =3D env->exception_nr; + pending_exc.deliver_error_code =3D env->has_error_code; + pending_exc.error_code =3D env->error_code; + pending_exc.exception_parameter =3D env->exception_payload; + } + + assocs[0].name =3D HV_REGISTER_PENDING_INTERRUPTION; + assocs[0].value.reg64 =3D pending_int.as_uint64; + assocs[1].name =3D HV_REGISTER_INTERRUPT_STATE; + assocs[1].value.reg64 =3D int_state.as_uint64; + assocs[2].name =3D HV_REGISTER_PENDING_EVENT0; + assocs[2].value.pending_exception_event =3D pending_exc; + + ret =3D mshv_set_generic_regs(cpu, assocs, ARRAY_SIZE(assocs)); + if (ret < 0) { + error_report("failed to set vcpu event registers"); + return -1; + } + + return 0; +} + int mshv_arch_load_vcpu_state(CPUState *cpu) { int ret; @@ -559,6 +717,11 @@ int mshv_arch_load_vcpu_state(CPUState *cpu) return ret; } =20 + ret =3D get_vcpu_events(cpu); + if (ret < 0) { + return ret; + } + return 0; } =20 @@ -1100,6 +1263,11 @@ int mshv_arch_store_vcpu_state(const CPUState *cpu) return ret; } =20 + ret =3D set_vcpu_events(cpu); + if (ret < 0) { + return ret; + } + return 0; } =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469176; cv=none; d=zohomail.com; s=zohoarc; b=iDepHHkeVqxXza0f26eMC5V+sfiWVtv/9pSb/f2ASYa6YQ7UJzQJzB5b9dTtz1o+8c6Padx+Ao2HBs5dxcxjs6CqT4TH6DMDn8QcuS2qYiqo14dGp7GcqFtMhe2BmEH+dJdr7moeGeqVV3qPLQ/CLX9zEgA5P5861oqJMQ5qxWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469176; 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=hWzuLmfM5mOqM+9k40W+ZwF1xU/OB7680Gl9q1U09qY=; b=IqsHcTsf0J+s4lnkrQf/gVn7rcAsMZokf/FoAzagAETfmp3xOiozqhJIGaYfX1M6WNSsf4aYBBTbAuNzs5UGFgVC5CTmUwAiT9R824BXF08XSRSqNaeYxILDRvgRVh36GpRSd8BLltHlewFt8CcaZC1n1gBoU1hQ2s495EvhKLk= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469176381140.08182534806656; Fri, 26 Jun 2026 03:19:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ea-0000ts-UZ; Fri, 26 Jun 2026 06:19:21 -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 1wd3eT-0000Sc-8S for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eR-0005Mj-6w for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:12 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-SbyUcD7OMqye3qL-If5fVw-1; Fri, 26 Jun 2026 06:19:09 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-492488f8583so8532025e9.2 for ; Fri, 26 Jun 2026 03:19:09 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fce5a8sm66578015e9.3.2026.06.26.03.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hWzuLmfM5mOqM+9k40W+ZwF1xU/OB7680Gl9q1U09qY=; b=W5vZKDJLk7IB3ppiGD3Y+Vd1L6axU1tibn2k3VQCbytazhRl9a5/g04ZAsBsdVQwWokAGg m0PJS3kDoxtkIRCA1Oiuc9cBCsN4jXHNGgGQ40X+iOMv7V9nAA3ROa32bAyu5tAC1uRWPH 1EPyalJZ4AdY8Ct4TxkqNJ9u/sCm6Lw= X-MC-Unique: SbyUcD7OMqye3qL-If5fVw-1 X-Mimecast-MFC-AGG-ID: SbyUcD7OMqye3qL-If5fVw_1782469148 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469148; x=1783073948; 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; bh=hWzuLmfM5mOqM+9k40W+ZwF1xU/OB7680Gl9q1U09qY=; b=ZthsGFDPc2OLTQqzpAOnGkoUV3LQ4Rkk4n3MCoLbfAh0m4RJ9Y1bWQPz8eTCQEp0yo g3y1oXnhxyyPmhkE84LBN206RERsW6o4UpF0pRAHZarny3JNrhsa6AD6bGYlEtV9JT2c 89MzCuUx1lgVerkw4HX1uJmCauOZB7qX5KPJSA4MJ+Gc5Dl5EeN5T9+yVR4DOa/pfTvM zhS1UTjqgLhPtvSGCUErxLNniCSdf7K8eGcTI7hkgc4mgKLjUqoLbeBkBXgJOWKqG6Yl k25lMFwwn4v64PKixs8sRaAsZDOaiR0k5znLSZDwyK+gpu8e4SdX6cnsGIk4hXjBZJcI PGJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469148; x=1783073948; 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; bh=hWzuLmfM5mOqM+9k40W+ZwF1xU/OB7680Gl9q1U09qY=; b=aisZo/4glAA/VzUxJMg0/3yH5/T5rHizz/VL1JHlKx5ZnNSz9s7nqRHBKRIv44KSN3 CVcuzlE1UG7iEqUvoB6uQqdjR8eo1SynQ2OkbEiXo5YjybAAntHSG8U28wwTYHiuvG+n GQ13xZGeKB/O+mdVAJNuvUEL5fd5GV63sXR7bZxFjZv+oXxMEtmLI3IJ0MRn4RkuD3vV GWYq/Ina5xN2iN1OnGReWtTq+iNShfTwMCYwTlSlAZVkMSdL5keiwkIxsCdvzsUmNW9Q AJlXFuo73Hnzhs6SoSKVkHG90g/85HF99/uHrZhG/DHp+q5a0Ol/9vUfty3LSlhn3tua joOw== X-Gm-Message-State: AOJu0YzYKIOYrraNNq/bAkXMaXyXrMrUK2OtLfidm0fU4cKhcUAwLsgd wONv2en3kOZmmKoXqKk2e9dPQBASYq5wybmrSb2Y60RuTBJZDT+62tl4tX/eA3Kohy64oudWItK OJ5QWxZXRCmuHaaJtA5n2/bUkUXZtpZM8tOMMt3KEws2rkgDQCOvRjDJj19PMjVmHjbuOdXMtrx yj9z9um+Uv2JkTh3kBMSSBVqrXOUqZTebAnQSvw/Lk X-Gm-Gg: AfdE7cljZlJo0Zm6IH35eB1sQsuSe2NjzUsqWy6RxkfL7Cg3lEXUqWsV4KdX2dGEXGr Kng3WaEXwILbMd0nefp/6uSq4GdXE9lkBAuiuYUJVMqPfNegNC9Uo78msgSxQIon+KfddrLoHza beLH8i7NiaZa63hjQutr8XOK8eNDyyz2AolbpS/SoN1IIcB6QCSCp0tRoZ+ecrXd5gfi/8aohE1 jaA6fZpb+Sue73DplgeZhWmJRX8/AgZHu11JK2D/AOagTSy881yxFr5m/1ghOeQLBmkstsJJ4RP zv1gdN5U4BTZjCyetJAkiyvaPsGpRqlOut7W9ieuUDanowuedtQYaTjeU5MWqUHDa/gLrog9Cqk lZLAIQXDZnyKoo4jsD0CQcvCdpvrKAGGM2n+aHTEJgK32V/UZk1+Pn7QJ0qk1j+JgFfYVedVGne g70Pb0qM3EhNkc08f2 X-Received: by 2002:a05:600c:c4aa:b0:492:3445:ecf8 with SMTP id 5b1f17b1804b1-4926685fe2dmr88348825e9.3.1782469147940; Fri, 26 Jun 2026 03:19:07 -0700 (PDT) X-Received: by 2002:a05:600c:c4aa:b0:492:3445:ecf8 with SMTP id 5b1f17b1804b1-4926685fe2dmr88348105e9.3.1782469147339; Fri, 26 Jun 2026 03:19:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 28/45] target/i386/mshv: migrate XSAVE state Date: Fri, 26 Jun 2026 12:17:31 +0200 Message-ID: <20260626101748.1728079-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469177291158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke We implement fn's that roundtrip XSAVE state in migration. We are using the xsave_helper routines to move individual components from CPUX86State to an xsave_buf and then we have to compact the buffer to XSAVEC format, which is what the hypervisor expects. And the same applies in the other direction for restoring state from the hypervisor. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-32-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 100 +++++++++++++++++++++++++++++++++++- target/i386/meson.build | 2 +- 2 files changed, 100 insertions(+), 2 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 9f513a0e436..bbf874f6413 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -112,6 +112,78 @@ static enum hv_register_name FPU_REGISTER_NAMES[26] = =3D { =20 static int set_special_regs(const CPUState *cpu); =20 +static int get_xsave_state(CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + int cpu_fd =3D mshv_vcpufd(cpu); + int ret; + void *xsavec_buf; + const size_t page =3D HV_HYP_PAGE_SIZE; + size_t xsavec_buf_len =3D page; + + /* TODO: should properly determine xsavec size based on CPUID */ + xsavec_buf =3D qemu_memalign(page, xsavec_buf_len); + memset(xsavec_buf, 0, xsavec_buf_len); + + struct mshv_get_set_vp_state args =3D { + .type =3D MSHV_VP_STATE_XSAVE, + .buf_sz =3D xsavec_buf_len, + .buf_ptr =3D (uintptr_t)xsavec_buf, + }; + + ret =3D ioctl(cpu_fd, MSHV_GET_VP_STATE, &args); + if (ret < 0) { + error_report("failed to get xsave state: %s", strerror(errno)); + return -errno; + } + + ret =3D decompact_xsave_area(xsavec_buf, xsavec_buf_len, env); + g_free(xsavec_buf); + if (ret < 0) { + error_report("failed to decompact xsave area"); + return ret; + } + x86_cpu_xrstor_all_areas(x86cpu, env->xsave_buf, env->xsave_buf_len); + + return 0; +} + +static int set_xsave_state(const CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + int cpu_fd =3D mshv_vcpufd(cpu); + int ret; + void *xsavec_buf; + size_t page =3D HV_HYP_PAGE_SIZE, xsavec_buf_len; + + /* allocate and populate compacted buffer */ + xsavec_buf =3D qemu_memalign(page, page); + xsavec_buf_len =3D page; + + /* save registers to standard format buffer */ + x86_cpu_xsave_all_areas(x86cpu, env->xsave_buf, env->xsave_buf_len); + + /* store compacted version of xsave area in xsavec_buf */ + compact_xsave_area(env, xsavec_buf, xsavec_buf_len); + + struct mshv_get_set_vp_state args =3D { + .type =3D MSHV_VP_STATE_XSAVE, + .buf_sz =3D xsavec_buf_len, + .buf_ptr =3D (uintptr_t)xsavec_buf, + }; + + ret =3D ioctl(cpu_fd, MSHV_SET_VP_STATE, &args); + g_free(xsavec_buf); + if (ret < 0) { + error_report("failed to set xsave state: %s", strerror(errno)); + return -errno; + } + + return 0; +} + static void populate_fpu(const hv_register_assoc *assocs, X86CPU *x86cpu) { union hv_register_value value; @@ -717,6 +789,11 @@ int mshv_arch_load_vcpu_state(CPUState *cpu) return ret; } =20 + ret =3D get_xsave_state(cpu); + if (ret < 0) { + return ret; + } + ret =3D get_vcpu_events(cpu); if (ret < 0) { return ret; @@ -1263,6 +1340,11 @@ int mshv_arch_store_vcpu_state(const CPUState *cpu) return ret; } =20 + ret =3D set_xsave_state(cpu); + if (ret < 0) { + return ret; + } + ret =3D set_vcpu_events(cpu); if (ret < 0) { return ret; @@ -1817,9 +1899,10 @@ void mshv_arch_init_vcpu(CPUState *cpu) X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; AccelCPUState *state =3D cpu->accel; - size_t page =3D HV_HYP_PAGE_SIZE; + size_t page =3D HV_HYP_PAGE_SIZE, xsave_len; void *mem =3D qemu_memalign(page, 2 * page); int ret; + X86XSaveHeader *header; =20 /* sanity check, to make sure we don't overflow the page */ QEMU_BUILD_BUG_ON((MAX_REGISTER_COUNT @@ -1833,6 +1916,17 @@ void mshv_arch_init_vcpu(CPUState *cpu) =20 env->emu_mmio_buf =3D g_new(char, 4096); =20 + /* Initialize XSAVE buffer page-aligned */ + /* TODO: pick proper size based on CPUID */ + xsave_len =3D page; + env->xsave_buf =3D qemu_memalign(page, xsave_len); + env->xsave_buf_len =3D xsave_len; + memset(env->xsave_buf, 0, env->xsave_buf_len); + + /* we need to set the compacted format bit in xsave header for mshv */ + header =3D (X86XSaveHeader *)(env->xsave_buf + sizeof(X86LegacyXSaveAr= ea)); + header->xcomp_bv =3D header->xstate_bv | (1ULL << 63); + /* * TODO: populate topology info: * X86CPUTopoInfo *topo_info =3D &env->topo_info; @@ -1857,6 +1951,10 @@ void mshv_arch_destroy_vcpu(CPUState *cpu) g_free(state->hvcall_args.base); state->hvcall_args =3D (MshvHvCallArgs){0}; g_clear_pointer(&env->emu_mmio_buf, g_free); + + qemu_vfree(env->xsave_buf); + env->xsave_buf =3D NULL; + env->xsave_buf_len =3D 0; } =20 uint32_t mshv_get_supported_cpuid(uint32_t func, uint32_t idx, int reg) diff --git a/target/i386/meson.build b/target/i386/meson.build index 80062d1d0d8..b4fbf8a5374 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -12,7 +12,7 @@ i386_ss.add(when: 'CONFIG_KVM', if_true: files('xsave_hel= per.c', 'host-cpu.c')) i386_ss.add(when: 'CONFIG_HVF', if_true: files('xsave_helper.c', 'host-cpu= .c')) i386_ss.add(when: 'CONFIG_WHPX', if_true: files('xsave_helper.c', 'host-cp= u.c')) i386_ss.add(when: 'CONFIG_NVMM', if_true: files('host-cpu.c')) -i386_ss.add(when: 'CONFIG_MSHV', if_true: files('host-cpu.c')) +i386_ss.add(when: 'CONFIG_MSHV', if_true: files('xsave_helper.c', 'host-cp= u.c')) =20 i386_system_ss =3D ss.source_set() i386_system_ss.add(files( --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469283; cv=none; d=zohomail.com; s=zohoarc; b=JKD4bJUNlT+nciN1TVBHn6u5qn8S0lFTSSYdn2ol+dLtVBy7mXpZIgL4aJiRzWQNPK+oLDTBye/b+6hVAIG2F6Or4X8+6yJ3OzMfjSpUd1JjQY7gfaiFx/sw1r2wLFfL1fTxP14yVnP7we4oBDaI8UgHnAPmileUStbaGGRVLao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469283; 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=3FPFtWK7Hdsxwe36pUBqav5XMaIfU9fErfGMcCg2SxE=; b=jxiUYzBMLuIZD9imgPx/gcJzWViFYN5YMyIMhZVziUXGxTJ0/+M3/PC7I34FAJ57qi3fkHk9LS8gXxchBWhLzn+/dpYC5K6efQaNIuiDIPNHRes0leOI0dAjxra8sWqM7TxjRcHdaajvRrOGC74zXRTxhVEjULOPcWnRk/avk08= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469283042501.71560116434307; Fri, 26 Jun 2026 03:21:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ec-00010o-EF; Fri, 26 Jun 2026 06:19:22 -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 1wd3eU-0000Zd-Nt for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eT-0005N1-1u for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:14 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-YaYKYSK0NWSnZp1Hdwyeug-1; Fri, 26 Jun 2026 06:19:11 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-490b4d3d3e6so6054405e9.0 for ; Fri, 26 Jun 2026 03:19:11 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c1b754471sm22958631f8f.0.2026.06.26.03.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3FPFtWK7Hdsxwe36pUBqav5XMaIfU9fErfGMcCg2SxE=; b=MeFLt/psNpf1kcecarZA+JJvuGCU6A/QtpNFynK9EEqvLpqrEEtprNX2aWcbUKbaTauWA+ xOd4AWZ29kF2zGLiXzFfU3WhXYp3pJs4LGY7tKFfP4mTH6+pd5YDRjahMwqLT1+TAFeTje 6AzYlHRvQ7suSkXR8mA0jhFNdruqwG8= X-MC-Unique: YaYKYSK0NWSnZp1Hdwyeug-1 X-Mimecast-MFC-AGG-ID: YaYKYSK0NWSnZp1Hdwyeug_1782469150 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469150; x=1783073950; 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; bh=3FPFtWK7Hdsxwe36pUBqav5XMaIfU9fErfGMcCg2SxE=; b=p2v00i3AvWQjewibzoqIb6p38mI4SKeE+v/7vqk3aoe4Um4wfDc5kQQHR/5ajwfqmz zrjhXMtNIi+mxQ4bd9CRBVueQrt8ImVJyBKB04AqDNuy2PTYBZTSsOlRt1PzGt9TUdwr W1qReHSRXLCSt3fbSBk4IfBTLVlo4Zt/RoNNEgAuWaqVJwZlzMTULUnfEEKPRK4/VShq Y9bj2MITu+eNTXFucHn5SG6dE3GcmdNDbLPHB2O1CAbHOjYZIxiGNeFY21WGuJxkT0EM B0+XCQKpcMRIFn008CJkCbUdIeFR5a3GQX7Q/3CbyA0U0jMTMJk3dGw2idDmgK4UEJ1E EjkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469150; x=1783073950; 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; bh=3FPFtWK7Hdsxwe36pUBqav5XMaIfU9fErfGMcCg2SxE=; b=nOtaZ51vC13abi+WveQEpZ0W3D2q9K9JnuogLgixFhTKhWg5QRLve0RGci7WY596/L LaoK0Yxs1NVsd7kGZtDHekMdMQG2b6xZB3EyfwyIi2vnSPaaffE10WCjwfyCFZevJZEK f7taDnY8TLfi0aAIq0twvwRcDRfF6fZpiCDnRJ2QXEdi7KwsX3eczYqsRMpkh/Nyn1V1 HQXA1G1NupKzVZSJr3OZbXyKQSFO072rp+CUieU0I3xfeIcSEBlkH3R4tHzMi70YMjTN P2YHCFE6uOrOxL+H2xs1t+EZr7Xd+c3rPT6a3x4s7F8gI0pJYRr8pNaGwie+2SoctEoG R8Fg== X-Gm-Message-State: AOJu0YzgjCC4VKzLu0ozKUMEsNIzVcyX5Hpiqup1YAgYH76yX2PqrCyq 8Tq0zv0nu52CfGVETi1p9giLl3kMV8QPvToYmMiEqu5ksSOEu52eE330JoYNsGwiG/cvZ4WvrjG U+1V7S6307h7N+TObQstnJUnoo4rJbGF3++x01oJ+VI3WwaBWzU+0zWXGq2csrmJHS/pvzlKPR6 Q/9EDfnKTQZ6w+GwYHMWRe224IwBEBwQxMnl5pk4iI X-Gm-Gg: AfdE7clhegk97duJ7yIMmsASlpwxyCLHn3JvY0OOSZ7tNXY9qTcA7WyoqvnoS6c1rQT eJondEdJmwuc6XB/PHKPHI4xQKx46Oj/nhtGMHNCb0cR7n2wjDgO8Q6VfCFxcVnr540NrEEt4FX kC9cLKZYsE2Zy82ntjhjXAlIkYWNa9TBfcRNHdLw2lWHkTwqDSD8RIrj/pu/CQ1FJFRWbVTcPfJ cakxEOwuif5y0mnqfbBeU7LVc3+8BQutJ3X0/ROtO6rVEpw4dFiXgVt25+gl6GBOyyt5f8wCGU7 WtVHlTKWqS0VbpcjQrvf0827WlEVbtV+Nz1UjC/+zim3Lt9vaGMuCxkQMuHXiQT7TyHCN+py4+6 6Pto+t/OzonQO63xDIsVM8wofusHZl3d0vE4PfK6GkSAoIdz4RyB3hmVaGO0Ih9f+lbRXFFB0UF RsJgBBi1oOB+0IFK1o X-Received: by 2002:a05:600c:82cd:b0:492:48c8:c705 with SMTP id 5b1f17b1804b1-4926fc2fa58mr1600735e9.1.1782469150088; Fri, 26 Jun 2026 03:19:10 -0700 (PDT) X-Received: by 2002:a05:600c:82cd:b0:492:48c8:c705 with SMTP id 5b1f17b1804b1-4926fc2fa58mr1600285e9.1.1782469149586; Fri, 26 Jun 2026 03:19:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 29/45] target/i386/mshv: reconstruct hflags after load Date: Fri, 26 Jun 2026 12:17:32 +0200 Message-ID: <20260626101748.1728079-30-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469283915158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke hflags is a cached bitmap derived from standard and special regs. We want to reconstruct this state after regs and sregs have been read from the hypervisor, similar to how it's one in other accelerators. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-33-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index bbf874f6413..8bd63bd9628 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -765,6 +765,16 @@ static int set_vcpu_events(const CPUState *cpu) return 0; } =20 +static int update_hflags(CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + + x86_update_hflags(env); + + return 0; +} + int mshv_arch_load_vcpu_state(CPUState *cpu) { int ret; @@ -779,6 +789,9 @@ int mshv_arch_load_vcpu_state(CPUState *cpu) return ret; } =20 + /* INVARIANT: hflags are derived from regs+sregs, need to get both fir= st */ + update_hflags(cpu); + ret =3D get_xc_reg(cpu); if (ret < 0) { return ret; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469342; cv=none; d=zohomail.com; s=zohoarc; b=c7k2AOqqjAp26cvjobjJZnJZhHjyGkvU2p17iksJGKFN1fksBwYseEwA64p8/fXdBAcB+2ZctymJINv6zO6yygOyIZxQkOgSjhvq4yKgm6pDdWkrurSYL4cVNLHd1yLyLfmfGJpTL6ibNKysNZm/SS8j6d2b/UC1zmgTm1iGVok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469342; 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=o5qTe4qQrXMwNdhcjN8qbG5KKgxfqPRAjc19lPqN684=; b=Hj/KEFSqjqmqflZ0Bf39aK5GFniUhGb0f2zU+eB4wjR6BbglyQl8DosqCUlzmIuyIdxqXRfOxu7CWxx9PJnUQjOKcsLMoLeIXfuVhQFyr4UbZJYDHFnrKnCqmteL5aHPbuA2hfE0+0DLNHPf+ExqLwTcHR0V1j5VGavSfR/H+bw= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469342340666.1957657036507; Fri, 26 Jun 2026 03:22:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ec-00012l-P8; Fri, 26 Jun 2026 06:19:22 -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 1wd3eZ-0000qI-EX for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eW-0005NN-9r for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:19 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-220-cxjWObpPM2akDTDhlCn6Ig-1; Fri, 26 Jun 2026 06:19:14 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-490c56e2576so5483315e9.3 for ; Fri, 26 Jun 2026 03:19:13 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4926c291489sm35258525e9.2.2026.06.26.03.19.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469155; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o5qTe4qQrXMwNdhcjN8qbG5KKgxfqPRAjc19lPqN684=; b=ImUWlrrdUjAb1v2LKePWJEc0pKyWsvy2eKPoI1ne6l5Uukl8w6T39J5bULjvfw/h38YsTi cwpzXKGaAJSs6KfGlvDwXejleN5JcyL2sTWsEUaIlkfW4qhF524pI/VDin0meuL1MPHszv ESIE2lnVhFUPeb+geelduTXdyc7SVdA= X-MC-Unique: cxjWObpPM2akDTDhlCn6Ig-1 X-Mimecast-MFC-AGG-ID: cxjWObpPM2akDTDhlCn6Ig_1782469153 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469153; x=1783073953; 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; bh=o5qTe4qQrXMwNdhcjN8qbG5KKgxfqPRAjc19lPqN684=; b=Xj5uKEiAFWVdJd+21qWhe8WXBKqhBOqXF9nJnd+66SVB0LMpvSSpQWkRFphxLe5Ne7 ZmaL8WH+ApfzuPIdcEcE5KEjk/4IAd9GH6Rm6eoi9XbFgAwapC2iB48KeEBSfoIo4I4/ yMKn6FvhFpwbiKyMzzf21c56oj0UKalDUO1x5zS7g617UpcPb042oogwyFh/jACWFkmx PD+2H52vdFtOB4CUQfQq/NkJ8mK7mdG1HwTarIfaAF3A9FOIXR/6nFqZR1DfWPCE2zD7 RBdw8Vosdk6huSjXKJLeJgFoWGHlrfpx2jNrIRujlQBs3ZKbNwCkmnOA/KqfEFBiG/vN lJKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469153; x=1783073953; 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; bh=o5qTe4qQrXMwNdhcjN8qbG5KKgxfqPRAjc19lPqN684=; b=fEhgze4HHm97za9KB+EFe/lUmXA3xGMFMyckNzFr0SGAN46kobIWRGNTcTreHAimCn HP1MCVwQN0eUB79cVrLyP9IP4uCHxROd1jokvjU7D8AZnKI1YZN4swWLvg9Y0F8Ogs50 qfPwXC7f18AH3ZuxoEfvUQniL+GxArpepdX7s5Qt/rUXHuntY92Z+8fj8O7dZ6WsEqL9 3bpjzpwE9Ur0eccHEd67GfVSZ464cIP8qazksTJVVUhrTyubUnqVip9ehwMD9UeF1YUZ XLK509Wh73hT3izyjQSTJ8DRbZXe44TtWdxBahcC9WLQ+GOMg6tlcKlxY/xJOUG+rCZ4 RC5g== X-Gm-Message-State: AOJu0Yy84SD6ub+vPIU0KrA+lbgvkwoELoicFDx5Ku0ilxzFZQ238yTW cHgeloUfn2UrqDk6hJGFaYBQ9BQ7cqRfxrdXbJD34OiTTTicoqwoH69LHGxlr53jrmNDdTICzVG fnRvgNJriv89LeYMohmd3+PN3Ny3wBd8syWAtgdeUMgt680L/AfrWo3oAnVC+4Cw0T/7/jzgfBf UrdlSxS6uQMOf1cX7RgmlDbsn5wgA8ZYFFLJ4XXtMi X-Gm-Gg: AfdE7clKMW/+xbejo49C86s708yVLo52K0sTCPrMkkUIv7yZPffBr+62r69PKiIZKZE UtrFMPiOIYYYEV4vchxtT6dEklmD+4COEDw0BuRPt+JV5KJVEOwiWmjwavPjw379dApvWAOuvUI stClhHwHhuGTBujM1i15ukLiNo6lAL5KVUyayy0y3uexJEEZ/9RA6r1E3OOjvOxNqJMJHZanyUU pLCRm8KAL1vWrNdlXD9tcH2razE9G9mwvl9xkNeCrm2Xpjq9gepUmOPshdgVQNp6ogBqxrl0fMF C4Hl29q80BMo2h+MrA+8acqz8d2S0XFwSJn9KW95Vt9ge80ftszXKWvl9Zofzw6R57Ie7iREAMU LozNllEx7+DcNZfs6MbwC8vKUelBBKSLVYOBVxdaZZ6CwG2vJPIpIa261yf32aR94MlGbLmqJgR hs3fipW7Mf6Qn2CN+U X-Received: by 2002:a05:600c:6094:b0:490:da12:f1fa with SMTP id 5b1f17b1804b1-4926689343bmr91711195e9.31.1782469152420; Fri, 26 Jun 2026 03:19:12 -0700 (PDT) X-Received: by 2002:a05:600c:6094:b0:490:da12:f1fa with SMTP id 5b1f17b1804b1-4926689343bmr91710305e9.31.1782469151696; Fri, 26 Jun 2026 03:19:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 30/45] target/i386/mshv: migrate MSRs Date: Fri, 26 Jun 2026 12:17:33 +0200 Message-ID: <20260626101748.1728079-31-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469344426158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke In this change the we rewrite the existing MSR logic to make MSRs migratable: - we map them on existing QEMU fields in the CPU. A table and a macro MSHV_ENV_FIELD is used to associate a HV register name to the their msr index and their offset in the cpu state struct. The list is not exhaustive and will be extended in follow-up commits. - mshv_set/get_msrs() fns are called in the arch_load/store_vcpu_state() fns. they use use generic registers ioctl's and map the input/output via load/store_to/from_env() from/to the hv register content to the cpu state representation. - init_msrs() has been moved from mshv-vcpu to the msr source file - we need to perform some filtering of MSR because before writing and reading, because the hvcalls will fail if the partition doesn't support a given MSRs. - Some MSRs are partition-wide and so we will only write the to on the BSP. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-21-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/hw/hyperv/hvgdk_mini.h | 14 + include/system/mshv_int.h | 16 +- target/i386/mshv/mshv-cpu.c | 39 +-- target/i386/mshv/msr.c | 574 ++++++++++++++------------------- 4 files changed, 264 insertions(+), 379 deletions(-) diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h index 81fe7f7efb0..b00ec8a6367 100644 --- a/include/hw/hyperv/hvgdk_mini.h +++ b/include/hw/hyperv/hvgdk_mini.h @@ -9,6 +9,19 @@ =20 #define MSHV_IOCTL 0xB8 =20 +/* Hyper-V specific model specific registers (MSRs) */ + +/* HV_X64_SYNTHETIC_MSR */ +#define HV_X64_MSR_GUEST_OS_ID 0x40000000 +#define HV_X64_MSR_HYPERCALL 0x40000001 +#define HV_X64_MSR_VP_INDEX 0x40000002 +#define HV_X64_MSR_RESET 0x40000003 +#define HV_X64_MSR_VP_RUNTIME 0x40000010 +#define HV_X64_MSR_TIME_REF_COUNT 0x40000020 +#define HV_X64_MSR_REFERENCE_TSC 0x40000021 +#define HV_X64_MSR_TSC_FREQUENCY 0x40000022 +#define HV_X64_MSR_APIC_FREQUENCY 0x40000023 + typedef enum hv_register_name { /* Pending Interruption Register */ HV_REGISTER_PENDING_INTERRUPTION =3D 0x00010002, @@ -161,6 +174,7 @@ typedef enum hv_register_name { HV_X64_REGISTER_MSR_IA32_MISC_ENABLE =3D 0x000800A0, =20 /* Misc */ + HV_X64_REGISTER_HYPERCALL =3D 0x00090001, HV_REGISTER_GUEST_OS_ID =3D 0x00090002, HV_REGISTER_REFERENCE_TSC =3D 0x00090017, =20 diff --git a/include/system/mshv_int.h b/include/system/mshv_int.h index 5a30dceeea8..ba3073888ac 100644 --- a/include/system/mshv_int.h +++ b/include/system/mshv_int.h @@ -129,18 +129,8 @@ bool mshv_log_global_start(MemoryListener *listener, E= rror **errp); void mshv_log_global_stop(MemoryListener *listener); =20 /* msr */ -typedef struct MshvMsrEntry { - uint32_t index; - uint32_t reserved; - uint64_t data; -} MshvMsrEntry; - -typedef struct MshvMsrEntries { - MshvMsrEntry entries[MSHV_MSR_ENTRIES_COUNT]; - uint32_t nmsrs; -} MshvMsrEntries; - -int mshv_configure_msr(const CPUState *cpu, const MshvMsrEntry *msrs, - size_t n_msrs); +int mshv_init_msrs(const CPUState *cpu); +int mshv_get_msrs(CPUState *cpu); +int mshv_set_msrs(const CPUState *cpu); =20 #endif diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 8bd63bd9628..a383e0ab104 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -802,6 +802,11 @@ int mshv_arch_load_vcpu_state(CPUState *cpu) return ret; } =20 + ret =3D mshv_get_msrs(cpu); + if (ret < 0) { + return ret; + } + ret =3D get_xsave_state(cpu); if (ret < 0) { return ret; @@ -1353,6 +1358,11 @@ int mshv_arch_store_vcpu_state(const CPUState *cpu) return ret; } =20 + ret =3D mshv_set_msrs(cpu); + if (ret < 0) { + return ret; + } + ret =3D set_xsave_state(cpu); if (ret < 0) { return ret; @@ -1880,33 +1890,6 @@ void mshv_init_mmio_emu(void) init_emu(&mshv_x86_emul_ops); } =20 -static int init_msrs(const CPUState *cpu) -{ - int ret; - uint64_t d_t =3D MSR_MTRR_ENABLE | MSR_MTRR_MEM_TYPE_WB; - - const struct hv_register_assoc assocs[] =3D { - { .name =3D HV_X64_REGISTER_SYSENTER_CS, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_SYSENTER_ESP, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_SYSENTER_EIP, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_STAR, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_CSTAR, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_LSTAR, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_KERNEL_GS_BASE, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_SFMASK, .value.reg64 =3D 0x= 0 }, - { .name =3D HV_X64_REGISTER_MSR_MTRR_DEF_TYPE, .value.reg64 =3D d_= t }, - }; - QEMU_BUILD_BUG_ON(ARRAY_SIZE(assocs) > MSHV_MSR_ENTRIES_COUNT); - - ret =3D mshv_set_generic_regs(cpu, assocs, ARRAY_SIZE(assocs)); - if (ret < 0) { - error_report("failed to put msrs"); - return -1; - } - - return 0; -} - void mshv_arch_init_vcpu(CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); @@ -1948,7 +1931,7 @@ void mshv_arch_init_vcpu(CPUState *cpu) ret =3D init_cpuid2(cpu); assert(ret =3D=3D 0); =20 - ret =3D init_msrs(cpu); + ret =3D mshv_init_msrs(cpu); assert(ret =3D=3D 0); =20 ret =3D init_lint(cpu); diff --git a/target/i386/mshv/msr.c b/target/i386/mshv/msr.c index e6e5baef507..7447467dbf5 100644 --- a/target/i386/mshv/msr.c +++ b/target/i386/mshv/msr.c @@ -14,362 +14,260 @@ #include "hw/hyperv/hvgdk_mini.h" #include "linux/mshv.h" #include "qemu/error-report.h" +#include "cpu.h" =20 -static uint32_t supported_msrs[64] =3D { - IA32_MSR_TSC, - IA32_MSR_EFER, - IA32_MSR_KERNEL_GS_BASE, - IA32_MSR_APIC_BASE, - IA32_MSR_PAT, - IA32_MSR_SYSENTER_CS, - IA32_MSR_SYSENTER_ESP, - IA32_MSR_SYSENTER_EIP, - IA32_MSR_STAR, - IA32_MSR_LSTAR, - IA32_MSR_CSTAR, - IA32_MSR_SFMASK, - IA32_MSR_MTRR_DEF_TYPE, - IA32_MSR_MTRR_PHYSBASE0, - IA32_MSR_MTRR_PHYSMASK0, - IA32_MSR_MTRR_PHYSBASE1, - IA32_MSR_MTRR_PHYSMASK1, - IA32_MSR_MTRR_PHYSBASE2, - IA32_MSR_MTRR_PHYSMASK2, - IA32_MSR_MTRR_PHYSBASE3, - IA32_MSR_MTRR_PHYSMASK3, - IA32_MSR_MTRR_PHYSBASE4, - IA32_MSR_MTRR_PHYSMASK4, - IA32_MSR_MTRR_PHYSBASE5, - IA32_MSR_MTRR_PHYSMASK5, - IA32_MSR_MTRR_PHYSBASE6, - IA32_MSR_MTRR_PHYSMASK6, - IA32_MSR_MTRR_PHYSBASE7, - IA32_MSR_MTRR_PHYSMASK7, - IA32_MSR_MTRR_FIX64K_00000, - IA32_MSR_MTRR_FIX16K_80000, - IA32_MSR_MTRR_FIX16K_A0000, - IA32_MSR_MTRR_FIX4K_C0000, - IA32_MSR_MTRR_FIX4K_C8000, - IA32_MSR_MTRR_FIX4K_D0000, - IA32_MSR_MTRR_FIX4K_D8000, - IA32_MSR_MTRR_FIX4K_E0000, - IA32_MSR_MTRR_FIX4K_E8000, - IA32_MSR_MTRR_FIX4K_F0000, - IA32_MSR_MTRR_FIX4K_F8000, - IA32_MSR_TSC_AUX, - IA32_MSR_DEBUG_CTL, - HV_X64_MSR_GUEST_OS_ID, - HV_X64_MSR_SINT0, - HV_X64_MSR_SINT1, - HV_X64_MSR_SINT2, - HV_X64_MSR_SINT3, - HV_X64_MSR_SINT4, - HV_X64_MSR_SINT5, - HV_X64_MSR_SINT6, - HV_X64_MSR_SINT7, - HV_X64_MSR_SINT8, - HV_X64_MSR_SINT9, - HV_X64_MSR_SINT10, - HV_X64_MSR_SINT11, - HV_X64_MSR_SINT12, - HV_X64_MSR_SINT13, - HV_X64_MSR_SINT14, - HV_X64_MSR_SINT15, - HV_X64_MSR_SCONTROL, - HV_X64_MSR_SIEFP, - HV_X64_MSR_SIMP, - HV_X64_MSR_REFERENCE_TSC, - HV_X64_MSR_EOM, +#define MSHV_ENV_FIELD(env, offset) (*(uint64_t *)((char *)(env) + (offset= ))) + +typedef struct MshvMsrEnvMap { + uint32_t msr_index; + uint32_t hv_name; + ptrdiff_t env_offset; +} MshvMsrEnvMap; + +/* We assert that 64bit access to sysenter_cs is safe because of padding */ +QEMU_BUILD_BUG_ON(offsetof(CPUX86State, sysenter_esp) - + offsetof(CPUX86State, sysenter_cs) + < sizeof(uint64_t)); + +/* Those MSRs have a direct mapping to fields in CPUX86State */ +static const MshvMsrEnvMap msr_env_map[] =3D { + /* Architectural */ + { IA32_MSR_EFER, HV_X64_REGISTER_EFER, offsetof(CPUX86State, efer) }, + { IA32_MSR_PAT, HV_X64_REGISTER_PAT, offsetof(CPUX86State, pat) }, + + /* Syscall */ + { IA32_MSR_SYSENTER_CS, HV_X64_REGISTER_SYSENTER_CS, + offsetof(CPUX86State, sysenter_cs) }, + { IA32_MSR_SYSENTER_ESP, HV_X64_REGISTER_SYSENTER_ESP, + offsetof(CPUX86State, sysenter_esp) }, + { IA32_MSR_SYSENTER_EIP, HV_X64_REGISTER_SYSENTER_EIP, + offsetof(CPUX86State, sysenter_eip) }, + { IA32_MSR_STAR, HV_X64_REGISTER_STAR, + offsetof(CPUX86State, star) }, + { IA32_MSR_LSTAR, HV_X64_REGISTER_LSTAR, + offsetof(CPUX86State, lstar) }, + { IA32_MSR_CSTAR, HV_X64_REGISTER_CSTAR, + offsetof(CPUX86State, cstar) }, + { IA32_MSR_SFMASK, HV_X64_REGISTER_SFMASK, + offsetof(CPUX86State, fmask) }, + { IA32_MSR_KERNEL_GS_BASE, HV_X64_REGISTER_KERNEL_GS_BASE, + offsetof(CPUX86State, kernelgsbase) }, + + /* TSC-related */ + { IA32_MSR_TSC, HV_X64_REGISTER_TSC, + offsetof(CPUX86State, tsc) }, + { IA32_MSR_TSC_AUX, HV_X64_REGISTER_TSC_AUX, + offsetof(CPUX86State, tsc_aux) }, + { IA32_MSR_TSC_ADJUST, HV_X64_REGISTER_TSC_ADJUST, + offsetof(CPUX86State, tsc_adjust) }, + + /* Hyper-V per-partition MSRs */ + { HV_X64_MSR_HYPERCALL, HV_X64_REGISTER_HYPERCALL, + offsetof(CPUX86State, msr_hv_hypercall) }, + { HV_X64_MSR_GUEST_OS_ID, HV_REGISTER_GUEST_OS_ID, + offsetof(CPUX86State, msr_hv_guest_os_id) = }, + { HV_X64_MSR_REFERENCE_TSC, HV_REGISTER_REFERENCE_TSC, + offsetof(CPUX86State, msr_hv_tsc) }, + + /* Hyper-V MSRs (non-SINT) */ + { HV_X64_MSR_SCONTROL, HV_REGISTER_SCONTROL, + offsetof(CPUX86State, msr_hv_synic_control) }, + { HV_X64_MSR_SIEFP, HV_REGISTER_SIEFP, + offsetof(CPUX86State, msr_hv_synic_evt_page) }, + { HV_X64_MSR_SIMP, HV_REGISTER_SIMP, + offsetof(CPUX86State, msr_hv_synic_msg_page) }, + + /* Other */ + + /* TODO: find out processor features that correlate to unsupported MSR= s. */ + /* { IA32_MSR_MISC_ENABLE, HV_X64_REGISTER_MSR_IA32_MISC_ENABLE, */ + /* offsetof(CPUX86State, msr_ia32_misc_enable)= }, */ + /* { IA32_MSR_BNDCFGS, HV_X64_REGISTER_BNDCFGS, */ + /* offsetof(CPUX86State, msr_bndcfgs) }, */ + { IA32_MSR_SPEC_CTRL, HV_X64_REGISTER_SPEC_CTRL, + offsetof(CPUX86State, spec_ctrl) }, }; -static const size_t msr_count =3D ARRAY_SIZE(supported_msrs); =20 -static int compare_msr_index(const void *a, const void *b) +int mshv_init_msrs(const CPUState *cpu) { - return *(uint32_t *)a - *(uint32_t *)b; -} - -__attribute__((constructor)) -static void init_sorted_msr_map(void) -{ - qsort(supported_msrs, msr_count, sizeof(uint32_t), compare_msr_index); -} - -static int mshv_is_supported_msr(uint32_t msr) -{ - return bsearch(&msr, supported_msrs, msr_count, sizeof(uint32_t), - compare_msr_index) !=3D NULL; -} - -static int mshv_msr_to_hv_reg_name(uint32_t msr, uint32_t *hv_reg) -{ - switch (msr) { - case IA32_MSR_TSC: - *hv_reg =3D HV_X64_REGISTER_TSC; - return 0; - case IA32_MSR_EFER: - *hv_reg =3D HV_X64_REGISTER_EFER; - return 0; - case IA32_MSR_KERNEL_GS_BASE: - *hv_reg =3D HV_X64_REGISTER_KERNEL_GS_BASE; - return 0; - case IA32_MSR_APIC_BASE: - *hv_reg =3D HV_X64_REGISTER_APIC_BASE; - return 0; - case IA32_MSR_PAT: - *hv_reg =3D HV_X64_REGISTER_PAT; - return 0; - case IA32_MSR_SYSENTER_CS: - *hv_reg =3D HV_X64_REGISTER_SYSENTER_CS; - return 0; - case IA32_MSR_SYSENTER_ESP: - *hv_reg =3D HV_X64_REGISTER_SYSENTER_ESP; - return 0; - case IA32_MSR_SYSENTER_EIP: - *hv_reg =3D HV_X64_REGISTER_SYSENTER_EIP; - return 0; - case IA32_MSR_STAR: - *hv_reg =3D HV_X64_REGISTER_STAR; - return 0; - case IA32_MSR_LSTAR: - *hv_reg =3D HV_X64_REGISTER_LSTAR; - return 0; - case IA32_MSR_CSTAR: - *hv_reg =3D HV_X64_REGISTER_CSTAR; - return 0; - case IA32_MSR_SFMASK: - *hv_reg =3D HV_X64_REGISTER_SFMASK; - return 0; - case IA32_MSR_MTRR_CAP: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_CAP; - return 0; - case IA32_MSR_MTRR_DEF_TYPE: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_DEF_TYPE; - return 0; - case IA32_MSR_MTRR_PHYSBASE0: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE0; - return 0; - case IA32_MSR_MTRR_PHYSMASK0: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK0; - return 0; - case IA32_MSR_MTRR_PHYSBASE1: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE1; - return 0; - case IA32_MSR_MTRR_PHYSMASK1: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK1; - return 0; - case IA32_MSR_MTRR_PHYSBASE2: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE2; - return 0; - case IA32_MSR_MTRR_PHYSMASK2: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK2; - return 0; - case IA32_MSR_MTRR_PHYSBASE3: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE3; - return 0; - case IA32_MSR_MTRR_PHYSMASK3: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK3; - return 0; - case IA32_MSR_MTRR_PHYSBASE4: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE4; - return 0; - case IA32_MSR_MTRR_PHYSMASK4: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK4; - return 0; - case IA32_MSR_MTRR_PHYSBASE5: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE5; - return 0; - case IA32_MSR_MTRR_PHYSMASK5: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK5; - return 0; - case IA32_MSR_MTRR_PHYSBASE6: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE6; - return 0; - case IA32_MSR_MTRR_PHYSMASK6: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK6; - return 0; - case IA32_MSR_MTRR_PHYSBASE7: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE7; - return 0; - case IA32_MSR_MTRR_PHYSMASK7: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK7; - return 0; - case IA32_MSR_MTRR_FIX64K_00000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX64K00000; - return 0; - case IA32_MSR_MTRR_FIX16K_80000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX16K80000; - return 0; - case IA32_MSR_MTRR_FIX16K_A0000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX16KA0000; - return 0; - case IA32_MSR_MTRR_FIX4K_C0000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KC0000; - return 0; - case IA32_MSR_MTRR_FIX4K_C8000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KC8000; - return 0; - case IA32_MSR_MTRR_FIX4K_D0000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KD0000; - return 0; - case IA32_MSR_MTRR_FIX4K_D8000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KD8000; - return 0; - case IA32_MSR_MTRR_FIX4K_E0000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KE0000; - return 0; - case IA32_MSR_MTRR_FIX4K_E8000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KE8000; - return 0; - case IA32_MSR_MTRR_FIX4K_F0000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KF0000; - return 0; - case IA32_MSR_MTRR_FIX4K_F8000: - *hv_reg =3D HV_X64_REGISTER_MSR_MTRR_FIX4KF8000; - return 0; - case IA32_MSR_TSC_AUX: - *hv_reg =3D HV_X64_REGISTER_TSC_AUX; - return 0; - case IA32_MSR_BNDCFGS: - *hv_reg =3D HV_X64_REGISTER_BNDCFGS; - return 0; - case IA32_MSR_DEBUG_CTL: - *hv_reg =3D HV_X64_REGISTER_DEBUG_CTL; - return 0; - case IA32_MSR_TSC_ADJUST: - *hv_reg =3D HV_X64_REGISTER_TSC_ADJUST; - return 0; - case IA32_MSR_SPEC_CTRL: - *hv_reg =3D HV_X64_REGISTER_SPEC_CTRL; - return 0; - case HV_X64_MSR_GUEST_OS_ID: - *hv_reg =3D HV_REGISTER_GUEST_OS_ID; - return 0; - case HV_X64_MSR_SINT0: - *hv_reg =3D HV_REGISTER_SINT0; - return 0; - case HV_X64_MSR_SINT1: - *hv_reg =3D HV_REGISTER_SINT1; - return 0; - case HV_X64_MSR_SINT2: - *hv_reg =3D HV_REGISTER_SINT2; - return 0; - case HV_X64_MSR_SINT3: - *hv_reg =3D HV_REGISTER_SINT3; - return 0; - case HV_X64_MSR_SINT4: - *hv_reg =3D HV_REGISTER_SINT4; - return 0; - case HV_X64_MSR_SINT5: - *hv_reg =3D HV_REGISTER_SINT5; - return 0; - case HV_X64_MSR_SINT6: - *hv_reg =3D HV_REGISTER_SINT6; - return 0; - case HV_X64_MSR_SINT7: - *hv_reg =3D HV_REGISTER_SINT7; - return 0; - case HV_X64_MSR_SINT8: - *hv_reg =3D HV_REGISTER_SINT8; - return 0; - case HV_X64_MSR_SINT9: - *hv_reg =3D HV_REGISTER_SINT9; - return 0; - case HV_X64_MSR_SINT10: - *hv_reg =3D HV_REGISTER_SINT10; - return 0; - case HV_X64_MSR_SINT11: - *hv_reg =3D HV_REGISTER_SINT11; - return 0; - case HV_X64_MSR_SINT12: - *hv_reg =3D HV_REGISTER_SINT12; - return 0; - case HV_X64_MSR_SINT13: - *hv_reg =3D HV_REGISTER_SINT13; - return 0; - case HV_X64_MSR_SINT14: - *hv_reg =3D HV_REGISTER_SINT14; - return 0; - case HV_X64_MSR_SINT15: - *hv_reg =3D HV_REGISTER_SINT15; - return 0; - case IA32_MSR_MISC_ENABLE: - *hv_reg =3D HV_X64_REGISTER_MSR_IA32_MISC_ENABLE; - return 0; - case HV_X64_MSR_SCONTROL: - *hv_reg =3D HV_REGISTER_SCONTROL; - return 0; - case HV_X64_MSR_SIEFP: - *hv_reg =3D HV_REGISTER_SIEFP; - return 0; - case HV_X64_MSR_SIMP: - *hv_reg =3D HV_REGISTER_SIMP; - return 0; - case HV_X64_MSR_REFERENCE_TSC: - *hv_reg =3D HV_REGISTER_REFERENCE_TSC; - return 0; - case HV_X64_MSR_EOM: - *hv_reg =3D HV_REGISTER_EOM; - return 0; - default: - error_report("failed to map MSR %u to HV register name", msr); - return -1; - } -} - -static int set_msrs(const CPUState *cpu, GList *msrs) -{ - size_t n_msrs; - GList *entries; - MshvMsrEntry *entry; - enum hv_register_name name; - struct hv_register_assoc *assoc; int ret; - size_t i =3D 0; + uint64_t d_t =3D MSR_MTRR_ENABLE | MSR_MTRR_MEM_TYPE_WB; =20 - n_msrs =3D g_list_length(msrs); - hv_register_assoc *assocs =3D g_new0(hv_register_assoc, n_msrs); + const struct hv_register_assoc assocs[] =3D { + { .name =3D HV_X64_REGISTER_SYSENTER_CS, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_SYSENTER_ESP, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_SYSENTER_EIP, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_STAR, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_CSTAR, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_LSTAR, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_KERNEL_GS_BASE, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_SFMASK, .value.reg64 =3D 0x= 0 }, + { .name =3D HV_X64_REGISTER_MSR_MTRR_DEF_TYPE, .value.reg64 =3D d_= t }, + }; =20 - entries =3D msrs; - for (const GList *elem =3D entries; elem !=3D NULL; elem =3D elem->nex= t) { - entry =3D elem->data; - ret =3D mshv_msr_to_hv_reg_name(entry->index, &name); - if (ret < 0) { - g_free(assocs); - return ret; - } - assoc =3D &assocs[i]; - assoc->name =3D name; - /* the union has been initialized to 0 */ - assoc->value.reg64 =3D entry->data; - i++; - } - ret =3D mshv_set_generic_regs(cpu, assocs, n_msrs); - g_free(assocs); + ret =3D mshv_set_generic_regs(cpu, assocs, ARRAY_SIZE(assocs)); if (ret < 0) { - error_report("failed to set msrs"); + error_report("failed to put msrs"); return -1; } + return 0; } =20 =20 -int mshv_configure_msr(const CPUState *cpu, const MshvMsrEntry *msrs, - size_t n_msrs) +/* + * INVARIANT: this fn expects assocs in the same order as they appear in + * msr_env_map. + */ +static void store_in_env(CPUState *cpu, const struct hv_register_assoc *as= socs, + size_t n_assocs) { - GList *valid_msrs =3D NULL; - uint32_t msr_index; - int ret; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + size_t i, j; + const MshvMsrEnvMap *mapping; + union hv_register_value hv_value; + ptrdiff_t offset; + uint32_t hv_name; =20 - for (size_t i =3D 0; i < n_msrs; i++) { - msr_index =3D msrs[i].index; - /* check whether index of msrs is in SUPPORTED_MSRS */ - if (mshv_is_supported_msr(msr_index)) { - valid_msrs =3D g_list_append(valid_msrs, (void *) &msrs[i]); + assert(n_assocs <=3D (ARRAY_SIZE(msr_env_map))); + + for (i =3D 0, j =3D 0; i < ARRAY_SIZE(msr_env_map); i++) { + hv_name =3D assocs[j].name; + mapping =3D &msr_env_map[i]; + if (hv_name !=3D mapping->hv_name) { + continue; } + + hv_value =3D assocs[j].value; + offset =3D mapping->env_offset; + MSHV_ENV_FIELD(env, offset) =3D hv_value.reg64; + j++; + } +} + +static void set_hv_name_in_assocs(struct hv_register_assoc *assocs, + size_t n_assocs) +{ + size_t i; + + assert(n_assocs =3D=3D ARRAY_SIZE(msr_env_map)); + for (i =3D 0; i < ARRAY_SIZE(msr_env_map); i++) { + assocs[i].name =3D msr_env_map[i].hv_name; + } +} + +static bool msr_supported(uint32_t name) +{ + /* + * This check is not done comprehensively, it's meant to avoid hvcall + * failures for certain MSRs on architectures that don't support them. + */ + + switch (name) { + case HV_X64_REGISTER_SPEC_CTRL: + return mshv_state->processor_features.ibrs_support; + case HV_X64_REGISTER_TSC_ADJUST: + return mshv_state->processor_features.tsc_adjust_support; } =20 - ret =3D set_msrs(cpu, valid_msrs); - g_list_free(valid_msrs); + return true; +} =20 - return ret; +int mshv_get_msrs(CPUState *cpu) +{ + int ret =3D 0; + size_t n_assocs =3D ARRAY_SIZE(msr_env_map); + struct hv_register_assoc assocs[ARRAY_SIZE(msr_env_map)]; + size_t i, j; + uint32_t name; + + set_hv_name_in_assocs(assocs, n_assocs); + + /* Filter out MSRs that cannot be read */ + for (i =3D 0, j =3D 0; i < n_assocs; i++) { + name =3D assocs[i].name; + + if (!msr_supported(name)) { + continue; + } + + if (j !=3D i) { + assocs[j] =3D assocs[i]; + } + j++; + } + n_assocs =3D j; + + ret =3D mshv_get_generic_regs(cpu, assocs, n_assocs); + if (ret < 0) { + error_report("Failed to get MSRs"); + return -errno; + } + + store_in_env(cpu, assocs, n_assocs); + + return 0; +} + +static void load_from_env(const CPUState *cpu, struct hv_register_assoc *a= ssocs, + size_t n_assocs) +{ + size_t i; + const MshvMsrEnvMap *mapping; + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + ptrdiff_t offset; + union hv_register_value *hv_value; + + assert(n_assocs =3D=3D ARRAY_SIZE(msr_env_map)); + + for (i =3D 0; i < ARRAY_SIZE(msr_env_map); i++) { + mapping =3D &msr_env_map[i]; + offset =3D mapping->env_offset; + assocs[i].name =3D mapping->hv_name; + hv_value =3D &assocs[i].value; + hv_value->reg64 =3D MSHV_ENV_FIELD(env, offset); + } +} + +int mshv_set_msrs(const CPUState *cpu) +{ + size_t n_assocs =3D ARRAY_SIZE(msr_env_map); + struct hv_register_assoc assocs[ARRAY_SIZE(msr_env_map)]; + int ret; + size_t i, j; + + load_from_env(cpu, assocs, n_assocs); + + /* Filter out MSRs that cannot be written */ + for (i =3D 0, j =3D 0; i < n_assocs; i++) { + uint32_t name =3D assocs[i].name; + + /* Partition-wide MSRs: only write on vCPU 0 */ + if (cpu->cpu_index !=3D 0 && + (name =3D=3D HV_X64_REGISTER_HYPERCALL || + name =3D=3D HV_REGISTER_GUEST_OS_ID || + name =3D=3D HV_REGISTER_REFERENCE_TSC)) { + continue; + } + + if (!msr_supported(name)) { + continue; + } + + if (j !=3D i) { + assocs[j] =3D assocs[i]; + } + j++; + } + n_assocs =3D j; + + ret =3D mshv_set_generic_regs(cpu, assocs, n_assocs); + if (ret < 0) { + error_report("Failed to set MSRs"); + return -errno; + } + + return 0; } --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469225; cv=none; d=zohomail.com; s=zohoarc; b=FIEUxp6XG45kZ4v50Fd1Qi/zzgZiraIhgGkpNQqiHmgjMPJuEg91ggxLTT4bPJPoKx//qfJ8RqCUSxyIXAeXVU1nkc3B3Q6a9vf3LOGQsV5MtovJNagYkWSAowGGbRTlH/e9Sx5IEMg8/lUfN+kcNX953OpUEBSBOeO7MWZ1+w0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469225; 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=mvuCG09jFYT3N7DhZlRwPAPRQKQKrhXH30rKgvdzMNE=; b=fzRZHH052ye+PCFj4nuG9blqO/REeQwgsLZpo8s8AoBLymkLRagclpQvt9OsEA0Kqir/oTxbG1QguZgUNihYQU/k23cbTBj1iYAjs8y32qSPuAqRYNYNjfyf4DTzFufksKNm5AGC6bLk+JEabJskXNbCNZaFlyf0FyClMbyO3ko= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469225406926.5618873255294; Fri, 26 Jun 2026 03:20:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3en-00020v-1N; Fri, 26 Jun 2026 06:19: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 1wd3ea-0000uE-Fp for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eX-0005NS-Up for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:20 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-190-eGYNhJHxNJKRSxZr2q-yOA-1; Fri, 26 Jun 2026 06:19:16 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4924583c7baso9445035e9.1 for ; Fri, 26 Jun 2026 03:19:15 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46f86c34d76sm1156931f8f.3.2026.06.26.03.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mvuCG09jFYT3N7DhZlRwPAPRQKQKrhXH30rKgvdzMNE=; b=QNUUyda/yeBnA0miS7ed68gahA/p8tNPTGanJc5cz1waTlK51OBTnp7OSPtPl9jfemgp2T HcYMafCN/1uwMAHN91tTgL6TBn2nx63Qbikp0wn0S7pMjEYLzPV/1wXPHdO5ZUd2Et7slq Aa0xguvgDBYhq2UdXX+JmEbKDFTEZrM= X-MC-Unique: eGYNhJHxNJKRSxZr2q-yOA-1 X-Mimecast-MFC-AGG-ID: eGYNhJHxNJKRSxZr2q-yOA_1782469155 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469155; x=1783073955; 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; bh=mvuCG09jFYT3N7DhZlRwPAPRQKQKrhXH30rKgvdzMNE=; b=ZX2umTdoE0S7mB5QNPI9uVEpg5lMZW4Vo5rjHpRJrPoXHTocYZU4XgUSTgGvKKjgP1 f128alrw/L7lwPe9a+a41ft4KLw9T7tyIh7nl3Ep9OOKVCgCD+3TpFOE2VPQQ3Qeo5Vw HzGHgdlPWDdPdfG1vGLJt85larXyUdODh+TZ44KMMWODQn6gk+ojFcsqFb7FTQfkroqQ 9rx+FSMzwceaYJ089A4QSH6GtpdFLdDy8srMRJeFAh6JbRQ5Z8L42lJ/jT+LcMxvVds0 +MOUlK5ls6MR8vyQJifaN4Z1B1MeYiEZMYYCtzN4G6Ev/HXNK0YdhyquERqxMVgaQ2RI mtiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469155; x=1783073955; 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; bh=mvuCG09jFYT3N7DhZlRwPAPRQKQKrhXH30rKgvdzMNE=; b=S/itsYtzYh1AL9Gjd0NQ2TTCsDqIspeZruRsaWodQz05zUfpH6iNH7rLtL3NvyhkUT 7MmQs+pqZKPhAx1gu3A/TK5NnxD3b/GwsXNMj5XBWUnz607NbnUtfjqENOlBm45pneLm T1JSmfZj+R/oyOkcUTwlkhD7po3qoTuA6Dgh/bnCskSveQIhNWDWHOPAo5AMDp19hlA5 mYSC5d8s53d10fZ5cd2z2ohWOWCtvMFTigy8cCe30OIKqSbYy6sTQQZ/OZj7eiIWcvcF s1LZGQ6srbjhr/4Px6Xkstnr5h0arPlFshc87h17VJqE0Y+AhzdAs3XuSILboI9LmgEV Ws5A== X-Gm-Message-State: AOJu0YxK5nrWVE6D4Bhtmu3A1RLows1GZ6fbJtFboBWUDvnAStK/OCzV YXUNaXXFrBNPDZgJyXktYOpK+ZvilWYjzRImxCoQpz7MVM8s2Sj3wnDEMnx2I4Hdr6bGKX3aJbq s4tLFUXkE2orn5SQZ9Oaqk9+EmlfZHal9K0QVcGnxZ/s5JF9VRhfxZ0gdHZaFx6jFbB4LWkgViM 3pSO4chwnUbiwUHRp6Jsi4D2mgTJzQO3fM+WyY5Dyt X-Gm-Gg: AfdE7cnwl3FJvDEWk1vjKeXs5iWJmjwMKUnWKj2ZPQoof6/CoMhVnJDIK21uUkekSTP 4wHEtILQWyQ4Q9CVNF0vJS/tPnTGYz8nOvT8sVyTA4kwlLwKNMQagiq1VHbA1PPDXtaL/sWHGov 7ExGdELnkdgeQn397HNrOmR3KlijATSmXs6Mo2hCm95DgJ0+Yv+0FXVaDTw5luuIc3VaqNbl1+f NbWTSV8WH4BdOJjyeiPsKzQ/eBphpUq79aPMWEFLETcdUK9Ykcg48EzO1CC5wI/bbdiWX2Nsn7N tUWpjle9L9IQo93vk03BNn7VTSwNuZt5JANncUxns5A3DFIXB0D9MlqdkzAcEUBYMxFPdPZfGFu eyNZM4LCVUannYuMF9pN4XyUas1OKcG6KcNAweX8hJgIYoWYuHHqs0UOUgAO+pkEYKatvBtzWsj riNtKu4ckuV79VsVSw X-Received: by 2002:a05:600c:1d25:b0:492:3c49:88ac with SMTP id 5b1f17b1804b1-49266847bb9mr79331125e9.10.1782469154595; Fri, 26 Jun 2026 03:19:14 -0700 (PDT) X-Received: by 2002:a05:600c:1d25:b0:492:3c49:88ac with SMTP id 5b1f17b1804b1-49266847bb9mr79330605e9.10.1782469154000; Fri, 26 Jun 2026 03:19:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 31/45] target/i386/mshv: migrate MTRR MSRs Date: Fri, 26 Jun 2026 12:17:34 +0200 Message-ID: <20260626101748.1728079-32-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469227553158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke This change roundtrips memory access/caching MSRs. The mapping scheme is a bit more elaborate on these, so we have added a special handling instead of individual entries in the MSR mapping table. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-22-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/msr.c | 136 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 129 insertions(+), 7 deletions(-) diff --git a/target/i386/mshv/msr.c b/target/i386/mshv/msr.c index 7447467dbf5..76b593060a7 100644 --- a/target/i386/mshv/msr.c +++ b/target/i386/mshv/msr.c @@ -77,6 +77,10 @@ static const MshvMsrEnvMap msr_env_map[] =3D { { HV_X64_MSR_SIMP, HV_REGISTER_SIMP, offsetof(CPUX86State, msr_hv_synic_msg_page) }, =20 + /* MTRR default type */ + { IA32_MSR_MTRR_DEF_TYPE, HV_X64_REGISTER_MSR_MTRR_DEF_TYPE, + offsetof(CPUX86State, mtrr_deftype) }, + /* Other */ =20 /* TODO: find out processor features that correlate to unsupported MSR= s. */ @@ -88,6 +92,98 @@ static const MshvMsrEnvMap msr_env_map[] =3D { offsetof(CPUX86State, spec_ctrl) }, }; =20 +/* + * The assocs have to be set according to this schema: + * 8 entries for 0-7 mtrr_base + * 8 entries for mtrr_mask 0-7 + * 11 entries for 1 x 64k, 2 x 16k, 8 x 4k fixed MTRR + * 27 total entries + */ + +#define MSHV_MTRR_MSR_COUNT 27 +#define MSHV_MSR_TOTAL_COUNT (ARRAY_SIZE(msr_env_map) + MSHV_MTRR_MSR_COUN= T) + +static void store_in_env_mtrr_phys(CPUState *cpu, + const struct hv_register_assoc *assocs, + size_t n_assocs) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + size_t i, fixed_offset; + hv_register_name hv_name; + uint64_t base, mask; + + assert(n_assocs =3D=3D MSHV_MTRR_MSR_COUNT); + + for (i =3D 0; i < MSR_MTRRcap_VCNT; i++) { + hv_name =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE0 + i; + assert(assocs[i].name =3D=3D hv_name); + hv_name =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK0 + i; + assert(assocs[i + MSR_MTRRcap_VCNT].name =3D=3D hv_name); + + base =3D assocs[i].value.reg64; + mask =3D assocs[i + MSR_MTRRcap_VCNT].value.reg64; + env->mtrr_var[i].base =3D base; + env->mtrr_var[i].mask =3D mask; + } + + /* fixed 1x 64, 2x 16, 8x 4 kB */ + fixed_offset =3D MSR_MTRRcap_VCNT * 2; + for (i =3D 0; i < 11; i++) { + hv_name =3D HV_X64_REGISTER_MSR_MTRR_FIX64K00000 + i; + assert(assocs[fixed_offset + i].name =3D=3D hv_name); + env->mtrr_fixed[i] =3D assocs[fixed_offset + i].value.reg64; + } +} + +/* + * The assocs have to be set according to this schema: + * 8 entries for 0-7 mtrr_base + * 8 entries for mtrr_mask 0-7 + * 11 entries for 1 x 64k, 2 x 16k, 8 x 4k fixed MTRR + * 27 total entries + */ +static void load_from_env_mtrr_phys(const CPUState *cpu, + struct hv_register_assoc *assocs, + size_t n_assocs) +{ + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; + size_t i, fixed_offset; + uint64_t base, mask, fixed_value; + hv_register_name base_name, mask_name, fixed_name; + hv_register_assoc *assoc; + + assert(n_assocs =3D=3D MSHV_MTRR_MSR_COUNT); + + for (i =3D 0; i < MSR_MTRRcap_VCNT; i++) { + base =3D env->mtrr_var[i].base; + mask =3D env->mtrr_var[i].mask; + + base_name =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE0 + i; + mask_name =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK0 + i; + + assoc =3D &assocs[i]; + assoc->name =3D base_name; + assoc->value.reg64 =3D base; + + assoc =3D &assocs[i + MSR_MTRRcap_VCNT]; + assoc->name =3D mask_name; + assoc->value.reg64 =3D mask; + } + + /* fixed 1x 64, 2x 16, 8x 4 kB */ + fixed_offset =3D MSR_MTRRcap_VCNT * 2; + for (i =3D 0; i < 11; i++) { + fixed_name =3D HV_X64_REGISTER_MSR_MTRR_FIX64K00000 + i; + fixed_value =3D env->mtrr_fixed[i]; + + assoc =3D &assocs[fixed_offset + i]; + assoc->name =3D fixed_name; + assoc->value.reg64 =3D fixed_value; + } +} + int mshv_init_msrs(const CPUState *cpu) { int ret; @@ -129,8 +225,9 @@ static void store_in_env(CPUState *cpu, const struct hv= _register_assoc *assocs, union hv_register_value hv_value; ptrdiff_t offset; uint32_t hv_name; + size_t mtrr_index; =20 - assert(n_assocs <=3D (ARRAY_SIZE(msr_env_map))); + assert(n_assocs <=3D MSHV_MSR_TOTAL_COUNT); =20 for (i =3D 0, j =3D 0; i < ARRAY_SIZE(msr_env_map); i++) { hv_name =3D assocs[j].name; @@ -144,17 +241,38 @@ static void store_in_env(CPUState *cpu, const struct = hv_register_assoc *assocs, MSHV_ENV_FIELD(env, offset) =3D hv_value.reg64; j++; } + + mtrr_index =3D j; + store_in_env_mtrr_phys(cpu, &assocs[mtrr_index], MSHV_MTRR_MSR_COUNT); } =20 static void set_hv_name_in_assocs(struct hv_register_assoc *assocs, size_t n_assocs) { size_t i; + size_t mtrr_offset, mtrr_fixed_offset; + hv_register_name hv_name; + + assert(n_assocs =3D=3D MSHV_MSR_TOTAL_COUNT); =20 - assert(n_assocs =3D=3D ARRAY_SIZE(msr_env_map)); for (i =3D 0; i < ARRAY_SIZE(msr_env_map); i++) { assocs[i].name =3D msr_env_map[i].hv_name; } + + mtrr_offset =3D ARRAY_SIZE(msr_env_map); + for (i =3D 0; i < MSR_MTRRcap_VCNT; i++) { + hv_name =3D HV_X64_REGISTER_MSR_MTRR_PHYS_BASE0 + i; + assocs[mtrr_offset + i].name =3D hv_name; + hv_name =3D HV_X64_REGISTER_MSR_MTRR_PHYS_MASK0 + i; + assocs[mtrr_offset + MSR_MTRRcap_VCNT + i].name =3D hv_name; + } + + /* fixed 1x 64, 2x 16, 8x 4 kB */ + mtrr_fixed_offset =3D mtrr_offset + MSR_MTRRcap_VCNT * 2; + for (i =3D 0; i < 11; i++) { + hv_name =3D HV_X64_REGISTER_MSR_MTRR_FIX64K00000 + i; + assocs[mtrr_fixed_offset + i].name =3D hv_name; + } } =20 static bool msr_supported(uint32_t name) @@ -177,8 +295,8 @@ static bool msr_supported(uint32_t name) int mshv_get_msrs(CPUState *cpu) { int ret =3D 0; - size_t n_assocs =3D ARRAY_SIZE(msr_env_map); - struct hv_register_assoc assocs[ARRAY_SIZE(msr_env_map)]; + size_t n_assocs =3D MSHV_MSR_TOTAL_COUNT; + struct hv_register_assoc assocs[MSHV_MSR_TOTAL_COUNT]; size_t i, j; uint32_t name; =20 @@ -219,8 +337,9 @@ static void load_from_env(const CPUState *cpu, struct h= v_register_assoc *assocs, CPUX86State *env =3D &x86_cpu->env; ptrdiff_t offset; union hv_register_value *hv_value; + size_t mtrr_offset; =20 - assert(n_assocs =3D=3D ARRAY_SIZE(msr_env_map)); + assert(n_assocs =3D=3D MSHV_MSR_TOTAL_COUNT); =20 for (i =3D 0; i < ARRAY_SIZE(msr_env_map); i++) { mapping =3D &msr_env_map[i]; @@ -229,12 +348,15 @@ static void load_from_env(const CPUState *cpu, struct= hv_register_assoc *assocs, hv_value =3D &assocs[i].value; hv_value->reg64 =3D MSHV_ENV_FIELD(env, offset); } + + mtrr_offset =3D ARRAY_SIZE(msr_env_map); + load_from_env_mtrr_phys(cpu, &assocs[mtrr_offset], MSHV_MTRR_MSR_COUNT= ); } =20 int mshv_set_msrs(const CPUState *cpu) { - size_t n_assocs =3D ARRAY_SIZE(msr_env_map); - struct hv_register_assoc assocs[ARRAY_SIZE(msr_env_map)]; + size_t n_assocs =3D MSHV_MSR_TOTAL_COUNT; + struct hv_register_assoc assocs[MSHV_MSR_TOTAL_COUNT]; int ret; size_t i, j; =20 --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469237; cv=none; d=zohomail.com; s=zohoarc; b=L0fpNNHI5bZ2EbtS6+5fJ7rjGsjgB448aV2tHiK1zziK5cTom+r7Q0p+vYap7qJEMxFXqul/K40ldGNkMsZJU3/2b7HGHVZWkuWyIHtqwqpep2b3DUUGQJpmns3J88eR3+qNXx/1FGAaB/c0lYiER28kyaNDwqYBdQ3g3cvePkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469237; 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=wuaCIBqbAEEM5rWDY83KXOVdzkSLuV45P6OsTJ+LHD8=; b=GcS7LTJ5y0pIoSt8T8qBpPYX+DRio0BKgg0U+45MvO8EnPdYo9BR0z1BTCEbI7t2oNe5taiQl1QZOhbucMA6yKcQOScSvclevdaVV1rBDloE2ukucwNTDJh4iflkZMGJpetdmrPio+/VBkAJ42oQhZ5MpxJ/i0dK5vWxxkTpqYc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469237733413.42071565784966; Fri, 26 Jun 2026 03:20:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3en-00024o-Kf; Fri, 26 Jun 2026 06:19: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 1wd3ee-0001Al-5O for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ec-0005Nz-8i for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:23 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-354-TeHFs5iBPeuGFKAxMTOBFw-1; Fri, 26 Jun 2026 06:19:20 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4925bf70f5bso6251615e9.1 for ; Fri, 26 Jun 2026 03:19:20 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492691f60bcsm69684995e9.1.2026.06.26.03.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wuaCIBqbAEEM5rWDY83KXOVdzkSLuV45P6OsTJ+LHD8=; b=eafA6opeTQy/ZeVzKlGkjNY+NcXpvEw9cDkRGn3tIyVkCZLEPRLxKrS+u1x2gSe7IJXJMc MceC92ch17fcsP3mGEEn8BqccANpHwVhlmUnz+rN4KJIMqem+0bEHzXN+gxWqJ5pYFyrRW tqQBXeYbfioLVgCOAT7sSDg7OKwBRJ8= X-MC-Unique: TeHFs5iBPeuGFKAxMTOBFw-1 X-Mimecast-MFC-AGG-ID: TeHFs5iBPeuGFKAxMTOBFw_1782469159 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469159; x=1783073959; 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; bh=wuaCIBqbAEEM5rWDY83KXOVdzkSLuV45P6OsTJ+LHD8=; b=bQDjpGzGNAUnCs9ygATSa1CupOW5nV/zB8nC71mKhZdmFyo6M6lhYGJaY1aIaUNMdG gQmJlyx63ggmHJBXjaF5AhXnh7jQ7UxN8eesNG3Pl2Un/SgZUmT0vRYIMqrwvzbbT/iS pmeYWlIJRF0mg7SLR3w2snWZ7bO6wJy4keO3Sh23hVJUQyZia+m7DrCzTgb5tphBXmGF gjRTHRy0wK2vNmeQp4xsUu9asKvA5rO5CsJvdqsf14b2GRuaLolx2b6AQYeTcmU3uyGz SV6QqULyL11hPShze4QEdvtRXg06rG7RHF2qmh80+BNC7IzHcDfnp5eBzEUCzVV1ZHoK hVlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469159; x=1783073959; 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; bh=wuaCIBqbAEEM5rWDY83KXOVdzkSLuV45P6OsTJ+LHD8=; b=faKMxhOYgfFdgNsitLvE+/g/KRKwCpw1ysEOJAc5uKP09AL511GNEKIK+Af89jXFqe n5svHxelc2UxzWXjH4kI9PCuWvXkPa1fdoYawKiLcLMEqd376B3Iq+5L/1qcmoLcdtc+ xZZX5CMYzyLo1rer/fJPBNU4rskwfMZB9vLBFGO1P9vVwIX8CzVkgJv3RKgodFO9oLbs IikzpN2stQPTy7B7pCujrK6bz5hIz8MOchEVX0xNCpOOn0qmIkSTF93R9X4TOAyCAQjw PKYeruklLNzlC2Gg4QwhV5AuN1cDOdTJ6NLyWMswbNALS63YxzQ3lWrCDrJokjGJ3AFn 0Xkg== X-Gm-Message-State: AOJu0YzUGae2/6RyWVkuiUG1iM07p3zacsD+t/jzcVD7DKpnsN/TZjMy NoTi07MxQBFuMZZsKNTiML/84JDidwkBC9yaQMMtvHRC398OagtpfSyDZ3vpKeoRvsUoiBagofC PIHlO2k1H7hZRZrV//NAr9lc2nkZWakJouJfEBKFEPyX4FJg6pNxIxpORYpElQTMQEFyRszbzmy f3K2ilpye2vh3BQdDHGEPjWDYPHj2iDVqZs/bnQpC3 X-Gm-Gg: AfdE7cmOlr2p+cxYvwJkKYQH+fARcOTWosokIWq8teFTALWi2amaauQq5I9LMMas6hX huUfZcAarG0MSFf6x5Jq31JtecCNeJDuKxXQ0H2SATImVB1wmF0VLgO+zE/Q2dWEw5/rxTA3L1k DiP9qFkkUjKK/n4Ht6P4upui+roMHonDnAKULL+GJl0aIH4JuXYdQc4eIq5vXqG8HpKJ0/B9TLF uyVGZ+91TPEYJ6SH8cHo4FbaUKwUQnspsh1ptp6T3kRdIPt/RDvofZ54tAAz14d76URw7jkH89u YmFXXt9U9OH1Vhh5VRwjQGBKU3s0JZjeX6zqX8lzPpi/m2U9vBKcmhonHQSYCSeYfwBB5Sy8fbH zz7Ekz71TxhC/Dtb+4O8M4rOb9YRycEtqkXPEoxWOeQJoRryKEotzFNcLQ54YhIi2qTWVbVGT4Z BMnWjz7gIBJCaomq7h X-Received: by 2002:a05:600d:6454:10b0:490:e243:4806 with SMTP id 5b1f17b1804b1-49266866378mr73931015e9.9.1782469158908; Fri, 26 Jun 2026 03:19:18 -0700 (PDT) X-Received: by 2002:a05:600d:6454:10b0:490:e243:4806 with SMTP id 5b1f17b1804b1-49266866378mr73930675e9.9.1782469158488; Fri, 26 Jun 2026 03:19:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Magnus Kulke Subject: [PULL 32/45] target/i386/mshv: migrate CET/SS MSRs Date: Fri, 26 Jun 2026 12:17:35 +0200 Message-ID: <20260626101748.1728079-33-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469239675158500 Content-Type: text/plain; charset="utf-8" From: Magnus Kulke This change migrates the MSRs required for CET shadow stack and indirect branch tracking. They are gated behind cet_ss_support || cet_ibt_support mshv processor feature flags. Signed-off-by: Magnus Kulke Link: https://lore.kernel.org/r/20260417105618.3621-24-magnuskulke@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/hw/hyperv/hvgdk_mini.h | 11 +++++++++++ target/i386/mshv/msr.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h index b00ec8a6367..c6749a95255 100644 --- a/include/hw/hyperv/hvgdk_mini.h +++ b/include/hw/hyperv/hvgdk_mini.h @@ -170,6 +170,17 @@ typedef enum hv_register_name { HV_X64_REGISTER_SPEC_CTRL =3D 0x00080084, HV_X64_REGISTER_TSC_ADJUST =3D 0x00080096, =20 + /* CET / Shadow Stack */ + HV_X64_REGISTER_U_XSS =3D 0x0008008B, + HV_X64_REGISTER_U_CET =3D 0x0008008C, + HV_X64_REGISTER_S_CET =3D 0x0008008D, + HV_X64_REGISTER_SSP =3D 0x0008008E, + HV_X64_REGISTER_PL0_SSP =3D 0x0008008F, + HV_X64_REGISTER_PL1_SSP =3D 0x00080090, + HV_X64_REGISTER_PL2_SSP =3D 0x00080091, + HV_X64_REGISTER_PL3_SSP =3D 0x00080092, + HV_X64_REGISTER_INTERRUPT_SSP_TABLE_ADDR =3D 0x00080093, + /* Other MSRs */ HV_X64_REGISTER_MSR_IA32_MISC_ENABLE =3D 0x000800A0, =20 diff --git a/target/i386/mshv/msr.c b/target/i386/mshv/msr.c index 76b593060a7..8c220a99423 100644 --- a/target/i386/mshv/msr.c +++ b/target/i386/mshv/msr.c @@ -81,6 +81,26 @@ static const MshvMsrEnvMap msr_env_map[] =3D { { IA32_MSR_MTRR_DEF_TYPE, HV_X64_REGISTER_MSR_MTRR_DEF_TYPE, offsetof(CPUX86State, mtrr_deftype) }, =20 + /* CET / Shadow Stack */ + { MSR_IA32_U_CET, HV_X64_REGISTER_U_CET, + offsetof(CPUX86State, u_cet) }, + { MSR_IA32_S_CET, HV_X64_REGISTER_S_CET, + offsetof(CPUX86State, s_cet) }, + { MSR_IA32_PL0_SSP, HV_X64_REGISTER_PL0_SSP, + offsetof(CPUX86State, pl0_ssp) }, + { MSR_IA32_PL1_SSP, HV_X64_REGISTER_PL1_SSP, + offsetof(CPUX86State, pl1_ssp) }, + { MSR_IA32_PL2_SSP, HV_X64_REGISTER_PL2_SSP, + offsetof(CPUX86State, pl2_ssp) }, + { MSR_IA32_PL3_SSP, HV_X64_REGISTER_PL3_SSP, + offsetof(CPUX86State, pl3_ssp) }, + { MSR_IA32_INT_SSP_TAB, HV_X64_REGISTER_INTERRUPT_SSP_TABLE_ADDR, + offsetof(CPUX86State, int_ssp_table) }, + + /* XSAVE Supervisor State */ + { MSR_IA32_XSS, HV_X64_REGISTER_U_XSS, + offsetof(CPUX86State, xss) }, + /* Other */ =20 /* TODO: find out processor features that correlate to unsupported MSR= s. */ @@ -287,6 +307,16 @@ static bool msr_supported(uint32_t name) return mshv_state->processor_features.ibrs_support; case HV_X64_REGISTER_TSC_ADJUST: return mshv_state->processor_features.tsc_adjust_support; + case HV_X64_REGISTER_U_CET: + case HV_X64_REGISTER_S_CET: + case HV_X64_REGISTER_PL0_SSP: + case HV_X64_REGISTER_PL1_SSP: + case HV_X64_REGISTER_PL2_SSP: + case HV_X64_REGISTER_PL3_SSP: + case HV_X64_REGISTER_INTERRUPT_SSP_TABLE_ADDR: + case HV_X64_REGISTER_U_XSS: + return mshv_state->processor_features.cet_ss_support || + mshv_state->processor_features.cet_ibt_support; } =20 return true; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469387; cv=none; d=zohomail.com; s=zohoarc; b=kVXpvzmcsfwg3GHTJWS3IAk8G4DAXGYolo6iYVXf/wLBKtZUnL4Evf09n47PEmP/BmtnUYnuOpWmyRTDslobZeolNJ9MLFbtneZ9B3YPPVCda/jJwZ6qST4SDm+R6OPJOwezDwPDecK5MnAJGd9DhYsnSxB2y77QxTnwNwsgtfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469387; h=Content-Transfer-Encoding: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:Cc; bh=q+xth3zJnJDFs6lGu71xiSdWTKM4W7NCVGErv5m3aMI=; b=RDXJBLbQoySZozuvBwRQIV3wQHhv4A8vu1rj0lpK+KDwQf+HlBoYuapCS4UH5zvcXg+XdfG0RskYr7zWqJnpLGSChtmYSMytU8Ax5tFX5Vm5w4Q2z6EjJ/oYoisVM2V60tBCdjzTWO7V9EY91JNZr9IaMMK+iXzP8mN3tl0wOZc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469387422866.8182424092956; Fri, 26 Jun 2026 03:23:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3el-0001mC-8s; Fri, 26 Jun 2026 06:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ef-0001DB-4g for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ed-0005O6-Gh for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:24 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-qzDUd8QGO3WdKt5Rh4B96w-1; Fri, 26 Jun 2026 06:19:21 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-46fa65abd21so42036f8f.2 for ; Fri, 26 Jun 2026 03:19:21 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46d3b59cef1sm16715500f8f.26.2026.06.26.03.19.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q+xth3zJnJDFs6lGu71xiSdWTKM4W7NCVGErv5m3aMI=; b=GjKrPqbp4ehvkLAE/nWNftzUkJIxX3488kc4nakUWSZyGVcmglygJVv/KvheRjBQDFlaez mynIN66HwzlbbRyFDmGKN+A7PsFLLprk693mlPXJD/rBW8VmBIqjeUTm69GDaOhZahpKoY dcbyi1MRtyMql4j4bh4RbQNwBIw6rsE= X-MC-Unique: qzDUd8QGO3WdKt5Rh4B96w-1 X-Mimecast-MFC-AGG-ID: qzDUd8QGO3WdKt5Rh4B96w_1782469160 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469160; x=1783073960; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=q+xth3zJnJDFs6lGu71xiSdWTKM4W7NCVGErv5m3aMI=; b=icudgYHaoItoMI86Qw4tdZTBXIxYeki7I0CrqBnZO+I0CTEjkhRWEsxvy1pH1Qapa9 h/4JZNvnE7y6skoUck8eUX02lOS1kUSBHcsbJCVlhnfEZwglce7D9xregxLi4wzBU/IP Vrxxj2/IoZ8KXKlnJ7wd8zj0iAgvzM9LZHdsOavoMEqrprZu7LrCN8XuhjDYs5CAPSdb tbp+8qfzgo+mOXbSv2yp6kdwUtXTc39uWTMmOCVgMLKTM1UtLG4Ap65pukbJpBy5AsQ/ wamJMRIPeM2j0xA7D16/R/sIeXFrtPi5Qh3LTIRuP5PM6msTFrEaGhWZL2Op8oPmg0x4 Q8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469160; x=1783073960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=q+xth3zJnJDFs6lGu71xiSdWTKM4W7NCVGErv5m3aMI=; b=oVofNQWN/4bQnAuJlZn8eblDFEV2rzZtbzGBe794nmJK7nYOy+Hmkf8Gc97sTwlhhS M0dxpBi3U9v0s5Tp6tosG32j78qwgDiJ2oiX4m+/8aYOqPAUsjo2zUr+PIgO3Na1Wi9H aeY7Cw+kKe1gpX+cTso1dcLztxIQL1Bo+uFNvDBhy2Cmbg9JBlU0USx7qZsi2ijM8t51 xaLmsnqb5eqCdebwSdLMHpQtvgg6BlQQpinogLSY7E2jqMpvusO8p3G17d1FtyJl2rRN 242cGVkYPa4P7Kp6HhHzFSURVWBJvmHAJu3/LKlF5/do5n8vRxUGm7OrMhIt2f2D+hNe SiUQ== X-Gm-Message-State: AOJu0YxzilwiCnn1l+kwEssXVzD0gI8N+c552PCF22536RQiN0Ucdd73 sQqiW294B+uWfnrE2ohg0+azIOhG3wr6T6ufeWhKoCFexT6XsxiDC1LISBiZK6pCDi78BnZyzaY YHw9RwyFtpV5wSAsWqps/0ucLn1Wsar+fXX4MT3jYVo5voeVIeLgRrBvSIcb4aPDhXKbmiWSARm +AqjoJOvt1aiCu3TZLRkGImx5gpCPWo004qZmvfvqg X-Gm-Gg: AfdE7cmLF0807llI/+UmQtJpWVRbCZGDS+zUS7NJDpjJ6/rXY6s/BFnksa4ivJejldw fmjevkBHPk0Xt0wU9t0g/Nm8Ds3BUpxeRIZreDYKiKysDimuNtoseiOboMUtP5xNj9ENXzhwgaE awdmJZJSPsxgOWMzVCu3PR53aawtcdj+XsWGeWbNLj1sGgQJ0TwaVAv3P1rFEudxG0RIuMrN70w lBNAyCGSDPW0ci16obgGJHgdWe3M8Xs8jMNoAgGQUtiYBLHVMs46EML3FQMZHNt+sFiDlYITna6 /ZzZ7MScKAv7vRXAPf1Su9nQ5KvnSo1VOADaopI/Y45rD30YJoMaTpOOqZRxNRa7Noi4nF7clCe elFApW5kZzWAx/JYyKsn44IJFIti/gRN+pKtGZx92nhvde2kJ7TfslIIhjw5uG5qXGL702uhI71 7vJ+juN/JXPpiDlr3e X-Received: by 2002:a05:6000:2c0f:b0:46b:ea12:2912 with SMTP id ffacd0b85a97d-46dc05553f8mr10474554f8f.5.1782469160395; Fri, 26 Jun 2026 03:19:20 -0700 (PDT) X-Received: by 2002:a05:6000:2c0f:b0:46b:ea12:2912 with SMTP id ffacd0b85a97d-46dc05553f8mr10474494f8f.5.1782469159960; Fri, 26 Jun 2026 03:19:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 33/45] accel: remove unnecessary #ifdefs Date: Fri, 26 Jun 2026 12:17:36 +0200 Message-ID: <20260626101748.1728079-34-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469388508158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- accel/accel-irq.c | 14 -------------- accel/stubs/mshv-stub.c | 1 + 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/accel/accel-irq.c b/accel/accel-irq.c index 4303e10e408..830be27c7f9 100644 --- a/accel/accel-irq.c +++ b/accel/accel-irq.c @@ -19,11 +19,9 @@ =20 int accel_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice= *dev) { -#ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { return mshv_irqchip_add_msi_route(c, vector, dev); } -#endif if (kvm_enabled()) { return kvm_irqchip_add_msi_route(c, vector, dev); } @@ -32,11 +30,9 @@ int accel_irqchip_add_msi_route(AccelRouteChange *c, int= vector, PCIDevice *dev) =20 int accel_irqchip_update_msi_route(int vector, MSIMessage msg, PCIDevice *= dev) { -#ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { return mshv_irqchip_update_msi_route(vector, msg, dev); } -#endif if (kvm_enabled()) { return kvm_irqchip_update_msi_route(kvm_state, vector, msg, dev); } @@ -53,11 +49,9 @@ void accel_irqchip_commit_route_changes(AccelRouteChange= *c) =20 void accel_irqchip_commit_routes(void) { -#ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { mshv_irqchip_commit_routes(mshv_state); } -#endif if (kvm_enabled()) { kvm_irqchip_commit_routes(kvm_state); } @@ -65,11 +59,9 @@ void accel_irqchip_commit_routes(void) =20 void accel_irqchip_release_virq(int virq) { -#ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { mshv_irqchip_release_virq(mshv_state, virq); } -#endif if (kvm_enabled()) { kvm_irqchip_release_virq(kvm_state, virq); } @@ -78,11 +70,9 @@ void accel_irqchip_release_virq(int virq) int accel_irqchip_add_irqfd_notifier_gsi(EventNotifier *n, EventNotifier *= rn, int virq) { -#ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { return mshv_irqchip_add_irqfd_notifier_gsi(n, rn, virq); } -#endif if (kvm_enabled()) { return kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, n, rn, virq); } @@ -91,11 +81,9 @@ int accel_irqchip_add_irqfd_notifier_gsi(EventNotifier *= n, EventNotifier *rn, =20 int accel_irqchip_remove_irqfd_notifier_gsi(EventNotifier *n, int virq) { -#ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { return mshv_irqchip_remove_irqfd_notifier_gsi(n, virq); } -#endif if (kvm_enabled()) { return kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, n, virq); } @@ -104,14 +92,12 @@ int accel_irqchip_remove_irqfd_notifier_gsi(EventNotif= ier *n, int virq) =20 inline AccelRouteChange accel_irqchip_begin_route_changes(void) { -#ifdef CONFIG_MSHV_IS_POSSIBLE if (mshv_msi_via_irqfd_enabled()) { return (AccelRouteChange) { .accel =3D ACCEL(mshv_state), .changes =3D 0, }; } -#endif if (kvm_enabled()) { return (AccelRouteChange) { .accel =3D ACCEL(kvm_state), diff --git a/accel/stubs/mshv-stub.c b/accel/stubs/mshv-stub.c index 8b69539a85a..566a17ff9e4 100644 --- a/accel/stubs/mshv-stub.c +++ b/accel/stubs/mshv-stub.c @@ -13,6 +13,7 @@ #include "system/mshv.h" =20 bool mshv_allowed; +MshvState *mshv_state; =20 int mshv_irqchip_add_msi_route(AccelRouteChange *c, int vector, PCIDevice = *dev) { --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469196; cv=none; d=zohomail.com; s=zohoarc; b=Cg/qaHZZJAw7AmPLGUuSyjz0l63aW8d8NFY0KXEb+zAae+/qyr0WR9C9a5kkOaLl3GS01euPSyVHtyxLL2Y9ODu1Vr2odnkpc/ZiI5Zq9rDF5bqTZf8sYVGOpsYgWf1JhZSBDuXotbutEKDASNJdj3Fn/ugKrYhSppLqN86yeq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469196; 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=qkoE8S6UBX3o+N0SXfwXHK1tv2NXu1sYxgKB0nzO2dY=; b=dPh8r9OIEzJIPyYKddXzy19gZ484zWDtxl1zPNHmmfsM5Tsin2tTaW/nrGkes/C4GW8c/SjhQpxNsG167ZGhOv9jsuu2UC8qEkAQgsyT/VBykeGzeSXUMBsKaiZzB89LPF/mxtqfZkP2n9PqQV9uF5ByhdieuH1DX4OwTWtD56I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469196834979.8739342701821; Fri, 26 Jun 2026 03:19:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3em-0001v8-8s; Fri, 26 Jun 2026 06:19: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 1wd3ei-0001T4-W1 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eg-0005Og-QM for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:28 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414--jMyWzUkPu6zOWyE8wK2kA-1; Fri, 26 Jun 2026 06:19:25 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-49243626f15so6948955e9.1 for ; Fri, 26 Jun 2026 03:19:24 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492690168d5sm92222235e9.14.2026.06.26.03.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qkoE8S6UBX3o+N0SXfwXHK1tv2NXu1sYxgKB0nzO2dY=; b=AM+6EizPIaebpKmkinlZ7YQ1vSQCCf3TtRGGS9y53fgFRuuh0q3ZmUpgVvnRLuQA52ptYg fW9297KisD/tcljt5M641rUAJM/eoDNcpZMQ6t981pOpu11JvMFQTEPXLprnkpVxOLG6f/ dd2ifNpcZyKBQSgqjgHXWv3xoCdkquw= X-MC-Unique: -jMyWzUkPu6zOWyE8wK2kA-1 X-Mimecast-MFC-AGG-ID: -jMyWzUkPu6zOWyE8wK2kA_1782469164 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469164; x=1783073964; 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; bh=qkoE8S6UBX3o+N0SXfwXHK1tv2NXu1sYxgKB0nzO2dY=; b=blLisRH+q8PnXkpbtzKHUve5cT5zqinE3aqgBiiwnjKikvSDsO5RQQWP30p4BSh+q6 W3CBjxYIhben6QXsc8R4meOsOgRkR7wijHBePYZDuquNVo0IDHdeQi/VcSVngb78RnMt QsBHyeyFjW3Vzne9cDdp/3GOi6SodH+4qQXPDFH+I4wEdsINa6HN+gZ56RoBVvh+LosA TKbjtX/LWuSfXv8IaExUQsRvK1YcgpERRvopiY/CEUANzCGJ0GigTLl20EAZ++OzAxCK pcNDIlqoaB1XVzEL20HV7ratgAL6Ri9azavRn7eAzh2gMrEQiopXLinbALpiN6Lf1y1r eHlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469164; x=1783073964; 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; bh=qkoE8S6UBX3o+N0SXfwXHK1tv2NXu1sYxgKB0nzO2dY=; b=tTuvpt31BC1zJFW8VqeqGxn1tCK6HiFhXH5DvGWeDNk0bm4axFgR7aBOFfzs8EVxKy dmhEpT6Gs/roWrZ1RVaHfcdeOabO02eNXWthvbmv1AiU4W4c8rBUbhfFjBNk76IFADVb 6X/9J4tNnXXw4IpeQlZnmplbGfYGzO/jqI0ghvFn9kVYT8AFLNWFKjnxGh0dcTfZh8fu MU+zby/sePtKMSkBctJ3J5gGf+ZQ5LzNvu8dA2q1MG+HBUOTOlBtkHBQU7JwGa1E3mt+ zCm8XkLzVoMj8zcKvUo4O10v6INqxkt9DJ1Mi0Td8x98ByiwO1QhOHzFGPhlR6j/oIDD rFLw== X-Gm-Message-State: AOJu0Ywwu+Elj3jkFz/FfibQLqyOczXcywhBPD5qF+Qopd0OBIPd5zWb OgjPW0qIYmGz9F7nHAixevF8vQObe2DJn7gEvCYhF2U7PNex8ysDrU6Cp8SABbSxtUmB+keVF5K 5nqNhqTIrX2Xgu5Ix1abVuul356RtM5xmWgOnSHAa2xwTWePJ44E0lFeJscRO7XEux0E2E08an7 3Guw+fZTWX6DwB1+igoSb88lwieceF4dPrk6+HUmMx X-Gm-Gg: AfdE7cmG57C4Xv422YYPxYADG4PpBdDeZF5MBB6hh5QDFB0Qqv4zXIMOhqEii8J1EIL OzvZ/KbmVOb+zAO/kUj9rlpZ+2AclB6NKVHPxVn84rL1Gqgx4sl6CpkzdlHo2LbiRxnLnG2kmg+ ZoJY3dwHejqsDHlYiFxroTVH92cRa2nCH5A75yrz6qkLpURDvSqdky7CeKziLEwSN1r9vsZYDtC SyGF81CIWUuYl6Lfco7lfYWejhfGQWQIVJ7fWK45FpKqZsqMS2z5Ws0eBNRk+uIrFCcc5HK1lKa JdtIBu9rZs+TVReCdg50yjTB62yNpiRlurkmD/BGMbjf52cn6DR0wOGO8Kis9QCmFbs3IBZX1+H Dcdv7+kylbW9TNc2Wd6sgXyHk17eIUE/AViiIlsuAf92C7LvaK5KRbwIDz27zV18d8K8IO1UXr2 jn55v5W2qqi/2vYEOT X-Received: by 2002:a05:600c:4745:b0:490:b355:9c70 with SMTP id 5b1f17b1804b1-49266873f5bmr86529425e9.11.1782469163648; Fri, 26 Jun 2026 03:19:23 -0700 (PDT) X-Received: by 2002:a05:600c:4745:b0:490:b355:9c70 with SMTP id 5b1f17b1804b1-49266873f5bmr86528915e9.11.1782469163154; Fri, 26 Jun 2026 03:19:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= , Mohamed Mediouni Subject: [PULL 34/45] include/hw/hyperv: add hv_vp_register_page struct definition Date: Fri, 26 Jun 2026 12:17:37 +0200 Message-ID: <20260626101748.1728079-35-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469197728158500 From: Doru Bl=C3=A2nzeanu Define the `hv_vp_register_page` structure that the linux kernel uses to allow access to vcpu registers. This structure is going to be used in later patches to access vcpu registers. Signed-off-by: Doru Bl=C3=A2nzeanu Reviewed-by: Mohamed Mediouni Link: https://lore.kernel.org/r/20260428135053.251200-4-dblanzeanu@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- include/hw/hyperv/hvgdk_mini.h | 103 +++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h index c6749a95255..f8838a31bbe 100644 --- a/include/hw/hyperv/hvgdk_mini.h +++ b/include/hw/hyperv/hvgdk_mini.h @@ -504,6 +504,109 @@ struct hv_input_assert_virtual_interrupt { uint16_t rsvd_z1; } QEMU_PACKED; =20 +/* Flags for dirty mask of hv_vp_register_page */ +enum hv_x64_register_class_type { + HV_X64_REGISTER_CLASS_GENERAL =3D 0, + HV_X64_REGISTER_CLASS_IP =3D 1, + HV_X64_REGISTER_CLASS_XMM =3D 2, + HV_X64_REGISTER_CLASS_SEGMENT =3D 3, + HV_X64_REGISTER_CLASS_FLAGS =3D 4, +}; + +#define HV_VP_REGISTER_PAGE_MAX_VECTOR_COUNT 7 + +union hv_vp_register_page_interrupt_vectors { + uint64_t as_uint64; + struct { + uint8_t vector_count; + uint8_t vector[HV_VP_REGISTER_PAGE_MAX_VECTOR_COUNT]; + }; +}; + +struct hv_vp_register_page { + uint16_t version; + uint8_t isvalid; + uint8_t rsvdz; + uint32_t dirty; + + union { + struct { + /* General purpose registers (HV_X64_REGISTER_CLASS_GENERAL) */ + union { + struct { + uint64_t rax; + uint64_t rcx; + uint64_t rdx; + uint64_t rbx; + uint64_t rsp; + uint64_t rbp; + uint64_t rsi; + uint64_t rdi; + uint64_t r8; + uint64_t r9; + uint64_t r10; + uint64_t r11; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + } QEMU_PACKED; + + uint64_t gp_registers[16]; + }; + /* Instruction pointer (HV_X64_REGISTER_CLASS_IP) */ + uint64_t rip; + /* Flags (HV_X64_REGISTER_CLASS_FLAGS) */ + uint64_t rflags; + } QEMU_PACKED; + + uint64_t registers[18]; + }; + uint8_t reserved[8]; + /* Volatile XMM registers (HV_X64_REGISTER_CLASS_XMM) */ + union { + struct { + struct hv_u128 xmm0; + struct hv_u128 xmm1; + struct hv_u128 xmm2; + struct hv_u128 xmm3; + struct hv_u128 xmm4; + struct hv_u128 xmm5; + } QEMU_PACKED; + + struct hv_u128 xmm_registers[6]; + }; + /* Segment registers (HV_X64_REGISTER_CLASS_SEGMENT) */ + union { + struct { + struct hv_x64_segment_register es; + struct hv_x64_segment_register cs; + struct hv_x64_segment_register ss; + struct hv_x64_segment_register ds; + struct hv_x64_segment_register fs; + struct hv_x64_segment_register gs; + } QEMU_PACKED; + + struct hv_x64_segment_register segment_registers[6]; + }; + /* Misc. control registers (cannot be set via this interface) */ + uint64_t cr0; + uint64_t cr3; + uint64_t cr4; + uint64_t cr8; + uint64_t efer; + uint64_t dr7; + union hv_x64_pending_interruption_register pending_interruption; + union hv_x64_interrupt_state_register interrupt_state; + uint64_t instruction_emulation_hints; + uint64_t xfem; + + uint8_t reserved1[0x100]; + + /* Interrupts injected as part of HvCallDispatchVp. */ + union hv_vp_register_page_interrupt_vectors interrupt_vectors; +} QEMU_PACKED; + /* /dev/mshv */ #define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_= partition) #define MSHV_CREATE_VP _IOW(MSHV_IOCTL, 0x01, struct mshv_create_= vp) --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469363; cv=none; d=zohomail.com; s=zohoarc; b=GoTZp6mEO9Z5yenGRlGKAvr7pe09VI7RnNIyrEBAtwo/TQVimmnXrHy2Sf+ytLzKw8AVr/S0nkTzXlIPsAOlRcCtGwHjHn/9Mk+3bFIt4P4iWDExlRcgUkUJosGkmJTEQjZH4xkfZXWgLidDgWFLNnL490bYXlQUOro5qftZegg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469363; 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=UpA0ZMYEARfbuoCSlWmOkhd8EMX7+Uh6D+r5pGTpStM=; b=FJ+3UQ7Lm8VmBfB+iB16qdqNoyJ2UMu8VjGRLeT4BymrhWzw0IBqH0Mc0+MUuchT2r3y9hfJ6MmOtFG1S/8AUFoU+PyF592YDlN7IrRon8HAcGsQbNA4KLiaYXuzznXv0hjeSTdiV8NnOZH1AtgF3AfYezHpJPcsAz1E/0Eux2I= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469363576475.82229337633373; Fri, 26 Jun 2026 03:22:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3eo-0002Em-TR; Fri, 26 Jun 2026 06:19:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ek-0001jS-NT for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ei-0005Oy-NZ for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:30 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-316-eBmzDWC2NUSFsMb92al2cQ-1; Fri, 26 Jun 2026 06:19:26 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-460153ce644so451106f8f.0 for ; Fri, 26 Jun 2026 03:19:26 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c22c680fasm24258434f8f.34.2026.06.26.03.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469168; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UpA0ZMYEARfbuoCSlWmOkhd8EMX7+Uh6D+r5pGTpStM=; b=bIjuNKSW1Jwqs04/GQ+53Xyaum/nLvxezug4QwR6STiF1r0Z9Egjzn8JaO+VABxbAwMIUT xOpxx6TiJdKa+x65mo7oq8Wv/8KSwYL0qt3SH2Id/Jt2cpz4jjcMeHNwFPFgy3DFdIha/O DjNwLC80GnR7+Tgo+AMxo1aYFEuT64c= X-MC-Unique: eBmzDWC2NUSFsMb92al2cQ-1 X-Mimecast-MFC-AGG-ID: eBmzDWC2NUSFsMb92al2cQ_1782469166 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469165; x=1783073965; 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; bh=UpA0ZMYEARfbuoCSlWmOkhd8EMX7+Uh6D+r5pGTpStM=; b=dTVBt2QqLYzy4S3RsKniBu83cGhfz8kmd+Xa9u5hQYHJR2Jd8DFNfkoTXLGSd/5zyU CakoqbHiglG17bDoS72QBsgkj6qn93t7P3jyoXcydou56MCRwJ6tasaSbN8ugE2tziQd wynuZ1rc01JIDodUgvQNfQOgtZSNiz+C/0fyKp43fQbfdB4+B0gP4nl60n1H/LlE0xuO CdET0yfIl6aq+hAeDaMtAyFmHmX4WDp1Lc1DRYKZapATZ8T796ul5yN1Je5wnXeHoDTV 6eiLNpWxDkUxJRA5xBtr5C1fkMbxshhoBk6WsoUZs61M8SL6krr1qehKP52w6G6JeU21 MCGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469165; x=1783073965; 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; bh=UpA0ZMYEARfbuoCSlWmOkhd8EMX7+Uh6D+r5pGTpStM=; b=fQerfz59wewBxvJD6o+VsqTsvuAfTcQJvBcs5BP3bSsYQCNJpen5XuA/oTZl/7FxX6 QP0Mf3UN8ozcu0RGQuZzI4qvn/fmhQVG5sW1+b1rrCZORLd7t3wuAkABClw9DhGPrq+8 2/KOfusuJQ+xceEI7roiD0ItieYVNJTZzml/CPln+JPhTOOxCaXS4hkzZbSwNPHUEUT4 XEKKY7GcgeyfEuR3vfUuElkPSkwYQ9jZCwHaOLg56kFmMiUmh1KbdiW9hkbcytrHRtzx 75lTXYoC2vcWVnGzS4aNyUI+0saQ0xAp11B/8Pmekff06evbnDL4zcX5gHtlloeHObOE vFww== X-Gm-Message-State: AOJu0YyxiX20JcbuzD6m9PD4zVZOXyzy8biysPyByDejsSqXoiBdVPRA w7SFb03cxSMSNqHD2KNeZaFk4QHnaZx6f2NgxzS9t7Lb2b7ErUlmSn3jyFC0UUybu/9rBddjUjk My0PIDgGht412QZyYXA/6XQUONJxeP7nmpuyGzcXEDe9TIII0A2f6zOCrIndlekhnrQUNAZXMdI uGmw7b93+E14K1iWPPDZ5Wua8X4PZ5lzLu07cmi4YS X-Gm-Gg: AfdE7cnXe5Agp4f9tIhW+y99gR9uNWmSnDGjUrWBRmUqlmPS7LZil4YYeYWGayl9jwf utLNc0YG8rrNuV1hygx8NcxZFdSJ1TmqKOuPNKaHFx5V0zWOAqb5wBcbADkGf/p9CRBWNkGsFbJ 3iPLgRrPC+y4qpec3w0cdrc46WdGYTAgA1tuAsoU3kTOmlUiYdkXT18Y1LiuBzS2cc11JFRET/f H++rc9Wn24wqReRJUnZAfIRhwwJu7rnfvevRiZaujgObF7aYDrQYCAs1Cr7qxSW0BSHtflDgjRB pRiZ7qRNpWXxkEtWv4hRKss3TAXi8W+HD93HdiajkY8GLVqdIfNnJafqoXH47v7u9O4u9/QVyoe U7Sz4KTWu0isnisHDD6zH0g57wkDGVTpGtC6wdfda1SjReN/A4385DnnOtPI5YzNQpgxuxbi6WW Rg/tJOVps561fvLOeP X-Received: by 2002:a05:6000:2408:b0:46e:e2a0:9f54 with SMTP id ffacd0b85a97d-46ee2a0a0abmr4122059f8f.13.1782469165482; Fri, 26 Jun 2026 03:19:25 -0700 (PDT) X-Received: by 2002:a05:6000:2408:b0:46e:e2a0:9f54 with SMTP id ffacd0b85a97d-46ee2a0a0abmr4121968f8f.13.1782469164859; Fri, 26 Jun 2026 03:19:24 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= , Mohamed Mediouni Subject: [PULL 35/45] target/i386/mshv: hv_vp_register_page setup for the vcpu Date: Fri, 26 Jun 2026 12:17:38 +0200 Message-ID: <20260626101748.1728079-36-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469364521158500 From: Doru Bl=C3=A2nzeanu When the vcpu is created, call mmap to configure access to the register pag= e. Update CPUArchState to store a pointer to the mmapped hv_vp_register_page. Signed-off-by: Doru Bl=C3=A2nzeanu Reviewed-by: Mohamed Mediouni Link: https://lore.kernel.org/r/20260428135053.251200-5-dblanzeanu@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 9 +++++++-- target/i386/mshv/mshv-cpu.c | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 67e2ecf3251..e6a197602d8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1983,6 +1983,9 @@ typedef struct CPUCaches { CPUCacheInfo *l3_cache; } CPUCaches; =20 +struct kvm_msrs; +struct hv_vp_register_page; + typedef struct CPUArchState { /* standard registers */ target_ulong regs[CPU_NB_EREGS]; @@ -2289,6 +2292,10 @@ typedef struct CPUArchState { QEMUTimer *xen_periodic_timer; QemuMutex xen_timers_lock; #endif +#if defined(CONFIG_MSHV) + /* Shared register page */ + struct hv_vp_register_page *regs_page; +#endif #if defined(CONFIG_HVF) || defined(CONFIG_MSHV) || defined(CONFIG_WHPX) void *emu_mmio_buf; #endif @@ -2315,8 +2322,6 @@ typedef struct CPUArchState { DECLARE_BITMAP(avail_cpu_topo, CPU_TOPOLOGY_LEVEL__MAX); } CPUX86State; =20 -struct kvm_msrs; - /** * X86CPU: * @env: #CPUX86State diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index a383e0ab104..67dfb3c42ab 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -1906,6 +1906,18 @@ void mshv_arch_init_vcpu(CPUState *cpu) + sizeof(hv_input_get_vp_registers) > HV_HYP_PAGE_SIZE)); =20 + /* mmap the registers page */ + void *rp =3D mmap(NULL, page, PROT_READ | PROT_WRITE, + MAP_SHARED, mshv_vcpufd(cpu), + MSHV_VP_MMAP_OFFSET_REGISTERS * page); + if (rp =3D=3D MAP_FAILED) { + warn_report("register page mmap failed, falling back to hypercalls= : %s", + strerror(errno)); + env->regs_page =3D NULL; + } else { + env->regs_page =3D (struct hv_vp_register_page *) rp; + } + state->hvcall_args.base =3D mem; state->hvcall_args.input_page =3D mem; state->hvcall_args.output_page =3D (uint8_t *)mem + page; @@ -1944,6 +1956,11 @@ void mshv_arch_destroy_vcpu(CPUState *cpu) CPUX86State *env =3D &x86_cpu->env; AccelCPUState *state =3D cpu->accel; =20 + /* Unmap the register page */ + if (env->regs_page) { + munmap(env->regs_page, HV_HYP_PAGE_SIZE); + env->regs_page =3D NULL; + } g_free(state->hvcall_args.base); state->hvcall_args =3D (MshvHvCallArgs){0}; g_clear_pointer(&env->emu_mmio_buf, g_free); --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469229; cv=none; d=zohomail.com; s=zohoarc; b=hEhGkcqP+/RdCruMvPpuVyBdbyUtzTXITOIdTViOqNoDSsER5uTEoiJiguNFJAChe7R/Lg/To1CI5iHWcE11/JPe/li4eC5Go2/uOAv2YIkELQTtmZ5BP76xVwF7AX0cNsuDOO2dtkRq31prbutO4avxvfKf1cAjLgoiQ/6NX2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469229; 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=xjXgKIQvuuURFsFo6ZsMyVnrW+K5pqB6u7N2zlmowN4=; b=Yiju7N9aO2gRvvFZMBPNcZFgMEjOHxDt2vrpuOJpt3tOvxXdhIpHXOuzWMUC9SKB40Arw/grzfxxaTx9DB66BoN86hDe9LKp0hD/N3wZUoefJout1che8VBOESnHQxzFlL/RilGGRcj6L2W62Mep+eoanuiYR4qWWD7wH7ZRTQY= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469229632661.9938415059958; Fri, 26 Jun 2026 03:20:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ep-0002Pl-TZ; Fri, 26 Jun 2026 06:19:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3en-00029F-TE for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3el-0005PQ-RJ for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:33 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-gRs9yvj4PISvNcU168YRuw-1; Fri, 26 Jun 2026 06:19:29 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4924d5231daso6079155e9.0 for ; Fri, 26 Jun 2026 03:19:29 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4926c01de4fsm48657995e9.0.2026.06.26.03.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469171; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xjXgKIQvuuURFsFo6ZsMyVnrW+K5pqB6u7N2zlmowN4=; b=YgUQNyEC+1GsAboSmbdf2I1K15GfLrrmCacLS2S+OJcE7Oc52g9yR5J9kQIpOlTkuNejP5 58Vld5Ai7+iPqiBKdcp+8dlLi4Ucl9XSVUpQ+OEQhKK8iKaiwJ4MGlzs/SZ83awyaRu8Tu pU8COuvI0FWxLo0VK6B3875CzvPIPLo= X-MC-Unique: gRs9yvj4PISvNcU168YRuw-1 X-Mimecast-MFC-AGG-ID: gRs9yvj4PISvNcU168YRuw_1782469168 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469168; x=1783073968; 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; bh=xjXgKIQvuuURFsFo6ZsMyVnrW+K5pqB6u7N2zlmowN4=; b=WQCcQeRHGOVexs3A9ZuRS1QoP3WzkVcLp/Q/QT3ieJqqlw9KsD3icvlmCdHZJfxI5T C2r6k+c3tiOpA69piwWa9DLYM2YjHVI2uceHyb75YWQ+x0ZtQPmTdPQgfATBorrOUmrn k/ivUCXl88SCjkETtcFo2beCl8FG3RDdE3LT/FWsNjatyCDcoxOI1hc1ksRraF2MZKAi frghdKHWnb8inMNN2IGSUNY6G5tOLUWgDLGravAl/22QWNqXkkb7Loe7WcnwTxswAvjJ 0F84piakoL5my+f2P0CPE4wA+lyfm7RPBkn5yyj9a6TObLo1V6AXRRq7oNzsr2UPRB+9 laKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469168; x=1783073968; 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; bh=xjXgKIQvuuURFsFo6ZsMyVnrW+K5pqB6u7N2zlmowN4=; b=QrXsAeaH3ZtrE7oK2dhlfpaRX3C+mccd0o9+PeFun3qddM9JQI4dV7So/7zEo3nU6E T77bb8Pd47WIPc2TTYgC0NkxP7BSp5mi/lcZz+MbItSdHevol7ae/UcBrfrdbnRXdpxf Mc/wgNI9RASS/Jny5Dw5MVBOsknpsq4iHoAXYSZ43Bz8Q0LosOqP1t2j54gq4jiRMYmc cES6BBKUU8y+x4/exfT7IG01+Zz+IiZdzaLzh08mAQFdj97KNo9D/9HLlKakQEZ433L8 ThmArMou71CgKBPgDnloNjLoKZdTYSI27DO8yktOgyKJMQbSCaSqs2pe2sQs/UmOwQFc eIqg== X-Gm-Message-State: AOJu0YxjOD2BPvxP+z/NSUwN5pZIBHHcStdc0qzoAYDICdf0Zy3196gN PPmKkH7FV66CE5GBT3P0qZItmRBLQzfA93AHu9fAjOs84iMsUb5g+4MLbCPY5Od1poqkginFghQ Q5xKD9gbaMczatC9zfW50JCKkjfzDdJqB8gOHyQr9rm7ilRFHuFurhaIXkNBmGCWOeYTNl/SgQM UmxQ/ohQcVKg5xeMvi8gI0mbiSyBGqmn9qQQl4wirJ X-Gm-Gg: AfdE7clOTee16MJmKKS2dKsbLj0L6uYF2jGoY00ME8kCyr8Bwe3+O6RQ97q12RRvhTO XlqItnsj1XCKPJqnkxFOA+RFENXnFFxEg8rhuM8nrd1lmYugFHkC/MvzqAoUigigORcLAG7Vpgb u6lhnK102mgVfL2jH8ab13H1q4O04vvsKfpSb8h2Q8JbjP2N7GMHlSN0cNxyxecBmR/nG8eEMbq 4Z1XzvZX0EOgmjJIbln20UoRk54bz3jxlZoyS0VuhtfHqGkHOi/j1QAKOymXMBgtOOHNoakiRm/ t3lM5+1WdkWSMnAaC3OtF+JhQztz45y4DF6c6O2u71wtJu0kwFFN9zqHbedl0r+YVt0R0B9LD6r inQW4mMHeI+88vqOTgpsPQ297AO55eUlNwi4DsaufQxfbPZixpIJcUvAyDAJ6ZsgEaYTQOpWz9y ikzdJZjrop2YqIMkuv X-Received: by 2002:a05:600c:1d0e:b0:492:5bf9:cbbe with SMTP id 5b1f17b1804b1-49266899d25mr93099825e9.23.1782469168085; Fri, 26 Jun 2026 03:19:28 -0700 (PDT) X-Received: by 2002:a05:600c:1d0e:b0:492:5bf9:cbbe with SMTP id 5b1f17b1804b1-49266899d25mr93099175e9.23.1782469167543; Fri, 26 Jun 2026 03:19:27 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= , Mohamed Mediouni Subject: [PULL 36/45] target/i386/mshv: use the register page to get registers Date: Fri, 26 Jun 2026 12:17:39 +0200 Message-ID: <20260626101748.1728079-37-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469231986158500 From: Doru Bl=C3=A2nzeanu Change the mshv_load_regs to use the register page when it is mmapped and is valid. Otherwise use the existing logic that uses ioctls to fetch registers. When retrieving the special registers, there are some registers that are not present in the register page: TR, LDTR, GDTR, IDTR, CR2, APIC_BASE. For this ones we still need to use ioctls to correctly fetch. Signed-off-by: Doru Bl=C3=A2nzeanu Reviewed-by: Mohamed Mediouni Link: https://lore.kernel.org/r/20260428135053.251200-6-dblanzeanu@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 117 ++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 67dfb3c42ab..ed78fa09934 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -270,6 +270,15 @@ static int get_xc_reg(CPUState *cpu) return 0; } =20 +static enum hv_register_name NON_VP_PAGE_REGISTER_NAMES[6] =3D { + HV_X64_REGISTER_TR, + HV_X64_REGISTER_LDTR, + HV_X64_REGISTER_GDTR, + HV_X64_REGISTER_IDTR, + HV_X64_REGISTER_CR2, + HV_X64_REGISTER_APIC_BASE, +}; + static int translate_gva(const CPUState *cpu, uint64_t gva, uint64_t *gpa, uint64_t flags) { @@ -570,6 +579,106 @@ static void populate_special_regs(const hv_register_a= ssoc *assocs, cpu_set_apic_base(x86cpu->apic_state, assocs[16].value.reg64); } =20 +static void mshv_get_standard_regs_vp_page(CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + + /* General Purpose Registers */ + env->regs[R_EAX] =3D env->regs_page->rax; + env->regs[R_EBX] =3D env->regs_page->rbx; + env->regs[R_ECX] =3D env->regs_page->rcx; + env->regs[R_EDX] =3D env->regs_page->rdx; + env->regs[R_ESI] =3D env->regs_page->rsi; + env->regs[R_EDI] =3D env->regs_page->rdi; + env->regs[R_ESP] =3D env->regs_page->rsp; + env->regs[R_EBP] =3D env->regs_page->rbp; + env->regs[R_R8] =3D env->regs_page->r8; + env->regs[R_R9] =3D env->regs_page->r9; + env->regs[R_R10] =3D env->regs_page->r10; + env->regs[R_R11] =3D env->regs_page->r11; + env->regs[R_R12] =3D env->regs_page->r12; + env->regs[R_R13] =3D env->regs_page->r13; + env->regs[R_R14] =3D env->regs_page->r14; + env->regs[R_R15] =3D env->regs_page->r15; + + env->eip =3D env->regs_page->rip; + env->eflags =3D env->regs_page->rflags; + rflags_to_lflags(env); +} + +static int mshv_get_special_regs_vp_page(CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + struct hv_register_assoc assocs[ARRAY_SIZE(NON_VP_PAGE_REGISTER_NAMES)= ]; + int ret; + size_t n_regs =3D ARRAY_SIZE(NON_VP_PAGE_REGISTER_NAMES); + hv_x64_segment_register seg; + + /* Populate special registers that are in the VP register page */ + env->cr[0] =3D env->regs_page->cr0; + env->cr[3] =3D env->regs_page->cr3; + env->cr[4] =3D env->regs_page->cr4; + env->efer =3D env->regs_page->efer; + cpu_set_apic_tpr(x86cpu->apic_state, env->regs_page->cr8); + + /* Segment Registers - copy from packed struct to avoid unaligned acce= ss */ + memcpy(&seg, &env->regs_page->es, sizeof(hv_x64_segment_register)); + populate_segment_reg(&seg, &env->segs[R_ES]); + memcpy(&seg, &env->regs_page->cs, sizeof(hv_x64_segment_register)); + populate_segment_reg(&seg, &env->segs[R_CS]); + memcpy(&seg, &env->regs_page->ss, sizeof(hv_x64_segment_register)); + populate_segment_reg(&seg, &env->segs[R_SS]); + memcpy(&seg, &env->regs_page->ds, sizeof(hv_x64_segment_register)); + populate_segment_reg(&seg, &env->segs[R_DS]); + memcpy(&seg, &env->regs_page->fs, sizeof(hv_x64_segment_register)); + populate_segment_reg(&seg, &env->segs[R_FS]); + memcpy(&seg, &env->regs_page->gs, sizeof(hv_x64_segment_register)); + populate_segment_reg(&seg, &env->segs[R_GS]); + + /* The rest of the special registers that are not in the VP register p= age */ + for (size_t i =3D 0; i < n_regs; i++) { + assocs[i].name =3D NON_VP_PAGE_REGISTER_NAMES[i]; + } + + ret =3D mshv_get_generic_regs(cpu, assocs, n_regs); + if (ret < 0) { + error_report("failed to get non-vp-page special registers"); + return -1; + } + + /* Non-VP page registers - TR, LDTR, GDTR, IDTR, CR2, APIC_BASE */ + populate_segment_reg(&assocs[0].value.segment, &env->tr); + populate_segment_reg(&assocs[1].value.segment, &env->ldt); + + populate_table_reg(&assocs[2].value.table, &env->gdt); + populate_table_reg(&assocs[3].value.table, &env->idt); + env->cr[2] =3D assocs[4].value.reg64; + + cpu_set_apic_base(x86cpu->apic_state, assocs[5].value.reg64); + + return ret; +} + +static int mshv_get_registers_vp_page(CPUState *cpu) +{ + int ret; + + /* General Purpose Registers */ + mshv_get_standard_regs_vp_page(cpu); + + /* Special Registers - makes a hypercall */ + ret =3D mshv_get_special_regs_vp_page(cpu); + if (ret < 0) { + error_report("failed to get special registers for vp page"); + return -1; + } + + return 0; +} + + static int get_special_regs(CPUState *cpu) { struct hv_register_assoc assocs[ARRAY_SIZE(SPECIAL_REGISTER_NAMES)]; @@ -592,8 +701,16 @@ static int get_special_regs(CPUState *cpu) =20 static int load_regs(CPUState *cpu) { + X86CPU *x86_cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86_cpu->env; int ret; =20 + /* Use register vp page to optimize registers access */ + if (env->regs_page && env->regs_page->isvalid !=3D 0) { + ret =3D mshv_get_registers_vp_page(cpu); + return ret; + } + ret =3D get_standard_regs(cpu); if (ret < 0) { return ret; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469367; cv=none; d=zohomail.com; s=zohoarc; b=UdMTOk4VClA6AbfScxvh7liicnT+K6PGUJbcgvR3kwvKNU0uB/g76Z0uHHEFR05V1r6faACrCq/S09fg+YS7ym2OXhcpqubL0s9CY5rxMoR4OQyrJAmludnq34eCu/y0uJ8JcfE7/xFNgondsb0lzphbKwG6yTSl6kveBx0ja48= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469367; 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=3y6MpIRsqSm+hRQ0htHk7PXvzfcAGWEttHbyWAVRX6E=; b=isxv+63qAqScK6+CTn8d+Z7UjfpH73IU4Q41TIRXP3JcAHFDQ2K8WpfjMzfg8Nj/pvLA2zzR0zUkBKMX8wcZ5PdN8oOyjPwSKIb/LKyRgfCedal0bpnQeFfPup/V6oUUUwWbbo4+KT5rCIYGGoXlxD34QLuCDykmhvJX+039bzA= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469367683784.9185746960261; Fri, 26 Jun 2026 03:22:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ev-0002to-4p; Fri, 26 Jun 2026 06:19: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 1wd3er-0002ZM-D7 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ep-0005Pg-H9 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:37 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-676-q_L5pJ-gNJqAPhzwpvtDrQ-1; Fri, 26 Jun 2026 06:19:31 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-490afe64f26so4034825e9.0 for ; Fri, 26 Jun 2026 03:19:31 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fef710sm119444625e9.7.2026.06.26.03.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469174; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3y6MpIRsqSm+hRQ0htHk7PXvzfcAGWEttHbyWAVRX6E=; b=MWotOpB/ddtmCUysJwyjndZV+eDXkvGxvqt8VFEpViVbWK2GJBXXxwwX1eRL+lUNSVLmav pj+OCmtKC8LO7shJZ4nRFfeaWVLBiGC3pjX+9DDzyEdK+WN6jIn5pDQcc/DPu/8p5iKGSu gaGWnmc5kFes8+cgpSsgxHEC0n8ZoPs= X-MC-Unique: q_L5pJ-gNJqAPhzwpvtDrQ-1 X-Mimecast-MFC-AGG-ID: q_L5pJ-gNJqAPhzwpvtDrQ_1782469170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469170; x=1783073970; 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; bh=3y6MpIRsqSm+hRQ0htHk7PXvzfcAGWEttHbyWAVRX6E=; b=gsjNBa6gyHhs9LW9TJn54xyXGMuRRLl78z7mBtzsbTEAb/C97KBbm6HipnQnd4qv/C UriQd1QwreXZ0CzHGXMkTsdiqKdOo+UMtvdyC7GNVeu+jjE2M3jB3Vbg5lh3HQTI8KvF BEzuMj/+YOjpN78irbLJl/euxKpGI2ajupNcJUcKN9OIOkgSu+hhHJr8wAfjzIEe0EML Xqj5nUS5RR/6uO7P95twqpuUTtJ2Xkl70eIwN0bf2ExHGUw90HY3CMhz4evnfcU7k50p 0jkQ3QdZ9psX3uqJl2kYpyDJOBVey7koGpdV0LMGuhO+67SksAnip1IbKPyvPC09OOyy GxPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469170; x=1783073970; 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; bh=3y6MpIRsqSm+hRQ0htHk7PXvzfcAGWEttHbyWAVRX6E=; b=Ud9esy0bR+Ioh2uAq9t3pPAR3NBiztgvp3VINYZxwIddz2p3I6NvSb1oDwIAD91WdA Lk45wF6EksDPhDxZwjOtZ99mkKBgjLz6i+Zws2spkg7nxmWq82FdRbUIWpjFFeEypnPo fGJI7c3VULJ+r35qIHR+DojXYWHBg8BLM4SG+gXKzY85LGeyictviM/mhnb1xojGwsD1 F+Zjer8dtSuK9bbwJTrCfTiFjhGCPr11sTWsX4KrxjHOpsjbEWTbm22rGlP2zZLNjFhA NIyu3w5NuuZlCm9Ptqs2vF5U9UfD1pULKw9nKOv1yVAFBPT3ULQ1J/1hjy4BlyeLrcUq ti9w== X-Gm-Message-State: AOJu0YyN+ENOj7TKURGdWEEduUxX08x7+CWRE1+SpaE6hCg4VyR51nvQ RiTGvNh7LVjF3DYaFxm+gbsoeOYtwx9hkxQJP6Db+urgHdXcWY5rS6/fZBsRYQnMDaiCuOGag4y OvWE2vXfoPgLjTPqbu+OrZDswQk/uHZoZ5dXn/PYCBiM18vGurBRyA7CV016dkkvzJGUjTPBkki eecoMegEgG+o15Rtc4y/LWd1x4zgKur/xJODnDHkQR X-Gm-Gg: AfdE7cmLFd0lglGjq4KFkeglXjBQ0O9VcJTVuO6krZi/TQ+9Sydr+vz1YCgrCDnJoLG Bgs8tr4o6+PUecd2mOr7TFZVHvQZW0jVvi5LTtE+/VBXpL1v4X35S+xAHjWkxLal3R9aVF5Ozx1 ailW3M0DFvvXy2IJV+lCit60fvSwaZVFDseUCjoz5sBZ7QpV9o6tlF7lUZh3h5V24+rKSdCSPu+ 9RAxpOJbM7stwmULxjSl1IbjZCaWr7c8n+VscTSiDbc1DUBmOQsx+cbqvOanIy50Y6YEQr++p5/ peHZRGUFAaiORO1RWDlt7DV1qNKypOSpd8JcKTJO5X+zsn6+ddaWv9R260b9WxjwtCtaEugcxMh dh0Yq0lP0IGVQKb6kY+0d6fn1ekGMv3FhbM0oyzcwhVY8kSTA9G1rCYHTrFDIx/uP2/OmOos/lX NcAXkYK50gGO7p3ZJL X-Received: by 2002:a05:600c:a00f:b0:490:b26c:64ad with SMTP id 5b1f17b1804b1-492663e185dmr85546795e9.5.1782469170367; Fri, 26 Jun 2026 03:19:30 -0700 (PDT) X-Received: by 2002:a05:600c:a00f:b0:490:b26c:64ad with SMTP id 5b1f17b1804b1-492663e185dmr85546305e9.5.1782469169851; Fri, 26 Jun 2026 03:19:29 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Doru=20Bl=C3=A2nzeanu?= , Magnus Kulke , Mohamed Mediouni Subject: [PULL 37/45] target/i386/mshv: use the register page to set registers Date: Fri, 26 Jun 2026 12:17:40 +0200 Message-ID: <20260626101748.1728079-38-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469368545158500 From: Doru Bl=C3=A2nzeanu Update mshv_store_regs to use the register page when it is mmapped and valid to set registers. Otherwise use the ioctls to set the registers. Signed-off-by: Doru Bl=C3=A2nzeanu Reviewed-By: Magnus Kulke Reviewed-by: Mohamed Mediouni Link: https://lore.kernel.org/r/20260428135053.251200-7-dblanzeanu@linux.mi= crosoft.com Signed-off-by: Paolo Bonzini --- target/i386/mshv/mshv-cpu.c | 44 +++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index ed78fa09934..126ca40b481 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -457,14 +457,50 @@ static int set_standard_regs(const CPUState *cpu) return 0; } =20 +static void mshv_set_standard_regs_vp_page(CPUState *cpu) +{ + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; + + env->regs_page->rax =3D env->regs[R_EAX]; + env->regs_page->rbx =3D env->regs[R_EBX]; + env->regs_page->rcx =3D env->regs[R_ECX]; + env->regs_page->rdx =3D env->regs[R_EDX]; + env->regs_page->rsi =3D env->regs[R_ESI]; + env->regs_page->rdi =3D env->regs[R_EDI]; + env->regs_page->rsp =3D env->regs[R_ESP]; + env->regs_page->rbp =3D env->regs[R_EBP]; + env->regs_page->r8 =3D env->regs[R_R8]; + env->regs_page->r9 =3D env->regs[R_R9]; + env->regs_page->r10 =3D env->regs[R_R10]; + env->regs_page->r11 =3D env->regs[R_R11]; + env->regs_page->r12 =3D env->regs[R_R12]; + env->regs_page->r13 =3D env->regs[R_R13]; + env->regs_page->r14 =3D env->regs[R_R14]; + env->regs_page->r15 =3D env->regs[R_R15]; + env->regs_page->rip =3D env->eip; + lflags_to_rflags(env); + env->regs_page->rflags =3D env->eflags; + + env->regs_page->dirty |=3D (1u << HV_X64_REGISTER_CLASS_GENERAL) + | (1u << HV_X64_REGISTER_CLASS_IP) + | (1u << HV_X64_REGISTER_CLASS_FLAGS); +} + static int store_regs(CPUState *cpu) { + X86CPU *x86cpu =3D X86_CPU(cpu); + CPUX86State *env =3D &x86cpu->env; int ret; =20 - ret =3D set_standard_regs(cpu); - if (ret < 0) { - error_report("Failed to store standard registers"); - return -1; + /* Use register vp page to optimize registers access */ + if (env->regs_page && env->regs_page->isvalid !=3D 0) { + mshv_set_standard_regs_vp_page(cpu); + } else { + ret =3D set_standard_regs(cpu); + if (ret < 0) { + return ret; + } } =20 ret =3D set_special_regs(cpu); --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469308; cv=none; d=zohomail.com; s=zohoarc; b=UrKANLGDsvftcHl9e1CiAPf+fMbR+DggubJL/MTahw9YXMOVXbztocwsfsG/FSJGOWN4SK7UQcqwVmiay7mbCoLGIwzsPXkOfa8aEe9BHpEfhoEBGckmsSMugWWMsqWa5qSMPjRiu+3mfxrPTodrHVdoh7VO+z7qaX2XHr5Ya2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469308; 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=E9KU7ssH9wWsLEPGIbswP0xc8v660m5Ls1IHSY4SE5E=; b=AZ91D8rJGjAD2fIsYAzqytWj9YiIPw6DBOdbKs/2kT2x6Qs9Re29bDLXCnF6usQP/jT0tNbDJVeVZ+1ueZ+BFfY54DTW/VwKx0GtOATpRXrUtjT9Fm+msFr7bOKxg3yrrh+xW5fjiVsM/oh+3xVspwj3V0osSwxtihWFG+ue5Zc= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469308519762.8212350552412; Fri, 26 Jun 2026 03:21:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3et-0002iI-27; Fri, 26 Jun 2026 06:19:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3er-0002am-Mg for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3eq-0005Pk-3V for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:37 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-vfqNIp_gOT6t0j1DiRzZew-1; Fri, 26 Jun 2026 06:19:34 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-469675e37e8so448152f8f.1 for ; Fri, 26 Jun 2026 03:19:33 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46dd5f9da4fsm14912211f8f.23.2026.06.26.03.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E9KU7ssH9wWsLEPGIbswP0xc8v660m5Ls1IHSY4SE5E=; b=fufBEBhLkxnByp+xXm7CkTvtT1qJGgjzwFEuzfhqvxQXsWS23Yr2NW1AyxYiwGZyLOuJat IWfGnv5HEmBrfgqnxo29IAMidvJf7sTC+Dltt0tTUn9YuQCRuOgCiSjCQsJTHrxaVZ9ZYG y89z+pMozEhlp3fDO2lYk7crM+5uqIU= X-MC-Unique: vfqNIp_gOT6t0j1DiRzZew-1 X-Mimecast-MFC-AGG-ID: vfqNIp_gOT6t0j1DiRzZew_1782469173 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469173; x=1783073973; 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; bh=E9KU7ssH9wWsLEPGIbswP0xc8v660m5Ls1IHSY4SE5E=; b=oTZjM/wC/zrgREvHPQukFaMBvbR0z/UMUzcQkaXARse6dXHpH7Y5VYHWuUhYV4rEW1 Ohng+BbUqJQxM83EDZqZZMbmToWjOScWA+4/6zGMxO+tS4m4O5YXnCZwdfe7HgEqXp78 xqkqkSldcG+kaFROuHjNuQQzYadjxsUQonL/lyw/rTe4QNa32Aeqx4CykkSJdwTCBUDf OVvIMRBtvCEfo+qRwqjZkBuFXWJh0mj/zhgHa19JZjxMoMcybjSMaSRunKVBot29896R TyL6pEmXwzNHXYQoenytwbbVfyKJaGVziwtip3jWl0kV0CKLNnfZEtX2L+N5rvnVsmOg bXJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469173; x=1783073973; 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; bh=E9KU7ssH9wWsLEPGIbswP0xc8v660m5Ls1IHSY4SE5E=; b=oeEfVhYN0P+u+vsk9bMv3LPtzwolQa5rmEYo4zjbjeOmKwj7z9PRP6j9l0ysq422aD MtyVfbCvXjbvarIYud0nou16uU4sTgW8haoX8+1kleOE20brv037AR18lIgma1UjrK3n KWHCmhe9GJse9JRYJI0nd78bCFMBjm95QbZYeljwirtBz/3INZBbsSkBfmURw/pIV8Yk s89qiysFMPntpPEHiKxrEYCzRRxnOXQpoxbHoQw8+NxsskdCPTwPoug5jVIwgwHSuVE7 Nx4oyKsMcaPwUg59G5UOkreyD9OtXNbt+OieMb0z1lmMpF2Yj4lSwdK3jrgfJoVOvexk utPw== X-Gm-Message-State: AOJu0YxAh0iTSYE9IKRegdtzEMIs3e8fxOxTo0L7+8hrHUBfvmLrTtz3 YC5W+zG0t0QUQNl2qOkXMw0wVdVkGcijltEo/e05rGffx/EADNccu2gS4Oly8QZyrbIA+tdGbxx tmnMggX4lbUg6ZSpl/sQry9smp/acKa9VFHSRQtd9/oNqCKAoJj+W1nHjVDga+4+ceZsN5lgynu BcSnlsNmpXqJb6pJDib6m9j2JGZmp/lSZav7g3ld3+ X-Gm-Gg: AfdE7clWYo523/qM/XXF44swb+cIS6KxmpXdwsuqfcXiBc++cpKX+sbKeDUOw+oeAxB nqyMjFitxrbV6uoeYxyVTabJzqr1XG5xAVJnnP09/PMNSWBXs/MvS3nYVZAnrjFYK33U7HEYzxj 1V0qkhqDngRNm7ESSO3AXZvXRRPpBicEYHjumbQQypm2x1dYyQy3ZzyQZoXQ0L38lcZ/gCT5o6R QEghmagaPZfaHbamH3/rY0oGlRRKEjuVs0Iqmf7A56cTmHaKV8rnNbPp5aGZT3j00bffrE2HVZQ zd5N1Dv5XYs3rBi/R31EMtPJKguPK22+63e7mo9bDmvmT3ajOtnDANJDZwGV0GQfVuCuFGu7Xof lGKw7vNfeiNlDilbfzC4YWYPHThwZHkxy1QT3lOiAQDm0NAVXb3l1SfkXcZthATpaSC9GWCXZHE yUWbtSgIQS9FGxy4ss X-Received: by 2002:a05:6000:4012:b0:46f:558:a429 with SMTP id ffacd0b85a97d-46f0558a957mr3101747f8f.11.1782469172838; Fri, 26 Jun 2026 03:19:32 -0700 (PDT) X-Received: by 2002:a05:6000:4012:b0:46f:558:a429 with SMTP id ffacd0b85a97d-46f0558a957mr3101684f8f.11.1782469172306; Fri, 26 Jun 2026 03:19:32 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 38/45] i386/sev: Remove the example that references memory-encryption Date: Fri, 26 Jun 2026 12:17:41 +0200 Message-ID: <20260626101748.1728079-39-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469310051158500 From: Xiaoyao Li "confidential-guest-support" is the recommended property to configure sev for the machine, and amd-memory-encryption.rst has already switched to use "confidential-guest-support" in the example. Instead of changing "memory-encryption" to "confidential-guest-support" in the comment of struct SevGuestState, just drop the example for simplicity. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Xiaoyao Li Link: https://lore.kernel.org/r/20260512084458.622465-2-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 99cf30806be..debe6344ab4 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -160,10 +160,6 @@ struct SevCommonStateClass { * * The SevGuestState object is used for creating and managing a SEV * guest. - * - * # $QEMU \ - * -object sev-guest,id=3Dsev0 \ - * -machine ...,memory-encryption=3Dsev0 */ struct SevGuestState { SevCommonState parent_obj; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469355; cv=none; d=zohomail.com; s=zohoarc; b=PuU6k/V565PlSi5USkMTE27DqSOoHJYMVgNcpxgS+URY3fvQQibydJDXMPkHh8oAqIQ3xyD0JvxGKOpo7YAML+JhX1ovMZlWeiSb04pQHUvYiFsadHrIuwjv8T2I1xpN0tKh7UXNxLyMMkQjukTVO99kulEvpsUg2PVydTaLToE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469355; 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=8aIFFStwIQPyPGGFFcCuo9KULlPMnEEdzY+2iD1/Z4E=; b=eQoC1tCRTlKtX20EIqlLkotyC64175i5JoQF4uCVRlebXLQRjhWgICjEwlnMvCu2CKYCnFj6e7dlwzxXHYbVdhHnNXc9vkgkvdox7TxGhdQ0E+7goKCxmifBHpGi9U9mFm2o40OA+smT1gA07wEJKSCSf4HzMp2KJarSIiDEA+4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469355813814.5499267626906; Fri, 26 Jun 2026 03:22:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ev-0002t5-2R; Fri, 26 Jun 2026 06:19: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 1wd3eu-0002pL-0Z for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3es-0005Q2-GV for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:39 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-869twCt8OC2_TGV14TglXQ-1; Fri, 26 Jun 2026 06:19:36 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4924a7ae480so6774655e9.0 for ; Fri, 26 Jun 2026 03:19:36 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49269020266sm65401815e9.15.2026.06.26.03.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8aIFFStwIQPyPGGFFcCuo9KULlPMnEEdzY+2iD1/Z4E=; b=OnZ/b1rHJQc5KKvIdLuHS2fd9nNiKsqtIuW46WzVdv4TneccakHAjHDyIQJVrSN+/XjL9n EgNEs4E7nTfJeMtR50JTAa5tzGmFNdUoMzDvtlFmubEBaKTR/B3T1MCw+FDDsoIwZV26K+ 7b/TkD8QIg2I4RBhSe2vg2EV0P2OxsA= X-MC-Unique: 869twCt8OC2_TGV14TglXQ-1 X-Mimecast-MFC-AGG-ID: 869twCt8OC2_TGV14TglXQ_1782469175 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469175; x=1783073975; 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; bh=8aIFFStwIQPyPGGFFcCuo9KULlPMnEEdzY+2iD1/Z4E=; b=W6LeiXI9NaHNLtMNywOfRDaLAMX27Jd9nM+UVjY7T/T/Po2hD+hx40iSCJr3jFSsLt 67vBylBLL2++CO0bBTzF0ALHFoq8mwjDQAeKJVpaBckA+tnv4QY7m26vvSr5zP4SUWh5 Bl9SokblUBBawyUUKgSvpLrzSQKZbtq6f76IDnr1yR5Oxxi3mYLN4F931RTo0KBhxpWj hbXQADnJlIgaQOFqjtoOW5+uKK0V3bm6i9RDIk8L9aQ7sHPnjFYIcVha38vfsaZhKwRV wnZp2mtg4bWP4jgz6MfFpk21QQlG2+NOIVuU7VGgbFic2rqTUle1dfGNZgoZSvqkB+zz aonA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469175; x=1783073975; 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; bh=8aIFFStwIQPyPGGFFcCuo9KULlPMnEEdzY+2iD1/Z4E=; b=Wb/y3OxWhJwinqXQhby41+TQ1mR/apIYlOV2dASg5i6co5DqUZvtbxCIASeodzFIS0 IwOKn3v3ntdTv0FLTbxQhDa8Zd0A0U6bYsKUkhfnh5rrTIPlAE3jw4sq4/PZxVeDVJWs 7vVyuSPiGYxJSXhWiwgTS5YjZCQobK4uCCRryGl8JszlWrEoxJKLahRwLl2MB7H0eePL j4Dtlh9lt9IZNhpucl+BOvDlbwnJQv8uWfxywk3tu3PvYrlaARX1Ulh/kgVlZW4faCWc pc8k9IrVhSB70gaXKQ2IUmnKTy5oACU2BN12vGYPQLEwPtsp5XnS/0zO7BKQQlacVXbS 8g0A== X-Gm-Message-State: AOJu0YxOH5ydD0tsdSviYFXULVZRE/6svJI8M33XoCsXqgNC302u63dT Sw6Y4HSKlJ6T2fKiy47Wg0ebcy3QNN9DW85h74ijH6WTfFKduJ5hdq3Wo96JrECS2ov+AAchLaQ /S8kmx5IpmBvfD+uy2KWJQImKlCr0duKMGvF8TqloJrJAM/Cd6XCqNJrBOvz0AWI+vnLtzJJllK W0qIkWsINztocUracO7Mvckriu0gbIpbODrardB+B4 X-Gm-Gg: AfdE7clz+JBIwiEkHpQATsDHJlrwywjI9H1PsH+CuyH4UH3F6+RTnba5Be/5SNDL/Fx UIy1hMVUaq02FifCG9HohEkxqrLuZ+8th5i4EBaii1WUw45Q5ZO/zOU6BHEFr7OP2SiXMSnOo1J vZ5pJQCeFkNEkeuh8+auaij4eFW8K6rm9VK1XwCVoiqAtVabCYIqVXnAfKl9CQYPWe4koAIn0l7 DVnuumazTI/VFWCaFmQO3P3Hx+FDoSXkIoEgNwLDu3d0nEpc1pbYjDy7LuUoN+VX8V6PN/7ArVb IM3Ac6jEVp05z3s5owgt9ZqFY1MHBPUM+zkCudPL0zzyy/6TJzM7YdndqlEug5jWmg/AABKScg1 BBtVa/E8RWSAksgZbrE500T9ayMNwsOIgjIeX7iGlHde2Ih0iyRCQx7HWyyClJ5qHHrljVbXZwM 4FWmk8aD9enbGSi0eI X-Received: by 2002:a05:600d:8443:10b0:490:d32b:39c3 with SMTP id 5b1f17b1804b1-4926685feb6mr71609875e9.6.1782469175336; Fri, 26 Jun 2026 03:19:35 -0700 (PDT) X-Received: by 2002:a05:600d:8443:10b0:490:d32b:39c3 with SMTP id 5b1f17b1804b1-4926685feb6mr71609425e9.6.1782469174890; Fri, 26 Jun 2026 03:19:34 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 39/45] qemu-options: Change memory-encryption to confidential-guest-support in the example Date: Fri, 26 Jun 2026 12:17:42 +0200 Message-ID: <20260626101748.1728079-40-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469356409158500 From: Xiaoyao Li "confidential-guest-support" is the recommended property instead of "memory-encryption". Switch to "confidential-guest-support" in the example of sev-guest. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Xiaoyao Li Link: https://lore.kernel.org/r/20260512084458.622465-3-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- qemu-options.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index c799286153f..03456527910 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -6364,7 +6364,7 @@ SRST # |qemu_system_x86| \\ ...... \\ -object sev-guest,id=3Dsev0,cbitpos=3D47,reduced-phys-bit= s=3D1 \\ - -machine ...,memory-encryption=3Dsev0 \\ + -machine ...,confidential-guest-support=3Dsev0 \\ ..... =20 ``-object igvm-cfg,file=3Dfile`` --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469342; cv=none; d=zohomail.com; s=zohoarc; b=OrrR44YOZRkZeWjWbCjvqN84yzYyT96pruhKZrPibMLpGKyFhDEEhSK6bIjNBud/vPIXw46z1RNEEYFygMyrS9GUsRZmst9JzXFwCmaRs9JMztqGdcklgjEFI7zpO5+X1GYxIIR6Mo1EGHEVK7Nhrdxr69rUGg7iIsAyfr3nSp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469342; 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=jDJzWr4DPm70qXaqFLhNskSOs+Tj3s84msP9xo6bd4U=; b=JkNz5ka8QplME6SpDusMTcG7RWQho2LcwIPtJrkvol+0I0NZncwRcU/odeVtdz0LcqX82ZIS0+TXoHHVqg1TAcccuNMwTnb1hcId4KQNSKowYmVGiaJQhGbeQ9si0IZaUhmNcMbX7h0MZbRGNb/X7F4DiK9nsX0+PPHp0c6a8EQ= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469342327976.1153785425649; Fri, 26 Jun 2026 03:22:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3ez-0003FC-09; Fri, 26 Jun 2026 06:19:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ew-000365-Tq for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ev-0005QI-2v for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:42 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-dstnw27lP7ON8iN9-i7rgA-1; Fri, 26 Jun 2026 06:19:39 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4924d5231daso6080065e9.0 for ; Fri, 26 Jun 2026 03:19:39 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fe949csm79379145e9.5.2026.06.26.03.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469180; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jDJzWr4DPm70qXaqFLhNskSOs+Tj3s84msP9xo6bd4U=; b=Ye2SFDiK6atcZEoph9p3eejBcIH1ikXhieDD1M8Zw3HyM2iWUtoCO8/VRKc9+9IOfWQ4bx k2WIvnq5vJwenU7jctgSd1na6dYXvVUvGf/zaf0xe3tmxYUhcosjz2M0XzJ7ES7k1ot1c/ 2LOj8/I0Y0vwjvUXSinXMqaYWq5cWBQ= X-MC-Unique: dstnw27lP7ON8iN9-i7rgA-1 X-Mimecast-MFC-AGG-ID: dstnw27lP7ON8iN9-i7rgA_1782469178 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469178; x=1783073978; 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; bh=jDJzWr4DPm70qXaqFLhNskSOs+Tj3s84msP9xo6bd4U=; b=r5Y6rxJkLplO3gmTgiCmrI6SlmLNhEMgOuyt/hunf9XlWB5de5DnlfzamRNeT3eg5y vHLd6bwr33Tviu41VQfsvValUDHmRyZ6qsrZR4lxsFNSFbm5xoIhFkUc+cP625VvcE7h Qi6jX/TGdW7Wr17mnhqFxKRzzwUO+jrfRkhSE6BI3tG0bL7f9AJbHFojNTzUXDKgG49A vCMNB9KLe2Gz7/LhO/pIl7bNRO7Q+cdk14nsB0tSv9TIeEXUlVzeViYFyeXF5YUy/9of 4MXgryKeTNV2qUDHXrSJXS+p0C3HazdxjibnJRHvVnT/zBP5TY69rTHZV6AEm8AiuQJC Eekw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469178; x=1783073978; 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; bh=jDJzWr4DPm70qXaqFLhNskSOs+Tj3s84msP9xo6bd4U=; b=o8yY+gK8swcC07KUXK7yO68rDDpcOYObaMAOS263nnMYGHf5LOiQNcBdPokOL7VKK6 LrjlzZbAKVrnuWzvcLLkDHEdUQup5vB9Yu38LcI5fLAuVjEhZrsPCVvmes6c1gf/DIyW Jo981vYyxxUv/VhZ+/bM4vB3BnUtPYzyMOJ82TY+XS6G4qOGmj4eWG5qgTid+8ChuaHX 5DloAhQaLlJjT/1Yo2vUNle+p5SAcR11LqNCaicsSTiqB0ihnisiNiRve1OVytYtLUEt L319rlJyzlgFHbCR4IX58H2uQKEw9MSZ8j6e21ebYb44004PYwwLaOuFFthrK3/0wYmV /KKQ== X-Gm-Message-State: AOJu0YxtL2n49XShaAfcQ2aQ69wLcYgQ+gci1Ha9UG47bCDAF58FV7W6 XOBbgcEyfDT0qQdMgYhjBjj71s1q7gA3otE1GgrQdBTsn+HlJ9cxshSOFvsDMvOaW9glS9X+pYo zvW55y51YDv1h1mhyohSxmXDffXKVm7MED8BM1tBV0/tPjlErFsirgTtyhtFMkTBI12ANCNHOGk dsW3DyDhKQWuRkg2XEV/3PxpKfoID7yCc59V59R2BB X-Gm-Gg: AfdE7cnwYWUzYqTm8XBE93DVV67onVF/15xZlK+qo+qPGiNQpctPWCsO9XMs96DyhXd 2oOZUtTOInxD8WPopNJmj+qwhZutMB7iB3/CNV+1XRlTGyiEvp4yWzctG+LuGqNV/Ak7VhJ+xT6 HfRlk0UbHx2mY/1mi6aHwCwuYrt5zzU+g17FA2koLhTKZNB9ExosrGlYZ4LtqUA/Nn7DEm0Lz2y B7BTq3w1Tva1xNsYXODFBZJZoKedOOApYwo0Bbi1GFCnD48QZsZheISHIrFa+rAuVMEpUWLLsLV lZ8HloWmPCVJOlgT6IQvRt5OerhzDn9VC9OsEVpwJ3WNKk5u6XNGzJNJ/5N5bgl/gmvvPC2gIP6 x9SkvmndX9EPdDNIu4B5/3ZXPu8CxacwvpkhIC7/Nc40Vnfz+SlvT0YUE8xsOmapcGq1HG86pML Eaeg1FFlaP6pMwiT79 X-Received: by 2002:a05:600c:3b17:b0:490:b7e6:bd1d with SMTP id 5b1f17b1804b1-49266874055mr95173075e9.16.1782469177868; Fri, 26 Jun 2026 03:19:37 -0700 (PDT) X-Received: by 2002:a05:600c:3b17:b0:490:b7e6:bd1d with SMTP id 5b1f17b1804b1-49266874055mr95172445e9.16.1782469177285; Fri, 26 Jun 2026 03:19:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 40/45] qemu-options: Add confidential-guest-support to machine options Date: Fri, 26 Jun 2026 12:17:43 +0200 Message-ID: <20260626101748.1728079-41-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469344241158500 From: Xiaoyao Li "confidential-guest-support" is the recommended property to configure machine with confidential computing technology instead of "memory-encryption". Add "confidential-guest-support" to machine options and call out explicitly "memory-encryption" is the alias of it and not recommended. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Xiaoyao Li Link: https://lore.kernel.org/r/20260512084458.622465-4-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- qemu-options.hx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 03456527910..a8ee5d14e14 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -36,7 +36,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " dea-key-wrap=3Don|off controls support for DEA key wr= apping (default=3Don)\n" " suppress-vmdesc=3Don|off disables self-describing mig= ration (default=3Doff)\n" " nvdimm=3Don|off controls NVDIMM support (default=3Dof= f)\n" - " memory-encryption=3D memory encryption object to = use (default=3Dnone)\n" + " confidential-guest-support=3D specifies confident= ial guest support object (default=3Dnone)\n" + " memory-encryption=3D (memory-encryption is the al= ias of confidential-guest-support, recommend to use confidential-guest-supp= ort)\n" " hmat=3Don|off controls ACPI HMAT support (default=3Do= ff)\n" " spcr=3Don|off controls ACPI SPCR support (default=3Do= n)\n" #ifdef CONFIG_POSIX @@ -100,8 +101,12 @@ SRST ``nvdimm=3Don|off`` Enables or disables NVDIMM support. The default is off. =20 + ``confidential-guest-support=3D`` + confidential guest support object to use. The default is none. + ``memory-encryption=3D`` - Memory encryption object to use. The default is none. + The alias of ``confidential-guest-support``. Recommend to use + confidential-guest-support. =20 ``hmat=3Don|off`` Enables or disables ACPI Heterogeneous Memory Attribute Table --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469388; cv=none; d=zohomail.com; s=zohoarc; b=GFliGM1D4nGElZtK0YxuFmOwjoejD6He+1hfLbxCIF3mN+pyLHyQtNOBrmAa4oBl/N7a3Y+csGQPm5g/bM24IX06Hor3FBj0nYVaO4BWEPGkORPC4szwX9rQZca513WZyG6at8ddz1MBVutkEVwSb/Jg04tE7lF5/uFINecwbOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469388; 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=9MvxJQhtTKs4rTFMQQCaiswmThg2o/sTBst6a0P6uok=; b=kHVJfnw5kHwz8uCqx7hKSIWih/IGrLixEu2thJ9jKXeEwQ1pnhtO8CcQOf/5V/gFFmW89fLIxqBCtYveyLweI8NJibSOZo5cpjBeXj102TDO+loaHcwwmj7h9TE+L3ah5k/TVHSenSM/3Emjf1Mq/ehLr96bI8B6FK9lt7fNTBE= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469388072565.8573926675815; Fri, 26 Jun 2026 03:23:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3f0-0003IB-2y; Fri, 26 Jun 2026 06:19: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 1wd3ey-0003E5-Jo for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3ew-0005QR-Qj for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:44 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-ATu-asW7OUCX6nrMuZZbdg-1; Fri, 26 Jun 2026 06:19:40 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4924314568cso7123065e9.3 for ; Fri, 26 Jun 2026 03:19:40 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49269071c9esm64501155e9.9.2026.06.26.03.19.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9MvxJQhtTKs4rTFMQQCaiswmThg2o/sTBst6a0P6uok=; b=Xmx7yklMS4s+8/nxV1dyqp/BhyLliNv8kuVtcNxVJKSDH9XMzFGfMNeIBeSLNFEczAhnQW ++QjoIfMOK2pp+qEZaIxCI+MDnM+Pem5dNzWsUZf72XIBqhI58L5pzYSPSPtbws3L4p4bn TBt7uhMUFrKagVfkvQraPSlW8+0DMB8= X-MC-Unique: ATu-asW7OUCX6nrMuZZbdg-1 X-Mimecast-MFC-AGG-ID: ATu-asW7OUCX6nrMuZZbdg_1782469180 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469179; x=1783073979; 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; bh=9MvxJQhtTKs4rTFMQQCaiswmThg2o/sTBst6a0P6uok=; b=T2mo8kaakr0A5VWFKZWon8m5JFGgn/L7RaV1bHIr2ijK0c6dViV78CgDXgC9M0JW3P CjZNvsOdk5Fx79gp7E7cXm4WgrEBZvfyRNGgRyuCQhyvej0T/06+f2+v9u5A3ILdIyqI OJllLxbEZJEFSgpPatWdLWgG8bOuO8Qq0oNRzR7yKfpGOChN+tFtwSJFpZWo100ex84K HBLdHtzURCJLcbLuLqoR94iJkdXLI03Jt3TdOiAqRmDbVgQzv7Z0mA6ZBw17GQfmrbBU WEJyfknCVa2FK/Qx4E/3AZ2a1/DkSszxQA77UaKzU3fIGQU6vC1vHtq4hHIk39J0hUDV 8tyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469179; x=1783073979; 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; bh=9MvxJQhtTKs4rTFMQQCaiswmThg2o/sTBst6a0P6uok=; b=O4q5HcNEYUAw4gGu5mnM61LIHmDvQdxG8gOFZo3m3tY7ucMEuQ/2HWS/H3CtjmYzqb ++4W5j5zmYcACNJizGSagOpCKoAc5rTzMbD2Z9Yp/XgzHuN133O4lSDLzVJJ+t+6vQgY G1abjoQdmX9FHIx7KPhDgs6mDx/7N4vRlmzYcUUkdPcy5+4ujTzLZrg3LkaT+j2ZdzUP xnNrIsntJiS1+ApOtDr8lbQj+guRm3AIe+7it+GUbBMvovwfyLFnbx0ZYYqZp6XlSpkM 9ZKH3RNLswbGjsQQnuXzyFiyRpNe00FdjPdUfyasnJU2JqLSrwAsE5ijCuMnxMODyUMs xknA== X-Gm-Message-State: AOJu0YyN4zmsPs3MQ0BjMN1IZgQVv1uNRG90Sxxi1BgzFerYjKXAe3bW ipJmcIdmi3SIrR5Sbm7MFwwO9wto8xLdjUjskaYgVmao90H7pklAwE3mHiSoYj4eThWspPiPrO1 FPq8yOwf84bj2y2Q9dEUFrq9VB563QBan/GvXrcRxDxgtls6/czPuIgtwqb/0H8xKBZp/MDF0oH NbDWdW9PT5j8vWMaNI0yufjumNOImifm4AOTA//4mS X-Gm-Gg: AfdE7cmxDaSHAPdrWEa9X1ckRw8Hw9gwD2tqu5Q+AftQWTBKLU9KX1nSAGJnG1X+Z+P Z0T+vVaxb4UGHY90Zf3tX7Qum6uvmZzO8pcPRu9jiqApie5cBTV+7zeDXdD6ZFmHSB0OuOxQtu3 1eg9ib4tEJqaB8KYeXT+9jbCut3ITxJWZHqUThWRyT/wvHH9OtO8o8ijh4q49a1O14/we8jhmSF WUoXLBIvD+NgI69Scd5GMzJO2S4KMcQF3qN0SPdL7eZpN+GdqtUkYemfq/TdyM5gOuQnsgTfH3D mjfn9CdW3iYGlvw5SRRKbEln7/H3mb5P62mMjAhA2L1GL/1D9wTNxhl1FR0lH6rIXGignDjTMEv a/bJMMn6HjqA7KaTMmhK83PxuTQC7TKHD9JD80nQaXLq2Yh/Y4i4DQRlOqJEHKg95Rg+VyVi0k9 mJFbSlotKKt8vX7VZk X-Received: by 2002:a05:600c:c3c1:20b0:492:4335:4d4c with SMTP id 5b1f17b1804b1-492668833c0mr72293695e9.30.1782469179596; Fri, 26 Jun 2026 03:19:39 -0700 (PDT) X-Received: by 2002:a05:600c:c3c1:20b0:492:4335:4d4c with SMTP id 5b1f17b1804b1-492668833c0mr72293175e9.30.1782469179012; Fri, 26 Jun 2026 03:19:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li Subject: [PULL 41/45] qemu-options: Add description of tdx-guest object Date: Fri, 26 Jun 2026 12:17:44 +0200 Message-ID: <20260626101748.1728079-42-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469388507158501 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li Add description of tdx-guest object so that QEMU doc page can have the description. Signed-off-by: Xiaoyao Li Link: https://lore.kernel.org/r/20260512084458.622465-5-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- qemu-options.hx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index a8ee5d14e14..f1874a05915 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -6372,6 +6372,47 @@ SRST -machine ...,confidential-guest-support=3Dsev0 \\ ..... =20 + ``-object tdx-guest,id=3Did,[attributes=3Dattrs,sept-ve-disable=3Don|o= ff,mrconfigid=3Dsha384_digest,mrowner=3Dsha384_digest,mrownerconfig=3Dsha38= 4_digest,quote-generation-socket=3Dsocketaddr]`` + Create an Intel Trusted Domain eXtensions (TDX) guest object, whic= h is + the type of ``confidential-guest-support`` object. When pass the o= bject + ID to machine's ``confidential-guest-support`` property, it can cr= eate + a TDX guest. + + The ``attributes`` property is a 64-bit integer, which specifies t= he + TD attributes of the TD. + + The ``sept-ve-disable`` property controls the bit 28 of TD attribu= tes + specifically. When it's on, the EPT violation conversion to #VE on + guest access of PENDING pages is disabled. Some guest OS (e.g., Li= nux + TD guest) may require this to be set, otherwise they refuse to boo= t. + The default value is on. + + The ``mrconfigid`` property is base64 encoded SHA384 digest, which + provides the ID for non-owner-defined configuration of the guest T= D, + e.g., run-time or OS configuration. The default value is all zeros. + + The ``mrowner`` property is base64 encoded SHA384 digest, which + provides the ID for guest TD's owner. The default value is all zer= os. + + The ``mrownerconfig`` property is base64 encoded SHA384 digest, wh= ich + provides the ID for owner-defined configuration of the guest TD, e= .g., + the configuration specific to the workload rather than the run-tim= e of + OS. The default value is all zeros. + + The ``quote-generation-socket`` property specifies the socket addr= ess + of the Quote Generation Service (QGS). QGS is a daemon running on = the + host. QEMU forwards the request from TD guest to QGS and + sents the reply (which contains generated QUOTE on success) from Q= GS + to guest TD. + + .. parsed-literal:: + + # |qemu_system_x86| \\ + ...... \\ + -object '{"qom-type":"tdx-guest","id":"tdx","quote-genera= tion-socket":{"type":"unix","path":"/var/run/qgs.socket"}}' \\ + -machine ...,confidential-guest-support=3Dtdx \\ + ...... + ``-object igvm-cfg,file=3Dfile`` Create an IGVM configuration object that defines the initial state of the guest using a file in that conforms to the Independent Guest --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469393; cv=none; d=zohomail.com; s=zohoarc; b=eVtX9l/rnKoIb0yhzH964zc+xf5OXePTGKzvbIYsq75g4X9Z3tV9hCGUuOm9Ah7shD7IloyQkghmwMoYSwanW0o7kYYzhQ/OVXSZL5lVvmqQgZrdwmdaAdUimI2hh7i0O8UAok0Zg173GQDH50MhINGgQLSXw/73183OrBbAIMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469393; 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=h42x0Bdf/i8YC+kFDGxCSDxey27JESfBshEXAUKWWpA=; b=LxBYKjsxO1mCGUGHAyfVHotCcYPYrps0i09855DJQKzom9PctbR1mgTpv+lhjtdF1x9r9HXvQG+I0E3nno9ig2dIUb0iIv1FdbP2JxInMfZDMVFQk+BQdbHKGUzjFTF8bJZT0HcWQNQ9vpB0TfuxvDYtyC9aZQ4cSpsUUjFEPao= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178246939394690.5386126825332; Fri, 26 Jun 2026 03:23:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3f4-0003Yd-MS; Fri, 26 Jun 2026 06:19:50 -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 1wd3f3-0003Rq-7L for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3f1-0005SI-F1 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:48 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-tAV4qKoCOcyA_HrqSu66sA-1; Fri, 26 Jun 2026 06:19:45 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-463aaa77ffeso442030f8f.3 for ; Fri, 26 Jun 2026 03:19:45 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46e3d6ba143sm10723272f8f.33.2026.06.26.03.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469186; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h42x0Bdf/i8YC+kFDGxCSDxey27JESfBshEXAUKWWpA=; b=WMw+Qt81oArV9XbfpoFbu0gz0L0IoO471y31/mFSnUjGvM7h8dX0DfVIjroM1MB2shfZUr 9QZWCDwMHVhqAGTIdX1kY3y1Isad1VbmrgbtgFm5YHHVU728p3trWSjljDPm6uUaibaD2b AVa/ILgYYMS5iW4fX6A+edtVjRcXQdE= X-MC-Unique: tAV4qKoCOcyA_HrqSu66sA-1 X-Mimecast-MFC-AGG-ID: tAV4qKoCOcyA_HrqSu66sA_1782469184 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469184; x=1783073984; 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; bh=h42x0Bdf/i8YC+kFDGxCSDxey27JESfBshEXAUKWWpA=; b=OoDk3tp9DJyjC1sSibtq2J0xQf0JrjwjtMfVquffFrYFp9WFDfS2+800ho3GMbs7mW j6GegXGqK2DrMK+j46E55OhY7B+qQm/WVmq7mEABREo69yf998LXXkf/9AhgUrcEblId P/1U2l5ejSSqjrm0ic8aqrcleJCg7aBavtpOo0pchvORt4HQGBMpQy7leln7hoZqrhHO snM4CtOzJUQ3ixsDOQY9nKpHUbNYSRrKcjlwspdVUgWqbHGicVT5YgLGe3SMJLKRj4x+ kEbwa64GcON/wl3k3M0g1v/c0Tbi4Hi4080ffqEUUhYjQYoChI5NZ1FyR3+jJqwKdu3F iXBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469184; x=1783073984; 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; bh=h42x0Bdf/i8YC+kFDGxCSDxey27JESfBshEXAUKWWpA=; b=OEiQ0er8pnLvAuexB8F8fB0acizVGo6i1qaqEodkJbbgow/D9yafqz6bisCmoI2Dt9 Ph2iT6wU9WuGimScg3Y8zWtT75GCkPdUEk1p8sjuZtzraSqlziIurR8ds+SRjH/uwVlQ Z28EZ01fbWyIg4VCGn/Z2RZj0QakgGo/g48UdWMnya3wtlR31yFQzfCQAttW2ZE2TV8S zfiZ03nIus/fJZXqTN+lEBlhs43fOkAhbHo3s7kSkEWjFxi0i5a4CO72EaOaAKzZP2GO 3NC+ddCZjWdW2vHQwoHlI+h75hDol7ZEqtBtcy7gR197cWIbQhLIcYxtP8Xq7lk/G2rU yPzQ== X-Gm-Message-State: AOJu0YyJejST51Qpov/QbxL4Z9amCUf8cUkG0twAtOIIvW1cw3SMtvw4 Mq9TUFLgVhAkclOyuez4WiABcqkEMUHVACp5dBiChdNS5Jeacb0bYi4yvjTGUb2dkz9r2zWO0m+ u/jZ0lXSRsU65EJXyZBQzJnfE18/H+hzmtqmkMx8FXynf4yAjxZYm++xSvZ5/c+qyN2hmCt0NXi VGfH5zqLCZ5tl2pVld8QUQLIdLF21LOI1lq1n3o3XC X-Gm-Gg: AfdE7cnh61nMNtIuswu/x3x8WBdmAwRKUGaY4LXkq7jNS+5OnBf3zQu+4Kiitbjcy1P ni0h5F+ALtk5kE6P67b28pZQ10b0y98fIVC+P0aql0HhZRWK5+EyedfgVbSvt/D1+ZA2kgJvYNz sbRHiSJILUb+04Fc+FHfQOLuLQV2qY3RN8FJQ1MmLZzsDXBAdJy/394kLMsSV3BEVSyKlrkfXvn nJVpX2VB+x6EjonJg7Ocu70xb91PsRC2Mi6cdaGGu//7UFzvatKlqbSs2qVN7TnMjok6zE5nbWC /J5S1YZbDwgpSVrKQAAjHq0RexxkL6wRLL+SnQCjBCxXPu2JNkY6RL0DgqausyCkowMeybVe4SD CUwVT9gkNpT70O4MvrBS2YfgPH3CwNlAExUnWO6y1eE46M/cPH62pP07uBoSE5WQysZRW6LiM+c C0++UCH6IcZiTrtgr8 X-Received: by 2002:a05:6000:2c0e:b0:43f:e2b7:7160 with SMTP id ffacd0b85a97d-46dbed35f0amr10059228f8f.4.1782469184120; Fri, 26 Jun 2026 03:19:44 -0700 (PDT) X-Received: by 2002:a05:6000:2c0e:b0:43f:e2b7:7160 with SMTP id ffacd0b85a97d-46dbed35f0amr10059181f8f.4.1782469183685; Fri, 26 Jun 2026 03:19:43 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PULL 42/45] machine: Deprecate memory-encryption Date: Fri, 26 Jun 2026 12:17:45 +0200 Message-ID: <20260626101748.1728079-43-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469394512158500 From: Xiaoyao Li We've had 'confidential-guest-support' for long enough that no one should be using 'memory-encryption' anymore. Deprecate 'memory-encryption' by adding notes in docs/about/deprecated.rst and print a warning when 'memory-encryptio' is used. Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Xiaoyao Li Link: https://lore.kernel.org/qemu-devel/aMPYkUsytGxLPIM7@redhat.com/ Link: https://lore.kernel.org/r/20260512084458.622465-6-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- docs/about/deprecated.rst | 7 +++++++ hw/core/machine.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 97750f5edc9..cf3e1a007c7 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -249,6 +249,13 @@ The RISC-V ``shakti_c`` machine hasn't had meaningful = contributions since 2021 and is currently unmaintained. The machine is scheduled to be removed as it appears to have no users. =20 +``memory-encryption`` machine property (since 11.1) +''''''''''''''''''''''''''''''''''''''''''''''''''' + +Use ``confidential-guest-support`` instead. The ``memory-encryption`` obje= ct +was an early implementation of memory encryption support in QEMU, but it h= as +been superseded by the more comprehensive ``confidential-guest-support`` +object. =20 Backend options --------------- diff --git a/hw/core/machine.c b/hw/core/machine.c index 9a10e45aabd..5b97df6db96 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -497,6 +497,8 @@ static void machine_set_memory_encryption(Object *obj, = const char *value, Object *cgs =3D object_resolve_path_component(object_get_objects_root(), value); =20 + warn_report("memory-encryption is deprecated, use confidential-guest-s= upport instead"); + if (!cgs) { error_setg(errp, "No such memory encryption object '%s'", value); return; --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469342; cv=none; d=zohomail.com; s=zohoarc; b=eaPgTwyzfWe1g4gsp6war1h2X7vRmDHMs1k0WIzym+KozNklwQUwN0H/iGn20WnHlSSL5kH+qbFtrSOvReLEQnSx98QlHw6wXdJ4wvo6CKOu61fzCNeccNQp0zrFwRjjn1mxxwDCSVZ+/+2uRQRX/KqsMSDYzawzQoxWflkwSJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469342; 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=VgCjIZjGwX7SpaWajCTdC373pSdn6nF6m99W2fnMJbo=; b=V70umO0wEN3D+vllf+nTIJZv54wKgeN6epuydcinXyEgPyR1ZSeRhi8tA3e8Q3VHIZ6ablWjBnx1mW6v1VgqCEOHA9SFb4kFRvh283GItQXudafZIV1AKidjJxStGzfaq8L4Xqprgqo9N1+wXBpoM2PGXhf+C4xbWZ9TDYC2cL4= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469342825252.16281865207077; Fri, 26 Jun 2026 03:22:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3f5-0003dO-Rp; Fri, 26 Jun 2026 06:19:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3f5-0003ai-07 for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3f3-0005ST-6n for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:50 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-434-smGT3y6pPY-7Q1bHB0Zk_Q-1; Fri, 26 Jun 2026 06:19:47 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-490e547f3cfso11331215e9.3 for ; Fri, 26 Jun 2026 03:19:47 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-492690a1a85sm116074675e9.15.2026.06.26.03.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VgCjIZjGwX7SpaWajCTdC373pSdn6nF6m99W2fnMJbo=; b=FQeko2rUs1X5Q7OiY4j/rX7HA3LZDSiBKof2W64KSb7/fuqnmptzrl4lc9a7jNayJsxLg3 cToyFNO4F68lliqlvn0jIQRo5PWZIovOR8MZihyD/x/LojQfT97Hp+4fHaLMjmePU6tgv4 Rjn/Unyg4dp+in3C/hYkDhUr/GM2MQ8= X-MC-Unique: smGT3y6pPY-7Q1bHB0Zk_Q-1 X-Mimecast-MFC-AGG-ID: smGT3y6pPY-7Q1bHB0Zk_Q_1782469186 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469186; x=1783073986; 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; bh=VgCjIZjGwX7SpaWajCTdC373pSdn6nF6m99W2fnMJbo=; b=fNYdPf49ex9eZZXQ6uFuM7T5FsH5DRsIb47+zwdZoadX/hzSQ7mvoEpjvo2A2t+ViO v5djJng8yAA+HJQRlmcM1EYK7auB+jkWS58slYlRmc69n9+M97ZwicCcUQBXX1mCrp82 LjxJhKmiWjm+i+1MemcIzpVGWik1IXGMyeX2E/aaxnRVb5dY5k1xK3ze9WSJ5WeoHzdp 2XrkfQJmY2kmyioOeBiRPvt9MsUEFZou3EpK85oI2Fw9NR3I9Ql6uAYENY56JqVVJiTs h9AjkuMGv5gtDe4jpWtM92lJnImm0y42FIu0bNXhDFF6ke9BLMTTO7n5vbzbtZBAbtit UTwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469186; x=1783073986; 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; bh=VgCjIZjGwX7SpaWajCTdC373pSdn6nF6m99W2fnMJbo=; b=fVD16DO7p8Y2H/594+cskAhQbtDs4leAPn7XFzZJuv0xNAxt8ijLijP8mGFyMSW9Me N8wU3eT2E9fabOh04tjoyNPujoFit2aIu5+BZJE4YilKXkSyQdO4pPUJNRJiqJs6Lmk/ YLdtxzmwzolJkb9oiu6JvdzOVnmgvVRTUnSpJtyTOyKoRHdljA6L50YJqj3+/QLrDRBN DSh8LjGvDdP+Cli5sP1Z9Et59n3MIMYK9EYgbM4WnwR95/rYD6YEf5HsJCxEV1+6H4zy socze3xktlND8iMFLsYoAvRuAUl3l4eBkytAcZZ1CYhg5n0SLdL3wW/VgYEJvUWOuaat 6A1A== X-Gm-Message-State: AOJu0Yy+odOMyDMRVW8VT8efKQR1Byr66y2V6ph2s+11h1hkQ+pdLKW4 IpZKd3RzHF6h1sBuTx+svsx1FJ9GtCIwANhnn6GoD8A7mEGU2vu7Su2gIsGTEBz6lb+HUE0mzpe f73yqyxzBZ6Xn/NPHCLZt4DcM8FhNgIfg4U/ORQqagQ0za3GU68loJVT7m4OCoukaghdEcm7S5S qErpvO1cPCfMXIJ+ydt65Qa1OTyfksN5VHnDfG17l+ X-Gm-Gg: AfdE7cmBU5fumJJR7fipY3VhT12Ygasl0bWoICxqxEW8lF4i3MNMlf4AM4WYVoi1P9R VaI01h2yUKb63sZjOS+6NC+W45REYxCSBXXy5FEXSfbk60M6TQEqV8uqhHYUwqvyaPLmJrEzJTM TvQQPIg/+Cj2Q/xK0i2j2KJWAF9avI+qHir4N/DVhwEe18sngeZzJsAiYUBYV89CW9ua9Dhk2fe Gnjh7/Dowi/fMY5lurKy0Elr9M7D4YV2AbTvIAUl6Vybim/hbbncns01+Gv872MrWGsI1z+lm5o 7+ggPVlPkXh/geBTkuJzZ7cH7UWKLpmyRMDOQDOiRiK1GM9F8FFxwASdtiOJMtNymEMihc7rlG7 fGMaM0Lpln9BfinpmxccKBKM3D5YWQIVedZ1mIYuYEbX1lgCstbdsKvnscikbeHEP79f6uvGYZ8 DINEOdY34XSWPLINdO X-Received: by 2002:a05:600c:524c:b0:492:4d52:315f with SMTP id 5b1f17b1804b1-492667e864dmr87631605e9.0.1782469185976; Fri, 26 Jun 2026 03:19:45 -0700 (PDT) X-Received: by 2002:a05:600c:524c:b0:492:4d52:315f with SMTP id 5b1f17b1804b1-492667e864dmr87631015e9.0.1782469185453; Fri, 26 Jun 2026 03:19:45 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Zhenzhong Duan Subject: [PULL 43/45] i386/tdx: Use .has_gpa field to check if the gpa is valid Date: Fri, 26 Jun 2026 12:17:46 +0200 Message-ID: <20260626101748.1728079-44-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469344277158500 From: Xiaoyao Li When translating the QAPI type GuestPanicInformationTdx into its C struct, the generated code provides a .has_gpa boolean field to indicate whether the optional gpa field is present. Replace the magic sentinel value -1ULL, previously used to signal "no valid GPA", with the idiomatic .has_gpa field. This removes the implicit sentinel coupling and makes the validity check self-documenting. Signed-off-by: Xiaoyao Li Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Zhenzhong Duan Link: https://lore.kernel.org/r/20260512082108.621596-2-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- system/runstate.c | 2 +- target/i386/kvm/tdx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/runstate.c b/system/runstate.c index 0e1cb3b4e67..09be7c8d202 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -706,7 +706,7 @@ void qemu_system_guest_panicked(GuestPanicInformation *= info) " error code: 0x%" PRIx32 " error message:\"%s\"= \n", info->u.tdx.error_code, message); g_free(message); - if (info->u.tdx.gpa !=3D -1ull) { + if (info->u.tdx.has_gpa) { qemu_log_mask(LOG_GUEST_ERROR, "Additional error informati= on " "can be found at gpa page: 0x%" PRIx64 "\n", info->u.tdx.gpa); diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index df46fce7693..da4478cb21f 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -1403,7 +1403,7 @@ int tdx_handle_report_fatal_error(X86CPU *cpu, struct= kvm_run *run) uint64_t reg_mask =3D run->system_event.data[R_ECX]; char *message =3D NULL; uint64_t *tmp; - uint64_t gpa =3D -1ull; + uint64_t gpa =3D 0; bool has_gpa =3D false; =20 if (error_code & 0xffff) { --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469229; cv=none; d=zohomail.com; s=zohoarc; b=ZjmF9szdkxpINSbbEEYdpiOS3KnBmRDu+He+cGNypk9mrsnrD5hn0ZMTTwhC1C2bCSK5yuaf8g2Fs3fw+eGRYlxEM/ou6PvsGBSgTfYUFkf3K+h8Vw9UPCGIwCnznDivVnSjhwL0mbUZD3BSZ13KwZBiW3n2IpZhBf9AJf8D3sE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469229; 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=WsOdP/w9CsB2e0wkH1FPwJZcH2RwGI7JrZ69X4jQzLQ=; b=FACRiQiaEnrpB53yvdCIevB+EweTWxK94xV3JFo0khSEQGXuFsaI/+O4ico2LpsynzJupi1g/vkrOiaX1a9WfytJPYQgE+Y3c25ystYacjAkFVRfPZUOzwNGxkcflYU+PPgBsGo/d4KMDxTi3utBQhsp/9+AzJo8dzjB2sqOK0M= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469229636976.5585021433658; Fri, 26 Jun 2026 03:20:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3fd-00050p-DO; Fri, 26 Jun 2026 06:20:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3fP-0004fH-Hg for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:20:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3fM-0005UU-8W for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:20:11 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-172-2gXLEn6-MImgMM-og9FDCw-1; Fri, 26 Jun 2026 06:19:51 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-4623bdcad2fso441113f8f.0 for ; Fri, 26 Jun 2026 03:19:51 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49268fc0d36sm112788805e9.2.2026.06.26.03.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WsOdP/w9CsB2e0wkH1FPwJZcH2RwGI7JrZ69X4jQzLQ=; b=JT9IqACTLr8K+RBeZbArW7rXqfgbFaIr+ehzkfngj7fZt4ZDMJJoS+3/3ngln1PFBpwwYS eyj7J0cYAyRxsYxEd4bfyTCjhahqStgCyQgawjFTrUVLYeJqYjYgDSqMJHDKIOWFrnnuYi IHp/318n/U3z7nGyiep3ErH888ihsBs= X-MC-Unique: 2gXLEn6-MImgMM-og9FDCw-1 X-Mimecast-MFC-AGG-ID: 2gXLEn6-MImgMM-og9FDCw_1782469188 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469188; x=1783073988; 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; bh=WsOdP/w9CsB2e0wkH1FPwJZcH2RwGI7JrZ69X4jQzLQ=; b=r/1PQmlSPfLFrwe9XbV8hDyudz/d16NAUJ04O+ff1OIY8r7aLATZKeqhcWTsUj2GOJ rgbvm8nTo3XYw/fTz3lb0J05mL8nGtxXIli3aDMWcYxMQNF5mmOj+5H+mXh9+dXYZ+z5 8O+aoANTck44ZbOYrtnd4JtaLbp+ACDH89el7B5xJTZDjxewlwM8QLdW02uL+LcKStmn OIyZoT0dxEchZuwfV4ha5ZmSEYoYLavjkRpENL1vrrJpr36oBX+dioiWDtYok79/KFye fZcfTm0P47JlE3VqLLr/45RzPmpNxItcBi6cqUbdrDsf7yPGyLK5E2TIsly1G5HHzu4A rw2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469188; x=1783073988; 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; bh=WsOdP/w9CsB2e0wkH1FPwJZcH2RwGI7JrZ69X4jQzLQ=; b=Q1dodZ7kNdK0Ej7q9L6vJhwtNlXQR1IMGPJJCUChZahMSDGPANCH9QVWzgcYUSAB7A 9Wjdt2cDu8wYWHLY2UEwBySGmzgaOET83Sg0KztM3efDG1Z545xb0rFgXwowX4hngY8Y oGhGCZSDDrTotfFAZKAwFNqpQMJ/cqqBtvPNBuFMu7giSNOTv7pSPbiQ3q+6V+VwtkyI IF/4C7L0XAhrEUZdTrWqb9VwkxtR8XTOewKaU1Iyd+iO0d7giBCmaEWGCaEcJ5UlCFvC eT6w8+WlanhzXwTQUvnNKzzAiFIVt2SVK9uYa93gbd+sRvML4QBa1uRSxhM4WneqGS3M ScPg== X-Gm-Message-State: AOJu0YyYhqgichLx3yUVituAx6XcScJzry8tFya6ILZzzMIvbbwC4883 /1phKhK9h5FtrxwE7/rArz08dIFcE0tWFhOwL0IFV4fnG47D61Yyp/Vvtol2OfrudwkSSnyB2KH aVaS543QRHhMfViXXd3AVNK+7KCFqVBHGh0h1TA44uSFlmSFpH5Sud+T3aZ6ZpY+iBQ9OuahMYy 47IcEmG/C+mPnV7ChnTJyONQDEq0yoksfGhnNKn4sn X-Gm-Gg: AfdE7cknDaaJGxuYhKRPqKZsFyxxGceZj7twvGnskLtu+BjKHWpoeLfObSzFEP910Qz UAQ5uiTlBX4/07iGmKnsymfBmYGXMoJTmaHlDm9zTzYj9r7gyK3ZHivmJphdHpGtjr+0T3it2d5 1l1K3T1KOAnfSI7y1YMsXtjOwHzfAD41CZGJiy6fqjA6G+garYXt9q8OL2qgIeoORFAeYpNmWXp G8yfxf2GJYjLMg0qkl8/wDUIS9rygbTC7Xz0Z9/hWVW3rcG0biRm95OS1d+AIXH80eX0eLNAw8i lIZK+lsFQfZAIaw6ErfEx1SFBPi1vqlsTjZRtoyjWA4Cr0CHbOo4DiS8O077ZMHZCHZvJ+vM7pJ tRvX1geBxys0ni3vCiMMMimSzLo9c65FfkASBatwD+yurSQclHCS4eM9Z2r1YaxMPgLu6fj+Kej K5QW98VQcy7bR5hvf3 X-Received: by 2002:a05:600c:8889:10b0:490:b58a:e6ff with SMTP id 5b1f17b1804b1-4926688590dmr70373515e9.22.1782469188172; Fri, 26 Jun 2026 03:19:48 -0700 (PDT) X-Received: by 2002:a05:600c:8889:10b0:490:b58a:e6ff with SMTP id 5b1f17b1804b1-4926688590dmr70373075e9.22.1782469187683; Fri, 26 Jun 2026 03:19:47 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , Chenyi Qiang Subject: [PULL 44/45] i386/tdx: Make AMX alias bits supported Date: Fri, 26 Jun 2026 12:17:47 +0200 Message-ID: <20260626101748.1728079-45-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469231608158500 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li When booting a TD guest on a platform that supports AMX alias bits, QEMU emits the warning such as: qemu-system-x86_64: warning: TDX forcibly sets the feature: CPUID[eax=3D1= Eh,ecx=3D01h].EAX.amx-int8-alias [bit 0] ... Bit[3:0] of CPUID(0x1e,1).EAX alias the AMX CPUID bits from leaf 7. Their TDX virtualization type is "CPUID_Enabled & Native": the value is determined by the leaf-7 AMX bit they are aliased to and the native hardware value. These bits must be added to the TDX supported bits list so that they can be enabled without triggering the forced-set warning. For simplicity, mark them as supported whenever the corresponding AMX XFAM bit is supported, rather than checking each aliased leaf-7 bit individually. This reduces code complexity. Any platform that supports the AMX XFAM bit but not these alias bits will still be handled correctly, since the TDX module provides the real value via tdx_check_features(). Signed-off-by: Xiaoyao Li Tested-by: Chenyi Qiang Link: https://lore.kernel.org/r/20260512082108.621596-3-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- target/i386/kvm/tdx.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index da4478cb21f..e3c5eb99842 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -560,13 +560,19 @@ typedef struct TdxXFAMDep { } TdxXFAMDep; =20 /* - * Note, only the CPUID bits whose virtualization type are "XFAM & Native"= are - * defiend here. + * Note, usually the CPUID bits whose virtualization type are "XFAM & Nati= ve" + * are defined here while "XFAM & Configured & Native" are not. Because the + * latter are reported as configurable bits by KVM when they are supported. + * And they are not supported when not in the configurable bits list from = KVM + * even if the corresponding XFAM bit is supported. * - * For those whose virtualization type are "XFAM & Configured & Native", t= hey - * are reported as configurable bits. And they are not supported if not in= the - * configureable bits list from KVM even if the corresponding XFAM bit is - * supported. + * Special cases: + * + * - AMX alias bits, their type is "CPUID_Enabled & Native" which means th= eir + * value is determined by the CPUID bit they are aliased to. + * + * For simplicity, relax the dependency to related XFAM bit. + * tdx_check_features() will eventually catch the unsupported configuratio= ns. */ TdxXFAMDep tdx_xfam_deps[] =3D { { XSTATE_YMM_BIT, { FEAT_1_ECX, CPUID_EXT_FMA } }, @@ -580,6 +586,10 @@ TdxXFAMDep tdx_xfam_deps[] =3D { { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_BF16 } }, { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_TILE } }, { XSTATE_XTILE_CFG_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AMX_INT8 } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_INT8_ALIAS= } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_BF16_ALIAS= } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_COMPLEX_AL= IAS } }, + { XSTATE_XTILE_CFG_BIT, { FEAT_1E_1_EAX, CPUID_1E_1_EAX_AMX_FP16_ALIAS= } }, }; =20 static struct kvm_cpuid_entry2 *find_in_supported_entry(uint32_t function, --=20 2.54.0 From nobody Sun Jul 26 11:51:49 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1782469359; cv=none; d=zohomail.com; s=zohoarc; b=csIIvMhtuUIjoQu6at7FG7xG8lrfzBGIbj5CpA9VuQOWGncy6WhW2dmmxwGK4L8TeHt7JYOsWlH5lXCsaJOdNUmwtWrq/x/Y29KBW8l+gxTHiZ+KIenh8+dUC0eRuAsoOKWdTT3dwlL3aNGzRdk3ZWGXwX6TLqrielCmhH/T0Uk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782469359; 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=jSRwuOc010Ufku1OU9TvA9RlMNaejs2seQxcYG23jkU=; b=WcOBL4saxOlFPPXPA0iwJ4IjMGpw2DRSIJlNomINItnzdbsthAlLFo2WbzXiCP4dxLu1H77f4wpw00MAOAHZNTVMXF09WuBFNLn38iCzIJdEDDleUFdAeHMeqASvEgs4Rrj/xT4gbZhZ3jGiLww2I9L0C3E10JSfMi4scrI4pyo= 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=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1782469359606400.83759841595486; Fri, 26 Jun 2026 03:22:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wd3fA-0004C0-Oj; Fri, 26 Jun 2026 06:19:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3f9-00040z-En for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wd3f7-0005Sr-IP for qemu-devel@nongnu.org; Fri, 26 Jun 2026 06:19:55 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-nxIJZnLKMYyUbF6eUxCsoQ-1; Fri, 26 Jun 2026 06:19:51 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-463aaa77ffeso442076f8f.3 for ; Fri, 26 Jun 2026 03:19:51 -0700 (PDT) Received: from [192.168.10.48] ([151.95.124.208]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46c221d998esm22922825f8f.24.2026.06.26.03.19.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 03:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782469193; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jSRwuOc010Ufku1OU9TvA9RlMNaejs2seQxcYG23jkU=; b=IJAEQz5nsdZrQgXqSLbjofBy0vSqgEQ0M/GttN84xtyLV3okAkEkaTRzgioIAyI9LzCdgo P+5Aaj0Rk+UfWT5fTvoTB85aNlMawvx4tmISEJfCLBY1F4V3wJNLCfUyo2lbMfCVMDjNWz 4Xb8vrfoazjxVD5ASdG7hygdr4F+Rso= X-MC-Unique: nxIJZnLKMYyUbF6eUxCsoQ-1 X-Mimecast-MFC-AGG-ID: nxIJZnLKMYyUbF6eUxCsoQ_1782469190 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782469190; x=1783073990; 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; bh=jSRwuOc010Ufku1OU9TvA9RlMNaejs2seQxcYG23jkU=; b=bMdLc809ZbIu0qfurfx60TjExs1GAHVPCHaxOXoF7GWw2VzFPSlcp/QaHBvq2xeoDD 0GZZbDPq1iTGII/BtbuTPrNcdX3fA5ntf5edMzK/MmHey5d9U1GZ0tZsqZfEdBTIxo7I 2cvQr/BDBH/iaBRaIa6Y0T4HRd9q2qPfhHakqZn8htAwgkw9pYp+2dGrZiQK9swstj+g Go3KxwwU5kh8Snasp1pwXSxVNb4Al0Ob+lgKl1HSnU2cbxQo7P4RX1lP1yKAOpQOpONc ywU+Lnsm9nq6LWFq6IpFusdoIc6ZjOSJpRQInB7dEwY/+SX57Zt0+mRNpgiQ0JtGwckm wE8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782469190; x=1783073990; 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; bh=jSRwuOc010Ufku1OU9TvA9RlMNaejs2seQxcYG23jkU=; b=d2BRuY8I7iZ2th/A+CQy3v6JhHxEkQe5/RdQeCwS63d7bBvILYiite9nWQKjKnSIBT dxmftiUVU+mn+9vFYmBa7T4fNKQl+6XjpRa+xuWEuDumofRa4dEuFRzU1appfr9Ht1Wc oep4y/l4gtmFSWAMeA8Di1gfUbJ2RqetiV8HhlBdy8R3mmtIw+nQCw00gjwyTbXa24yl W8IvFrigc4TFAHdtALV2oL5Z1y31UTbZvUN1MdrI8N7DFB1Tvuj0xPjxEMj+w6DrG1iR 3Fq1GVdAyWXTRKNhe/DPXZ3G9xMqMgIdKfLhqlIBre+I8xgfBO9/qgnSMUjY5SaRvXiY WO4Q== X-Gm-Message-State: AOJu0Yw02Ty9X2oNfhosEhJws0xXF8LF77MXTMw5NUfNK6aGPWHnL2sw EjkusQbCZ+spRDAr+UlTsSVbBFvOomEkUZeAdbQ5bmO25IgNl5v2GvNTjCmGeedK+qClaLAwkYJ p6Q+AqCRK2QknKaqo22Bvt6JGbOW7Asa1VPndfo9zSj/UwuL3vXs5fSTgPg3Zj0REjhgYmOV113 FT9GHwOCVR1ydMlYiBrQRCbW6ERTZTve6KxheQiWe6 X-Gm-Gg: AfdE7clgYFTet2HWO3AW3wscbU+ceJ5pkpRJVMAP5Rld/nQlezgfOAs4kLuVs4tUNYG KGN1N+II0i3bXA+aEab3FZYqKRAXkRLpEa/tiMJP++sJkQvl9pvzfRly685xEhd/p5TthQ6sPBo qD8eO/U/uKIK1vyHeTurDuwfysCXPv7ircmjixVWwtvIU78hgBaAwrIO4VWKEJGg4pdvHCK392K uiB4lmF2GTb6gfS03VcgvaL4B6czAWO3uOgqwabIuQTO1mtp7ZuEA1vC74ozX7dKX5uzQRQRLvJ wtquSBwAKc/aKAIvIXqwJUa4I4kEcuWHPDJUFycX88q2DWahU9W5Wge3BYcPVf9Rw5/BGLJa9hF +XW0FR5SuucQQlI+lVPo2W4TUZsKggsICQUubfQt1dKPwGUeFlmmfd/6CQKK9EtotNjy+mJMwwd rsknjrhKQY82nHK5S4 X-Received: by 2002:a5d:5f8e:0:b0:45e:64b3:af44 with SMTP id ffacd0b85a97d-46dc18a4a8fmr9740120f8f.36.1782469190349; Fri, 26 Jun 2026 03:19:50 -0700 (PDT) X-Received: by 2002:a5d:5f8e:0:b0:45e:64b3:af44 with SMTP id ffacd0b85a97d-46dc18a4a8fmr9740071f8f.36.1782469189905; Fri, 26 Jun 2026 03:19:49 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: Xiaoyao Li , Chenyi Qiang Subject: [PULL 45/45] i386/tdx: Add CPUID_24_0_EBX_AVX10_VL_MASK as supported Date: Fri, 26 Jun 2026 12:17:48 +0200 Message-ID: <20260626101748.1728079-46-pbonzini@redhat.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260626101748.1728079-1-pbonzini@redhat.com> References: <20260626101748.1728079-1-pbonzini@redhat.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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1782469360342158500 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li AVX10 depends on CPUID_24_0_EBX_AVX10_VL_MASK as defined in feature_dependencies[]. Currently CPUID_24_0_EBX_AVX10_VL_MASK is always not supported for TDX, so AVX10 cannot be exposed to TD guest. The TDX virtualization type of these bits is "XFAM & CPUID_Enabled & Native": their value is determined by XFAM[5:7], the AVX10 CPUID bit, and the native hardware value. For simplicity, add CPUID_24_0_EBX_AVX10_VL_MASK to tdx_xfam_deps[] under the AVX512/XFAM dependency, without separately checking the AVX10 bit. It's safe because any invalid combination supplied by the user will be caught by tdx_check_features(). Signed-off-by: Xiaoyao Li Tested-by: Chenyi Qiang Link: https://lore.kernel.org/r/20260512082108.621596-4-xiaoyao.li@intel.com Signed-off-by: Paolo Bonzini --- target/i386/kvm/tdx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/i386/kvm/tdx.c b/target/i386/kvm/tdx.c index e3c5eb99842..f882578c707 100644 --- a/target/i386/kvm/tdx.c +++ b/target/i386/kvm/tdx.c @@ -571,6 +571,9 @@ typedef struct TdxXFAMDep { * - AMX alias bits, their type is "CPUID_Enabled & Native" which means th= eir * value is determined by the CPUID bit they are aliased to. * + * - AVX10_VL_MASK, their type is "XFAM & CPUID_Enabled & Native" which me= ans + * their value is determined by both the corresponding XFAM bit and CPUID = bit. + * * For simplicity, relax the dependency to related XFAM bit. * tdx_check_features() will eventually catch the unsupported configuratio= ns. */ @@ -579,6 +582,7 @@ TdxXFAMDep tdx_xfam_deps[] =3D { { XSTATE_YMM_BIT, { FEAT_7_0_EBX, CPUID_7_0_EBX_AVX2 } }, { XSTATE_OPMASK_BIT, { FEAT_7_0_ECX, CPUID_7_0_ECX_AVX512_VBMI } }, { XSTATE_OPMASK_BIT, { FEAT_7_0_EDX, CPUID_7_0_EDX_AVX512_FP16 } }, + { XSTATE_OPMASK_BIT, { FEAT_24_0_EBX, CPUID_24_0_EBX_AVX10_VL_MASK = } }, { XSTATE_PT_BIT, { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT } }, { XSTATE_PKRU_BIT, { FEAT_7_0_ECX, CPUID_7_0_ECX_PKU } }, { XSTATE_CET_U_BIT, { FEAT_7_0_ECX, CPUID_7_0_ECX_CET_SHSTK } }, --=20 2.54.0