platform/x86/amd/hsmp: fix compile-testing without CONFiG_AMD_NB
PATCH 1/1 platform/x86/amd/hsmp: fix compile-testing without CONFiG_AMD_NB
From: Arnd Bergmann <[email protected]>
node_to_amd_nb() is defined to NULL in non-AMD configs:
drivers/platform/x86/amd/hsmp/plat.c: In function 'init_platform_device':drivers/platform/x86/amd/hsmp/plat.c:165:68: error: dereferencing 'void *' pointer [-Werror]
165 | sock->root = node_to_amd_nb(i)->root;
| ^~drivers/platform/x86/amd/hsmp/plat.c:165:68: error: request for member 'root' in something not a structure or union
Change the definition to something that builds. This does introduce a NULL pointer dereference but the code is never called since the driver won't probe successfully.
--- arch/x86/include/asm/amd_nb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/include/asm/amd_nb.h +4 -1
@@ -116,7 +116,10 @@ static inline bool amd_gart_present(void)#define amd_nb_num (x) 0#define amd_nb_has_feature (x) false -#define node_to_amd_nb (x) NULL +static inline struct amd_northbridge *node_to_amd_nb (int node) +{ +return NULL ; +}#define amd_gart_present (x) false#endif
Signature · 1 line
2.39.5
Borislav Petkov
maintainerQuoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
node_to_amd_nb()is defined to NULL in non-AMD configs:
drivers/platform/x86/amd/hsmp/plat.c: In function 'init_platform_device':drivers/platform/x86/amd/hsmp/plat.c:165:68: error: dereferencing 'void *' pointer [-Werror]
165 |sock->root= node_to_amd_nb(i)->root;
| ^~drivers/platform/x86/amd/hsmp/plat.c:165:68: error: request for member 'root' in something not a structure or union
Quoted 5 lines
Change the definition to something that builds. This does introduce a NULL pointer dereference but the code is never called since the driver won't probe successfully.
Fixes 7d3135d16356 ("platform/x86/amd/hsmp: Create separate ACPI, plat and common drivers")
^^^^^^^^^^^^
I'm guessing this is queued for 6.13...
Quoted 10 lines
Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/include/asm/amd_nb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/x86/include/asm/amd_nb.h +0
-0
arch/x86/include/asm/amd_nb.h static inline bool amd_gart_present(void) · line 123
Quoted 9 lines
arch/x86/include/asm/amd_nb.h +4
-1@@ -116,7 +116,10 @@ static inline bool amd_gart_present(void)#define amd_nb_num (x) 0#define amd_nb_has_feature (x) false -#define node_to_amd_nb (x) NULL +static inline struct amd_northbridge *node_to_amd_nb (int node) +{ +return NULL ; +}#define amd_gart_present (x) false
... so this fix should go to Linus now so that build testing doesn't break?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 13 lines · Borislav Petkov
arch/x86/include/asm/amd_nb.h static inline bool amd_gart_present(void) · line 123
Quoted 9 lines · Arnd Bergmann
#define
amd_nb_num(x)0
#defineamd_nb_has_feature(x)falsearch/x86/include/asm/amd_nb.h +4
-1-#define node_to_amd_nb (x) NULL +static inline struct amd_northbridge *node_to_amd_nb (int node) +{ +return NULL ; +}#define amd_gart_present (x) false... so this fix should go to Linus now so that build testing doesn't break?
That would work, or Ilpo can pick it into the tree that has the driver changes, possibly folding the fix into the other changes.
Arnd
Borislav Petkov
maintainerQuoted 3 lines · Arnd Bergmann
That would work, or Ilpo can pick it into the tree that has the driver changes, possibly folding the fix into the other changes.
Right, while it shouldn't be a problem, I'd like to keep all amd_nb changes in one tree because we have stuff in-flight touching and changing exactly that area so...
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 8 lines · Borislav Petkov
Quoted 3 lines · Arnd Bergmann
That would work, or Ilpo can pick it into the tree that has the driver changes, possibly folding the fix into the other changes.
Right, while it shouldn't be a problem, I'd like to keep all
amd_nbchanges in one tree because we have stuff in-flight touching and changing exactly that area so...
Hi Boris,
I'm unfortunately left a bit unsure what exactly is your suggestion here, so could you please elaborate?
(I'm assuming the big amd_nb series will go through the x86 tree.)
Thanks in advance.
Signature · 1 line
i.
Borislav Petkov
maintainerHi,
Quoted 2 lines · Ilpo Järvinen
I'm unfortunately left a bit unsure what exactly is your suggestion here, so could you please elaborate?
My suggestion is, I send it to Linus now so it appears in 6.12-rc6 and thus the build error is gone in every other tree.
Quoted 1 line
(I'm assuming the big
amd_nbseries will go through the x86 tree.)
Yeah, eventually. Not now but see above: if the fix appears in mainline now, no problems.
Right?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 7 lines · Borislav Petkov
Quoted 2 lines · Ilpo Järvinen
I'm unfortunately left a bit unsure what exactly is your suggestion here, so could you please elaborate?
My suggestion is, I send it to Linus now so it appears in 6.12-rc6 and thus the build error is gone in every other tree.
Quoted 6 lines
Quoted 1 line
(I'm assuming the big
amd_nbseries will go through the x86 tree.)Yeah, eventually. Not now but see above: if the fix appears in mainline now, no problems.
Right?
Yes, I'm fine with you sending it to Linus in this cycle. Thanks.
Signature · 1 line
i.
Quoted 10 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
node_to_amd_nb()is defined to NULL in non-AMD configs:
drivers/platform/x86/amd/hsmp/plat.c: In function 'init_platform_device':drivers/platform/x86/amd/hsmp/plat.c:165:68: error: dereferencing 'void *' pointer [-Werror]
165 |sock->root= node_to_amd_nb(i)->root;
| ^~drivers/platform/x86/amd/hsmp/plat.c:165:68: error: request for member 'root' in something not a structure or union
Quoted 3 lines
Change the definition to something that builds. This does introduce a NULL pointer dereference but the code is never called since the driver won't probe successfully.
I don't like this very wording because what the code very much does is NULL check on node_to_amd_nb() which leads to immediate failure of .probe(). (We don't call other deferences after a NULL check "NULL pointer dereference" either so none is introduced by this patch, IMO.)
With that fixed,
Signature · 1 line
i.
Quoted 23 lines
Fixes 7d3135d16356 ("platform/x86/amd/hsmp: Create separate ACPI, plat and common drivers")Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/include/asm/amd_nb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arch/x86/include/asm/amd_nb.h +4
-1@@ -116,7 +116,10 @@ static inline bool amd_gart_present(void)#define amd_nb_num (x) 0#define amd_nb_has_feature (x) false -#define node_to_amd_nb (x) NULL +static inline struct amd_northbridge *node_to_amd_nb (int node) +{ +return NULL ; +}#define amd_gart_present (x) false#endif
Borislav Petkov
maintainerQuoted 4 lines · Ilpo Järvinen
I don't like this very wording because what the code very much does is NULL check on
node_to_amd_nb()which leads to immediate failure of .probe(). (We don't call other deferences after a NULL check "NULL pointer dereference" either so none is introduced by this patch, IMO.)
I was wondering that too: where does this line
sock->root = node_to_amd_nb(i)->root;
quoted by gcc come from?
IOW, what is the correct Fixes: tag?
The commit 7d3135d16356 ("platform/x86/amd/hsmp: Create separate ACPI, plat and common drivers
is only in next AFAICT, so I'll drop the Fixes: tag when sending...
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 10 lines · Borislav Petkov
Quoted 4 lines · Ilpo Järvinen
I don't like this very wording because what the code very much does is NULL check on
node_to_amd_nb()which leads to immediate failure of .probe(). (We don't call other deferences after a NULL check "NULL pointer dereference" either so none is introduced by this patch, IMO.)I was wondering that too: where does this line
sock->root = node_to_amd_nb(i)->root;
Quoted 7 lines
quoted by gcc come from?
IOW, what is the correct Fixes: tag?
The commit
7d3135d16356("platform/x86/amd/hsmp: Create separate ACPI, plat and common driversis only in next AFAICT, so I'll drop the Fixes: tag when sending...
To clarify,
The assignment line is old (from 287a821c76be8 or even before that in some form which would have not lead to compiler warning though).
It's the COMPILE_TEST that got enabled in 7d3135d16356, before that hsmp depended on AMD_NB so the condition could never trigger.
Signature · 1 line
i.
Borislav Petkov
maintainerQuoted 2 lines · Ilpo Järvinen
It's the
COMPILE_TESTthat got enabled in7d3135d16356, before that hsmp depended onAMD_NBso the condition could never trigger.
This COMPILE_TEST thing is only causing more trouble than it is solving... :-\
Lemme fixup Arnd's commit message and queue it.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[tip: x86/urgent] x86/amd_nb: Fix compile-testing without CONFIG_AMD_NB
In reply to Arnd BergmannThe following commit has been merged into the x86/urgent branch of tip:
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: fce9642c765a18abd1db0339a7d832c29b68456a Gitweb: https://git.kernel.org/tip/fce9642c765a18abd1db0339a7d832c29b68456a Author: Arnd Bergmann <[email protected]> AuthorDate: Tue, 29 Oct 2024 09:23:20 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Tue, 29 Oct 2024 18:16:05 +01:00
x86/amd_nb: Fix compile-testing without CONFIG_AMD_NB
node_to_amd_nb() is defined to NULL in non-AMD configs:
drivers/platform/x86/amd/hsmp/plat.c: In function 'init_platform_device':
drivers/platform/x86/amd/hsmp/plat.c:165:68: error: dereferencing 'void *' pointer [-Werror]
165 | sock->root = node_to_amd_nb(i)->root;
| ^~ drivers/platform/x86/amd/hsmp/plat.c:165:68: error: request for member 'root' in something not a structure or union
Users of the interface who also allow COMPILE_TEST will cause the above build error so provide an inline stub to fix that.
[ bp: Massage commit message. ]
--- arch/x86/include/asm/amd_nb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/include/asm/amd_nb.h +4 -1
@@ -116,7 +116,10 @@ static inline bool amd_gart_present(void)#define amd_nb_num (x) 0#define amd_nb_has_feature (x) false -#define node_to_amd_nb (x) NULL +static inline struct amd_northbridge *node_to_amd_nb (int node) +{ +return NULL ; +}#define amd_gart_present (x) false#endif