* [PATCH] perf/x86/amd: Run AMD BRS code only on supported hw
@ 2022-05-16 15:48 Borislav Petkov
2022-05-17 0:59 ` Stephane Eranian
2022-05-17 22:14 ` [tip: perf/core] " tip-bot2 for Borislav Petkov
0 siblings, 2 replies; 4+ messages in thread
From: Borislav Petkov @ 2022-05-16 15:48 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Stephane Eranian, X86 ML, LKML
From: Borislav Petkov <bp@suse.de>
This fires on a Fam16h machine here:
unchecked MSR access error: WRMSR to 0xc000010f (tried to write 0x0000000000000018) \
at rIP: 0xffffffff81007db1 (amd_brs_reset+0x11/0x50)
Call Trace:
<TASK>
amd_pmu_cpu_starting
? x86_pmu_dead_cpu
x86_pmu_starting_cpu
cpuhp_invoke_callback
? x86_pmu_starting_cpu
? x86_pmu_dead_cpu
cpuhp_issue_call
? x86_pmu_starting_cpu
__cpuhp_setup_state_cpuslocked
? x86_pmu_dead_cpu
? x86_pmu_starting_cpu
__cpuhp_setup_state
? map_vsyscall
init_hw_perf_events
? map_vsyscall
do_one_initcall
? _raw_spin_unlock_irqrestore
? try_to_wake_up
kernel_init_freeable
? rest_init
kernel_init
ret_from_fork
because that CPU hotplug callback gets executed on any AMD CPU - not
only on the BRS-enabled ones. Check the BRS feature bit properly.
Signed-off-by: Borislav Petkov <bp@suse.de>
---
arch/x86/events/amd/brs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/amd/brs.c b/arch/x86/events/amd/brs.c
index 895c82165d85..bee8765a1e9b 100644
--- a/arch/x86/events/amd/brs.c
+++ b/arch/x86/events/amd/brs.c
@@ -57,7 +57,7 @@ static inline u64 get_debug_extn_cfg(void)
static bool __init amd_brs_detect(void)
{
- if (!boot_cpu_has(X86_FEATURE_BRS))
+ if (!cpu_feature_enabled(X86_FEATURE_BRS))
return false;
switch (boot_cpu_data.x86) {
@@ -112,6 +112,9 @@ static inline int amd_brs_get_tos(union amd_debug_extn_cfg *cfg)
*/
void amd_brs_reset(void)
{
+ if (!cpu_feature_enabled(X86_FEATURE_BRS))
+ return;
+
/*
* Reset config
*/
--
2.35.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf/x86/amd: Run AMD BRS code only on supported hw
2022-05-16 15:48 [PATCH] perf/x86/amd: Run AMD BRS code only on supported hw Borislav Petkov
@ 2022-05-17 0:59 ` Stephane Eranian
2022-05-17 8:46 ` Borislav Petkov
2022-05-17 22:14 ` [tip: perf/core] " tip-bot2 for Borislav Petkov
1 sibling, 1 reply; 4+ messages in thread
From: Stephane Eranian @ 2022-05-17 0:59 UTC (permalink / raw)
To: Borislav Petkov; +Cc: Peter Zijlstra, X86 ML, LKML
On Mon, May 16, 2022 at 8:48 AM Borislav Petkov <bp@alien8.de> wrote:
>
> From: Borislav Petkov <bp@suse.de>
>
> This fires on a Fam16h machine here:
>
> unchecked MSR access error: WRMSR to 0xc000010f (tried to write 0x0000000000000018) \
> at rIP: 0xffffffff81007db1 (amd_brs_reset+0x11/0x50)
> Call Trace:
> <TASK>
> amd_pmu_cpu_starting
> ? x86_pmu_dead_cpu
> x86_pmu_starting_cpu
> cpuhp_invoke_callback
> ? x86_pmu_starting_cpu
> ? x86_pmu_dead_cpu
> cpuhp_issue_call
> ? x86_pmu_starting_cpu
> __cpuhp_setup_state_cpuslocked
> ? x86_pmu_dead_cpu
> ? x86_pmu_starting_cpu
> __cpuhp_setup_state
> ? map_vsyscall
> init_hw_perf_events
> ? map_vsyscall
> do_one_initcall
> ? _raw_spin_unlock_irqrestore
> ? try_to_wake_up
> kernel_init_freeable
> ? rest_init
> kernel_init
> ret_from_fork
>
> because that CPU hotplug callback gets executed on any AMD CPU - not
> only on the BRS-enabled ones. Check the BRS feature bit properly.
>
Thanks for catching this. I tested on Zen2 (Fam17h) and it did not
trigger the problem, yet I think
the problem in amd_brs_reset() is there.
> Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-By: Stephane Eranian <eranian@google.com>
> ---
> arch/x86/events/amd/brs.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/events/amd/brs.c b/arch/x86/events/amd/brs.c
> index 895c82165d85..bee8765a1e9b 100644
> --- a/arch/x86/events/amd/brs.c
> +++ b/arch/x86/events/amd/brs.c
> @@ -57,7 +57,7 @@ static inline u64 get_debug_extn_cfg(void)
>
> static bool __init amd_brs_detect(void)
> {
> - if (!boot_cpu_has(X86_FEATURE_BRS))
> + if (!cpu_feature_enabled(X86_FEATURE_BRS))
> return false;
>
> switch (boot_cpu_data.x86) {
> @@ -112,6 +112,9 @@ static inline int amd_brs_get_tos(union amd_debug_extn_cfg *cfg)
> */
> void amd_brs_reset(void)
> {
> + if (!cpu_feature_enabled(X86_FEATURE_BRS))
> + return;
> +
> /*
> * Reset config
> */
> --
> 2.35.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] perf/x86/amd: Run AMD BRS code only on supported hw
2022-05-17 0:59 ` Stephane Eranian
@ 2022-05-17 8:46 ` Borislav Petkov
0 siblings, 0 replies; 4+ messages in thread
From: Borislav Petkov @ 2022-05-17 8:46 UTC (permalink / raw)
To: Stephane Eranian; +Cc: Peter Zijlstra, X86 ML, LKML
On Mon, May 16, 2022 at 05:59:27PM -0700, Stephane Eranian wrote:
> Thanks for catching this. I tested on Zen2 (Fam17h) and it did not
> trigger the problem
That's because Zen2 has this MSR - 0xc000010f - so the write succeeds.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: perf/core] perf/x86/amd: Run AMD BRS code only on supported hw
2022-05-16 15:48 [PATCH] perf/x86/amd: Run AMD BRS code only on supported hw Borislav Petkov
2022-05-17 0:59 ` Stephane Eranian
@ 2022-05-17 22:14 ` tip-bot2 for Borislav Petkov
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Borislav Petkov @ 2022-05-17 22:14 UTC (permalink / raw)
To: linux-tip-commits
Cc: Borislav Petkov, Peter Zijlstra (Intel), x86, linux-kernel
The following commit has been merged into the perf/core branch of tip:
Commit-ID: 841b51e4a3590866d17fa2663c64688c25b891b1
Gitweb: https://git.kernel.org/tip/841b51e4a3590866d17fa2663c64688c25b891b1
Author: Borislav Petkov <bp@suse.de>
AuthorDate: Mon, 16 May 2022 17:48:38 +02:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 18 May 2022 00:08:26 +02:00
perf/x86/amd: Run AMD BRS code only on supported hw
This fires on a Fam16h machine here:
unchecked MSR access error: WRMSR to 0xc000010f (tried to write 0x0000000000000018) \
at rIP: 0xffffffff81007db1 (amd_brs_reset+0x11/0x50)
Call Trace:
<TASK>
amd_pmu_cpu_starting
? x86_pmu_dead_cpu
x86_pmu_starting_cpu
cpuhp_invoke_callback
? x86_pmu_starting_cpu
? x86_pmu_dead_cpu
cpuhp_issue_call
? x86_pmu_starting_cpu
__cpuhp_setup_state_cpuslocked
? x86_pmu_dead_cpu
? x86_pmu_starting_cpu
__cpuhp_setup_state
? map_vsyscall
init_hw_perf_events
? map_vsyscall
do_one_initcall
? _raw_spin_unlock_irqrestore
? try_to_wake_up
kernel_init_freeable
? rest_init
kernel_init
ret_from_fork
because that CPU hotplug callback gets executed on any AMD CPU - not
only on the BRS-enabled ones. Check the BRS feature bit properly.
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-By: Stephane Eranian <eranian@google.com>
Link: https://lkml.kernel.org/r/20220516154838.7044-1-bp@alien8.de
---
arch/x86/events/amd/brs.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/events/amd/brs.c b/arch/x86/events/amd/brs.c
index 895c821..bee8765 100644
--- a/arch/x86/events/amd/brs.c
+++ b/arch/x86/events/amd/brs.c
@@ -57,7 +57,7 @@ static inline u64 get_debug_extn_cfg(void)
static bool __init amd_brs_detect(void)
{
- if (!boot_cpu_has(X86_FEATURE_BRS))
+ if (!cpu_feature_enabled(X86_FEATURE_BRS))
return false;
switch (boot_cpu_data.x86) {
@@ -112,6 +112,9 @@ static inline int amd_brs_get_tos(union amd_debug_extn_cfg *cfg)
*/
void amd_brs_reset(void)
{
+ if (!cpu_feature_enabled(X86_FEATURE_BRS))
+ return;
+
/*
* Reset config
*/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-17 22:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16 15:48 [PATCH] perf/x86/amd: Run AMD BRS code only on supported hw Borislav Petkov
2022-05-17 0:59 ` Stephane Eranian
2022-05-17 8:46 ` Borislav Petkov
2022-05-17 22:14 ` [tip: perf/core] " tip-bot2 for Borislav Petkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®