diff options
| author | Borislav Petkov <bp@suse.de> | 2016-03-07 05:10:03 -0500 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2016-03-08 03:08:45 -0500 |
| commit | 5b46b5e003724547f0c83041cada15f9f496590d (patch) | |
| tree | 9847b23e0ba52a5f3dbe54db5928e4c94503aac0 /arch/x86/kernel/cpu/microcode | |
| parent | 7d0161569a3b66aaa01520002c3e5fd7126d071f (diff) | |
x86/microcode/intel: Improve microcode sanity-checking error messages
Turn them into proper sentences. Add comments to microcode_sanity_check() to
explain what it does.
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: http://lkml.kernel.org/r/1457345404-28884-5-git-send-email-bp@alien8.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/cpu/microcode')
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/intel_lib.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/arch/x86/kernel/cpu/microcode/intel_lib.c b/arch/x86/kernel/cpu/microcode/intel_lib.c index ffb1bbf45db0..23b1d92342e3 100644 --- a/arch/x86/kernel/cpu/microcode/intel_lib.c +++ b/arch/x86/kernel/cpu/microcode/intel_lib.c | |||
| @@ -57,15 +57,16 @@ int microcode_sanity_check(void *mc, int print_err) | |||
| 57 | 57 | ||
| 58 | if (data_size + MC_HEADER_SIZE > total_size) { | 58 | if (data_size + MC_HEADER_SIZE > total_size) { |
| 59 | if (print_err) | 59 | if (print_err) |
| 60 | pr_err("error! Bad data size in microcode data file\n"); | 60 | pr_err("Error: bad microcode data file size.\n"); |
| 61 | return -EINVAL; | 61 | return -EINVAL; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | if (mc_header->ldrver != 1 || mc_header->hdrver != 1) { | 64 | if (mc_header->ldrver != 1 || mc_header->hdrver != 1) { |
| 65 | if (print_err) | 65 | if (print_err) |
| 66 | pr_err("error! Unknown microcode update format\n"); | 66 | pr_err("Error: invalid/unknown microcode update format.\n"); |
| 67 | return -EINVAL; | 67 | return -EINVAL; |
| 68 | } | 68 | } |
| 69 | |||
| 69 | ext_table_size = total_size - (MC_HEADER_SIZE + data_size); | 70 | ext_table_size = total_size - (MC_HEADER_SIZE + data_size); |
| 70 | if (ext_table_size) { | 71 | if (ext_table_size) { |
| 71 | u32 ext_table_sum = 0; | 72 | u32 ext_table_sum = 0; |
| @@ -74,43 +75,58 @@ int microcode_sanity_check(void *mc, int print_err) | |||
| 74 | if ((ext_table_size < EXT_HEADER_SIZE) | 75 | if ((ext_table_size < EXT_HEADER_SIZE) |
| 75 | || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) { | 76 | || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) { |
| 76 | if (print_err) | 77 | if (print_err) |
| 77 | pr_err("error! Small exttable size in microcode data file\n"); | 78 | pr_err("Error: truncated extended signature table.\n"); |
| 78 | return -EINVAL; | 79 | return -EINVAL; |
| 79 | } | 80 | } |
| 81 | |||
| 80 | ext_header = mc + MC_HEADER_SIZE + data_size; | 82 | ext_header = mc + MC_HEADER_SIZE + data_size; |
| 81 | if (ext_table_size != exttable_size(ext_header)) { | 83 | if (ext_table_size != exttable_size(ext_header)) { |
| 82 | if (print_err) | 84 | if (print_err) |
| 83 | pr_err("error! Bad exttable size in microcode data file\n"); | 85 | pr_err("Error: extended signature table size mismatch.\n"); |
| 84 | return -EFAULT; | 86 | return -EFAULT; |
| 85 | } | 87 | } |
| 88 | |||
| 86 | ext_sigcount = ext_header->count; | 89 | ext_sigcount = ext_header->count; |
| 87 | 90 | ||
| 88 | /* check extended table checksum */ | 91 | /* |
| 92 | * Check extended table checksum: the sum of all dwords that | ||
| 93 | * comprise a valid table must be 0. | ||
| 94 | */ | ||
| 89 | ext_tablep = (u32 *)ext_header; | 95 | ext_tablep = (u32 *)ext_header; |
| 90 | 96 | ||
| 91 | i = ext_table_size / sizeof(u32); | 97 | i = ext_table_size / sizeof(u32); |
| 92 | while (i--) | 98 | while (i--) |
| 93 | ext_table_sum += ext_tablep[i]; | 99 | ext_table_sum += ext_tablep[i]; |
| 100 | |||
| 94 | if (ext_table_sum) { | 101 | if (ext_table_sum) { |
| 95 | if (print_err) | 102 | if (print_err) |
| 96 | pr_warn("aborting, bad extended signature table checksum\n"); | 103 | pr_warn("Bad extended signature table checksum, aborting.\n"); |
| 97 | return -EINVAL; | 104 | return -EINVAL; |
| 98 | } | 105 | } |
| 99 | } | 106 | } |
| 100 | 107 | ||
| 101 | /* calculate the checksum */ | 108 | /* |
| 109 | * Calculate the checksum of update data and header. The checksum of | ||
| 110 | * valid update data and header including the extended signature table | ||
| 111 | * must be 0. | ||
| 112 | */ | ||
| 102 | orig_sum = 0; | 113 | orig_sum = 0; |
| 103 | i = (MC_HEADER_SIZE + data_size) / sizeof(u32); | 114 | i = (MC_HEADER_SIZE + data_size) / sizeof(u32); |
| 104 | while (i--) | 115 | while (i--) |
| 105 | orig_sum += ((u32 *)mc)[i]; | 116 | orig_sum += ((u32 *)mc)[i]; |
| 117 | |||
| 106 | if (orig_sum) { | 118 | if (orig_sum) { |
| 107 | if (print_err) | 119 | if (print_err) |
| 108 | pr_err("aborting, bad checksum\n"); | 120 | pr_err("Bad microcode data checksum, aborting.\n"); |
| 109 | return -EINVAL; | 121 | return -EINVAL; |
| 110 | } | 122 | } |
| 123 | |||
| 111 | if (!ext_table_size) | 124 | if (!ext_table_size) |
| 112 | return 0; | 125 | return 0; |
| 113 | /* check extended signature checksum */ | 126 | |
| 127 | /* | ||
| 128 | * Check extended signature checksum: 0 => valid. | ||
| 129 | */ | ||
| 114 | for (i = 0; i < ext_sigcount; i++) { | 130 | for (i = 0; i < ext_sigcount; i++) { |
| 115 | ext_sig = (void *)ext_header + EXT_HEADER_SIZE + | 131 | ext_sig = (void *)ext_header + EXT_HEADER_SIZE + |
| 116 | EXT_SIGNATURE_SIZE * i; | 132 | EXT_SIGNATURE_SIZE * i; |
| @@ -119,7 +135,7 @@ int microcode_sanity_check(void *mc, int print_err) | |||
| 119 | + (ext_sig->sig + ext_sig->pf + ext_sig->cksum); | 135 | + (ext_sig->sig + ext_sig->pf + ext_sig->cksum); |
| 120 | if (sum) { | 136 | if (sum) { |
| 121 | if (print_err) | 137 | if (print_err) |
| 122 | pr_err("aborting, bad checksum\n"); | 138 | pr_err("Bad extended signature checksum, aborting.\n"); |
| 123 | return -EINVAL; | 139 | return -EINVAL; |
| 124 | } | 140 | } |
| 125 | } | 141 | } |
