Skip to contentSkip to conversation

acpi/nvdimm: remove forward name references

PATCH In review Michael S. Tsirkin 4 participants 13 messages Apr 23, 2018 – Apr 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c +4 -2
index 59d6e42..fadebbd 100644
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf, NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,
                              NVDIMM_DSM_MEM_FILE, dsm_dma_arrea,
Signature · 1 line
MST
#1 lore raw
Quoted 17 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 7 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 4 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns. I think nvdimm_build_common_dsm() needs some refining.

Quoted 32 lines
 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index 59d6e42..fadebbd renamed from hw/acpi/nvdimm.c +0 -0

100644

hw/acpi/nvdimm.c +4 -0
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf, NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
hw/acpi/nvdimm.c +0 -2
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE, dsm_dma_arrea,
--
MST

#2 lore raw
Quoted 26 lines · Erik
Quoted 17 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 7 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 7 lines
Quoted 4 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 5 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns. I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001)

{
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID: Hardware ID
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 33 lines
Quoted 33 lines

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index 59d6e42..fadebbd renamed from hw/acpi/nvdimm.c +0 -0

100644

hw/acpi/nvdimm.c +4 -0
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf, NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
hw/acpi/nvdimm.c +0 -2
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE, dsm_dma_arrea,
--
MST

#3 lore raw
Quoted 30 lines · On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 29 lines · Erik
Quoted 17 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 7 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 3 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Quoted 11 lines
Quoted 4 lines
Quoted 1 line

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 4 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns.

What's wrong with it?
Method is complete so temporary objects
it has used went out of scope, all within spec rules and worked fine with linux and windows guests.

Quoted 20 lines
Quoted 1 line

I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001)

{
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID: Hardware ID
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?
Quoted 3 lines

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset RegionLen RegionOffset := TermArg => Integer
TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

So named object is not accepted, we could have played games with references and Type2Opcode but that didn't work nice with Windows ACPI parser. Hence local object.

The reason why OperationRegion is dynamic, is that if we put it outside of method it will become static, and we would have to use Integer constant there (no named objects are allowed) and then patch it dynamically in bios loader.
I'd prefer to keep it as is, without introducing another hack like build_append_named_operation_region() to create it with know offset so firmware could patch it.

Quoted 39 lines

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 33 lines
Quoted 33 lines
  

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index 59d6e42..fadebbd renamed from hw/acpi/nvdimm.c +0 -0

100644

hw/acpi/nvdimm.c +4 -0
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf, NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
hw/acpi/nvdimm.c +0 -2
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE, dsm_dma_arrea,
--
MST

#4 lore raw
Quoted 72 lines · Igor Mammedov
Quoted 30 lines · On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 29 lines · Erik
Quoted 17 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 7 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 3 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Quoted 11 lines
Quoted 4 lines
Quoted 1 line

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 4 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns.

What's wrong with it?
Method is complete so temporary objects
it has used went out of scope, all within spec rules and worked fine with linux and windows guests.

Quoted 20 lines
Quoted 1 line

I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001)

