From: "Andreas Färber" <afaerber@suse.de>
To: Don Slutz <dslutz@verizon.com>
Cc: xen-devel@lists.xensource.com,
Eduardo Habkost <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
qemu-devel@nongnu.org, Anthony Liguori <aliguori@amazon.com>,
Igor Mammedov <imammedo@redhat.com>
Subject: Re: [PATCH v3 3/4] pc & q35: Add new object pc-memory-layout.
Date: Fri, 18 Apr 2014 17:45:50 +0200 [thread overview]
Message-ID: <535148AE.9030500@suse.de> (raw)
In-Reply-To: <1395705336-22528-4-git-send-email-dslutz@verizon.com>
Am 25.03.2014 00:55, schrieb Don Slutz:
> 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?
> +
> +/**
> + * @PcMemoryLayoutState:
Please drop @.
> + */
> +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) {
Isn't this always zero due to the default value?
> + 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);
Is this forgotten debug output? For a user, __func__ is not helpful and
error_report() would be preferable. Also please just use PRIx64 for
max_ram_below_4g rather than casting.
> + 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 {
We don't have central, recursive realization of devices yet. That means
your device is instantiated but never realized, and while you're not
exposing any global state it allows to tweak the property value
throughout device lifetime.
Also you're forgetting to add this device to the composition tree via
object_property_add_child(). Neither ACPI code nor future QOM code can
discover it that way.
> 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 {
Dito here for all pc_piix.c comments.
> 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,
Regards,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2014-04-18 15:45 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 23:55 [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Don Slutz
2014-03-24 23:55 ` [PATCH v3 1/4] xen-all: Fix xen_hvm_init() to adjust pc memory layout Don Slutz
2014-04-18 14:23 ` Andreas Färber
2014-04-22 16:29 ` Don Slutz
2014-03-24 23:55 ` [PATCH v3 2/4] GlobalProperty: Display warning about unused -global Don Slutz
2014-04-18 15:21 ` Andreas Färber
2014-04-18 15:36 ` [Xen-devel] " Fabio Fantoni
2014-04-18 15:59 ` Andreas Färber
2014-04-18 16:54 ` Fabio Fantoni
2014-04-19 10:56 ` Fabio Fantoni
2014-04-22 18:44 ` Don Slutz
2014-04-19 20:54 ` Paolo Bonzini
2014-04-22 23:13 ` Don Slutz
2014-04-23 0:28 ` Paolo Bonzini
2014-04-23 12:58 ` Don Slutz
2014-04-23 13:33 ` Andreas Färber
2014-04-22 20:23 ` Don Slutz
2014-04-23 0:28 ` Paolo Bonzini
2014-04-23 13:25 ` Don Slutz
2014-03-24 23:55 ` [PATCH v3 3/4] pc & q35: Add new object pc-memory-layout Don Slutz
2014-04-18 15:45 ` Andreas Färber [this message]
2014-04-22 23:54 ` Don Slutz
2014-04-21 12:27 ` Paolo Bonzini
2014-04-23 0:13 ` Don Slutz
2014-04-23 3:27 ` Paolo Bonzini
2014-04-23 6:51 ` Marcel Apfelbaum
2014-03-24 23:55 ` [PATCH v3 4/4] xen-all: Pass max_ram_below_4g to xen_hvm_init Don Slutz
2014-03-25 11:17 ` Stefano Stabellini
2014-04-18 16:19 ` Andreas Färber
2014-04-22 18:27 ` Don Slutz
2014-03-25 9:08 ` [PATCH v3 0/4] Add max-ram-below-4g (was Add pci_hole_min_size machine option) Michael S. Tsirkin
2014-04-17 18:27 ` PING " Don Slutz
2014-04-18 14:10 ` Andreas Färber
2014-04-22 16:31 ` Don Slutz
2014-05-05 8:12 ` [Qemu-devel] " Michael S. Tsirkin
2014-05-05 16:16 ` Don Slutz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=535148AE.9030500@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=dslutz@verizon.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).