qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hw/usb/quirks: Use smaller types to reduce .rodata by 10KiB

The USB descriptor sizes are specified as 16-bit for idVendor /
idProduct, and 8-bit for bInterfaceClass / bInterfaceSubClass /
bInterfaceProtocol. Doing so we reduce the usbredir_raw_serial_ids[]
and usbredir_ftdi_serial_ids[] arrays from 16KiB to 6KiB (size
reported on x86_64 host, building with --extra-cflags=-Os).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Philippe Mathieu-Daudé and committed by
Paolo Bonzini
092b6d1e a9d8ba2b

+15 -11
+2 -2
hw/usb/quirks.c
··· 22 22 uint8_t interface_protocol) { 23 23 int i; 24 24 25 - for (i = 0; ids[i].vendor_id != -1; i++) { 25 + for (i = 0; ids[i].terminating_entry == 0; i++) { 26 26 if (ids[i].vendor_id == vendor_id && 27 27 ids[i].product_id == product_id && 28 - (ids[i].interface_class == -1 || 28 + (ids[i].interface_protocol_used == 0 || 29 29 (ids[i].interface_class == interface_class && 30 30 ids[i].interface_subclass == interface_subclass && 31 31 ids[i].interface_protocol == interface_protocol))) {
+13 -9
hw/usb/quirks.h
··· 21 21 #include "quirks-pl2303-ids.h" 22 22 23 23 struct usb_device_id { 24 - int vendor_id; 25 - int product_id; 26 - int interface_class; 27 - int interface_subclass; 28 - int interface_protocol; 24 + uint16_t vendor_id; 25 + uint16_t product_id; 26 + uint8_t interface_class; 27 + uint8_t interface_subclass; 28 + uint8_t interface_protocol; 29 + uint8_t interface_protocol_used:1, 30 + terminating_entry:1, 31 + reserved:6; 29 32 }; 30 33 31 34 #define USB_DEVICE(vendor, product) \ 32 - .vendor_id = vendor, .product_id = product, .interface_class = -1, 35 + .vendor_id = vendor, .product_id = product, .interface_protocol_used = 0, 33 36 34 37 #define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, iclass, isubclass, iproto) \ 35 38 .vendor_id = vend, .product_id = prod, .interface_class = iclass, \ 36 - .interface_subclass = isubclass, .interface_protocol = iproto 39 + .interface_subclass = isubclass, .interface_protocol = iproto, \ 40 + .interface_protocol_used = 1 37 41 38 42 static const struct usb_device_id usbredir_raw_serial_ids[] = { 39 43 /* ··· 206 210 { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) }, 207 211 { USB_DEVICE(SMART_VENDOR_ID, SMART_PRODUCT_ID) }, 208 212 209 - { USB_DEVICE(-1, -1) } /* Terminating Entry */ 213 + { .terminating_entry = 1 } /* Terminating Entry */ 210 214 }; 211 215 212 216 static const struct usb_device_id usbredir_ftdi_serial_ids[] = { ··· 906 910 { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID) }, 907 911 { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) }, 908 912 909 - { USB_DEVICE(-1, -1) } /* Terminating Entry */ 913 + { .terminating_entry = 1 } /* Terminating Entry */ 910 914 }; 911 915 912 916 #undef USB_DEVICE