{
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID: Hardware ID
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?
Quoted 3 lines

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

Quoted 6 lines

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset RegionLen RegionOffset := TermArg => Integer
TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

So named object is not accepted,

might be worth checking what happens with actual OSPMs. If it does happen to work, we can try tweaking the ACPI spec to allow this.

Quoted 3 lines

we could have played games with
references and Type2Opcode but that didn't work nice with Windows ACPI parser. Hence local object.

A comment in code wouldn't hurt to explain this.

Quoted 7 lines

The reason why OperationRegion is dynamic, is that if we put it outside of method it will become static, and we would have to use Integer constant there (no named objects are allowed) and then patch it dynamically in bios loader.
I'd prefer to keep it as is, without introducing another hack like build_append_named_operation_region() to create it with know offset so firmware could patch it.

I agree to that.

Quoted 39 lines
Quoted 39 lines

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 33 lines
Quoted 33 lines
  

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index 59d6e42..fadebbd renamed from hw/acpi/nvdimm.c +0 -0

100644

hw/acpi/nvdimm.c +4 -0
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf, NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
hw/acpi/nvdimm.c +0 -2
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray *table_offsets,
 GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE, dsm_dma_arrea,
--
MST

#5 lore raw
Quoted 90 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, April 24, 2018 10:43 AM
To: Igor Mammedov <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 42 lines · Igor Mammedov
Quoted 39 lines · On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 28 lines · Erik
Quoted 18 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 8 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 7 lines
Quoted 4 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns.

What's wrong with it?
Method is complete so temporary objects it has used went out of scope, all within spec rules and worked fine with linux and windows guests.

Quoted 11 lines
Quoted 1 line

I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001) {
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID:

Hardware ID

Quoted 16 lines
Quoted 11 lines
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset
RegionLen RegionOffset := TermArg => Integer TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

Quoted 4 lines
Quoted 1 line

So named object is not accepted,

might be worth checking what happens with actual OSPMs.
If it does happen to work, we can try tweaking the ACPI spec to allow this.

I'm looking at the ACPI6.2a spec on page 840 and it says
TermArg := Type2Opcode | DataObject | Argterm |LocalTerm |NameString |SymbolicExpression

In our case, MEMA is a namestring so we should be able to avoid the local6 and insert MEMA instead. Just as long as the Named object appears in the table before the object is used, the windows parser should work fine.

After applying this patch, the only change in ASL/AML that I was expecting was for MEMA to be moved to the top of the definition block and leave everything else alone.

We usually do not recommend the creation of objects inside of control methods due to the overhead of creating/destroying these objects after each method call. So the one problem that I can see with this is that performance could bog down if this method is called a lot. If it is not called very frequently, then it's probably not a big deal.

Quoted 59 lines
Quoted 4 lines

we could have played games with
references and Type2Opcode but that didn't work nice with Windows ACPI parser. Hence local object.

A comment in code wouldn't hurt to explain this.

Quoted 7 lines

The reason why OperationRegion is dynamic, is that if we put it outside of method it will become static, and we would have to use Integer constant there (no named objects are allowed) and then patch it dynamically in bios loader.
I'd prefer to keep it as is, without introducing another hack like build_append_named_operation_region() to create it with know offset so firmware could patch it.

I agree to that.

Quoted 42 lines
Quoted 42 lines

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 36 lines
Quoted 36 lines

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index renamed from hw/acpi/nvdimm.c +0 -0

59d6e42..fadebbd
100644

hw/acpi/nvdimm.c +5 -2
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf,
+ NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE,
dsm_dma_arrea,
--
MST

#6 lore raw
Quoted 90 lines · Erik
Quoted 90 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, April 24, 2018 10:43 AM
To: Igor Mammedov <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 42 lines · Igor Mammedov
Quoted 39 lines · On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 28 lines · Erik
Quoted 18 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 8 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 7 lines
Quoted 4 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns.

What's wrong with it?
Method is complete so temporary objects it has used went out of scope, all within spec rules and worked fine with linux and windows guests.

Quoted 11 lines
Quoted 1 line

I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001) {
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID:

Hardware ID

Quoted 16 lines
Quoted 11 lines
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset
RegionLen RegionOffset := TermArg => Integer TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

So named object is not accepted,

might be worth checking what happens with actual OSPMs.
If it does happen to work, we can try tweaking the ACPI spec to allow this.

I'm looking at the ACPI6.2a spec on page 840 and it says
TermArg := Type2Opcode | DataObject | Argterm |LocalTerm |NameString |SymbolicExpression

Oh right, that's there since ACPI 6.0. As usual, the issue is that we can't easily check what does OSPM support.
This is really something worth fixing in the spec IMHO. We could just try and test a bunch of guest OSPMs and if they happen to work, switch to that. Lots of work for uncertain benefit.

Quoted 3 lines

In our case, MEMA is a namestring so we should be able to avoid the local6 and insert MEMA instead. Just as long as the Named object appears in the table before the object is used, the windows parser should work fine.

After applying this patch, the only change in ASL/AML that I was expecting was for MEMA to be moved to the top of the definition block and leave everything else alone.

Right. This is what I see.

Quoted 61 lines

We usually do not recommend the creation of objects inside of control methods due to the overhead of creating/destroying these objects after each method call. So the one problem that I can see with this is that performance could bog down if this method is called a lot. If it is not called very frequently, then it's probably not a big deal.

Quoted 59 lines
Quoted 4 lines

we could have played games with
references and Type2Opcode but that didn't work nice with Windows ACPI parser. Hence local object.

A comment in code wouldn't hurt to explain this.

Quoted 7 lines

The reason why OperationRegion is dynamic, is that if we put it outside of method it will become static, and we would have to use Integer constant there (no named objects are allowed) and then patch it dynamically in bios loader.
I'd prefer to keep it as is, without introducing another hack like build_append_named_operation_region() to create it with know offset so firmware could patch it.

I agree to that.

Quoted 42 lines
Quoted 42 lines

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 36 lines
Quoted 36 lines

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index renamed from hw/acpi/nvdimm.c +0 -0

59d6e42..fadebbd
100644

hw/acpi/nvdimm.c +5 -2
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf,
+ NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE,
dsm_dma_arrea,
--
MST

#7 lore raw
Quoted 93 lines · On Tue, 24 Apr 2018 21:06:37 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 92 lines · Erik
Quoted 92 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, April 24, 2018 10:43 AM
To: Igor Mammedov <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 42 lines · Igor Mammedov
Quoted 39 lines · On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 28 lines · Erik
Quoted 18 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 8 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 7 lines
Quoted 4 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns.

What's wrong with it?
Method is complete so temporary objects it has used went out of scope, all within spec rules and worked fine with linux and windows guests.

Quoted 11 lines
Quoted 1 line

I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001) {
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID:  

Hardware ID

Quoted 17 lines
Quoted 11 lines
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset
RegionLen RegionOffset := TermArg => Integer TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

So named object is not accepted,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

might be worth checking what happens with actual OSPMs.
If it does happen to work, we can try tweaking the ACPI spec to allow this.

I'm looking at the ACPI6.2a spec on page 840 and it says
TermArg := Type2Opcode | DataObject | Argterm |LocalTerm |NameString |SymbolicExpression

Oh right, that's there since ACPI 6.0.

Strange, I've rechecked AML definition of TermArg in 6.0 and 6.2a and it still says only

TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

For 6.2a, I'm looking at chapter "20.2.5 Term Objects Encoding" where exactly do you guys see that longer variant?

Quoted 6 lines

As usual, the issue is that
we can't easily check what does OSPM support. This is really something worth fixing in the spec IMHO. We could just try and test a bunch of guest OSPMs and if they happen to work, switch to that. Lots of work for uncertain benefit.

I think some windows versions weren't happy with it when we were trying to use dynamic operation regions with offset as namestring.

Quoted 67 lines
Quoted 3 lines

In our case, MEMA is a namestring so we should be able to avoid the local6 and insert MEMA instead. Just as long as the Named object appears in the table before the object is used, the windows parser should work fine.

After applying this patch, the only change in ASL/AML that I was expecting was for MEMA to be moved to the top of the definition block and leave everything else alone.

Right. This is what I see.

Quoted 61 lines

We usually do not recommend the creation of objects inside of control methods due to the overhead of creating/destroying these objects after each method call. So the one problem that I can see with this is that performance could bog down if this method is called a lot. If it is not called very frequently, then it's probably not a big deal.

Quoted 59 lines
Quoted 4 lines

we could have played games with
references and Type2Opcode but that didn't work nice with Windows ACPI parser. Hence local object.

A comment in code wouldn't hurt to explain this.

Quoted 7 lines

The reason why OperationRegion is dynamic, is that if we put it outside of method it will become static, and we would have to use Integer constant there (no named objects are allowed) and then patch it dynamically in bios loader.
I'd prefer to keep it as is, without introducing another hack like build_append_named_operation_region() to create it with know offset so firmware could patch it.

I agree to that.

Quoted 42 lines
Quoted 42 lines

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 36 lines
Quoted 36 lines
 

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index renamed from hw/acpi/nvdimm.c +0 -0

59d6e42..fadebbd
100644

hw/acpi/nvdimm.c +5 -2
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf,
+ NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE,
dsm_dma_arrea,
--
MST

#8 lore raw
Quoted 102 lines · On Wed, 25 Apr 2018 15:49:38 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 99 lines · On Tue, 24 Apr 2018 21:06:37 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 97 lines · Erik
Quoted 90 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, April 24, 2018 10:43 AM
To: Igor Mammedov <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 42 lines · Igor Mammedov
Quoted 39 lines · On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 28 lines · Erik
Quoted 18 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 8 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 7 lines
Quoted 4 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns.

What's wrong with it?
Method is complete so temporary objects it has used went out of scope, all within spec rules and worked fine with linux and windows guests.

Quoted 11 lines
Quoted 1 line

I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001) {
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID:    

Hardware ID

Quoted 16 lines
Quoted 11 lines
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset
RegionLen RegionOffset := TermArg => Integer TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

Quoted 4 lines
Quoted 1 line

So named object is not accepted,

might be worth checking what happens with actual OSPMs.
If it does happen to work, we can try tweaking the ACPI spec to allow this.

I'm looking at the ACPI6.2a spec on page 840 and it says
TermArg := Type2Opcode | DataObject | Argterm |LocalTerm |NameString |SymbolicExpression

Quoted 8 lines
Quoted 1 line

Oh right, that's there since ACPI 6.0.

Strange, I've rechecked AML definition of TermArg in 6.0 and 6.2a and it still says only

TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

For 6.2a, I'm looking at chapter "20.2.5 Term Objects Encoding" where exactly do you guys see that longer variant?

Found it in "19.2.3 ASL Root and Secondary Terms", so it looks like we have a bug in spec since definition of TermArg differs.

Quoted 80 lines
Quoted 6 lines

As usual, the issue is that
we can't easily check what does OSPM support. This is really something worth fixing in the spec IMHO. We could just try and test a bunch of guest OSPMs and if they happen to work, switch to that. Lots of work for uncertain benefit.

I think some windows versions weren't happy with it when we were trying to use dynamic operation regions with offset as namestring.

Quoted 67 lines
Quoted 3 lines

In our case, MEMA is a namestring so we should be able to avoid the local6 and insert MEMA instead. Just as long as the Named object appears in the table before the object is used, the windows parser should work fine.

After applying this patch, the only change in ASL/AML that I was expecting was for MEMA to be moved to the top of the definition block and leave everything else alone.

Right. This is what I see.

Quoted 61 lines

We usually do not recommend the creation of objects inside of control methods due to the overhead of creating/destroying these objects after each method call. So the one problem that I can see with this is that performance could bog down if this method is called a lot. If it is not called very frequently, then it's probably not a big deal.

Quoted 59 lines
Quoted 4 lines

we could have played games with
references and Type2Opcode but that didn't work nice with Windows ACPI parser. Hence local object.

A comment in code wouldn't hurt to explain this.

Quoted 7 lines

The reason why OperationRegion is dynamic, is that if we put it outside of method it will become static, and we would have to use Integer constant there (no named objects are allowed) and then patch it dynamically in bios loader.
I'd prefer to keep it as is, without introducing another hack like build_append_named_operation_region() to create it with know offset so firmware could patch it.

I agree to that.

Quoted 42 lines
Quoted 42 lines

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 36 lines
Quoted 36 lines
   

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index renamed from hw/acpi/nvdimm.c +0 -0

59d6e42..fadebbd
100644

hw/acpi/nvdimm.c +5 -2
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf,
+ NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE,
dsm_dma_arrea,
--
MST

#9 lore raw
In reply to Igor Mammedov
Quoted 102 lines · Igor Mammedov
Quoted 99 lines · On Tue, 24 Apr 2018 21:06:37 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 97 lines · Erik
Quoted 90 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, April 24, 2018 10:43 AM
To: Igor Mammedov <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 42 lines · Igor Mammedov
Quoted 39 lines · On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 28 lines · Erik
Quoted 18 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Monday, April 23, 2018 4:03 PM
To: [email protected]
Cc: Schmauss, Erik <[email protected]>; Igor Mammedov <[email protected]>; Xiao Guangrong <[email protected]>
Subject: [PATCH] acpi/nvdimm: remove forward name references

NVDIMM SSDT table references a name ("MEMA") before it is defined. This is reported to no longer be supported since Linux 4.17-rc1.

While arguably Linux needs to keep working on old hypervisors, and other OSes seem fine with our behaviour, it seems cleaner to have the definition appear in the SSDT before use.

Quoted 8 lines

---

Hi Erik,
could you pls test the issue and report whether it addresses your concern? I can't

Hi Michael,

Quoted 7 lines
Quoted 4 lines

do much to fix past releases which IIUC shipped this code since 2.6.0 about a year ago.

Lightly tested with Linux only.

I'm looking at the ASL tables generated by make check-qtest-x86_64. This line

which line?

Quoted 19 lines
Quoted 4 lines
Quoted 4 lines

ends up generating a strange ACPI table where the Operation region and field declarations are stuck inside the NCAL method which is called from _DSM. If we create the operation region and methods inside methods, they disappear after the NCAL method returns.

What's wrong with it?
Method is complete so temporary objects it has used went out of scope, all within spec rules and worked fine with linux and windows guests.

Quoted 11 lines
Quoted 1 line

I think nvdimm_build_common_dsm() needs some refining.

What exactly do you refer to?

DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001) {
    Name (MEMA, 0x07FFE000)
    Scope (\_SB)
    {
        Device (NVDR)
        {
            Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID:  

Hardware ID

Quoted 16 lines
Quoted 11 lines
            Method (NCAL, 5, Serialized)
            {
                Local6 = MEMA /* \MEMA */
                OperationRegion (NPIO, SystemIO, 0x0A18, 0x04)
                OperationRegion (NRAM, SystemMemory, Local6, 0x1000)

		^^^ this?

I agree the NPIO could be moved out.
Don't really understand why is Local6 needed - can't MEMA be used directly? Assuming it isn't NRAM could be moved out too.

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset
RegionLen RegionOffset := TermArg => Integer TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

Quoted 4 lines
Quoted 1 line

So named object is not accepted,

might be worth checking what happens with actual OSPMs.
If it does happen to work, we can try tweaking the ACPI spec to allow this.

I'm looking at the ACPI6.2a spec on page 840 and it says
TermArg := Type2Opcode | DataObject | Argterm |LocalTerm |NameString |SymbolicExpression

Quoted 8 lines
Quoted 1 line

Oh right, that's there since ACPI 6.0.

Strange, I've rechecked AML definition of TermArg in 6.0 and 6.2a and it still says only

TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

For 6.2a, I'm looking at chapter "20.2.5 Term Objects Encoding" where exactly do you guys see that longer variant?

Oh interesting. That's in
19.2.3 ASL Root and Secondary Terms

How come it's not the same?

Quoted 10 lines
Quoted 7 lines

As usual, the issue is that
we can't easily check what does OSPM support. This is really something worth fixing in the spec IMHO. We could just try and test a bunch of guest OSPMs and if they happen to work, switch to that. Lots of work for uncertain benefit.

I think some windows versions weren't happy with it when we were trying to use dynamic operation regions with offset as namestring.

Good to know, thanks.

Quoted 68 lines
Quoted 68 lines
Quoted 4 lines

In our case, MEMA is a namestring so we should be able to avoid the local6 and insert MEMA instead. Just as long as the Named object appears in the table before the object is used, the windows parser should work fine.

After applying this patch, the only change in ASL/AML that I was expecting was for MEMA to be moved to the top of the definition block and leave everything else alone.

Right. This is what I see.

Quoted 61 lines

We usually do not recommend the creation of objects inside of control methods due to the overhead of creating/destroying these objects after each method call. So the one problem that I can see with this is that performance could bog down if this method is called a lot. If it is not called very frequently, then it's probably not a big deal.

Quoted 59 lines
Quoted 4 lines

we could have played games with
references and Type2Opcode but that didn't work nice with Windows ACPI parser. Hence local object.

A comment in code wouldn't hurt to explain this.

Quoted 7 lines

The reason why OperationRegion is dynamic, is that if we put it outside of method it will become static, and we would have to use Integer constant there (no named objects are allowed) and then patch it dynamically in bios loader.
I'd prefer to keep it as is, without introducing another hack like build_append_named_operation_region() to create it with know offset so firmware could patch it.

I agree to that.

Quoted 42 lines
Quoted 42 lines

It all seems suboptimal but given the method is serialized, I don't see anything wrong with it as such.

Quoted 36 lines
Quoted 36 lines
 

 hw/acpi/nvdimm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c index renamed from hw/acpi/nvdimm.c +0 -0

59d6e42..fadebbd
100644

hw/acpi/nvdimm.c +5 -2
@@ -1234,6 +1234,10 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
     ssdt = init_aml_allocator();
     acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader));
 
+    /* Storage for the memory address */
+    mem_addr_offset = table_data->len +
+        build_append_named_dword(ssdt->buf,
+ NVDIMM_ACPI_MEM_ADDR);
+
     sb_scope = aml_scope("\\_SB");
 
     dev = aml_device("NVDR");
@@ -1266,8 +1270,6 @@ static void nvdimm_build_ssdt(GArray
 *table_offsets, GArray *table_data,
 
     /* copy AML table into ACPI tables blob and patch header there */
     g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len);
-    mem_addr_offset = build_append_named_dword(table_data,
-                                               NVDIMM_ACPI_MEM_ADDR);
 
     bios_linker_loader_alloc(linker,

NVDIMM_DSM_MEM_FILE,
dsm_dma_arrea,
--
MST

#10 lore raw
Quoted 20 lines · On Wed, 25 Apr 2018 17:17:04 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Tue, 24 Apr 2018 21:06:37 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 15 lines · Erik
Quoted 15 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, April 24, 2018 10:43 AM
To: Igor Mammedov <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 3 lines · Igor Mammedov

On Tue, 24 Apr 2018 04:02:40 +0300
"Michael S. Tsirkin" <[email protected]> wrote:

[...]

Quoted 19 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

From spec
DefOpRegion := OpRegionOp NameString RegionSpace RegionOffset
RegionLen RegionOffset := TermArg => Integer TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

So named object is not accepted,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

might be worth checking what happens with actual OSPMs.
If it does happen to work, we can try tweaking the ACPI spec to allow this.

I'm looking at the ACPI6.2a spec on page 840 and it says
TermArg := Type2Opcode | DataObject | Argterm |LocalTerm |NameString |SymbolicExpression

Oh right, that's there since ACPI 6.0.

Strange, I've rechecked AML definition of TermArg in 6.0 and 6.2a and it still says only

TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

Quoted 7 lines
Quoted 2 lines

For 6.2a, I'm looking at chapter "20.2.5 Term Objects Encoding" where exactly do you guys see that longer variant?

Oh interesting. That's in
19.2.3 ASL Root and Secondary Terms

How come it's not the same?

bugs are everywhere, see "20.2.5 Term Objects Encoding"

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

As usual, the issue is that
we can't easily check what does OSPM support. This is really something worth fixing in the spec IMHO. We could just try and test a bunch of guest OSPMs and if they happen to work, switch to that. Lots of work for uncertain benefit.

Quoted 6 lines
Quoted 3 lines

I think some windows versions weren't happy with it when we were trying to use dynamic operation regions with offset as namestring.

Good to know, thanks.

I'll try to retest MS VMs I have here, to see which one breaks.

#11 lore raw
Quoted 59 lines

-----Original Message-----
From: Igor Mammedov [mailto:[email protected]]
Sent: Wednesday, April 25, 2018 8:32 AM
To: Michael S. Tsirkin <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 22 lines · On Wed, 25 Apr 2018 17:17:04 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 21 lines · Igor Mammedov
Quoted 18 lines · On Tue, 24 Apr 2018 21:06:37 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 17 lines · Erik
Quoted 17 lines

-----Original Message-----
From: Michael S. Tsirkin [mailto:[email protected]]
Sent: Tuesday, April 24, 2018 10:43 AM
To: Igor Mammedov <[email protected]>
Cc: Schmauss, Erik <[email protected]>; [email protected]; Xiao Guangrong <[email protected]>; Williams, Dan J <[email protected]>
Subject: Re: [PATCH] acpi/nvdimm: remove forward name references

Quoted 3 lines · Igor Mammedov

On Tue, 24 Apr 2018 04:02:40 +0300 "Michael S. Tsirkin" <[email protected]> wrote:

[...]

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

From spec
DefOpRegion := OpRegionOp NameString RegionSpace
RegionOffset RegionLen RegionOffset := TermArg => Integer TermArg := Type2Opcode
| DataObject | ArgObj | LocalObj

So named object is not accepted,

might be worth checking what happens with actual OSPMs.
If it does happen to work, we can try tweaking the ACPI spec to allow

this.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I'm looking at the ACPI6.2a spec on page 840 and it says TermArg := Type2Opcode | DataObject | Argterm |LocalTerm

|NameString |SymbolicExpression

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Oh right, that's there since ACPI 6.0.

Strange, I've rechecked AML definition of TermArg in 6.0 and 6.2a and it still says only

TermArg := Type2Opcode | DataObject | ArgObj | LocalObj

Quoted 22 lines
Quoted 7 lines
Quoted 2 lines

For 6.2a, I'm looking at chapter "20.2.5 Term Objects Encoding" where exactly do you guys see that longer variant?

Oh interesting. That's in
19.2.3 ASL Root and Secondary Terms

How come it's not the same?

bugs are everywhere, see "20.2.5 Term Objects Encoding"

Quoted 13 lines
Quoted 10 lines
Quoted 8 lines

As usual, the issue is that
we can't easily check what does OSPM support.
This is really something worth fixing in the spec IMHO. We could just try and test a bunch of guest OSPMs and if they happen to work, switch to that. Lots of work for uncertain benefit.

I think some windows versions weren't happy with it when we were trying to use dynamic operation regions with offset as namestring.

Good to know, thanks.

I have made a big mistake. I was comparing the resulting SSDT of this patch to an SSDT Generated by a much older version of kvm/qemu. The latest kvm/qemu upstream builds the SSDT with the operation region contained inside of methods. This should resolve MEMA of the operation region when the method is invoked. The older SSDT that I was looking at declared the memory region outside of methods and had a forward reference to MEMA which we no longer support.

So the latest qemu/kvm works just fine and this patch is not needed, Dan has confirmed that the latest qemu/kvm works for his nvdimm setup.

Thanks for all of the help and I'm sorry for any confusion that I might have caused!

Quoted 2 lines

I'll try to retest MS VMs I have here, to see which one breaks.

#12 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line

Good to know, thanks.

I have made a big mistake. I was comparing the resulting SSDT of this patch to an SSDT Generated by a much older version of kvm/qemu. The latest kvm/qemu upstream builds the SSDT with the operation region contained inside of methods. This should resolve MEMA of the operation region when the method is invoked. The older SSDT that I was looking at declared the memory region outside of methods and had a forward reference to MEMA which we no longer support.

Quoted 4 lines

So the latest qemu/kvm works just fine and this patch is not needed, Dan has confirmed that the latest qemu/kvm works for his nvdimm setup.

Thanks for all of the help and I'm sorry for any confusion that I might have caused!

Yes, my bad as well. I saw the regression on v2.8.0, but updating to latest qemu-mainline also fixes the problem for me.

Thanks for the debug.