]> xenbits.xensource.com Git - xen.git/commitdiff
x86/vIO-APIC: make use of xmalloc_flex_struct()
authorJan Beulich <jbeulich@suse.com>
Mon, 7 Dec 2020 13:53:20 +0000 (14:53 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 7 Dec 2020 13:53:20 +0000 (14:53 +0100)
... 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@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/hvm/vioapic.c
xen/include/asm-x86/hvm/vioapic.h

index e64abee7a9a935bbd28bf080bf334dbdb0b3c132..7c462a44d42648d9f44ceb4f25fc89c33e9db2a7 100644 (file)
@@ -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;
index d6f4e12d546df85ee7c93e904da2c5d866e434fb..36b64d20d60ccd6dd4cbb4a1dcc296201bb73a4d 100644 (file)
@@ -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)