|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] x86/vIO-APIC: make use of xmalloc_flex_struct()
... instead of effectively open-coding it in a type-unsafe way. Drop
hvm_vioapic_size() altogether, folding the other use in a memset()
invocation into the subsequent loop.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -622,9 +622,9 @@ void vioapic_reset(struct domain *d)
unsigned int nr_pins = vioapic->nr_pins, base_gsi = vioapic->base_gsi;
unsigned int pin;
- memset(vioapic, 0, hvm_vioapic_size(nr_pins));
+ memset(vioapic, 0, offsetof(typeof(*vioapic), redirtbl));
for ( pin = 0; pin < nr_pins; pin++ )
- vioapic->redirtbl[pin].fields.mask = 1;
+ vioapic->redirtbl[pin] = (union vioapic_redir_entry){ .fields.mask
= 1 };
if ( !is_hardware_domain(d) )
{
@@ -685,7 +685,8 @@ int vioapic_init(struct domain *d)
}
if ( (domain_vioapic(d, i) =
- xmalloc_bytes(hvm_vioapic_size(nr_pins))) == NULL )
+ xmalloc_flex_struct(struct hvm_vioapic, redirtbl,
+ nr_pins)) == NULL )
{
vioapic_free(d, nr_vioapics);
return -ENOMEM;
--- a/xen/include/asm-x86/hvm/vioapic.h
+++ b/xen/include/asm-x86/hvm/vioapic.h
@@ -56,7 +56,6 @@ struct hvm_vioapic {
};
};
-#define hvm_vioapic_size(cnt) offsetof(struct hvm_vioapic, redirtbl[cnt])
#define domain_vioapic(d, i) ((d)->arch.hvm.vioapic[i])
#define vioapic_domain(v) ((v)->domain)
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |