Subsystems (2)
Hi,
After 3.14 I noticed that perf started to only support software events.
The reason - found after a some staring deathmatches because the patches look innocent - is a typo in __flip_bit() introduced by 22085a66c2fab6cf9b9393c056a3600a6b4735de which only takes effect after c0a639ad0bc6b178b46996bd1f821a04643e2bde. Due to the typo no msr writes via either msr_clear/set_bit actually write back the new value. That then causes cpuid limits not to be lifted causing 'my' perf and very likely some other problems.
There's also a typo in the former commit which makes it impossible to actually use the MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro correctly.
Regards,
Andres Freund
PATCH 1/2 x86: Fix typo preventing msr_set/clear_bit from having an effect
Due to a typo the msr accessor function introduced in 22085a66c2fab6cf9b9393c056a3600a6b4735de didn't have any lasting effects because they accidentally wrote the old value back.
After c0a639ad0bc6b178b46996bd1f821a04643e2bde this at the very least this causes cpuid limits not to be lifted on some cpus leading to missing capabilities for those.
--- arch/x86/lib/msr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/lib/msr.c +1 -1
@@ -76,7 +76,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set)if (m1.q == m.q)return 0 ; - err =msr_write (msr, &m); + err =msr_write (msr, &m1);if (err)return err;
Signature · 1 line
2.0.0.rc2.4.g1dc51c6.dirty
Re: [PATCH 1/2] x86: Fix typo preventing msr_set/clear_bit from having an effect
Quoted 22 lines · Andres Freund
Due to a typo the msr accessor function introduced in
22085a66c2fab6cf9b9393c056a3600a6b4735dedidn't have any lasting effects because they accidentally wrote the old value back.After
c0a639ad0bc6b178b46996bd1f821a04643e2bdethis at the very least this causes cpuid limits not to be lifted on some cpus leading to missing capabilities for those.Signed-off-by Andres Freund <[email protected]>Cc Borislav Petkov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Ingo Molnar <[email protected]>Cc Thomas Gleixner <[email protected]>--- arch/x86/lib/msr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/lib/msr.c +0
-0
arch/x86/lib/msr.c static inline int __flip_bit(u32 msr, u8 bit, bool set) · line 81
Quoted 7 lines
arch/x86/lib/msr.c +1
-1@@ -76,7 +76,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set)if (m1.q == m.q)return 0 ; - err =msr_write (msr, &m); + err =msr_write (msr, &m1);if (err)return err;
Good catch, thanks, and sorry about the screwup! :-[
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 1/2] x86: Fix typo preventing msr_set/clear_bit from having an effect
Hi,
Quoted 17 lines · Borislav Petkov
Quoted 8 lines · Andres Freund
Due to a typo the msr accessor function introduced in
22085a66c2fab6cf9b9393c056a3600a6b4735dedidn't have any lasting effects because they accidentally wrote the old value back.After
c0a639ad0bc6b178b46996bd1f821a04643e2bdethis at the very least this causes cpuid limits not to be lifted on some cpus leading to missing capabilities for those.Quoted 8 lines
Signed-off-by Andres Freund <[email protected]>Cc Borislav Petkov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Ingo Molnar <[email protected]>Cc Thomas Gleixner <[email protected]>--- arch/x86/lib/msr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 3 lines
Good catch, thanks, and sorry about the screwup! :-[
Acked-by Borislav Petkov <[email protected]>
It got caught before the release, so all is well... Actually rather surprised it only causes relatively minor problems; i.e. still boots.
Did I CC the correct people for this to get picked up for 3.15 or to I need to do anything else?
Greetings,
Andres Freund
Re: [PATCH 1/2] x86: Fix typo preventing msr_set/clear_bit from having an effect
Quoted 1 line · Andres Freund
It got caught before the release, so all is well...
Yeah.
Quoted 2 lines
Actually rather surprised it only causes relatively minor problems; i.e. still boots.
Well, I did switch only a couple of sites in intel.c, maybe you got lucky... (if that can be called getting lucky at all :-P).
Quoted 2 lines
Did I CC the correct people for this to get picked up for 3.15 or to I need to do anything else?
Yes, you did, it looks good.
Thanks!
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--tip-bot for Andres Freund
merge bot[tip:x86/urgent] x86: Fix typo preventing msr_set/ clear_bit from having an effect
In reply to Andres Freundx86: Fix typo preventing msr_set/clear_bit from having an effect
Commit-ID: 722a0d22d028bd74061cf582de1764884e73674f Gitweb: http://git.kernel.org/tip/722a0d22d028bd74061cf582de1764884e73674f Author: Andres Freund <[email protected]> AuthorDate: Fri, 9 May 2014 03:29:16 +0200 Committer: H. Peter Anvin <[email protected]> CommitDate: Fri, 9 May 2014 08:42:32 -0700
x86: Fix typo preventing msr_set/clear_bit from having an effect
Due to a typo the msr accessor function introduced in 22085a66c2fab6cf9b9393c056a3600a6b4735de didn't have any lasting effects because they accidentally wrote the old value back.
After c0a639ad0bc6b178b46996bd1f821a04643e2bde this at the very least this causes cpuid limits not to be lifted on some cpus leading to missing capabilities for those.
--- arch/x86/lib/msr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/lib/msr.c +1 -1
@@ -76,7 +76,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set)if (m1.q == m.q)return 0 ; - err =msr_write (msr, &m); + err =msr_write (msr, &m1);if (err)return err;
PATCH 2/2 x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro
In reply to Andres FreundThe spuriously added semicolon didn't have any effect because the macro isn't currently in use.
c0a639ad0bc6b178b46996bd1f821a04643e2bde
--- arch/x86/include/uapi/asm/msr-index.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/uapi/asm/msr-index.h +1 -1
@@ -384,7 +384,7 @@#define MSR_IA32_MISC_ENABLE_MWAIT_BIT 18#define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << MSR_IA32_MISC_ENABLE_MWAIT_BIT)#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT 22 -#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT); +#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT)#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT 23#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT)#define MSR_IA32_MISC_ENABLE_XD_DISABLE_BIT 34
Signature · 1 line
2.0.0.rc2.4.g1dc51c6.dirty
Re: [PATCH 2/2] x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro
Quoted 19 lines · Andres Freund
The spuriously added semicolon didn't have any effect because the macro isn't currently in use.
c0a639ad0bc6b178b46996bd1f821a04643e2bdeSigned-off-by Andres Freund <[email protected]>Cc Borislav Petkov <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Ingo Molnar <[email protected]>Cc Thomas Gleixner <[email protected]>--- arch/x86/include/uapi/asm/msr-index.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/uapi/asm/msr-index.h +0
-0
arch/x86/include/uapi/asm/msr-index.h line 390
Quoted 8 lines
arch/x86/include/uapi/asm/msr-index.h +1
-1@@ -384,7 +384,7 @@#define MSR_IA32_MISC_ENABLE_MWAIT_BIT 18#define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << MSR_IA32_MISC_ENABLE_MWAIT_BIT)#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT 22 -#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT); +#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT)#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT 23#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT)#define MSR_IA32_MISC_ENABLE_XD_DISABLE_BIT 34
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Re: [PATCH 2/2] x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro
Quoted 10 lines · Borislav Petkov
arch/x86/include/uapi/asm/msr-index.h line 387
Quoted 10 lines
arch/x86/include/uapi/asm/msr-index.h +1
-1@@ -384,7 +384,7 @@#define MSR_IA32_MISC_ENABLE_MWAIT_BIT 18#define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << MSR_IA32_MISC_ENABLE_MWAIT_BIT)#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT 22 -#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT); +#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT)
Btw, we should probably be catching typos like that with checkpatch. Here's an initial version for single-line macros:
---
From: Borislav Petkov <[email protected]>
Subject: [PATCH] checkpatch: Catch trailing semicolons in macro definitions
This currently checks only single-line macro definitions. I.e.,
$ git show c0a639ad0bc6b178b46996bd1f821a04643e2bde | ./scripts/checkpatch.pl -
...
WARNING: Trailing semicolon at macro definition
+#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_BIT_LIMIT_CPUID);
--- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+)
scripts/checkpatch.pl +5 -0
@@ -3313,6 +3313,11 @@ sub process { } } + if ($line =~ /^\+\s*#\s*define\s.*;\s*$/) { + WARN("TRAILING_SEMICOLON", + "Trailing semicolon at macro definition\n" . $herecurr); + } + # check for multiple assignments if ($line =~ /^.\s*$Lval\s*=\s*$Lval\s*=(?!=)/) { CHK("MULTIPLE_ASSIGNMENTS",
Signature · 8 lines
1.9.0
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Joe Perches
maintainerRe: [PATCH 2/2] x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro
Quoted 2 lines · Borislav Petkov
Quoted 1 line · Borislav Petkov
arch/x86/include/uapi/asm/msr-index.h
Quoted 1 line
arch/x86/include/uapi/asm/msr-index.h +0
-0
[]
Quoted 5 lines
Quoted 2 lines
arch/x86/include/uapi/asm/msr-index.h
Quoted 2 lines
arch/x86/include/uapi/asm/msr-index.h +1
-1-#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT); +#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT)Btw, we should probably be catching typos like that with checkpatch. Here's an initial version for single-line macros:
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
scripts/checkpatch.pl sub process { · line 3320
Quoted 9 lines
scripts/checkpatch.pl +5
-0@@ -3313,6 +3313,11 @@ sub process { } } + if ($line =~ /^\+\s*#\s*define\s.*;\s*$/) { + WARN("TRAILING_SEMICOLON", + "Trailing semicolon at macro definition\n" . $herecurr); + } +
Seems sensible.
I suggest moving the test next to the other macro definition tests for things like unnecessary semicolon around "do {... while (0)" around line 3800.
Extending the test to find multiline forms like
#define foo \ bar;
would also be trivially done there.
Joe Perches
maintainerPATCH 1/1 checkpatch: Warn on #defines ending in semicolon
In reply to Borislav PetkovUsing a #define ending in a semicolon is poor style and can lead to unexpected code paths being executed.
Warn on uses of these #define types:
#define foo[(...)] bar; #define foo[(...)] \ bar;
--- scripts/checkpatch.pl | 11 +++++++++++ 1 file changed, 11 insertions(+)
scripts/checkpatch.pl +11 -0
@@ -3782,6 +3782,17 @@ sub process { WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON", "do {} while (0) macros should not be semicolon terminated\n" . "$herectx"); } + } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) { + $ctx =~ s/\n*$//; + my $cnt = statement_rawlines($ctx); + my $herectx = $here . "\n"; + + for (my $n = 0; $n < $cnt; $n++) { + $herectx .= raw_line($linenr, $n) . "\n"; + } + + WARN("TRAILING_SEMICOLON", + "macros should not use a trailing semicolon\n" . "$herectx"); } }
Re: [PATCH] checkpatch: Warn on #defines ending in semicolon
Quoted 1 line · Joe Perches
Using a #define ending in a semicolon is poor style
It's not poor style it's simply a bug. Just because it
Quoted 1 line
can lead to unexpected code paths being executed.
Thanks,
tglx
Joe Perches
maintainerRe: [PATCH] checkpatch: Warn on #defines ending in semicolon
Quoted 7 lines · Thomas Gleixner
Quoted 1 line · Joe Perches
Using a #define ending in a semicolon is poor style
It's not poor style it's simply a bug. Just because it
Quoted 1 line
can lead to unexpected code paths being executed.
I think it's still a (bad) style issue.
I remember a discussion with a developer that
wanted all macros to end in a semicolon so he
could write COBOL like C.
ick.
cheers, Joe
tip-bot for Andres Freund
merge bot[tip:x86/urgent] x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro
In reply to Andres Freundx86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro
Commit-ID: c45f77364ba060395b7eff1bf45e6c537f913380 Gitweb: http://git.kernel.org/tip/c45f77364ba060395b7eff1bf45e6c537f913380 Author: Andres Freund <[email protected]> AuthorDate: Fri, 9 May 2014 03:29:17 +0200 Committer: H. Peter Anvin <[email protected]> CommitDate: Fri, 9 May 2014 08:42:47 -0700
x86: Fix typo in MSR_IA32_MISC_ENABLE_LIMIT_CPUID macro
The spuriously added semicolon didn't have any effect because the macro isn't currently in use.
c0a639ad0bc6b178b46996bd1f821a04643e2bde
--- arch/x86/include/uapi/asm/msr-index.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/uapi/asm/msr-index.h +1 -1
@@ -384,7 +384,7 @@#define MSR_IA32_MISC_ENABLE_MWAIT_BIT 18#define MSR_IA32_MISC_ENABLE_MWAIT (1ULL << MSR_IA32_MISC_ENABLE_MWAIT_BIT)#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT 22 -#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT); +#define MSR_IA32_MISC_ENABLE_LIMIT_CPUID (1ULL << MSR_IA32_MISC_ENABLE_LIMIT_CPUID_BIT)#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT 23#define MSR_IA32_MISC_ENABLE_XTPR_DISABLE (1ULL << MSR_IA32_MISC_ENABLE_XTPR_DISABLE_BIT)#define MSR_IA32_MISC_ENABLE_XD_DISABLE_BIT 34