Skip to contentSkip to conversation

Support ACPI NVDIMM Label Methods

PATCH Superseded Robert Hoo 2 participants 17 messages Sep 1, 2022 – Sep 22, 2022

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Robert Hoo

author
#0 lore raw

v3 cover Support ACPI NVDIMM Label Methods

Originally NVDIMM Label methods was defined in Intel PMEM _DSM Interface Spec [1], of function index 4, 5 and 6.
Recent ACPI spec [2] has deprecated those _DSM methods with ACPI NVDIMM Label Methods _LS{I,R,W}. The essence of these functions has no changes.

This patch set is to update QEMU emulation on this, as well as update bios-table-test golden binaries.

[1] Intel PMEM _DSM Interface Spec v2.0, 3.10 Deprecated Functions
https://pmem.io/documents/IntelOptanePMem_DSM_Interface-V2.0.pdf
[2] ACPI Spec v6.4, 6.5.10 NVDIMM Label Methods
https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf

---
Change Log:
v2 --> v3:
Patch of nvdimm_debug() --> qemu trace, has been separated and already upstream'ed.
Patch of accepting _DSM rev.2 is dropped, as unnecessary. Roll back implementation to the idea of simply wrapper _DSM.

v1 --> v2:
Almost rewritten
Separate Patch 2
Dance with tests/qtest/bios-table-tests
Add trace event

Robert Hoo (5):
tests/acpi: allow SSDT changes
acpi/ssdt: Fix aml_or() and aml_and() in if clause acpi/nvdimm: define macro for NVDIMM Device _DSM acpi/nvdimm: Implement ACPI NVDIMM Label Methods test/acpi/bios-tables-test: SSDT: update golden master binaries

 hw/acpi/nvdimm.c                 | 102 +++++++++++++++++++++++++++++--
 tests/data/acpi/pc/SSDT.dimmpxm  | Bin 734 -> 1893 bytes
 tests/data/acpi/q35/SSDT.dimmpxm | Bin 734 -> 1893 bytes
 3 files changed, 96 insertions(+), 6 deletions(-)
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH v3 1/5 tests/acpi: allow SSDT changes

---
 tests/qtest/bios-tables-test-allowed-diff.h | 2 ++
 1 file changed, 2 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +2 -0
index dfb8523c8b..eb8bae1407 100644
@@ -1 +1,3 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/SSDT.dimmpxm",
+"tests/data/acpi/q35/SSDT.dimmpxm",
Signature · 1 line
2.31.1
author
#2 lore raw

PATCH v3 2/5 acpi/ssdt: Fix aml_or() and aml_and() in if clause

In reply to Robert Hoo

In If condition, using bitwise and/or, rather than logical and/or.

The result change in AML code:

If (((Local6 == Zero) | (Arg0 != Local0)))
==>
If (((Local6 == Zero) || (Arg0 != Local0)))

If (((ObjectType (Arg3) == 0x04) & (SizeOf (Arg3) == One))) ==>
If (((ObjectType (Arg3) == 0x04) && (SizeOf (Arg3) == One)))

Fixes 90623ebf603 ("nvdimm acpi: check UUID")
Fixes 4568c948066 ("nvdimm acpi: save arg3 of _DSM method")
---
 hw/acpi/nvdimm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
hw/acpi/nvdimm.c +3 -4
index 31e46df0bd..201317c611 100644
@@ -1037,7 +1037,7 @@ static void nvdimm_build_common_dsm(Aml *dev,
 
     uuid_invalid = aml_lnot(aml_equal(uuid, expected_uuid));
 
-    unsupport = aml_if(aml_or(unpatched, uuid_invalid, NULL));
+    unsupport = aml_if(aml_lor(unpatched, uuid_invalid));
 
     /*
      * function 0 is called to inquire what functions are supported by
@@ -1069,10 +1069,9 @@ static void nvdimm_build_common_dsm(Aml *dev,
      * in the DSM Spec.
      */
     pckg = aml_arg(3);
-    ifctx = aml_if(aml_and(aml_equal(aml_object_type(pckg),
+    ifctx = aml_if(aml_land(aml_equal(aml_object_type(pckg),
                    aml_int(4 /* Package */)) /* It is a Package? */,
-                   aml_equal(aml_sizeof(pckg), aml_int(1)) /* 1 element? */,
-                   NULL));
+                   aml_equal(aml_sizeof(pckg), aml_int(1)) /* 1 element? */));
 
     pckg_index = aml_local(2);
     pckg_buf = aml_local(3);
Signature · 1 line
2.31.1
author
#3 lore raw

PATCH v3 3/5 acpi/nvdimm: define macro for NVDIMM Device _DSM

In reply to Robert Hoo

Since it will be heavily used in next patch, define macro NVDIMM_DEVICE_DSM_UUID for "4309AC30-0D11-11E4-9191-0800200C9A66", which is NVDIMM device specific method uuid defined in NVDIMM _DSM interface spec, Section 3. [1]

No functional changes in this patch.

[1] https://pmem.io/documents/IntelOptanePMem_DSM_Interface-V2.0.pdf

---
 hw/acpi/nvdimm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c +2 -2
index 201317c611..afff911c1e 100644
@@ -922,6 +922,7 @@ void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io,
 #define NVDIMM_DSM_RFIT_STATUS  "RSTA"
 
 #define NVDIMM_QEMU_RSVD_UUID   "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62"
+#define NVDIMM_DEVICE_DSM_UUID  "4309AC30-0D11-11E4-9191-0800200C9A66"
 
 static void nvdimm_build_common_dsm(Aml *dev,
                                     NVDIMMState *nvdimm_state)
@@ -1029,8 +1030,7 @@ static void nvdimm_build_common_dsm(Aml *dev,
                /* UUID for QEMU internal use */), expected_uuid));
     aml_append(elsectx, ifctx);
     elsectx2 = aml_else();
-    aml_append(elsectx2, aml_store(
-               aml_touuid("4309AC30-0D11-11E4-9191-0800200C9A66")
+    aml_append(elsectx2, aml_store(aml_touuid(NVDIMM_DEVICE_DSM_UUID)
                /* UUID for NVDIMM Devices */, expected_uuid));
     aml_append(elsectx, elsectx2);
     aml_append(method, elsectx);
Signature · 1 line
2.31.1
Reviewed-by on v3 3/5
#4 lore raw

Re: [PATCH v3 3/5] acpi/nvdimm: define macro for NVDIMM Device _DSM

Quoted 11 lines · On Thu, 1 Sep 2022 11:27:19 +0800 Robert Hoo <[email protected]> wrote:

Since it will be heavily used in next patch, define macro NVDIMM_DEVICE_DSM_UUID for "4309AC30-0D11-11E4-9191-0800200C9A66", which is NVDIMM device specific method uuid defined in NVDIMM _DSM interface spec, Section 3. [1]

No functional changes in this patch.

[1] https://pmem.io/documents/IntelOptanePMem_DSM_Interface-V2.0.pdf

Quoted 26 lines
---
 hw/acpi/nvdimm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/acpi/nvdimm.c +2 -2
index 201317c611..afff911c1e 100644
@@ -922,6 +922,7 @@ void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io,
 #define NVDIMM_DSM_RFIT_STATUS  "RSTA"
 
 #define NVDIMM_QEMU_RSVD_UUID   "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62"
+#define NVDIMM_DEVICE_DSM_UUID  "4309AC30-0D11-11E4-9191-0800200C9A66"
 
 static void nvdimm_build_common_dsm(Aml *dev,
                                     NVDIMMState *nvdimm_state)
@@ -1029,8 +1030,7 @@ static void nvdimm_build_common_dsm(Aml *dev,
                /* UUID for QEMU internal use */), expected_uuid));
     aml_append(elsectx, ifctx);
     elsectx2 = aml_else();
