Commit 6a9feaa8 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Borislav Petkov

x86/mm/kmmio: Use this_cpu_ptr() instead get_cpu_var() for kmmio_ctx

Both call sites that access kmmio_ctx, access kmmio_ctx with interrupts
disabled. There is no need to use get_cpu_var() which additionally
disables preemption.

Use this_cpu_ptr() to access the kmmio_ctx variable of the current CPU.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200205143426.2592512-1-bigeasy@linutronix.de
parent 681ff018
...@@ -260,7 +260,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) ...@@ -260,7 +260,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
goto no_kmmio; goto no_kmmio;
} }
ctx = &get_cpu_var(kmmio_ctx); ctx = this_cpu_ptr(&kmmio_ctx);
if (ctx->active) { if (ctx->active) {
if (page_base == ctx->addr) { if (page_base == ctx->addr) {
/* /*
...@@ -285,7 +285,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) ...@@ -285,7 +285,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
pr_emerg("previous hit was at 0x%08lx.\n", ctx->addr); pr_emerg("previous hit was at 0x%08lx.\n", ctx->addr);
disarm_kmmio_fault_page(faultpage); disarm_kmmio_fault_page(faultpage);
} }
goto no_kmmio_ctx; goto no_kmmio;
} }
ctx->active++; ctx->active++;
...@@ -314,11 +314,8 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) ...@@ -314,11 +314,8 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
* the user should drop to single cpu before tracing. * the user should drop to single cpu before tracing.
*/ */
put_cpu_var(kmmio_ctx);
return 1; /* fault handled */ return 1; /* fault handled */
no_kmmio_ctx:
put_cpu_var(kmmio_ctx);
no_kmmio: no_kmmio:
rcu_read_unlock(); rcu_read_unlock();
preempt_enable_no_resched(); preempt_enable_no_resched();
...@@ -333,7 +330,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr) ...@@ -333,7 +330,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs) static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs)
{ {
int ret = 0; int ret = 0;
struct kmmio_context *ctx = &get_cpu_var(kmmio_ctx); struct kmmio_context *ctx = this_cpu_ptr(&kmmio_ctx);
if (!ctx->active) { if (!ctx->active) {
/* /*
...@@ -371,7 +368,6 @@ static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs) ...@@ -371,7 +368,6 @@ static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs)
if (!(regs->flags & X86_EFLAGS_TF)) if (!(regs->flags & X86_EFLAGS_TF))
ret = 1; ret = 1;
out: out:
put_cpu_var(kmmio_ctx);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment