Skip to content

Commit 9a45729

Browse files
committed
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 <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Acked-by: Paolo Bonzini <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Igor Mammedov <[email protected]> Reviewed-by: Paul Durrant <[email protected]> Message-id: [email protected]
1 parent 3235936 commit 9a45729

File tree

7 files changed

+59
-61
lines changed

7 files changed

+59
-61
lines changed

hw/i386/pc.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,45 @@ static void pc_machine_set_pit(Object *obj, bool value, Error **errp)
18571857
pcms->pit_enabled = value;
18581858
}
18591859

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+
18601899
static void pc_machine_initfn(Object *obj)
18611900
{
18621901
PCMachineState *pcms = PC_MACHINE(obj);
@@ -1866,6 +1905,7 @@ static void pc_machine_initfn(Object *obj)
18661905
#else
18671906
pcms->vmport = ON_OFF_AUTO_OFF;
18681907
#endif /* CONFIG_VMPORT */
1908+
pcms->max_ram_below_4g = 0; /* use default */
18691909
/* acpi build is enabled by default if machine supports it */
18701910
pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build;
18711911
pcms->smbus_enabled = true;
@@ -1964,6 +2004,12 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
19642004
mc->numa_mem_supported = true;
19652005
mc->default_ram_id = "pc.ram";
19662006

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)");
2012+
19672013
object_class_property_add(oc, PC_MACHINE_DEVMEM_REGION_SIZE, "int",
19682014
pc_machine_get_device_memory_region_size, NULL,
19692015
NULL, NULL);

hw/i386/pc_piix.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ static void pc_init1(MachineState *machine,
129129
if (xen_enabled()) {
130130
xen_hvm_init(pcms, &ram_memory);
131131
} 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 */
134134
}
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) {
137137
if (pcmc->gigabyte_align) {
138138
if (lowmem > 0xc0000000) {
139139
lowmem = 0xc0000000;
@@ -142,7 +142,7 @@ static void pc_init1(MachineState *machine,
142142
warn_report("Large machine and max_ram_below_4g "
143143
"(%" PRIu64 ") not a multiple of 1G; "
144144
"possible bad performance.",
145-
x86ms->max_ram_below_4g);
145+
pcms->max_ram_below_4g);
146146
}
147147
}
148148
}

hw/i386/pc_q35.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,18 @@ static void pc_q35_init(MachineState *machine)
156156
/* Handle the machine opt max-ram-below-4g. It is basically doing
157157
* min(qemu limit, user limit).
158158
*/
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;
161161
}
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;
164164
if (machine->ram_size - lowmem > lowmem &&
165165
lowmem & (1 * GiB - 1)) {
166166
warn_report("There is possibly poor performance as the ram size "
167167
" (0x%" PRIx64 ") is more then twice the size of"
168168
" max-ram-below-4g (%"PRIu64") and"
169169
" 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);
171171
}
172172
}
173173

hw/i386/x86.c

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -846,45 +846,6 @@ void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
846846
bios);
847847
}
848848

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-
888849
bool x86_machine_is_smm_enabled(X86MachineState *x86ms)
889850
{
890851
bool smm_available = false;
@@ -958,7 +919,6 @@ static void x86_machine_initfn(Object *obj)
958919

959920
x86ms->smm = ON_OFF_AUTO_AUTO;
960921
x86ms->acpi = ON_OFF_AUTO_AUTO;
961-
x86ms->max_ram_below_4g = 0; /* use default */
962922
x86ms->smp_dies = 1;
963923

964924
x86ms->apicid_from_cpu_idx = x86_apicid_from_cpu_idx;
@@ -980,12 +940,6 @@ static void x86_machine_class_init(ObjectClass *oc, void *data)
980940
x86mc->save_tsc_khz = true;
981941
nc->nmi_monitor_handler = x86_nmi;
982942

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-
989943
object_class_property_add(oc, X86_MACHINE_SMM, "OnOffAuto",
990944
x86_machine_get_smm, x86_machine_set_smm,
991945
NULL, NULL);

hw/i386/xen/xen-hvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static void xen_ram_init(PCMachineState *pcms,
205205
ram_addr_t block_len;
206206
uint64_t user_lowmem =
207207
object_property_get_uint(qdev_get_machine(),
208-
X86_MACHINE_MAX_RAM_BELOW_4G,
208+
PC_MACHINE_MAX_RAM_BELOW_4G,
209209
&error_abort);
210210

211211
/* Handle the machine opt max-ram-below-4g. It is basically doing

include/hw/i386/pc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct PCMachineState {
3535
PFlashCFI01 *flash[2];
3636

3737
/* Configuration options: */
38+
uint64_t max_ram_below_4g;
3839
OnOffAuto vmport;
3940

4041
bool acpi_build_enabled;
@@ -51,6 +52,7 @@ struct PCMachineState {
5152
};
5253

5354
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
55+
#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
5456
#define PC_MACHINE_DEVMEM_REGION_SIZE "device-memory-region-size"
5557
#define PC_MACHINE_VMPORT "vmport"
5658
#define PC_MACHINE_SMBUS "smbus"

include/hw/i386/x86.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ typedef struct {
5151
qemu_irq *gsi;
5252
GMappedFile *initrd_mapped_file;
5353

54-
/* Configuration options: */
55-
uint64_t max_ram_below_4g;
56-
5754
/* RAM information (sizes, addresses, configuration): */
5855
ram_addr_t below_4g_mem_size, above_4g_mem_size;
5956

@@ -82,7 +79,6 @@ typedef struct {
8279
AddressSpace *ioapic_as;
8380
} X86MachineState;
8481

85-
#define X86_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
8682
#define X86_MACHINE_SMM "smm"
8783
#define X86_MACHINE_ACPI "acpi"
8884

0 commit comments

Comments
 (0)