diff mbox series

[02/16] x86/amd_nb: Restrict init function to AMD-based systems

Message ID 20241023172150.659002-3-yazen.ghannam@amd.com (mailing list archive)
State Handled Elsewhere
Headers show
Series AMD NB and SMN rework | expand

Commit Message

Yazen Ghannam Oct. 23, 2024, 5:21 p.m. UTC
The code implicitly operates on AMD-based systems by matching on PCI
IDs. However, the use of these IDs is going away.

Add an explicit CPU vendor check instead of relying on PCI IDs.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 arch/x86/kernel/amd_nb.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Zhuo, Qiuxu Oct. 31, 2024, 8:09 a.m. UTC | #1
> From: Yazen Ghannam <yazen.ghannam@amd.com>
> [..]
> --- a/arch/x86/kernel/amd_nb.c
> +++ b/arch/x86/kernel/amd_nb.c
> @@ -582,6 +582,10 @@ static __init void fix_erratum_688(void)
> 
>  static __init int init_amd_nbs(void)
>  {
> +	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
> +	    boot_cpu_data.x86_vendor != X86_VENDOR_HYGON)
> +		return 0;
> +
>  	amd_cache_northbridges();

This function could fail and return an error.
Is an early return with an error code needed if this function fails?

[ I know this is out of this patch scope. ]

>  	amd_cache_gart();

-Qiuxu
Borislav Petkov Oct. 31, 2024, 10:36 a.m. UTC | #2
On Thu, Oct 31, 2024 at 08:09:14AM +0000, Zhuo, Qiuxu wrote:
> This function could fail and return an error.
> Is an early return with an error code needed if this function fails?

No, grep for amd_northbridges.num checks in the code.
Zhuo, Qiuxu Oct. 31, 2024, 11:50 a.m. UTC | #3
> From: Borislav Petkov <bp@alien8.de>
> [...]
> 
> On Thu, Oct 31, 2024 at 08:09:14AM +0000, Zhuo, Qiuxu wrote:
> > This function could fail and return an error.
> > Is an early return with an error code needed if this function fails?
> 
> No, grep for amd_northbridges.num checks in the code.

If the return value of amd_cache_northbridges() isn't used in any place, 
make it return void?

-Qiuxu
Borislav Petkov Oct. 31, 2024, 1:11 p.m. UTC | #4
On October 31, 2024 12:50:10 PM GMT+01:00, "Zhuo, Qiuxu" <qiuxu.zhuo@intel.com> wrote:
>> From: Borislav Petkov <bp@alien8.de>
>> [...]
>> 
>> On Thu, Oct 31, 2024 at 08:09:14AM +0000, Zhuo, Qiuxu wrote:
>> > This function could fail and return an error.
>> > Is an early return with an error code needed if this function fails?
>> 
>> No, grep for amd_northbridges.num checks in the code.
>
>If the return value of amd_cache_northbridges() isn't used in any place, 
>make it return void?
>
>-Qiuxu

Feel free to propose patches *after* the dust around that area settles.
diff mbox series

Patch

diff --git a/arch/x86/kernel/amd_nb.c b/arch/x86/kernel/amd_nb.c
index 9fe9972d2071..37b8244899d8 100644
--- a/arch/x86/kernel/amd_nb.c
+++ b/arch/x86/kernel/amd_nb.c
@@ -582,6 +582,10 @@  static __init void fix_erratum_688(void)
 
 static __init int init_amd_nbs(void)
 {
+	if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD &&
+	    boot_cpu_data.x86_vendor != X86_VENDOR_HYGON)
+		return 0;
+
 	amd_cache_northbridges();
 	amd_cache_gart();