Skip to contentSkip to conversation

platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore()

PATCH In review rjingar 2 participants 3 messages Dec 16, 2023 – Dec 18, 2023

Subsystems (2)
lore
Share & tools
lore

rjingar

author
#0 lore raw

PATCH 1/2 platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore()

From: Rajvi Jingar <[email protected]>

For input value 0, PMC stays unassigned which causes crash while trying to access PMC for register read/write. Include LTR index 0 in pmc_index and ltr_index calculation.

Fixes 2bcef4529222 ("platform/x86:intel/pmc: Enable debugfs multiple PMC support")
---
 drivers/platform/x86/intel/pmc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel/pmc/core.c +1 -1
index 983e3a8f4910..55eb6a4683fb 100644
@@ -474,7 +474,7 @@ int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value)
 	 * is based on the contiguous indexes from ltr_show output.
 	 * pmc index and ltr index needs to be calculated from it.
 	 */
-	for (pmc_index = 0; pmc_index < ARRAY_SIZE(pmcdev->pmcs) && ltr_index > 0; pmc_index++) {
+	for (pmc_index = 0; pmc_index < ARRAY_SIZE(pmcdev->pmcs) && ltr_index >= 0; pmc_index++) {
 		pmc = pmcdev->pmcs[pmc_index];
 
 		if (!pmc)
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/2
#1 lore raw
Quoted 18 lines · rjingar

From: Rajvi Jingar <[email protected]>

For input value 0, PMC stays unassigned which causes crash while trying to access PMC for register read/write. Include LTR index 0 in pmc_index and ltr_index calculation.

Fixes 2bcef4529222 ("platform/x86:intel/pmc: Enable debugfs multiple PMC support")
---
 drivers/platform/x86/intel/pmc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/intel/pmc/core.c +0 -0
index 983e3a8f4910..55eb6a4683fb 100644

drivers/platform/x86/intel/pmc/core.c int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value) · line 480

Quoted 8 lines
drivers/platform/x86/intel/pmc/core.c +1 -1
@@ -474,7 +474,7 @@ int pmc_core_send_ltr_ignore(struct pmc_dev *pmcdev, u32 value)
 	 * is based on the contiguous indexes from ltr_show output.
 	 * pmc index and ltr index needs to be calculated from it.
 	 */
-	for (pmc_index = 0; pmc_index < ARRAY_SIZE(pmcdev->pmcs) && ltr_index > 0; pmc_index++) {
+	for (pmc_index = 0; pmc_index < ARRAY_SIZE(pmcdev->pmcs) && ltr_index >= 0; pmc_index++) {
 		pmc = pmcdev->pmcs[pmc_index];
 
 		if (!pmc)

I'll have to say though I really don't like they way that function is playing with fire by mixing the use of signed and unsigned variables.

As is, this can only be triggered through a debugfs write and we're already in -rc6 so IMO next material.

Signature · 1 line
 i.
maintainer
#2 lore raw
In reply to rjingar
Quoted 5 lines · rjingar

For input value 0, PMC stays unassigned which causes crash while trying to access PMC for register read/write. Include LTR index 0 in pmc_index and ltr_index calculation.

Thank you for your contribution, it has been applied to my local review-ilpo branch. Note it will show up in the public platform-drivers-x86/review-ilpo branch only once I've pushed my local branch there, which might take a while.

The list of commits applied:
[1/2] platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore()

      commit: fbcf67ce5a9e2831c14bdfb895be05213e611724

--
i.