accel/mshv: store partition proc features
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 <magnuskulke@linux.microsoft.com> Link: https://lore.kernel.org/r/20260417105618.3621-19-magnuskulke@linux.microsoft.com Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Magnus Kulke committed
Apr 17, 2026 at 12:56 UTC
e624d93f3384f4981076186c8d1f22535fa73052
3 files changed
+61
-1
accel/mshv/mshv-all.c
+57
@@ -133,6 +133,57 @@ static int get_host_partition_property(int mshv_fd, uint32_t property_code,
133
return 0;
134
}
135
136
+static int get_partition_property(int vm_fd, uint32_t feature_bank,
137
+ uint64_t *value)
138
+{
139
+ struct hv_input_get_partition_property in = {0};
140
+ struct hv_output_get_partition_property out = {0};
141
+ struct mshv_root_hvcall args = {0};
142
+ int ret;
143
+
144
+ in.property_code = feature_bank;
145
+
146
+ args.code = HVCALL_GET_PARTITION_PROPERTY;
147
+ args.in_sz = sizeof(in);
148
+ args.in_ptr = (uint64_t)∈
149
+ args.out_sz = sizeof(out);
150
+ args.out_ptr = (uint64_t)&out;
151
+
152
+ ret = ioctl(vm_fd, MSHV_ROOT_HVCALL, &args);
153
+ if (ret < 0) {
154
+ error_report("Failed to get guest partition property bank: %s",
155
+ strerror(errno));
156
+ return -1;
157
+ }
158
+
159
+ *value = out.property_value;
160
+ return 0;
161
+}
162
+
163
+static int get_proc_features(int vm_fd,
164
+ union hv_partition_processor_features *features)
165
+{
166
+ int ret;
167
+
168
+ ret = get_partition_property(vm_fd,
169
+ HV_PARTITION_PROPERTY_PROCESSOR_FEATURES0,
170
+ features[0].as_uint64);
171
+ if (ret < 0) {
172
+ error_report("Failed to get processor features bank 0");
173
+ return -1;
174
+ }
175
+
176
+ ret = get_partition_property(vm_fd,
177
+ HV_PARTITION_PROPERTY_PROCESSOR_FEATURES1,
178
+ features[1].as_uint64);
179
+ if (ret < 0) {
180
+ error_report("Failed to get processor features bank 1");
181
+ return -1;
182
+ }
183
+
184
+ return 0;
185
+}
186
+
187
static int create_partition(int mshv_fd, int *vm_fd)
188
{
189
int ret;
@@ -520,6 +571,12 @@ static int mshv_init(AccelState *as, MachineState *ms)
571
572
s->vm = vm_fd;
573
s->fd = mshv_fd;
574
+
575
+ ret = get_proc_features(vm_fd, &s->processor_features);
576
+ if (ret < 0) {
577
+ return -1;
578
+ }
579
+
580
s->nr_as = 1;
581
s->as = g_new0(MshvAddressSpace, s->nr_as);
582
include/hw/hyperv/hvhdk.h
+1
-1
@@ -353,7 +353,7 @@ union hv_partition_processor_features {
353
uint64_t lass_support:1;
354
uint64_t idle_hlt_intercept_support:1;
355
uint64_t msr_list_support:1;
356
- };
356
+ } QEMU_PACKED;
357
};
358
359
enum hv_translate_gva_result_code {
include/system/mshv_int.h
+3
@@ -14,6 +14,8 @@
14
#ifndef QEMU_MSHV_INT_H
15
#define QEMU_MSHV_INT_H
16
17
+#include "hw/hyperv/hvhdk.h"
18
+
19
#define MSHV_MSR_ENTRIES_COUNT 64
20
21
typedef struct hyperv_message hv_message;
@@ -53,6 +55,7 @@ struct MshvState {
55
int nr_allocated_irq_routes;
56
unsigned long *used_gsi_bitmap;
57
unsigned int gsi_count;
58
+ union hv_partition_processor_features processor_features;
59
};
60
61
typedef struct MshvMsiControl {