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

x86: move max-ram-below-4g to pc

Move from X86MachineClass to PCMachineClass so it disappears
from microvm machine type property list.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Message-id: 20200529073957.8018-4-kraxel@redhat.com

+59 -61
+46
hw/i386/pc.c
··· 1857 1857 pcms->pit_enabled = value; 1858 1858 } 1859 1859 1860 + static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v, 1861 + const char *name, void *opaque, 1862 + Error **errp) 1863 + { 1864 + PCMachineState *pcms = PC_MACHINE(obj); 1865 + uint64_t value = pcms->max_ram_below_4g; 1866 + 1867 + visit_type_size(v, name, &value, errp); 1868 + } 1869 + 1870 + static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, 1871 + const char *name, void *opaque, 1872 + Error **errp) 1873 + { 1874 + PCMachineState *pcms = PC_MACHINE(obj); 1875 + Error *error = NULL; 1876 + uint64_t value; 1877 + 1878 + visit_type_size(v, name, &value, &error); 1879 + if (error) { 1880 + error_propagate(errp, error); 1881 + return; 1882 + } 1883 + if (value > 4 * GiB) { 1884 + error_setg(&error, 1885 + "Machine option 'max-ram-below-4g=%"PRIu64 1886 + "' expects size less than or equal to 4G", value); 1887 + error_propagate(errp, error); 1888 + return; 1889 + } 1890 + 1891 + if (value < 1 * MiB) { 1892 + warn_report("Only %" PRIu64 " bytes of RAM below the 4GiB boundary," 1893 + "BIOS may not work with less than 1MiB", value); 1894 + } 1895 + 1896 + pcms->max_ram_below_4g = value; 1897 + } 1898 + 1860 1899 static void pc_machine_initfn(Object *obj) 1861 1900 { 1862 1901 PCMachineState *pcms = PC_MACHINE(obj); ··· 1866 1905 #else 1867 1906 pcms->vmport = ON_OFF_AUTO_OFF; 1868 1907 #endif /* CONFIG_VMPORT */ 1908 + pcms->max_ram_below_4g = 0; /* use default */ 1869 1909 /* acpi build is enabled by default if machine supports it */ 1870 1910 pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build; 1871 1911 pcms->smbus_enabled = true; ··· 1963 2003 mc->nvdimm_supported = true; 1964 2004 mc->numa_mem_supported = true; 1965 2005 mc->default_ram_id = "pc.ram"; 2006 + 2007 + object_class_property_add(oc, PC_MACHINE_MAX_RAM_BELOW_4G, "size", 2008 + pc_machine_get_max_ram_below_4g, pc_machine_set_max_ram_below_4g, 2009 + NULL, NULL); 2010 + object_class_property_set_description(oc, PC_MACHINE_MAX_RAM_BELOW_4G, 2011 + "Maximum ram below the 4G boundary (32bit boundary)"); 1966 2012 1967 2013 object_class_property_add(oc, PC_MACHINE_DEVMEM_REGION_SIZE, "int", 1968 2014 pc_machine_get_device_memory_region_size, NULL,
+5 -5
hw/i386/pc_piix.c
··· 129 129 if (xen_enabled()) { 130 130 xen_hvm_init(pcms, &ram_memory); 131 131 } else { 132 - if (!x86ms->max_ram_below_4g) { 133 - x86ms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */ 132 + if (!pcms->max_ram_below_4g) { 133 + pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */ 134 134 } 135 - lowmem = x86ms->max_ram_below_4g; 136 - if (machine->ram_size >= x86ms->max_ram_below_4g) { 135 + lowmem = pcms->max_ram_below_4g; 136 + if (machine->ram_size >= pcms->max_ram_below_4g) { 137 137 if (pcmc->gigabyte_align) { 138 138 if (lowmem > 0xc0000000) { 139 139 lowmem = 0xc0000000; ··· 142 142 warn_report("Large machine and max_ram_below_4g " 143 143 "(%" PRIu64 ") not a multiple of 1G; " 144 144 "possible bad performance.", 145 - x86ms->max_ram_below_4g); 145 + pcms->max_ram_below_4g); 146 146 } 147 147 } 148 148 }
+5 -5
hw/i386/pc_q35.c
··· 156 156 /* Handle the machine opt max-ram-below-4g. It is basically doing 157 157 * min(qemu limit, user limit). 158 158 */ 159 - if (!x86ms->max_ram_below_4g) { 160 - x86ms->max_ram_below_4g = 4 * GiB; 159 + if (!pcms->max_ram_below_4g) { 160 + pcms->max_ram_below_4g = 4 * GiB; 161 161 } 162 - if (lowmem > x86ms->max_ram_below_4g) { 163 - lowmem = x86ms->max_ram_below_4g; 162 + if (lowmem > pcms->max_ram_below_4g) { 163 + lowmem = pcms->max_ram_below_4g; 164 164 if (machine->ram_size - lowmem > lowmem && 165 165 lowmem & (1 * GiB - 1)) { 166 166 warn_report("There is possibly poor performance as the ram size " 167 167 " (0x%" PRIx64 ") is more then twice the size of" 168 168 " max-ram-below-4g (%"PRIu64") and" 169 169 " max-ram-below-4g is not a multiple of 1G.", 170 - (uint64_t)machine->ram_size, x86ms->max_ram_below_4g); 170 + (uint64_t)machine->ram_size, pcms->max_ram_below_4g); 171 171 } 172 172 } 173 173
-46
hw/i386/x86.c
··· 846 846 bios); 847 847 } 848 848 849 - static void x86_machine_get_max_ram_below_4g(Object *obj, Visitor *v, 850 - const char *name, void *opaque, 851 - Error **errp) 852 - { 853 - X86MachineState *x86ms = X86_MACHINE(obj); 854 - uint64_t value = x86ms->max_ram_below_4g; 855 - 856 - visit_type_size(v, name, &value, errp); 857 - } 858 - 859 - static void x86_machine_set_max_ram_below_4g(Object *obj, Visitor *v, 860 - const char *name, void *opaque, 861 - Error **errp) 862 - { 863 - X86MachineState *x86ms = X86_MACHINE(obj); 864 - Error *error = NULL; 865 - uint64_t value; 866 - 867 - visit_type_size(v, name, &value, &error); 868 - if (error) { 869 - error_propagate(errp, error); 870 - return; 871 - } 872 - if (value > 4 * GiB) { 873 - error_setg(&error, 874 - "Machine option 'max-ram-below-4g=%"PRIu64 875 - "' expects size less than or equal to 4G", value); 876 - error_propagate(errp, error); 877 - return; 878 - } 879 - 880 - if (value < 1 * MiB) { 881 - warn_report("Only %" PRIu64 " bytes of RAM below the 4GiB boundary," 882 - "BIOS may not work with less than 1MiB", value); 883 - } 884 - 885 - x86ms->max_ram_below_4g = value; 886 - } 887 - 888 849 bool x86_machine_is_smm_enabled(X86MachineState *x86ms) 889 850 { 890 851 bool smm_available = false; ··· 958 919 959 920 x86ms->smm = ON_OFF_AUTO_AUTO; 960 921 x86ms->acpi = ON_OFF_AUTO_AUTO; 961 - x86ms->max_ram_below_4g = 0; /* use default */ 962 922 x86ms->smp_dies = 1; 963 923 964 924 x86ms->apicid_from_cpu_idx = x86_apicid_from_cpu_idx; ··· 979 939 x86mc->compat_apic_id_mode = false; 980 940 x86mc->save_tsc_khz = true; 981 941 nc->nmi_monitor_handler = x86_nmi; 982 - 983 - object_class_property_add(oc, X86_MACHINE_MAX_RAM_BELOW_4G, "size", 984 - x86_machine_get_max_ram_below_4g, x86_machine_set_max_ram_below_4g, 985 - NULL, NULL); 986 - object_class_property_set_description(oc, X86_MACHINE_MAX_RAM_BELOW_4G, 987 - "Maximum ram below the 4G boundary (32bit boundary)"); 988 942 989 943 object_class_property_add(oc, X86_MACHINE_SMM, "OnOffAuto", 990 944 x86_machine_get_smm, x86_machine_set_smm,
+1 -1
hw/i386/xen/xen-hvm.c
··· 205 205 ram_addr_t block_len; 206 206 uint64_t user_lowmem = 207 207 object_property_get_uint(qdev_get_machine(), 208 - X86_MACHINE_MAX_RAM_BELOW_4G, 208 + PC_MACHINE_MAX_RAM_BELOW_4G, 209 209 &error_abort); 210 210 211 211 /* Handle the machine opt max-ram-below-4g. It is basically doing
+2
include/hw/i386/pc.h
··· 35 35 PFlashCFI01 *flash[2]; 36 36 37 37 /* Configuration options: */ 38 + uint64_t max_ram_below_4g; 38 39 OnOffAuto vmport; 39 40 40 41 bool acpi_build_enabled; ··· 51 52 }; 52 53 53 54 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" 55 + #define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" 54 56 #define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size" 55 57 #define PC_MACHINE_VMPORT "vmport" 56 58 #define PC_MACHINE_SMBUS "smbus"
-4
include/hw/i386/x86.h
··· 51 51 qemu_irq *gsi; 52 52 GMappedFile *initrd_mapped_file; 53 53 54 - /* Configuration options: */ 55 - uint64_t max_ram_below_4g; 56 - 57 54 /* RAM information (sizes, addresses, configuration): */ 58 55 ram_addr_t below_4g_mem_size, above_4g_mem_size; 59 56 ··· 82 79 AddressSpace *ioapic_as; 83 80 } X86MachineState; 84 81 85 - #define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g" 86 82 #define X86_MACHINE_SMM "smm" 87 83 #define X86_MACHINE_ACPI "acpi" 88 84