All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table
@ 2015-10-23 14:57 Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 01/19] acpi: aml: add aml_lgreater_equal() and aml_load_table() Igor Mammedov
                   ` (20 more replies)
  0 siblings, 21 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

As part of moving to dynamic DSDT and dropping
ASL templates althogether this series moves out
ASL part of memory hotplug from DSDT into a custom
ACPI table. Beside of reducing ASL codebase (DSDT)
series tries to generalize and consolidate ACPI
part of memory hotplug code so it could be easier
to reuse it with outher targets (I plan to do it
for ARM later).

New table uses 64-bit integers for simplification
of code that are available only since ACPI 2.0.
To avoid breaking Windows XP based (rev1) guests
that table is loaded only if guest supports 2.0
revision Using LoadTable() ASL method.

As a side effect of code consolidation/simplification
series reduces ACPI tables size on:
 - 879 bytes without memory hotplug
 - 1216 bytes with 256 hotpluggable memory slots

More detailed breakdown on max table sizes in default
and hotplug enabled cases:
     new+HP  new    old   old+HP
MHPT 50808   -       -    -
SSDT 2425    2368   2486  53688
DSDT 2267    2267   3028  3028

Tested with following guests:
 - RHEL7.2,
 - Windows XPsp3, Windows Server 2003EE,
 - Windows Server 2008DC, Windows Server 2012R2DC

Since memory hotpulg doesn't work on XP based guests,
I've just tested that it boots just fine with/without
memory hotplug enabled on QEMU side.
The rest of the guests work as expected.

git tree for testing:
https://github.com/imammedo/qemu/commits/mhpt_table_v1

Igor Mammedov (18):
  acpi: aml: add aml_lgreater_equal() and aml_load_table()
  acpi: aml: add aml_create_qword_field()
  acpi: aml: add aml_decrement() and aml_subtract()
  acpi: aml: add aml_call0() helper
  pc: acpi: move SSDT part of memhp into a custom table
  pc: acpi: memhp: move MHPD._STA method into MHPT table
  pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table
  pc: acpi: memhp: move MHPD.MSCN method into MHPT table
  pc: acpi: make memory device's _UID integer
  pc: acpi: memhp: move MHPD.MRST method into MHPT table
  pc: acpi: memhp: move MHPD.MPXM method into MHPT table
  pc: acpi: memhp: move MHPD.MOST method into MHPT table
  pc: acpi: memhp: move MHPD.MEJ0 method into MHPT table
  pc: acpi: bump DSDT revision compliance to v2
  pc: acpi: memhp: move MHPD.MCRS method into MHPT table
  pc: acpi: memhp: move MHPD Device along with _UID/_HID into MHPT table
  pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03
    into SSDT
  pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage

Xiao Guangrong (1):
  acpi: add aml_mutex(), aml_acquire(), aml_release()

 hw/acpi/Makefile.objs               |   2 +-
 hw/acpi/aml-build.c                 | 115 ++++++++++++++-
 hw/acpi/memory_hotplug_acpi_table.c | 286 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-build.c                | 140 ++++--------------
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 171 ---------------------
 hw/i386/acpi-dsdt.dsl               |   7 +-
 hw/i386/q35-acpi-dsdt.dsl           |   7 +-
 include/hw/acpi/aml-build.h         |   9 ++
 include/hw/acpi/memory_hotplug.h    |   8 +
 include/hw/acpi/pc-hotplug.h        |  24 ---
 10 files changed, 443 insertions(+), 326 deletions(-)
 create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
 delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 01/19] acpi: aml: add aml_lgreater_equal() and aml_load_table()
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 02/19] acpi: add aml_mutex(), aml_acquire(), aml_release() Igor Mammedov
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/aml-build.c         | 35 +++++++++++++++++++++++++++++++++++
 include/hw/acpi/aml-build.h |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 0d4b324..ba7c92e 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -672,6 +672,17 @@ Aml *aml_equal(Aml *arg1, Aml *arg2)
     return var;
 }
 
+/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLGreaterEqual */
+Aml *aml_lgreater_equal(Aml *arg1, Aml *arg2)
+{
+    /* LGreaterEqualOp := LNotOp LLessOp */
+    Aml *var = aml_opcode(0x92 /* LNotOp */);
+    build_append_byte(var->buf, 0x95 /* LLessOp */);
+    aml_append(var, arg1);
+    aml_append(var, arg2);
+    return var;
+}
+
 /* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefIfElse */
 Aml *aml_if(Aml *predicate)
 {
@@ -1135,6 +1146,30 @@ Aml *aml_unicode(const char *str)
     return var;
 }
 
+/*
+ * ACPI 2.0a: 16.2.3.4.2.28 LoadTable (Load Definition Block From XSDT)
+ */
+Aml *aml_load_table(const char *signature)
+{
+    Aml *var = aml_alloc();
+    build_append_byte(var->buf, 0x5B); /* ExtOpPrefix */
+    build_append_byte(var->buf, 0x1F); /* LoadTableOp */
+    aml_append(var, aml_string("%s", signature)); /* SignatureString */
+    aml_append(var, aml_string(ACPI_BUILD_APPNAME6)); /* OEMIDString */
+    aml_append(var,
+        aml_string("%s%s",
+                   ACPI_BUILD_APPNAME4,
+                   signature)); /* OEMTableIDString */
+    /* load at current context */
+    build_append_byte(var->buf, 0x0D); /* empty RootPathString */
+    build_append_byte(var->buf, 0x0);
+    build_append_byte(var->buf, 0x0D); /* empty ParameterPathString */
+    build_append_byte(var->buf, 0x0);
+    /* don't store anything into ParameterPathString since it's empty */
+    build_append_byte(var->buf, 0); /* ParameterData */
+    return var;
+}
+
 void
 build_header(GArray *linker, GArray *table_data,
              AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 1b632dc..148bf3e 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -229,6 +229,7 @@ Aml *aml_local(int num);
 Aml *aml_string(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
 Aml *aml_lnot(Aml *arg);
 Aml *aml_equal(Aml *arg1, Aml *arg2);
+Aml *aml_lgreater_equal(Aml *arg1, Aml *arg2);
 Aml *aml_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len,
                    const char *name_format, ...) GCC_FMT_ATTR(4, 5);
 Aml *aml_eisaid(const char *str);
@@ -274,6 +275,7 @@ Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
 Aml *aml_varpackage(uint32_t num_elements);
 Aml *aml_touuid(const char *uuid);
 Aml *aml_unicode(const char *str);
+Aml *aml_load_table(const char *signature);
 
 void
 build_header(GArray *linker, GArray *table_data,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 02/19] acpi: add aml_mutex(), aml_acquire(), aml_release()
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 01/19] acpi: aml: add aml_lgreater_equal() and aml_load_table() Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 03/19] acpi: aml: add aml_create_qword_field() Igor Mammedov
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

From: Xiao Guangrong <guangrong.xiao@linux.intel.com>

Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/aml-build.c         | 33 +++++++++++++++++++++++++++++++++
 include/hw/acpi/aml-build.h |  3 +++
 2 files changed, 36 insertions(+)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index ba7c92e..43233e2 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1170,6 +1170,39 @@ Aml *aml_load_table(const char *signature)
     return var;
 }
 
+/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMutex */
+Aml *aml_mutex(const char *name, uint8_t sync_level)
+{
+    Aml *var = aml_alloc();
+    build_append_byte(var->buf, 0x5B); /* ExtOpPrefix */
+    build_append_byte(var->buf, 0x01); /* MutexOp */
+    build_append_namestring(var->buf, "%s", name);
+    assert(!(sync_level & 0xF0));
+    build_append_byte(var->buf, sync_level);
+    return var;
+}
+
+/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAcquire */
+Aml *aml_acquire(Aml *mutex, uint16_t timeout)
+{
+    Aml *var = aml_alloc();
+    build_append_byte(var->buf, 0x5B); /* ExtOpPrefix */
+    build_append_byte(var->buf, 0x23); /* AcquireOp */
+    aml_append(var, mutex);
+    build_append_int_noprefix(var->buf, timeout, sizeof(timeout));
+    return var;
+}
+
+/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefRelease */
+Aml *aml_release(Aml *mutex)
+{
+    Aml *var = aml_alloc();
+    build_append_byte(var->buf, 0x5B); /* ExtOpPrefix */
+    build_append_byte(var->buf, 0x27); /* ReleaseOp */
+    aml_append(var, mutex);
+    return var;
+}
+
 void
 build_header(GArray *linker, GArray *table_data,
              AcpiTableHeader *h, const char *sig, int len, uint8_t rev)
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 148bf3e..6ac01cb 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -271,6 +271,9 @@ Aml *aml_package(uint8_t num_elements);
 Aml *aml_buffer(int buffer_size, uint8_t *byte_list);
 Aml *aml_resource_template(void);
 Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule);
+Aml *aml_mutex(const char *name, uint8_t sync_level);
+Aml *aml_acquire(Aml *mutex, uint16_t timeout);
+Aml *aml_release(Aml *mutex);
 Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
 Aml *aml_varpackage(uint32_t num_elements);
 Aml *aml_touuid(const char *uuid);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 03/19] acpi: aml: add aml_create_qword_field()
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 01/19] acpi: aml: add aml_lgreater_equal() and aml_load_table() Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 02/19] acpi: add aml_mutex(), aml_acquire(), aml_release() Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 04/19] acpi: aml: add aml_decrement() and aml_subtract() Igor Mammedov
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/aml-build.c         | 21 +++++++++++++++++----
 include/hw/acpi/aml-build.h |  1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 43233e2..6e147eb 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -805,17 +805,30 @@ Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule)
     return var;
 }
 
-/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefCreateDWordField */
-Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name)
+static
+Aml *create_field_common(int opcode, Aml *srcbuf, Aml *index, const char *name)
 {
-    Aml *var = aml_alloc();
-    build_append_byte(var->buf, 0x8A); /* CreateDWordFieldOp */
+    Aml *var = aml_opcode(opcode);
     aml_append(var, srcbuf);
     aml_append(var, index);
     build_append_namestring(var->buf, "%s", name);
     return var;
 }
 
+/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefCreateDWordField */
+Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name)
+{
+    return create_field_common(0x8A /* CreateDWordFieldOp */,
+                               srcbuf, index, name);
+}
+
+/* ACPI 2.0a: 17.2.4.2 Named Objects Encoding: DefCreateQWordField */
+Aml *aml_create_qword_field(Aml *srcbuf, Aml *index, const char *name)
+{
+    return create_field_common(0x8F /* CreateQWordFieldOp */,
+                               srcbuf, index, name);
+}
+
 /* ACPI 1.0b: 16.2.3 Data Objects Encoding: String */
 Aml *aml_string(const char *name_format, ...)
 {
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 6ac01cb..f788a1e 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -275,6 +275,7 @@ Aml *aml_mutex(const char *name, uint8_t sync_level);
 Aml *aml_acquire(Aml *mutex, uint16_t timeout);
 Aml *aml_release(Aml *mutex);
 Aml *aml_create_dword_field(Aml *srcbuf, Aml *index, const char *name);
+Aml *aml_create_qword_field(Aml *srcbuf, Aml *index, const char *name);
 Aml *aml_varpackage(uint32_t num_elements);
 Aml *aml_touuid(const char *uuid);
 Aml *aml_unicode(const char *str);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 04/19] acpi: aml: add aml_decrement() and aml_subtract()
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (2 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 03/19] acpi: aml: add aml_create_qword_field() Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 05/19] acpi: aml: add aml_call0() helper Igor Mammedov
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/aml-build.c         | 18 ++++++++++++++++++
 include/hw/acpi/aml-build.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 6e147eb..dc6e18d 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -495,6 +495,16 @@ Aml *aml_add(Aml *arg1, Aml *arg2)
     return var;
 }
 
+/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefSubtract */
+Aml *aml_subtract(Aml *arg1, Aml *arg2)
+{
+    Aml *var = aml_opcode(0x74 /* SubtractOp */);
+    aml_append(var, arg1);
+    aml_append(var, arg2);
+    build_append_byte(var->buf, 0x00 /* NullNameOp */);
+    return var;
+}
+
 /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIncrement */
 Aml *aml_increment(Aml *arg)
 {
@@ -503,6 +513,14 @@ Aml *aml_increment(Aml *arg)
     return var;
 }
 
+/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefDecrement */
+Aml *aml_decrement(Aml *arg)
+{
+    Aml *var = aml_opcode(0x76 /* DecrementOp */);
+    aml_append(var, arg);
+    return var;
+}
+
 /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefIndex */
 Aml *aml_index(Aml *arg1, Aml *idx)
 {
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index f788a1e..4577e00 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -205,7 +205,9 @@ Aml *aml_shiftleft(Aml *arg1, Aml *count);
 Aml *aml_shiftright(Aml *arg1, Aml *count);
 Aml *aml_lless(Aml *arg1, Aml *arg2);
 Aml *aml_add(Aml *arg1, Aml *arg2);
+Aml *aml_subtract(Aml *arg1, Aml *arg2);
 Aml *aml_increment(Aml *arg);
+Aml *aml_decrement(Aml *arg);
 Aml *aml_index(Aml *arg1, Aml *idx);
 Aml *aml_notify(Aml *arg1, Aml *arg2);
 Aml *aml_call1(const char *method, Aml *arg1);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 05/19] acpi: aml: add aml_call0() helper
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (3 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 04/19] acpi: aml: add aml_decrement() and aml_subtract() Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table Igor Mammedov
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

it will help to call a method with 0 arguments

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/aml-build.c         | 8 ++++++++
 include/hw/acpi/aml-build.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index dc6e18d..68d9669 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -541,6 +541,14 @@ Aml *aml_notify(Aml *arg1, Aml *arg2)
 }
 
 /* helper to call method with 1 argument */
+Aml *aml_call0(const char *method)
+{
+    Aml *var = aml_alloc();
+    build_append_namestring(var->buf, "%s", method);
+    return var;
+}
+
+/* helper to call method with 1 argument */
 Aml *aml_call1(const char *method, Aml *arg1)
 {
     Aml *var = aml_alloc();
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 4577e00..5b6efa4 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -210,6 +210,7 @@ Aml *aml_increment(Aml *arg);
 Aml *aml_decrement(Aml *arg);
 Aml *aml_index(Aml *arg1, Aml *idx);
 Aml *aml_notify(Aml *arg1, Aml *arg2);
+Aml *aml_call0(const char *method);
 Aml *aml_call1(const char *method, Aml *arg1);
 Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2);
 Aml *aml_call3(const char *method, Aml *arg1, Aml *arg2, Aml *arg3);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (4 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 05/19] acpi: aml: add aml_call0() helper Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-24 17:41   ` Michael S. Tsirkin
                     ` (2 more replies)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 07/19] pc: acpi: memhp: move MHPD._STA method into MHPT table Igor Mammedov
                   ` (14 subsequent siblings)
  20 siblings, 3 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

moves SSDT part to custom MHPT table, which is loaded
at runtime by OSPM if it supports ACPIv2 revision and
only if memory hotplug is enabled.
That should reduce ACPI tables blob size if memory
hotplug is not enabled (default case).

Checked for compatibility issues with:
 * Windows XPsp3, Windows Server 2003: they don't load
   the table as OSPM only reports revision 1 as supported.
   And we don't care about memhp for these guests as they
   do not support it anyway.
 * Windows Server 2008, Windows Server 2008R2:
   works as expected

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/Makefile.objs               |   2 +-
 hw/acpi/memory_hotplug_acpi_table.c | 138 ++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-build.c                | 130 +++++----------------------------
 include/hw/acpi/memory_hotplug.h    |   3 +
 4 files changed, 159 insertions(+), 114 deletions(-)
 create mode 100644 hw/acpi/memory_hotplug_acpi_table.c

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 7d3230c..c04064e 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -1,7 +1,7 @@
 common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
 common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
-common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
+common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o
 common-obj-$(CONFIG_ACPI) += acpi_interface.o
 common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
 common-obj-$(CONFIG_ACPI) += aml-build.o
diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
new file mode 100644
index 0000000..28da13c
--- /dev/null
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -0,0 +1,138 @@
+#include <stdbool.h>
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/memory_hotplug.h"
+#include "include/hw/acpi/pc-hotplug.h"
+#include "hw/boards.h"
+
+#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
+
+void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
+                uint16_t io_base, uint16_t io_len)
+{
+    int i;
+    Aml *table, *sb_scope, *dev, *method, *ifctx, *ctrl_dev;
+
+    table = init_aml_allocator();
+    acpi_data_push(table->buf, sizeof(AcpiTableHeader));
+
+    /* scope for memory hotplug controller device node */
+    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
+    ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
+    {
+        Aml *crs, *field;
+
+        aml_append(ctrl_dev,
+            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
+        );
+
+        crs = aml_resource_template();
+        aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
+        aml_append(ctrl_dev, aml_name_decl("_CRS", crs));
+
+        aml_append(ctrl_dev, aml_operation_region(
+            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
+            io_base, io_len)
+        );
+
+        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
+                          AML_PRESERVE);
+        aml_append(field, /* read only */
+            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
+        aml_append(field, /* read only */
+            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
+        aml_append(field, /* read only */
+            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
+        aml_append(field, /* read only */
+            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
+        aml_append(field, /* read only */
+            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
+        aml_append(ctrl_dev, field);
+
+        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
+                          AML_WRITE_AS_ZEROS);
+        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
+        aml_append(field, /* 1 if enabled, read only */
+            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
+        aml_append(field,
+            /*(read) 1 if has a insert event. (write) 1 to clear event */
+            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
+        aml_append(field,
+            /* (read) 1 if has a remove event. (write) 1 to clear event */
+            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
+        aml_append(field,
+            /* initiates device eject, write only */
+            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
+        aml_append(ctrl_dev, field);
+
+        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
+                          AML_PRESERVE);
+        aml_append(field, /* DIMM selector, write only */
+            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
+        aml_append(field, /* _OST event code, write only */
+            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
+        aml_append(field, /* _OST status code, write only */
+            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
+        aml_append(ctrl_dev, field);
+    }
+    aml_append(table, ctrl_dev);
+
+    sb_scope = aml_scope("\\_SB");
+    for (i = 0; i < nr_mem; i++) {
+        const char *s;
+
+        dev = aml_device("MP%02X", i);
+        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
+        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
+
+        method = aml_method("_CRS", 0);
+        s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
+        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        aml_append(dev, method);
+
+        method = aml_method("_STA", 0);
+        s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
+        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        aml_append(dev, method);
+
+        method = aml_method("_PXM", 0);
+        s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
+        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
+        aml_append(dev, method);
+
+        method = aml_method("_OST", 3);
+        s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
+        aml_append(method, aml_return(aml_call4(
+            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
+        )));
+        aml_append(dev, method);
+
+        method = aml_method("_EJ0", 1);
+        s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
+        aml_append(method, aml_return(aml_call2(
+                   s, aml_name("_UID"), aml_arg(0))));
+        aml_append(dev, method);
+
+        aml_append(sb_scope, dev);
+    }
+
+    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
+     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
+     */
+    method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
+    for (i = 0; i < nr_mem; i++) {
+        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
+        aml_append(ifctx,
+            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
+        );
+        aml_append(method, ifctx);
+    }
+    aml_append(sb_scope, method);
+    aml_append(table, sb_scope);
+
+    /* copy AML table into ACPI tables blob and patch header there */
+    g_array_append_vals(table_data, table->buf->data, table->buf->len);
+    build_header(linker, table_data,
+        (void *)(table_data->data + table_data->len - table->buf->len),
+        "MHPT", table->buf->len, 2);
+    free_aml_allocator();
+}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 95e0c65..8add4d9 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -925,6 +925,16 @@ build_ssdt(GArray *table_data, GArray *linker,
     /* Reserve space for header */
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    sb_scope = aml_scope("\\_SB");
+    method = aml_method("_INI", 0);
+    ifctx = aml_if(aml_lgreater_equal(aml_name("_REV"), aml_int(2)));
+    if (nr_mem) {
+        aml_append(ifctx, aml_load_table("MHPT"));
+    }
+    aml_append(method, ifctx);
+    aml_append(sb_scope, method);
+    aml_append(ssdt, sb_scope);
+
     /* Extra PCI root buses are implemented  only for i440fx */
     bus = find_i440fx();
     if (bus) {
@@ -1200,119 +1210,6 @@ build_ssdt(GArray *table_data, GArray *linker,
         }
         aml_append(sb_scope, aml_name_decl("CPON", pkg));
 
-        /* build memory devices */
-        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
-        scope = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
-        aml_append(scope,
-            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
-        );
-
-        crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, pm->mem_hp_io_base, pm->mem_hp_io_base, 0,
-                   pm->mem_hp_io_len)
-        );
-        aml_append(scope, aml_name_decl("_CRS", crs));
-
-        aml_append(scope, aml_operation_region(
-            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
-            pm->mem_hp_io_base, pm->mem_hp_io_len)
-        );
-
-        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
-                          AML_PRESERVE);
-        aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
-        aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
-        aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
-        aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
-        aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
-        aml_append(scope, field);
-
-        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
-                          AML_WRITE_AS_ZEROS);
-        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
-        aml_append(field, /* 1 if enabled, read only */
-            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
-        aml_append(field,
-            /*(read) 1 if has a insert event. (write) 1 to clear event */
-            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
-        aml_append(field,
-            /* (read) 1 if has a remove event. (write) 1 to clear event */
-            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
-        aml_append(field,
-            /* initiates device eject, write only */
-            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
-        aml_append(scope, field);
-
-        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
-                          AML_PRESERVE);
-        aml_append(field, /* DIMM selector, write only */
-            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
-        aml_append(field, /* _OST event code, write only */
-            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
-        aml_append(field, /* _OST status code, write only */
-            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
-        aml_append(scope, field);
-
-        aml_append(sb_scope, scope);
-
-        for (i = 0; i < nr_mem; i++) {
-            #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
-            const char *s;
-
-            dev = aml_device("MP%02X", i);
-            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
-            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
-
-            method = aml_method("_CRS", 0);
-            s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
-            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-            aml_append(dev, method);
-
-            method = aml_method("_STA", 0);
-            s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
-            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-            aml_append(dev, method);
-
-            method = aml_method("_PXM", 0);
-            s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
-            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
-            aml_append(dev, method);
-
-            method = aml_method("_OST", 3);
-            s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
-            aml_append(method, aml_return(aml_call4(
-                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
-            )));
-            aml_append(dev, method);
-
-            method = aml_method("_EJ0", 1);
-            s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
-            aml_append(method, aml_return(aml_call2(
-                       s, aml_name("_UID"), aml_arg(0))));
-            aml_append(dev, method);
-
-            aml_append(sb_scope, dev);
-        }
-
-        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
-         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
-         */
-        method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
-        for (i = 0; i < nr_mem; i++) {
-            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
-            aml_append(ifctx,
-                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
-            );
-            aml_append(method, ifctx);
-        }
-        aml_append(sb_scope, method);
-
         {
             Object *pci_host;
             PCIBus *bus = NULL;
@@ -1671,6 +1568,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
     uint8_t *u;
     size_t aml_len = 0;
     GArray *tables_blob = tables->table_data;
+    MachineState *machine = MACHINE(qdev_get_machine());
 
     acpi_get_cpu_info(&cpu);
     acpi_get_pm_info(&pm);
@@ -1742,6 +1640,12 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
         build_dmar_q35(tables_blob, tables->linker);
     }
 
+    if (machine->ram_slots) {
+        acpi_add_table(table_offsets, tables_blob);
+        build_mhpt(tables_blob, tables->linker, machine->ram_slots,
+                   pm.mem_hp_io_base, pm.mem_hp_io_len);
+    }
+
     /* Add tables supplied by user (if any) */
     for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
         unsigned len = acpi_table_len(u);
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 1342adb..5fd2854 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -45,4 +45,7 @@ extern const VMStateDescription vmstate_memory_hotplug;
                    vmstate_memory_hotplug, MemHotplugState)
 
 void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
+
+void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
+                uint16_t io_base, uint16_t io_len);
 #endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 07/19] pc: acpi: memhp: move MHPD._STA method into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (5 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 08/19] pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table Igor Mammedov
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 3 +++
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 8 --------
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index 28da13c..c99a5c3 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -73,6 +73,9 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(field, /* _OST status code, write only */
             aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
         aml_append(ctrl_dev, field);
+
+        /* present, functioning, decoding, not shown in UI */
+        aml_append(ctrl_dev, aml_name_decl("_STA", aml_int(0xB)));
     }
     aml_append(table, ctrl_dev);
 
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index c2bb6a1..b4eacc9 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -35,14 +35,6 @@
             External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
             External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
 
-            Method(_STA, 0) {
-                If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
-                    Return(0x0)
-                }
-                /* present, functioning, decoding, not shown in UI */
-                Return(0xB)
-            }
-
             Mutex (MEMORY_SLOT_LOCK, 0)
 
             Method(MEMORY_SLOT_SCAN_METHOD, 0) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 08/19] pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (6 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 07/19] pc: acpi: memhp: move MHPD._STA method into MHPT table Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 09/19] pc: acpi: memhp: move MHPD.MSCN method into MHPT table Igor Mammedov
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 2 ++
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 3 +--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index c99a5c3..8a9bcd9 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -76,6 +76,8 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
 
         /* present, functioning, decoding, not shown in UI */
         aml_append(ctrl_dev, aml_name_decl("_STA", aml_int(0xB)));
+
+        aml_append(ctrl_dev, aml_mutex(stringify(MEMORY_SLOT_LOCK), 0));
     }
     aml_append(table, ctrl_dev);
 
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index b4eacc9..a1e519b 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -34,8 +34,7 @@
             External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
             External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
             External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
-
-            Mutex (MEMORY_SLOT_LOCK, 0)
+            External(MEMORY_SLOT_LOCK, MutexObj)
 
             Method(MEMORY_SLOT_SCAN_METHOD, 0) {
                 If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 09/19] pc: acpi: memhp: move MHPD.MSCN method into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (7 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 08/19] pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 10/19] pc: acpi: make memory device's _UID integer Igor Mammedov
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 53 +++++++++++++++++++++++++++++++------
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 27 +------------------
 include/hw/acpi/pc-hotplug.h        |  4 ---
 3 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index 8a9bcd9..e702cad 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -4,13 +4,18 @@
 #include "include/hw/acpi/pc-hotplug.h"
 #include "hw/boards.h"
 
+#define MEMORY_SLOT_INSERT_EVENT     "MINS"
+#define MEMORY_SLOT_REMOVE_EVENT     "MRMV"
+#define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
+
 #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
 
 void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
                 uint16_t io_base, uint16_t io_len)
 {
     int i;
-    Aml *table, *sb_scope, *dev, *method, *ifctx, *ctrl_dev;
+    Aml *table, *sb_scope, *dev, *method, *ifctx, *ctrl_dev, *while_ctx;
+    Aml *else_ctx;
 
     table = init_aml_allocator();
     acpi_data_push(table->buf, sizeof(AcpiTableHeader));
@@ -20,10 +25,8 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
     ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
     {
         Aml *crs, *field;
-
-        aml_append(ctrl_dev,
-            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
-        );
+        Aml *a_ctrl_lock = aml_name(stringify(MEMORY_SLOT_LOCK));
+        Aml *a_slot_selector = aml_name(stringify(MEMORY_SLOT_SLECTOR));
 
         crs = aml_resource_template();
         aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
@@ -55,10 +58,10 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
         aml_append(field,
             /*(read) 1 if has a insert event. (write) 1 to clear event */
-            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
+            aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
         aml_append(field,
             /* (read) 1 if has a remove event. (write) 1 to clear event */
-            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
+            aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
         aml_append(field,
             /* initiates device eject, write only */
             aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
@@ -78,6 +81,40 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(ctrl_dev, aml_name_decl("_STA", aml_int(0xB)));
 
         aml_append(ctrl_dev, aml_mutex(stringify(MEMORY_SLOT_LOCK), 0));
+
+        method = aml_method(stringify(MEMORY_SLOT_SCAN_METHOD), 0);
+        {
+            Aml *a_idx = aml_local(0);
+
+            aml_append(method, aml_store(aml_int(0), a_idx));
+            aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
+            while_ctx = aml_while(aml_lless(a_idx, aml_int(nr_mem)));
+            {
+                Aml *a_ins_evt = aml_name(MEMORY_SLOT_INSERT_EVENT);
+                Aml *a_rm_evt = aml_name(MEMORY_SLOT_REMOVE_EVENT);
+
+                aml_append(while_ctx, aml_store(a_idx, a_slot_selector));
+                ifctx = aml_if(aml_equal(a_ins_evt, aml_int(1)));
+                aml_append(ifctx,
+                    aml_call2(MEMORY_SLOT_NOTIFY_METHOD, a_idx, aml_int(1)));
+                aml_append(ifctx, aml_store(aml_int(1), a_ins_evt));
+                aml_append(while_ctx, ifctx);
+
+                else_ctx = aml_else();
+                ifctx = aml_if(aml_equal(a_rm_evt, aml_int(1)));
+                aml_append(ifctx,
+                    aml_call2(MEMORY_SLOT_NOTIFY_METHOD, a_idx, aml_int(3)));
+                aml_append(ifctx, aml_store(aml_int(1), a_rm_evt));
+                aml_append(else_ctx, ifctx);
+                aml_append(while_ctx, else_ctx);
+
+                aml_append(while_ctx, aml_increment(a_idx));
+            }
+            aml_append(method, while_ctx);
+            aml_append(method, aml_release(a_ctrl_lock));
+            aml_append(method, aml_return(aml_int(1)));
+        }
+        aml_append(ctrl_dev, method);
     }
     aml_append(table, ctrl_dev);
 
@@ -123,7 +160,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
     /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
      *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
      */
-    method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
+    method = aml_method(MEMORY_SLOT_NOTIFY_METHOD, 2);
     for (i = 0; i < nr_mem; i++) {
         ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
         aml_append(ifctx,
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index a1e519b..92baf87 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -13,13 +13,12 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-    External(MEMORY_SLOT_NOTIFY_METHOD, MethodObj)
+    External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj)
 
     Scope(\_SB.PCI0) {
         Device(MEMORY_HOTPLUG_DEVICE) {
             Name(_HID, "PNP0A06")
             Name(_UID, "Memory hotplug resources")
-            External(MEMORY_SLOTS_NUMBER, IntObj)
 
             /* Memory hotplug IO registers */
             External(MEMORY_SLOT_ADDR_LOW, FieldUnitObj) // read only
@@ -28,36 +27,12 @@
             External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
             External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only
             External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only
-            External(MEMORY_SLOT_INSERT_EVENT, FieldUnitObj) // (read) 1 if has a insert event. (write) 1 to clear event
-            External(MEMORY_SLOT_REMOVE_EVENT, FieldUnitObj) // (read) 1 if has a remove event. (write) 1 to clear event
             External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only
             External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
             External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
             External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
             External(MEMORY_SLOT_LOCK, MutexObj)
 
-            Method(MEMORY_SLOT_SCAN_METHOD, 0) {
-                If (LEqual(MEMORY_SLOTS_NUMBER, Zero)) {
-                     Return(Zero)
-                }
-
-                Store(Zero, Local0) // Mem devs iterrator
-                Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
-                while (LLess(Local0, MEMORY_SLOTS_NUMBER)) {
-                    Store(Local0, MEMORY_SLOT_SLECTOR) // select Local0 DIMM
-                    If (LEqual(MEMORY_SLOT_INSERT_EVENT, One)) { // Memory device needs check
-                        MEMORY_SLOT_NOTIFY_METHOD(Local0, 1)
-                        Store(1, MEMORY_SLOT_INSERT_EVENT)
-                    } Elseif (LEqual(MEMORY_SLOT_REMOVE_EVENT, One)) { // Ejection request
-                        MEMORY_SLOT_NOTIFY_METHOD(Local0, 3)
-                        Store(1, MEMORY_SLOT_REMOVE_EVENT)
-                    }
-                    Add(Local0, One, Local0) // goto next DIMM
-                }
-                Release(MEMORY_SLOT_LOCK)
-                Return(One)
-            }
-
             Method(MEMORY_SLOT_STATUS_METHOD, 1) {
                 Store(Zero, Local0)
 
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 77b1569..9b67a93 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -33,7 +33,6 @@
 #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
 
 #define MEMORY_HOTPLUG_DEVICE        MHPD
-#define MEMORY_SLOTS_NUMBER          MDNR
 #define MEMORY_HOTPLUG_IO_REGION     HPMR
 #define MEMORY_SLOT_ADDR_LOW         MRBL
 #define MEMORY_SLOT_ADDR_HIGH        MRBH
@@ -41,8 +40,6 @@
 #define MEMORY_SLOT_SIZE_HIGH        MRLH
 #define MEMORY_SLOT_PROXIMITY        MPX
 #define MEMORY_SLOT_ENABLED          MES
-#define MEMORY_SLOT_INSERT_EVENT     MINS
-#define MEMORY_SLOT_REMOVE_EVENT     MRMV
 #define MEMORY_SLOT_EJECT            MEJ
 #define MEMORY_SLOT_SLECTOR          MSEL
 #define MEMORY_SLOT_OST_EVENT        MOEV
@@ -53,7 +50,6 @@
 #define MEMORY_SLOT_OST_METHOD       MOST
 #define MEMORY_SLOT_PROXIMITY_METHOD MPXM
 #define MEMORY_SLOT_EJECT_METHOD     MEJ0
-#define MEMORY_SLOT_NOTIFY_METHOD    MTFY
 #define MEMORY_SLOT_SCAN_METHOD      MSCN
 
 #endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 10/19] pc: acpi: make memory device's _UID integer
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (8 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 09/19] pc: acpi: memhp: move MHPD.MSCN method into MHPT table Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 11/19] pc: acpi: memhp: move MHPD.MRST method into MHPT table Igor Mammedov
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

It will allow us to drop ToInteger() operator from ASL/AML code.
Change is transparent to legacy ASL that uses ToInteger() operator,
since it can accept any ComputationalData which includes Integer type.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index e702cad..3eb1780 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -123,7 +123,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         const char *s;
 
         dev = aml_device("MP%02X", i);
-        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
+        aml_append(dev, aml_name_decl("_UID", aml_int(i)));
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
 
         method = aml_method("_CRS", 0);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 11/19] pc: acpi: memhp: move MHPD.MRST method into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (9 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 10/19] pc: acpi: make memory device's _UID integer Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 12/19] pc: acpi: memhp: move MHPD.MPXM " Igor Mammedov
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 25 +++++++++++++++++++++++--
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 15 ---------------
 include/hw/acpi/pc-hotplug.h        |  2 --
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index 3eb1780..7ca3c7d 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -7,6 +7,8 @@
 #define MEMORY_SLOT_INSERT_EVENT     "MINS"
 #define MEMORY_SLOT_REMOVE_EVENT     "MRMV"
 #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
+#define MEMORY_SLOT_STATUS_METHOD    "MRST"
+#define MEMORY_SLOT_ENABLED          "MES"
 
 #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
 
@@ -25,6 +27,8 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
     ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
     {
         Aml *crs, *field;
+        Aml *a_slot_arg = aml_arg(0);
+        Aml *a_ret_val = aml_local(0);
         Aml *a_ctrl_lock = aml_name(stringify(MEMORY_SLOT_LOCK));
         Aml *a_slot_selector = aml_name(stringify(MEMORY_SLOT_SLECTOR));
 
@@ -55,7 +59,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
                           AML_WRITE_AS_ZEROS);
         aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
         aml_append(field, /* 1 if enabled, read only */
-            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
+            aml_named_field(MEMORY_SLOT_ENABLED, 1));
         aml_append(field,
             /*(read) 1 if has a insert event. (write) 1 to clear event */
             aml_named_field(MEMORY_SLOT_INSERT_EVENT, 1));
@@ -115,6 +119,23 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_append(method, aml_return(aml_int(1)));
         }
         aml_append(ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_STATUS_METHOD, 1);
+        {
+            Aml *a_slot_enabled = aml_name(MEMORY_SLOT_ENABLED);
+
+            aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(aml_int(0), a_ret_val));
+            aml_append(method, aml_store(a_slot_arg, a_slot_selector));
+
+            ifctx = aml_if(aml_equal(a_slot_enabled, aml_int(1)));
+            aml_append(ifctx, aml_store(aml_int(0xF), a_ret_val));
+            aml_append(method, ifctx);
+
+            aml_append(method, aml_release(a_ctrl_lock));
+            aml_append(method, aml_return(a_ret_val));
+        }
+        aml_append(ctrl_dev, method);
     }
     aml_append(table, ctrl_dev);
 
@@ -132,7 +153,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(dev, method);
 
         method = aml_method("_STA", 0);
-        s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
+        s = BASEPATH MEMORY_SLOT_STATUS_METHOD;
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
         aml_append(dev, method);
 
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index 92baf87..13e93dc 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -26,27 +26,12 @@
             External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only
             External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
             External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only
-            External(MEMORY_SLOT_ENABLED, FieldUnitObj) // 1 if enabled, read only
             External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only
             External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
             External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
             External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
             External(MEMORY_SLOT_LOCK, MutexObj)
 
-            Method(MEMORY_SLOT_STATUS_METHOD, 1) {
-                Store(Zero, Local0)
-
-                Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
-                Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
-
-                If (LEqual(MEMORY_SLOT_ENABLED, One)) {
-                    Store(0xF, Local0)
-                }
-
-                Release(MEMORY_SLOT_LOCK)
-                Return(Local0)
-            }
-
             Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 9b67a93..47efa99 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -39,13 +39,11 @@
 #define MEMORY_SLOT_SIZE_LOW         MRLL
 #define MEMORY_SLOT_SIZE_HIGH        MRLH
 #define MEMORY_SLOT_PROXIMITY        MPX
-#define MEMORY_SLOT_ENABLED          MES
 #define MEMORY_SLOT_EJECT            MEJ
 #define MEMORY_SLOT_SLECTOR          MSEL
 #define MEMORY_SLOT_OST_EVENT        MOEV
 #define MEMORY_SLOT_OST_STATUS       MOSC
 #define MEMORY_SLOT_LOCK             MLCK
-#define MEMORY_SLOT_STATUS_METHOD    MRST
 #define MEMORY_SLOT_CRS_METHOD       MCRS
 #define MEMORY_SLOT_OST_METHOD       MOST
 #define MEMORY_SLOT_PROXIMITY_METHOD MPXM
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 12/19] pc: acpi: memhp: move MHPD.MPXM method into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (10 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 11/19] pc: acpi: memhp: move MHPD.MRST method into MHPT table Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 13/19] pc: acpi: memhp: move MHPD.MOST " Igor Mammedov
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 18 ++++++++++++++++--
 hw/i386/acpi-dsdt-mem-hotplug.dsl   |  9 ---------
 include/hw/acpi/pc-hotplug.h        |  2 --
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index 7ca3c7d..3d35ac1 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -9,6 +9,8 @@
 #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
 #define MEMORY_SLOT_STATUS_METHOD    "MRST"
 #define MEMORY_SLOT_ENABLED          "MES"
+#define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
+#define MEMORY_SLOT_PROXIMITY        "MPX"
 
 #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
 
@@ -52,7 +54,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(field, /* read only */
             aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
         aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
+            aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
         aml_append(ctrl_dev, field);
 
         field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
@@ -136,6 +138,18 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_append(method, aml_return(a_ret_val));
         }
         aml_append(ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_PROXIMITY_METHOD, 1);
+        {
+            Aml *a_proximity = aml_name(MEMORY_SLOT_PROXIMITY);
+
+            aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(a_slot_arg, a_slot_selector));
+            aml_append(method, aml_store(a_proximity, a_ret_val));
+            aml_append(method, aml_release(a_ctrl_lock));
+            aml_append(method, aml_return(a_ret_val));
+        }
+        aml_append(ctrl_dev, method);
     }
     aml_append(table, ctrl_dev);
 
@@ -158,7 +172,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(dev, method);
 
         method = aml_method("_PXM", 0);
-        s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
+        s = BASEPATH MEMORY_SLOT_PROXIMITY_METHOD;
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
         aml_append(dev, method);
 
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index 13e93dc..02fecf2 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -25,7 +25,6 @@
             External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only
             External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only
             External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
-            External(MEMORY_SLOT_PROXIMITY, FieldUnitObj) // read only
             External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only
             External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
             External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
@@ -96,14 +95,6 @@
                 Return(MR64)
             }
 
-            Method(MEMORY_SLOT_PROXIMITY_METHOD, 1) {
-                Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
-                Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
-                Store(MEMORY_SLOT_PROXIMITY, Local0)
-                Release(MEMORY_SLOT_LOCK)
-                Return(Local0)
-            }
-
             Method(MEMORY_SLOT_OST_METHOD, 4) {
                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 47efa99..d7d5ede 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -38,7 +38,6 @@
 #define MEMORY_SLOT_ADDR_HIGH        MRBH
 #define MEMORY_SLOT_SIZE_LOW         MRLL
 #define MEMORY_SLOT_SIZE_HIGH        MRLH
-#define MEMORY_SLOT_PROXIMITY        MPX
 #define MEMORY_SLOT_EJECT            MEJ
 #define MEMORY_SLOT_SLECTOR          MSEL
 #define MEMORY_SLOT_OST_EVENT        MOEV
@@ -46,7 +45,6 @@
 #define MEMORY_SLOT_LOCK             MLCK
 #define MEMORY_SLOT_CRS_METHOD       MCRS
 #define MEMORY_SLOT_OST_METHOD       MOST
-#define MEMORY_SLOT_PROXIMITY_METHOD MPXM
 #define MEMORY_SLOT_EJECT_METHOD     MEJ0
 #define MEMORY_SLOT_SCAN_METHOD      MSCN
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 13/19] pc: acpi: memhp: move MHPD.MOST method into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (11 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 12/19] pc: acpi: memhp: move MHPD.MPXM " Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 14/19] pc: acpi: memhp: move MHPD.MEJ0 " Igor Mammedov
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 22 +++++++++++++++++++---
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 10 ----------
 include/hw/acpi/pc-hotplug.h        |  3 ---
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index 3d35ac1..7300624 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -11,6 +11,9 @@
 #define MEMORY_SLOT_ENABLED          "MES"
 #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
 #define MEMORY_SLOT_PROXIMITY        "MPX"
+#define MEMORY_SLOT_OST_METHOD       "MOST"
+#define MEMORY_SLOT_OST_EVENT        "MOEV"
+#define MEMORY_SLOT_OST_STATUS       "MOSC"
 
 #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
 
@@ -78,9 +81,9 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(field, /* DIMM selector, write only */
             aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
         aml_append(field, /* _OST event code, write only */
-            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
+            aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
         aml_append(field, /* _OST status code, write only */
-            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
+            aml_named_field(MEMORY_SLOT_OST_STATUS, 32));
         aml_append(ctrl_dev, field);
 
         /* present, functioning, decoding, not shown in UI */
@@ -150,6 +153,19 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_append(method, aml_return(a_ret_val));
         }
         aml_append(ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_OST_METHOD, 4);
+        {
+            Aml *a_ost_evt = aml_name(MEMORY_SLOT_OST_EVENT);
+            Aml *a_ost_status = aml_name(MEMORY_SLOT_OST_STATUS);
+
+            aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(a_slot_arg, a_slot_selector));
+            aml_append(method, aml_store(aml_arg(1), a_ost_evt));
+            aml_append(method, aml_store(aml_arg(2), a_ost_status));
+            aml_append(method, aml_release(a_ctrl_lock));
+        }
+        aml_append(ctrl_dev, method);
     }
     aml_append(table, ctrl_dev);
 
@@ -177,7 +193,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(dev, method);
 
         method = aml_method("_OST", 3);
-        s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
+        s = BASEPATH MEMORY_SLOT_OST_METHOD;
         aml_append(method, aml_return(aml_call4(
             s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
         )));
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index 02fecf2..8889eca 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -27,8 +27,6 @@
             External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
             External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only
             External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
-            External(MEMORY_SLOT_OST_EVENT, FieldUnitObj) // _OST event code, write only
-            External(MEMORY_SLOT_OST_STATUS, FieldUnitObj) // _OST status code, write only
             External(MEMORY_SLOT_LOCK, MutexObj)
 
             Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
@@ -95,14 +93,6 @@
                 Return(MR64)
             }
 
-            Method(MEMORY_SLOT_OST_METHOD, 4) {
-                Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
-                Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
-                Store(Arg1, MEMORY_SLOT_OST_EVENT)
-                Store(Arg2, MEMORY_SLOT_OST_STATUS)
-                Release(MEMORY_SLOT_LOCK)
-            }
-
             Method(MEMORY_SLOT_EJECT_METHOD, 2) {
                 Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
                 Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index d7d5ede..203d449 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -40,11 +40,8 @@
 #define MEMORY_SLOT_SIZE_HIGH        MRLH
 #define MEMORY_SLOT_EJECT            MEJ
 #define MEMORY_SLOT_SLECTOR          MSEL
-#define MEMORY_SLOT_OST_EVENT        MOEV
-#define MEMORY_SLOT_OST_STATUS       MOSC
 #define MEMORY_SLOT_LOCK             MLCK
 #define MEMORY_SLOT_CRS_METHOD       MCRS
-#define MEMORY_SLOT_OST_METHOD       MOST
 #define MEMORY_SLOT_EJECT_METHOD     MEJ0
 #define MEMORY_SLOT_SCAN_METHOD      MSCN
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 14/19] pc: acpi: memhp: move MHPD.MEJ0 method into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (12 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 13/19] pc: acpi: memhp: move MHPD.MOST " Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2 Igor Mammedov
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 17 +++++++++++++++--
 hw/i386/acpi-dsdt-mem-hotplug.dsl   |  8 --------
 include/hw/acpi/pc-hotplug.h        |  2 --
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index 7300624..c74da76 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -14,6 +14,8 @@
 #define MEMORY_SLOT_OST_METHOD       "MOST"
 #define MEMORY_SLOT_OST_EVENT        "MOEV"
 #define MEMORY_SLOT_OST_STATUS       "MOSC"
+#define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
+#define MEMORY_SLOT_EJECT            "MEJ"
 
 #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
 
@@ -73,7 +75,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_named_field(MEMORY_SLOT_REMOVE_EVENT, 1));
         aml_append(field,
             /* initiates device eject, write only */
-            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
+            aml_named_field(MEMORY_SLOT_EJECT, 1));
         aml_append(ctrl_dev, field);
 
         field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
@@ -166,6 +168,17 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_append(method, aml_release(a_ctrl_lock));
         }
         aml_append(ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_EJECT_METHOD, 2);
+        {
+            Aml *a_eject = aml_name(MEMORY_SLOT_EJECT);
+
+            aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(a_slot_arg, a_slot_selector));
+            aml_append(method, aml_store(aml_int(1), a_eject));
+            aml_append(method, aml_release(a_ctrl_lock));
+        }
+        aml_append(ctrl_dev, method);
     }
     aml_append(table, ctrl_dev);
 
@@ -200,7 +213,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(dev, method);
 
         method = aml_method("_EJ0", 1);
-        s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
+        s = BASEPATH MEMORY_SLOT_EJECT_METHOD;
         aml_append(method, aml_return(aml_call2(
                    s, aml_name("_UID"), aml_arg(0))));
         aml_append(dev, method);
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index 8889eca..87d8d66 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -25,7 +25,6 @@
             External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only
             External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only
             External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
-            External(MEMORY_SLOT_EJECT, FieldUnitObj) // initiates device eject, write only
             External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
             External(MEMORY_SLOT_LOCK, MutexObj)
 
@@ -92,12 +91,5 @@
                 Release(MEMORY_SLOT_LOCK)
                 Return(MR64)
             }
-
-            Method(MEMORY_SLOT_EJECT_METHOD, 2) {
-                Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
-                Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
-                Store(1, MEMORY_SLOT_EJECT)
-                Release(MEMORY_SLOT_LOCK)
-            }
         } // Device()
     } // Scope()
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 203d449..7198c90 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -38,11 +38,9 @@
 #define MEMORY_SLOT_ADDR_HIGH        MRBH
 #define MEMORY_SLOT_SIZE_LOW         MRLL
 #define MEMORY_SLOT_SIZE_HIGH        MRLH
-#define MEMORY_SLOT_EJECT            MEJ
 #define MEMORY_SLOT_SLECTOR          MSEL
 #define MEMORY_SLOT_LOCK             MLCK
 #define MEMORY_SLOT_CRS_METHOD       MCRS
-#define MEMORY_SLOT_EJECT_METHOD     MEJ0
 #define MEMORY_SLOT_SCAN_METHOD      MSCN
 
 #endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (13 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 14/19] pc: acpi: memhp: move MHPD.MEJ0 " Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-24 19:40   ` Michael S. Tsirkin
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 16/19] pc: acpi: memhp: move MHPD.MCRS method into MHPT table Igor Mammedov
                   ` (5 subsequent siblings)
  20 siblings, 1 reply; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

it turns on 64-bit integer handling in OSPM, which we could use
for writing simpler/smaller AML code.
Tested with Windows XP and Windows Server 2008, Linux:
 * XP doesn't care about revision and continues to use 32 integers
   and boots just fine with this change.
 * WS 2008 and Linux - support rev2 and use 64-bit integers

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/acpi-build.c      | 2 +-
 hw/i386/acpi-dsdt.dsl     | 2 +-
 hw/i386/q35-acpi-dsdt.dsl | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 8add4d9..c929540 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1484,7 +1484,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
 
     memset(dsdt, 0, sizeof *dsdt);
     build_header(linker, table_data, dsdt, "DSDT",
-                 misc->dsdt_size, 1);
+                 misc->dsdt_size, 2);
 }
 
 static GArray *
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index 8dba096..6d46b36 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -22,7 +22,7 @@ ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode
 DefinitionBlock (
     "acpi-dsdt.aml",    // Output Filename
     "DSDT",             // Signature
-    0x01,               // DSDT Compliance Revision
+    0x02,               // DSDT Compliance Revision
     "BXPC",             // OEMID
     "BXDSDT",           // TABLE ID
     0x1                 // OEM Revision
diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
index 7be7b37..ecefdec 100644
--- a/hw/i386/q35-acpi-dsdt.dsl
+++ b/hw/i386/q35-acpi-dsdt.dsl
@@ -28,7 +28,7 @@ ACPI_EXTRACT_ALL_CODE Q35AcpiDsdtAmlCode
 DefinitionBlock (
     "q35-acpi-dsdt.aml",// Output Filename
     "DSDT",             // Signature
-    0x01,               // DSDT Compliance Revision
+    0x02,               // DSDT Compliance Revision
     "BXPC",             // OEMID
     "BXDSDT",           // TABLE ID
     0x2                 // OEM Revision
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 16/19] pc: acpi: memhp: move MHPD.MCRS method into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (14 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2 Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 17/19] pc: acpi: memhp: move MHPD Device along with _UID/_HID " Igor Mammedov
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 60 +++++++++++++++++++++++++------
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 72 -------------------------------------
 include/hw/acpi/pc-hotplug.h        |  7 ----
 3 files changed, 49 insertions(+), 90 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index c74da76..a410619 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -16,6 +16,11 @@
 #define MEMORY_SLOT_OST_STATUS       "MOSC"
 #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
 #define MEMORY_SLOT_EJECT            "MEJ"
+#define MEMORY_SLOT_CRS_METHOD       "MCRS"
+#define MEMORY_SLOT_ADDR             "MRB"
+#define MEMORY_SLOT_SIZE             "MRL"
+#define MEMORY_SLOT_LOCK             "MLCK"
+#define MEMORY_SLOT_SLECTOR          "MSEL"
 
 #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
 
@@ -36,8 +41,8 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         Aml *crs, *field;
         Aml *a_slot_arg = aml_arg(0);
         Aml *a_ret_val = aml_local(0);
-        Aml *a_ctrl_lock = aml_name(stringify(MEMORY_SLOT_LOCK));
-        Aml *a_slot_selector = aml_name(stringify(MEMORY_SLOT_SLECTOR));
+        Aml *a_ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
+        Aml *a_slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
 
         crs = aml_resource_template();
         aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
@@ -51,13 +56,9 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
                           AML_PRESERVE);
         aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
+            aml_named_field(MEMORY_SLOT_ADDR, 64));
         aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
-        aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
-        aml_append(field, /* read only */
-            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
+            aml_named_field(MEMORY_SLOT_SIZE, 64));
         aml_append(field, /* read only */
             aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
         aml_append(ctrl_dev, field);
@@ -81,7 +82,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
                           AML_PRESERVE);
         aml_append(field, /* DIMM selector, write only */
-            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
+            aml_named_field(MEMORY_SLOT_SLECTOR, 32));
         aml_append(field, /* _OST event code, write only */
             aml_named_field(MEMORY_SLOT_OST_EVENT, 32));
         aml_append(field, /* _OST status code, write only */
@@ -91,7 +92,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         /* present, functioning, decoding, not shown in UI */
         aml_append(ctrl_dev, aml_name_decl("_STA", aml_int(0xB)));
 
-        aml_append(ctrl_dev, aml_mutex(stringify(MEMORY_SLOT_LOCK), 0));
+        aml_append(ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
 
         method = aml_method(stringify(MEMORY_SLOT_SCAN_METHOD), 0);
         {
@@ -179,6 +180,43 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_append(method, aml_release(a_ctrl_lock));
         }
         aml_append(ctrl_dev, method);
+
+        method = aml_method(MEMORY_SLOT_CRS_METHOD, 1);
+        {
+            Aml *a_mr64 = aml_name("MR64");
+            Aml *a_crs_tmpl = aml_resource_template();
+            Aml *a_min = aml_name("MIN");
+            Aml *a_max =  aml_name("MAX");
+            Aml *a_len = aml_name("LEN");
+
+            aml_append(method, aml_acquire(a_ctrl_lock, 0xFFFF));
+            aml_append(method, aml_store(a_slot_arg, a_slot_selector));
+
+            aml_append(a_crs_tmpl,
+                aml_qword_memory(AML_POS_DECODE, AML_MIN_FIXED, AML_MAX_FIXED,
+                                 AML_CACHEABLE, AML_READ_WRITE,
+                                 0, 0x0, 0xFFFFFFFFFFFFFFFE, 0,
+                                 0xFFFFFFFFFFFFFFFF));
+            aml_append(method, aml_name_decl("MR64", a_crs_tmpl));
+            aml_append(method,
+                aml_create_qword_field(a_mr64, aml_int(14), "MIN"));
+            aml_append(method,
+                aml_create_qword_field(a_mr64, aml_int(22), "MAX"));
+            aml_append(method,
+                aml_create_qword_field(a_mr64, aml_int(38), "LEN"));
+
+            aml_append(method, aml_store(aml_name(MEMORY_SLOT_ADDR), a_min));
+            aml_append(method, aml_store(aml_name(MEMORY_SLOT_SIZE), a_len));
+
+            aml_append(method, aml_store(
+                aml_add(a_min, aml_subtract(a_len, aml_int(1))),
+                a_max
+            ));
+
+            aml_append(method, aml_release(a_ctrl_lock));
+            aml_append(method, aml_return(a_mr64));
+        }
+        aml_append(ctrl_dev, method);
     }
     aml_append(table, ctrl_dev);
 
@@ -191,7 +229,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
 
         method = aml_method("_CRS", 0);
-        s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
+        s = BASEPATH MEMORY_SLOT_CRS_METHOD;
         aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
         aml_append(dev, method);
 
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index 87d8d66..50b7541 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -19,77 +19,5 @@
         Device(MEMORY_HOTPLUG_DEVICE) {
             Name(_HID, "PNP0A06")
             Name(_UID, "Memory hotplug resources")
-
-            /* Memory hotplug IO registers */
-            External(MEMORY_SLOT_ADDR_LOW, FieldUnitObj) // read only
-            External(MEMORY_SLOT_ADDR_HIGH, FieldUnitObj) // read only
-            External(MEMORY_SLOT_SIZE_LOW, FieldUnitObj) // read only
-            External(MEMORY_SLOT_SIZE_HIGH, FieldUnitObj) // read only
-            External(MEMORY_SLOT_SLECTOR, FieldUnitObj) // DIMM selector, write only
-            External(MEMORY_SLOT_LOCK, MutexObj)
-
-            Method(MEMORY_SLOT_CRS_METHOD, 1, Serialized) {
-                Acquire(MEMORY_SLOT_LOCK, 0xFFFF)
-                Store(ToInteger(Arg0), MEMORY_SLOT_SLECTOR) // select DIMM
-
-                Name(MR64, ResourceTemplate() {
-                    QWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
-                    Cacheable, ReadWrite,
-                    0x0000000000000000,        // Address Space Granularity
-                    0x0000000000000000,        // Address Range Minimum
-                    0xFFFFFFFFFFFFFFFE,        // Address Range Maximum
-                    0x0000000000000000,        // Address Translation Offset
-                    0xFFFFFFFFFFFFFFFF,        // Address Length
-                    ,, MW64, AddressRangeMemory, TypeStatic)
-                })
-
-                CreateDWordField(MR64, 14, MINL)
-                CreateDWordField(MR64, 18, MINH)
-                CreateDWordField(MR64, 38, LENL)
-                CreateDWordField(MR64, 42, LENH)
-                CreateDWordField(MR64, 22, MAXL)
-                CreateDWordField(MR64, 26, MAXH)
-
-                Store(MEMORY_SLOT_ADDR_HIGH, MINH)
-                Store(MEMORY_SLOT_ADDR_LOW, MINL)
-                Store(MEMORY_SLOT_SIZE_HIGH, LENH)
-                Store(MEMORY_SLOT_SIZE_LOW, LENL)
-
-                // 64-bit math: MAX = MIN + LEN - 1
-                Add(MINL, LENL, MAXL)
-                Add(MINH, LENH, MAXH)
-                If (LLess(MAXL, MINL)) {
-                    Add(MAXH, One, MAXH)
-                }
-                If (LLess(MAXL, One)) {
-                    Subtract(MAXH, One, MAXH)
-                }
-                Subtract(MAXL, One, MAXL)
-
-                If (LEqual(MAXH, Zero)){
-                    Name(MR32, ResourceTemplate() {
-                        DWordMemory(ResourceProducer, PosDecode, MinFixed, MaxFixed,
-                        Cacheable, ReadWrite,
-                        0x00000000,        // Address Space Granularity
-                        0x00000000,        // Address Range Minimum
-                        0xFFFFFFFE,        // Address Range Maximum
-                        0x00000000,        // Address Translation Offset
-                        0xFFFFFFFF,        // Address Length
-                        ,, MW32, AddressRangeMemory, TypeStatic)
-                    })
-                    CreateDWordField(MR32, MW32._MIN, MIN)
-                    CreateDWordField(MR32, MW32._MAX, MAX)
-                    CreateDWordField(MR32, MW32._LEN, LEN)
-                    Store(MINL, MIN)
-                    Store(MAXL, MAX)
-                    Store(LENL, LEN)
-
-                    Release(MEMORY_SLOT_LOCK)
-                    Return(MR32)
-                }
-
-                Release(MEMORY_SLOT_LOCK)
-                Return(MR64)
-            }
         } // Device()
     } // Scope()
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 7198c90..29f0244 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -34,13 +34,6 @@
 
 #define MEMORY_HOTPLUG_DEVICE        MHPD
 #define MEMORY_HOTPLUG_IO_REGION     HPMR
-#define MEMORY_SLOT_ADDR_LOW         MRBL
-#define MEMORY_SLOT_ADDR_HIGH        MRBH
-#define MEMORY_SLOT_SIZE_LOW         MRLL
-#define MEMORY_SLOT_SIZE_HIGH        MRLH
-#define MEMORY_SLOT_SLECTOR          MSEL
-#define MEMORY_SLOT_LOCK             MLCK
-#define MEMORY_SLOT_CRS_METHOD       MCRS
 #define MEMORY_SLOT_SCAN_METHOD      MSCN
 
 #endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 17/19] pc: acpi: memhp: move MHPD Device along with _UID/_HID into MHPT table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (15 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 16/19] pc: acpi: memhp: move MHPD.MCRS method into MHPT table Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 18/19] pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03 into SSDT Igor Mammedov
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 6 +++++-
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 7 -------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index a410619..ea308ab 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -36,7 +36,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
 
     /* scope for memory hotplug controller device node */
     assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
-    ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
+    ctrl_dev = aml_device("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
     {
         Aml *crs, *field;
         Aml *a_slot_arg = aml_arg(0);
@@ -44,6 +44,10 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         Aml *a_ctrl_lock = aml_name(MEMORY_SLOT_LOCK);
         Aml *a_slot_selector = aml_name(MEMORY_SLOT_SLECTOR);
 
+        aml_append(ctrl_dev, aml_name_decl("_HID", aml_string("PNP0A06")));
+        aml_append(ctrl_dev,
+            aml_name_decl("_UID", aml_string("Memory hotplug resources")));
+
         crs = aml_resource_template();
         aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
         aml_append(ctrl_dev, aml_name_decl("_CRS", crs));
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
index 50b7541..20c5ec1 100644
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ b/hw/i386/acpi-dsdt-mem-hotplug.dsl
@@ -14,10 +14,3 @@
  */
 
     External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj)
-
-    Scope(\_SB.PCI0) {
-        Device(MEMORY_HOTPLUG_DEVICE) {
-            Name(_HID, "PNP0A06")
-            Name(_UID, "Memory hotplug resources")
-        } // Device()
-    } // Scope()
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 18/19] pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03 into SSDT
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (16 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 17/19] pc: acpi: memhp: move MHPD Device along with _UID/_HID " Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 19/19] pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage Igor Mammedov
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

in addition to moving exclude _E03 handler from SSDT
if memory hotplug is not enabled.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c |  6 +++---
 hw/i386/acpi-build.c                |  8 ++++++++
 hw/i386/acpi-dsdt-mem-hotplug.dsl   | 16 ----------------
 hw/i386/acpi-dsdt.dsl               |  5 -----
 hw/i386/q35-acpi-dsdt.dsl           |  5 -----
 include/hw/acpi/memory_hotplug.h    |  5 +++++
 include/hw/acpi/pc-hotplug.h        |  2 --
 7 files changed, 16 insertions(+), 31 deletions(-)
 delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index ea308ab..e370233 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -22,7 +22,7 @@
 #define MEMORY_SLOT_LOCK             "MLCK"
 #define MEMORY_SLOT_SLECTOR          "MSEL"
 
-#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
+#define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
 
 void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
                 uint16_t io_base, uint16_t io_len)
@@ -36,7 +36,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
 
     /* scope for memory hotplug controller device node */
     assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
-    ctrl_dev = aml_device("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
+    ctrl_dev = aml_device("\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE);
     {
         Aml *crs, *field;
         Aml *a_slot_arg = aml_arg(0);
@@ -98,7 +98,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
 
         aml_append(ctrl_dev, aml_mutex(MEMORY_SLOT_LOCK, 0));
 
-        method = aml_method(stringify(MEMORY_SLOT_SCAN_METHOD), 0);
+        method = aml_method(MEMORY_SLOT_SCAN_METHOD, 0);
         {
             Aml *a_idx = aml_local(0);
 
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index c929540..1bdae78 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -935,6 +935,14 @@ build_ssdt(GArray *table_data, GArray *linker,
     aml_append(sb_scope, method);
     aml_append(ssdt, sb_scope);
 
+    scope =  aml_scope("\\_GPE");
+    if (nr_mem) {
+        method = aml_method("_E03", 0);
+        aml_append(method, aml_call0(MEMORY_HOTPLUG_HANDLER_PATH));
+        aml_append(scope, method);
+    }
+    aml_append(ssdt, scope);
+
     /* Extra PCI root buses are implemented  only for i440fx */
     bus = find_i440fx();
     if (bus) {
diff --git a/hw/i386/acpi-dsdt-mem-hotplug.dsl b/hw/i386/acpi-dsdt-mem-hotplug.dsl
deleted file mode 100644
index 20c5ec1..0000000
--- a/hw/i386/acpi-dsdt-mem-hotplug.dsl
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-    External(\_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD, MethodObj)
diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
index 6d46b36..203863f 100644
--- a/hw/i386/acpi-dsdt.dsl
+++ b/hw/i386/acpi-dsdt.dsl
@@ -250,7 +250,6 @@ DefinitionBlock (
 #include "hw/acpi/pc-hotplug.h"
 #define CPU_STATUS_BASE PIIX4_CPU_HOTPLUG_IO_BASE
 #include "acpi-dsdt-cpu-hotplug.dsl"
-#include "acpi-dsdt-mem-hotplug.dsl"
 
 
 /****************************************************************
@@ -271,10 +270,6 @@ DefinitionBlock (
             // CPU hotplug event
             \_SB.PRSC()
         }
-        Method(_E03) {
-            // Memory hotplug event
-            \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD()
-        }
         Method(_L04) {
         }
         Method(_L05) {
diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
index ecefdec..ca2d25d 100644
--- a/hw/i386/q35-acpi-dsdt.dsl
+++ b/hw/i386/q35-acpi-dsdt.dsl
@@ -387,7 +387,6 @@ DefinitionBlock (
 #include "hw/acpi/pc-hotplug.h"
 #define CPU_STATUS_BASE ICH9_CPU_HOTPLUG_IO_BASE
 #include "acpi-dsdt-cpu-hotplug.dsl"
-#include "acpi-dsdt-mem-hotplug.dsl"
 
 
 /****************************************************************
@@ -404,10 +403,6 @@ DefinitionBlock (
             // CPU hotplug event
             \_SB.PRSC()
         }
-        Method(_E03) {
-            // Memory hotplug event
-            \_SB.PCI0.MEMORY_HOTPLUG_DEVICE.MEMORY_SLOT_SCAN_METHOD()
-        }
         Method(_L04) {
         }
         Method(_L05) {
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 5fd2854..a107b9b 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -46,6 +46,11 @@ extern const VMStateDescription vmstate_memory_hotplug;
 
 void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
+#define MEMORY_HOTPLUG_DEVICE        "MHPD"
+#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
+#define MEMORY_HOTPLUG_HANDLER_PATH  "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "." \
+    MEMORY_SLOT_SCAN_METHOD
+
 void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
                 uint16_t io_base, uint16_t io_len);
 #endif
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 29f0244..65e7d3b 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -32,8 +32,6 @@
 #define ACPI_MEMORY_HOTPLUG_IO_LEN 24
 #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
 
-#define MEMORY_HOTPLUG_DEVICE        MHPD
 #define MEMORY_HOTPLUG_IO_REGION     HPMR
-#define MEMORY_SLOT_SCAN_METHOD      MSCN
 
 #endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 19/19] pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (17 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 18/19] pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03 into SSDT Igor Mammedov
@ 2015-10-23 14:57 ` Igor Mammedov
  2015-10-23 16:38 ` [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Laszlo Ersek
  2015-10-24 17:39 ` Michael S. Tsirkin
  20 siblings, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-23 14:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, mst

MEMORY_HOTPLUG_IO_REGION isn't used anywhere else except of
memory_hotplug_acpi_table.c, so move it there and cleanup
stringify() ugliness

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug_acpi_table.c | 10 +++++-----
 include/hw/acpi/pc-hotplug.h        |  2 --
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
index e370233..14df930 100644
--- a/hw/acpi/memory_hotplug_acpi_table.c
+++ b/hw/acpi/memory_hotplug_acpi_table.c
@@ -21,6 +21,7 @@
 #define MEMORY_SLOT_SIZE             "MRL"
 #define MEMORY_SLOT_LOCK             "MLCK"
 #define MEMORY_SLOT_SLECTOR          "MSEL"
+#define MEMORY_HOTPLUG_IO_REGION     "HPMR"
 
 #define BASEPATH "\\_SB.PCI0." MEMORY_HOTPLUG_DEVICE "."
 
@@ -53,11 +54,10 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
         aml_append(ctrl_dev, aml_name_decl("_CRS", crs));
 
         aml_append(ctrl_dev, aml_operation_region(
-            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
-            io_base, io_len)
+            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO, io_base, io_len)
         );
 
-        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
+        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
                           AML_PRESERVE);
         aml_append(field, /* read only */
             aml_named_field(MEMORY_SLOT_ADDR, 64));
@@ -67,7 +67,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_named_field(MEMORY_SLOT_PROXIMITY, 32));
         aml_append(ctrl_dev, field);
 
-        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
+        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_BYTE_ACC,
                           AML_WRITE_AS_ZEROS);
         aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
         aml_append(field, /* 1 if enabled, read only */
@@ -83,7 +83,7 @@ void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
             aml_named_field(MEMORY_SLOT_EJECT, 1));
         aml_append(ctrl_dev, field);
 
-        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
+        field = aml_field(MEMORY_HOTPLUG_IO_REGION, AML_DWORD_ACC,
                           AML_PRESERVE);
         aml_append(field, /* DIMM selector, write only */
             aml_named_field(MEMORY_SLOT_SLECTOR, 32));
diff --git a/include/hw/acpi/pc-hotplug.h b/include/hw/acpi/pc-hotplug.h
index 65e7d3b..a4f513d 100644
--- a/include/hw/acpi/pc-hotplug.h
+++ b/include/hw/acpi/pc-hotplug.h
@@ -32,6 +32,4 @@
 #define ACPI_MEMORY_HOTPLUG_IO_LEN 24
 #define ACPI_MEMORY_HOTPLUG_BASE 0x0a00
 
-#define MEMORY_HOTPLUG_IO_REGION     HPMR
-
 #endif
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (18 preceding siblings ...)
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 19/19] pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage Igor Mammedov
@ 2015-10-23 16:38 ` Laszlo Ersek
  2015-10-24 17:39 ` Michael S. Tsirkin
  20 siblings, 0 replies; 32+ messages in thread
From: Laszlo Ersek @ 2015-10-23 16:38 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: Peter Maydell, pbonzini, mst

Igor,

On 10/23/15 16:57, Igor Mammedov wrote:
> As part of moving to dynamic DSDT and dropping
> ASL templates althogether this series moves out
> ASL part of memory hotplug from DSDT into a custom
> ACPI table. Beside of reducing ASL codebase (DSDT)
> series tries to generalize and consolidate ACPI
> part of memory hotplug code so it could be easier
> to reuse it with outher targets (I plan to do it
> for ARM later).
> 
> New table uses 64-bit integers for simplification
> of code that are available only since ACPI 2.0.
> To avoid breaking Windows XP based (rev1) guests
> that table is loaded only if guest supports 2.0
> revision Using LoadTable() ASL method.

Please consider CC'ing me on future ACPI patches -- it's risky to hope
that (or not to care if) I notice them automatically.

In particular, it's great that Windows supports LoadTable(), *but* the
following requirement of the ACPI spec:

    Any table referenced by LoadTable must be in memory marked by
    AddressRangeReserved or AddressRangeNVS.

needs extra care if you'd like this to work under OVMF.

In fact this topic shares a whole bunch of details with our pending
DataTableRegion / VMGenID design:

http://thread.gmane.org/gmane.comp.emulators.qemu/357940/focus=361701

and for OVMF's linker/loader (and for edk2's generic
EFI_ACPI_TABLE_PROTOCOL) to work with this, you'd have to jump through
almost the same hoops.

In particular, the new ACPI table should have signature "UEFI" (to make
sure EFI_ACPI_TABLE_PROTOCOL allocates it in AcpiNVS). In addition, that
signature dictates a data table structure (with a few extra fixed
headers), not a definition block, according to the UEFI spec Appendix O.

So, I'm not sure this can be made work with OVMF at all, if we'd like to
respect all relevant specs (and existing code).

... I wonder when we'll *finally* bite the bullet, and say, "if you want
XP to work, then simply don't specify this feature on the QEMU command
line, otherwise XP will crash".