-    aml_append(elsectx2, aml_store(
-               aml_touuid("4309AC30-0D11-11E4-9191-0800200C9A66")
+    aml_append(elsectx2, aml_store(aml_touuid(NVDIMM_DEVICE_DSM_UUID)
                /* UUID for NVDIMM Devices */, expected_uuid));
     aml_append(elsectx, elsectx2);
     aml_append(method, elsectx);
author
#5 lore raw

PATCH v3 4/5 acpi/nvdimm: Implement ACPI NVDIMM Label Methods

In reply to Robert Hoo

Recent ACPI spec [1] has defined NVDIMM Label Methods _LS{I,R,W}, which deprecates corresponding _DSM Functions defined by PMEM _DSM Interface spec [2].

Since the semantics of the new Label Methods are same as old _DSM methods, the implementations here simply wrapper old ones.

ASL form diff can be found in next patch of updating golden master binaries.

[1] ACPI Spec v6.4, 6.5.10 NVDIMM Label Methods
https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
[2] Intel PMEM _DSM Interface Spec v2.0, 3.10 Deprecated Functions
https://pmem.io/documents/IntelOptanePMem_DSM_Interface-V2.0.pdf

---
 hw/acpi/nvdimm.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
hw/acpi/nvdimm.c +91 -0
index afff911c1e..516acfe53b 100644
@@ -1243,6 +1243,7 @@ static void nvdimm_build_fit(Aml *dev)
 static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots)
 {
     uint32_t slot;
+    Aml *method, *pkg, *field, *com_call;
 
     for (slot = 0; slot < ram_slots; slot++) {
         uint32_t handle = nvdimm_slot_to_handle(slot);
@@ -1260,6 +1261,96 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots)
          */
         aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle)));
 
+        /*
+         * ACPI v6.4: Section 6.5.10 NVDIMM Label Methods
+         */
+        /* _LSI */
+        method = aml_method("_LSI", 0, AML_SERIALIZED);
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(4), aml_int(0),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(0)));
+
+        aml_append(method, aml_create_dword_field(aml_local(0),
+                                                  aml_int(0), "STTS"));
+        aml_append(method, aml_create_dword_field(aml_local(0), aml_int(4),
+                                                  "SLSA"));
+        aml_append(method, aml_create_dword_field(aml_local(0), aml_int(8),
+                                                  "MAXT"));
+
+        pkg = aml_package(3);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("SLSA"));
+        aml_append(pkg, aml_name("MAXT"));
+        aml_append(method, aml_name_decl("RET", pkg));
+        aml_append(method, aml_return(aml_name("RET")));
+
+        aml_append(nvdimm_dev, method);
+
+        /* _LSR */
+        method = aml_method("_LSR", 2, AML_SERIALIZED);
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8, NULL)));
+
+        aml_append(method, aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(0), "OFST"));
+        aml_append(method, aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(4), "LEN"));
+        aml_append(method, aml_store(aml_arg(0), aml_name("OFST")));
+        aml_append(method, aml_store(aml_arg(1), aml_name("LEN")));
+
+        pkg = aml_package(1);
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(5), aml_name("PKG1"),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0), "STTS");
+        aml_append(method, field);
+        field = aml_create_field(aml_local(3), aml_int(32),
+                                 aml_shiftleft(aml_name("LEN"), aml_int(3)),
+                                 "LDAT");
+        aml_append(method, field);
+        aml_append(method, aml_name_decl("LSA", aml_buffer(0, NULL)));
+        aml_append(method, aml_to_buffer(aml_name("LDAT"), aml_name("LSA")));
+        pkg = aml_package(2);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("LSA"));
+        aml_append(method, aml_name_decl("RET", pkg));
+        aml_append(method, aml_return(aml_name("RET")));
+        aml_append(nvdimm_dev, method);
+
+        /* _LSW */
+        method = aml_method("_LSW", 3, AML_SERIALIZED);
+        aml_append(method, aml_store(aml_arg(2), aml_local(2)));
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8, NULL)));
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(0), "OFST");
+        aml_append(method, field);
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(4), "TLEN");
+        aml_append(method, field);
+        aml_append(method, aml_store(aml_arg(0), aml_name("OFST")));
+        aml_append(method, aml_store(aml_arg(1), aml_name("TLEN")));
+
+        aml_append(method, aml_concatenate(aml_name("INPT"), aml_local(2),
+                                            aml_name("INPT")));
+        pkg = aml_package(1);
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(6), aml_name("PKG1"),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0), "STTS");
+        aml_append(method, field);
+        aml_append(method, aml_return(aml_to_integer(aml_name("STTS"))));
+        aml_append(nvdimm_dev, method);
+
         nvdimm_build_device_dsm(nvdimm_dev, handle);
         aml_append(root_dev, nvdimm_dev);
     }
Signature · 1 line
2.31.1
#6 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 10 lines · On Thu, 1 Sep 2022 11:27:20 +0800 Robert Hoo <[email protected]> wrote:

Recent ACPI spec [1] has defined NVDIMM Label Methods _LS{I,R,W}, which deprecates corresponding _DSM Functions defined by PMEM _DSM Interface spec [2].

Since the semantics of the new Label Methods are same as old _DSM methods, the implementations here simply wrapper old ones.

ASL form diff can be found in next patch of updating golden master binaries.

Quoted 7 lines

[1] ACPI Spec v6.4, 6.5.10 NVDIMM Label Methods
https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
[2] Intel PMEM _DSM Interface Spec v2.0, 3.10 Deprecated Functions
https://pmem.io/documents/IntelOptanePMem_DSM_Interface-V2.0.pdf

looks more or less fine except of excessive use of named variables which creates global scope variables.

I'd suggest to store temporary buffers/packages in LocalX variales, you should be able to do that for everything modulo aml_create_dword_field().

see an example below

Quoted 33 lines
---
 hw/acpi/nvdimm.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
hw/acpi/nvdimm.c +14 -0
index afff911c1e..516acfe53b 100644
@@ -1243,6 +1243,7 @@ static void nvdimm_build_fit(Aml *dev)
 static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots)
 {
     uint32_t slot;
+    Aml *method, *pkg, *field, *com_call;
 
     for (slot = 0; slot < ram_slots; slot++) {
         uint32_t handle = nvdimm_slot_to_handle(slot);
@@ -1260,6 +1261,96 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots)
          */
         aml_append(nvdimm_dev, aml_name_decl("_ADR", aml_int(handle)));
 
+        /*
+         * ACPI v6.4: Section 6.5.10 NVDIMM Label Methods
+         */
+        /* _LSI */
+        method = aml_method("_LSI", 0, AML_SERIALIZED);
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(4), aml_int(0),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(0)));
+
+        aml_append(method, aml_create_dword_field(aml_local(0),
+                                                  aml_int(0), "STTS"));

hw/acpi/nvdimm.c static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) · line 1286

Quoted 10 lines
hw/acpi/nvdimm.c +10 -0
+        aml_append(method, aml_create_dword_field(aml_local(0), aml_int(4),
+                                                  "SLSA"));
+        aml_append(method, aml_create_dword_field(aml_local(0), aml_int(8),
+                                                  "MAXT"));
+
+        pkg = aml_package(3);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("SLSA"));
+        aml_append(pkg, aml_name("MAXT"));
+        aml_append(method, aml_name_decl("RET", pkg));

ex: put it in local instead of named variable and return that the same applies to other named temporary named variables.

Quoted 55 lines
hw/acpi/nvdimm.c +55 -0
+        aml_append(method, aml_return(aml_name("RET")));
+
+        aml_append(nvdimm_dev, method);
+
+        /* _LSR */
+        method = aml_method("_LSR", 2, AML_SERIALIZED);
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8, NULL)));
+
+        aml_append(method, aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(0), "OFST"));
+        aml_append(method, aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(4), "LEN"));
+        aml_append(method, aml_store(aml_arg(0), aml_name("OFST")));
+        aml_append(method, aml_store(aml_arg(1), aml_name("LEN")));
+
+        pkg = aml_package(1);
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(5), aml_name("PKG1"),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0), "STTS");
+        aml_append(method, field);
+        field = aml_create_field(aml_local(3), aml_int(32),
+                                 aml_shiftleft(aml_name("LEN"), aml_int(3)),
+                                 "LDAT");
+        aml_append(method, field);
+        aml_append(method, aml_name_decl("LSA", aml_buffer(0, NULL)));
+        aml_append(method, aml_to_buffer(aml_name("LDAT"), aml_name("LSA")));
+        pkg = aml_package(2);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("LSA"));
+        aml_append(method, aml_name_decl("RET", pkg));
+        aml_append(method, aml_return(aml_name("RET")));
+        aml_append(nvdimm_dev, method);
+
+        /* _LSW */
+        method = aml_method("_LSW", 3, AML_SERIALIZED);
+        aml_append(method, aml_store(aml_arg(2), aml_local(2)));
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8, NULL)));
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(0), "OFST");
+        aml_append(method, field);
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(4), "TLEN");
+        aml_append(method, field);
+        aml_append(method, aml_store(aml_arg(0), aml_name("OFST")));
+        aml_append(method, aml_store(aml_arg(1), aml_name("TLEN")));
+
+        aml_append(method, aml_concatenate(aml_name("INPT"), aml_local(2),
+                                            aml_name("INPT")));
+        pkg = aml_package(1);

hw/acpi/nvdimm.c static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) · line 1351

Quoted 10 lines
hw/acpi/nvdimm.c +10 -0
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(6), aml_name("PKG1"),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0), "STTS");
+        aml_append(method, field);
+        aml_append(method, aml_return(aml_to_integer(aml_name("STTS"))));

why do you need explicitly convert DWORD field to integer?
it should be fine to return STTS directly (implicit conversion should take care of the rest)

Quoted 5 lines
hw/acpi/nvdimm.c +2 -0
+        aml_append(nvdimm_dev, method);
+
         nvdimm_build_device_dsm(nvdimm_dev, handle);
         aml_append(root_dev, nvdimm_dev);
     }
author
#7 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 77 lines · Igor Mammedov
Quoted 12 lines · On Thu, 1 Sep 2022 11:27:20 +0800 Robert Hoo <[email protected]> wrote:

Recent ACPI spec [1] has defined NVDIMM Label Methods _LS{I,R,W}, which
deprecates corresponding _DSM Functions defined by PMEM _DSM Interface spec
[2].

Since the semantics of the new Label Methods are same as old _DSM methods, the implementations here simply wrapper old ones.

ASL form diff can be found in next patch of updating golden master binaries.

Quoted 7 lines

[1] ACPI Spec v6.4, 6.5.10 NVDIMM Label Methods
https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
[2] Intel PMEM _DSM Interface Spec v2.0, 3.10 Deprecated Functions
https://pmem.io/documents/IntelOptanePMem_DSM_Interface-V2.0.pdf

looks more or less fine except of excessive use of named variables which creates global scope variables.

I'd suggest to store temporary buffers/packages in LocalX variales, you should be able to do that for everything modulo aml_create_dword_field().

see an example below

Quoted 45 lines
---
 hw/acpi/nvdimm.c | 91
++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
hw/acpi/nvdimm.c +1 -0
index afff911c1e..516acfe53b 100644
@@ -1243,6 +1243,7 @@ static void nvdimm_build_fit(Aml *dev)
 static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t
 ram_slots)
 {
     uint32_t slot;
+    Aml *method, *pkg, *field, *com_call;
 
     for (slot = 0; slot < ram_slots; slot++) {
         uint32_t handle = nvdimm_slot_to_handle(slot);
hw/acpi/nvdimm.c +14 -0
@@ -1260,6 +1261,96 @@ static void nvdimm_build_nvdimm_devices(Aml
 *root_dev, uint32_t ram_slots)
          */
         aml_append(nvdimm_dev, aml_name_decl("_ADR",
 aml_int(handle)));
 
+        /*
+         * ACPI v6.4: Section 6.5.10 NVDIMM Label Methods
+         */
+        /* _LSI */
+        method = aml_method("_LSI", 0, AML_SERIALIZED);
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(4), aml_int(0),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(0)));
+
+        aml_append(method, aml_create_dword_field(aml_local(0),
+                                                  aml_int(0),
 "STTS"));
+        aml_append(method, aml_create_dword_field(aml_local(0),

aml_int(4),

hw/acpi/nvdimm.c +2 -0
+                                                  "SLSA"));
+        aml_append(method, aml_create_dword_field(aml_local(0),

aml_int(8),

hw/acpi/nvdimm.c +2 -0
+                                                  "MAXT"));
+
Quoted 8 lines

hw/acpi/nvdimm.c static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) · line 1286

Quoted 5 lines
hw/acpi/nvdimm.c +5 -0
+        pkg = aml_package(3);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("SLSA"));
+        aml_append(pkg, aml_name("MAXT"));
+        aml_append(method, aml_name_decl("RET", pkg));

ex: put it in local instead of named variable and return that the same applies to other named temporary named variables.

Could you help provide the example in form of ASL? Thanks.

Quoted 99 lines
Quoted 86 lines
hw/acpi/nvdimm.c +7 -0
+        aml_append(method, aml_return(aml_name("RET")));
+
+        aml_append(nvdimm_dev, method);
+
+        /* _LSR */
+        method = aml_method("_LSR", 2, AML_SERIALIZED);
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8,

NULL)));

hw/acpi/nvdimm.c +2 -0
+
+        aml_append(method,

aml_create_dword_field(aml_name("INPT"),
+ aml_int(0),
"OFST"));
+ aml_append(method,
aml_create_dword_field(aml_name("INPT"),
+ aml_int(4),
"LEN"));
+ aml_append(method, aml_store(aml_arg(0),
aml_name("OFST")));
+ aml_append(method, aml_store(aml_arg(1),
aml_name("LEN")));

hw/acpi/nvdimm.c +8 -0
+
+        pkg = aml_package(1);
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(5),

aml_name("PKG1"),

hw/acpi/nvdimm.c +3 -0
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0),

"STTS");

hw/acpi/nvdimm.c +3 -0
+        aml_append(method, field);
+        field = aml_create_field(aml_local(3), aml_int(32),
+                                 aml_shiftleft(aml_name("LEN"),

aml_int(3)),

hw/acpi/nvdimm.c +3 -0
+                                 "LDAT");
+        aml_append(method, field);
+        aml_append(method, aml_name_decl("LSA", aml_buffer(0,

NULL)));
+ aml_append(method, aml_to_buffer(aml_name("LDAT"),
aml_name("LSA")));

hw/acpi/nvdimm.c +11 -0
+        pkg = aml_package(2);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("LSA"));
+        aml_append(method, aml_name_decl("RET", pkg));
+        aml_append(method, aml_return(aml_name("RET")));
+        aml_append(nvdimm_dev, method);
+
+        /* _LSW */
+        method = aml_method("_LSW", 3, AML_SERIALIZED);
+        aml_append(method, aml_store(aml_arg(2), aml_local(2)));
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8,

