x86/vIO-APIC: make use of xmalloc_flex_struct()
PATCH 1/1 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 <[email protected]>
xen/arch/x86/hvm/vioapic.c +4 -3
@@ -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 ;
xen/include/asm-x86/hvm/vioapic.h +0 -1
@@ -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)
Quoted 5 lines · Jan Beulich
... instead of effectively open-coding it in a type-unsafe way. Drop
hvm_vioapic_size()altogether, folding the other use in amemset()invocation into the subsequent loop.Signed-off-by Jan Beulich <[email protected]>
Acked-by Andrew Cooper <[email protected]>