Skip to contentSkip to conversation

memory hotplug fixups when building with clang

PATCH In review Igor Mammedov 2 participants 8 messages Jun 16, 2014 – Jun 17, 2014

lore
Share & tools
lore
#0 lore raw

cover memory hotplug fixups when building with clang

fixes build errors and warnings introduced by
memory hotplug series when building with clang

Igor Mammedov (4):
pc: acpi: do not hardcode preprocessor fixup! pc: initialize memory hotplug address space fixup! pc: add memory hotplug handler to PC_MACHINE fixup! pc: implement pc-dimm device abstraction

 hw/i386/Makefile.objs    |    2 +-
 hw/i386/pc.c             |    6 +++---
 include/hw/mem/pc-dimm.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
#1 lore raw

PATCH 1/4 pc: acpi: do not hardcode preprocessor

but use one provided by environment, in addition
force C style preprocessing so that 'gcc -E' or
"clang -E" wouldn't ignore .dsl files.

---
 hw/i386/Makefile.objs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/i386/Makefile.objs +1 -1
index a65473c..48014ab 100644
@@ -18,7 +18,7 @@ iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
 ifdef IASL
 #IASL Present. Generate hex files from .dsl
 hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
-	$(call quiet-command, cpp -P $(QEMU_DGFLAGS) $(QEMU_INCLUDES) $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
+	$(call quiet-command, $(CPP) -x c -P $(QEMU_DGFLAGS) $(QEMU_INCLUDES) $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
 	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
 	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
 	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/4 fixup! pc: initialize memory hotplug address space

In reply to Igor Mammedov
---
 hw/i386/pc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/i386/pc.c +1 -1
index 37344ce..73daa07 100644
@@ -1261,7 +1261,7 @@ FWCfgState *pc_memory_init(MachineState *machine,
 
         if ((pcms->hotplug_memory_base + hotplug_mem_size) <
             hotplug_mem_size) {
-            error_report("unsupported amount of maximum memory: %"PRIu64,
+            error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT,
                          machine->maxram_size);
             exit(EXIT_FAILURE);
         }
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/4 fixup! pc: add memory hotplug handler to PC_MACHINE

In reply to Igor Mammedov
---
 hw/i386/pc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc.c +2 -2
index 73daa07..e993b0f 100644
@@ -1564,8 +1564,8 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     PCDIMMDevice *dimm = PC_DIMM(dev);
     PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
     MemoryRegion *mr = ddc->get_memory_region(dimm);
-    ram_addr_t addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,
-                                              &local_err);
+    uint64_t addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,
+                                            &local_err);
     if (local_err) {
         goto out;
     }
Signature · 1 line
1.7.1
#4 lore raw

Re: [Qemu-devel] [PATCH 3/4] fixup! pc: add memory hotplug handler to PC_MACHINE

Quoted 1 line · Igor Mammedov

Note that properties are all int64.
I think we need a new kind of "RAM offset" property that verifies that the supplied value is a valid
ram offset.

Quoted 21 lines
---
 hw/i386/pc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/i386/pc.c +2 -2
index 73daa07..e993b0f 100644
@@ -1564,8 +1564,8 @@ static void pc_dimm_plug(HotplugHandler *hotplug_dev,
     PCDIMMDevice *dimm = PC_DIMM(dev);
     PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
     MemoryRegion *mr = ddc->get_memory_region(dimm);
-    ram_addr_t addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,
-                                              &local_err);
+    uint64_t addr = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP,
+                                            &local_err);
     if (local_err) {
         goto out;
     }
Signature · 1 line
1.7.1
#5 lore raw

PATCH 4/4 fixup! pc: implement pc-dimm device abstraction

In reply to Igor Mammedov

fix typecheck error in DEFINE_PROP_UINT64 when building with with clang, on OS X ram_addr_t is uintptr_t with size 8 bytes but compiler still refuses to accept type_check() macro as valid.

It's still fixing consequences of how ram_addr_t is defined but it's safer this way than to change ram_addr_t to uint64_t unconditionally last minute.

TODO:
is to fix ram_addr_t on 32-bit host so that it could represent 64-bit guest addresses which is broken now if --disable-xen configure option was used.

---
 include/hw/mem/pc-dimm.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/hw/mem/pc-dimm.h +1 -1
index 5f80d14..0f4a6ba 100644
@@ -52,7 +52,7 @@ typedef struct PCDIMMDevice {
     DeviceState parent_obj;
 
     /* public */
-    ram_addr_t addr;
+    uint64_t addr;
     uint32_t node;
     int32_t slot;
     HostMemoryBackend *hostmem;
Signature · 1 line
1.7.1
#6 lore raw

Re: [Qemu-devel] [PATCH 4/4] fixup! pc: implement pc-dimm device abstraction

Quoted 23 lines · Igor Mammedov

fix typecheck error in DEFINE_PROP_UINT64 when building with with clang, on OS X ram_addr_t is uintptr_t with size 8 bytes but compiler still refuses to accept type_check() macro as valid.

It's still fixing consequences of how ram_addr_t is defined but it's safer this way than to change ram_addr_t to uint64_t unconditionally last minute.

TODO:
is to fix ram_addr_t on 32-bit host so that it could represent 64-bit guest addresses which is broken now if --disable-xen configure option was used.

---
 include/hw/mem/pc-dimm.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/hw/mem/pc-dimm.h +0 -0
index 5f80d14..0f4a6ba 100644

include/hw/mem/pc-dimm.h typedef struct PCDIMMDevice { · line 58

Quoted 8 lines
include/hw/mem/pc-dimm.h +1 -1
@@ -52,7 +52,7 @@ typedef struct PCDIMMDevice {
     DeviceState parent_obj;
 
     /* public */
-    ram_addr_t addr;
+    uint64_t addr;
     uint32_t node;
     int32_t slot;
     HostMemoryBackend *hostmem;

This needs some thought.
HACKING explicitly says:
Guest RAM memory offsets must use ram_addr_t, but only for RAM, it may not cover whole guest address space.

I think we need to validate addresses where they
are used/defined.

Quoted 2 lines
Signature · 1 line
1.7.1
#7 lore raw
In reply to Igor Mammedov
Quoted 8 lines · Igor Mammedov

fixes build errors and warnings introduced by
memory hotplug series when building with clang

Igor Mammedov (4):
pc: acpi: do not hardcode preprocessor fixup! pc: initialize memory hotplug address space fixup! pc: add memory hotplug handler to PC_MACHINE fixup! pc: implement pc-dimm device abstraction

I applied patches 1-3.
I think patch 4 can be improved on, let's
merge it on top.

Quoted 4 lines
 hw/i386/Makefile.objs    |    2 +-
 hw/i386/pc.c             |    6 +++---
 include/hw/mem/pc-dimm.h |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)