NULL)));

hw/acpi/nvdimm.c +2 -0
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(0),

"OFST");

hw/acpi/nvdimm.c +3 -0
+        aml_append(method, field);
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(4),

"TLEN");

hw/acpi/nvdimm.c +2 -0
+        aml_append(method, field);
+        aml_append(method, aml_store(aml_arg(0),

aml_name("OFST")));
+ aml_append(method, aml_store(aml_arg(1),
aml_name("TLEN")));

hw/acpi/nvdimm.c +2 -0
+
+        aml_append(method, aml_concatenate(aml_name("INPT"),

aml_local(2),

hw/acpi/nvdimm.c +7 -0
+                                            aml_name("INPT")));
+        pkg = aml_package(1);
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(6),

aml_name("PKG1"),

hw/acpi/nvdimm.c +3 -0
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0),

"STTS");

hw/acpi/nvdimm.c +2 -0
+        aml_append(method, field);
+        aml_append(method,
Quoted 1 line

aml_return(aml_to_integer(aml_name("STTS"))));

why do you need explicitly convert DWORD field to integer? it should be fine to return STTS directly (implicit conversion should take care of the rest)

Quoted 5 lines
hw/acpi/nvdimm.c +2 -0
+        aml_append(nvdimm_dev, method);
+
         nvdimm_build_device_dsm(nvdimm_dev, handle);
         aml_append(root_dev, nvdimm_dev);
     }
#8 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 87 lines · On Fri, 09 Sep 2022 22:02:34 +0800 Robert Hoo <[email protected]> wrote:
Quoted 77 lines · Igor Mammedov
Quoted 12 lines · On Thu, 1 Sep 2022 11:27:20 +0800 Robert Hoo <[email protected]> wrote:

Recent ACPI spec [1] has defined NVDIMM Label Methods _LS{I,R,W}, which
deprecates corresponding _DSM Functions defined by PMEM _DSM Interface spec
[2].

Since the semantics of the new Label Methods are same as old _DSM methods, the implementations here simply wrapper old ones.

ASL form diff can be found in next patch of updating golden master binaries.

Quoted 7 lines

[1] ACPI Spec v6.4, 6.5.10 NVDIMM Label Methods
https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
[2] Intel PMEM _DSM Interface Spec v2.0, 3.10 Deprecated Functions
https://pmem.io/documents/IntelOptanePMem_DSM_Interface-V2.0.pdf

looks more or less fine except of excessive use of named variables which creates global scope variables.

I'd suggest to store temporary buffers/packages in LocalX variales, you should be able to do that for everything modulo aml_create_dword_field().

see an example below

Quoted 45 lines
---
 hw/acpi/nvdimm.c | 91
++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
hw/acpi/nvdimm.c +1 -0
index afff911c1e..516acfe53b 100644
@@ -1243,6 +1243,7 @@ static void nvdimm_build_fit(Aml *dev)
 static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t
 ram_slots)
 {
     uint32_t slot;
+    Aml *method, *pkg, *field, *com_call;
 
     for (slot = 0; slot < ram_slots; slot++) {
         uint32_t handle = nvdimm_slot_to_handle(slot);
hw/acpi/nvdimm.c +14 -0
@@ -1260,6 +1261,96 @@ static void nvdimm_build_nvdimm_devices(Aml
 *root_dev, uint32_t ram_slots)
          */
         aml_append(nvdimm_dev, aml_name_decl("_ADR",
 aml_int(handle)));
 
+        /*
+         * ACPI v6.4: Section 6.5.10 NVDIMM Label Methods
+         */
+        /* _LSI */
+        method = aml_method("_LSI", 0, AML_SERIALIZED);
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(4), aml_int(0),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(0)));
+
+        aml_append(method, aml_create_dword_field(aml_local(0),
+                                                  aml_int(0),
 "STTS"));
+        aml_append(method, aml_create_dword_field(aml_local(0),

aml_int(4),

hw/acpi/nvdimm.c +2 -0
+                                                  "SLSA"));
+        aml_append(method, aml_create_dword_field(aml_local(0),

aml_int(8),

hw/acpi/nvdimm.c +2 -0
+                                                  "MAXT"));
+
Quoted 8 lines

hw/acpi/nvdimm.c static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) · line 1286

Quoted 5 lines
hw/acpi/nvdimm.c +5 -0
+        pkg = aml_package(3);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("SLSA"));
+        aml_append(pkg, aml_name("MAXT"));
+        aml_append(method, aml_name_decl("RET", pkg));  

ex: put it in local instead of named variable and return that the same applies to other named temporary named variables.

Quoted 1 line

Could you help provide the example in form of ASL?

see hw/i386/acpi-build.c: build_prt() or aml_pci_device_dsm()

Quoted 101 lines

Thanks.

Quoted 99 lines
Quoted 86 lines
hw/acpi/nvdimm.c +7 -0
+        aml_append(method, aml_return(aml_name("RET")));
+
+        aml_append(nvdimm_dev, method);
+
+        /* _LSR */
+        method = aml_method("_LSR", 2, AML_SERIALIZED);
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8,

NULL)));

hw/acpi/nvdimm.c +2 -0
+
+        aml_append(method,

aml_create_dword_field(aml_name("INPT"),
+ aml_int(0),
"OFST"));
+ aml_append(method,
aml_create_dword_field(aml_name("INPT"),
+ aml_int(4),
"LEN"));
+ aml_append(method, aml_store(aml_arg(0),
aml_name("OFST")));
+ aml_append(method, aml_store(aml_arg(1),
aml_name("LEN")));

hw/acpi/nvdimm.c +8 -0
+
+        pkg = aml_package(1);
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(5),

aml_name("PKG1"),

hw/acpi/nvdimm.c +3 -0
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0),

"STTS");

hw/acpi/nvdimm.c +3 -0
+        aml_append(method, field);
+        field = aml_create_field(aml_local(3), aml_int(32),
+                                 aml_shiftleft(aml_name("LEN"),

aml_int(3)),

hw/acpi/nvdimm.c +3 -0
+                                 "LDAT");
+        aml_append(method, field);
+        aml_append(method, aml_name_decl("LSA", aml_buffer(0,

NULL)));
+ aml_append(method, aml_to_buffer(aml_name("LDAT"),
aml_name("LSA")));

hw/acpi/nvdimm.c +11 -0
+        pkg = aml_package(2);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("LSA"));
+        aml_append(method, aml_name_decl("RET", pkg));
+        aml_append(method, aml_return(aml_name("RET")));
+        aml_append(nvdimm_dev, method);
+
+        /* _LSW */
+        method = aml_method("_LSW", 3, AML_SERIALIZED);
+        aml_append(method, aml_store(aml_arg(2), aml_local(2)));
+        aml_append(method, aml_name_decl("INPT", aml_buffer(8,

NULL)));

hw/acpi/nvdimm.c +2 -0
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(0),

"OFST");

hw/acpi/nvdimm.c +3 -0
+        aml_append(method, field);
+        field = aml_create_dword_field(aml_name("INPT"),
+                                                  aml_int(4),

"TLEN");

hw/acpi/nvdimm.c +2 -0
+        aml_append(method, field);
+        aml_append(method, aml_store(aml_arg(0),

aml_name("OFST")));
+ aml_append(method, aml_store(aml_arg(1),
aml_name("TLEN")));

