mirror of https://github.com/xemu-project/xemu.git
Hyper-V Dynamic Memory and VMBus misc small patches
This pull request contains two small patches to hv-balloon: the first one replacing alloca() usage with g_malloc0() + g_autofree and the second one adding additional declaration of a protocol message struct with an optional field explicitly defined to avoid a Coverity warning. Also included is a VMBus patch to print a warning when it is enabled without the recommended set of Hyper-V features (enlightenments) since some Windows versions crash at boot in this case. -----BEGIN PGP SIGNATURE----- iQGzBAABCAAdFiEE4ndqq6COJv9aG0oJUrHW6VHQzgcFAmXrQeMACgkQUrHW6VHQ zgcvWwv9GUCDnidnDka8WGF2wgBEaPPdC2JXcqRFFLADISBAn/3fhsOERO6FwYuN pouhVEJnHpp9ueNAx+et51ySRzGCaL+VdOGGeReQllIOZGsnOnB8JfM58UE4lX4Z prCr72bxFsunxRqlqxssejrc8fBhgEQRPo5lQabl73rxftpXkNTHY0CGTwlvnaY1 CzEBTBuowzkZJbQYDL8Qim2HrYqrSnOaend6bbrj9P6P+UFw9wLJU5tkfYCiHUjg Ux2Fjjx+5+qD9yE7khtxSHqjwWYkR7xA9di1yv4Znqg18gzdbuqnlrKR7F0v98yh sWFy+fyfVRDg+G2yh2F+vAUjmAJUrfw5+GL3uZTWIevoQUoSHBQfgUEJrlIKvykZ WP1XuAZRH3m2akDOXOWZVcDhkb3zPKtPJYZ2WncBZk+DLCs/vg94Taq0FcZefBTn 6qsFjs2lHz96uOSzgqICfU34ghcxfU5xgzmvKxKAiriOItmRMHgIYOXLHRfaIJhV MT/9OMuW =kVny -----END PGP SIGNATURE----- Merge tag 'pull-hv-balloon-20240308' of https://github.com/maciejsszmigiero/qemu into staging Hyper-V Dynamic Memory and VMBus misc small patches This pull request contains two small patches to hv-balloon: the first one replacing alloca() usage with g_malloc0() + g_autofree and the second one adding additional declaration of a protocol message struct with an optional field explicitly defined to avoid a Coverity warning. Also included is a VMBus patch to print a warning when it is enabled without the recommended set of Hyper-V features (enlightenments) since some Windows versions crash at boot in this case. # -----BEGIN PGP SIGNATURE----- # # iQGzBAABCAAdFiEE4ndqq6COJv9aG0oJUrHW6VHQzgcFAmXrQeMACgkQUrHW6VHQ # zgcvWwv9GUCDnidnDka8WGF2wgBEaPPdC2JXcqRFFLADISBAn/3fhsOERO6FwYuN # pouhVEJnHpp9ueNAx+et51ySRzGCaL+VdOGGeReQllIOZGsnOnB8JfM58UE4lX4Z # prCr72bxFsunxRqlqxssejrc8fBhgEQRPo5lQabl73rxftpXkNTHY0CGTwlvnaY1 # CzEBTBuowzkZJbQYDL8Qim2HrYqrSnOaend6bbrj9P6P+UFw9wLJU5tkfYCiHUjg # Ux2Fjjx+5+qD9yE7khtxSHqjwWYkR7xA9di1yv4Znqg18gzdbuqnlrKR7F0v98yh # sWFy+fyfVRDg+G2yh2F+vAUjmAJUrfw5+GL3uZTWIevoQUoSHBQfgUEJrlIKvykZ # WP1XuAZRH3m2akDOXOWZVcDhkb3zPKtPJYZ2WncBZk+DLCs/vg94Taq0FcZefBTn # 6qsFjs2lHz96uOSzgqICfU34ghcxfU5xgzmvKxKAiriOItmRMHgIYOXLHRfaIJhV # MT/9OMuW # =kVny # -----END PGP SIGNATURE----- # gpg: Signature made Fri 08 Mar 2024 16:50:43 GMT # gpg: using RSA key E2776AABA08E26FF5A1B4A0952B1D6E951D0CE07 # gpg: Good signature from "Maciej S. Szmigiero <mail@maciej.szmigiero.name>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 727A 0D4D DB9E D9F6 039B ECEF 847F 5E37 90CE 0977 # Subkey fingerprint: E277 6AAB A08E 26FF 5A1B 4A09 52B1 D6E9 51D0 CE07 * tag 'pull-hv-balloon-20240308' of https://github.com/maciejsszmigiero/qemu: vmbus: Print a warning when enabled without the recommended set of features hv-balloon: define dm_hot_add_with_region to avoid Coverity warning hv-balloon: avoid alloca() usage Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
256f016658
|
@ -366,7 +366,7 @@ static void hv_balloon_unballoon_posting(HvBalloon *balloon, StateDesc *stdesc)
|
|||
PageRangeTree dtree;
|
||||
uint64_t *dctr;
|
||||
bool our_range;
|
||||
struct dm_unballoon_request *ur;
|
||||
g_autofree struct dm_unballoon_request *ur = NULL;
|
||||
size_t ur_size = sizeof(*ur) + sizeof(ur->range_array[0]);
|
||||
PageRange range;
|
||||
bool bret;
|
||||
|
@ -388,8 +388,7 @@ static void hv_balloon_unballoon_posting(HvBalloon *balloon, StateDesc *stdesc)
|
|||
assert(dtree.t);
|
||||
assert(dctr);
|
||||
|
||||
ur = alloca(ur_size);
|
||||
memset(ur, 0, ur_size);
|
||||
ur = g_malloc0(ur_size);
|
||||
ur->hdr.type = DM_UNBALLOON_REQUEST;
|
||||
ur->hdr.size = ur_size;
|
||||
ur->hdr.trans_id = balloon->trans_id;
|
||||
|
@ -514,8 +513,8 @@ ret_idle:
|
|||
static void hv_balloon_hot_add_rb_wait(HvBalloon *balloon, StateDesc *stdesc)
|
||||
{
|
||||
VMBusChannel *chan = hv_balloon_get_channel(balloon);
|
||||
struct dm_hot_add *ha;
|
||||
size_t ha_size = sizeof(*ha) + sizeof(ha->range);
|
||||
struct dm_hot_add_with_region *ha;
|
||||
size_t ha_size = sizeof(*ha);
|
||||
|
||||
assert(balloon->state == S_HOT_ADD_RB_WAIT);
|
||||
|
||||
|
@ -531,8 +530,8 @@ static void hv_balloon_hot_add_posting(HvBalloon *balloon, StateDesc *stdesc)
|
|||
PageRange *hot_add_range = &balloon->hot_add_range;
|
||||
uint64_t *current_count = &balloon->ha_current_count;
|
||||
VMBusChannel *chan = hv_balloon_get_channel(balloon);
|
||||
struct dm_hot_add *ha;
|
||||
size_t ha_size = sizeof(*ha) + sizeof(ha->range);
|
||||
g_autofree struct dm_hot_add_with_region *ha = NULL;
|
||||
size_t ha_size = sizeof(*ha);
|
||||
union dm_mem_page_range *ha_region;
|
||||
uint64_t align, chunk_max_size;
|
||||
ssize_t ret;
|
||||
|
@ -560,9 +559,8 @@ static void hv_balloon_hot_add_posting(HvBalloon *balloon, StateDesc *stdesc)
|
|||
*/
|
||||
*current_count = MIN(hot_add_range->count, chunk_max_size);
|
||||
|
||||
ha = alloca(ha_size);
|
||||
ha_region = &(&ha->range)[1];
|
||||
memset(ha, 0, ha_size);
|
||||
ha = g_malloc0(ha_size);
|
||||
ha_region = &ha->region;
|
||||
ha->hdr.type = DM_MEM_HOT_ADD_REQUEST;
|
||||
ha->hdr.size = ha_size;
|
||||
ha->hdr.trans_id = balloon->trans_id;
|
||||
|
|
|
@ -951,3 +951,15 @@ uint64_t hyperv_syndbg_query_options(void)
|
|||
|
||||
return msg.u.query_options.options;
|
||||
}
|
||||
|
||||
static bool vmbus_recommended_features_enabled;
|
||||
|
||||
bool hyperv_are_vmbus_recommended_features_enabled(void)
|
||||
{
|
||||
return vmbus_recommended_features_enabled;
|
||||
}
|
||||
|
||||
void hyperv_set_vmbus_recommended_features_enabled(void)
|
||||
{
|
||||
vmbus_recommended_features_enabled = true;
|
||||
}
|
||||
|
|
|
@ -2631,6 +2631,12 @@ static void vmbus_bridge_realize(DeviceState *dev, Error **errp)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!hyperv_are_vmbus_recommended_features_enabled()) {
|
||||
warn_report("VMBus enabled without the recommended set of Hyper-V features: "
|
||||
"hv-stimer, hv-vapic and hv-runtime. "
|
||||
"Some Windows versions might not boot or enable the VMBus device");
|
||||
}
|
||||
|
||||
bridge->bus = VMBUS(qbus_new(TYPE_VMBUS, dev, "vmbus"));
|
||||
}
|
||||
|
||||
|
|
|
@ -328,7 +328,8 @@ struct dm_unballoon_response {
|
|||
/*
|
||||
* Hot add request message. Message sent from the host to the guest.
|
||||
*
|
||||
* mem_range: Memory range to hot add.
|
||||
* range: Memory range to hot add.
|
||||
* region: Explicit hot add memory region for guest to use. Optional.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -337,6 +338,12 @@ struct dm_hot_add {
|
|||
union dm_mem_page_range range;
|
||||
} QEMU_PACKED;
|
||||
|
||||
struct dm_hot_add_with_region {
|
||||
struct dm_header hdr;
|
||||
union dm_mem_page_range range;
|
||||
union dm_mem_page_range region;
|
||||
} QEMU_PACKED;
|
||||
|
||||
/*
|
||||
* Hot add response message.
|
||||
* This message is sent by the guest to report the status of a hot add request.
|
||||
|
|
|
@ -139,4 +139,8 @@ typedef struct HvSynDbgMsg {
|
|||
} HvSynDbgMsg;
|
||||
typedef uint16_t (*HvSynDbgHandler)(void *context, HvSynDbgMsg *msg);
|
||||
void hyperv_set_syndbg_handler(HvSynDbgHandler handler, void *context);
|
||||
|
||||
bool hyperv_are_vmbus_recommended_features_enabled(void);
|
||||
void hyperv_set_vmbus_recommended_features_enabled(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,3 +52,7 @@ void hyperv_x86_synic_reset(X86CPU *cpu)
|
|||
void hyperv_x86_synic_update(X86CPU *cpu)
|
||||
{
|
||||
}
|
||||
|
||||
void hyperv_x86_set_vmbus_recommended_features_enabled(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -149,3 +149,8 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void hyperv_x86_set_vmbus_recommended_features_enabled(void)
|
||||
{
|
||||
hyperv_set_vmbus_recommended_features_enabled();
|
||||
}
|
||||
|
|
|
@ -26,4 +26,6 @@ int hyperv_x86_synic_add(X86CPU *cpu);
|
|||
void hyperv_x86_synic_reset(X86CPU *cpu);
|
||||
void hyperv_x86_synic_update(X86CPU *cpu);
|
||||
|
||||
void hyperv_x86_set_vmbus_recommended_features_enabled(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1650,6 +1650,13 @@ static int hyperv_init_vcpu(X86CPU *cpu)
|
|||
}
|
||||
}
|
||||
|
||||
/* Skip SynIC and VP_INDEX since they are hard deps already */
|
||||
if (hyperv_feat_enabled(cpu, HYPERV_FEAT_STIMER) &&
|
||||
hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC) &&
|
||||
hyperv_feat_enabled(cpu, HYPERV_FEAT_RUNTIME)) {
|
||||
hyperv_x86_set_vmbus_recommended_features_enabled();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue