pc: acpi: move memory hotplug out of DSDT/SSDT into custom table
cover pc: acpi: move memory hotplug out of DSDT/SSDT into custom table
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
Signature · 1 line
1.8.3.1
PATCH 1/19 acpi: aml: add aml_lgreater_equal() and aml_load_table()
--- hw/acpi/aml-build.c | 35 +++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 2 ++ 2 files changed, 37 insertions(+)
hw/acpi/aml-build.c +35 -0
@@ -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)
include/hw/acpi/aml-build.h +2 -0
@@ -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,
Signature · 1 line
1.8.3.1
PATCH 2/19 acpi: add aml_mutex(), aml_acquire(), aml_release()
In reply to Igor MammedovFrom: Xiao Guangrong <[email protected]>
--- hw/acpi/aml-build.c | 33 +++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 3 +++ 2 files changed, 36 insertions(+)
hw/acpi/aml-build.c +33 -0
@@ -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)
include/hw/acpi/aml-build.h +3 -0
@@ -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);
Signature · 1 line
1.8.3.1
PATCH 3/19 acpi: aml: add aml_create_qword_field()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 21 +++++++++++++++++---- include/hw/acpi/aml-build.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)
hw/acpi/aml-build.c +17 -4
@@ -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, ...) {
include/hw/acpi/aml-build.h +1 -0
@@ -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);
Signature · 1 line
1.8.3.1
PATCH 4/19 acpi: aml: add aml_decrement() and aml_subtract()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 18 ++++++++++++++++++ include/hw/acpi/aml-build.h | 2 ++ 2 files changed, 20 insertions(+)
hw/acpi/aml-build.c +18 -0
@@ -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) {
include/hw/acpi/aml-build.h +2 -0
@@ -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);
Signature · 1 line
1.8.3.1
PATCH 5/19 acpi: aml: add aml_call0() helper
In reply to Igor Mammedovit will help to call a method with 0 arguments
--- hw/acpi/aml-build.c | 8 ++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 9 insertions(+)
hw/acpi/aml-build.c +8 -0
@@ -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 ();
include/hw/acpi/aml-build.h +1 -0
@@ -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);
Signature · 1 line
1.8.3.1
PATCH 6/19 pc: acpi: move SSDT part of memhp into a custom table
In reply to Igor Mammedovmoves 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
--- 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
hw/acpi/Makefile.objs +1 -1
@@ -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
hw/acpi/memory_hotplug_acpi_table.c new file +138 -0
138 lines not on this page · raw message
hw/i386/acpi-build.c +17 -113
154 lines not on this page · raw message
include/hw/acpi/memory_hotplug.h +3 -0
@@ -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
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
hw/acpi/memory_hotplug_acpi_table.c line 138
Quoted 7 lines · Igor Mammedov
hw/acpi/memory_hotplug_acpi_table.c new file +7
-0+/* 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?
Signature · 1 line
MST
Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
In reply to Igor MammedovQuoted 5 lines · Igor Mammedov
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.
Quoted 350 lines
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 expectedSigned-off-by Igor Mammedov <[email protected]>--- 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.chw/acpi/Makefile.objs +1
-1@@ -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.ohw/acpi/memory_hotplug_acpi_table.c new file +138
-0@@ -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 (); +}hw/i386/acpi-build.c +17
-113@@ -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);include/hw/acpi/memory_hotplug.h +3
-0@@ -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 Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
Quoted 10 lines · Michael S. Tsirkin
Quoted 5 lines · Igor Mammedov
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
Quoted 361 lines
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.
Quoted 350 lines
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 expectedSigned-off-by Igor Mammedov <[email protected]>--- 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.chw/acpi/Makefile.objs +1
-1@@ -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.ohw/acpi/memory_hotplug_acpi_table.c new file +138
-0@@ -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 (); +}hw/i386/acpi-build.c +17
-113@@ -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);include/hw/acpi/memory_hotplug.h +3
-0@@ -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 Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
In reply to Michael S. TsirkinQuoted 11 lines · On Sat, 24 Oct 2015 20:59:07 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 5 lines · Igor Mammedov
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.
Quoted 8 lines
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.
Quoted 353 lines
Quoted 353 lines
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 expectedSigned-off-by Igor Mammedov <[email protected]>--- 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.chw/acpi/Makefile.objs +1
-1@@ -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.ohw/acpi/memory_hotplug_acpi_table.c new file +138
-0@@ -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 (); +}hw/i386/acpi-build.c +17
-113@@ -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);include/hw/acpi/memory_hotplug.h +3
-0@@ -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 Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 06/19] pc: acpi: move SSDT part of memhp into a custom table
In reply to Igor Mammedovhw/acpi/memory_hotplug_acpi_table.c
Quoted 39 lines · Igor Mammedov
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 expectedSigned-off-by Igor Mammedov <[email protected]>--- 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.chw/acpi/Makefile.objs +1
-1@@ -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.ohw/acpi/memory_hotplug_acpi_table.c new file +0
-0
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.
Quoted 317 lines
hw/acpi/memory_hotplug_acpi_table.c new file +138
-0@@ -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 (); +}hw/i386/acpi-build.c +17
-113@@ -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);include/hw/acpi/memory_hotplug.h +3
-0@@ -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 Signature · 1 line
1.8.3.1
PATCH 7/19 pc: acpi: memhp: move MHPD._STA method into MHPT table
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 3 +++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +3 -0
@@ -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);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -8
@@ -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) {
Signature · 1 line
1.8.3.1
PATCH 8/19 pc: acpi: memhp: move MHPD.MLCK mutex into NHPT table
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 2 ++ hw/i386/acpi-dsdt-mem-hotplug.dsl | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +2 -0
@@ -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);
hw/i386/acpi-dsdt-mem-hotplug.dsl +1 -2
@@ -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)) {
Signature · 1 line
1.8.3.1
PATCH 9/19 pc: acpi: memhp: move MHPD.MSCN method into MHPT table
In reply to Igor Mammedov--- 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(-)
hw/acpi/memory_hotplug_acpi_table.c +45 -8
@@ -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,
hw/i386/acpi-dsdt-mem-hotplug.dsl +1 -26
@@ -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)
include/hw/acpi/pc-hotplug.h +0 -4
@@ -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
Signature · 1 line
1.8.3.1
PATCH 10/19 pc: acpi: make memory device's _UID integer
In reply to Igor MammedovIt 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.
--- hw/acpi/memory_hotplug_acpi_table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/acpi/memory_hotplug_acpi_table.c +1 -1
@@ -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 );
Signature · 1 line
1.8.3.1
PATCH 11/19 pc: acpi: memhp: move MHPD.MRST method into MHPT table
In reply to Igor Mammedov--- 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(-)
hw/acpi/memory_hotplug_acpi_table.c +23 -2
@@ -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);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -15
@@ -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
include/hw/acpi/pc-hotplug.h +0 -2
@@ -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
Signature · 1 line
1.8.3.1
PATCH 12/19 pc: acpi: memhp: move MHPD.MPXM method into MHPT table
In reply to Igor Mammedov--- 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(-)
hw/acpi/memory_hotplug_acpi_table.c +16 -2
@@ -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);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -9
@@ -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
include/hw/acpi/pc-hotplug.h +0 -2
@@ -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
Signature · 1 line
1.8.3.1
PATCH 13/19 pc: acpi: memhp: move MHPD.MOST method into MHPT table
In reply to Igor Mammedov--- 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(-)
hw/acpi/memory_hotplug_acpi_table.c +19 -3
@@ -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 ) )));
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -10
@@ -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
include/hw/acpi/pc-hotplug.h +0 -3
@@ -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
Signature · 1 line
1.8.3.1
PATCH 14/19 pc: acpi: memhp: move MHPD.MEJ0 method into MHPT table
In reply to Igor Mammedov--- 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(-)
hw/acpi/memory_hotplug_acpi_table.c +15 -2
@@ -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);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -8
@@ -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()
include/hw/acpi/pc-hotplug.h +0 -2
@@ -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
Signature · 1 line
1.8.3.1
PATCH 15/19 pc: acpi: bump DSDT revision compliance to v2
In reply to Igor Mammedovit 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
--- 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(-)
hw/i386/acpi-build.c +1 -1
@@ -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 *
hw/i386/acpi-dsdt.dsl +1 -1
@@ -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
hw/i386/q35-acpi-dsdt.dsl +1 -1
@@ -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
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
Quoted 8 lines · Igor Mammedov
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 integersSigned-off-by Igor Mammedov <[email protected]>
This is still planned, right? IIUC you didn't post any code that needs the 64 bit math.
Quoted 47 lines
--- 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(-)hw/i386/acpi-build.c +1
-1@@ -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 *hw/i386/acpi-dsdt.dsl +1
-1@@ -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 Revisionhw/i386/q35-acpi-dsdt.dsl +1
-1@@ -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 RevisionSignature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
Quoted 8 lines · On Sat, 24 Oct 2015 22:40:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
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
Quoted 4 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>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.
Quoted 48 lines
Quoted 48 lines
--- 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(-)hw/i386/acpi-build.c +1
-1@@ -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 *hw/i386/acpi-dsdt.dsl +1
-1@@ -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 Revisionhw/i386/q35-acpi-dsdt.dsl +1
-1@@ -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 RevisionSignature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
Quoted 17 lines · Igor Mammedov
Quoted 8 lines · On Sat, 24 Oct 2015 22:40:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
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 integersQuoted 4 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>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,
Quoted 8 lines
it greatly simplifies
_CRSas 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 hotplugand even it could be 'fixed' if we check
_REVon 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.
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
--- 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(-)hw/i386/acpi-build.c +1
-1@@ -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 *hw/i386/acpi-dsdt.dsl +1
-1@@ -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 Revisionhw/i386/q35-acpi-dsdt.dsl +1
-1@@ -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 RevisionSignature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
Quoted 24 lines · On Mon, 26 Oct 2015 12:07:50 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 23 lines · Igor Mammedov
Quoted 8 lines · On Sat, 24 Oct 2015 22:40:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
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 integersQuoted 4 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>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
_CRSas 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
Quoted 7 lines
Quoted 2 lines
and even it could be 'fixed' if we check
_REVon 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.
Quoted 3 lines
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.
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
--- 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(-)hw/i386/acpi-build.c +1
-1@@ -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 *hw/i386/acpi-dsdt.dsl +1
-1@@ -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 Revisionhw/i386/q35-acpi-dsdt.dsl +1
-1@@ -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 RevisionSignature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 15/19] pc: acpi: bump DSDT revision compliance to v2
Quoted 27 lines · Igor Mammedov
Quoted 24 lines · On Mon, 26 Oct 2015 12:07:50 +0200 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 23 lines · Igor Mammedov
Quoted 8 lines · On Sat, 24 Oct 2015 22:40:59 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 7 lines · Igor Mammedov
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 integersQuoted 4 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>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
_CRSas 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
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
and even it could be 'fixed' if we check
_REVon 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.
Quoted 11 lines
Quoted 3 lines
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.
Quoted 4 lines
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.
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
--- 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(-)hw/i386/acpi-build.c +1
-1@@ -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 *hw/i386/acpi-dsdt.dsl +1
-1@@ -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 Revisionhw/i386/q35-acpi-dsdt.dsl +1
-1@@ -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 RevisionSignature · 1 line
1.8.3.1
PATCH 16/19 pc: acpi: memhp: move MHPD.MCRS method into MHPT table
In reply to Igor Mammedov--- 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(-)
hw/acpi/memory_hotplug_acpi_table.c +49 -11
@@ -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);
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -72
77 lines not on this page · raw message
include/hw/acpi/pc-hotplug.h +0 -7
@@ -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
Signature · 1 line
1.8.3.1
PATCH 17/19 pc: acpi: memhp: move MHPD Device along with _UID/_HID into MHPT table
In reply to Igor Mammedov--- hw/acpi/memory_hotplug_acpi_table.c | 6 +++++- hw/i386/acpi-dsdt-mem-hotplug.dsl | 7 ------- 2 files changed, 5 insertions(+), 8 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +5 -1
@@ -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));
hw/i386/acpi-dsdt-mem-hotplug.dsl +0 -7
@@ -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()
Signature · 1 line
1.8.3.1
PATCH 18/19 pc: acpi: memhp: remove acpi-dsdt-mem-hotplug.dsl and move \_GPE._E03 into SSDT
In reply to Igor Mammedovin addition to moving exclude _E03 handler from SSDT if memory hotplug is not enabled.
--- 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
hw/acpi/memory_hotplug_acpi_table.c +3 -3
@@ -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 );
hw/i386/acpi-build.c +8 -0
@@ -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) {
hw/i386/acpi-dsdt-mem-hotplug.dsl deleted +0 -16
@@ -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)
hw/i386/acpi-dsdt.dsl +0 -5
@@ -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) {
hw/i386/q35-acpi-dsdt.dsl +0 -5
@@ -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) {
include/hw/acpi/memory_hotplug.h +5 -0
@@ -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
include/hw/acpi/pc-hotplug.h +0 -2
@@ -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
Signature · 1 line
1.8.3.1
PATCH 19/19 pc: acpi: memhp: cleanup MEMORY_HOTPLUG_IO_REGION usage
In reply to Igor MammedovMEMORY_HOTPLUG_IO_REGION isn't used anywhere else except of memory_hotplug_acpi_table.c, so move it there and cleanup stringify() ugliness
--- hw/acpi/memory_hotplug_acpi_table.c | 10 +++++----- include/hw/acpi/pc-hotplug.h | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-)
hw/acpi/memory_hotplug_acpi_table.c +5 -5
@@ -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 ));
include/hw/acpi/pc-hotplug.h +0 -2
@@ -32,6 +32,4 @@#define ACPI_MEMORY_HOTPLUG_IO_LEN 24#define ACPI_MEMORY_HOTPLUG_BASE 0x0a00 -#define MEMORY_HOTPLUG_IO_REGION HPMR -#endif
Signature · 1 line
1.8.3.1
Igor,
Quoted 9 lines · Igor Mammedov
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).
Quoted 5 lines
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
Quoted 64 lines
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 slotsMore 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 3028Tested with following guests:
- RHEL7.2,
- Windows XPsp3, Windows Server 2003EE,
- Windows Server 2008DC, Windows Server 2012R2DCSince 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_v1Igor Mammedov (18):
acpi: aml: addaml_lgreater_equal()andaml_load_table()
acpi: aml: addaml_create_qword_field()
acpi: aml: addaml_decrement()andaml_subtract()
acpi: aml: addaml_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_UIDinteger
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: cleanupMEMORY_HOTPLUG_IO_REGIONusageXiao Guangrong (1):
acpi: addaml_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
Quoted 2 lines · Igor Mammedov
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.
Quoted 78 lines
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 slotsMore 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 3028Tested with following guests:
- RHEL7.2,
- Windows XPsp3, Windows Server 2003EE,
- Windows Server 2008DC, Windows Server 2012R2DCSince 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_v1Igor Mammedov (18):
acpi: aml: addaml_lgreater_equal()andaml_load_table()
acpi: aml: addaml_create_qword_field()
acpi: aml: addaml_decrement()andaml_subtract()
acpi: aml: addaml_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_UIDinteger
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: cleanupMEMORY_HOTPLUG_IO_REGIONusageXiao Guangrong (1):
acpi: addaml_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.dslSignature · 1 line
1.8.3.1