Skip to content

Commit 6a9feaa

Browse files
Sebastian Andrzej Siewiorsuryasaimadhu
authored andcommitted
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: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 681ff01 commit 6a9feaa

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

arch/x86/mm/kmmio.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
260260
goto no_kmmio;
261261
}
262262

263-
ctx = &get_cpu_var(kmmio_ctx);
263+
ctx = this_cpu_ptr(&kmmio_ctx);
264264
if (ctx->active) {
265265
if (page_base == ctx->addr) {
266266
/*
@@ -285,7 +285,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
285285
pr_emerg("previous hit was at 0x%08lx.\n", ctx->addr);
286286
disarm_kmmio_fault_page(faultpage);
287287
}
288-
goto no_kmmio_ctx;
288+
goto no_kmmio;
289289
}
290290
ctx->active++;
291291

@@ -314,11 +314,8 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
314314
* the user should drop to single cpu before tracing.
315315
*/
316316

317-
put_cpu_var(kmmio_ctx);
318317
return 1; /* fault handled */
319318

320-
no_kmmio_ctx:
321-
put_cpu_var(kmmio_ctx);
322319
no_kmmio:
323320
rcu_read_unlock();
324321
preempt_enable_no_resched();
@@ -333,7 +330,7 @@ int kmmio_handler(struct pt_regs *regs, unsigned long addr)
333330
static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs)
334331
{
335332
int ret = 0;
336-
struct kmmio_context *ctx = &get_cpu_var(kmmio_ctx);
333+
struct kmmio_context *ctx = this_cpu_ptr(&kmmio_ctx);
337334

338335
if (!ctx->active) {
339336
/*
@@ -371,7 +368,6 @@ static int post_kmmio_handler(unsigned long condition, struct pt_regs *regs)
371368
if (!(regs->flags & X86_EFLAGS_TF))
372369
ret = 1;
373370
out:
374-
put_cpu_var(kmmio_ctx);
375371
return ret;
376372
}
377373

0 commit comments

Comments
 (0)