platform/x86/amd/hsmp: Add CONFIG_ACPI dependency
PATCH v2 1/1 platform/x86/amd/hsmp: Add CONFIG_ACPI dependency
HSMP interface is only supported on x86 based AMD EPYC line of processors. Driver uses ACPI APIs, so make it dependent on CONFIG_ACPI.
---
Changes since v1:
Correct the email id for Naveen Krishna Chatradhi and change it as Reviewed-by.
drivers/platform/x86/amd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/amd/Kconfig +1 -1
@@ -8,7 +8,7 @@ source "drivers/platform/x86/amd/pmc/Kconfig" config AMD_HSMP tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 + depends on AMD_NB && X86_64 && ACPI help The driver provides a way for user space tools to monitor and manage system management functionality on EPYC server CPUs from AMD.
Signature · 1 line
2.25.1
PATCH v2 1/1 platform/x86/amd/hsmp: Remove NULL dereferencing code
Do not log using dev_err() in case of !sock, which causes null pointer dereferencing.
Also remove unnecessary check "boot_cpu_data.x86_model >= 0x00", which is always true because its an unsigned type.
---
Changes since v1:
Correct the email id for Naveen Krishna Chatradhi.
drivers/platform/x86/amd/hsmp.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/platform/x86/amd/hsmp.c +4 -7
@@ -566,17 +566,15 @@ static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,struct hsmp_message msg = {0 };int ret; +if (!sock) +return -EINVAL ; +/* Do not support lseek(), reads entire metric table */ if (count < bin_attr->size) {dev_err (sock->dev,"Wrong buffer size\n" );return -EINVAL ; } -if (!sock) { -dev_err (sock->dev,"Failed to read attribute private data\n" ); -return -EINVAL ; - } - msg.msg_id =HSMP_GET_METRIC_TABLE ; msg.sock_ind = sock->sock_ind;
@@ -739,8 +737,7 @@ static int hsmp_cache_proto_ver(u16 sock_ind)static inline bool is_f1a_m0h (void ) { -if (boot_cpu_data.x86 ==0x1A && - (boot_cpu_data.x86_model >=0x00 && boot_cpu_data.x86_model <=0x0F )) +if (boot_cpu_data.x86 ==0x1A && boot_cpu_data.x86_model <=0x0F )return true;return false;
Signature · 1 line
2.25.1
Re: [PATCH v2] platform/x86/amd/hsmp: Remove NULL dereferencing code
Hi Suma,
Quoted 35 lines · Suma Hegde
Do not log using
dev_err()in case of !sock, which causes null pointer dereferencing.Also remove unnecessary check "boot_cpu_data.x86_model >=
0x00", which is always true because its an unsigned type.Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>---
Changes since v1:
Correct the email id for Naveen Krishna Chatradhi.drivers/platform/x86/amd/hsmp.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/platform/x86/amd/hsmp.c +3
-0@@ -566,17 +566,15 @@ static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,struct hsmp_message msg = {0 };int ret; +if (!sock) +return -EINVAL ; +/* Do not support lseek(), reads entire metric table */ if (count < bin_attr->size) {dev_err (sock->dev,"Wrong buffer size\n" );return -EINVAL ;
drivers/platform/x86/amd/hsmp.c static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, · line 580
Quoted 10 lines
drivers/platform/x86/amd/hsmp.c +0
-5} -if (!sock) { -dev_err (sock->dev,"Failed to read attribute private data\n" ); -return -EINVAL ; - } - msg.msg_id =HSMP_GET_METRIC_TABLE ; msg.sock_ind = sock->sock_ind;
sock gets initialized like this:
struct hsmp_socket *sock = bin_attr->private;
and bin_attr->private is setup before registering the file and thus it will never be NULL.
So the correct fix would be to simply drop the check rather then to move it.
drivers/platform/x86/amd/hsmp.c static int hsmp_cache_proto_ver(u16 sock_ind) · line 743
Quoted 10 lines
drivers/platform/x86/amd/hsmp.c +1
-2@@ -739,8 +737,7 @@ static int hsmp_cache_proto_ver(u16 sock_ind)static inline bool is_f1a_m0h (void ) { -if (boot_cpu_data.x86 ==0x1A && - (boot_cpu_data.x86_model >=0x00 && boot_cpu_data.x86_model <=0x0F )) +if (boot_cpu_data.x86 ==0x1A && boot_cpu_data.x86_model <=0x0F )return true;return false;
This bit looks fine but this really belongs in a separate patch as it has nothing to do with "Remove NULL dereferencing code"
Regards,
Hans
Re: [PATCH v2] platform/x86/amd/hsmp: Remove NULL dereferencing code
Hi Hans,
Quoted 53 lines · Hans de Goede
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi Suma,
Quoted 35 lines · Suma Hegde
Do not log using
dev_err()in case of !sock, which causes null pointer dereferencing.Also remove unnecessary check "boot_cpu_data.x86_model >=
0x00", which is always true because its an unsigned type.Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>---
Changes since v1:
Correct the email id for Naveen Krishna Chatradhi.drivers/platform/x86/amd/hsmp.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/platform/x86/amd/hsmp.c +3
-0@@ -566,17 +566,15 @@ static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj,struct hsmp_message msg = {0 };int ret; +if (!sock) +return -EINVAL ; +/* Do not support lseek(), reads entire metric table */ if (count < bin_attr->size) {dev_err (sock->dev,"Wrong buffer size\n" );return -EINVAL ;drivers/platform/x86/amd/hsmp.c static ssize_t hsmp_metric_tbl_read(struct file *filp, struct kobject *kobj, · line 580
Quoted 10 lines
drivers/platform/x86/amd/hsmp.c +0
-5} -if (!sock) { -dev_err (sock->dev,"Failed to read attribute private data\n" ); -return -EINVAL ; - } - msg.msg_id =HSMP_GET_METRIC_TABLE ; msg.sock_ind = sock->sock_ind;sock gets initialized like this:
Quoted 7 lines
struct hsmp_socket *sock = bin_attr->private;and
bin_attr->privateis setup before registering the file and thus it will never be NULL.So the correct fix would be to simply drop the check rather then to move it.
Thank you for your review comment, I will send a patch to address this change.
Quoted 9 lines
Quoted 9 lines
drivers/platform/x86/amd/hsmp.c +1
-2@@ -739,8 +737,7 @@ static int hsmp_cache_proto_ver(u16 sock_ind)static inline bool is_f1a_m0h (void ) { -if (boot_cpu_data.x86 ==0x1A && - (boot_cpu_data.x86_model >=0x00 && boot_cpu_data.x86_model <=0x0F )) +if (boot_cpu_data.x86 ==0x1A && boot_cpu_data.x86_model <=0x0F )return true;
Quoted 3 lines
drivers/platform/x86/amd/hsmp.c static int hsmp_cache_proto_ver(u16 sock_ind) · line 743
Quoted 1 line
drivers/platform/x86/amd/hsmp.c +0
-0return false;This bit looks fine but this really belongs in a separate patch as it has nothing to do with "Remove NULL dereferencing code"
Ilpo has already merged it into relevant patch(platform/x86/amd/hsmp: Non-ACPI support for AMD F1A_M00~0Fh) and the change is available in review-ilpo branch.
Quoted 3 lines
Regards,
Hans
Thanks and Regards,
Suma
Quoted 1 line
Hi,
Quoted 7 lines · Suma Hegde
HSMP interface is only supported on x86 based AMD EPYC line of processors. Driver uses ACPI APIs, so make it dependent on
CONFIG_ACPI.Reported-by kernel test robot <[email protected]>Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
I will include this patch in my next fixes pull-req to Linus for the current kernel development cycle.
Regards,
Hans
Quoted 21 lines
---
Changes since v1:
Correct the email id for Naveen Krishna Chatradhi and change it as Reviewed-by.drivers/platform/x86/amd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/amd/Kconfig +1
-1@@ -8,7 +8,7 @@ source "drivers/platform/x86/amd/pmc/Kconfig" config AMD_HSMP tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 + depends on AMD_NB && X86_64 && ACPI help The driver provides a way for user space tools to monitor and manage system management functionality on EPYC server CPUs from AMD.
Hi Hans,
Quoted 20 lines · Hans de Goede
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hi,
Quoted 7 lines · Suma Hegde
HSMP interface is only supported on x86 based AMD EPYC line of processors. Driver uses ACPI APIs, so make it dependent on
CONFIG_ACPI.Reported-by kernel test robot <[email protected]>Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hansNote it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Quoted 6 lines
I will include this patch in my next fixes pull-req to Linus for the current kernel development cycle.
Regards,
Hans
This change was merged by Ilpo in review-ilpo branch into commit: platform/x86/amd/hsmp: Add support for ACPI based probing.
Quoted 23 lines
Quoted 23 lines
---
Changes since v1:
Correct the email id for Naveen Krishna Chatradhi and change it as Reviewed-by.drivers/platform/x86/amd/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/amd/Kconfig +1
-1@@ -8,7 +8,7 @@ source "drivers/platform/x86/amd/pmc/Kconfig" config AMD_HSMP tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 + depends on AMD_NB && X86_64 && ACPI help The driver provides a way for user space tools to monitor and manage system management functionality on EPYC server CPUs from AMD.
Ilpo Järvinen
maintainerQuoted 30 lines · Suma
Quoted 13 lines · Hans de Goede
Quoted 8 lines · Suma Hegde
HSMP interface is only supported on x86 based AMD EPYC line of processors. Driver uses ACPI APIs, so make it dependent on
CONFIG_ACPI.Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hansQuoted 5 lines
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
I will include this patch in my next fixes pull-req to Linus for the current kernel development cycle.
This change was merged by Ilpo in review-ilpo branch into commit:
platform/x86/amd/hsmp: Add support for ACPI based probing.Quoted 7 lines
Quoted 7 lines
drivers/platform/x86/amd/Kconfig +0
-0@@ -8,7 +8,7 @@ source "drivers/platform/x86/amd/pmc/Kconfig"
Quoted 4 lines
Quoted 4 lines
drivers/platform/x86/amd/Kconfig source "drivers/platform/x86/amd/pmc/Kconfig" · line 11
Quoted 4 lines
drivers/platform/x86/amd/Kconfig +1
-1config AMD_HSMP tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 + depends on AMD_NB && X86_64 && ACPI
Yes, it only belongs to for-next.
The change that triggered the build fail is (it is only in for-next):
commit ba8dcff0e9c4f8fa6a46315126fb837acb0f98fc
Author: Suma Hegde <[email protected]> Date: Sat Jan 6 02:25:28 2024 +0000
platform/x86/amd/hsmp: Add support for ACPI based probing
Signature · 1 line
i.
Hi,
Quoted 31 lines · Ilpo Järvinen
Quoted 30 lines · Suma
Quoted 13 lines · Hans de Goede
Quoted 8 lines · Suma Hegde
HSMP interface is only supported on x86 based AMD EPYC line of processors. Driver uses ACPI APIs, so make it dependent on
CONFIG_ACPI.Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/Signed-off-by Suma Hegde <[email protected]>Reviewed-by Naveen Krishna Chatradhi <[email protected]>Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hansQuoted 5 lines
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
I will include this patch in my next fixes pull-req to Linus for the current kernel development cycle.
This change was merged by Ilpo in review-ilpo branch into commit:
platform/x86/amd/hsmp: Add support for ACPI based probing.Quoted 7 lines
Quoted 7 lines
drivers/platform/x86/amd/Kconfig +0
-0@@ -8,7 +8,7 @@ source "drivers/platform/x86/amd/pmc/Kconfig"
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
drivers/platform/x86/amd/Kconfig source "drivers/platform/x86/amd/pmc/Kconfig" · line 11
Quoted 4 lines
drivers/platform/x86/amd/Kconfig +1
-1config AMD_HSMP tristate "AMD HSMP Driver" - depends on AMD_NB && X86_64 + depends on AMD_NB && X86_64 && ACPIYes, it only belongs to for-next.
The change that triggered the build fail is (it is only in for-next):
Ah, my bad, thank you both for catching this.
I have dropped this from my review-hans branch now.
Regards,
Hans