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

acpi: factor out fw_cfg_add_acpi_dsdt()

Add helper function to add fw_cfg device,
also move code to hw/i386/fw_cfg.c.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20200619091905.21676-8-kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Gerd Hoffmann and committed by
Michael S. Tsirkin
0575c2fd df0f3d13

+30 -23
+1 -23
hw/i386/acpi-build.c
··· 1802 1802 1803 1803 /* create fw_cfg node, unconditionally */ 1804 1804 { 1805 - /* when using port i/o, the 8-bit data register *always* overlaps 1806 - * with half of the 16-bit control register. Hence, the total size 1807 - * of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the 1808 - * DMA control register is located at FW_CFG_DMA_IO_BASE + 4 */ 1809 - uint8_t io_size = object_property_get_bool(OBJECT(x86ms->fw_cfg), 1810 - "dma_enabled", NULL) ? 1811 - ROUND_UP(FW_CFG_CTL_SIZE, 4) + sizeof(dma_addr_t) : 1812 - FW_CFG_CTL_SIZE; 1813 - 1814 1805 scope = aml_scope("\\_SB.PCI0"); 1815 - dev = aml_device("FWCF"); 1816 - 1817 - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); 1818 - 1819 - /* device present, functioning, decoding, not shown in UI */ 1820 - aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); 1821 - 1822 - crs = aml_resource_template(); 1823 - aml_append(crs, 1824 - aml_io(AML_DECODE16, FW_CFG_IO_BASE, FW_CFG_IO_BASE, 0x01, io_size) 1825 - ); 1826 - aml_append(dev, aml_name_decl("_CRS", crs)); 1827 - 1828 - aml_append(scope, dev); 1806 + fw_cfg_add_acpi_dsdt(scope, x86ms->fw_cfg); 1829 1807 aml_append(dsdt, scope); 1830 1808 } 1831 1809
+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