Messages in this thread Patch in this message | | | From | Lai Jiangshan <> | Subject | [PATCH 4/4] x86/nmi: Convert nmi_cr2/nmi_dr7 to be func-local variable | Date | Mon, 13 Dec 2021 23:03:40 +0800 |
| |
From: Lai Jiangshan <laijs@linux.alibaba.com>
nmi_cr2 and nmi_dr7 are used inside a function (the outmost exc_nmi()), they don't need to be percpu data.
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com> --- arch/x86/kernel/nmi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c index 44c3adb68282..673eee5831db 100644 --- a/arch/x86/kernel/nmi.c +++ b/arch/x86/kernel/nmi.c @@ -470,12 +470,12 @@ enum nmi_states { NMI_LATCHED, }; static DEFINE_PER_CPU(enum nmi_states, nmi_state); -static DEFINE_PER_CPU(unsigned long, nmi_cr2); -static DEFINE_PER_CPU(unsigned long, nmi_dr7); DEFINE_IDTENTRY_NMI(exc_nmi) { irqentry_state_t irq_state; + unsigned long nmi_cr2; + unsigned long nmi_dr7; /* * Re-enable NMIs right here when running as an SEV-ES guest. This might @@ -491,7 +491,7 @@ DEFINE_IDTENTRY_NMI(exc_nmi) return; } this_cpu_write(nmi_state, NMI_EXECUTING); - this_cpu_write(nmi_cr2, read_cr2()); + nmi_cr2 = read_cr2(); nmi_restart: /* @@ -500,7 +500,7 @@ DEFINE_IDTENTRY_NMI(exc_nmi) */ sev_es_ist_enter(regs); - this_cpu_write(nmi_dr7, local_db_save()); + nmi_dr7 = local_db_save(); irq_state = irqentry_nmi_enter(regs); @@ -511,12 +511,12 @@ DEFINE_IDTENTRY_NMI(exc_nmi) irqentry_nmi_exit(regs, irq_state); - local_db_restore(this_cpu_read(nmi_dr7)); + local_db_restore(nmi_dr7); sev_es_ist_exit(); - if (unlikely(this_cpu_read(nmi_cr2) != read_cr2())) - write_cr2(this_cpu_read(nmi_cr2)); + if (unlikely(nmi_cr2 != read_cr2())) + write_cr2(nmi_cr2); if (this_cpu_dec_return(nmi_state)) goto nmi_restart; -- 2.19.1.6.gb485710b
| |