[PATCH V8 22/44] entry: Pass pt_regs to irqentry_exit_cond_resched()

ira.weiny
2022-01-27T17:56:01Z

From: Ira Weiny <ira.weiny@intel.com>

Auxiliary pt_regs space needs to be manipulated by the generic
entry/exit code.

Unfortunately, the call to irqentry_exit_cond_resched() from
xen_pv_evtchn_do_upcall() bypasses the 'normal' irqentry_exit() call.

Normally the irqentry_exit() would take care of handling any auxiliary
pt_regs but because of this bypass irqentry_exit_cond_resched() is
required to handle it.

Add pt_regs to irqentry_exit_cond_resched() so that any auxiliary
pt_regs data can be handled.

Create an internal exit_cond_resched() call for irqentry_exit() to avoid
passing pt_regs because irqentry_exit() will directly handle any
auxiliary pt_regs data.

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

---
Changes for V8
New Patch
---
arch/x86/entry/common.c | 2 +-
include/linux/entry-common.h | 3 ++-
kernel/entry/common.c | 9 +++++++--
3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 6c2826417b33..f1ba770d035d 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -309,7 +309,7 @@ __visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs)

inhcall = get_and_clear_inhcall();
if (inhcall && !WARN_ON_ONCE(state.exit_rcu)) {
- irqentry_exit_cond_resched();
+ irqentry_exit_cond_resched(regs);
instrumentation_end();
restore_inhcall(inhcall);
} else {
diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index ddaffc983e62..14fd329847e7 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -451,10 +451,11 @@ irqentry_state_t noinstr irqentry_enter(struct pt_regs *regs);

/**
* irqentry_exit_cond_resched - Conditionally reschedule on return from interrupt
+ * @regs: Pointer to pt_regs of interrupted context
*
* Conditional reschedule with additional sanity checks.
*/
-void irqentry_exit_cond_resched(void);
+void irqentry_exit_cond_resched(struct pt_regs *regs);

void __irqentry_exit_cond_resched(void);
#ifdef CONFIG_PREEMPT_DYNAMIC
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 490442a48332..f4210a7fc84d 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -395,7 +395,7 @@ void __irqentry_exit_cond_resched(void)
DEFINE_STATIC_CALL(__irqentry_exit_cond_resched, __irqentry_exit_cond_resched);
#endif

-void irqentry_exit_cond_resched(void)
+static void exit_cond_resched(void)
{
if (IS_ENABLED(CONFIG_PREEMPTION)) {
#ifdef CONFIG_PREEMPT_DYNAMIC
@@ -406,6 +406,11 @@ void irqentry_exit_cond_resched(void)
}
}

+void irqentry_exit_cond_resched(struct pt_regs *regs)
+{
+ exit_cond_resched();
+}
+
noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
{
lockdep_assert_irqs_disabled();
@@ -431,7 +436,7 @@ noinstr void irqentry_exit(struct pt_regs *regs, irqentry_state_t state)
}

instrumentation_begin();
- irqentry_exit_cond_resched();
+ exit_cond_resched();
/* Covers both tracing and lockdep */
trace_hardirqs_on();
instrumentation_end();
--
2.31.1