We could simply create a text file under docs/, and collect all the
features / cmdline switches that are *expressly* incompatible with
Windows XP. (CC'ing Peter.)

For this memory hotplug feature, the direct consequence would be that
you could separate out the MHPT stuff into a new *SSDT* instead, and
everything would just work automatically with OVMF as well.

Of course I can also accept if the consensus is to ignore OVMF...

Thanks
Laszlo

> 
> As a side effect of code consolidation/simplification
> series reduces ACPI tables size on:
>  - 879 bytes without memory hotplug
>  - 1216 bytes with 256 hotpluggable memory slots
> 
> More detailed breakdown on max table sizes in default
> and hotplug enabled cases:
>      new+HP  new    old   old+HP
> MHPT 50808   -       -    -
> SSDT 2425    2368   2486  53688
> DSDT 2267    2267   3028  3028
> 
> Tested with following guests:
>  - RHEL7.2,
>  - Windows XPsp3, Windows Server 2003EE,
>  - Windows Server 2008DC, Windows Server 2012R2DC
> 
> Since memory hotpulg doesn't work on XP based guests,
> I've just tested that it boots just fine with/without
> memory hotplug enabled on QEMU side.
> The rest of the guests work as expected.
> 
> git tree for testing:
> https://github.com/imammedo/qemu/commits/mhpt_table_v1
> 
> Igor Mammedov (18):
>   acpi: aml: add aml_lgreater_equal() and aml_load_table()
>   acpi: aml: add aml_create_qword_field()
>   acpi: aml: add aml_decrement() and aml_subtract()
>   acpi: aml: add aml_call0() helper
>   pc: acpi: move SSDT part of memhp into a custom table
>   pc: acpi: memhp: move MHPD._STA method into MHPT table
>   pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table
>   pc: acpi: memhp: move MHPD.MSCN method into MHPT table
>   pc: acpi: make memory device's _UID integer
>   pc: acpi: memhp: move MHPD.MRST method into MHPT table
>   pc: acpi: memhp: move MHPD.MPXM method into MHPT table
>   pc: acpi: memhp: move MHPD.MOST method into MHPT table
>   pc: acpi: memhp: move MHPD.MEJ0 method into MHPT table
>   pc: acpi: bump DSDT revision compliance to v2
>   pc: acpi: memhp: move MHPD.MCRS method into MHPT table
>   pc: acpi: memhp: move MHPD Device along with _UID/_HID into MHPT table
>   pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03
>     into SSDT
>   pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage
> 
> Xiao Guangrong (1):
>   acpi: add aml_mutex(), aml_acquire(), aml_release()
> 
>  hw/acpi/Makefile.objs               |   2 +-
>  hw/acpi/aml-build.c                 | 115 ++++++++++++++-
>  hw/acpi/memory_hotplug_acpi_table.c | 286 ++++++++++++++++++++++++++++++++++++
>  hw/i386/acpi-build.c                | 140 ++++--------------
>  hw/i386/acpi-dsdt-mem-hotplug.dsl   | 171 ---------------------
>  hw/i386/acpi-dsdt.dsl               |   7 +-
>  hw/i386/q35-acpi-dsdt.dsl           |   7 +-
>  include/hw/acpi/aml-build.h         |   9 ++
>  include/hw/acpi/memory_hotplug.h    |   8 +
>  include/hw/acpi/pc-hotplug.h        |  24 ---
>  10 files changed, 443 insertions(+), 326 deletions(-)
>  create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
>  delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table
  2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
                   ` (19 preceding siblings ...)
  2015-10-23 16:38 ` [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Laszlo Ersek
@ 2015-10-24 17:39 ` Michael S. Tsirkin
  20 siblings, 0 replies; 32+ messages in thread
From: Michael S. Tsirkin @ 2015-10-24 17:39 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pbonzini, qemu-devel

On Fri, Oct 23, 2015 at 04:57:03PM +0200, Igor Mammedov wrote:
> As part of moving to dynamic DSDT and dropping
> ASL templates althogether

If this is indeed what we are trying to do, I would rather have it
factored differently:

1. rewrite ASL parts in C, no code changes
   (existing tests should pass!)
2. rework to split it up gradually

Makes it much easier to be sure there aren't bugs
introduced in this rework.



> this series moves out
> ASL part of memory hotplug from DSDT into a custom
> ACPI table. Beside of reducing ASL codebase (DSDT)
> series tries to generalize and consolidate ACPI
> part of memory hotplug code so it could be easier
> to reuse it with outher targets (I plan to do it
> for ARM later).
> 
> New table uses 64-bit integers for simplification
> of code that are available only since ACPI 2.0.
> To avoid breaking Windows XP based (rev1) guests
> that table is loaded only if guest supports 2.0
> revision Using LoadTable() ASL method.
> As a side effect of code consolidation/simplification
> series reduces ACPI tables size on:
>  - 879 bytes without memory hotplug
>  - 1216 bytes with 256 hotpluggable memory slots
> 
> More detailed breakdown on max table sizes in default
> and hotplug enabled cases:
>      new+HP  new    old   old+HP
> MHPT 50808   -       -    -
> SSDT 2425    2368   2486  53688
> DSDT 2267    2267   3028  3028
> 
> Tested with following guests:
>  - RHEL7.2,
>  - Windows XPsp3, Windows Server 2003EE,
>  - Windows Server 2008DC, Windows Server 2012R2DC
> 
> Since memory hotpulg doesn't work on XP based guests,
> I've just tested that it boots just fine with/without
> memory hotplug enabled on QEMU side.
> The rest of the guests work as expected.
> 
> git tree for testing:
> https://github.com/imammedo/qemu/commits/mhpt_table_v1
> 
> Igor Mammedov (18):
>   acpi: aml: add aml_lgreater_equal() and aml_load_table()
>   acpi: aml: add aml_create_qword_field()
>   acpi: aml: add aml_decrement() and aml_subtract()
>   acpi: aml: add aml_call0() helper
>   pc: acpi: move SSDT part of memhp into a custom table
>   pc: acpi: memhp: move MHPD._STA method into MHPT table
>   pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table
>   pc: acpi: memhp: move MHPD.MSCN method into MHPT table
>   pc: acpi: make memory device's _UID integer
>   pc: acpi: memhp: move MHPD.MRST method into MHPT table
>   pc: acpi: memhp: move MHPD.MPXM method into MHPT table
>   pc: acpi: memhp: move MHPD.MOST method into MHPT table
>   pc: acpi: memhp: move MHPD.MEJ0 method into MHPT table
>   pc: acpi: bump DSDT revision compliance to v2
>   pc: acpi: memhp: move MHPD.MCRS method into MHPT table
>   pc: acpi: memhp: move MHPD Device along with _UID/_HID into MHPT table
>   pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03
>     into SSDT
>   pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage
> 
> Xiao Guangrong (1):
>   acpi: add aml_mutex(), aml_acquire(), aml_release()
> 
>  hw/acpi/Makefile.objs               |   2 +-
>  hw/acpi/aml-build.c                 | 115 ++++++++++++++-
>  hw/acpi/memory_hotplug_acpi_table.c | 286 ++++++++++++++++++++++++++++++++++++
>  hw/i386/acpi-build.c                | 140 ++++--------------
>  hw/i386/acpi-dsdt-mem-hotplug.dsl   | 171 ---------------------
>  hw/i386/acpi-dsdt.dsl               |   7 +-
>  hw/i386/q35-acpi-dsdt.dsl           |   7 +-
>  include/hw/acpi/aml-build.h         |   9 ++
>  include/hw/acpi/memory_hotplug.h    |   8 +
>  include/hw/acpi/pc-hotplug.h        |  24 ---
>  10 files changed, 443 insertions(+), 326 deletions(-)
>  create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
>  delete mode 100644 hw/i386/acpi-dsdt-mem-hotplug.dsl
> 
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table Igor Mammedov
@ 2015-10-24 17:41   ` Michael S. Tsirkin
  2015-10-24 17:59   ` Michael S. Tsirkin
  2015-10-24 19:37   ` Michael S. Tsirkin
  2 siblings, 0 replies; 32+ messages in thread
From: Michael S. Tsirkin @ 2015-10-24 17:41 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pbonzini, qemu-devel

On Fri, Oct 23, 2015 at 04:57:09PM +0200, Igor Mammedov wrote:
> +    /* copy AML table into ACPI tables blob and patch header there */
> +    g_array_append_vals(table_data, table->buf->data, table->buf->len);
> +    build_header(linker, table_data,
> +        (void *)(table_data->data + table_data->len - table->buf->len),
> +        "MHPT", table->buf->len, 2);
> +    free_aml_allocator();
> +}

Why not just put this in an SSDT?
And what guarantees that there won't be an MHPT table
in a future version of the spec, conflicting with this use?

-- 
MST

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table Igor Mammedov
  2015-10-24 17:41   ` Michael S. Tsirkin
@ 2015-10-24 17:59   ` Michael S. Tsirkin
  2015-10-25 13:33     ` Laszlo Ersek
  2015-10-26 13:36     ` Igor Mammedov
  2015-10-24 19:37   ` Michael S. Tsirkin
  2 siblings, 2 replies; 32+ messages in thread
From: Michael S. Tsirkin @ 2015-10-24 17:59 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pbonzini, lersek, qemu-devel

On Fri, Oct 23, 2015 at 04:57:09PM +0200, Igor Mammedov wrote:
> moves SSDT part to custom MHPT table, which is loaded
> at runtime by OSPM if it supports ACPIv2 revision and
> only if memory hotplug is enabled.
> That should reduce ACPI tables blob size if memory
> hotplug is not enabled (default case).

With seabios, it's still in reserved memory. How does it help?

And this trick likely breaks UEFI.

I just checked, the only legal way to specify OEM
specific tables seems to be using OEMX prefix.

But there's a decent chance this will conflict with
people using command line flags to load their own
tables.

This likely means this trick is off.



> Checked for compatibility issues with:
>  * Windows XPsp3, Windows Server 2003: they don't load
>    the table as OSPM only reports revision 1 as supported.
>    And we don't care about memhp for these guests as they
>    do not support it anyway.
>  * Windows Server 2008, Windows Server 2008R2:
>    works as expected
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/acpi/Makefile.objs               |   2 +-
>  hw/acpi/memory_hotplug_acpi_table.c | 138 ++++++++++++++++++++++++++++++++++++
>  hw/i386/acpi-build.c                | 130 +++++----------------------------
>  include/hw/acpi/memory_hotplug.h    |   3 +
>  4 files changed, 159 insertions(+), 114 deletions(-)
>  create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
> 
> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index 7d3230c..c04064e 100644
> --- a/hw/acpi/Makefile.objs
> +++ b/hw/acpi/Makefile.objs
> @@ -1,7 +1,7 @@
>  common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
>  common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
> -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
> +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o
>  common-obj-$(CONFIG_ACPI) += acpi_interface.o
>  common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
>  common-obj-$(CONFIG_ACPI) += aml-build.o
> diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
> new file mode 100644
> index 0000000..28da13c
> --- /dev/null
> +++ b/hw/acpi/memory_hotplug_acpi_table.c
> @@ -0,0 +1,138 @@
> +#include <stdbool.h>
> +#include "hw/acpi/aml-build.h"
> +#include "hw/acpi/memory_hotplug.h"
> +#include "include/hw/acpi/pc-hotplug.h"
> +#include "hw/boards.h"
> +
> +#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
> +
> +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
> +                uint16_t io_base, uint16_t io_len)
> +{
> +    int i;
> +    Aml *table, *sb_scope, *dev, *method, *ifctx, *ctrl_dev;
> +
> +    table = init_aml_allocator();
> +    acpi_data_push(table->buf, sizeof(AcpiTableHeader));
> +
> +    /* scope for memory hotplug controller device node */
> +    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> +    ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
> +    {
> +        Aml *crs, *field;
> +
> +        aml_append(ctrl_dev,
> +            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
> +        );
> +
> +        crs = aml_resource_template();
> +        aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
> +        aml_append(ctrl_dev, aml_name_decl("_CRS", crs));
> +
> +        aml_append(ctrl_dev, aml_operation_region(
> +            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
> +            io_base, io_len)
> +        );
> +
> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> +                          AML_PRESERVE);
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
> +        aml_append(ctrl_dev, field);
> +
> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
> +                          AML_WRITE_AS_ZEROS);
> +        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> +        aml_append(field, /* 1 if enabled, read only */
> +            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
> +        aml_append(field,
> +            /*(read) 1 if has a insert event. (write) 1 to clear event */
> +            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
> +        aml_append(field,
> +            /* (read) 1 if has a remove event. (write) 1 to clear event */
> +            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
> +        aml_append(field,
> +            /* initiates device eject, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
> +        aml_append(ctrl_dev, field);
> +
> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> +                          AML_PRESERVE);
> +        aml_append(field, /* DIMM selector, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
> +        aml_append(field, /* _OST event code, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
> +        aml_append(field, /* _OST status code, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
> +        aml_append(ctrl_dev, field);
> +    }
> +    aml_append(table, ctrl_dev);
> +
> +    sb_scope = aml_scope("\\_SB");
> +    for (i = 0; i < nr_mem; i++) {
> +        const char *s;
> +
> +        dev = aml_device("MP%02X", i);
> +        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> +        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> +
> +        method = aml_method("_CRS", 0);
> +        s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_STA", 0);
> +        s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_PXM", 0);
> +        s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_OST", 3);
> +        s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
> +        aml_append(method, aml_return(aml_call4(
> +            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> +        )));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_EJ0", 1);
> +        s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
> +        aml_append(method, aml_return(aml_call2(
> +                   s, aml_name("_UID"), aml_arg(0))));
> +        aml_append(dev, method);
> +
> +        aml_append(sb_scope, dev);
> +    }
> +
> +    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> +     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> +     */
> +    method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
> +    for (i = 0; i < nr_mem; i++) {
> +        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> +        aml_append(ifctx,
> +            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> +        );
> +        aml_append(method, ifctx);
> +    }
> +    aml_append(sb_scope, method);
> +    aml_append(table, sb_scope);
> +
> +    /* copy AML table into ACPI tables blob and patch header there */
> +    g_array_append_vals(table_data, table->buf->data, table->buf->len);
> +    build_header(linker, table_data,
> +        (void *)(table_data->data + table_data->len - table->buf->len),
> +        "MHPT", table->buf->len, 2);
> +    free_aml_allocator();
> +}
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 95e0c65..8add4d9 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -925,6 +925,16 @@ build_ssdt(GArray *table_data, GArray *linker,
>      /* Reserve space for header */
>      acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
>  
> +    sb_scope = aml_scope("\\_SB");
> +    method = aml_method("_INI", 0);
> +    ifctx = aml_if(aml_lgreater_equal(aml_name("_REV"), aml_int(2)));
> +    if (nr_mem) {
> +        aml_append(ifctx, aml_load_table("MHPT"));
> +    }
> +    aml_append(method, ifctx);
> +    aml_append(sb_scope, method);
> +    aml_append(ssdt, sb_scope);
> +
>      /* Extra PCI root buses are implemented  only for i440fx */
>      bus = find_i440fx();
>      if (bus) {
> @@ -1200,119 +1210,6 @@ build_ssdt(GArray *table_data, GArray *linker,
>          }
>          aml_append(sb_scope, aml_name_decl("CPON", pkg));
>  
> -        /* build memory devices */
> -        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> -        scope = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
> -        aml_append(scope,
> -            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
> -        );
> -
> -        crs = aml_resource_template();
> -        aml_append(crs,
> -            aml_io(AML_DECODE16, pm->mem_hp_io_base, pm->mem_hp_io_base, 0,
> -                   pm->mem_hp_io_len)
> -        );
> -        aml_append(scope, aml_name_decl("_CRS", crs));
> -
> -        aml_append(scope, aml_operation_region(
> -            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
> -            pm->mem_hp_io_base, pm->mem_hp_io_len)
> -        );
> -
> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> -                          AML_PRESERVE);
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
> -        aml_append(scope, field);
> -
> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
> -                          AML_WRITE_AS_ZEROS);
> -        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> -        aml_append(field, /* 1 if enabled, read only */
> -            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
> -        aml_append(field,
> -            /*(read) 1 if has a insert event. (write) 1 to clear event */
> -            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
> -        aml_append(field,
> -            /* (read) 1 if has a remove event. (write) 1 to clear event */
> -            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
> -        aml_append(field,
> -            /* initiates device eject, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
> -        aml_append(scope, field);
> -
> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> -                          AML_PRESERVE);
> -        aml_append(field, /* DIMM selector, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
> -        aml_append(field, /* _OST event code, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
> -        aml_append(field, /* _OST status code, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
> -        aml_append(scope, field);
> -
> -        aml_append(sb_scope, scope);
> -
> -        for (i = 0; i < nr_mem; i++) {
> -            #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
> -            const char *s;
> -
> -            dev = aml_device("MP%02X", i);
> -            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> -            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> -
> -            method = aml_method("_CRS", 0);
> -            s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_STA", 0);
> -            s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_PXM", 0);
> -            s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_OST", 3);
> -            s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
> -            aml_append(method, aml_return(aml_call4(
> -                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> -            )));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_EJ0", 1);
> -            s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
> -            aml_append(method, aml_return(aml_call2(
> -                       s, aml_name("_UID"), aml_arg(0))));
> -            aml_append(dev, method);
> -
> -            aml_append(sb_scope, dev);
> -        }
> -
> -        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> -         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> -         */
> -        method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
> -        for (i = 0; i < nr_mem; i++) {
> -            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> -            aml_append(ifctx,
> -                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> -            );
> -            aml_append(method, ifctx);
> -        }
> -        aml_append(sb_scope, method);
> -
>          {
>              Object *pci_host;
>              PCIBus *bus = NULL;
> @@ -1671,6 +1568,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>      uint8_t *u;
>      size_t aml_len = 0;
>      GArray *tables_blob = tables->table_data;
> +    MachineState *machine = MACHINE(qdev_get_machine());
>  
>      acpi_get_cpu_info(&cpu);
>      acpi_get_pm_info(&pm);
> @@ -1742,6 +1640,12 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>          build_dmar_q35(tables_blob, tables->linker);
>      }
>  
> +    if (machine->ram_slots) {
> +        acpi_add_table(table_offsets, tables_blob);
> +        build_mhpt(tables_blob, tables->linker, machine->ram_slots,
> +                   pm.mem_hp_io_base, pm.mem_hp_io_len);
> +    }
> +
>      /* Add tables supplied by user (if any) */
>      for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
>          unsigned len = acpi_table_len(u);
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index 1342adb..5fd2854 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -45,4 +45,7 @@ extern const VMStateDescription vmstate_memory_hotplug;
>                     vmstate_memory_hotplug, MemHotplugState)
>  
>  void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
> +
> +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
> +                uint16_t io_base, uint16_t io_len);
>  #endif
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table Igor Mammedov
  2015-10-24 17:41   ` Michael S. Tsirkin
  2015-10-24 17:59   ` Michael S. Tsirkin
@ 2015-10-24 19:37   ` Michael S. Tsirkin
  2 siblings, 0 replies; 32+ messages in thread
From: Michael S. Tsirkin @ 2015-10-24 19:37 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pbonzini, qemu-devel

On Fri, Oct 23, 2015 at 04:57:09PM +0200, Igor Mammedov wrote:
> moves SSDT part to custom MHPT table, which is loaded
> at runtime by OSPM if it supports ACPIv2 revision and
> only if memory hotplug is enabled.
> That should reduce ACPI tables blob size if memory
> hotplug is not enabled (default case).
> 
> Checked for compatibility issues with:
>  * Windows XPsp3, Windows Server 2003: they don't load
>    the table as OSPM only reports revision 1 as supported.
>    And we don't care about memhp for these guests as they
>    do not support it anyway.
>  * Windows Server 2008, Windows Server 2008R2:
>    works as expected
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  hw/acpi/Makefile.objs               |   2 +-
>  hw/acpi/memory_hotplug_acpi_table.c | 138 ++++++++++++++++++++++++++++++++++++
>  hw/i386/acpi-build.c                | 130 +++++----------------------------
>  include/hw/acpi/memory_hotplug.h    |   3 +
>  4 files changed, 159 insertions(+), 114 deletions(-)
>  create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
> 
> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index 7d3230c..c04064e 100644
> --- a/hw/acpi/Makefile.objs
> +++ b/hw/acpi/Makefile.objs
> @@ -1,7 +1,7 @@
>  common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
>  common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
> -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
> +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o
>  common-obj-$(CONFIG_ACPI) += acpi_interface.o
>  common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
>  common-obj-$(CONFIG_ACPI) += aml-build.o
> diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
> new file mode 100644
> index 0000000..28da13c

This diff is pretty hard to read. Isn't there some way
you could refactor this to make the diff smaller?
E.g. move the part that isn't changed into
a function first, then call it from a different place.

> --- /dev/null
> +++ b/hw/acpi/memory_hotplug_acpi_table.c
> @@ -0,0 +1,138 @@
> +#include <stdbool.h>
> +#include "hw/acpi/aml-build.h"
> +#include "hw/acpi/memory_hotplug.h"
> +#include "include/hw/acpi/pc-hotplug.h"
> +#include "hw/boards.h"
> +
> +#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
> +
> +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
> +                uint16_t io_base, uint16_t io_len)
> +{
> +    int i;
> +    Aml *table, *sb_scope, *dev, *method, *ifctx, *ctrl_dev;
> +
> +    table = init_aml_allocator();
> +    acpi_data_push(table->buf, sizeof(AcpiTableHeader));
> +
> +    /* scope for memory hotplug controller device node */
> +    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> +    ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
> +    {
> +        Aml *crs, *field;
> +
> +        aml_append(ctrl_dev,
> +            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
> +        );
> +
> +        crs = aml_resource_template();
> +        aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
> +        aml_append(ctrl_dev, aml_name_decl("_CRS", crs));
> +
> +        aml_append(ctrl_dev, aml_operation_region(
> +            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
> +            io_base, io_len)
> +        );
> +
> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> +                          AML_PRESERVE);
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
> +        aml_append(field, /* read only */
> +            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
> +        aml_append(ctrl_dev, field);
> +
> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
> +                          AML_WRITE_AS_ZEROS);
> +        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> +        aml_append(field, /* 1 if enabled, read only */
> +            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
> +        aml_append(field,
> +            /*(read) 1 if has a insert event. (write) 1 to clear event */
> +            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
> +        aml_append(field,
> +            /* (read) 1 if has a remove event. (write) 1 to clear event */
> +            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
> +        aml_append(field,
> +            /* initiates device eject, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
> +        aml_append(ctrl_dev, field);
> +
> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> +                          AML_PRESERVE);
> +        aml_append(field, /* DIMM selector, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
> +        aml_append(field, /* _OST event code, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
> +        aml_append(field, /* _OST status code, write only */
> +            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
> +        aml_append(ctrl_dev, field);
> +    }
> +    aml_append(table, ctrl_dev);
> +
> +    sb_scope = aml_scope("\\_SB");
> +    for (i = 0; i < nr_mem; i++) {
> +        const char *s;
> +
> +        dev = aml_device("MP%02X", i);
> +        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> +        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> +
> +        method = aml_method("_CRS", 0);
> +        s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_STA", 0);
> +        s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_PXM", 0);
> +        s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_OST", 3);
> +        s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
> +        aml_append(method, aml_return(aml_call4(
> +            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> +        )));
> +        aml_append(dev, method);
> +
> +        method = aml_method("_EJ0", 1);
> +        s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
> +        aml_append(method, aml_return(aml_call2(
> +                   s, aml_name("_UID"), aml_arg(0))));
> +        aml_append(dev, method);
> +
> +        aml_append(sb_scope, dev);
> +    }
> +
> +    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> +     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> +     */
> +    method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
> +    for (i = 0; i < nr_mem; i++) {
> +        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> +        aml_append(ifctx,
> +            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> +        );
> +        aml_append(method, ifctx);
> +    }
> +    aml_append(sb_scope, method);
> +    aml_append(table, sb_scope);
> +
> +    /* copy AML table into ACPI tables blob and patch header there */
> +    g_array_append_vals(table_data, table->buf->data, table->buf->len);
> +    build_header(linker, table_data,
> +        (void *)(table_data->data + table_data->len - table->buf->len),
> +        "MHPT", table->buf->len, 2);
> +    free_aml_allocator();
> +}
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 95e0c65..8add4d9 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -925,6 +925,16 @@ build_ssdt(GArray *table_data, GArray *linker,
>      /* Reserve space for header */
>      acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
>  
> +    sb_scope = aml_scope("\\_SB");
> +    method = aml_method("_INI", 0);
> +    ifctx = aml_if(aml_lgreater_equal(aml_name("_REV"), aml_int(2)));
> +    if (nr_mem) {
> +        aml_append(ifctx, aml_load_table("MHPT"));
> +    }
> +    aml_append(method, ifctx);
> +    aml_append(sb_scope, method);
> +    aml_append(ssdt, sb_scope);
> +
>      /* Extra PCI root buses are implemented  only for i440fx */
>      bus = find_i440fx();
>      if (bus) {
> @@ -1200,119 +1210,6 @@ build_ssdt(GArray *table_data, GArray *linker,
>          }
>          aml_append(sb_scope, aml_name_decl("CPON", pkg));
>  
> -        /* build memory devices */
> -        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> -        scope = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
> -        aml_append(scope,
> -            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
> -        );
> -
> -        crs = aml_resource_template();
> -        aml_append(crs,
> -            aml_io(AML_DECODE16, pm->mem_hp_io_base, pm->mem_hp_io_base, 0,
> -                   pm->mem_hp_io_len)
> -        );
> -        aml_append(scope, aml_name_decl("_CRS", crs));
> -
> -        aml_append(scope, aml_operation_region(
> -            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
> -            pm->mem_hp_io_base, pm->mem_hp_io_len)
> -        );
> -
> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> -                          AML_PRESERVE);
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
> -        aml_append(field, /* read only */
> -            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
> -        aml_append(scope, field);
> -
> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
> -                          AML_WRITE_AS_ZEROS);
> -        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> -        aml_append(field, /* 1 if enabled, read only */
> -            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
> -        aml_append(field,
> -            /*(read) 1 if has a insert event. (write) 1 to clear event */
> -            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
> -        aml_append(field,
> -            /* (read) 1 if has a remove event. (write) 1 to clear event */
> -            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
> -        aml_append(field,
> -            /* initiates device eject, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
> -        aml_append(scope, field);
> -
> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> -                          AML_PRESERVE);
> -        aml_append(field, /* DIMM selector, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
> -        aml_append(field, /* _OST event code, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
> -        aml_append(field, /* _OST status code, write only */
> -            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
> -        aml_append(scope, field);
> -
> -        aml_append(sb_scope, scope);
> -
> -        for (i = 0; i < nr_mem; i++) {
> -            #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
> -            const char *s;
> -
> -            dev = aml_device("MP%02X", i);
> -            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> -            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> -
> -            method = aml_method("_CRS", 0);
> -            s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_STA", 0);
> -            s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_PXM", 0);
> -            s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_OST", 3);
> -            s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
> -            aml_append(method, aml_return(aml_call4(
> -                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> -            )));
> -            aml_append(dev, method);
> -
> -            method = aml_method("_EJ0", 1);
> -            s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
> -            aml_append(method, aml_return(aml_call2(
> -                       s, aml_name("_UID"), aml_arg(0))));
> -            aml_append(dev, method);
> -
> -            aml_append(sb_scope, dev);
> -        }
> -
> -        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> -         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> -         */
> -        method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
> -        for (i = 0; i < nr_mem; i++) {
> -            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> -            aml_append(ifctx,
> -                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> -            );
> -            aml_append(method, ifctx);
> -        }
> -        aml_append(sb_scope, method);
> -
>          {
>              Object *pci_host;
>              PCIBus *bus = NULL;
> @@ -1671,6 +1568,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>      uint8_t *u;
>      size_t aml_len = 0;
>      GArray *tables_blob = tables->table_data;
> +    MachineState *machine = MACHINE(qdev_get_machine());
>  
>      acpi_get_cpu_info(&cpu);
>      acpi_get_pm_info(&pm);
> @@ -1742,6 +1640,12 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>          build_dmar_q35(tables_blob, tables->linker);
>      }
>  
> +    if (machine->ram_slots) {
> +        acpi_add_table(table_offsets, tables_blob);
> +        build_mhpt(tables_blob, tables->linker, machine->ram_slots,
> +                   pm.mem_hp_io_base, pm.mem_hp_io_len);
> +    }
> +
>      /* Add tables supplied by user (if any) */
>      for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
>          unsigned len = acpi_table_len(u);
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index 1342adb..5fd2854 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -45,4 +45,7 @@ extern const VMStateDescription vmstate_memory_hotplug;
>                     vmstate_memory_hotplug, MemHotplugState)
>  
>  void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
> +
> +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
> +                uint16_t io_base, uint16_t io_len);
>  #endif
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
  2015-10-23 14:57 ` [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2 Igor Mammedov
@ 2015-10-24 19:40   ` Michael S. Tsirkin
  2015-10-26 10:03     ` Igor Mammedov
  0 siblings, 1 reply; 32+ messages in thread
From: Michael S. Tsirkin @ 2015-10-24 19:40 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pbonzini, qemu-devel

On Fri, Oct 23, 2015 at 04:57:18PM +0200, Igor Mammedov wrote:
> it turns on 64-bit integer handling in OSPM, which we could use
> for writing simpler/smaller AML code.
> Tested with Windows XP and Windows Server 2008, Linux:
>  * XP doesn't care about revision and continues to use 32 integers
>    and boots just fine with this change.
>  * WS 2008 and Linux - support rev2 and use 64-bit integers
> 
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

This is still planned, right? IIUC you didn't post any code
that needs the 64 bit math.

> ---
>  hw/i386/acpi-build.c      | 2 +-
>  hw/i386/acpi-dsdt.dsl     | 2 +-
>  hw/i386/q35-acpi-dsdt.dsl | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 8add4d9..c929540 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1484,7 +1484,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
>  
>      memset(dsdt, 0, sizeof *dsdt);
>      build_header(linker, table_data, dsdt, "DSDT",
> -                 misc->dsdt_size, 1);
> +                 misc->dsdt_size, 2);
>  }
>  
>  static GArray *
> diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> index 8dba096..6d46b36 100644
> --- a/hw/i386/acpi-dsdt.dsl
> +++ b/hw/i386/acpi-dsdt.dsl
> @@ -22,7 +22,7 @@ ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode
>  DefinitionBlock (
>      "acpi-dsdt.aml",    // Output Filename
>      "DSDT",             // Signature
> -    0x01,               // DSDT Compliance Revision
> +    0x02,               // DSDT Compliance Revision
>      "BXPC",             // OEMID
>      "BXDSDT",           // TABLE ID
>      0x1                 // OEM Revision
> diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> index 7be7b37..ecefdec 100644
> --- a/hw/i386/q35-acpi-dsdt.dsl
> +++ b/hw/i386/q35-acpi-dsdt.dsl
> @@ -28,7 +28,7 @@ ACPI_EXTRACT_ALL_CODE Q35AcpiDsdtAmlCode
>  DefinitionBlock (
>      "q35-acpi-dsdt.aml",// Output Filename
>      "DSDT",             // Signature
> -    0x01,               // DSDT Compliance Revision
> +    0x02,               // DSDT Compliance Revision
>      "BXPC",             // OEMID
>      "BXDSDT",           // TABLE ID
>      0x2                 // OEM Revision
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
  2015-10-24 17:59   ` Michael S. Tsirkin
@ 2015-10-25 13:33     ` Laszlo Ersek
  2015-10-26 13:36     ` Igor Mammedov
  1 sibling, 0 replies; 32+ messages in thread
From: Laszlo Ersek @ 2015-10-25 13:33 UTC (permalink / raw)
  To: Michael S. Tsirkin, Igor Mammedov; +Cc: pbonzini, qemu-devel

On 10/24/15 19:59, Michael S. Tsirkin wrote:
> On Fri, Oct 23, 2015 at 04:57:09PM +0200, Igor Mammedov wrote:
>> moves SSDT part to custom MHPT table, which is loaded
>> at runtime by OSPM if it supports ACPIv2 revision and
>> only if memory hotplug is enabled.
>> That should reduce ACPI tables blob size if memory
>> hotplug is not enabled (default case).
> 
> With seabios, it's still in reserved memory. How does it help?
> 
> And this trick likely breaks UEFI.

It does; see my response to the blurb.

In any case, I might send an email to the USWG list because I think
better cooperation is needed between the ACPI and UEFI specs for
supporting LoadTable and DataTableRegion. In particular,
EFI_ACPI_TABLE2_PROTOCOL.InstallTable() should take the EFI memory type
to install the table in. Luckily these two specs belong to the same
organization now.

Thanks
Laszlo

> I just checked, the only legal way to specify OEM
> specific tables seems to be using OEMX prefix.
> 
> But there's a decent chance this will conflict with
> people using command line flags to load their own
> tables.
> 
> This likely means this trick is off.
> 
> 
> 
>> Checked for compatibility issues with:
>>  * Windows XPsp3, Windows Server 2003: they don't load
>>    the table as OSPM only reports revision 1 as supported.
>>    And we don't care about memhp for these guests as they
>>    do not support it anyway.
>>  * Windows Server 2008, Windows Server 2008R2:
>>    works as expected
>>
>> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>> ---
>>  hw/acpi/Makefile.objs               |   2 +-
>>  hw/acpi/memory_hotplug_acpi_table.c | 138 ++++++++++++++++++++++++++++++++++++
>>  hw/i386/acpi-build.c                | 130 +++++----------------------------
>>  include/hw/acpi/memory_hotplug.h    |   3 +
>>  4 files changed, 159 insertions(+), 114 deletions(-)
>>  create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
>>
>> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
>> index 7d3230c..c04064e 100644
>> --- a/hw/acpi/Makefile.objs
>> +++ b/hw/acpi/Makefile.objs
>> @@ -1,7 +1,7 @@
>>  common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
>>  common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
>>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
>> -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
>> +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o
>>  common-obj-$(CONFIG_ACPI) += acpi_interface.o
>>  common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
>>  common-obj-$(CONFIG_ACPI) += aml-build.o
>> diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
>> new file mode 100644
>> index 0000000..28da13c
>> --- /dev/null
>> +++ b/hw/acpi/memory_hotplug_acpi_table.c
>> @@ -0,0 +1,138 @@
>> +#include <stdbool.h>
>> +#include "hw/acpi/aml-build.h"
>> +#include "hw/acpi/memory_hotplug.h"
>> +#include "include/hw/acpi/pc-hotplug.h"
>> +#include "hw/boards.h"
>> +
>> +#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
>> +
>> +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
>> +                uint16_t io_base, uint16_t io_len)
>> +{
>> +    int i;
>> +    Aml *table, *sb_scope, *dev, *method, *ifctx, *ctrl_dev;
>> +
>> +    table = init_aml_allocator();
>> +    acpi_data_push(table->buf, sizeof(AcpiTableHeader));
>> +
>> +    /* scope for memory hotplug controller device node */
>> +    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
>> +    ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
>> +    {
>> +        Aml *crs, *field;
>> +
>> +        aml_append(ctrl_dev,
>> +            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
>> +        );
>> +
>> +        crs = aml_resource_template();
>> +        aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
>> +        aml_append(ctrl_dev, aml_name_decl("_CRS", crs));
>> +
>> +        aml_append(ctrl_dev, aml_operation_region(
>> +            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
>> +            io_base, io_len)
>> +        );
>> +
>> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
>> +                          AML_PRESERVE);
>> +        aml_append(field, /* read only */
>> +            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
>> +        aml_append(field, /* read only */
>> +            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
>> +        aml_append(field, /* read only */
>> +            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
>> +        aml_append(field, /* read only */
>> +            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
>> +        aml_append(field, /* read only */
>> +            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
>> +        aml_append(ctrl_dev, field);
>> +
>> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
>> +                          AML_WRITE_AS_ZEROS);
>> +        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
>> +        aml_append(field, /* 1 if enabled, read only */
>> +            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
>> +        aml_append(field,
>> +            /*(read) 1 if has a insert event. (write) 1 to clear event */
>> +            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
>> +        aml_append(field,
>> +            /* (read) 1 if has a remove event. (write) 1 to clear event */
>> +            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
>> +        aml_append(field,
>> +            /* initiates device eject, write only */
>> +            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
>> +        aml_append(ctrl_dev, field);
>> +
>> +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
>> +                          AML_PRESERVE);
>> +        aml_append(field, /* DIMM selector, write only */
>> +            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
>> +        aml_append(field, /* _OST event code, write only */
>> +            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
>> +        aml_append(field, /* _OST status code, write only */
>> +            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
>> +        aml_append(ctrl_dev, field);
>> +    }
>> +    aml_append(table, ctrl_dev);
>> +
>> +    sb_scope = aml_scope("\\_SB");
>> +    for (i = 0; i < nr_mem; i++) {
>> +        const char *s;
>> +
>> +        dev = aml_device("MP%02X", i);
>> +        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
>> +        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
>> +
>> +        method = aml_method("_CRS", 0);
>> +        s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
>> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>> +        aml_append(dev, method);
>> +
>> +        method = aml_method("_STA", 0);
>> +        s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
>> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>> +        aml_append(dev, method);
>> +
>> +        method = aml_method("_PXM", 0);
>> +        s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
>> +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>> +        aml_append(dev, method);
>> +
>> +        method = aml_method("_OST", 3);
>> +        s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
>> +        aml_append(method, aml_return(aml_call4(
>> +            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
>> +        )));
>> +        aml_append(dev, method);
>> +
>> +        method = aml_method("_EJ0", 1);
>> +        s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
>> +        aml_append(method, aml_return(aml_call2(
>> +                   s, aml_name("_UID"), aml_arg(0))));
>> +        aml_append(dev, method);
>> +
>> +        aml_append(sb_scope, dev);
>> +    }
>> +
>> +    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
>> +     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
>> +     */
>> +    method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
>> +    for (i = 0; i < nr_mem; i++) {
>> +        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
>> +        aml_append(ifctx,
>> +            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
>> +        );
>> +        aml_append(method, ifctx);
>> +    }
>> +    aml_append(sb_scope, method);
>> +    aml_append(table, sb_scope);
>> +
>> +    /* copy AML table into ACPI tables blob and patch header there */
>> +    g_array_append_vals(table_data, table->buf->data, table->buf->len);
>> +    build_header(linker, table_data,
>> +        (void *)(table_data->data + table_data->len - table->buf->len),
>> +        "MHPT", table->buf->len, 2);
>> +    free_aml_allocator();
>> +}
>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>> index 95e0c65..8add4d9 100644
>> --- a/hw/i386/acpi-build.c
>> +++ b/hw/i386/acpi-build.c
>> @@ -925,6 +925,16 @@ build_ssdt(GArray *table_data, GArray *linker,
>>      /* Reserve space for header */
>>      acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
>>  
>> +    sb_scope = aml_scope("\\_SB");
>> +    method = aml_method("_INI", 0);
>> +    ifctx = aml_if(aml_lgreater_equal(aml_name("_REV"), aml_int(2)));
>> +    if (nr_mem) {
>> +        aml_append(ifctx, aml_load_table("MHPT"));
>> +    }
>> +    aml_append(method, ifctx);
>> +    aml_append(sb_scope, method);
>> +    aml_append(ssdt, sb_scope);
>> +
>>      /* Extra PCI root buses are implemented  only for i440fx */
>>      bus = find_i440fx();
>>      if (bus) {
>> @@ -1200,119 +1210,6 @@ build_ssdt(GArray *table_data, GArray *linker,
>>          }
>>          aml_append(sb_scope, aml_name_decl("CPON", pkg));
>>  
>> -        /* build memory devices */
>> -        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
>> -        scope = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
>> -        aml_append(scope,
>> -            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
>> -        );
>> -
>> -        crs = aml_resource_template();
>> -        aml_append(crs,
>> -            aml_io(AML_DECODE16, pm->mem_hp_io_base, pm->mem_hp_io_base, 0,
>> -                   pm->mem_hp_io_len)
>> -        );
>> -        aml_append(scope, aml_name_decl("_CRS", crs));
>> -
>> -        aml_append(scope, aml_operation_region(
>> -            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
>> -            pm->mem_hp_io_base, pm->mem_hp_io_len)
>> -        );
>> -
>> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
>> -                          AML_PRESERVE);
>> -        aml_append(field, /* read only */
>> -            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
>> -        aml_append(field, /* read only */
>> -            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
>> -        aml_append(field, /* read only */
>> -            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
>> -        aml_append(field, /* read only */
>> -            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
>> -        aml_append(field, /* read only */
>> -            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
>> -        aml_append(scope, field);
>> -
>> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
>> -                          AML_WRITE_AS_ZEROS);
>> -        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
>> -        aml_append(field, /* 1 if enabled, read only */
>> -            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
>> -        aml_append(field,
>> -            /*(read) 1 if has a insert event. (write) 1 to clear event */
>> -            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
>> -        aml_append(field,
>> -            /* (read) 1 if has a remove event. (write) 1 to clear event */
>> -            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
>> -        aml_append(field,
>> -            /* initiates device eject, write only */
>> -            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
>> -        aml_append(scope, field);
>> -
>> -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
>> -                          AML_PRESERVE);
>> -        aml_append(field, /* DIMM selector, write only */
>> -            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
>> -        aml_append(field, /* _OST event code, write only */
>> -            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
>> -        aml_append(field, /* _OST status code, write only */
>> -            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
>> -        aml_append(scope, field);
>> -
>> -        aml_append(sb_scope, scope);
>> -
>> -        for (i = 0; i < nr_mem; i++) {
>> -            #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
>> -            const char *s;
>> -
>> -            dev = aml_device("MP%02X", i);
>> -            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
>> -            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
>> -
>> -            method = aml_method("_CRS", 0);
>> -            s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
>> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>> -            aml_append(dev, method);
>> -
>> -            method = aml_method("_STA", 0);
>> -            s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
>> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>> -            aml_append(dev, method);
>> -
>> -            method = aml_method("_PXM", 0);
>> -            s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
>> -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
>> -            aml_append(dev, method);
>> -
>> -            method = aml_method("_OST", 3);
>> -            s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
>> -            aml_append(method, aml_return(aml_call4(
>> -                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
>> -            )));
>> -            aml_append(dev, method);
>> -
>> -            method = aml_method("_EJ0", 1);
>> -            s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
>> -            aml_append(method, aml_return(aml_call2(
>> -                       s, aml_name("_UID"), aml_arg(0))));
>> -            aml_append(dev, method);
>> -
>> -            aml_append(sb_scope, dev);
>> -        }
>> -
>> -        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
>> -         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
>> -         */
>> -        method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
>> -        for (i = 0; i < nr_mem; i++) {
>> -            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
>> -            aml_append(ifctx,
>> -                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
>> -            );
>> -            aml_append(method, ifctx);
>> -        }
>> -        aml_append(sb_scope, method);
>> -
>>          {
>>              Object *pci_host;
>>              PCIBus *bus = NULL;
>> @@ -1671,6 +1568,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>>      uint8_t *u;
>>      size_t aml_len = 0;
>>      GArray *tables_blob = tables->table_data;
>> +    MachineState *machine = MACHINE(qdev_get_machine());
>>  
>>      acpi_get_cpu_info(&cpu);
>>      acpi_get_pm_info(&pm);
>> @@ -1742,6 +1640,12 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
>>          build_dmar_q35(tables_blob, tables->linker);
>>      }
>>  
>> +    if (machine->ram_slots) {
>> +        acpi_add_table(table_offsets, tables_blob);
>> +        build_mhpt(tables_blob, tables->linker, machine->ram_slots,
>> +                   pm.mem_hp_io_base, pm.mem_hp_io_len);
>> +    }
>> +
>>      /* Add tables supplied by user (if any) */
>>      for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
>>          unsigned len = acpi_table_len(u);
>> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
>> index 1342adb..5fd2854 100644
>> --- a/include/hw/acpi/memory_hotplug.h
>> +++ b/include/hw/acpi/memory_hotplug.h
>> @@ -45,4 +45,7 @@ extern const VMStateDescription vmstate_memory_hotplug;
>>                     vmstate_memory_hotplug, MemHotplugState)
>>  
>>  void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>> +
>> +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
>> +                uint16_t io_base, uint16_t io_len);
>>  #endif
>> -- 
>> 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
  2015-10-24 19:40   ` Michael S. Tsirkin
@ 2015-10-26 10:03     ` Igor Mammedov
  2015-10-26 10:07       ` Michael S. Tsirkin
  0 siblings, 1 reply; 32+ messages in thread
From: Igor Mammedov @ 2015-10-26 10:03 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: pbonzini, qemu-devel

On Sat, 24 Oct 2015 22:40:59 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Fri, Oct 23, 2015 at 04:57:18PM +0200, Igor Mammedov wrote:
> > it turns on 64-bit integer handling in OSPM, which we could use
> > for writing simpler/smaller AML code.
> > Tested with Windows XP and Windows Server 2008, Linux:
> >  * XP doesn't care about revision and continues to use 32 integers
> >    and boots just fine with this change.
> >  * WS 2008 and Linux - support rev2 and use 64-bit integers
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> 
> This is still planned, right? IIUC you didn't post any code
> that needs the 64 bit math.
nope, the next patch 16/19 uses 64-bit math,

it greatly simplifies _CRS as we don't have to do
64-bit math manually using 32-bit integers.

And even if we put new MHPD.MCRS() that uses 64-bit math in SSDT,
it won't crash XP unless someone would try to do memory hotplug

and even it could be 'fixed' if we check _REV on every
hotplug event, it's a bit ugly but should work.

> 
> > ---
> >  hw/i386/acpi-build.c      | 2 +-
> >  hw/i386/acpi-dsdt.dsl     | 2 +-
> >  hw/i386/q35-acpi-dsdt.dsl | 2 +-
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 8add4d9..c929540 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1484,7 +1484,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
> >  
> >      memset(dsdt, 0, sizeof *dsdt);
> >      build_header(linker, table_data, dsdt, "DSDT",
> > -                 misc->dsdt_size, 1);
> > +                 misc->dsdt_size, 2);
> >  }
> >  
> >  static GArray *
> > diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> > index 8dba096..6d46b36 100644
> > --- a/hw/i386/acpi-dsdt.dsl
> > +++ b/hw/i386/acpi-dsdt.dsl
> > @@ -22,7 +22,7 @@ ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode
> >  DefinitionBlock (
> >      "acpi-dsdt.aml",    // Output Filename
> >      "DSDT",             // Signature
> > -    0x01,               // DSDT Compliance Revision
> > +    0x02,               // DSDT Compliance Revision
> >      "BXPC",             // OEMID
> >      "BXDSDT",           // TABLE ID
> >      0x1                 // OEM Revision
> > diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> > index 7be7b37..ecefdec 100644
> > --- a/hw/i386/q35-acpi-dsdt.dsl
> > +++ b/hw/i386/q35-acpi-dsdt.dsl
> > @@ -28,7 +28,7 @@ ACPI_EXTRACT_ALL_CODE Q35AcpiDsdtAmlCode
> >  DefinitionBlock (
> >      "q35-acpi-dsdt.aml",// Output Filename
> >      "DSDT",             // Signature
> > -    0x01,               // DSDT Compliance Revision
> > +    0x02,               // DSDT Compliance Revision
> >      "BXPC",             // OEMID
> >      "BXDSDT",           // TABLE ID
> >      0x2                 // OEM Revision
> > -- 
> > 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
  2015-10-26 10:03     ` Igor Mammedov
@ 2015-10-26 10:07       ` Michael S. Tsirkin
  2015-10-26 11:06         ` Igor Mammedov
  0 siblings, 1 reply; 32+ messages in thread
From: Michael S. Tsirkin @ 2015-10-26 10:07 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pbonzini, qemu-devel

On Mon, Oct 26, 2015 at 11:03:01AM +0100, Igor Mammedov wrote:
> On Sat, 24 Oct 2015 22:40:59 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Fri, Oct 23, 2015 at 04:57:18PM +0200, Igor Mammedov wrote:
> > > it turns on 64-bit integer handling in OSPM, which we could use
> > > for writing simpler/smaller AML code.
> > > Tested with Windows XP and Windows Server 2008, Linux:
> > >  * XP doesn't care about revision and continues to use 32 integers
> > >    and boots just fine with this change.
> > >  * WS 2008 and Linux - support rev2 and use 64-bit integers
> > > 
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > 
> > This is still planned, right? IIUC you didn't post any code
> > that needs the 64 bit math.
> nope, the next patch 16/19 uses 64-bit math,
> 
> it greatly simplifies _CRS as we don't have to do
> 64-bit math manually using 32-bit integers.
> 
> And even if we put new MHPD.MCRS() that uses 64-bit math in SSDT,
> it won't crash XP unless someone would try to do memory hotplug
> 
> and even it could be 'fixed' if we check _REV on every
> hotplug event, it's a bit ugly but should work.

Aha. That's exactly what I said. All that patch commit log
says is
    pc: acpi: memhp: move MHPD.MCRS method into MHPT table
when in fact you also rework it all to use 64 bit math.

So pls don't do this. Pls start by rewriting ASL in C
while keeping AML code identical. Cleanups - next.

> > 
> > > ---
> > >  hw/i386/acpi-build.c      | 2 +-
> > >  hw/i386/acpi-dsdt.dsl     | 2 +-
> > >  hw/i386/q35-acpi-dsdt.dsl | 2 +-
> > >  3 files changed, 3 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > index 8add4d9..c929540 100644
> > > --- a/hw/i386/acpi-build.c
> > > +++ b/hw/i386/acpi-build.c
> > > @@ -1484,7 +1484,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
> > >  
> > >      memset(dsdt, 0, sizeof *dsdt);
> > >      build_header(linker, table_data, dsdt, "DSDT",
> > > -                 misc->dsdt_size, 1);
> > > +                 misc->dsdt_size, 2);
> > >  }
> > >  
> > >  static GArray *
> > > diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> > > index 8dba096..6d46b36 100644
> > > --- a/hw/i386/acpi-dsdt.dsl
> > > +++ b/hw/i386/acpi-dsdt.dsl
> > > @@ -22,7 +22,7 @@ ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode
> > >  DefinitionBlock (
> > >      "acpi-dsdt.aml",    // Output Filename
> > >      "DSDT",             // Signature
> > > -    0x01,               // DSDT Compliance Revision
> > > +    0x02,               // DSDT Compliance Revision
> > >      "BXPC",             // OEMID
> > >      "BXDSDT",           // TABLE ID
> > >      0x1                 // OEM Revision
> > > diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> > > index 7be7b37..ecefdec 100644
> > > --- a/hw/i386/q35-acpi-dsdt.dsl
> > > +++ b/hw/i386/q35-acpi-dsdt.dsl
> > > @@ -28,7 +28,7 @@ ACPI_EXTRACT_ALL_CODE Q35AcpiDsdtAmlCode
> > >  DefinitionBlock (
> > >      "q35-acpi-dsdt.aml",// Output Filename
> > >      "DSDT",             // Signature
> > > -    0x01,               // DSDT Compliance Revision
> > > +    0x02,               // DSDT Compliance Revision
> > >      "BXPC",             // OEMID
> > >      "BXDSDT",           // TABLE ID
> > >      0x2                 // OEM Revision
> > > -- 
> > > 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
  2015-10-26 10:07       ` Michael S. Tsirkin
@ 2015-10-26 11:06         ` Igor Mammedov
  2015-10-26 11:17           ` Michael S. Tsirkin
  0 siblings, 1 reply; 32+ messages in thread
From: Igor Mammedov @ 2015-10-26 11:06 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: pbonzini, qemu-devel

On Mon, 26 Oct 2015 12:07:50 +0200
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Mon, Oct 26, 2015 at 11:03:01AM +0100, Igor Mammedov wrote:
> > On Sat, 24 Oct 2015 22:40:59 +0300
> > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > 
> > > On Fri, Oct 23, 2015 at 04:57:18PM +0200, Igor Mammedov wrote:
> > > > it turns on 64-bit integer handling in OSPM, which we could use
> > > > for writing simpler/smaller AML code.
> > > > Tested with Windows XP and Windows Server 2008, Linux:
> > > >  * XP doesn't care about revision and continues to use 32 integers
> > > >    and boots just fine with this change.
> > > >  * WS 2008 and Linux - support rev2 and use 64-bit integers
> > > > 
> > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > 
> > > This is still planned, right? IIUC you didn't post any code
> > > that needs the 64 bit math.
> > nope, the next patch 16/19 uses 64-bit math,
> > 
> > it greatly simplifies _CRS as we don't have to do
> > 64-bit math manually using 32-bit integers.
> > 
> > And even if we put new MHPD.MCRS() that uses 64-bit math in SSDT,
> > it won't crash XP unless someone would try to do memory hotplug
> > 
> > and even it could be 'fixed' if we check _REV on every
> > hotplug event, it's a bit ugly but should work.
> 
> Aha. That's exactly what I said. All that patch commit log
> says is
>     pc: acpi: memhp: move MHPD.MCRS method into MHPT table
> when in fact you also rework it all to use 64 bit math.
yep, it's my fault. I'll fix it.

> 
> So pls don't do this. Pls start by rewriting ASL in C
> while keeping AML code identical. Cleanups - next.
That's what I'm trying to avoid in this case as 
reworked code is much simpler than the original ASL.
Rewriting original complex MHPD.MCRS() ASL into C and
immediately replacing it with simplified version is
rather counterproductive especially taking in account that
'make check' tests will fail anyway since code is moved
between tables and C-produced AML doesn't exactly match
blobs produced by a particular IASL version anyway.

But I can certainly do/split it other way around,
simplify ASL first and then rewrite result in C.
That should make reviewing easier even if tests
are broken.

> 
> > > 
> > > > ---
> > > >  hw/i386/acpi-build.c      | 2 +-
> > > >  hw/i386/acpi-dsdt.dsl     | 2 +-
> > > >  hw/i386/q35-acpi-dsdt.dsl | 2 +-
> > > >  3 files changed, 3 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > index 8add4d9..c929540 100644
> > > > --- a/hw/i386/acpi-build.c
> > > > +++ b/hw/i386/acpi-build.c
> > > > @@ -1484,7 +1484,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
> > > >  
> > > >      memset(dsdt, 0, sizeof *dsdt);
> > > >      build_header(linker, table_data, dsdt, "DSDT",
> > > > -                 misc->dsdt_size, 1);
> > > > +                 misc->dsdt_size, 2);
> > > >  }
> > > >  
> > > >  static GArray *
> > > > diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> > > > index 8dba096..6d46b36 100644
> > > > --- a/hw/i386/acpi-dsdt.dsl
> > > > +++ b/hw/i386/acpi-dsdt.dsl
> > > > @@ -22,7 +22,7 @@ ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode
> > > >  DefinitionBlock (
> > > >      "acpi-dsdt.aml",    // Output Filename
> > > >      "DSDT",             // Signature
> > > > -    0x01,               // DSDT Compliance Revision
> > > > +    0x02,               // DSDT Compliance Revision
> > > >      "BXPC",             // OEMID
> > > >      "BXDSDT",           // TABLE ID
> > > >      0x1                 // OEM Revision
> > > > diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> > > > index 7be7b37..ecefdec 100644
> > > > --- a/hw/i386/q35-acpi-dsdt.dsl
> > > > +++ b/hw/i386/q35-acpi-dsdt.dsl
> > > > @@ -28,7 +28,7 @@ ACPI_EXTRACT_ALL_CODE Q35AcpiDsdtAmlCode
> > > >  DefinitionBlock (
> > > >      "q35-acpi-dsdt.aml",// Output Filename
> > > >      "DSDT",             // Signature
> > > > -    0x01,               // DSDT Compliance Revision
> > > > +    0x02,               // DSDT Compliance Revision
> > > >      "BXPC",             // OEMID
> > > >      "BXDSDT",           // TABLE ID
> > > >      0x2                 // OEM Revision
> > > > -- 
> > > > 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
  2015-10-26 11:06         ` Igor Mammedov
@ 2015-10-26 11:17           ` Michael S. Tsirkin
  0 siblings, 0 replies; 32+ messages in thread
From: Michael S. Tsirkin @ 2015-10-26 11:17 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: pbonzini, qemu-devel

On Mon, Oct 26, 2015 at 12:06:51PM +0100, Igor Mammedov wrote:
> On Mon, 26 Oct 2015 12:07:50 +0200
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Mon, Oct 26, 2015 at 11:03:01AM +0100, Igor Mammedov wrote:
> > > On Sat, 24 Oct 2015 22:40:59 +0300
> > > "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > > 
> > > > On Fri, Oct 23, 2015 at 04:57:18PM +0200, Igor Mammedov wrote:
> > > > > it turns on 64-bit integer handling in OSPM, which we could use
> > > > > for writing simpler/smaller AML code.
> > > > > Tested with Windows XP and Windows Server 2008, Linux:
> > > > >  * XP doesn't care about revision and continues to use 32 integers
> > > > >    and boots just fine with this change.
> > > > >  * WS 2008 and Linux - support rev2 and use 64-bit integers
> > > > > 
> > > > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > > > 
> > > > This is still planned, right? IIUC you didn't post any code
> > > > that needs the 64 bit math.
> > > nope, the next patch 16/19 uses 64-bit math,
> > > 
> > > it greatly simplifies _CRS as we don't have to do
> > > 64-bit math manually using 32-bit integers.
> > > 
> > > And even if we put new MHPD.MCRS() that uses 64-bit math in SSDT,
> > > it won't crash XP unless someone would try to do memory hotplug
> > > 
> > > and even it could be 'fixed' if we check _REV on every
> > > hotplug event, it's a bit ugly but should work.
> > 
> > Aha. That's exactly what I said. All that patch commit log
> > says is
> >     pc: acpi: memhp: move MHPD.MCRS method into MHPT table
> > when in fact you also rework it all to use 64 bit math.
> yep, it's my fault. I'll fix it.

Don't fix the comment. Just do it the right way.

> > 
> > So pls don't do this. Pls start by rewriting ASL in C
> > while keeping AML code identical. Cleanups - next.
> That's what I'm trying to avoid in this case as 
> reworked code is much simpler than the original ASL.
> Rewriting original complex MHPD.MCRS() ASL into C and
> immediately replacing it with simplified version is
> rather counterproductive especially taking in account that
> 'make check' tests will fail anyway since code is moved
> between tables and C-produced AML doesn't exactly match
> blobs produced by a particular IASL version anyway.

So make it match.
It seems pretty robust ATM, since we disassemble and
only compare the dis-assembled output.
Let's keep that invariant.

> But I can certainly do/split it other way around,
> simplify ASL first and then rewrite result in C.
> That should make reviewing easier even if tests
> are broken.

So your untested (in the field, I trust you to test your code) C matches
untested ASL. This doesn't help too much.

Sorry, IMO that's the wrong way to prioritize things. I value ease of
testing and reviewing patches much higher than ease of writing them,
and stability higher than any individual feature.

The original migration into QEMU was completely seemless because of full
bit for bit compatibility with seabios.

I bent the rules when the stuff was first rewritten in C and this
introduced some regressions, but there was just too much demand for the
stuff, people had real trouble hacking in 3 languages (python/C/ASL),
and that was holding up multiple features so some instability was worth
it.

Nothing like this here, this is just general cleanup.
Let's do it the slow, safe way please.

> > 
> > > > 
> > > > > ---
> > > > >  hw/i386/acpi-build.c      | 2 +-
> > > > >  hw/i386/acpi-dsdt.dsl     | 2 +-
> > > > >  hw/i386/q35-acpi-dsdt.dsl | 2 +-
> > > > >  3 files changed, 3 insertions(+), 3 deletions(-)
> > > > > 
> > > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > > index 8add4d9..c929540 100644
> > > > > --- a/hw/i386/acpi-build.c
> > > > > +++ b/hw/i386/acpi-build.c
> > > > > @@ -1484,7 +1484,7 @@ build_dsdt(GArray *table_data, GArray *linker, AcpiMiscInfo *misc)
> > > > >  
> > > > >      memset(dsdt, 0, sizeof *dsdt);
> > > > >      build_header(linker, table_data, dsdt, "DSDT",
> > > > > -                 misc->dsdt_size, 1);
> > > > > +                 misc->dsdt_size, 2);
> > > > >  }
> > > > >  
> > > > >  static GArray *
> > > > > diff --git a/hw/i386/acpi-dsdt.dsl b/hw/i386/acpi-dsdt.dsl
> > > > > index 8dba096..6d46b36 100644
> > > > > --- a/hw/i386/acpi-dsdt.dsl
> > > > > +++ b/hw/i386/acpi-dsdt.dsl
> > > > > @@ -22,7 +22,7 @@ ACPI_EXTRACT_ALL_CODE AcpiDsdtAmlCode
> > > > >  DefinitionBlock (
> > > > >      "acpi-dsdt.aml",    // Output Filename
> > > > >      "DSDT",             // Signature
> > > > > -    0x01,               // DSDT Compliance Revision
> > > > > +    0x02,               // DSDT Compliance Revision
> > > > >      "BXPC",             // OEMID
> > > > >      "BXDSDT",           // TABLE ID
> > > > >      0x1                 // OEM Revision
> > > > > diff --git a/hw/i386/q35-acpi-dsdt.dsl b/hw/i386/q35-acpi-dsdt.dsl
> > > > > index 7be7b37..ecefdec 100644
> > > > > --- a/hw/i386/q35-acpi-dsdt.dsl
> > > > > +++ b/hw/i386/q35-acpi-dsdt.dsl
> > > > > @@ -28,7 +28,7 @@ ACPI_EXTRACT_ALL_CODE Q35AcpiDsdtAmlCode
> > > > >  DefinitionBlock (
> > > > >      "q35-acpi-dsdt.aml",// Output Filename
> > > > >      "DSDT",             // Signature
> > > > > -    0x01,               // DSDT Compliance Revision
> > > > > +    0x02,               // DSDT Compliance Revision
> > > > >      "BXPC",             // OEMID
> > > > >      "BXDSDT",           // TABLE ID
> > > > >      0x2                 // OEM Revision
> > > > > -- 
> > > > > 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
  2015-10-24 17:59   ` Michael S. Tsirkin
  2015-10-25 13:33     ` Laszlo Ersek
@ 2015-10-26 13:36     ` Igor Mammedov
  1 sibling, 0 replies; 32+ messages in thread
From: Igor Mammedov @ 2015-10-26 13:36 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: pbonzini, lersek, qemu-devel

On Sat, 24 Oct 2015 20:59:07 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Fri, Oct 23, 2015 at 04:57:09PM +0200, Igor Mammedov wrote:
> > moves SSDT part to custom MHPT table, which is loaded
> > at runtime by OSPM if it supports ACPIv2 revision and
> > only if memory hotplug is enabled.
> > That should reduce ACPI tables blob size if memory
> > hotplug is not enabled (default case).
> 
> With seabios, it's still in reserved memory. How does it help?
> 
> And this trick likely breaks UEFI.
> 
> I just checked, the only legal way to specify OEM
> specific tables seems to be using OEMX prefix.
> 
> But there's a decent chance this will conflict with
> people using command line flags to load their own
> tables.
> 
> This likely means this trick is off.
Ok, I'll drop LoadTable and keep it in SSDT, there is no
hard req to use a separate table since all memhp code is
rev1.0 compatible for now and even when it's switched to
64-bit math it shouldn't affect XP unless someone would
try hotplug memory on it.

> 
> 
> 
> > Checked for compatibility issues with:
> >  * Windows XPsp3, Windows Server 2003: they don't load
> >    the table as OSPM only reports revision 1 as supported.
> >    And we don't care about memhp for these guests as they
> >    do not support it anyway.
> >  * Windows Server 2008, Windows Server 2008R2:
> >    works as expected
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  hw/acpi/Makefile.objs               |   2 +-
> >  hw/acpi/memory_hotplug_acpi_table.c | 138 ++++++++++++++++++++++++++++++++++++
> >  hw/i386/acpi-build.c                | 130 +++++----------------------------
> >  include/hw/acpi/memory_hotplug.h    |   3 +
> >  4 files changed, 159 insertions(+), 114 deletions(-)
> >  create mode 100644 hw/acpi/memory_hotplug_acpi_table.c
> > 
> > diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> > index 7d3230c..c04064e 100644
> > --- a/hw/acpi/Makefile.objs
> > +++ b/hw/acpi/Makefile.objs
> > @@ -1,7 +1,7 @@
> >  common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o
> >  common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o
> >  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o
> > -common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
> > +common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o
> >  common-obj-$(CONFIG_ACPI) += acpi_interface.o
> >  common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
> >  common-obj-$(CONFIG_ACPI) += aml-build.o
> > diff --git a/hw/acpi/memory_hotplug_acpi_table.c b/hw/acpi/memory_hotplug_acpi_table.c
> > new file mode 100644
> > index 0000000..28da13c
> > --- /dev/null
> > +++ b/hw/acpi/memory_hotplug_acpi_table.c
> > @@ -0,0 +1,138 @@
> > +#include <stdbool.h>
> > +#include "hw/acpi/aml-build.h"
> > +#include "hw/acpi/memory_hotplug.h"
> > +#include "include/hw/acpi/pc-hotplug.h"
> > +#include "hw/boards.h"
> > +
> > +#define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
> > +
> > +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
> > +                uint16_t io_base, uint16_t io_len)
> > +{
> > +    int i;
> > +    Aml *table, *sb_scope, *dev, *method, *ifctx, *ctrl_dev;
> > +
> > +    table = init_aml_allocator();
> > +    acpi_data_push(table->buf, sizeof(AcpiTableHeader));
> > +
> > +    /* scope for memory hotplug controller device node */
> > +    assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> > +    ctrl_dev = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
> > +    {
> > +        Aml *crs, *field;
> > +
> > +        aml_append(ctrl_dev,
> > +            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
> > +        );
> > +
> > +        crs = aml_resource_template();
> > +        aml_append(crs, aml_io(AML_DECODE16, io_base, io_base, 0, io_len));
> > +        aml_append(ctrl_dev, aml_name_decl("_CRS", crs));
> > +
> > +        aml_append(ctrl_dev, aml_operation_region(
> > +            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
> > +            io_base, io_len)
> > +        );
> > +
> > +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> > +                          AML_PRESERVE);
> > +        aml_append(field, /* read only */
> > +            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
> > +        aml_append(field, /* read only */
> > +            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
> > +        aml_append(ctrl_dev, field);
> > +
> > +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
> > +                          AML_WRITE_AS_ZEROS);
> > +        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> > +        aml_append(field, /* 1 if enabled, read only */
> > +            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
> > +        aml_append(field,
> > +            /*(read) 1 if has a insert event. (write) 1 to clear event */
> > +            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
> > +        aml_append(field,
> > +            /* (read) 1 if has a remove event. (write) 1 to clear event */
> > +            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
> > +        aml_append(field,
> > +            /* initiates device eject, write only */
> > +            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
> > +        aml_append(ctrl_dev, field);
> > +
> > +        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> > +                          AML_PRESERVE);
> > +        aml_append(field, /* DIMM selector, write only */
> > +            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
> > +        aml_append(field, /* _OST event code, write only */
> > +            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
> > +        aml_append(field, /* _OST status code, write only */
> > +            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
> > +        aml_append(ctrl_dev, field);
> > +    }
> > +    aml_append(table, ctrl_dev);
> > +
> > +    sb_scope = aml_scope("\\_SB");
> > +    for (i = 0; i < nr_mem; i++) {
> > +        const char *s;
> > +
> > +        dev = aml_device("MP%02X", i);
> > +        aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> > +        aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> > +
> > +        method = aml_method("_CRS", 0);
> > +        s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
> > +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_STA", 0);
> > +        s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
> > +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_PXM", 0);
> > +        s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
> > +        aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_OST", 3);
> > +        s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
> > +        aml_append(method, aml_return(aml_call4(
> > +            s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> > +        )));
> > +        aml_append(dev, method);
> > +
> > +        method = aml_method("_EJ0", 1);
> > +        s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
> > +        aml_append(method, aml_return(aml_call2(
> > +                   s, aml_name("_UID"), aml_arg(0))));
> > +        aml_append(dev, method);
> > +
> > +        aml_append(sb_scope, dev);
> > +    }
> > +
> > +    /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> > +     *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> > +     */
> > +    method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
> > +    for (i = 0; i < nr_mem; i++) {
> > +        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> > +        aml_append(ifctx,
> > +            aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> > +        );
> > +        aml_append(method, ifctx);
> > +    }
> > +    aml_append(sb_scope, method);
> > +    aml_append(table, sb_scope);
> > +
> > +    /* copy AML table into ACPI tables blob and patch header there */
> > +    g_array_append_vals(table_data, table->buf->data, table->buf->len);
> > +    build_header(linker, table_data,
> > +        (void *)(table_data->data + table_data->len - table->buf->len),
> > +        "MHPT", table->buf->len, 2);
> > +    free_aml_allocator();
> > +}
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 95e0c65..8add4d9 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -925,6 +925,16 @@ build_ssdt(GArray *table_data, GArray *linker,
> >      /* Reserve space for header */
> >      acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
> >  
> > +    sb_scope = aml_scope("\\_SB");
> > +    method = aml_method("_INI", 0);
> > +    ifctx = aml_if(aml_lgreater_equal(aml_name("_REV"), aml_int(2)));
> > +    if (nr_mem) {
> > +        aml_append(ifctx, aml_load_table("MHPT"));
> > +    }
> > +    aml_append(method, ifctx);
> > +    aml_append(sb_scope, method);
> > +    aml_append(ssdt, sb_scope);
> > +
> >      /* Extra PCI root buses are implemented  only for i440fx */
> >      bus = find_i440fx();
> >      if (bus) {
> > @@ -1200,119 +1210,6 @@ build_ssdt(GArray *table_data, GArray *linker,
> >          }
> >          aml_append(sb_scope, aml_name_decl("CPON", pkg));
> >  
> > -        /* build memory devices */
> > -        assert(nr_mem <= ACPI_MAX_RAM_SLOTS);
> > -        scope = aml_scope("\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE));
> > -        aml_append(scope,
> > -            aml_name_decl(stringify(MEMORY_SLOTS_NUMBER), aml_int(nr_mem))
> > -        );
> > -
> > -        crs = aml_resource_template();
> > -        aml_append(crs,
> > -            aml_io(AML_DECODE16, pm->mem_hp_io_base, pm->mem_hp_io_base, 0,
> > -                   pm->mem_hp_io_len)
> > -        );
> > -        aml_append(scope, aml_name_decl("_CRS", crs));
> > -
> > -        aml_append(scope, aml_operation_region(
> > -            stringify(MEMORY_HOTPLUG_IO_REGION), AML_SYSTEM_IO,
> > -            pm->mem_hp_io_base, pm->mem_hp_io_len)
> > -        );
> > -
> > -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> > -                          AML_PRESERVE);
> > -        aml_append(field, /* read only */
> > -            aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32));
> > -        aml_append(field, /* read only */
> > -            aml_named_field(stringify(MEMORY_SLOT_ADDR_HIGH), 32));
> > -        aml_append(field, /* read only */
> > -            aml_named_field(stringify(MEMORY_SLOT_SIZE_LOW), 32));
> > -        aml_append(field, /* read only */
> > -            aml_named_field(stringify(MEMORY_SLOT_SIZE_HIGH), 32));
> > -        aml_append(field, /* read only */
> > -            aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32));
> > -        aml_append(scope, field);
> > -
> > -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_BYTE_ACC,
> > -                          AML_WRITE_AS_ZEROS);
> > -        aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */));
> > -        aml_append(field, /* 1 if enabled, read only */
> > -            aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1));
> > -        aml_append(field,
> > -            /*(read) 1 if has a insert event. (write) 1 to clear event */
> > -            aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1));
> > -        aml_append(field,
> > -            /* (read) 1 if has a remove event. (write) 1 to clear event */
> > -            aml_named_field(stringify(MEMORY_SLOT_REMOVE_EVENT), 1));
> > -        aml_append(field,
> > -            /* initiates device eject, write only */
> > -            aml_named_field(stringify(MEMORY_SLOT_EJECT), 1));
> > -        aml_append(scope, field);
> > -
> > -        field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), AML_DWORD_ACC,
> > -                          AML_PRESERVE);
> > -        aml_append(field, /* DIMM selector, write only */
> > -            aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32));
> > -        aml_append(field, /* _OST event code, write only */
> > -            aml_named_field(stringify(MEMORY_SLOT_OST_EVENT), 32));
> > -        aml_append(field, /* _OST status code, write only */
> > -            aml_named_field(stringify(MEMORY_SLOT_OST_STATUS), 32));
> > -        aml_append(scope, field);
> > -
> > -        aml_append(sb_scope, scope);
> > -
> > -        for (i = 0; i < nr_mem; i++) {
> > -            #define BASEPATH "\\_SB.PCI0." stringify(MEMORY_HOTPLUG_DEVICE) "."
> > -            const char *s;
> > -
> > -            dev = aml_device("MP%02X", i);
> > -            aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
> > -            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
> > -
> > -            method = aml_method("_CRS", 0);
> > -            s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
> > -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -            aml_append(dev, method);
> > -
> > -            method = aml_method("_STA", 0);
> > -            s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
> > -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -            aml_append(dev, method);
> > -
> > -            method = aml_method("_PXM", 0);
> > -            s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
> > -            aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
> > -            aml_append(dev, method);
> > -
> > -            method = aml_method("_OST", 3);
> > -            s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
> > -            aml_append(method, aml_return(aml_call4(
> > -                s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
> > -            )));
> > -            aml_append(dev, method);
> > -
> > -            method = aml_method("_EJ0", 1);
> > -            s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
> > -            aml_append(method, aml_return(aml_call2(
> > -                       s, aml_name("_UID"), aml_arg(0))));
> > -            aml_append(dev, method);
> > -
> > -            aml_append(sb_scope, dev);
> > -        }
> > -
> > -        /* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
> > -         *     If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
> > -         */
> > -        method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
> > -        for (i = 0; i < nr_mem; i++) {
> > -            ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
> > -            aml_append(ifctx,
> > -                aml_notify(aml_name("MP%.02X", i), aml_arg(1))
> > -            );
> > -            aml_append(method, ifctx);
> > -        }
> > -        aml_append(sb_scope, method);
> > -
> >          {
> >              Object *pci_host;
> >              PCIBus *bus = NULL;
> > @@ -1671,6 +1568,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
> >      uint8_t *u;
> >      size_t aml_len = 0;
> >      GArray *tables_blob = tables->table_data;
> > +    MachineState *machine = MACHINE(qdev_get_machine());
> >  
> >      acpi_get_cpu_info(&cpu);
> >      acpi_get_pm_info(&pm);
> > @@ -1742,6 +1640,12 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
> >          build_dmar_q35(tables_blob, tables->linker);
> >      }
> >  
> > +    if (machine->ram_slots) {
> > +        acpi_add_table(table_offsets, tables_blob);
> > +        build_mhpt(tables_blob, tables->linker, machine->ram_slots,
> > +                   pm.mem_hp_io_base, pm.mem_hp_io_len);
> > +    }
> > +
> >      /* Add tables supplied by user (if any) */
> >      for (u = acpi_table_first(); u; u = acpi_table_next(u)) {
> >          unsigned len = acpi_table_len(u);
> > diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> > index 1342adb..5fd2854 100644
> > --- a/include/hw/acpi/memory_hotplug.h
> > +++ b/include/hw/acpi/memory_hotplug.h
> > @@ -45,4 +45,7 @@ extern const VMStateDescription vmstate_memory_hotplug;
> >                     vmstate_memory_hotplug, MemHotplugState)
> >  
> >  void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
> > +
> > +void build_mhpt(GArray *table_data, GArray *linker, uint32_t nr_mem,
> > +                uint16_t io_base, uint16_t io_len);
> >  #endif
> > -- 
> > 1.8.3.1

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2015-10-26 13:36 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-23 14:57 [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 01/19] acpi: aml: add aml_lgreater_equal() and aml_load_table() Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 02/19] acpi: add aml_mutex(), aml_acquire(), aml_release() Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 03/19] acpi: aml: add aml_create_qword_field() Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 04/19] acpi: aml: add aml_decrement() and aml_subtract() Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 05/19] acpi: aml: add aml_call0() helper Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table Igor Mammedov
2015-10-24 17:41   ` Michael S. Tsirkin
2015-10-24 17:59   ` Michael S. Tsirkin
2015-10-25 13:33     ` Laszlo Ersek
2015-10-26 13:36     ` Igor Mammedov
2015-10-24 19:37   ` Michael S. Tsirkin
2015-10-23 14:57 ` [Qemu-devel] [PATCH 07/19] pc: acpi: memhp: move MHPD._STA method into MHPT table Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 08/19] pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 09/19] pc: acpi: memhp: move MHPD.MSCN method into MHPT table Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 10/19] pc: acpi: make memory device's _UID integer Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 11/19] pc: acpi: memhp: move MHPD.MRST method into MHPT table Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 12/19] pc: acpi: memhp: move MHPD.MPXM " Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 13/19] pc: acpi: memhp: move MHPD.MOST " Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 14/19] pc: acpi: memhp: move MHPD.MEJ0 " Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2 Igor Mammedov
2015-10-24 19:40   ` Michael S. Tsirkin
2015-10-26 10:03     ` Igor Mammedov
2015-10-26 10:07       ` Michael S. Tsirkin
2015-10-26 11:06         ` Igor Mammedov
2015-10-26 11:17           ` Michael S. Tsirkin
2015-10-23 14:57 ` [Qemu-devel] [PATCH 16/19] pc: acpi: memhp: move MHPD.MCRS method into MHPT table Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 17/19] pc: acpi: memhp: move MHPD Device along with _UID/_HID " Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 18/19] pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03 into SSDT Igor Mammedov
2015-10-23 14:57 ` [Qemu-devel] [PATCH 19/19] pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage Igor Mammedov
2015-10-23 16:38 ` [Qemu-devel] [PATCH 00/19] pc: acpi: move memory hotplug out of DSDT/SSDT into custom table Laszlo Ersek
2015-10-24 17:39 ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.