* [Qemu-devel] [PATCH v3 1/4] xen-all: Fix xen_hvm_init() to adjust pc memory layout.
2014-03-24 23:55 [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
@ 2014-03-24 23:55 ` Don Slutz
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 2/4] GlobalProperty: Display warning about unused -global Don Slutz
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Don Slutz @ 2014-03-24 23:55 UTC (permalink / raw)
To: xen-devel, qemu-devel, Stefano Stabellini
Cc: Don Slutz, Anthony Liguori, Michael S. Tsirkin
This is just below_4g_mem_size and above_4g_mem_size which is used later in QEMU.
Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
hw/i386/pc_piix.c | 31 ++++++++++++++++---------------
hw/i386/pc_q35.c | 29 +++++++++++++++--------------
include/hw/xen/xen.h | 3 ++-
xen-all.c | 24 ++++++++++++++----------
xen-stub.c | 3 ++-
5 files changed, 49 insertions(+), 41 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7930a26..bd52f6e 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -96,21 +96,6 @@ static void pc_init1(QEMUMachineInitArgs *args,
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(args->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
@@ -127,6 +112,22 @@ static void pc_init1(QEMUMachineInitArgs *args,
below_4g_mem_size = args->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(args->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 c844dc2..6e34fe1 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -83,20 +83,6 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
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(args->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).
@@ -115,6 +101,21 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
below_4g_mem_size = args->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(args->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 9d549fc..0f3942e 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(QEMUMachine *machine);
-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-all.c b/xen-all.c
index ba34739..c64300c 100644
--- a/xen-all.c
+++ b/xen-all.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);
}
}
@@ -1066,7 +1069,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;
@@ -1144,7 +1148,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);
diff --git a/xen-stub.c b/xen-stub.c
index 59927cb..0302dff 100644
--- a/xen-stub.c
+++ b/xen-stub.c
@@ -64,7 +64,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;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v3 2/4] GlobalProperty: Display warning about unused -global
2014-03-24 23:55 [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 1/4] xen-all: Fix xen_hvm_init() to adjust pc memory layout Don Slutz
@ 2014-03-24 23:55 ` Don Slutz
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 3/4] pc & q35: Add new object pc-memory-layout Don Slutz
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Don Slutz @ 2014-03-24 23:55 UTC (permalink / raw)
To: xen-devel, qemu-devel, Stefano Stabellini
Cc: Don Slutz, Anthony Liguori, Michael S. Tsirkin
This can help a user understand why -global was ignored.
For example: with "-vga cirrus"; "-global vga.vgamem_mb=16" is just
ignored when "-global cirrus-vga.vgamem_mb=16" is not.
This is currently clear when the wrong property is provided:
out/x86_64-softmmu/qemu-system-x86_64 -global cirrus-vga.vram_size_mb=16 -monitor pty -vga cirrus
char device redirected to /dev/pts/20 (label compat_monitor0)
qemu-system-x86_64: Property '.vram_size_mb' not found
Aborted (core dumped)
vs
out/x86_64-softmmu/qemu-system-x86_64 -global vga.vram_size_mb=16 -monitor pty -vga cirrus
char device redirected to /dev/pts/20 (label compat_monitor0)
VNC server running on `::1:5900'
^Cqemu: terminating on signal 2
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
hw/core/qdev-properties-system.c | 1 +
hw/core/qdev-properties.c | 15 +++++++++++++++
include/hw/qdev-core.h | 1 +
include/hw/qdev-properties.h | 1 +
vl.c | 2 ++
5 files changed, 20 insertions(+)
diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index de83561..9c742ca 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -444,6 +444,7 @@ static int qdev_add_one_global(QemuOpts *opts, void *opaque)
g->driver = qemu_opt_get(opts, "driver");
g->property = qemu_opt_get(opts, "property");
g->value = qemu_opt_get(opts, "value");
+ g->not_used = true;
qdev_prop_register_global(g);
return 0;
}
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index c67acf5..437c008 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -951,6 +951,20 @@ void qdev_prop_register_global_list(GlobalProperty *props)
}
}
+void qdev_prop_check_global(void)
+{
+ GlobalProperty *prop;
+
+ QTAILQ_FOREACH(prop, &global_props, next) {
+ if (!prop->not_used) {
+ continue;
+ }
+ fprintf(stderr, "Warning: \"-global %s.%s=%s\" not used\n",
+ prop->driver, prop->property, prop->value);
+
+ }
+}
+
void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
Error **errp)
{
@@ -962,6 +976,7 @@ void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
if (strcmp(typename, prop->driver) != 0) {
continue;
}
+ prop->not_used = false;
object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
if (err != NULL) {
error_propagate(errp, err);
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index dbe473c..131fb49 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -235,6 +235,7 @@ typedef struct GlobalProperty {
const char *driver;
const char *property;
const char *value;
+ bool not_used;
QTAILQ_ENTRY(GlobalProperty) next;
} GlobalProperty;
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index c46e908..fbca313 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -180,6 +180,7 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
void qdev_prop_register_global(GlobalProperty *prop);
void qdev_prop_register_global_list(GlobalProperty *props);
+void qdev_prop_check_global(void);
void qdev_prop_set_globals(DeviceState *dev, Error **errp);
void qdev_prop_set_globals_for_type(DeviceState *dev, const char *typename,
Error **errp);
diff --git a/vl.c b/vl.c
index acd97a8..61fac1b 100644
--- a/vl.c
+++ b/vl.c
@@ -4490,6 +4490,8 @@ int main(int argc, char **argv, char **envp)
}
}
+ qdev_prop_check_global();
+
if (incoming) {
Error *local_err = NULL;
qemu_start_incoming_migration(incoming, &local_err);
--
1.8.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v3 3/4] pc & q35: Add new object pc-memory-layout.
2014-03-24 23:55 [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 1/4] xen-all: Fix xen_hvm_init() to adjust pc memory layout Don Slutz
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 2/4] GlobalProperty: Display warning about unused -global Don Slutz
@ 2014-03-24 23:55 ` Don Slutz
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init Don Slutz
2014-03-25 9:08 ` [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Michael S. Tsirkin
4 siblings, 0 replies; 9+ messages in thread
From: Don Slutz @ 2014-03-24 23:55 UTC (permalink / raw)
To: xen-devel, qemu-devel, Stefano Stabellini
Cc: Don Slutz, Anthony Liguori, Michael S. Tsirkin
This new object has the property max-ram-below-4g.
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 adding "-global pc-memory-layout.max-ram-below-4g=2G" to
the command line will limit the amount of ram that is below 4G to
2G.
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
hw/i386/pc.c | 42 ++++++++++++++++++++++++++++++++++++++++++
hw/i386/pc_piix.c | 23 +++++++++++++++++++++--
hw/i386/pc_q35.c | 23 +++++++++++++++++++++--
include/hw/i386/pc.h | 2 ++
4 files changed, 86 insertions(+), 4 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 14f0d91..45339f3 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1429,3 +1429,45 @@ void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name)
gsi_state->ioapic_irq[i] = qdev_get_gpio_in(dev, i);
}
}
+
+/* pc-memory-layout stuff */
+
+typedef struct PcMemoryLayoutState PcMemoryLayoutState;
+
+/**
+ * @PcMemoryLayoutState:
+ */
+struct PcMemoryLayoutState {
+ /*< private >*/
+ Object parent_obj;
+ /*< public >*/
+
+ uint64_t max_ram_below_4g;
+};
+
+static Property pc_memory_layout_props[] = {
+ DEFINE_PROP_SIZE("max-ram-below-4g", PcMemoryLayoutState,
+ max_ram_below_4g, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void pc_memory_layout_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->props = pc_memory_layout_props;
+}
+
+static const TypeInfo pc_memory_layout_info = {
+ .name = TYPE_PC_MEMORY_LAYOUT,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(PcMemoryLayoutState),
+ .class_init = pc_memory_layout_class_init,
+};
+
+static void pc_memory_layout_register_types(void)
+{
+ type_register_static(&pc_memory_layout_info);
+}
+
+type_init(pc_memory_layout_register_types)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index bd52f6e..81d730d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -95,6 +95,23 @@ static void pc_init1(QEMUMachineInitArgs *args,
DeviceState *icc_bridge;
FWCfgState *fw_cfg = NULL;
PcGuestInfo *guest_info;
+ Object *pc_memory_layout;
+ uint64_t max_ram_below_4g;
+ ram_addr_t lowmem = 0xe0000000;
+
+ pc_memory_layout = object_new(TYPE_PC_MEMORY_LAYOUT);
+ max_ram_below_4g = object_property_get_int(pc_memory_layout,
+ "max-ram-below-4g",
+ NULL);
+ if (max_ram_below_4g) {
+ if (max_ram_below_4g > (1ULL << 32)) {
+ fprintf(stderr,
+ "%s: max_ram_below_4g=%lld too big adjusted to %lld\n",
+ __func__, (long long)max_ram_below_4g, 1ULL << 32);
+ max_ram_below_4g = 1ULL << 32;
+ }
+ lowmem = max_ram_below_4g;
+ }
/* 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.
@@ -103,8 +120,10 @@ static void pc_init1(QEMUMachineInitArgs *args,
* For old machine types, use whatever split we used historically to avoid
* breaking migration.
*/
- if (args->ram_size >= 0xe0000000) {
- ram_addr_t lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
+ if (args->ram_size >= lowmem) {
+ if (!max_ram_below_4g && gigabyte_align) {
+ lowmem = 0xc0000000;
+ }
above_4g_mem_size = args->ram_size - lowmem;
below_4g_mem_size = lowmem;
} else {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 6e34fe1..529f53d 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -82,6 +82,23 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
PCIDevice *ahci;
DeviceState *icc_bridge;
PcGuestInfo *guest_info;
+ Object *pc_memory_layout;
+ uint64_t max_ram_below_4g;
+ ram_addr_t lowmem = 0xb0000000;
+
+ pc_memory_layout = object_new(TYPE_PC_MEMORY_LAYOUT);
+ max_ram_below_4g = object_property_get_int(pc_memory_layout,
+ "max-ram-below-4g",
+ NULL);
+ if (max_ram_below_4g) {
+ if (max_ram_below_4g > (1ULL << 32)) {
+ fprintf(stderr,
+ "%s: max_ram_below_4g=%lld too big adjusted to %lld\n",
+ __func__, (long long)max_ram_below_4g, 1ULL << 32);
+ max_ram_below_4g = 1ULL << 32;
+ }
+ lowmem = max_ram_below_4g;
+ }
/* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory
* and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping
@@ -92,8 +109,10 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
* For old machine types, use whatever split we used historically to avoid
* breaking migration.
*/
- if (args->ram_size >= 0xb0000000) {
- ram_addr_t lowmem = gigabyte_align ? 0x80000000 : 0xb0000000;
+ if (args->ram_size >= lowmem) {
+ if (!max_ram_below_4g && gigabyte_align) {
+ lowmem = 0x80000000;
+ }
above_4g_mem_size = args->ram_size - lowmem;
below_4g_mem_size = lowmem;
} else {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 9010246..9162d61 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -163,6 +163,8 @@ void cpu_smm_register(cpu_set_smm_t callback, void *arg);
void ioapic_init_gsi(GSIState *gsi_state, const char *parent_name);
+#define TYPE_PC_MEMORY_LAYOUT "pc-memory-layout"
+
/* acpi_piix.c */
I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
--
1.8.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH v3 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init.
2014-03-24 23:55 [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
` (2 preceding siblings ...)
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 3/4] pc & q35: Add new object pc-memory-layout Don Slutz
@ 2014-03-24 23:55 ` Don Slutz
2014-03-25 11:17 ` Stefano Stabellini
2014-03-25 9:08 ` [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Michael S. Tsirkin
4 siblings, 1 reply; 9+ messages in thread
From: Don Slutz @ 2014-03-24 23:55 UTC (permalink / raw)
To: xen-devel, qemu-devel, Stefano Stabellini
Cc: Don Slutz, Anthony Liguori, Michael S. Tsirkin
This is the xen part of "pc & q35: Add new object pc-memory-layout."
Signed-off-by: Don Slutz <dslutz@verizon.com>
---
v3: Adjust for code readability. Set max_ram_below_4g always and use
it to calculate above_4g_mem_size, below_4g_mem_size.
hw/i386/pc_piix.c | 4 ++--
hw/i386/pc_q35.c | 4 ++--
include/hw/xen/xen.h | 4 ++--
xen-all.c | 40 +++++++++++++++++++++-------------------
xen-stub.c | 4 ++--
5 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 81d730d..8a93548 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -131,8 +131,8 @@ static void pc_init1(QEMUMachineInitArgs *args,
below_4g_mem_size = args->ram_size;
}
- if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
- &ram_memory) != 0) {
+ if (xen_enabled() && xen_hvm_init(max_ram_below_4g, &below_4g_mem_size,
+ &above_4g_mem_size, &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 529f53d..09e98e6 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -120,8 +120,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
below_4g_mem_size = args->ram_size;
}
- if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
- &ram_memory) != 0) {
+ if (xen_enabled() && xen_hvm_init(max_ram_below_4g, &below_4g_mem_size,
+ &above_4g_mem_size, &ram_memory) != 0) {
fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
exit(1);
}
diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
index 0f3942e..eca39a5 100644
--- a/include/hw/xen/xen.h
+++ b/include/hw/xen/xen.h
@@ -40,8 +40,8 @@ int xen_init(QEMUMachine *machine);
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);
+int xen_hvm_init(ram_addr_t max_ram_below_4g, 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-all.c b/xen-all.c
index c64300c..3f6f890 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -155,31 +155,32 @@ qemu_irq *xen_interrupt_controller_init(void)
/* Memory Ops */
-static void xen_ram_init(ram_addr_t *below_4g_mem_size,
+static void xen_ram_init(ram_addr_t ram_size, ram_addr_t max_ram_below_4g,
+ ram_addr_t *below_4g_mem_size,
ram_addr_t *above_4g_mem_size,
- ram_addr_t ram_size, MemoryRegion **ram_memory_p)
+ 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
- */
- block_len += HVM_BELOW_4G_MMIO_LENGTH;
- }
- 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;
+ max_ram_below_4g = max_ram_below_4g ? max_ram_below_4g : HVM_BELOW_4G_RAM_END;
+ if (ram_size >= max_ram_below_4g) {
+ *above_4g_mem_size = ram_size - max_ram_below_4g;
+ *below_4g_mem_size = max_ram_below_4g;
} 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, and keep a hole of
+ * of the size computed above or passed in. */
+ 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);
memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
&ram_memory, 0, 0xa0000);
@@ -1069,8 +1070,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(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
- MemoryRegion **ram_memory)
+int xen_hvm_init(ram_addr_t max_ram_below_4g, ram_addr_t *below_4g_mem_size,
+ ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory)
{
int i, rc;
unsigned long ioreq_pfn;
@@ -1148,7 +1149,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(ram_size, max_ram_below_4g, below_4g_mem_size,
+ above_4g_mem_size, ram_memory);
qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
diff --git a/xen-stub.c b/xen-stub.c
index 0302dff..dd317a5 100644
--- a/xen-stub.c
+++ b/xen-stub.c
@@ -64,8 +64,8 @@ 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)
+int xen_hvm_init(ram_addr_t max_ram_below_4g, ram_addr_t *below_4g_mem_size,
+ ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory)
{
return 0;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init.
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init Don Slutz
@ 2014-03-25 11:17 ` Stefano Stabellini
0 siblings, 0 replies; 9+ messages in thread
From: Stefano Stabellini @ 2014-03-25 11:17 UTC (permalink / raw)
To: Don Slutz
Cc: xen-devel, Michael S. Tsirkin, qemu-devel, Anthony Liguori,
Stefano Stabellini
On Mon, 24 Mar 2014, Don Slutz wrote:
> This is the xen part of "pc & q35: Add new object pc-memory-layout."
>
> Signed-off-by: Don Slutz <dslutz@verizon.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> v3: Adjust for code readability. Set max_ram_below_4g always and use
> it to calculate above_4g_mem_size, below_4g_mem_size.
>
> hw/i386/pc_piix.c | 4 ++--
> hw/i386/pc_q35.c | 4 ++--
> include/hw/xen/xen.h | 4 ++--
> xen-all.c | 40 +++++++++++++++++++++-------------------
> xen-stub.c | 4 ++--
> 5 files changed, 29 insertions(+), 27 deletions(-)
>
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index 81d730d..8a93548 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -131,8 +131,8 @@ static void pc_init1(QEMUMachineInitArgs *args,
> below_4g_mem_size = args->ram_size;
> }
>
> - if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
> - &ram_memory) != 0) {
> + if (xen_enabled() && xen_hvm_init(max_ram_below_4g, &below_4g_mem_size,
> + &above_4g_mem_size, &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 529f53d..09e98e6 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -120,8 +120,8 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
> below_4g_mem_size = args->ram_size;
> }
>
> - if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size,
> - &ram_memory) != 0) {
> + if (xen_enabled() && xen_hvm_init(max_ram_below_4g, &below_4g_mem_size,
> + &above_4g_mem_size, &ram_memory) != 0) {
> fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
> exit(1);
> }
> diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h
> index 0f3942e..eca39a5 100644
> --- a/include/hw/xen/xen.h
> +++ b/include/hw/xen/xen.h
> @@ -40,8 +40,8 @@ int xen_init(QEMUMachine *machine);
> 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);
> +int xen_hvm_init(ram_addr_t max_ram_below_4g, 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-all.c b/xen-all.c
> index c64300c..3f6f890 100644
> --- a/xen-all.c
> +++ b/xen-all.c
> @@ -155,31 +155,32 @@ qemu_irq *xen_interrupt_controller_init(void)
>
> /* Memory Ops */
>
> -static void xen_ram_init(ram_addr_t *below_4g_mem_size,
> +static void xen_ram_init(ram_addr_t ram_size, ram_addr_t max_ram_below_4g,
> + ram_addr_t *below_4g_mem_size,
> ram_addr_t *above_4g_mem_size,
> - ram_addr_t ram_size, MemoryRegion **ram_memory_p)
> + 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
> - */
> - block_len += HVM_BELOW_4G_MMIO_LENGTH;
> - }
> - 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;
> + max_ram_below_4g = max_ram_below_4g ? max_ram_below_4g : HVM_BELOW_4G_RAM_END;
> + if (ram_size >= max_ram_below_4g) {
> + *above_4g_mem_size = ram_size - max_ram_below_4g;
> + *below_4g_mem_size = max_ram_below_4g;
> } 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, and keep a hole of
> + * of the size computed above or passed in. */
> + 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);
>
> memory_region_init_alias(&ram_640k, NULL, "xen.ram.640k",
> &ram_memory, 0, 0xa0000);
> @@ -1069,8 +1070,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(ram_addr_t *below_4g_mem_size, ram_addr_t *above_4g_mem_size,
> - MemoryRegion **ram_memory)
> +int xen_hvm_init(ram_addr_t max_ram_below_4g, ram_addr_t *below_4g_mem_size,
> + ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory)
> {
> int i, rc;
> unsigned long ioreq_pfn;
> @@ -1148,7 +1149,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(ram_size, max_ram_below_4g, below_4g_mem_size,
> + above_4g_mem_size, ram_memory);
>
> qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state);
>
> diff --git a/xen-stub.c b/xen-stub.c
> index 0302dff..dd317a5 100644
> --- a/xen-stub.c
> +++ b/xen-stub.c
> @@ -64,8 +64,8 @@ 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)
> +int xen_hvm_init(ram_addr_t max_ram_below_4g, ram_addr_t *below_4g_mem_size,
> + ram_addr_t *above_4g_mem_size, MemoryRegion **ram_memory)
> {
> return 0;
> }
> --
> 1.8.4
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option)
2014-03-24 23:55 [Qemu-devel] [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
` (3 preceding siblings ...)
2014-03-24 23:55 ` [Qemu-devel] [PATCH v3 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init Don Slutz
@ 2014-03-25 9:08 ` Michael S. Tsirkin
[not found] ` <5351324E.9090603@suse.de>
4 siblings, 1 reply; 9+ messages in thread
From: Michael S. Tsirkin @ 2014-03-25 9:08 UTC (permalink / raw)
To: Don Slutz
Cc: afaerber, xen-devel, qemu-devel, Anthony Liguori,
Stefano Stabellini
On Mon, Mar 24, 2014 at 07:55:32PM -0400, Don Slutz wrote:
> 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 (4):
> xen-all: Fix xen_hvm_init() to adjust pc memory layout.
> GlobalProperty: Display warning about unused -global
> pc & q35: Add new object pc-memory-layout.
> xen-all: Pass max_ram_below_4g to xen_hvm_init.
>
> hw/core/qdev-properties-system.c | 1 +
> hw/core/qdev-properties.c | 15 ++++++++++++
> hw/i386/pc.c | 42 ++++++++++++++++++++++++++++++++
> hw/i386/pc_piix.c | 52 +++++++++++++++++++++++++++-------------
> hw/i386/pc_q35.c | 50 ++++++++++++++++++++++++++------------
> include/hw/i386/pc.h | 2 ++
> include/hw/qdev-core.h | 1 +
> include/hw/qdev-properties.h | 1 +
> include/hw/xen/xen.h | 3 ++-
> vl.c | 2 ++
> xen-all.c | 46 +++++++++++++++++++----------------
> xen-stub.c | 3 ++-
> 12 files changed, 165 insertions(+), 53 deletions(-)
Andreas, could you review pls, esp patch 2?
> --
> 1.8.4
^ permalink raw reply [flat|nested] 9+ messages in thread