hw/acpi/nvdimm.c +2 -0
+
+        aml_append(method, aml_concatenate(aml_name("INPT"),

aml_local(2),

hw/acpi/nvdimm.c +7 -0
+                                            aml_name("INPT")));
+        pkg = aml_package(1);
+        aml_append(pkg, aml_name("INPT"));
+        aml_append(method, aml_name_decl("PKG1", pkg));
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(6),

aml_name("PKG1"),

hw/acpi/nvdimm.c +3 -0
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(3)));
+        field = aml_create_dword_field(aml_local(3), aml_int(0),

"STTS");

hw/acpi/nvdimm.c +2 -0
+        aml_append(method, field);
+        aml_append(method,
Quoted 1 line

aml_return(aml_to_integer(aml_name("STTS"))));

why do you need explicitly convert DWORD field to integer? it should be fine to return STTS directly (implicit conversion should take care of the rest)

Quoted 5 lines
hw/acpi/nvdimm.c +2 -0
+        aml_append(nvdimm_dev, method);
+
         nvdimm_build_device_dsm(nvdimm_dev, handle);
         aml_append(root_dev, nvdimm_dev);
     }  
author
#9 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

In reply to Igor Mammedov

On Fri, 2022-09-09 at 15:39 +0200, Igor Mammedov wrote:
...

Quoted 9 lines

looks more or less fine except of excessive use of named variables which creates global scope variables.

I'd suggest to store temporary buffers/packages in LocalX variales, you should be able to do that for everything modulo aml_create_dword_field().

see an example below

...

Quoted 22 lines
Quoted 22 lines
hw/acpi/nvdimm.c +13 -0
+        /*
+         * ACPI v6.4: Section 6.5.10 NVDIMM Label Methods
+         */
+        /* _LSI */
+        method = aml_method("_LSI", 0, AML_SERIALIZED);
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(4), aml_int(0),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(0)));
+
+        aml_append(method, aml_create_dword_field(aml_local(0),
+                                                  aml_int(0),

"STTS"));
+ aml_append(method, aml_create_dword_field(aml_local(0),
aml_int(4),

(quoted diff) +2 -0
+                                                  "SLSA"));
+        aml_append(method, aml_create_dword_field(aml_local(0),

aml_int(8),

(quoted diff) +2 -0
+                                                  "MAXT"));
+
Quoted 9 lines

hw/acpi/nvdimm.c static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) · line 1286

Quoted 5 lines
hw/acpi/nvdimm.c +5 -0
+        pkg = aml_package(3);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("SLSA"));
+        aml_append(pkg, aml_name("MAXT"));
+        aml_append(method, aml_name_decl("RET", pkg));

ex: put it in local instead of named variable and return that the same applies to other named temporary named variables.

Fine, get your point now.
In ASL it will look like this:

                    Local1 = Package (0x3) {STTS, SLSA, MAXT}
                    Return (Local1)

But as for

                    CreateDWordField (Local0, Zero, STTS)  // Status
                    CreateDWordField (Local0, 0x04, SLSA)  // SizeofLSA
                    CreateDWordField (Local0, 0x08, MAXT)  // Max Trans

I cannot figure out how to substitute with LocalX. Can you shed more light?

CreateQWordFieldTerm :=
CreateQWordField (
SourceBuffer, // TermArg => Buffer
ByteIndex, // TermArg => Integer
QWordFieldName // NameString
)
NameString :=
<RootChar NamePath> | <ParentPrefixChar PrefixPath NamePath> | NonEmptyNamePath

Quoted 2 lines
Quoted 2 lines
(quoted diff) +2 -0
+        aml_append(method, aml_return(aml_name("RET")));
+

...

Quoted 9 lines
Quoted 5 lines

+ field = aml_create_dword_field(aml_local(3), aml_int(0),
"STTS");

(quoted diff) +2 -0
+        aml_append(method, field);
+        aml_append(method,

aml_return(aml_to_integer(aml_name("STTS"))));

why do you need explicitly convert DWORD field to integer? it should be fine to return STTS directly (implicit conversion should take care of the rest)

Explicit convert eases my anxiety on uncertainty. ;)

Quoted 3 lines
Quoted 3 lines
(quoted diff) +2 -0
+        aml_append(nvdimm_dev, method);
+

...

#10 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 50 lines · On Fri, 16 Sep 2022 10:27:08 +0800 Robert Hoo <[email protected]> wrote:

On Fri, 2022-09-09 at 15:39 +0200, Igor Mammedov wrote:
...

Quoted 9 lines

looks more or less fine except of excessive use of named variables which creates global scope variables.

I'd suggest to store temporary buffers/packages in LocalX variales, you should be able to do that for everything modulo aml_create_dword_field().

see an example below

...

Quoted 22 lines
Quoted 22 lines
hw/acpi/nvdimm.c +13 -0
+        /*
+         * ACPI v6.4: Section 6.5.10 NVDIMM Label Methods
+         */
+        /* _LSI */
+        method = aml_method("_LSI", 0, AML_SERIALIZED);
+        com_call = aml_call5(NVDIMM_COMMON_DSM,
+                            aml_touuid(NVDIMM_DEVICE_DSM_UUID),
+                            aml_int(1), aml_int(4), aml_int(0),
+                            aml_int(handle));
+        aml_append(method, aml_store(com_call, aml_local(0)));
+
+        aml_append(method, aml_create_dword_field(aml_local(0),
+                                                  aml_int(0),

"STTS"));
+ aml_append(method, aml_create_dword_field(aml_local(0),
aml_int(4),

(quoted diff) +2 -0
+                                                  "SLSA"));
+        aml_append(method, aml_create_dword_field(aml_local(0),

aml_int(8),

(quoted diff) +2 -0
+                                                  "MAXT"));
+
Quoted 9 lines

hw/acpi/nvdimm.c static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) · line 1286

Quoted 5 lines
hw/acpi/nvdimm.c +5 -0
+        pkg = aml_package(3);
+        aml_append(pkg, aml_name("STTS"));
+        aml_append(pkg, aml_name("SLSA"));
+        aml_append(pkg, aml_name("MAXT"));
+        aml_append(method, aml_name_decl("RET", pkg));  

ex: put it in local instead of named variable and return that the same applies to other named temporary named variables.

Fine, get your point now.
In ASL it will look like this:

                    Local1 = Package (0x3) {STTS, SLSA, MAXT}
                    Return (Local1)
Quoted 7 lines

But as for

                    CreateDWordField (Local0, Zero, STTS)  // Status
                    CreateDWordField (Local0, 0x04, SLSA)  // SizeofLSA
                    CreateDWordField (Local0, 0x08, MAXT)  // Max Trans

I cannot figure out how to substitute with LocalX. Can you shed more light?

Leave this as is, there is no way to make it anonymous/local with FooField.

(well one might try to use Index and copy field's bytes into a buffer and then explicitly convert to Integer, but that's a rather convoluted way around limitation so I'd not go this route)

Quoted 31 lines

CreateQWordFieldTerm :=
CreateQWordField (
SourceBuffer, // TermArg => Buffer
ByteIndex, // TermArg => Integer
QWordFieldName // NameString
)
NameString :=
<RootChar NamePath> | <ParentPrefixChar PrefixPath NamePath> | NonEmptyNamePath

Quoted 2 lines
Quoted 2 lines
(quoted diff) +2 -0
+        aml_append(method, aml_return(aml_name("RET")));
+  

...

Quoted 9 lines
Quoted 5 lines

+ field = aml_create_dword_field(aml_local(3), aml_int(0),
"STTS");

(quoted diff) +2 -0
+        aml_append(method, field);
+        aml_append(method,

aml_return(aml_to_integer(aml_name("STTS"))));

why do you need explicitly convert DWORD field to integer? it should be fine to return STTS directly (implicit conversion should take care of the rest)

Explicit convert eases my anxiety on uncertainty. ;)

