x86, microcode: Do Intel microcode revision check signed v2
PATCH 1/2 x86, microcode: Do Intel microcode revision check signed v2
From: Andi Kleen <[email protected]>
The Intel SDM Vol 3 9.11.1 Microcode update states that the update revision field is signed. However we do the comparison unsigned, as the comparison gets promoted. Change the field to be signed, so that comparision is really signed.
v2: Change field.
Signed-off-by Andi Kleen <[email protected]>
--- arch/x86/include/asm/microcode_intel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/microcode_intel.h +1 -1
@@ -5,7 +5,7 @@struct microcode_header_intel {unsigned int hdrver; -unsigned int rev; +int rev;unsigned int date;unsigned int sig;unsigned int cksum;
Signature · 1 line
1.8.3.1
PATCH 2/2 x86, microcode: Add option to allow downgrading of microcode
From: Andi Kleen <[email protected]>
For testing purposes it can be useful to downgrade microcode. Normally the driver only allows upgrading.
Add a module_param (default off) that allows downgrading.
Note the module_param can currently not be set for early ucode update, only for late.
Signed-off-by Andi Kleen <[email protected]>
--- arch/x86/kernel/microcode_intel_lib.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/microcode_intel_lib.c +7 -0
@@ -26,11 +26,16 @@#include <linux/uaccess.h> #include <linux/kernel.h> #include <linux/module.h> +#include <linux/moduleparam.h> #include <asm/microcode_intel.h> #include <asm/processor.h> #include <asm/msr.h> +static bool allow_downgrade; +module_param (allow_downgrade, bool,0644 ); +MODULE_PARM_DESC (allow_downgrade,"Allow downgrading microcode" ); +static inline int update_match_cpu (unsigned int csig,unsigned int cpf,unsigned int sig,unsigned int pf)
@@ -41,6 +46,8 @@ update_match_cpu(unsigned int csig, unsigned int cpf,int update_match_revision (struct microcode_header_intel *mc_header,int rev) { +if (allow_downgrade) +return 1 ;return (mc_header->rev <= rev) ?0 :1 ; }
Signature · 1 line
1.8.3.1