* [Qemu-devel] [PATCH v6 1/3] xen-hvm: Fix xen_hvm_init() to adjust pc memory layout
2014-06-17 18:32 [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
@ 2014-06-17 18:32 ` Don Slutz
2014-06-17 18:32 ` [Qemu-devel] [PATCH v6 2/3] pc & q35: Add new machine opt max-ram-below-4g Don Slutz
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Don Slutz @ 2014-06-17 18:32 UTC (permalink / raw)
To: xen-devel, qemu-devel, Stefano Stabellini
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Don Slutz, Anthony Liguori,
Igor Mammedov, Andreas Färber
This is just below_4g_mem_size and above_4g_mem_size which is used later in QEMU.
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
v6:
No change
v5:
No change
v4:
Switch Acked-by & Signed-off-by
rebase on master
v3:
Add Acked-by: Stefano Stabellini
v2:
No change
hw/i386/pc_piix.c | 31 ++++++++++++++++---------------
hw/i386/pc_q35.c | 29 +++++++++++++++--------------
include/hw/xen/xen.h | 3 ++-
xen-hvm-stub.c | 3 ++-
xen-hvm.c | 24 ++++++++++++++----------
5 files changed, 49 insertions(+), 41 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 3e7524b..60057f9 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -99,21 +99,6 @@ static void pc_init1(MachineState *machine,
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
- if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) {
- fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
- exit(1);
- }
-
- icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
- object_property_add_child(qdev_get_machine(), "icc-bridge",
- OBJECT(icc_bridge), NULL);
-
- pc_cpus_init(machine->cpu_model, icc_bridge);
-
- if (kvm_enabled() && kvmclock_enabled) {
- kvmclock_create();
- }
-
/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
* If it doesn't, we need to split it in chunks below and above 4G.
* In any case, try to make sure that guest addresses aligned at
@@ -130,6 +115,22 @@ static void pc_init1(MachineState *machine,
below_4g_mem_size = machine->ram_size;
}
+ if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
+ &ram_memory) != 0) {
+ fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
+ exit(1);
+ }
+
+ icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
+ object_property_add_child(qdev_get_machine(), "icc-bridge",
+ OBJECT(icc_bridge), NULL);
+
+ pc_cpus_init(machine->cpu_model, icc_bridge);
+
+ if (kvm_enabled() && kvmclock_enabled) {
+ kvmclock_create();
+ }
+
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index aa71332..2cb743c 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -86,20 +86,6 @@ static void pc_q35_init(MachineState *machine)
DeviceState *icc_bridge;
PcGuestInfo *guest_info;
- if (xen_enabled() && xen_hvm_init(&ram_memory) != 0) {
- fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
- exit(1);
- }
-
- icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
- object_property_add_child(qdev_get_machine(), "icc-bridge",
- OBJECT(icc_bridge), NULL);
-
- pc_cpus_init(machine->cpu_model, icc_bridge);
- pc_acpi_init("q35-acpi-dsdt.aml");
-
- kvmclock_create();
-
/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory
* and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping
* also known as MMCFG).
@@ -118,6 +104,21 @@ static void pc_q35_init(MachineState *machine)
below_4g_mem_size = machine->ram_size;
}
+ if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
+ &ram_memory) != 0) {
+ fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
+ exit(1);
+ }
+
+ icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
+ object_property_add_child(qdev_get_machine(), "icc-bridge",
+ OBJECT(icc_bridge), NULL);
+
+ pc_cpus_init(machine->cpu_model, icc_bridge);
+ pc_acpi_init("q35-acpi-dsdt.aml");
+
+ kvmclock_create();
+
/* pci enabled */
if (pci_enabled) {
pci_memory = g_new(MemoryRegion, 1);
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 85fda3d..f71f2d8 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -37,10 +37,11 @@ void xen_cmos_set_s3_resume(void *opaque, int irq, int level);
qemu_irq *xen_interrupt_controller_init(void);
int xen_init(MachineClass *mc);
-int xen_hvm_init(MemoryRegion **ram_memory);
void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
#if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
+int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
+ MemoryRegion **ram_memory);
void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
struct MemoryRegion *mr);
void xen_modified_memory(ram_addr_t start, ram_addr_t length);
diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c
index 4eb27b5..2d98696 100644
--- a/xen-hvm-stub.c
+++ b/xen-hvm-stub.c
@@ -51,7 +51,8 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length)
{
}
-int xen_hvm_init(MemoryRegion **ram_memory)
+int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
+ MemoryRegion **ram_memory)
{
return 0;
}
diff --git a/xen-hvm.c b/xen-hvm.c
index a64486c..a0b6b5d 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -155,10 +155,11 @@ qemu_irq *xen_interrupt_controller_init(void)
/* Memory Ops */
-static void xen_ram_init(ram_addr_t ram_size, MemoryRegion **ram_memory_p)
+static void xen_ram_init(ram_addr_t *below_4g_mem_size,
+ ram_addr_t *above_4g_mem_size,
+ ram_addr_t ram_size, MemoryRegion **ram_memory_p)
{
MemoryRegion *sysmem = get_system_memory();
- ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
ram_addr_t block_len;
block_len = ram_size;
@@ -173,10 +174,11 @@ static void xen_ram_init(ram_addr_t ram_size, MemoryRegion **ram_memory_p)
vmstate_register_ram_global(&ram_memory);
if (ram_size >= HVM_BELOW_4G_RAM_END) {
- above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
- below_4g_mem_size = HVM_BELOW_4G_RAM_END;
+ *above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
+ *below_4g_mem_size = HVM_BELOW_4G_RAM_END;
} else {
- below_4g_mem_size = ram_size;
+ *above_4g_mem_size = 0;
+ *below_4g_mem_size = ram_size;
}
memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
@@ -189,12 +191,13 @@ static void xen_ram_init(ram_addr_t ram_size, MemoryRegion **ram_memory_p)
* the Options ROM, so it is registered here as RAM.
*/
memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo",
- &ram_memory, 0xc0000, below_4g_mem_size - 0xc0000);
+ &ram_memory, 0xc0000,
+ *below_4g_mem_size - 0xc0000);
memory_region_add_subregion(sysmem, 0xc0000, &ram_lo);
- if (above_4g_mem_size > 0) {
+ if (*above_4g_mem_size > 0) {
memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi",
&ram_memory, 0x100000000ULL,
- above_4g_mem_size);
+ *above_4g_mem_size);
memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi);
}
}
@@ -958,7 +961,8 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0);
}
-int xen_hvm_init(MemoryRegion **ram_memory)
+int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
+ MemoryRegion **ram_memory)
{
int i, rc;
unsigned long ioreq_pfn;
@@ -1036,7 +1040,7 @@ int xen_hvm_init(MemoryRegion **ram_memory)
/* Init RAM management */
xen_map_cache_init(xen_phys_offset_to_gaddr, state);
- xen_ram_init(ram_size, ram_memory);
+ xen_ram_init(below_4g_mem_size, above_4g_mem_size, ram_size, ram_memory);
qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
--
1.8.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v6 2/3] pc & q35: Add new machine opt max-ram-below-4g
2014-06-17 18:32 [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
2014-06-17 18:32 ` [Qemu-devel] [PATCH v6 1/3] xen-hvm: Fix xen_hvm_init() to adjust pc memory layout Don Slutz
@ 2014-06-17 18:32 ` Don Slutz
2014-06-17 18:32 ` [Qemu-devel] [PATCH v6 3/3] xen-hvm: Pass is_default to xen_hvm_init Don Slutz
2014-06-17 18:41 ` [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Michael S. Tsirkin
3 siblings, 0 replies; 8+ messages in thread
From: Don Slutz @ 2014-06-17 18:32 UTC (permalink / raw)
To: xen-devel, qemu-devel, Stefano Stabellini
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Don Slutz, Anthony Liguori,
Igor Mammedov, Andreas Färber
This is a pc & q35 only machine opt.
Remove gigabyte_align (now handled by .default_machine_opts).
Add warning about BIOS.
One use is to allow for more ram in a 32bit guest for example:
-machine pc,max-ram-below-4g=3.75G
If you add enough PCI devices then all mmio for them will not fit
below 4G which may not be the layout the user wanted. This allows
you to increase the below 4G address space that PCI devices can use
(aka decrease ram below 4G) and therefore in more cases not have any
mmio that is above 4G.
For example using "-machine pc,max-ram-below-4g=2G" on the command
line will limit the amount of ram that is below 4G to 2G.
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
v6:
Added setting of .default_machine_opts to include max-ram-below-4g
for all pc types.
Removed gigabyte_align
Added warning on small value.
"less then" to "less than"
v5:
Re-work based on:
https://github.com/imammedo/qemu/commits/memory-hotplug-v11
hw/i386/pc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
hw/i386/pc_piix.c | 46 ++++++++++++++++++++++++++++++++--------------
hw/i386/pc_q35.c | 45 +++++++++++++++++++++++++++++++--------------
include/hw/i386/pc.h | 3 +++
vl.c | 4 ++++
5 files changed, 114 insertions(+), 28 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e993b0f..a7f4f17 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1647,11 +1647,55 @@ pc_machine_get_hotplug_memory_region_size(Object *obj, Visitor *v, void *opaque,
visit_type_int(v, &value, name, errp);
}
+static void pc_machine_get_max_ram_below_4g(Object *obj, Visitor *v,
+ void *opaque, const char *name,
+ Error **errp)
+{
+ PCMachineState *pcms = PC_MACHINE(obj);
+ uint64_t value = pcms->max_ram_below_4g;
+
+ visit_type_size(v, &value, name, errp);
+}
+
+static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
+ void *opaque, const char *name,
+ Error **errp)
+{
+ PCMachineState *pcms = PC_MACHINE(obj);
+ Error *error = NULL;
+ uint64_t value;
+
+ visit_type_size(v, &value, name, &error);
+ if (error) {
+ error_propagate(errp, error);
+ return;
+ }
+ if (value > (1ULL << 32)) {
+ error_set(&error, ERROR_CLASS_GENERIC_ERROR,
+ "Machine option 'max-ram-below-4g=%"PRIu64
+ "' expects size less than or equal to 4G", value);
+ error_propagate(errp, error);
+ return;
+ }
+
+ if (value > 0 && value < (1ULL << 20)) {
+ error_report("Warning: small max_ram_below_4g(%"PRIu64
+ ") less than 1M. BIOS may not work..",
+ value);
+ }
+
+ pcms->max_ram_below_4g = value;
+}
+
static void pc_machine_initfn(Object *obj)
{
object_property_add(obj, PC_MACHINE_MEMHP_REGION_SIZE, "int",
pc_machine_get_hotplug_memory_region_size,
NULL, NULL, NULL, NULL);
+ object_property_add(obj, PC_MACHINE_MAX_RAM_BELOW_4G, "size",
+ pc_machine_get_max_ram_below_4g,
+ pc_machine_set_max_ram_below_4g,
+ NULL, NULL, NULL);
}
static void pc_machine_class_init(ObjectClass *oc, void *data)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 60057f9..200c225 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -48,6 +48,7 @@
#include "exec/address-spaces.h"
#include "hw/acpi/acpi.h"
#include "cpu.h"
+#include "qemu/error-report.h"
#ifdef CONFIG_XEN
# include <xen/hvm/hvm_info_table.h>
#endif
@@ -62,11 +63,6 @@ static bool has_pci_info;
static bool has_acpi_build = true;
static bool smbios_defaults = true;
static bool smbios_legacy_mode;
-/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
- * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
- * pages in the host.
- */
-static bool gigabyte_align = true;
static bool has_reserved_memory = true;
/* PC hardware initialisation */
@@ -99,6 +95,19 @@ static void pc_init1(MachineState *machine,
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
+ /* Make sure that 2.0 guest addresses aligned at 1Gbyte
+ * boundaries get mapped to host addresses aligned at 1Gbyte
+ * boundaries. This way we can use 1GByte pages in the host.
+ */
+
+ if (pc_machine->max_ram_below_4g == 0) {
+ if (machine->ram_size >= 0xe0000000) {
+ pc_machine->max_ram_below_4g = 0xc0000000;
+ } else {
+ pc_machine->max_ram_below_4g = 0xe0000000;
+ }
+ }
+
/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
* If it doesn't, we need to split it in chunks below and above 4G.
* In any case, try to make sure that guest addresses aligned at
@@ -106,10 +115,15 @@ static void pc_init1(MachineState *machine,
* For old machine types, use whatever split we used historically to avoid
* breaking migration.
*/
- if (machine->ram_size >= 0xe0000000) {
- ram_addr_t lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
- above_4g_mem_size = machine->ram_size - lowmem;
- below_4g_mem_size = lowmem;
+ if (machine->ram_size >= pc_machine->max_ram_below_4g) {
+ above_4g_mem_size = machine->ram_size - pc_machine->max_ram_below_4g;
+ below_4g_mem_size = pc_machine->max_ram_below_4g;
+ if (pc_machine->max_ram_below_4g && above_4g_mem_size > below_4g_mem_size &&
+ pc_machine->max_ram_below_4g & ((1ULL << 30) - 1)) {
+ error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
+ ") not a multiple of 1G; possible bad performance.",
+ pc_machine->max_ram_below_4g);
+ }
} else {
above_4g_mem_size = 0;
below_4g_mem_size = machine->ram_size;
@@ -285,7 +299,6 @@ static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
smbios_defaults = false;
- gigabyte_align = false;
option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
@@ -411,7 +424,7 @@ static void pc_xen_hvm_init(MachineState *machine)
#define PC_I440FX_2_1_MACHINE_OPTIONS \
PC_I440FX_MACHINE_OPTIONS, \
- .default_machine_opts = "firmware=bios-256k.bin"
+ .default_machine_opts = "firmware=bios-256k.bin,max-ram-below-4g=3G"
static QEMUMachine pc_i440fx_machine_v2_1 = {
PC_I440FX_2_1_MACHINE_OPTIONS,
@@ -421,7 +434,9 @@ static QEMUMachine pc_i440fx_machine_v2_1 = {
.is_default = 1,
};
-#define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
+#define PC_I440FX_2_0_MACHINE_OPTIONS \
+ PC_I440FX_MACHINE_OPTIONS, \
+ .default_machine_opts = "firmware=bios-256k.bin,max-ram-below-4g=0"
static QEMUMachine pc_i440fx_machine_v2_0 = {
PC_I440FX_2_0_MACHINE_OPTIONS,
@@ -433,7 +448,9 @@ static QEMUMachine pc_i440fx_machine_v2_0 = {
},
};
-#define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
+#define PC_I440FX_1_7_MACHINE_OPTIONS \
+ PC_I440FX_MACHINE_OPTIONS, \
+ .default_machine_opts = "max-ram-below-4g=3.5G"
static QEMUMachine pc_i440fx_machine_v1_7 = {
PC_I440FX_1_7_MACHINE_OPTIONS,
@@ -445,7 +462,7 @@ static QEMUMachine pc_i440fx_machine_v1_7 = {
},
};
-#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
+#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_1_7_MACHINE_OPTIONS
static QEMUMachine pc_i440fx_machine_v1_6 = {
PC_I440FX_1_6_MACHINE_OPTIONS,
@@ -821,6 +838,7 @@ static QEMUMachine pc_machine_v0_10 = {
static QEMUMachine isapc_machine = {
PC_COMMON_MACHINE_OPTIONS,
+ .default_machine_opts = "max-ram-below-4g=3.5G",
.name = "isapc",
.desc = "ISA-only PC",
.init = pc_init_isa,
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 2cb743c..43365cb 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -44,6 +44,7 @@
#include "hw/ide/ahci.h"
#include "hw/usb.h"
#include "hw/cpu/icc_bus.h"
+#include "qemu/error-report.h"
/* ICH9 AHCI has 6 ports */
#define MAX_SATA_PORTS 6
@@ -52,11 +53,6 @@ static bool has_pci_info;
static bool has_acpi_build = true;
static bool smbios_defaults = true;
static bool smbios_legacy_mode;
-/* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
- * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte
- * pages in the host.
- */
-static bool gigabyte_align = true;
static bool has_reserved_memory = true;
/* PC hardware initialisation */
@@ -86,6 +82,19 @@ static void pc_q35_init(MachineState *machine)
DeviceState *icc_bridge;
PcGuestInfo *guest_info;
+ /* Make sure that 2.0 guest addresses aligned at 1Gbyte
+ * boundaries get mapped to host addresses aligned at 1Gbyte
+ * boundaries. This way we can use 1GByte pages in the host.
+ */
+
+ if (pc_machine->max_ram_below_4g == 0) {
+ if (machine->ram_size >= 0xb0000000) {
+ pc_machine->max_ram_below_4g = 0x80000000;
+ } else {
+ pc_machine->max_ram_below_4g = 0xb0000000;
+ }
+ }
+
/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory
* and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping
* also known as MMCFG).
@@ -95,10 +104,15 @@ static void pc_q35_init(MachineState *machine)
* For old machine types, use whatever split we used historically to avoid
* breaking migration.
*/
- if (machine->ram_size >= 0xb0000000) {
- ram_addr_t lowmem = gigabyte_align ? 0x80000000 : 0xb0000000;
- above_4g_mem_size = machine->ram_size - lowmem;
- below_4g_mem_size = lowmem;
+ if (machine->ram_size >= pc_machine->max_ram_below_4g) {
+ above_4g_mem_size = machine->ram_size - pc_machine->max_ram_below_4g;
+ below_4g_mem_size = pc_machine->max_ram_below_4g;
+ if (pc_machine->max_ram_below_4g && above_4g_mem_size > below_4g_mem_size &&
+ pc_machine->max_ram_below_4g & ((1ULL << 30) - 1)) {
+ error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
+ ") not a multiple of 1G; possible bad performance.",
+ pc_machine->max_ram_below_4g);
+ }
} else {
above_4g_mem_size = 0;
below_4g_mem_size = machine->ram_size;
@@ -263,7 +277,6 @@ static void pc_compat_1_7(MachineState *machine)
{
pc_compat_2_0(machine);
smbios_defaults = false;
- gigabyte_align = false;
option_rom_has_mr = true;
x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
}
@@ -325,7 +338,7 @@ static void pc_q35_init_1_4(MachineState *machine)
#define PC_Q35_2_1_MACHINE_OPTIONS \
PC_Q35_MACHINE_OPTIONS, \
- .default_machine_opts = "firmware=bios-256k.bin"
+ .default_machine_opts = "firmware=bios-256k.bin,max-ram-below-4g=2G"
static QEMUMachine pc_q35_machine_v2_1 = {
PC_Q35_2_1_MACHINE_OPTIONS,
@@ -334,7 +347,9 @@ static QEMUMachine pc_q35_machine_v2_1 = {
.init = pc_q35_init,
};
-#define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS
+#define PC_Q35_2_0_MACHINE_OPTIONS \
+ PC_Q35_MACHINE_OPTIONS, \
+ .default_machine_opts = "firmware=bios-256k.bin,max-ram-below-4g=0"
static QEMUMachine pc_q35_machine_v2_0 = {
PC_Q35_2_0_MACHINE_OPTIONS,
@@ -346,7 +361,9 @@ static QEMUMachine pc_q35_machine_v2_0 = {
},
};
-#define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
+#define PC_Q35_1_7_MACHINE_OPTIONS \
+ PC_Q35_MACHINE_OPTIONS, \
+ .default_machine_opts = "max-ram-below-4g=2.75G"
static QEMUMachine pc_q35_machine_v1_7 = {
PC_Q35_1_7_MACHINE_OPTIONS,
@@ -358,7 +375,7 @@ static QEMUMachine pc_q35_machine_v1_7 = {
},
};
-#define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS
+#define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_1_7_MACHINE_OPTIONS
static QEMUMachine pc_q35_machine_v1_6 = {
PC_Q35_1_6_MACHINE_OPTIONS,
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 76d4c6e..f5672ee 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -33,10 +33,13 @@ struct PCMachineState {
MemoryRegion hotplug_memory;
HotplugHandler *acpi_dev;
+
+ uint64_t max_ram_below_4g;
};
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
#define PC_MACHINE_MEMHP_REGION_SIZE "hotplug-memory-region-size"
+#define PC_MACHINE_MAX_RAM_BELOW_4G "max-ram-below-4g"
/**
* PCMachineClass:
diff --git a/vl.c b/vl.c
index 1617013..27c60eb 100644
--- a/vl.c
+++ b/vl.c
@@ -381,6 +381,10 @@ static QemuOptsList qemu_machine_opts = {
.name = "kvm-type",
.type = QEMU_OPT_STRING,
.help = "Specifies the KVM virtualization mode (HV, PR)",
+ },{
+ .name = PC_MACHINE_MAX_RAM_BELOW_4G,
+ .type = QEMU_OPT_SIZE,
+ .help = "maximum ram below the 4G boundary (32bit boundary)",
},
{ /* End of list */ }
},
--
1.8.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v6 3/3] xen-hvm: Pass is_default to xen_hvm_init
2014-06-17 18:32 [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
2014-06-17 18:32 ` [Qemu-devel] [PATCH v6 1/3] xen-hvm: Fix xen_hvm_init() to adjust pc memory layout Don Slutz
2014-06-17 18:32 ` [Qemu-devel] [PATCH v6 2/3] pc & q35: Add new machine opt max-ram-below-4g Don Slutz
@ 2014-06-17 18:32 ` Don Slutz
2014-06-17 18:54 ` Michael S. Tsirkin
2014-06-17 18:41 ` [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Michael S. Tsirkin
3 siblings, 1 reply; 8+ messages in thread
From: Don Slutz @ 2014-06-17 18:32 UTC (permalink / raw)
To: xen-devel, qemu-devel, Stefano Stabellini
Cc: Marcel Apfelbaum, Michael S. Tsirkin, Don Slutz, Anthony Liguori,
Igor Mammedov, Andreas Färber
This is the xen part of "pc & q35: Add new machine opt max-ram-below-4g"
This is done by adding a counter to know how many times
pc_machine_set_max_ram_below_4g() is called. Therefore xen can know
if a non-default setting is requested.
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
v6:
Changed to work with the changes in #2:
Added max_ram_below_4g_changed in order to know if it is a default value
or a user specified one.
Added "assert(pc_machine->max_ram_below_4g_changed > 0)" so that
"make check" will abort on default not set for any of the pc or
q35 machine types.
Dropped "Acked-by: Stefano Stabellin" do to bigger change.
hw/i386/pc.c | 1 +
hw/i386/pc_piix.c | 2 ++
hw/i386/pc_q35.c | 2 ++
include/hw/i386/pc.h | 1 +
include/hw/xen/xen.h | 2 +-
xen-hvm-stub.c | 2 +-
xen-hvm.c | 36 ++++++++++++++++++++----------------
7 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index a7f4f17..fc7e211 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1685,6 +1685,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
}
pcms->max_ram_below_4g = value;
+ pcms->max_ram_below_4g_changed++;
}
static void pc_machine_initfn(Object *obj)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 200c225..6072aec 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -129,7 +129,9 @@ static void pc_init1(MachineState *machine,
below_4g_mem_size = machine->ram_size;
}
+ assert(pc_machine->max_ram_below_4g_changed > 0);
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
+ pc_machine->max_ram_below_4g_changed == 1,
&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 43365cb..9386e44 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -118,7 +118,9 @@ static void pc_q35_init(MachineState *machine)
below_4g_mem_size = machine->ram_size;
}
+ assert(pc_machine->max_ram_below_4g_changed > 0);
if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
+ pc_machine->max_ram_below_4g_changed == 1,
&ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index f5672ee..34e488a 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -35,6 +35,7 @@ struct PCMachineState {
HotplugHandler *acpi_dev;
uint64_t max_ram_below_4g;
+ uint32_t max_ram_below_4g_changed;
};
#define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index f71f2d8..6b94c14 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -41,7 +41,7 @@ void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
#if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
- MemoryRegion **ram_memory);
+ bool is_default, MemoryRegion **ram_memory);
void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
struct MemoryRegion *mr);
void xen_modified_memory(ram_addr_t start, ram_addr_t length);
diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c
index 2d98696..d1bdb76 100644
--- a/xen-hvm-stub.c
+++ b/xen-hvm-stub.c
@@ -52,7 +52,7 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length)
}
int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
- MemoryRegion **ram_memory)
+ bool is_default, MemoryRegion **ram_memory)
{
return 0;
}
diff --git a/xen-hvm.c b/xen-hvm.c
index a0b6b5d..fba2c92 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -156,31 +156,34 @@ qemu_irq *xen_interrupt_controller_init(void)
/* Memory Ops */
static void xen_ram_init(ram_addr_t *below_4g_mem_size,
- ram_addr_t *above_4g_mem_size,
+ ram_addr_t *above_4g_mem_size, bool is_default,
ram_addr_t ram_size, MemoryRegion **ram_memory_p)
{
MemoryRegion *sysmem = get_system_memory();
ram_addr_t block_len;
- block_len = ram_size;
- if (ram_size >= HVM_BELOW_4G_RAM_END) {
- /* Xen does not allocate the memory continuously, and keep a hole at
- * HVM_BELOW_4G_MMIO_START of HVM_BELOW_4G_MMIO_LENGTH
+ if (is_default) {
+ if (ram_size >= HVM_BELOW_4G_RAM_END) {
+ *above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
+ *below_4g_mem_size = HVM_BELOW_4G_RAM_END;
+ } else {
+ *above_4g_mem_size = 0;
+ *below_4g_mem_size = ram_size;
+ }
+ }
+ if (!*above_4g_mem_size) {
+ block_len = ram_size;
+ } else {
+ /*
+ * Xen does not allocate the memory continuously, it keeps a
+ * hole of the size computed above or passed in.
*/
- block_len += HVM_BELOW_4G_MMIO_LENGTH;
+ block_len = (1ULL << 32) + *above_4g_mem_size;
}
memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len);
*ram_memory_p = &ram_memory;
vmstate_register_ram_global(&ram_memory);
- if (ram_size >= HVM_BELOW_4G_RAM_END) {
- *above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
- *below_4g_mem_size = HVM_BELOW_4G_RAM_END;
- } else {
- *above_4g_mem_size = 0;
- *below_4g_mem_size = ram_size;
- }
-
memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
&ram_memory, 0, 0xa0000);
memory_region_add_subregion(sysmem, 0, &ram_640k);
@@ -962,7 +965,7 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
}
int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
- MemoryRegion **ram_memory)
+ bool is_default, MemoryRegion **ram_memory)
{
int i, rc;
unsigned long ioreq_pfn;
@@ -1040,7 +1043,8 @@ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
/* Init RAM management */
xen_map_cache_init(xen_phys_offset_to_gaddr, state);
- xen_ram_init(below_4g_mem_size, above_4g_mem_size, ram_size, ram_memory);
+ xen_ram_init(below_4g_mem_size, above_4g_mem_size, is_default, ram_size,
+ ram_memory);
qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
--
1.8.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v6 3/3] xen-hvm: Pass is_default to xen_hvm_init
2014-06-17 18:32 ` [Qemu-devel] [PATCH v6 3/3] xen-hvm: Pass is_default to xen_hvm_init Don Slutz
@ 2014-06-17 18:54 ` Michael S. Tsirkin
0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2014-06-17 18:54 UTC (permalink / raw)
To: Don Slutz
Cc: xen-devel, Stefano Stabellini, Marcel Apfelbaum, qemu-devel,
Anthony Liguori, Igor Mammedov, Andreas Färber
On Tue, Jun 17, 2014 at 02:32:10PM -0400, Don Slutz wrote:
> This is the xen part of "pc & q35: Add new machine opt max-ram-below-4g"
>
> This is done by adding a counter to know how many times
> pc_machine_set_max_ram_below_4g() is called. Therefore xen can know
> if a non-default setting is requested.
>
> Signed-off-by: Don Slutz <dslutz@verizon.com>
> ---
> v6:
> Changed to work with the changes in #2:
> Added max_ram_below_4g_changed in order to know if it is a default value
> or a user specified one.
If you are special casing the default you might set it
to 0 just as well.
Sorry about not being clear, but what me and others were saying is that
we prefer an API should that there's no need for special-casing
user-specified values.
This approach isn't any better, it's just moving hacks around.
Of the two use-cases that you supplied, increasing RAM
below 4g and decreasing RAM below 4g, which do you
really care about?
If you really want a way to limit low RAM to 2g, then
how about this: set max_ram_below_4g_changed to 4g, and
apply the current limits *on top*.
So if user sets limit to 3.99 one still gets 3.5 or whatever.
But if you set it to 2G then you get 2G.
> Added "assert(pc_machine->max_ram_below_4g_changed > 0)" so that
> "make check" will abort on default not set for any of the pc or
> q35 machine types.
> Dropped "Acked-by: Stefano Stabellin" do to bigger change.
>
> hw/i386/pc.c | 1 +
> hw/i386/pc_piix.c | 2 ++
> hw/i386/pc_q35.c | 2 ++
> include/hw/i386/pc.h | 1 +
> include/hw/xen/xen.h | 2 +-
> xen-hvm-stub.c | 2 +-
> xen-hvm.c | 36 ++++++++++++++++++++----------------
> 7 files changed, 28 insertions(+), 18 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index a7f4f17..fc7e211 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1685,6 +1685,7 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v,
> }
>
> pcms->max_ram_below_4g = value;
> + pcms->max_ram_below_4g_changed++;
> }
>
> static void pc_machine_initfn(Object *obj)
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 200c225..6072aec 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -129,7 +129,9 @@ static void pc_init1(MachineState *machine,
> below_4g_mem_size = machine->ram_size;
> }
>
> + assert(pc_machine->max_ram_below_4g_changed > 0);
> if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
> + pc_machine->max_ram_below_4g_changed == 1,
> &ram_memory) != 0) {
> fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
> exit(1);
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 43365cb..9386e44 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -118,7 +118,9 @@ static void pc_q35_init(MachineState *machine)
> below_4g_mem_size = machine->ram_size;
> }
>
> + assert(pc_machine->max_ram_below_4g_changed > 0);
> if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
> + pc_machine->max_ram_below_4g_changed == 1,
> &ram_memory) != 0) {
> fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
> exit(1);
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index f5672ee..34e488a 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -35,6 +35,7 @@ struct PCMachineState {
> HotplugHandler *acpi_dev;
>
> uint64_t max_ram_below_4g;
> + uint32_t max_ram_below_4g_changed;
> };
>
> #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
> diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
> index f71f2d8..6b94c14 100644
> --- a/include/hw/xen/xen.h
> +++ b/include/hw/xen/xen.h
> @@ -41,7 +41,7 @@ void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
>
> #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
> int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
> - MemoryRegion **ram_memory);
> + bool is_default, MemoryRegion **ram_memory);
> void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size,
> struct MemoryRegion *mr);
> void xen_modified_memory(ram_addr_t start, ram_addr_t length);
> diff --git a/xen-hvm-stub.c b/xen-hvm-stub.c
> index 2d98696..d1bdb76 100644
> --- a/xen-hvm-stub.c
> +++ b/xen-hvm-stub.c
> @@ -52,7 +52,7 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length)
> }
>
> int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
> - MemoryRegion **ram_memory)
> + bool is_default, MemoryRegion **ram_memory)
> {
> return 0;
> }
> diff --git a/xen-hvm.c b/xen-hvm.c
> index a0b6b5d..fba2c92 100644
> --- a/xen-hvm.c
> +++ b/xen-hvm.c
> @@ -156,31 +156,34 @@ qemu_irq *xen_interrupt_controller_init(void)
> /* Memory Ops */
>
> static void xen_ram_init(ram_addr_t *below_4g_mem_size,
> - ram_addr_t *above_4g_mem_size,
> + ram_addr_t *above_4g_mem_size, bool is_default,
> ram_addr_t ram_size, MemoryRegion **ram_memory_p)
> {
> MemoryRegion *sysmem = get_system_memory();
> ram_addr_t block_len;
>
> - block_len = ram_size;
> - if (ram_size >= HVM_BELOW_4G_RAM_END) {
> - /* Xen does not allocate the memory continuously, and keep a hole at
> - * HVM_BELOW_4G_MMIO_START of HVM_BELOW_4G_MMIO_LENGTH
> + if (is_default) {
> + if (ram_size >= HVM_BELOW_4G_RAM_END) {
> + *above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
> + *below_4g_mem_size = HVM_BELOW_4G_RAM_END;
> + } else {
> + *above_4g_mem_size = 0;
> + *below_4g_mem_size = ram_size;
> + }
> + }
> + if (!*above_4g_mem_size) {
> + block_len = ram_size;
> + } else {
> + /*
> + * Xen does not allocate the memory continuously, it keeps a
> + * hole of the size computed above or passed in.
> */
> - block_len += HVM_BELOW_4G_MMIO_LENGTH;
> + block_len = (1ULL << 32) + *above_4g_mem_size;
> }
> memory_region_init_ram(&ram_memory, NULL, "xen.ram", block_len);
> *ram_memory_p = &ram_memory;
> vmstate_register_ram_global(&ram_memory);
>
> - if (ram_size >= HVM_BELOW_4G_RAM_END) {
> - *above_4g_mem_size = ram_size - HVM_BELOW_4G_RAM_END;
> - *below_4g_mem_size = HVM_BELOW_4G_RAM_END;
> - } else {
> - *above_4g_mem_size = 0;
> - *below_4g_mem_size = ram_size;
> - }
> -
> memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
> &ram_memory, 0, 0xa0000);
> memory_region_add_subregion(sysmem, 0, &ram_640k);
> @@ -962,7 +965,7 @@ static void xen_wakeup_notifier(Notifier *notifier, void *data)
> }
>
> int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
> - MemoryRegion **ram_memory)
> + bool is_default, MemoryRegion **ram_memory)
> {
> int i, rc;
> unsigned long ioreq_pfn;
> @@ -1040,7 +1043,8 @@ int xen_hvm_init(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
>
> /* Init RAM management */
> xen_map_cache_init(xen_phys_offset_to_gaddr, state);
> - xen_ram_init(below_4g_mem_size, above_4g_mem_size, ram_size, ram_memory);
> + xen_ram_init(below_4g_mem_size, above_4g_mem_size, is_default, ram_size,
> + ram_memory);
>
> qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
>
> --
> 1.8.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option)
2014-06-17 18:32 [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
` (2 preceding siblings ...)
2014-06-17 18:32 ` [Qemu-devel] [PATCH v6 3/3] xen-hvm: Pass is_default to xen_hvm_init Don Slutz
@ 2014-06-17 18:41 ` Michael S. Tsirkin
2014-06-17 18:53 ` Don Slutz
3 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2014-06-17 18:41 UTC (permalink / raw)
To: Don Slutz
Cc: xen-devel, Stefano Stabellini, Marcel Apfelbaum, qemu-devel,
Anthony Liguori, Igor Mammedov, Andreas Färber
On Tue, Jun 17, 2014 at 02:32:07PM -0400, Don Slutz wrote:
> Changes v5 to v6:
> rebased on git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git pci
>
> Changed default handling. Most pc machines are now set to 3.5G
> (0xe0000000) and q35 are set to 2.75G (0xb0000000). The special
> value of 0 is used to flag the complex gigabyte_align memory
> layout selection.
>
> I did change the default for pc-i440fx-2.1 to 3G and pc-q35-2.1 to
> 2G instead of the complex gigabyte_align. This looks ok to me
> because the statement by Gerd Hoffmann is about more ram for 32
> bit (+non-PAE) guests can now have more then the defualt by
> specifing the new option like "max-ram-below-4g=3.75G" or
> "max-ram-below-4g=3.9375G". Or if that is too complex to
> understand just select pc-i440fx-2.0 or pc-q35-2.0 to get what
> they use to get.
I don't think it's OK.
The beauty of Gerd's hack is that it does the right thing
for 32 bit guests without any need for tweaks.
I.e. most users get good performance.
By comparison this setting seems easier to get wrong than right.
And we definitely don't want to push people to use 2.0
compat setting unless they need bug for bug compatible hardware.
Generally, I'm still confused about this feature.
It seems to be about helping 32 bit non PAE guests, is that right?
But if that's the case why use >4G memory?
> Michael S. Tsirkin, Igor Mammedov, Marcel Apfelbaum:
> #2 "pc & q35: Add new machine opt max-ram-below-4g":
> Added setting of .default_machine_opts to include max-ram-below-4g
> for all pc types.
> Removed gigabyte_align.
> Added warning on small value.
> "less then" to "less than"
>
> #3 "xen-hvm: Pass is_default to xen_hvm_init":
> Changed to work with the changes in #2:
> Added max_ram_below_4g_changed in order to know if it is a default value
> or a user specified one.
> Added "assert(pc_machine->max_ram_below_4g_changed > 0)" so that
> "make check" will abort on default not set for any of the pc or
> q35 machine types.
> Dropped "Acked-by: Stefano Stabellin" do to bigger change.
>
>
> Changes v4 to v5:
> Re-work based on:
>
> https://github.com/imammedo/qemu/commits/memory-hotplug-v11
>
> And so it now depends on this patch set.
>
> Stefano Stabellini:
> #3 "xen-hvm: Pass is_default to xen_hvm_init"
> Acked-by
> Minor change of pmc to pcms.
>
> Changes v3 to v4:
> Split out #2 "GlobalProperty: Display warning about unused -global"
> rebase on e00fcfe (origin/master)
> rename xen-all to xen-hvm
>
> Adjust #1 "xen-hvm: Fix xen_hvm_init() to adjust pc memory layout"
> Switch Acked-by & Signed-off-by
> rebase on master
>
> Rework #3 "xen-hvm: Pass is_default to xen_hvm_init":
> To pass is_default instead of max_ram_below_4g.
> Also did not add "Acked-by: Stefano Stabellini" since code changed a lot.
>
> Andreas Färber:
> all: Remove dot at end of subject
> #3 "xen-hvm: Pass is_default to xen_hvm_init"
> Adjust comment formatting.
>
> Andreas Färber, Paolo Bonzini, Marcel Apfelbaum:
> rework to use "opts per machine"
> Drop old #3, new #2.
>
>
> Changes v2 to v3:
> Stefano Stabellini:
> Acked-by #1 "xen-all: Fix xen_hvm_init() to adjust pc memory"
> Adjust for code readability #4 "xen-all: Pass max_ram_below_4g to xen_hvm_init."
> Set max_ram_below_4g always and use it to calculate above_4g_mem_size,
> below_4g_mem_size.
>
> Changes v1 to v2:
> Michael S. Tsirkin:
> Rename option.
> Only add it to machine types that support it.
> Split into 4 parts.
>
> 1/4 -- xen-all: Fix xen_hvm_init() to adjust pc memory layout
>
> This looks to be a possible bug that has yet to be found.
> below_4g_mem_size and above_4g_mem_size are stored in PcGuestInfo
> (pc_guest_info_init) which are currently not "correct". This and
> 4/4 change the same lines.
>
> 2/4 -- GlobalProperty: Display warning about unused -global
>
> My testing showed that setting a global property on an object
> that is not used is not reported at all. This is added to help
> when the new global is set but not used. The negative not_used
> was picked so that all static objects are assumed to be used
> even when they are not.
>
> 3/4 -- pc & q35: Add new object pc-memory-layout
>
> The objects that it might make sense to add this property to all
> get created too late. So add a new object just to hold this
> property. Name it so that it is expected that only pc (and q35)
> machine types support it.
>
> 4/4 -- xen-all: Pass max_ram_below_4g to xen_hvm_init
>
> Seprate the xen only part of the change. Currectly based on patch 1/4
>
> Don Slutz (3):
> xen-hvm: Fix xen_hvm_init() to adjust pc memory layout
> pc & q35: Add new machine opt max-ram-below-4g
> xen-hvm: Pass is_default to xen_hvm_init
>
> hw/i386/pc.c | 45 ++++++++++++++++++++++++++++++++
> hw/i386/pc_piix.c | 73 +++++++++++++++++++++++++++++++++-------------------
> hw/i386/pc_q35.c | 72 ++++++++++++++++++++++++++++++++-------------------
> include/hw/i386/pc.h | 4 +++
> include/hw/xen/xen.h | 3 ++-
> vl.c | 4 +++
> xen-hvm-stub.c | 3 ++-
> xen-hvm.c | 46 +++++++++++++++++++--------------
> 8 files changed, 177 insertions(+), 73 deletions(-)
>
> --
> 1.8.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option)
2014-06-17 18:41 ` [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Michael S. Tsirkin
@ 2014-06-17 18:53 ` Don Slutz
2014-06-17 19:00 ` Michael S. Tsirkin
0 siblings, 1 reply; 8+ messages in thread
From: Don Slutz @ 2014-06-17 18:53 UTC (permalink / raw)
To: Michael S. Tsirkin, Don Slutz
Cc: xen-devel, Stefano Stabellini, Marcel Apfelbaum, qemu-devel,
Anthony Liguori, Igor Mammedov, Andreas Färber
On 06/17/14 14:41, Michael S. Tsirkin wrote:
> On Tue, Jun 17, 2014 at 02:32:07PM -0400, Don Slutz wrote:
>> Changes v5 to v6:
>> rebased on git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git pci
>>
>> Changed default handling. Most pc machines are now set to 3.5G
>> (0xe0000000) and q35 are set to 2.75G (0xb0000000). The special
>> value of 0 is used to flag the complex gigabyte_align memory
>> layout selection.
>>
>> I did change the default for pc-i440fx-2.1 to 3G and pc-q35-2.1 to
>> 2G instead of the complex gigabyte_align. This looks ok to me
>> because the statement by Gerd Hoffmann is about more ram for 32
>> bit (+non-PAE) guests can now have more then the defualt by
>> specifing the new option like "max-ram-below-4g=3.75G" or
>> "max-ram-below-4g=3.9375G". Or if that is too complex to
>> understand just select pc-i440fx-2.0 or pc-q35-2.0 to get what
>> they use to get.
> I don't think it's OK.
>
> The beauty of Gerd's hack is that it does the right thing
> for 32 bit guests without any need for tweaks.
> I.e. most users get good performance.
>
> By comparison this setting seems easier to get wrong than right.
>
> And we definitely don't want to push people to use 2.0
> compat setting unless they need bug for bug compatible hardware.
Ok. Will switch back on a v7.
> Generally, I'm still confused about this feature.
> It seems to be about helping 32 bit non PAE guests, is that right?
No. That is just part of it.
> But if that's the case why use >4G memory?
>
I know of a use case where the guest code (custom OS) wants 1G below
4G and 3G above 4G. And 1G below and 7G above. They want a big MMIO
space for many PCI cards but also still gigabyte aligned.
It seems to me to be better to add the machine option (that is more flexible)
then 4 new pc machine types that have this memory layout.
-Don Slutz
>> Michael S. Tsirkin, Igor Mammedov, Marcel Apfelbaum:
>> #2 "pc & q35: Add new machine opt max-ram-below-4g":
>> Added setting of .default_machine_opts to include max-ram-below-4g
>> for all pc types.
>> Removed gigabyte_align.
>> Added warning on small value.
>> "less then" to "less than"
>>
>> #3 "xen-hvm: Pass is_default to xen_hvm_init":
>> Changed to work with the changes in #2:
>> Added max_ram_below_4g_changed in order to know if it is a default value
>> or a user specified one.
>> Added "assert(pc_machine->max_ram_below_4g_changed > 0)" so that
>> "make check" will abort on default not set for any of the pc or
>> q35 machine types.
>> Dropped "Acked-by: Stefano Stabellin" do to bigger change.
>>
>>
>> Changes v4 to v5:
>> Re-work based on:
>>
>> https://github.com/imammedo/qemu/commits/memory-hotplug-v11
>>
>> And so it now depends on this patch set.
>>
>> Stefano Stabellini:
>> #3 "xen-hvm: Pass is_default to xen_hvm_init"
>> Acked-by
>> Minor change of pmc to pcms.
>>
>> Changes v3 to v4:
>> Split out #2 "GlobalProperty: Display warning about unused -global"
>> rebase on e00fcfe (origin/master)
>> rename xen-all to xen-hvm
>>
>> Adjust #1 "xen-hvm: Fix xen_hvm_init() to adjust pc memory layout"
>> Switch Acked-by & Signed-off-by
>> rebase on master
>>
>> Rework #3 "xen-hvm: Pass is_default to xen_hvm_init":
>> To pass is_default instead of max_ram_below_4g.
>> Also did not add "Acked-by: Stefano Stabellini" since code changed a lot.
>>
>> Andreas Färber:
>> all: Remove dot at end of subject
>> #3 "xen-hvm: Pass is_default to xen_hvm_init"
>> Adjust comment formatting.
>>
>> Andreas Färber, Paolo Bonzini, Marcel Apfelbaum:
>> rework to use "opts per machine"
>> Drop old #3, new #2.
>>
>>
>> Changes v2 to v3:
>> Stefano Stabellini:
>> Acked-by #1 "xen-all: Fix xen_hvm_init() to adjust pc memory"
>> Adjust for code readability #4 "xen-all: Pass max_ram_below_4g to xen_hvm_init."
>> Set max_ram_below_4g always and use it to calculate above_4g_mem_size,
>> below_4g_mem_size.
>>
>> Changes v1 to v2:
>> Michael S. Tsirkin:
>> Rename option.
>> Only add it to machine types that support it.
>> Split into 4 parts.
>>
>> 1/4 -- xen-all: Fix xen_hvm_init() to adjust pc memory layout
>>
>> This looks to be a possible bug that has yet to be found.
>> below_4g_mem_size and above_4g_mem_size are stored in PcGuestInfo
>> (pc_guest_info_init) which are currently not "correct". This and
>> 4/4 change the same lines.
>>
>> 2/4 -- GlobalProperty: Display warning about unused -global
>>
>> My testing showed that setting a global property on an object
>> that is not used is not reported at all. This is added to help
>> when the new global is set but not used. The negative not_used
>> was picked so that all static objects are assumed to be used
>> even when they are not.
>>
>> 3/4 -- pc & q35: Add new object pc-memory-layout
>>
>> The objects that it might make sense to add this property to all
>> get created too late. So add a new object just to hold this
>> property. Name it so that it is expected that only pc (and q35)
>> machine types support it.
>>
>> 4/4 -- xen-all: Pass max_ram_below_4g to xen_hvm_init
>>
>> Seprate the xen only part of the change. Currectly based on patch 1/4
>>
>> Don Slutz (3):
>> xen-hvm: Fix xen_hvm_init() to adjust pc memory layout
>> pc & q35: Add new machine opt max-ram-below-4g
>> xen-hvm: Pass is_default to xen_hvm_init
>>
>> hw/i386/pc.c | 45 ++++++++++++++++++++++++++++++++
>> hw/i386/pc_piix.c | 73 +++++++++++++++++++++++++++++++++-------------------
>> hw/i386/pc_q35.c | 72 ++++++++++++++++++++++++++++++++-------------------
>> include/hw/i386/pc.h | 4 +++
>> include/hw/xen/xen.h | 3 ++-
>> vl.c | 4 +++
>> xen-hvm-stub.c | 3 ++-
>> xen-hvm.c | 46 +++++++++++++++++++--------------
>> 8 files changed, 177 insertions(+), 73 deletions(-)
>>
>> --
>> 1.8.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH v6 0/3] Add max-ram-below-4g (was Add pci_hole_min_size machine option)
2014-06-17 18:53 ` Don Slutz
@ 2014-06-17 19:00 ` Michael S. Tsirkin
0 siblings, 0 replies; 8+ messages in thread
From: Michael S. Tsirkin @ 2014-06-17 19:00 UTC (permalink / raw)
To: Don Slutz
Cc: xen-devel, Stefano Stabellini, Marcel Apfelbaum, qemu-devel,
Anthony Liguori, Igor Mammedov, Andreas Färber
On Tue, Jun 17, 2014 at 02:53:21PM -0400, Don Slutz wrote:
> On 06/17/14 14:41, Michael S. Tsirkin wrote:
> >On Tue, Jun 17, 2014 at 02:32:07PM -0400, Don Slutz wrote:
> >>Changes v5 to v6:
> >> rebased on git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git pci
> >>
> >> Changed default handling. Most pc machines are now set to 3.5G
> >> (0xe0000000) and q35 are set to 2.75G (0xb0000000). The special
> >> value of 0 is used to flag the complex gigabyte_align memory
> >> layout selection.
> >>
> >> I did change the default for pc-i440fx-2.1 to 3G and pc-q35-2.1 to
> >> 2G instead of the complex gigabyte_align. This looks ok to me
> >> because the statement by Gerd Hoffmann is about more ram for 32
> >> bit (+non-PAE) guests can now have more then the defualt by
> >> specifing the new option like "max-ram-below-4g=3.75G" or
> >> "max-ram-below-4g=3.9375G". Or if that is too complex to
> >> understand just select pc-i440fx-2.0 or pc-q35-2.0 to get what
> >> they use to get.
> >I don't think it's OK.
> >
> >The beauty of Gerd's hack is that it does the right thing
> >for 32 bit guests without any need for tweaks.
> >I.e. most users get good performance.
> >
> >By comparison this setting seems easier to get wrong than right.
> >
> >And we definitely don't want to push people to use 2.0
> >compat setting unless they need bug for bug compatible hardware.
>
> Ok. Will switch back on a v7.
>
> >Generally, I'm still confused about this feature.
> >It seems to be about helping 32 bit non PAE guests, is that right?
>
> No. That is just part of it.
>
> >But if that's the case why use >4G memory?
> >
>
> I know of a use case where the guest code (custom OS) wants 1G below
> 4G and 3G above 4G. And 1G below and 7G above. They want a big MMIO
> space for many PCI cards but also still gigabyte aligned.
Why not use 64 bit BARs on cards?
Many cards we emulate don't support them but
that's historical: before 57271d63c4d93352406704d540453c43a4a241a7 we
didn't emulate 64 bit addresses correctly (and that was because before
b35ba30f8fa235c779d876ee299b80a2d501d204 it was too expensive).
>
> It seems to me to be better to add the machine option (that is more flexible)
> then 4 new pc machine types that have this memory layout.
>
> -Don Slutz
Assuming we want this (motivation for which I didn't yet get
completely), I think the right thing to do would not be to
let user specify the layout exactly, instead
let user specify a limit on low memory.
Use that together with other limits we calculate.
Default would be 4g -> no limit.
> >> Michael S. Tsirkin, Igor Mammedov, Marcel Apfelbaum:
> >> #2 "pc & q35: Add new machine opt max-ram-below-4g":
> >> Added setting of .default_machine_opts to include max-ram-below-4g
> >> for all pc types.
> >> Removed gigabyte_align.
> >> Added warning on small value.
> >> "less then" to "less than"
> >>
> >> #3 "xen-hvm: Pass is_default to xen_hvm_init":
> >> Changed to work with the changes in #2:
> >> Added max_ram_below_4g_changed in order to know if it is a default value
> >> or a user specified one.
> >> Added "assert(pc_machine->max_ram_below_4g_changed > 0)" so that
> >> "make check" will abort on default not set for any of the pc or
> >> q35 machine types.
> >> Dropped "Acked-by: Stefano Stabellin" do to bigger change.
> >>
> >>
> >>Changes v4 to v5:
> >> Re-work based on:
> >>
> >> https://github.com/imammedo/qemu/commits/memory-hotplug-v11
> >>
> >> And so it now depends on this patch set.
> >>
> >> Stefano Stabellini:
> >> #3 "xen-hvm: Pass is_default to xen_hvm_init"
> >> Acked-by
> >> Minor change of pmc to pcms.
> >>
> >>Changes v3 to v4:
> >> Split out #2 "GlobalProperty: Display warning about unused -global"
> >> rebase on e00fcfe (origin/master)
> >> rename xen-all to xen-hvm
> >>
> >> Adjust #1 "xen-hvm: Fix xen_hvm_init() to adjust pc memory layout"
> >> Switch Acked-by & Signed-off-by
> >> rebase on master
> >>
> >> Rework #3 "xen-hvm: Pass is_default to xen_hvm_init":
> >> To pass is_default instead of max_ram_below_4g.
> >> Also did not add "Acked-by: Stefano Stabellini" since code changed a lot.
> >>
> >> Andreas Färber:
> >> all: Remove dot at end of subject
> >> #3 "xen-hvm: Pass is_default to xen_hvm_init"
> >> Adjust comment formatting.
> >>
> >> Andreas Färber, Paolo Bonzini, Marcel Apfelbaum:
> >> rework to use "opts per machine"
> >> Drop old #3, new #2.
> >>
> >>Changes v2 to v3:
> >> Stefano Stabellini:
> >> Acked-by #1 "xen-all: Fix xen_hvm_init() to adjust pc memory"
> >> Adjust for code readability #4 "xen-all: Pass max_ram_below_4g to xen_hvm_init."
> >> Set max_ram_below_4g always and use it to calculate above_4g_mem_size,
> >> below_4g_mem_size.
> >>
> >>Changes v1 to v2:
> >> Michael S. Tsirkin:
> >> Rename option.
> >> Only add it to machine types that support it.
> >> Split into 4 parts.
> >>
> >>1/4 -- xen-all: Fix xen_hvm_init() to adjust pc memory layout
> >>
> >> This looks to be a possible bug that has yet to be found.
> >> below_4g_mem_size and above_4g_mem_size are stored in PcGuestInfo
> >> (pc_guest_info_init) which are currently not "correct". This and
> >> 4/4 change the same lines.
> >>
> >>2/4 -- GlobalProperty: Display warning about unused -global
> >>
> >> My testing showed that setting a global property on an object
> >> that is not used is not reported at all. This is added to help
> >> when the new global is set but not used. The negative not_used
> >> was picked so that all static objects are assumed to be used
> >> even when they are not.
> >>
> >>3/4 -- pc & q35: Add new object pc-memory-layout
> >>
> >> The objects that it might make sense to add this property to all
> >> get created too late. So add a new object just to hold this
> >> property. Name it so that it is expected that only pc (and q35)
> >> machine types support it.
> >>
> >>4/4 -- xen-all: Pass max_ram_below_4g to xen_hvm_init
> >>
> >> Seprate the xen only part of the change. Currectly based on patch 1/4
> >>
> >>Don Slutz (3):
> >> xen-hvm: Fix xen_hvm_init() to adjust pc memory layout
> >> pc & q35: Add new machine opt max-ram-below-4g
> >> xen-hvm: Pass is_default to xen_hvm_init
> >>
> >> hw/i386/pc.c | 45 ++++++++++++++++++++++++++++++++
> >> hw/i386/pc_piix.c | 73 +++++++++++++++++++++++++++++++++-------------------
> >> hw/i386/pc_q35.c | 72 ++++++++++++++++++++++++++++++++-------------------
> >> include/hw/i386/pc.h | 4 +++
> >> include/hw/xen/xen.h | 3 ++-
> >> vl.c | 4 +++
> >> xen-hvm-stub.c | 3 ++-
> >> xen-hvm.c | 46 +++++++++++++++++++--------------
> >> 8 files changed, 177 insertions(+), 73 deletions(-)
> >>
> >>--
> >>1.8.4
^ permalink raw reply [flat|nested] 8+ messages in thread