lkml.org 
[lkml]   [2022]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH V10 19/44] entry: Add calls for save/restore auxiliary pt_regs
Date
From: Ira Weiny <ira.weiny@intel.com>

Some architectures have auxiliary pt_regs space which is available to
store extra information on the stack. For ease of implementation the
common C code was left to fill in the data when needed.

Add calls to the architecture save and restore auxiliary pt_regs
functions. Define empty calls for any architecture which does not have
auxiliary pt_regs.

NOTE: Due to the split nature of the Xen exit code
irqentry_exit_cond_resched() requires an unbalanced call to
arch_restore_aux_pt_regs().

Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Changes for V9
Update commit message

Changes for V8
New patch which introduces a generic auxiliary pt_register save
restore.
---
include/linux/entry-common.h | 7 +++++++
kernel/entry/common.c | 16 ++++++++++++++--
2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index f35086d2a258..15b35ca937f2 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -79,6 +79,13 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs);
static __always_inline void arch_check_user_regs(struct pt_regs *regs) {}
#endif

+#ifndef CONFIG_ARCH_HAS_PTREGS_AUXILIARY
+
+static inline void arch_save_aux_pt_regs(struct pt_regs *regs) { }
+static inline void arch_restore_aux_pt_regs(struct pt_regs *regs) { }
+
+#endif
+
/**
* enter_from_user_mode - Establish state when coming from user mode
*
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 8f73b54bfa56..9a02b517c7e7 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -317,7 +317,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)

if (user_mode(regs)) {
irqentry_enter_from_user_mode(regs);
- return ret;
+ goto aux_save;
}

/*
@@ -356,7 +356,7 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
instrumentation_end();

ret.exit_rcu = true;
- return ret;
+ goto aux_save;
}

/*
@@ -371,6 +371,11 @@ noinstr irqentry_state_t irqentry_enter(struct pt_regs *regs)
trace_hardirqs_off_finish();
instrumentation_end();

+aux_save:
+ instrumentation_begin();
+ arch_save_aux_pt_regs(regs);
+ instrumentation_end();
+
return ret;
}

@@ -401,6 +406,7 @@ void dynamic_irqentry_exit_cond_resched(void)

void irqentry_exit_cond_resched(struct pt_regs *regs)
{
+ arch_restore_aux_pt_regs(regs);
irqentry_exit_cond_resched_internal();
}

@@ -408,6 +414,10 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
{
lockdep_assert_irqs_disabled();

+ instrumentation_begin();
+ arch_restore_aux_pt_regs(regs);
+ instrumentation_end();
+
/* Check whether this returns to user mode */
if (user_mode(regs)) {
irqentry_exit_to_user_mode(regs);
@@ -459,6 +469,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs)
instrumentation_begin();
trace_hardirqs_off_finish();
ftrace_nmi_enter();
+ arch_save_aux_pt_regs(regs);
instrumentation_end();

return irq_state;
@@ -467,6 +478,7 @@ irqentry_state_t noinstr irqentry_nmi_enter(struct pt_regs *regs)
void noinstr irqentry_nmi_exit(struct pt_regs *regs, irqentry_state_t irq_state)
{
instrumentation_begin();
+ arch_restore_aux_pt_regs(regs);
ftrace_nmi_exit();
if (irq_state.lockdep) {
trace_hardirqs_on_prepare();
--
2.35.1
\
 
 \ /
  Last update: 2022-04-19 19:11    [W:0.237 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site