diff options
| author | Borislav Petkov <bp@suse.de> | 2015-05-17 06:54:59 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2015-05-18 03:32:36 -0400 |
| commit | 6b2d469f5b5dd1d39548f2e79557b9b5ffe00eb1 (patch) | |
| tree | ea08f5ad1edb340b411f9dc3a54448fd1076169d | |
| parent | 8de3eafc161022dd094fa009346509c712e9c4b0 (diff) | |
x86/microcode/intel: Simplify update_match_cpu()
Drop unreadable macro, deconstruct compound conditional
statement into single ones and return early if they match. Add
comments.
There should be no functionality change resulting from this
patch.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1431860101-14847-3-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | arch/x86/include/asm/microcode_intel.h | 3 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/intel_lib.c | 19 |
2 files changed, 13 insertions, 9 deletions
diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h index 8e87e6fe98b5..45a318f677be 100644 --- a/arch/x86/include/asm/microcode_intel.h +++ b/arch/x86/include/asm/microcode_intel.h | |||
| @@ -51,9 +51,6 @@ struct extended_sigtable { | |||
| 51 | (((struct microcode_intel *)mc)->hdr.datasize ? \ | 51 | (((struct microcode_intel *)mc)->hdr.datasize ? \ |
| 52 | ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE) | 52 | ((struct microcode_intel *)mc)->hdr.datasize : DEFAULT_UCODE_DATASIZE) |
| 53 | 53 | ||
| 54 | #define sigmatch(s1, s2, p1, p2) \ | ||
| 55 | (((s1) == (s2)) && (((p1) & (p2)) || (((p1) == 0) && ((p2) == 0)))) | ||
| 56 | |||
| 57 | #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) | 54 | #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) |
| 58 | 55 | ||
| 59 | extern int has_newer_microcode(void *mc, unsigned int csig, int cpf, int rev); | 56 | extern int has_newer_microcode(void *mc, unsigned int csig, int cpf, int rev); |
diff --git a/arch/x86/kernel/cpu/microcode/intel_lib.c b/arch/x86/kernel/cpu/microcode/intel_lib.c index 425f8e29b795..1ffe507931af 100644 --- a/arch/x86/kernel/cpu/microcode/intel_lib.c +++ b/arch/x86/kernel/cpu/microcode/intel_lib.c | |||
| @@ -31,11 +31,18 @@ | |||
| 31 | #include <asm/processor.h> | 31 | #include <asm/processor.h> |
| 32 | #include <asm/msr.h> | 32 | #include <asm/msr.h> |
| 33 | 33 | ||
| 34 | static inline int | 34 | static inline bool cpu_signatures_match(unsigned int s1, unsigned int p1, |
| 35 | update_match_cpu(unsigned int csig, unsigned int cpf, | 35 | unsigned int s2, unsigned int p2) |
| 36 | unsigned int sig, unsigned int pf) | ||
| 37 | { | 36 | { |
| 38 | return (!sigmatch(sig, csig, pf, cpf)) ? 0 : 1; | 37 | if (s1 != s2) |
| 38 | return false; | ||
| 39 | |||
| 40 | /* Processor flags are either both 0 ... */ | ||
| 41 | if (!p1 && !p2) | ||
| 42 | return true; | ||
| 43 | |||
| 44 | /* ... or they intersect. */ | ||
| 45 | return p1 & p2; | ||
| 39 | } | 46 | } |
| 40 | 47 | ||
| 41 | int microcode_sanity_check(void *mc, int print_err) | 48 | int microcode_sanity_check(void *mc, int print_err) |
| @@ -132,7 +139,7 @@ int get_matching_sig(unsigned int csig, int cpf, void *mc) | |||
| 132 | int ext_sigcount, i; | 139 | int ext_sigcount, i; |
| 133 | struct extended_signature *ext_sig; | 140 | struct extended_signature *ext_sig; |
| 134 | 141 | ||
| 135 | if (update_match_cpu(csig, cpf, mc_header->sig, mc_header->pf)) | 142 | if (cpu_signatures_match(csig, cpf, mc_header->sig, mc_header->pf)) |
| 136 | return 1; | 143 | return 1; |
| 137 | 144 | ||
| 138 | /* Look for ext. headers: */ | 145 | /* Look for ext. headers: */ |
| @@ -144,7 +151,7 @@ int get_matching_sig(unsigned int csig, int cpf, void *mc) | |||
| 144 | ext_sig = (void *)ext_header + EXT_HEADER_SIZE; | 151 | ext_sig = (void *)ext_header + EXT_HEADER_SIZE; |
| 145 | 152 | ||
| 146 | for (i = 0; i < ext_sigcount; i++) { | 153 | for (i = 0; i < ext_sigcount; i++) { |
| 147 | if (update_match_cpu(csig, cpf, ext_sig->sig, ext_sig->pf)) | 154 | if (cpu_signatures_match(csig, cpf, ext_sig->sig, ext_sig->pf)) |
| 148 | return 1; | 155 | return 1; |
| 149 | ext_sig++; | 156 | ext_sig++; |
| 150 | } | 157 | } |
