From nobody Sun Apr 12 05:55:52 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1770826127; cv=none; d=zohomail.com; s=zohoarc; b=l0RXwDzCqnfIloP+6/eqk1rYvVsM9XzdKmVAYBQ6k5HV1TC/bL6UrieTVHwPU9bAZKetzY0kCES/a/HJJlXes6gsBEimUCoTUWFM7zBC3O3r9elLs+DIwGapv1m6aE9OqXXIKCVRSI7R6JluD1nTPhFkqZG5vw2UFgqjUrXIss4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770826127; 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=j0zx57orCfjH/b4yZSBp1d3VPOTnjKE85cp35cyPnmg=; b=hFBEcc4zDOBFLNywH/IdKk0T9j0ZUPG7HCY+H8zCzX0Ok8XKCXejwGMwprcB9o6YNxVoExQU+GJgHiiaJJnyUfZxEDsN9kxG4vcRceZ9QDXFPlGD+JCQGYQ2EvIp6EbnXWjqFMyQzDn7MKllXO7rLB+71o8tQGwSZPWYkUd4ytE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770826127818813.1826128729806; Wed, 11 Feb 2026 08:08:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vqCke-0002pe-L5; Wed, 11 Feb 2026 11:07:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vqCXn-0007De-RH for qemu-devel@nongnu.org; Wed, 11 Feb 2026 10:54:23 -0500 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vqCXl-0003Q4-KI for qemu-devel@nongnu.org; Wed, 11 Feb 2026 10:54:23 -0500 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.59]) by linux.microsoft.com (Postfix) with ESMTPSA id 463AA20B7169; Wed, 11 Feb 2026 07:54:18 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 463AA20B7169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1770825259; bh=j0zx57orCfjH/b4yZSBp1d3VPOTnjKE85cp35cyPnmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kr/QmNAqqmzKf44BjHqTEMvNMp72u28Lf58pQLMiZtGhsrqEb+hNg2TP4QJ2fzraG yz7kPEj/v/bMjCo7CqZ8EJpMDSWuwlo7sk+j0vmiQuwUAlNbkWZLc2wQKx3nhhxVmf WAr1UjSfUhxsHwluxVjz3yrfkS3NzD6hiOY75gMs= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: Magnus Kulke , Wei Liu , Wei Liu , Zhao Liu , Paolo Bonzini , Magnus Kulke Subject: [PATCH 02/10] include/hw/hyperv: add QEMU_PACKED to uapi structs Date: Wed, 11 Feb 2026 16:54:02 +0100 Message-Id: <20260211155410.203883-3-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260211155410.203883-1-magnuskulke@linux.microsoft.com> References: <20260211155410.203883-1-magnuskulke@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 11 Feb 2026 11:07:29 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linux.microsoft.com) X-ZM-MESSAGEID: 1770826129656154100 Content-Type: text/plain; charset="utf-8" The uapi definitions are marked with __packed hints in the kernel headers, since we want to keep the contract of the Microsoft Hypervisor ABI explicit, we should also added them in our vendored files, with a few notable exceptions where the attribute is a noop. Signed-off-by: Magnus Kulke --- include/hw/hyperv/hvgdk_mini.h | 37 ++++++++++++++++++++++------------ include/hw/hyperv/hvhdk.h | 14 +++++++------ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/include/hw/hyperv/hvgdk_mini.h b/include/hw/hyperv/hvgdk_mini.h index cb52cc9de2..7d7b2e9b36 100644 --- a/include/hw/hyperv/hvgdk_mini.h +++ b/include/hw/hyperv/hvgdk_mini.h @@ -7,6 +7,8 @@ #ifndef HW_HYPERV_HVGDK_MINI_H #define HW_HYPERV_HVGDK_MINI_H =20 +#include "qemu/compiler.h" + #define MSHV_IOCTL 0xB8 =20 typedef enum hv_register_name { @@ -211,7 +213,7 @@ enum hv_intercept_type { struct hv_u128 { uint64_t low_part; uint64_t high_part; -}; +} QEMU_PACKED; =20 union hv_x64_xmm_control_status_register { struct hv_u128 as_uint128; @@ -326,13 +328,13 @@ typedef struct hv_x64_segment_register { }; uint16_t attributes; }; -} hv_x64_segment_register; +} QEMU_PACKED hv_x64_segment_register; =20 typedef struct hv_x64_table_register { uint16_t pad[3]; uint16_t limit; uint64_t base; -} hv_x64_table_register; +} QEMU_PACKED hv_x64_table_register; =20 union hv_x64_fp_control_status_register { struct hv_u128 as_uint128; @@ -416,6 +418,10 @@ typedef union hv_register_value { union hv_x64_register_sev_control sev_control; } hv_register_value; =20 +/* + * This struct is __packed in the kernel. Since all members are naturally + * aligned, we can omit QEMU_PACKED to avoid address-of-packed-member warn= ings. + */ typedef struct hv_register_assoc { uint32_t name; /* enum hv_register_name */ uint32_t reserved1; @@ -439,7 +445,7 @@ typedef struct hv_input_get_vp_registers { uint8_t rsvd_z8; uint16_t rsvd_z16; uint32_t names[]; -} hv_input_get_vp_registers; +} QEMU_PACKED hv_input_get_vp_registers; =20 typedef struct hv_input_set_vp_registers { uint64_t partition_id; @@ -448,7 +454,7 @@ typedef struct hv_input_set_vp_registers { uint8_t rsvd_z8; uint16_t rsvd_z16; struct hv_register_assoc elements[]; -} hv_input_set_vp_registers; +} QEMU_PACKED hv_input_set_vp_registers; =20 union hv_interrupt_control { uint64_t as_uint64; @@ -468,7 +474,7 @@ struct hv_input_assert_virtual_interrupt { uint8_t target_vtl; uint8_t rsvd_z0; uint16_t rsvd_z1; -}; +} QEMU_PACKED; =20 /* /dev/mshv */ #define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_= partition) @@ -487,6 +493,11 @@ struct hv_input_assert_virtual_interrupt { ******************************** */ =20 +/* + * This struct is __packed in the kernel, but since all members are natura= lly + * aligned, so we can omit QEMU_PACKED to avoid address-of-packed-member + * warnings. + */ struct hv_local_interrupt_controller_state { /* HV_X64_INTERRUPT_CONTROLLER_STATE */ uint32_t apic_id; @@ -644,7 +655,7 @@ struct hv_x64_intercept_message_header { struct hv_x64_segment_register cs_segment; uint64_t rip; uint64_t rflags; -}; +} QEMU_PACKED; =20 union hv_x64_io_port_access_info { uint8_t as_uint8; @@ -669,7 +680,7 @@ typedef struct hv_x64_io_port_intercept_message { uint64_t rcx; uint64_t rsi; uint64_t rdi; -} hv_x64_io_port_intercept_message; +} QEMU_PACKED hv_x64_io_port_intercept_message; =20 union hv_x64_memory_access_info { uint8_t as_uint8; @@ -692,7 +703,7 @@ struct hv_x64_memory_intercept_message { uint64_t guest_virtual_address; uint64_t guest_physical_address; uint8_t instruction_bytes[16]; -}; +} QEMU_PACKED; =20 union hv_message_flags { uint8_t asu8; @@ -711,14 +722,14 @@ struct hv_message_header { uint64_t sender; union hv_port_id port; }; -}; +} QEMU_PACKED; =20 struct hv_message { struct hv_message_header header; union { uint64_t payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT]; } u; -}; +} QEMU_PACKED; =20 /* From github.com/rust-vmm/mshv-bindings/src/x86_64/regs.rs */ =20 @@ -731,13 +742,13 @@ struct hv_cpuid_entry { uint32_t ecx; uint32_t edx; uint32_t padding[3]; -}; +} QEMU_PACKED; =20 struct hv_cpuid { uint32_t nent; uint32_t padding; struct hv_cpuid_entry entries[0]; -}; +} QEMU_PACKED; =20 #define IA32_MSR_TSC 0x00000010 #define IA32_MSR_EFER 0xC0000080 diff --git a/include/hw/hyperv/hvhdk.h b/include/hw/hyperv/hvhdk.h index 866c8211bf..bf2f8cbc27 100644 --- a/include/hw/hyperv/hvhdk.h +++ b/include/hw/hyperv/hvhdk.h @@ -9,6 +9,8 @@ #ifndef HW_HYPERV_HVHDK_H #define HW_HYPERV_HVHDK_H =20 +#include "qemu/compiler.h" + #define HV_PARTITION_SYNTHETIC_PROCESSOR_FEATURES_BANKS 1 =20 struct hv_input_set_partition_property { @@ -16,7 +18,7 @@ struct hv_input_set_partition_property { uint32_t property_code; /* enum hv_partition_property_code */ uint32_t padding; uint64_t property_value; -}; +} QEMU_PACKED; =20 union hv_partition_synthetic_processor_features { uint64_t as_uint64[HV_PARTITION_SYNTHETIC_PROCESSOR_FEATURES_BANKS]; @@ -201,12 +203,12 @@ typedef struct hv_input_translate_virtual_address { uint32_t padding; uint64_t control_flags; uint64_t gva_page; -} hv_input_translate_virtual_address; +} QEMU_PACKED hv_input_translate_virtual_address; =20 typedef struct hv_output_translate_virtual_address { union hv_translate_gva_result translation_result; uint64_t gpa_page; -} hv_output_translate_virtual_address; +} QEMU_PACKED hv_output_translate_virtual_address; =20 typedef struct hv_register_x64_cpuid_result_parameters { struct { @@ -226,13 +228,13 @@ typedef struct hv_register_x64_cpuid_result_parameter= s { uint32_t edx; uint32_t edx_mask; } result; -} hv_register_x64_cpuid_result_parameters; +} QEMU_PACKED hv_register_x64_cpuid_result_parameters; =20 typedef struct hv_register_x64_msr_result_parameters { uint32_t msr_index; uint32_t access_type; uint32_t action; /* enum hv_unimplemented_msr_action */ -} hv_register_x64_msr_result_parameters; +} QEMU_PACKED hv_register_x64_msr_result_parameters; =20 union hv_register_intercept_result_parameters { struct hv_register_x64_cpuid_result_parameters cpuid; @@ -244,6 +246,6 @@ typedef struct hv_input_register_intercept_result { uint32_t vp_index; uint32_t intercept_type; /* enum hv_intercept_type */ union hv_register_intercept_result_parameters parameters; -} hv_input_register_intercept_result; +} QEMU_PACKED hv_input_register_intercept_result; =20 #endif /* HW_HYPERV_HVHDK_H */ --=20 2.34.1