[PATCH v2 4/4] acpi_mrrm: fake for testing, do not apply!

Tony Luck
2025-02-27T22:48:42Z

Dummy MRRM table for a 2 socket system with memory map:

LocalAccess RemoteAccess
0-3.5G DDR on socket 0 0 1
2G-512G More DDR on socket 0 0 1
512G-1T DDR on socket 1 0 1
1T-2T Reserved for CXL on socket 0 2 3
2T-3T Reserved for CXL on socket 1 2 3

This tags all local DDR access in region 0, remote DDR in region 1,
local CXL in region 2, and remote CXL in region 3.

Presented to user like this:

$ cd /sys/firmware/acpi
$ grep ^ memory_ranges/*/*
memory_ranges/range0/base:0x0
memory_ranges/range0/length:0xe0000000
memory_ranges/range0/local_region_id:0x0
memory_ranges/range0/remote_region_id:0x1
memory_ranges/range1/base:0x100000000
memory_ranges/range1/length:0x7f00000000
memory_ranges/range1/local_region_id:0x0
memory_ranges/range1/remote_region_id:0x1
memory_ranges/range2/base:0x8000000000
memory_ranges/range2/length:0x8000000000
memory_ranges/range2/local_region_id:0x0
memory_ranges/range2/remote_region_id:0x1
memory_ranges/range3/base:0x10000000000
memory_ranges/range3/length:0x100000000000
memory_ranges/range3/local_region_id:0x2
memory_ranges/range3/remote_region_id:0x3
memory_ranges/range4/base:0x200000000000
memory_ranges/range4/length:0x100000000000
memory_ranges/range4/local_region_id:0x2
memory_ranges/range4/remote_region_id:0x3

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
drivers/acpi/acpi_mrrm.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/drivers/acpi/acpi_mrrm.c b/drivers/acpi/acpi_mrrm.c
index 1f7d0381a628..16f0ca7072e0 100644
--- a/drivers/acpi/acpi_mrrm.c
+++ b/drivers/acpi/acpi_mrrm.c
@@ -147,11 +147,35 @@ static __init int add_boot_memory_ranges(void)
return ret;
}

+#define FAKE 1
+#ifdef FAKE
+static const u8 fake_mrrm[] = {
+ 0x4D,0x52,0x52,0x4D,0xE0,0x00,0x00,0x00,0x01,0x3A,0x49,0x4E,0x54,0x45,0x4C,0x00,
+ 0x49,0x4E,0x54,0x45,0x4C,0x20,0x49,0x44,0x02,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,
+ 0x12,0x12,0x24,0x20,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x03,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x03,0x00,0x02,0x03,0x00,0x00,0x00,0x00,
+ 0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,
+ 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x03,0x00,0x02,0x03,0x00,0x00,0x00,0x00
+};
+#endif
+
static __init int mrrm_init(void)
{
int ret;

+#ifdef FAKE
+ ret = acpi_parse_mrrm((struct acpi_table_header *)fake_mrrm);
+#else
ret = acpi_table_parse(ACPI_SIG_MRRM, acpi_parse_mrrm);
+#endif

if (ret < 0)
return ret;
--
2.48.1