kvm/i386: Add xen-gnttab-max-frames property

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
David Woodhouse 2022-12-16 16:27:00 +00:00
parent 2aff696b10
commit 6f43f2ee49
5 changed files with 43 additions and 0 deletions

View File

@ -3704,6 +3704,7 @@ static void kvm_accel_instance_init(Object *obj)
s->notify_vmexit = NOTIFY_VMEXIT_OPTION_RUN;
s->notify_window = 0;
s->xen_version = 0;
s->xen_gnttab_max_frames = 64;
}
/**

View File

@ -120,6 +120,7 @@ struct KVMState
uint32_t notify_window;
uint32_t xen_version;
uint32_t xen_caps;
uint16_t xen_gnttab_max_frames;
};
void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,

View File

@ -25,6 +25,7 @@ void *kvm_xen_get_vcpu_info_hva(uint32_t vcpu_id);
void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id, int type);
void kvm_xen_set_callback_asserted(void);
int kvm_xen_set_vcpu_virq(uint32_t vcpu_id, uint16_t virq, uint16_t port);
uint16_t kvm_xen_get_gnttab_max_frames(void);
#define kvm_xen_has_cap(cap) (!!(kvm_xen_get_caps() & \
KVM_XEN_HVM_CONFIG_ ## cap))

View File

@ -5880,6 +5880,33 @@ static void kvm_arch_set_xen_version(Object *obj, Visitor *v,
}
}
static void kvm_arch_get_xen_gnttab_max_frames(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
KVMState *s = KVM_STATE(obj);
uint16_t value = s->xen_gnttab_max_frames;
visit_type_uint16(v, name, &value, errp);
}
static void kvm_arch_set_xen_gnttab_max_frames(Object *obj, Visitor *v,
const char *name, void *opaque,
Error **errp)
{
KVMState *s = KVM_STATE(obj);
Error *error = NULL;
uint16_t value;
visit_type_uint16(v, name, &value, &error);
if (error) {
error_propagate(errp, error);
return;
}
s->xen_gnttab_max_frames = value;
}
void kvm_arch_accel_class_init(ObjectClass *oc)
{
object_class_property_add_enum(oc, "notify-vmexit", "NotifyVMexitOption",
@ -5905,6 +5932,13 @@ void kvm_arch_accel_class_init(ObjectClass *oc)
"Xen version to be emulated "
"(in XENVER_version form "
"e.g. 0x4000a for 4.10)");
object_class_property_add(oc, "xen-gnttab-max-frames", "uint16",
kvm_arch_get_xen_gnttab_max_frames,
kvm_arch_set_xen_gnttab_max_frames,
NULL, NULL);
object_class_property_set_description(oc, "xen-gnttab-max-frames",
"Maximum number of grant table frames");
}
void kvm_set_max_apic_id(uint32_t max_apic_id)

View File

@ -1238,6 +1238,12 @@ int kvm_xen_handle_exit(X86CPU *cpu, struct kvm_xen_exit *exit)
return 0;
}
uint16_t kvm_xen_get_gnttab_max_frames(void)
{
KVMState *s = KVM_STATE(current_accel());
return s->xen_gnttab_max_frames;
}
int kvm_put_xen_state(CPUState *cs)
{
X86CPU *cpu = X86_CPU(cs);