Quoted 3 lines
Quoted 3 lines
(quoted diff) +2 -0
+        aml_append(nvdimm_dev, method);
+  

...

author
#11 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 19 lines · Igor Mammedov
Quoted 10 lines

Fine, get your point now.
In ASL it will look like this:

                    Local1 = Package (0x3) {STTS, SLSA, MAXT}
                    Return (Local1)

But as for
CreateDWordField (Local0, Zero, STTS) //
Status

Quoted 8 lines
                    CreateDWordField (Local0, 0x04, SLSA)  //
SizeofLSA
                    CreateDWordField (Local0, 0x08, MAXT)  // Max

Trans

I cannot figure out how to substitute with LocalX. Can you shed more
light?

Quoted 9 lines

Leave this as is, there is no way to make it anonymous/local with FooField.

(well one might try to use Index and copy field's bytes into a buffer and
then explicitly convert to Integer, but that's a rather convoluted way
around limitation so I'd not go this route)

OK, pls. take a look, how about this?

Method (_LSI, 0, Serialized) // _LSI: Label Storage Information

{   
    Local0 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x04, Zero, One)    // Buffer
    CreateDWordField (Local0, Zero, STTS)  // Status
    CreateDWordField (Local0, 0x04, SLSA)  // Size of LSA
    CreateDWordField (Local0, 0x08, MAXT)  // Max Transfer Size
    Local1 = Package (0x3) {STTS, SLSA, MAXT}
    Return (Local1)
}

Method (_LSR, 2, Serialized) // _LSR: Label Storage Read

{
    Name (INPT, Buffer(8) {})
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, LEN);
    OFST = Arg0
    LEN = Arg1
    Local0 = Package (0x01) {INPT}
    Local3 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x05, Local0, One)
    CreateDWordField (Local3, Zero, STTS)
    CreateField (Local3, 32, LEN << 3, LDAT)
    Local1 = Package (0x2) {STTS, toBuffer(LDAT)}
    Return (Local1)
}

Method (_LSW, 3, Serialized) // _LSW: Label Storage Write

{
    Local2 = Arg2
    Name (INPT, Buffer(8) {})
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, TLEN);
    OFST = Arg0
    TLEN = Arg1
    Concatenate(INPT, Local2, INPT)
    Local0 = Package (0x01)
    {
        INPT
    }
    Local3 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"),

0x02, 0x06, Local0, One)
CreateDWordField (Local3, 0, STTS)
Return (STTS)
}

#12 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 43 lines · On Fri, 16 Sep 2022 21:15:35 +0800 Robert Hoo <[email protected]> wrote:
Quoted 19 lines · Igor Mammedov
Quoted 10 lines

Fine, get your point now.
In ASL it will look like this:

                    Local1 = Package (0x3) {STTS, SLSA, MAXT}
                    Return (Local1)  

But as for
CreateDWordField (Local0, Zero, STTS) //
Status

Quoted 8 lines
                    CreateDWordField (Local0, 0x04, SLSA)  //
SizeofLSA
                    CreateDWordField (Local0, 0x08, MAXT)  // Max

Trans

I cannot figure out how to substitute with LocalX. Can you shed more
light?

Quoted 9 lines

Leave this as is, there is no way to make it anonymous/local with FooField.

(well one might try to use Index and copy field's bytes into a buffer and
then explicitly convert to Integer, but that's a rather convoluted way
around limitation so I'd not go this route)

OK, pls. take a look, how about this?

Method (_LSI, 0, Serialized) // _LSI: Label Storage Information

{   
    Local0 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x04, Zero, One)    // Buffer
    CreateDWordField (Local0, Zero, STTS)  // Status
    CreateDWordField (Local0, 0x04, SLSA)  // Size of LSA
    CreateDWordField (Local0, 0x08, MAXT)  // Max Transfer Size
    Local1 = Package (0x3) {STTS, SLSA, MAXT}
    Return (Local1)
}
Quoted 5 lines

Method (_LSR, 2, Serialized) // _LSR: Label Storage Read

{
    Name (INPT, Buffer(8) {})
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, LEN);

why do you have to create and use INPT, wouldn't local be enough to keep the buffer?

Quoted 11 lines

OFST = Arg0
LEN = Arg1
Local0 = Package (0x01) {INPT}
Local3 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x05, Local0, One)

    CreateDWordField (Local3, Zero, STTS)
    CreateField (Local3, 32, LEN << 3, LDAT)
    Local1 = Package (0x2) {STTS, toBuffer(LDAT)}
    Return (Local1)
}
Quoted 4 lines

Method (_LSW, 3, Serialized) // _LSW: Label Storage Write {
Local2 = Arg2
Name (INPT, Buffer(8) {})

ditto

Quoted 17 lines
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, TLEN);
    OFST = Arg0
    TLEN = Arg1
    Concatenate(INPT, Local2, INPT)
    Local0 = Package (0x01)
    {
        INPT
    }
    Local3 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"),

0x02, 0x06, Local0, One)
CreateDWordField (Local3, 0, STTS)
Return (STTS)
}

author
#13 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 50 lines · Igor Mammedov
Quoted 47 lines · On Fri, 16 Sep 2022 21:15:35 +0800 Robert Hoo <[email protected]> wrote:
Quoted 23 lines · Igor Mammedov
Quoted 13 lines

Fine, get your point now.
In ASL it will look like this:

                    Local1 = Package (0x3) {STTS, SLSA, MAXT}
                    Return (Local1)  

But as for
CreateDWordField (Local0, Zero, STTS) //
Status

                    CreateDWordField (Local0, 0x04, SLSA)  //
SizeofLSA
                    CreateDWordField (Local0, 0x08, MAXT)  //
Quoted 6 lines

Max
Trans

I cannot figure out how to substitute with LocalX. Can you shed more
light?

Leave this as is, there is no way to make it anonymous/local with FooField.

Quoted 8 lines

(well one might try to use Index and copy field's bytes into a buffer
and
then explicitly convert to Integer, but that's a rather convoluted
way
around limitation so I'd not go this route)

OK, pls. take a look, how about this?

Method (_LSI, 0, Serialized) // _LSI: Label Storage Information

{   
    Local0 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x04, Zero, One)    // Buffer
    CreateDWordField (Local0, Zero, STTS)  // Status
    CreateDWordField (Local0, 0x04, SLSA)  // Size of LSA
    CreateDWordField (Local0, 0x08, MAXT)  // Max Transfer Size
    Local1 = Package (0x3) {STTS, SLSA, MAXT}
    Return (Local1)
}
Quoted 8 lines
Quoted 5 lines

Method (_LSR, 2, Serialized) // _LSR: Label Storage Read

{
    Name (INPT, Buffer(8) {})
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, LEN);

why do you have to create and use INPT, wouldn't local be enough to keep the buffer?

If substitute INPT with LocalX, then later
Local0 = Package (0x01) {LocalX} isn't accepted.

PackageElement :=
DataObject | NameString

Quoted 33 lines
Quoted 12 lines

OFST = Arg0
LEN = Arg1
Local0 = Package (0x01) {INPT}
Local3 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x05, Local0, One)

    CreateDWordField (Local3, Zero, STTS)
    CreateField (Local3, 32, LEN << 3, LDAT)
    Local1 = Package (0x2) {STTS, toBuffer(LDAT)}
    Return (Local1)
}
Quoted 4 lines

Method (_LSW, 3, Serialized) // _LSW: Label Storage Write {
Local2 = Arg2
Name (INPT, Buffer(8) {})

