The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/2] platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore()
@ 2023-12-16  1:16 rjingar
  2023-12-18 12:30 ` Ilpo Järvinen
  2023-12-18 13:10 ` Ilpo Järvinen
  0 siblings, 2 replies; 3+ messages in thread
From: rjingar @ 2023-12-16  1:16 UTC (permalink / raw)
  To: irenic.rajneesh, david.e.box, hdegoede, ilpo.jarvinen, markgross,
	platform-driver-x86, linux-kernel
  Cc: rajvi.jingar

From: Rajvi Jingar <rajvi.jingar@linux.intel.com>

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")
Signed-off-by: Rajvi Jingar <rajvi.jingar@linux.intel.com>
---
 drivers/platform/x86/intel/pmc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c
index 983e3a8f4910..55eb6a4683fb 100644
--- a/drivers/platform/x86/intel/pmc/core.c
+++ b/drivers/platform/x86/intel/pmc/core.c
@@ -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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore()
  2023-12-16  1:16 [PATCH 1/2] platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore() rjingar
@ 2023-12-18 12:30 ` Ilpo Järvinen
  2023-12-18 13:10 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2023-12-18 12:30 UTC (permalink / raw)
  To: rjingar, Hans de Goede
  Cc: irenic.rajneesh, david.e.box, markgross, platform-driver-x86,
	LKML

[-- Attachment #1: Type: text/plain, Size: 1539 bytes --]

On Fri, 15 Dec 2023, rjingar wrote:

> From: Rajvi Jingar <rajvi.jingar@linux.intel.com>
> 
> 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")
> Signed-off-by: Rajvi Jingar <rajvi.jingar@linux.intel.com>
> ---
>  drivers/platform/x86/intel/pmc/core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel/pmc/core.c b/drivers/platform/x86/intel/pmc/core.c
> index 983e3a8f4910..55eb6a4683fb 100644
> --- a/drivers/platform/x86/intel/pmc/core.c
> +++ b/drivers/platform/x86/intel/pmc/core.c
> @@ -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)
> 

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

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.

-- 
 i.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore()
  2023-12-16  1:16 [PATCH 1/2] platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore() rjingar
  2023-12-18 12:30 ` Ilpo Järvinen
@ 2023-12-18 13:10 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2023-12-18 13:10 UTC (permalink / raw)
  To: irenic.rajneesh, david.e.box, hdegoede, markgross,
	platform-driver-x86, linux-kernel, rjingar

On Fri, 15 Dec 2023 17:16:50 -0800, rjingar wrote:

> 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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-18 13:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-16  1:16 [PATCH 1/2] platform/x86/intel/pmc: Fix hang in pmc_core_send_ltr_ignore() rjingar
2023-12-18 12:30 ` Ilpo Järvinen
2023-12-18 13:10 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox