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

Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging

virtio,acpi,pci: fixes, cleanups.

Fixes, cleanups in ACPI, PCI, virtio.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Thu 25 Jun 2020 07:48:47 BST
# gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg: issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [full]
# gpg: aka "Michael S. Tsirkin <mst@redhat.com>" [full]
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67
# Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469

* remotes/mst/tags/for_upstream:
Rename use_acpi_pci_hotplug to more appropriate use_acpi_hotplug_bridge
Stop vhost-user sending uninitialized mmap_offsets
docs/specs/tpm: ACPI boot now supported for TPM/ARM
arm/acpi: Add the TPM2.0 device under the DSDT
acpi: Some build_tpm2() code reshape
tests/acpi: update expected data files
acpi: q35: drop _SB.PCI0.ISA.LPCD opregion.
acpi: drop build_piix4_pm()
acpi: drop serial/parallel enable bits from dsdt
acpi: simplify build_isa_devices_aml()
acpi: factor out fw_cfg_add_acpi_dsdt()
acpi: move aml builder code for i8042 (kbd+mouse) device
floppy: move cmos_get_fd_drive_type() from pc
floppy: make isa_fdc_get_drive_max_chs static
acpi: move aml builder code for floppy device
acpi: bios-tables-test: show more context on asl diffs
qtest: allow DSDT acpi table changes

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+286 -290
-2
docs/specs/tpm.rst
··· 346 346 -drive if=pflash,format=raw,file=flash0.img,readonly \ 347 347 -drive if=pflash,format=raw,file=flash1.img 348 348 349 - On Arm, ACPI boot with TPM is not yet supported. 350 - 351 349 In case SeaBIOS is used as firmware, it should show the TPM menu item 352 350 after entering the menu with 'ESC'. 353 351
+32 -19
hw/acpi/aml-build.c
··· 1878 1878 "FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_id); 1879 1879 } 1880 1880 1881 + /* 1882 + * build_tpm2 - Build the TPM2 table as specified in 1883 + * table 7: TCG Hardware Interface Description Table Format for TPM 2.0 1884 + * of TCG ACPI Specification, Family “1.2” and “2.0”, Version 1.2, Rev 8 1885 + */ 1881 1886 void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog) 1882 1887 { 1883 - Acpi20TPM2 *tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader)); 1884 - unsigned log_addr_size = sizeof(tpm2_ptr->log_area_start_address); 1885 - unsigned log_addr_offset = 1886 - (char *)&tpm2_ptr->log_area_start_address - table_data->data; 1887 1888 uint8_t start_method_params[12] = {}; 1889 + unsigned log_addr_offset, tpm2_start; 1890 + uint64_t control_area_start_address; 1888 1891 TPMIf *tpmif = tpm_find(); 1892 + uint32_t start_method; 1893 + void *tpm2_ptr; 1889 1894 1890 - /* platform class */ 1895 + tpm2_start = table_data->len; 1896 + tpm2_ptr = acpi_data_push(table_data, sizeof(AcpiTableHeader)); 1897 + 1898 + /* Platform Class */ 1891 1899 build_append_int_noprefix(table_data, TPM2_ACPI_CLASS_CLIENT, 2); 1892 - /* reserved */ 1900 + /* Reserved */ 1893 1901 build_append_int_noprefix(table_data, 0, 2); 1894 1902 if (TPM_IS_TIS_ISA(tpmif) || TPM_IS_TIS_SYSBUS(tpmif)) { 1895 - /* address of control area */ 1896 - build_append_int_noprefix(table_data, 0, 8); 1897 - /* start method */ 1898 - build_append_int_noprefix(table_data, TPM2_START_METHOD_MMIO, 4); 1903 + control_area_start_address = 0; 1904 + start_method = TPM2_START_METHOD_MMIO; 1899 1905 } else if (TPM_IS_CRB(tpmif)) { 1900 - build_append_int_noprefix(table_data, TPM_CRB_ADDR_CTRL, 8); 1901 - build_append_int_noprefix(table_data, TPM2_START_METHOD_CRB, 4); 1906 + control_area_start_address = TPM_CRB_ADDR_CTRL; 1907 + start_method = TPM2_START_METHOD_CRB; 1902 1908 } else { 1903 - g_warn_if_reached(); 1909 + g_assert_not_reached(); 1904 1910 } 1911 + /* Address of Control Area */ 1912 + build_append_int_noprefix(table_data, control_area_start_address, 8); 1913 + /* Start Method */ 1914 + build_append_int_noprefix(table_data, start_method, 4); 1905 1915 1906 - /* platform specific parameters */ 1907 - g_array_append_vals(table_data, &start_method_params, 12); 1916 + /* Platform Specific Parameters */ 1917 + g_array_append_vals(table_data, &start_method_params, 1918 + ARRAY_SIZE(start_method_params)); 1908 1919 1909 - /* log area minimum length */ 1920 + /* Log Area Minimum Length */ 1910 1921 build_append_int_noprefix(table_data, TPM_LOG_AREA_MINIMUM_SIZE, 4); 1911 1922 1912 1923 acpi_data_push(tcpalog, TPM_LOG_AREA_MINIMUM_SIZE); 1913 1924 bios_linker_loader_alloc(linker, ACPI_BUILD_TPMLOG_FILE, tcpalog, 1, 1914 1925 false); 1915 1926 1916 - /* log area start address to be filled by Guest linker */ 1927 + log_addr_offset = table_data->len; 1928 + 1929 + /* Log Area Start Address to be filled by Guest linker */ 1917 1930 build_append_int_noprefix(table_data, 0, 8); 1918 1931 bios_linker_loader_add_pointer(linker, ACPI_BUILD_TABLE_FILE, 1919 - log_addr_offset, log_addr_size, 1932 + log_addr_offset, 8, 1920 1933 ACPI_BUILD_TPMLOG_FILE, 0); 1921 1934 build_header(linker, table_data, 1922 - (void *)tpm2_ptr, "TPM2", sizeof(*tpm2_ptr), 4, NULL, NULL); 1935 + tpm2_ptr, "TPM2", table_data->len - tpm2_start, 4, NULL, NULL); 1923 1936 } 1924 1937 1925 1938 /* ACPI 5.0: 6.4.3.8.2 Serial Bus Connection Descriptors */
+11 -10
hw/acpi/piix4.c
··· 77 77 Notifier powerdown_notifier; 78 78 79 79 AcpiPciHpState acpi_pci_hotplug; 80 - bool use_acpi_pci_hotplug; 80 + bool use_acpi_hotplug_bridge; 81 81 82 82 uint8_t disable_s3; 83 83 uint8_t disable_s4; ··· 204 204 } 205 205 }; 206 206 207 - static bool vmstate_test_use_acpi_pci_hotplug(void *opaque, int version_id) 207 + static bool vmstate_test_use_acpi_hotplug_bridge(void *opaque, int version_id) 208 208 { 209 209 PIIX4PMState *s = opaque; 210 - return s->use_acpi_pci_hotplug; 210 + return s->use_acpi_hotplug_bridge; 211 211 } 212 212 213 - static bool vmstate_test_no_use_acpi_pci_hotplug(void *opaque, int version_id) 213 + static bool vmstate_test_no_use_acpi_hotplug_bridge(void *opaque, 214 + int version_id) 214 215 { 215 216 PIIX4PMState *s = opaque; 216 - return !s->use_acpi_pci_hotplug; 217 + return !s->use_acpi_hotplug_bridge; 217 218 } 218 219 219 220 static bool vmstate_test_use_memhp(void *opaque) ··· 290 291 VMSTATE_STRUCT_TEST( 291 292 acpi_pci_hotplug.acpi_pcihp_pci_status[ACPI_PCIHP_BSEL_DEFAULT], 292 293 PIIX4PMState, 293 - vmstate_test_no_use_acpi_pci_hotplug, 294 + vmstate_test_no_use_acpi_hotplug_bridge, 294 295 2, vmstate_pci_status, 295 296 struct AcpiPciHpPciStatus), 296 297 VMSTATE_PCI_HOTPLUG(acpi_pci_hotplug, PIIX4PMState, 297 - vmstate_test_use_acpi_pci_hotplug), 298 + vmstate_test_use_acpi_hotplug_bridge), 298 299 VMSTATE_END_OF_LIST() 299 300 }, 300 301 .subsections = (const VMStateDescription*[]) { ··· 530 531 s->smi_irq = smi_irq; 531 532 s->smm_enabled = smm_enabled; 532 533 if (xen_enabled()) { 533 - s->use_acpi_pci_hotplug = false; 534 + s->use_acpi_hotplug_bridge = false; 534 535 } 535 536 536 537 pci_realize_and_unref(pci_dev, bus, &error_fatal); ··· 595 596 memory_region_add_subregion(parent, GPE_BASE, &s->io_gpe); 596 597 597 598 acpi_pcihp_init(OBJECT(s), &s->acpi_pci_hotplug, bus, parent, 598 - s->use_acpi_pci_hotplug); 599 + s->use_acpi_hotplug_bridge); 599 600 600 601 s->cpu_hotplug_legacy = true; 601 602 object_property_add_bool(OBJECT(s), "cpu-hotplug-legacy", ··· 633 634 DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0), 634 635 DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2), 635 636 DEFINE_PROP_BOOL("acpi-pci-hotplug-with-bridge-support", PIIX4PMState, 636 - use_acpi_pci_hotplug, true), 637 + use_acpi_hotplug_bridge, true), 637 638 DEFINE_PROP_BOOL("memory-hotplug-support", PIIX4PMState, 638 639 acpi_memory_hotplug.is_enabled, true), 639 640 DEFINE_PROP_END_OF_LIST(),
+34
hw/arm/virt-acpi-build.c
··· 46 46 #include "hw/pci/pci.h" 47 47 #include "hw/arm/virt.h" 48 48 #include "hw/mem/nvdimm.h" 49 + #include "hw/platform-bus.h" 49 50 #include "sysemu/numa.h" 50 51 #include "sysemu/reset.h" 51 52 #include "sysemu/tpm.h" ··· 361 362 Aml *dev = aml_device(ACPI_POWER_BUTTON_DEVICE); 362 363 aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C"))); 363 364 aml_append(dev, aml_name_decl("_UID", aml_int(0))); 365 + aml_append(scope, dev); 366 + } 367 + 368 + static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms) 369 + { 370 + PlatformBusDevice *pbus = PLATFORM_BUS_DEVICE(vms->platform_bus_dev); 371 + hwaddr pbus_base = vms->memmap[VIRT_PLATFORM_BUS].base; 372 + SysBusDevice *sbdev = SYS_BUS_DEVICE(tpm_find()); 373 + MemoryRegion *sbdev_mr; 374 + hwaddr tpm_base; 375 + 376 + if (!sbdev) { 377 + return; 378 + } 379 + 380 + tpm_base = platform_bus_get_mmio_addr(pbus, sbdev, 0); 381 + assert(tpm_base != -1); 382 + 383 + tpm_base += pbus_base; 384 + 385 + sbdev_mr = sysbus_mmio_get_region(sbdev, 0); 386 + 387 + Aml *dev = aml_device("TPM0"); 388 + aml_append(dev, aml_name_decl("_HID", aml_string("MSFT0101"))); 389 + aml_append(dev, aml_name_decl("_UID", aml_int(0))); 390 + 391 + Aml *crs = aml_resource_template(); 392 + aml_append(crs, 393 + aml_memory32_fixed(tpm_base, 394 + (uint32_t)memory_region_size(sbdev_mr), 395 + AML_READ_WRITE)); 396 + aml_append(dev, aml_name_decl("_CRS", crs)); 364 397 aml_append(scope, dev); 365 398 } 366 399 ··· 762 795 } 763 796 764 797 acpi_dsdt_add_power_button(scope); 798 + acpi_dsdt_add_tpm(scope, vms); 765 799 766 800 aml_append(dsdt, scope); 767 801
+109 -2
hw/block/fdc.c
··· 32 32 #include "qapi/error.h" 33 33 #include "qemu/error-report.h" 34 34 #include "qemu/timer.h" 35 + #include "hw/acpi/aml-build.h" 35 36 #include "hw/irq.h" 36 37 #include "hw/isa/isa.h" 37 38 #include "hw/qdev-properties.h" ··· 2753 2754 return isa->state.drives[i].drive; 2754 2755 } 2755 2756 2756 - void isa_fdc_get_drive_max_chs(FloppyDriveType type, 2757 - uint8_t *maxc, uint8_t *maxh, uint8_t *maxs) 2757 + static void isa_fdc_get_drive_max_chs(FloppyDriveType type, uint8_t *maxc, 2758 + uint8_t *maxh, uint8_t *maxs) 2758 2759 { 2759 2760 const FDFormat *fdf; 2760 2761 ··· 2776 2777 (*maxc)--; 2777 2778 } 2778 2779 2780 + static Aml *build_fdinfo_aml(int idx, FloppyDriveType type) 2781 + { 2782 + Aml *dev, *fdi; 2783 + uint8_t maxc, maxh, maxs; 2784 + 2785 + isa_fdc_get_drive_max_chs(type, &maxc, &maxh, &maxs); 2786 + 2787 + dev = aml_device("FLP%c", 'A' + idx); 2788 + 2789 + aml_append(dev, aml_name_decl("_ADR", aml_int(idx))); 2790 + 2791 + fdi = aml_package(16); 2792 + aml_append(fdi, aml_int(idx)); /* Drive Number */ 2793 + aml_append(fdi, 2794 + aml_int(cmos_get_fd_drive_type(type))); /* Device Type */ 2795 + /* 2796 + * the values below are the limits of the drive, and are thus independent 2797 + * of the inserted media 2798 + */ 2799 + aml_append(fdi, aml_int(maxc)); /* Maximum Cylinder Number */ 2800 + aml_append(fdi, aml_int(maxs)); /* Maximum Sector Number */ 2801 + aml_append(fdi, aml_int(maxh)); /* Maximum Head Number */ 2802 + /* 2803 + * SeaBIOS returns the below values for int 0x13 func 0x08 regardless of 2804 + * the drive type, so shall we 2805 + */ 2806 + aml_append(fdi, aml_int(0xAF)); /* disk_specify_1 */ 2807 + aml_append(fdi, aml_int(0x02)); /* disk_specify_2 */ 2808 + aml_append(fdi, aml_int(0x25)); /* disk_motor_wait */ 2809 + aml_append(fdi, aml_int(0x02)); /* disk_sector_siz */ 2810 + aml_append(fdi, aml_int(0x12)); /* disk_eot */ 2811 + aml_append(fdi, aml_int(0x1B)); /* disk_rw_gap */ 2812 + aml_append(fdi, aml_int(0xFF)); /* disk_dtl */ 2813 + aml_append(fdi, aml_int(0x6C)); /* disk_formt_gap */ 2814 + aml_append(fdi, aml_int(0xF6)); /* disk_fill */ 2815 + aml_append(fdi, aml_int(0x0F)); /* disk_head_sttl */ 2816 + aml_append(fdi, aml_int(0x08)); /* disk_motor_strt */ 2817 + 2818 + aml_append(dev, aml_name_decl("_FDI", fdi)); 2819 + return dev; 2820 + } 2821 + 2822 + int cmos_get_fd_drive_type(FloppyDriveType fd0) 2823 + { 2824 + int val; 2825 + 2826 + switch (fd0) { 2827 + case FLOPPY_DRIVE_TYPE_144: 2828 + /* 1.44 Mb 3"5 drive */ 2829 + val = 4; 2830 + break; 2831 + case FLOPPY_DRIVE_TYPE_288: 2832 + /* 2.88 Mb 3"5 drive */ 2833 + val = 5; 2834 + break; 2835 + case FLOPPY_DRIVE_TYPE_120: 2836 + /* 1.2 Mb 5"5 drive */ 2837 + val = 2; 2838 + break; 2839 + case FLOPPY_DRIVE_TYPE_NONE: 2840 + default: 2841 + val = 0; 2842 + break; 2843 + } 2844 + return val; 2845 + } 2846 + 2847 + static void fdc_isa_build_aml(ISADevice *isadev, Aml *scope) 2848 + { 2849 + Aml *dev; 2850 + Aml *crs; 2851 + int i; 2852 + 2853 + #define ACPI_FDE_MAX_FD 4 2854 + uint32_t fde_buf[5] = { 2855 + 0, 0, 0, 0, /* presence of floppy drives #0 - #3 */ 2856 + cpu_to_le32(2) /* tape presence (2 == never present) */ 2857 + }; 2858 + 2859 + crs = aml_resource_template(); 2860 + aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04)); 2861 + aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01)); 2862 + aml_append(crs, aml_irq_no_flags(6)); 2863 + aml_append(crs, 2864 + aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2)); 2865 + 2866 + dev = aml_device("FDC0"); 2867 + aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700"))); 2868 + aml_append(dev, aml_name_decl("_CRS", crs)); 2869 + 2870 + for (i = 0; i < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) { 2871 + FloppyDriveType type = isa_fdc_get_drive_type(isadev, i); 2872 + 2873 + if (type < FLOPPY_DRIVE_TYPE_NONE) { 2874 + fde_buf[i] = cpu_to_le32(1); /* drive present */ 2875 + aml_append(dev, build_fdinfo_aml(i, type)); 2876 + } 2877 + } 2878 + aml_append(dev, aml_name_decl("_FDE", 2879 + aml_buffer(sizeof(fde_buf), (uint8_t *)fde_buf))); 2880 + 2881 + aml_append(scope, dev); 2882 + } 2883 + 2779 2884 static const VMStateDescription vmstate_isa_fdc ={ 2780 2885 .name = "fdc", 2781 2886 .version_id = 2, ··· 2809 2914 static void isabus_fdc_class_init(ObjectClass *klass, void *data) 2810 2915 { 2811 2916 DeviceClass *dc = DEVICE_CLASS(klass); 2917 + ISADeviceClass *isa = ISA_DEVICE_CLASS(klass); 2812 2918 2813 2919 dc->realize = isabus_fdc_realize; 2814 2920 dc->fw_name = "fdc"; 2815 2921 dc->reset = fdctrl_external_reset_isa; 2816 2922 dc->vmsd = &vmstate_isa_fdc; 2923 + isa->build_aml = fdc_isa_build_aml; 2817 2924 device_class_set_props(dc, isa_fdc_properties); 2818 2925 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); 2819 2926 }
+6 -204
hw/i386/acpi-build.c
··· 938 938 aml_append(table, scope); 939 939 } 940 940 941 - static Aml *build_fdinfo_aml(int idx, FloppyDriveType type) 942 - { 943 - Aml *dev, *fdi; 944 - uint8_t maxc, maxh, maxs; 945 - 946 - isa_fdc_get_drive_max_chs(type, &maxc, &maxh, &maxs); 947 - 948 - dev = aml_device("FLP%c", 'A' + idx); 949 - 950 - aml_append(dev, aml_name_decl("_ADR", aml_int(idx))); 951 - 952 - fdi = aml_package(16); 953 - aml_append(fdi, aml_int(idx)); /* Drive Number */ 954 - aml_append(fdi, 955 - aml_int(cmos_get_fd_drive_type(type))); /* Device Type */ 956 - /* 957 - * the values below are the limits of the drive, and are thus independent 958 - * of the inserted media 959 - */ 960 - aml_append(fdi, aml_int(maxc)); /* Maximum Cylinder Number */ 961 - aml_append(fdi, aml_int(maxs)); /* Maximum Sector Number */ 962 - aml_append(fdi, aml_int(maxh)); /* Maximum Head Number */ 963 - /* 964 - * SeaBIOS returns the below values for int 0x13 func 0x08 regardless of 965 - * the drive type, so shall we 966 - */ 967 - aml_append(fdi, aml_int(0xAF)); /* disk_specify_1 */ 968 - aml_append(fdi, aml_int(0x02)); /* disk_specify_2 */ 969 - aml_append(fdi, aml_int(0x25)); /* disk_motor_wait */ 970 - aml_append(fdi, aml_int(0x02)); /* disk_sector_siz */ 971 - aml_append(fdi, aml_int(0x12)); /* disk_eot */ 972 - aml_append(fdi, aml_int(0x1B)); /* disk_rw_gap */ 973 - aml_append(fdi, aml_int(0xFF)); /* disk_dtl */ 974 - aml_append(fdi, aml_int(0x6C)); /* disk_formt_gap */ 975 - aml_append(fdi, aml_int(0xF6)); /* disk_fill */ 976 - aml_append(fdi, aml_int(0x0F)); /* disk_head_sttl */ 977 - aml_append(fdi, aml_int(0x08)); /* disk_motor_strt */ 978 - 979 - aml_append(dev, aml_name_decl("_FDI", fdi)); 980 - return dev; 981 - } 982 - 983 - static Aml *build_fdc_device_aml(ISADevice *fdc) 984 - { 985 - int i; 986 - Aml *dev; 987 - Aml *crs; 988 - 989 - #define ACPI_FDE_MAX_FD 4 990 - uint32_t fde_buf[5] = { 991 - 0, 0, 0, 0, /* presence of floppy drives #0 - #3 */ 992 - cpu_to_le32(2) /* tape presence (2 == never present) */ 993 - }; 994 - 995 - dev = aml_device("FDC0"); 996 - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0700"))); 997 - 998 - crs = aml_resource_template(); 999 - aml_append(crs, aml_io(AML_DECODE16, 0x03F2, 0x03F2, 0x00, 0x04)); 1000 - aml_append(crs, aml_io(AML_DECODE16, 0x03F7, 0x03F7, 0x00, 0x01)); 1001 - aml_append(crs, aml_irq_no_flags(6)); 1002 - aml_append(crs, 1003 - aml_dma(AML_COMPATIBILITY, AML_NOTBUSMASTER, AML_TRANSFER8, 2)); 1004 - aml_append(dev, aml_name_decl("_CRS", crs)); 1005 - 1006 - for (i = 0; i < MIN(MAX_FD, ACPI_FDE_MAX_FD); i++) { 1007 - FloppyDriveType type = isa_fdc_get_drive_type(fdc, i); 1008 - 1009 - if (type < FLOPPY_DRIVE_TYPE_NONE) { 1010 - fde_buf[i] = cpu_to_le32(1); /* drive present */ 1011 - aml_append(dev, build_fdinfo_aml(i, type)); 1012 - } 1013 - } 1014 - aml_append(dev, aml_name_decl("_FDE", 1015 - aml_buffer(sizeof(fde_buf), (uint8_t *)fde_buf))); 1016 - 1017 - return dev; 1018 - } 1019 - 1020 - static Aml *build_kbd_device_aml(void) 1021 - { 1022 - Aml *dev; 1023 - Aml *crs; 1024 - 1025 - dev = aml_device("KBD"); 1026 - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0303"))); 1027 - 1028 - aml_append(dev, aml_name_decl("_STA", aml_int(0xf))); 1029 - 1030 - crs = aml_resource_template(); 1031 - aml_append(crs, aml_io(AML_DECODE16, 0x0060, 0x0060, 0x01, 0x01)); 1032 - aml_append(crs, aml_io(AML_DECODE16, 0x0064, 0x0064, 0x01, 0x01)); 1033 - aml_append(crs, aml_irq_no_flags(1)); 1034 - aml_append(dev, aml_name_decl("_CRS", crs)); 1035 - 1036 - return dev; 1037 - } 1038 - 1039 - static Aml *build_mouse_device_aml(void) 1040 - { 1041 - Aml *dev; 1042 - Aml *crs; 1043 - 1044 - dev = aml_device("MOU"); 1045 - aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0F13"))); 1046 - 1047 - aml_append(dev, aml_name_decl("_STA", aml_int(0xf))); 1048 - 1049 - crs = aml_resource_template(); 1050 - aml_append(crs, aml_irq_no_flags(12)); 1051 - aml_append(dev, aml_name_decl("_CRS", crs)); 1052 - 1053 - return dev; 1054 - } 1055 - 1056 941 static Aml *build_vmbus_device_aml(VMBusBridge *vmbus_bridge) 1057 942 { 1058 943 Aml *dev; ··· 1092 977 1093 978 static void build_isa_devices_aml(Aml *table) 1094 979 { 1095 - ISADevice *fdc = pc_find_fdc0(); 1096 980 VMBusBridge *vmbus_bridge = vmbus_bridge_find(); 1097 981 bool ambiguous; 1098 - 1099 - Aml *scope = aml_scope("_SB.PCI0.ISA"); 1100 982 Object *obj = object_resolve_path_type("", TYPE_ISA_BUS, &ambiguous); 983 + Aml *scope; 1101 984 1102 - aml_append(scope, build_kbd_device_aml()); 1103 - aml_append(scope, build_mouse_device_aml()); 1104 - if (fdc) { 1105 - aml_append(scope, build_fdc_device_aml(fdc)); 1106 - } 985 + assert(obj && !ambiguous); 1107 986 1108 - if (ambiguous) { 1109 - error_report("Multiple ISA busses, unable to define IPMI ACPI data"); 1110 - } else if (!obj) { 1111 - error_report("No ISA bus, unable to define IPMI ACPI data"); 1112 - } else { 1113 - build_acpi_ipmi_devices(scope, BUS(obj), "\\_SB.PCI0.ISA"); 1114 - isa_build_aml(ISA_BUS(obj), scope); 1115 - } 987 + scope = aml_scope("_SB.PCI0.ISA"); 988 + build_acpi_ipmi_devices(scope, BUS(obj), "\\_SB.PCI0.ISA"); 989 + isa_build_aml(ISA_BUS(obj), scope); 1116 990 1117 991 if (vmbus_bridge) { 1118 992 aml_append(scope, build_vmbus_device_aml(vmbus_bridge)); ··· 1466 1340 { 1467 1341 Aml *dev; 1468 1342 Aml *scope; 1469 - Aml *field; 1470 1343 1471 1344 scope = aml_scope("_SB.PCI0"); 1472 1345 dev = aml_device("ISA"); ··· 1476 1349 aml_append(dev, aml_operation_region("PIRQ", AML_PCI_CONFIG, 1477 1350 aml_int(0x60), 0x0C)); 1478 1351 1479 - aml_append(dev, aml_operation_region("LPCD", AML_PCI_CONFIG, 1480 - aml_int(0x80), 0x02)); 1481 - field = aml_field("LPCD", AML_ANY_ACC, AML_NOLOCK, AML_PRESERVE); 1482 - aml_append(field, aml_named_field("COMA", 3)); 1483 - aml_append(field, aml_reserved_field(1)); 1484 - aml_append(field, aml_named_field("COMB", 3)); 1485 - aml_append(field, aml_reserved_field(1)); 1486 - aml_append(field, aml_named_field("LPTD", 2)); 1487 - aml_append(dev, field); 1488 - 1489 - aml_append(dev, aml_operation_region("LPCE", AML_PCI_CONFIG, 1490 - aml_int(0x82), 0x02)); 1491 - /* enable bits */ 1492 - field = aml_field("LPCE", AML_ANY_ACC, AML_NOLOCK, AML_PRESERVE); 1493 - aml_append(field, aml_named_field("CAEN", 1)); 1494 - aml_append(field, aml_named_field("CBEN", 1)); 1495 - aml_append(field, aml_named_field("LPEN", 1)); 1496 - aml_append(dev, field); 1497 - 1498 - aml_append(scope, dev); 1499 - aml_append(table, scope); 1500 - } 1501 - 1502 - static void build_piix4_pm(Aml *table) 1503 - { 1504 - Aml *dev; 1505 - Aml *scope; 1506 - 1507 - scope = aml_scope("_SB.PCI0"); 1508 - dev = aml_device("PX13"); 1509 - aml_append(dev, aml_name_decl("_ADR", aml_int(0x00010003))); 1510 - 1511 - aml_append(dev, aml_operation_region("P13C", AML_PCI_CONFIG, 1512 - aml_int(0x00), 0xff)); 1513 1352 aml_append(scope, dev); 1514 1353 aml_append(table, scope); 1515 1354 } ··· 1518 1357 { 1519 1358 Aml *dev; 1520 1359 Aml *scope; 1521 - Aml *field; 1522 1360 1523 1361 scope = aml_scope("_SB.PCI0"); 1524 1362 dev = aml_device("ISA"); ··· 1527 1365 /* PIIX PCI to ISA irq remapping */ 1528 1366 aml_append(dev, aml_operation_region("P40C", AML_PCI_CONFIG, 1529 1367 aml_int(0x60), 0x04)); 1530 - /* enable bits */ 1531 - field = aml_field("^PX13.P13C", AML_ANY_ACC, AML_NOLOCK, AML_PRESERVE); 1532 - /* Offset(0x5f),, 7, */ 1533 - aml_append(field, aml_reserved_field(0x2f8)); 1534 - aml_append(field, aml_reserved_field(7)); 1535 - aml_append(field, aml_named_field("LPEN", 1)); 1536 - /* Offset(0x67),, 3, */ 1537 - aml_append(field, aml_reserved_field(0x38)); 1538 - aml_append(field, aml_reserved_field(3)); 1539 - aml_append(field, aml_named_field("CAEN", 1)); 1540 - aml_append(field, aml_reserved_field(3)); 1541 - aml_append(field, aml_named_field("CBEN", 1)); 1542 - aml_append(dev, field); 1543 1368 1544 1369 aml_append(scope, dev); 1545 1370 aml_append(table, scope); ··· 1679 1504 aml_append(dsdt, sb_scope); 1680 1505 1681 1506 build_hpet_aml(dsdt); 1682 - build_piix4_pm(dsdt); 1683 1507 build_piix4_isa_bridge(dsdt); 1684 1508 build_isa_devices_aml(dsdt); 1685 1509 build_piix4_pci_hotplug(dsdt); ··· 1924 1748 1925 1749 /* create fw_cfg node, unconditionally */ 1926 1750 { 1927 - /* when using port i/o, the 8-bit data register *always* overlaps 1928 - * with half of the 16-bit control register. Hence, the total size 1929 - * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the 1930 - * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 */ 1931 - uint8_t io_size = object_property_get_bool(OBJECT(x86ms->fw_cfg), 1932 - "dma_enabled", NULL) ? 1933 - ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : 1934 - FW_CFG_CTL_SIZE; 1935 - 1936 1751 scope = aml_scope("\\_SB.PCI0"); 1937 - dev = aml_device("FWCF"); 1938 - 1939 - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); 1940 - 1941 - /* device present, functioning, decoding, not shown in UI */ 1942 - aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); 1943 - 1944 - crs = aml_resource_template(); 1945 - aml_append(crs, 1946 - aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size) 1947 - ); 1948 - aml_append(dev, aml_name_decl("_CRS", crs)); 1949 - 1950 - aml_append(scope, dev); 1752 + fw_cfg_add_acpi_dsdt(scope, x86ms->fw_cfg); 1951 1753 aml_append(dsdt, scope); 1952 1754 } 1953 1755
+28
hw/i386/fw_cfg.c
··· 15 15 #include "qemu/osdep.h" 16 16 #include "sysemu/numa.h" 17 17 #include "hw/acpi/acpi.h" 18 + #include "hw/acpi/aml-build.h" 18 19 #include "hw/firmware/smbios.h" 19 20 #include "hw/i386/fw_cfg.h" 20 21 #include "hw/timer/hpet.h" ··· 179 180 *val = cpu_to_le64(feature_control_bits | FEATURE_CONTROL_LOCKED); 180 181 fw_cfg_add_file(fw_cfg, "etc/msr_feature_control", val, sizeof(*val)); 181 182 } 183 + 184 + void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg) 185 + { 186 + /* 187 + * when using port i/o, the 8-bit data register *always* overlaps 188 + * with half of the 16-bit control register. Hence, the total size 189 + * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the 190 + * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 191 + */ 192 + Object *obj = OBJECT(fw_cfg); 193 + uint8_t io_size = object_property_get_bool(obj, "dma_enabled", NULL) ? 194 + ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : 195 + FW_CFG_CTL_SIZE; 196 + Aml *dev = aml_device("FWCF"); 197 + Aml *crs = aml_resource_template(); 198 + 199 + aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); 200 + 201 + /* device present, functioning, decoding, not shown in UI */ 202 + aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); 203 + 204 + aml_append(crs, 205 + aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size)); 206 + 207 + aml_append(dev, aml_name_decl("_CRS", crs)); 208 + aml_append(scope, dev); 209 + }
+1
hw/i386/fw_cfg.h
··· 25 25 uint16_t apic_id_limit); 26 26 void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg); 27 27 void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg); 28 + void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg); 28 29 29 30 #endif
-25
hw/i386/pc.c
··· 386 386 387 387 #define REG_EQUIPMENT_BYTE 0x14 388 388 389 - int cmos_get_fd_drive_type(FloppyDriveType fd0) 390 - { 391 - int val; 392 - 393 - switch (fd0) { 394 - case FLOPPY_DRIVE_TYPE_144: 395 - /* 1.44 Mb 3"5 drive */ 396 - val = 4; 397 - break; 398 - case FLOPPY_DRIVE_TYPE_288: 399 - /* 2.88 Mb 3"5 drive */ 400 - val = 5; 401 - break; 402 - case FLOPPY_DRIVE_TYPE_120: 403 - /* 1.2 Mb 5"5 drive */ 404 - val = 2; 405 - break; 406 - case FLOPPY_DRIVE_TYPE_NONE: 407 - default: 408 - val = 0; 409 - break; 410 - } 411 - return val; 412 - } 413 - 414 389 static void cmos_init_hd(ISADevice *s, int type_ofs, int info_ofs, 415 390 int16_t cylinders, int8_t heads, int8_t sectors) 416 391 {
+31
hw/input/pckbd.c
··· 26 26 #include "qemu/log.h" 27 27 #include "hw/isa/isa.h" 28 28 #include "migration/vmstate.h" 29 + #include "hw/acpi/aml-build.h" 29 30 #include "hw/input/ps2.h" 30 31 #include "hw/irq.h" 31 32 #include "hw/input/i8042.h" ··· 561 562 qemu_register_reset(kbd_reset, s); 562 563 } 563 564 565 + static void i8042_build_aml(ISADevice *isadev, Aml *scope) 566 + { 567 + Aml *kbd; 568 + Aml *mou; 569 + Aml *crs; 570 + 571 + crs = aml_resource_template(); 572 + aml_append(crs, aml_io(AML_DECODE16, 0x0060, 0x0060, 0x01, 0x01)); 573 + aml_append(crs, aml_io(AML_DECODE16, 0x0064, 0x0064, 0x01, 0x01)); 574 + aml_append(crs, aml_irq_no_flags(1)); 575 + 576 + kbd = aml_device("KBD"); 577 + aml_append(kbd, aml_name_decl("_HID", aml_eisaid("PNP0303"))); 578 + aml_append(kbd, aml_name_decl("_STA", aml_int(0xf))); 579 + aml_append(kbd, aml_name_decl("_CRS", crs)); 580 + 581 + crs = aml_resource_template(); 582 + aml_append(crs, aml_irq_no_flags(12)); 583 + 584 + mou = aml_device("MOU"); 585 + aml_append(mou, aml_name_decl("_HID", aml_eisaid("PNP0F13"))); 586 + aml_append(mou, aml_name_decl("_STA", aml_int(0xf))); 587 + aml_append(mou, aml_name_decl("_CRS", crs)); 588 + 589 + aml_append(scope, kbd); 590 + aml_append(scope, mou); 591 + } 592 + 564 593 static void i8042_class_initfn(ObjectClass *klass, void *data) 565 594 { 566 595 DeviceClass *dc = DEVICE_CLASS(klass); 596 + ISADeviceClass *isa = ISA_DEVICE_CLASS(klass); 567 597 568 598 dc->realize = i8042_realizefn; 569 599 dc->vmsd = &vmstate_kbd_isa; 600 + isa->build_aml = i8042_build_aml; 570 601 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); 571 602 } 572 603
+6 -6
hw/virtio/vhost-user.c
··· 460 460 } 461 461 462 462 static void vhost_user_fill_msg_region(VhostUserMemoryRegion *dst, 463 - struct vhost_memory_region *src) 463 + struct vhost_memory_region *src, 464 + uint64_t mmap_offset) 464 465 { 465 466 assert(src != NULL && dst != NULL); 466 467 dst->userspace_addr = src->userspace_addr; 467 468 dst->memory_size = src->memory_size; 468 469 dst->guest_phys_addr = src->guest_phys_addr; 470 + dst->mmap_offset = mmap_offset; 469 471 } 470 472 471 473 static int vhost_user_fill_set_mem_table_msg(struct vhost_user *u, ··· 500 502 error_report("Failed preparing vhost-user memory table msg"); 501 503 return -1; 502 504 } 503 - vhost_user_fill_msg_region(&region_buffer, reg); 505 + vhost_user_fill_msg_region(&region_buffer, reg, offset); 504 506 msg->payload.memory.regions[*fd_num] = region_buffer; 505 - msg->payload.memory.regions[*fd_num].mmap_offset = offset; 506 507 fds[(*fd_num)++] = fd; 507 508 } else if (track_ramblocks) { 508 509 u->region_rb_offset[i] = 0; ··· 649 650 650 651 if (fd > 0) { 651 652 msg->hdr.request = VHOST_USER_REM_MEM_REG; 652 - vhost_user_fill_msg_region(&region_buffer, shadow_reg); 653 + vhost_user_fill_msg_region(&region_buffer, shadow_reg, 0); 653 654 msg->payload.mem_reg.region = region_buffer; 654 655 655 656 if (vhost_user_write(dev, msg, &fd, 1) < 0) { ··· 709 710 u->region_rb[reg_idx] = mr->ram_block; 710 711 } 711 712 msg->hdr.request = VHOST_USER_ADD_MEM_REG; 712 - vhost_user_fill_msg_region(&region_buffer, reg); 713 + vhost_user_fill_msg_region(&region_buffer, reg, offset); 713 714 msg->payload.mem_reg.region = region_buffer; 714 - msg->payload.mem_reg.region.mmap_offset = offset; 715 715 716 716 if (vhost_user_write(dev, msg, &fd, 1) < 0) { 717 717 return -1;
-18
include/hw/acpi/acpi-defs.h
··· 465 465 } QEMU_PACKED; 466 466 typedef struct Acpi20Tcpa Acpi20Tcpa; 467 467 468 - /* 469 - * TPM2 470 - * 471 - * Following Version 1.2, Revision 8 of specs: 472 - * https://trustedcomputinggroup.org/tcg-acpi-specification/ 473 - */ 474 - struct Acpi20TPM2 { 475 - ACPI_TABLE_HEADER_DEF 476 - uint16_t platform_class; 477 - uint16_t reserved; 478 - uint64_t control_area_address; 479 - uint32_t start_method; 480 - uint8_t start_method_params[12]; 481 - uint32_t log_area_minimum_length; 482 - uint64_t log_area_start_address; 483 - } QEMU_PACKED; 484 - typedef struct Acpi20TPM2 Acpi20TPM2; 485 - 486 468 /* DMAR - DMA Remapping table r2.2 */ 487 469 struct AcpiTableDmar { 488 470 ACPI_TABLE_HEADER_DEF
+1 -2
include/hw/block/fdc.h
··· 16 16 DriveInfo **fds, qemu_irq *fdc_tc); 17 17 18 18 FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i); 19 - void isa_fdc_get_drive_max_chs(FloppyDriveType type, 20 - uint8_t *maxc, uint8_t *maxh, uint8_t *maxs); 19 + int cmos_get_fd_drive_type(FloppyDriveType fd0); 21 20 22 21 #endif
-1
include/hw/i386/pc.h
··· 178 178 void pc_i8259_create(ISABus *isa_bus, qemu_irq *i8259_irqs); 179 179 180 180 ISADevice *pc_find_fdc0(void); 181 - int cmos_get_fd_drive_type(FloppyDriveType fd0); 182 181 183 182 /* port92.c */ 184 183 #define PORT92_A20_LINE "a20"
+1
stubs/Makefile.objs
··· 1 1 stub-obj-y += blk-commit-all.o 2 + stub-obj-y += cmos.o 2 3 stub-obj-y += cpu-get-clock.o 3 4 stub-obj-y += cpu-get-icount.o 4 5 stub-obj-y += dump.o
+7
stubs/cmos.c
··· 1 + #include "qemu/osdep.h" 2 + #include "hw/i386/pc.h" 3 + 4 + int cmos_get_fd_drive_type(FloppyDriveType fd0) 5 + { 6 + return 0; 7 + }
tests/data/acpi/pc/DSDT

This is a binary file and will not be displayed.

tests/data/acpi/pc/DSDT.acpihmat

This is a binary file and will not be displayed.

tests/data/acpi/pc/DSDT.bridge

This is a binary file and will not be displayed.

tests/data/acpi/pc/DSDT.cphp

This is a binary file and will not be displayed.

tests/data/acpi/pc/DSDT.dimmpxm

This is a binary file and will not be displayed.

tests/data/acpi/pc/DSDT.ipmikcs

This is a binary file and will not be displayed.

tests/data/acpi/pc/DSDT.memhp

This is a binary file and will not be displayed.

tests/data/acpi/pc/DSDT.numamem

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.acpihmat

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.bridge

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.cphp

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.dimmpxm

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.ipmibt

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.memhp

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.mmio64

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.numamem

This is a binary file and will not be displayed.

tests/data/acpi/q35/DSDT.tis

This is a binary file and will not be displayed.

+18
tests/qtest/bios-tables-test-allowed-diff.h
··· 1 1 /* List of comma-separated changed AML files to ignore */ 2 + "tests/data/acpi/pc/DSDT", 3 + "tests/data/acpi/pc/DSDT.acpihmat", 4 + "tests/data/acpi/pc/DSDT.bridge", 5 + "tests/data/acpi/pc/DSDT.cphp", 6 + "tests/data/acpi/pc/DSDT.dimmpxm", 7 + "tests/data/acpi/pc/DSDT.ipmikcs", 8 + "tests/data/acpi/pc/DSDT.memhp", 9 + "tests/data/acpi/pc/DSDT.numamem", 10 + "tests/data/acpi/q35/DSDT", 11 + "tests/data/acpi/q35/DSDT.acpihmat", 12 + "tests/data/acpi/q35/DSDT.bridge", 13 + "tests/data/acpi/q35/DSDT.cphp", 14 + "tests/data/acpi/q35/DSDT.dimmpxm", 15 + "tests/data/acpi/q35/DSDT.ipmibt", 16 + "tests/data/acpi/q35/DSDT.memhp", 17 + "tests/data/acpi/q35/DSDT.mmio64", 18 + "tests/data/acpi/q35/DSDT.numamem", 19 + "tests/data/acpi/q35/DSDT.tis",
+1 -1
tests/qtest/bios-tables-test.c
··· 469 469 fflush(stderr); 470 470 if (getenv("V")) { 471 471 const char *diff_env = getenv("DIFF"); 472 - const char *diff_cmd = diff_env ? diff_env : "diff -u"; 472 + const char *diff_cmd = diff_env ? diff_env : "diff -U 16"; 473 473 char *diff = g_strdup_printf("%s %s %s", diff_cmd, 474 474 exp_sdt->asl_file, sdt->asl_file); 475 475 int out = dup(STDOUT_FILENO);