ACPI: PPTT: Fix table length check when parsing processor nodes
PATCH 1/1 ACPI: PPTT: Fix table length check when parsing processor nodes
From: Yicong Yang <[email protected]>
Below error is met on my board and QEMU VM on SMT or non-SMT machine:
ACPI PPTT: PPTT table found, but unable to locate core 31 (31)
This is because the processor node is found by iterating the PPTT table under condition (for both acpi_find_processor_node() and acpi_pptt_leaf_node()):
while (entry + proc_sz < table_end)
[parse the processor node]
If the last processor node is happened to be the last node in the PPTT table, above condition will always be false since entry + proc_sz == table_end. Thus the last CPU is not parsed. Fix the loop condition to resolve the issue.
This issue is exposed by [1] but the root cause is explained above. Before [1] entry + proc_sz is always smaller than table_end.
[1] 7ab4f0e37a0f ("ACPI PPTT: Fix coding mistakes in a couple of sizeof() calls")
--- drivers/acpi/pptt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/pptt.c +2 -2
@@ -231,7 +231,7 @@ static int acpi_pptt_leaf_node(struct acpi_table_header *table_hdr, sizeof(struct acpi_table_pptt)); proc_sz =sizeof (struct acpi_pptt_processor ); -while ((unsigned long )entry + proc_sz < table_end) { +while ((unsigned long )entry + proc_sz <= table_end) { cpu_node = (struct acpi_pptt_processor *)entry;if (entry->type ==ACPI_PPTT_TYPE_PROCESSOR && cpu_node->parent == node_entry)
@@ -273,7 +273,7 @@ static struct acpi_pptt_processor *acpi_find_processor_node(struct acpi_table_he proc_sz =sizeof (struct acpi_pptt_processor );/* find the processor structure associated with this cpuid */ -while ((unsigned long )entry + proc_sz < table_end) { +while ((unsigned long )entry + proc_sz <= table_end) { cpu_node = (struct acpi_pptt_processor *)entry;if (entry->length ==0 ) {
Signature · 1 line
2.24.0
Quoted 11 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Below error is met on my board and QEMU VM on SMT or non-SMT machine:
ACPI PPTT: PPTT table found, but unable to locate core 31 (31)This is because the processor node is found by iterating the PPTT table under condition (for both
acpi_find_processor_node()andacpi_pptt_leaf_node()):
while (entry +proc_sz<table_end)
[parse the processor node]
Quoted 8 lines
If the last processor node is happened to be the last node in the PPTT table, above condition will always be false since entry +
proc_sz==table_end. Thus the last CPU is not parsed. Fix the loop condition to resolve the issue.This issue is exposed by [1] but the root cause is explained above. Before [1] entry +
proc_szis always smaller thantable_end.
Another thread [1] with similar patch.
Signature · 4 lines
Regards, Sudeep [1] https://lore.kernel.org/all/20250506-draco-taped-15f475cd@mheyne-amazon
Rafael J. Wysocki
maintainerQuoted 18 lines · Sudeep Holla
Quoted 16 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Below error is met on my board and QEMU VM on SMT or non-SMT machine:
ACPI PPTT: PPTT table found, but unable to locate core 31 (31)This is because the processor node is found by iterating the PPTT table under condition (for both
acpi_find_processor_node()andacpi_pptt_leaf_node()):
while (entry +proc_sz<table_end)
[parse the processor node]If the last processor node is happened to be the last node in the PPTT table, above condition will always be false since entry +
proc_sz==table_end. Thus the last CPU is not parsed. Fix the loop condition to resolve the issue.
Quoted 5 lines
Quoted 3 lines
This issue is exposed by [1] but the root cause is explained above. Before [1] entry +
proc_szis always smaller thantable_end.Another thread [1] with similar patch.
OK, so is this a correct fix?
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · Sudeep Holla
Quoted 16 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Below error is met on my board and QEMU VM on SMT or non-SMT machine:
ACPI PPTT: PPTT table found, but unable to locate core 31 (31)This is because the processor node is found by iterating the PPTT table under condition (for both
acpi_find_processor_node()andacpi_pptt_leaf_node()):
while (entry +proc_sz<table_end)
[parse the processor node]If the last processor node is happened to be the last node in the PPTT table, above condition will always be false since entry +
proc_sz==table_end. Thus the last CPU is not parsed. Fix the loop condition to resolve the issue.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
This issue is exposed by [1] but the root cause is explained above. Before [1] entry +
proc_szis always smaller thantable_end.Another thread [1] with similar patch.
OK, so is this a correct fix?
While it may fix the issue on the surface, I just want to be sure there are no other issues with the PPTT table presented from the firmware. I will asked some questions on that thread before I can agree on the solution.
Signature · 2 lines
Regards, Sudeep
Rafael J. Wysocki
maintainerQuoted 25 lines · Sudeep Holla
Quoted 23 lines · Rafael J. Wysocki
Quoted 22 lines · Sudeep Holla
Quoted 19 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Below error is met on my board and QEMU VM on SMT or non-SMT machine:
ACPI PPTT: PPTT table found, but unable to locate core 31 (31)This is because the processor node is found by iterating the PPTT table under condition (for both
acpi_find_processor_node()andacpi_pptt_leaf_node()):
while (entry +proc_sz<table_end)
[parse the processor node]If the last processor node is happened to be the last node in the PPTT table, above condition will always be false since entry +
proc_sz==table_end. Thus the last CPU is not parsed. Fix the loop condition to resolve the issue.This issue is exposed by [1] but the root cause is explained above. Before [1] entry +
proc_szis always smaller thantable_end.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Another thread [1] with similar patch.
OK, so is this a correct fix?
While it may fix the issue on the surface, I just want to be sure there are no other issues with the PPTT table presented from the firmware. I will asked some questions on that thread before I can agree on the solution.
Yeah, it looks like table_end points to the last byte of the table instead of pointing to the first byte after the end of the table.
Quoted 28 lines · Rafael J. Wysocki
Quoted 27 lines · Sudeep Holla
Quoted 25 lines · Rafael J. Wysocki
Quoted 23 lines · Sudeep Holla
Quoted 11 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Below error is met on my board and QEMU VM on SMT or non-SMT machine:
ACPI PPTT: PPTT table found, but unable to locate core 31 (31)This is because the processor node is found by iterating the PPTT table under condition (for both
acpi_find_processor_node()andacpi_pptt_leaf_node()):
while (entry +proc_sz<table_end)
[parse the processor node]Quoted 8 lines
If the last processor node is happened to be the last node in the PPTT table, above condition will always be false since entry +
proc_sz==table_end. Thus the last CPU is not parsed. Fix the loop condition to resolve the issue.This issue is exposed by [1] but the root cause is explained above. Before [1] entry +
proc_szis always smaller thantable_end.Another thread [1] with similar patch.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
OK, so is this a correct fix?
While it may fix the issue on the surface, I just want to be sure there are no other issues with the PPTT table presented from the firmware. I will asked some questions on that thread before I can agree on the solution.
Yeah, it looks like
table_endpoints to the last byte of the table instead of pointing to the first byte after the end of the table.
Indeed and also we should have private resources like L1 cache described after the initial 20 bytes of the node. So I am bit worried if this will just hide other problems while it may solve this problem by looks of it. This example doesn't look like a proper PPTT matching real systems.
Signature · 2 lines
Regards, Sudeep
Quoted 35 lines · On Wed, 7 May 2025 12:55:00 +0100 Sudeep Holla <[email protected]> wrote:
Quoted 34 lines · Rafael J. Wysocki
Quoted 32 lines · Sudeep Holla
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · Sudeep Holla
Quoted 16 lines · Yicong Yang
From: Yicong Yang <[email protected]>
Below error is met on my board and QEMU VM on SMT or non-SMT machine:
ACPI PPTT: PPTT table found, but unable to locate core 31 (31)This is because the processor node is found by iterating the PPTT table under condition (for both
acpi_find_processor_node()andacpi_pptt_leaf_node()):
while (entry +proc_sz<table_end)
[parse the processor node]If the last processor node is happened to be the last node in the PPTT table, above condition will always be false since entry +
proc_sz==table_end. Thus the last CPU is not parsed. Fix the loop condition to resolve the issue.Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
This issue is exposed by [1] but the root cause is explained above. Before [1] entry +
proc_szis always smaller thantable_end.Another thread [1] with similar patch.
OK, so is this a correct fix?
While it may fix the issue on the surface, I just want to be sure there are no other issues with the PPTT table presented from the firmware. I will asked some questions on that thread before I can agree on the solution.
Quoted 8 lines
Quoted 2 lines
Yeah, it looks like
table_endpoints to the last byte of the table instead of pointing to the first byte after the end of the table.Indeed and also we should have private resources like L1 cache described after the initial 20 bytes of the node. So I am bit worried if this will just hide other problems while it may solve this problem by looks of it. This example doesn't look like a proper PPTT matching real systems.
Assuming I'm understanding the bug correctly...
SMT systems will hit this. There will typically be no private resources for a thread as the L1I/D shared by multiple threads (which are processor nodes IIRC). Note we are trying to improve the cache description in QEMU at the moment as it would definitely be better to present caches in PPTT, but that isn't the main issue here.
Jonathan
Quoted 3 lines · Jonathan Cameron
On Wed, 7 May 2025 12:55:00 +0100
Sudeep Holla <[email protected]> wrote:
[...]
Quoted 7 lines
Quoted 6 lines
Indeed and also we should have private resources like L1 cache described after the initial 20 bytes of the node. So I am bit worried if this will just hide other problems while it may solve this problem by looks of it. This example doesn't look like a proper PPTT matching real systems.
Quoted 8 lines
Assuming I'm understanding the bug correctly...
SMT systems will hit this. There will typically be no private resources for a thread as the L1I/D shared by multiple threads (which are processor nodes IIRC). Note we are trying to improve the cache description in QEMU at the moment as it would definitely be better to present caches in PPTT, but that isn't the main issue here.
Indeed, I just replied in the other thread that I clearly missed SMT.
Signature · 2 lines
Regards, Sudeep