ditto

Quoted 14 lines
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, TLEN);
    OFST = Arg0
    TLEN = Arg1
    Concatenate(INPT, Local2, INPT)
    Local0 = Package (0x01)
    {
        INPT
    }
    Local3 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"),

0x02, 0x06, Local0, One)
CreateDWordField (Local3, 0, STTS)
Return (STTS)
}

#14 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 57 lines · On Tue, 20 Sep 2022 20:28:31 +0800 Robert Hoo <[email protected]> wrote:
Quoted 56 lines · Igor Mammedov
Quoted 52 lines · On Fri, 16 Sep 2022 21:15:35 +0800 Robert Hoo <[email protected]> wrote:
Quoted 23 lines · Igor Mammedov
Quoted 13 lines

Fine, get your point now.
In ASL it will look like this:

                    Local1 = Package (0x3) {STTS, SLSA, MAXT}
                    Return (Local1)    

But as for
CreateDWordField (Local0, Zero, STTS) //
Status

                    CreateDWordField (Local0, 0x04, SLSA)  //
SizeofLSA
                    CreateDWordField (Local0, 0x08, MAXT)  //
Quoted 6 lines

Max
Trans

I cannot figure out how to substitute with LocalX. Can you shed more
light?

Leave this as is, there is no way to make it anonymous/local with FooField.

Quoted 8 lines

(well one might try to use Index and copy field's bytes into a buffer
and
then explicitly convert to Integer, but that's a rather convoluted
way
around limitation so I'd not go this route)

OK, pls. take a look, how about this?

Method (_LSI, 0, Serialized) // _LSI: Label Storage Information

{   
    Local0 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x04, Zero, One)    // Buffer
    CreateDWordField (Local0, Zero, STTS)  // Status
    CreateDWordField (Local0, 0x04, SLSA)  // Size of LSA
    CreateDWordField (Local0, 0x08, MAXT)  // Max Transfer Size
    Local1 = Package (0x3) {STTS, SLSA, MAXT}
    Return (Local1)
}

Method (_LSR, 2, Serialized) // _LSR: Label Storage Read

{
    Name (INPT, Buffer(8) {})
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, LEN);  
Quoted 8 lines
Quoted 2 lines

why do you have to create and use INPT, wouldn't local be enough to keep the buffer?

If substitute INPT with LocalX, then later
Local0 = Package (0x01) {LocalX} isn't accepted.

PackageElement :=
DataObject | NameString

ok, then respin series and lets get it some testing.

BTW:
it looks like Windows Server starting from v2019 has support for NVDIMM-P devices which came with 'Optane DC Persistent Memory Modules' but it fails to recognize NVDIMMs in QEMU (complaining something about wrong target). Perhaps you can reach someone with Optane/ACPI expertise within your org and try to fix QEMU side.

Quoted 35 lines
Quoted 33 lines
Quoted 12 lines

OFST = Arg0
LEN = Arg1
Local0 = Package (0x01) {INPT}
Local3 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-0800200c9a66"),
0x02, 0x05, Local0, One)

    CreateDWordField (Local3, Zero, STTS)
    CreateField (Local3, 32, LEN << 3, LDAT)
    Local1 = Package (0x2) {STTS, toBuffer(LDAT)}
    Return (Local1)
}
Quoted 4 lines

Method (_LSW, 3, Serialized) // _LSW: Label Storage Write {
Local2 = Arg2
Name (INPT, Buffer(8) {})

ditto

Quoted 14 lines
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, TLEN);
    OFST = Arg0
    TLEN = Arg1
    Concatenate(INPT, Local2, INPT)
    Local0 = Package (0x01)
    {
        INPT
    }
    Local3 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"),

0x02, 0x06, Local0, One)
CreateDWordField (Local3, 0, STTS)
Return (STTS)
}

author
#15 lore raw

Re: [PATCH v3 4/5] acpi/nvdimm: Implement ACPI NVDIMM Label Methods

Quoted 73 lines · Igor Mammedov
Quoted 70 lines · On Tue, 20 Sep 2022 20:28:31 +0800 Robert Hoo <[email protected]> wrote:
Quoted 68 lines · Igor Mammedov
Quoted 56 lines · On Fri, 16 Sep 2022 21:15:35 +0800 Robert Hoo <[email protected]> wrote:
Quoted 29 lines · Igor Mammedov
Quoted 16 lines

Fine, get your point now.
In ASL it will look like this:

                    Local1 = Package (0x3) {STTS, SLSA,

MAXT}
Return (Local1)

But as for
CreateDWordField (Local0, Zero,
STTS) //
Status

                    CreateDWordField (Local0, 0x04,
SLSA)  //
SizeofLSA
                    CreateDWordField (Local0, 0x08,
Quoted 8 lines

MAXT) //
Max
Trans

I cannot figure out how to substitute with LocalX. Can you shed
more
light?

Leave this as is, there is no way to make it anonymous/local with
FooField.

Quoted 9 lines

(well one might try to use Index and copy field's bytes into a
buffer
and
then explicitly convert to Integer, but that's a rather convoluted
way
around limitation so I'd not go this route)

OK, pls. take a look, how about this?

Method (_LSI, 0, Serialized) // _LSI: Label Storage Information

{   
    Local0 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-
0800200c9a66"),
0x02, 0x04, Zero, One)    // Buffer
    CreateDWordField (Local0, Zero, STTS)  // Status
    CreateDWordField (Local0, 0x04, SLSA)  // Size of LSA
    CreateDWordField (Local0, 0x08, MAXT)  // Max Transfer Size
    Local1 = Package (0x3) {STTS, SLSA, MAXT}
    Return (Local1)
}
Quoted 5 lines

Method (_LSR, 2, Serialized) // _LSR: Label Storage Read

{
    Name (INPT, Buffer(8) {})
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, LEN);  

why do you have to create and use INPT, wouldn't local be enough to
keep the buffer?

Quoted 7 lines
Quoted 5 lines

If substitute INPT with LocalX, then later
Local0 = Package (0x01) {LocalX} isn't accepted.

PackageElement :=
DataObject | NameString

ok, then respin series and lets get it some testing.

Sure. I'd also like it to go through your tests, though I had done some ordinary tests like guest create/delete/init-labels on vNVDIMM.

Quoted 9 lines

BTW:
it looks like Windows Server starting from v2019 has support for NVDIMM-P devices which came with 'Optane DC Persistent Memory Modules'
but it fails to recognize NVDIMMs in QEMU (complaining something about
wrong target). Perhaps you can reach someone with Optane/ACPI expertise within your org and try to fix QEMU side.

Yes, it's a known gap there. I will try that once I had some time and resource.

Quoted 40 lines
Quoted 38 lines
Quoted 36 lines
Quoted 14 lines

OFST = Arg0
LEN = Arg1
Local0 = Package (0x01) {INPT}
Local3 = NCAL (ToUUID("4309ac30-0d11-11e4-9191-
0800200c9a66"),
0x02, 0x05, Local0, One)

    CreateDWordField (Local3, Zero, STTS)
    CreateField (Local3, 32, LEN << 3, LDAT)
    Local1 = Package (0x2) {STTS, toBuffer(LDAT)}
    Return (Local1)
}
Quoted 4 lines

Method (_LSW, 3, Serialized) // _LSW: Label Storage Write {
Local2 = Arg2
Name (INPT, Buffer(8) {})

ditto

Quoted 15 lines
    CreateDWordField (INPT, Zero, OFST);
    CreateDWordField (INPT, 4, TLEN);
    OFST = Arg0
    TLEN = Arg1
    Concatenate(INPT, Local2, INPT)
    Local0 = Package (0x01)
    {
        INPT
    }
    Local3 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-

