x86/traps: Have read_cr0() only once in the #NM handler
Borislav Petkov
maintainerPATCH 1/1 x86/traps: Have read_cr0() only once in the #NM handler
From: Borislav Petkov <[email protected]>
... instead of twice in the code. In any case, CR0 ends up being read once anyway:
1. The CONFIG_MATH_EMULATION case does so and exits.
2. The normal case does it once too.
However, read it on function entry instead to make the code even simpler to follow.
No functional changes.
--- arch/x86/kernel/traps.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/traps.c +2 -3
@@ -880,12 +880,12 @@ do_spurious_interrupt_bug(struct pt_regs *regs, long error_code) dotraplinkage voiddo_device_not_available (struct pt_regs *regs,long error_code) { -unsigned long cr0; +unsigned long cr0 =read_cr0 ();RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" );#ifdef CONFIG_MATH_EMULATION -if (!boot_cpu_has (X86_FEATURE_FPU ) && (read_cr0 () &X86_CR0_EM )) { +if (!boot_cpu_has (X86_FEATURE_FPU ) && (cr0 &X86_CR0_EM )) {struct math_emu_info info = { };cond_local_irq_enable (regs);
@@ -897,7 +897,6 @@ do_device_not_available(struct pt_regs *regs, long error_code)#endif /* This should not happen. */ - cr0 =read_cr0 ();if (WARN (cr0 &X86_CR0_TS ,"CR0.TS was set" )) {/* Try to fix it up and carry on. */ write_cr0 (cr0 & ~X86_CR0_TS );
Signature · 1 line
2.19.1
Quoted 10 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
... instead of twice in the code. In any case, CR0 ends up being read once anyway:
1. The
CONFIG_MATH_EMULATIONcase does so and exits.
2. The normal case does it once too.However, read it on function entry instead to make the code even simpler to follow.
makes sense.
Sebastian
Quoted 9 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
... instead of twice in the code. In any case, CR0 ends up being read once anyway:
1. The
CONFIG_MATH_EMULATIONcase does so and exits.
2. The normal case does it once too.
tip-bot for Borislav Petkov
merge botx86/traps: Have read_cr0() only once in the #NM handler
Commit-ID: ee35b9b9f6d52ba134b4e75442531935f295be7a Gitweb: https://git.kernel.org/tip/ee35b9b9f6d52ba134b4e75442531935f295be7a Author: Borislav Petkov <[email protected]> AuthorDate: Thu, 17 Jan 2019 13:02:05 +0100 Committer: Borislav Petkov <[email protected]> CommitDate: Tue, 22 Jan 2019 14:13:35 +0100
x86/traps: Have read_cr0() only once in the #NM handler
... instead of twice in the code. In any case, CR0 ends up being read once anyway:
1. The CONFIG_MATH_EMULATION case does so and exits.
2. The normal case does it once too.
However, read it on function entry instead to make the code even simpler to follow.
No functional changes.
--- arch/x86/kernel/traps.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/kernel/traps.c +2 -3
@@ -880,12 +880,12 @@ do_spurious_interrupt_bug(struct pt_regs *regs, long error_code) dotraplinkage voiddo_device_not_available (struct pt_regs *regs,long error_code) { -unsigned long cr0; +unsigned long cr0 =read_cr0 ();RCU_LOCKDEP_WARN (!rcu_is_watching (),"entry code didn't wake RCU" );#ifdef CONFIG_MATH_EMULATION -if (!boot_cpu_has (X86_FEATURE_FPU ) && (read_cr0 () &X86_CR0_EM )) { +if (!boot_cpu_has (X86_FEATURE_FPU ) && (cr0 &X86_CR0_EM )) {struct math_emu_info info = { };cond_local_irq_enable (regs);
@@ -897,7 +897,6 @@ do_device_not_available(struct pt_regs *regs, long error_code)#endif /* This should not happen. */ - cr0 =read_cr0 ();if (WARN (cr0 &X86_CR0_TS ,"CR0.TS was set" )) {/* Try to fix it up and carry on. */ write_cr0 (cr0 & ~X86_CR0_TS );