0800200c9a66"),
0x02, 0x06, Local0, One)
CreateDWordField (Local3, 0, STTS)
Return (STTS)
}

author
#16 lore raw

PATCH v3 5/5 test/acpi/bios-tables-test: SSDT: update golden master binaries

In reply to Robert Hoo

And empty bios-tables-test-allowed-diff.h.

Diff of ASL form, cited from qtest testlog.txt:

tmp/asl-APDMR1.dsl renamed from tmp/asl-0WHMR1.dsl +68 -5
@@ -1,30 +1,30 @@
 /*
  * Intel ACPI Component Architecture
  * AML/ASL+ Disassembler version 20180629 (64-bit version)
  * Copyright (c) 2000 - 2018 Intel Corporation
  *
  * Disassembling to symbolic ASL+ operators
  *
- * Disassembly of tests/data/acpi/pc/SSDT.dimmpxm, Tue Aug 30 11:38:09 2022
+ * Disassembly of /tmp/aml-1AEMR1, Tue Aug 30 11:38:09 2022
  *
  * Original Table Header:
  *     Signature        "SSDT"
- *     Length           0x000002DE (734)
+ *     Length           0x00000765 (1893)
  *     Revision         0x01
- *     Checksum         0x56
+ *     Checksum         0x36
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "NVDIMM"
  *     OEM Revision     0x00000001 (1)
  *     Compiler ID      "BXPC"
  *     Compiler Version 0x00000001 (1)
  */
 DefinitionBlock ("", "SSDT", 1, "BOCHS ", "NVDIMM", 0x00000001)
 {
     Scope (\_SB)
     {
         Device (NVDR)
         {
             Name (_HID, "ACPI0012" /* NVDIMM Root Device */)  // _HID: Hardware ID
             Method (NCAL, 5, Serialized)
             {
                 Local6 = MEMA /* \MEMA */
@@ -49,52 +49,52 @@
                     ODAT,   32736
                 }
 
                 If ((Arg4 == Zero))
                 {
                     Local0 = ToUUID ("2f10e7a4-9e91-11e4-89d3-123b93f75cba")
                 }
                 ElseIf ((Arg4 == 0x00010000))
                 {
                     Local0 = ToUUID ("648b9cf2-cda1-4312-8ad9-49c4af32bd62")
                 }
                 Else
                 {
                     Local0 = ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66")
                 }
 
-                If (((Local6 == Zero) | (Arg0 != Local0)))
+                If (((Local6 == Zero) || (Arg0 != Local0)))
                 {
                     If ((Arg2 == Zero))
                     {
                         Return (Buffer (One)
                         {
                              0x00                                             // .
                         })
                     }
 
                     Return (Buffer (One)
                     {
                          0x01                                             // .
                     })
                 }
 
                 HDLE = Arg4
                 REVS = Arg1
                 FUNC = Arg2
-                If (((ObjectType (Arg3) == 0x04) & (SizeOf (Arg3) == One)))
+                If (((ObjectType (Arg3) == 0x04) && (SizeOf (Arg3) == One)))
                 {
                     Local2 = Arg3 [Zero]
                     Local3 = DerefOf (Local2)
                     FARG = Local3
                 }
 
                 NTFI = Local6
                 Local1 = (RLEN - 0x04)
                 If ((Local1 < 0x08))
                 {
                     Local2 = Zero
                     Name (TBUF, Buffer (One)
                     {
                          0x00                                             // .
                     })
                     Local7 = Buffer (Zero){}
@@ -161,45 +161,234 @@
                     Else
                     {
                         If ((Local1 == Zero))
                         {
                             Return (Local2)
                         }
 
                         Local3 += Local1
                         Concatenate (Local2, Local0, Local2)
                     }
                 }
             }
 
             Device (NV00)
             {
                 Name (_ADR, One)  // _ADR: Address
+                Method (_LSI, 0, Serialized)  // _LSI: Label Storage Information
+                {
+                    Local0 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"), One, 0x04, Zero, One)
+                    CreateDWordField (Local0, Zero, STTS)
+                    CreateDWordField (Local0, 0x04, SLSA)
+                    CreateDWordField (Local0, 0x08, MAXT)
+                    Name (RET, Package (0x03)
+                    {
+                        STTS,
+                        SLSA,
+                        MAXT
+                    })
+                    Return (RET) /* \_SB_.NVDR.NV00._LSI.RET_ */
+                }
+
+                Method (_LSR, 2, Serialized)  // _LSR: Label Storage Read
+                {
+                    Name (INPT, Buffer (0x08)
+                    {
+                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // ........
+                    })
+                    CreateDWordField (INPT, Zero, OFST)
+                    CreateDWordField (INPT, 0x04, LEN)
+                    OFST = Arg0
+                    LEN = Arg1
+                    Name (PKG1, Package (0x01)
+                    {
+                        INPT
+                    })
+                    Local3 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"), One, 0x05, PKG1, One)
+                    CreateDWordField (Local3, Zero, STTS)
+                    CreateField (Local3, 0x20, (LEN << 0x03), LDAT)
+                    Name (LSA, Buffer (Zero){})
+                    ToBuffer (LDAT, LSA) /* \_SB_.NVDR.NV00._LSR.LSA_ */
+                    Name (RET, Package (0x02)
+                    {
+                        STTS,
+                        LSA
+                    })
+                    Return (RET) /* \_SB_.NVDR.NV00._LSR.RET_ */
+                }
+
+                Method (_LSW, 3, Serialized)  // _LSW: Label Storage Write
+                {
+                    Local2 = Arg2
+                    Name (INPT, Buffer (0x08)
+                    {
+                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00   // ........
+                    })
+                    CreateDWordField (INPT, Zero, OFST)
+                    CreateDWordField (INPT, 0x04, TLEN)
+                    OFST = Arg0
+                    TLEN = Arg1
+                    Concatenate (INPT, Local2, INPT) /* \_SB_.NVDR.NV00._LSW.INPT */
+                    Name (PKG1, Package (0x01)
+                    {
+                        INPT
+                    })
+                    Local3 = NCAL (ToUUID ("4309ac30-0d11-11e4-9191-0800200c9a66"), One, 0x06, PKG1, One)
+                    CreateDWordField (Local3, Zero, STTS)
+                    Return (ToInteger (STTS))
+                }
+
                 Method (_DSM, 4, NotSerialized)  // _DSM: Device-Specific Method
                 {
                     Return (NCAL (Arg0, Arg1, Arg2, Arg3, One))
                 }
             }

... // iterates in each NV devices

---
 tests/data/acpi/pc/SSDT.dimmpxm             | Bin 734 -> 1893 bytes
 tests/data/acpi/q35/SSDT.dimmpxm            | Bin 734 -> 1893 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   2 --
 3 files changed, 2 deletions(-)
tests/data/acpi/pc/SSDT.dimmpxm binary +0 -0
index ac55387d57e48adb99eb738a102308688a262fb8..2316d8f959267a178b12379dbcb439a6306b0db5 100644
GIT binary patch
tests/data/acpi/q35/SSDT.dimmpxm binary +0 -0
index 98e6f0e3f3bb02dd419e36bdd1db9b94c728c406..cfb1f0515293f2e3630b755da26d558f43c91bc4 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
index eb8bae1407..dfb8523c8b 100644
@@ -1,3 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/SSDT.dimmpxm",
-"tests/data/acpi/q35/SSDT.dimmpxm",
Signature · 1 line
2.31.1