|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/traps: Make an IDT-specific #PF helper
commit 4153eb7660ad441de75ab6dca50b54eb340d0728
Author: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Mon Aug 11 12:42:01 2025 +0100
Commit: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Dec 5 23:00:32 2025 +0000
x86/traps: Make an IDT-specific #PF helper
FRED provides %cr2 in the the stack frame, avoiding the need to read %cr2
manually.
Rename do_page_fault() to handle_PF(), and update it to take cr2, still
named
addr for consistency.
Introduce a new handle_PF_IDT() which reads %cr2 and conditionally
re-enables
interrupts.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/x86/traps.c | 26 ++++++++++++++------------
xen/arch/x86/x86_64/entry.S | 2 +-
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 3f1eae0d40..6ba7ae5202 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -1676,21 +1676,10 @@ static int fixup_page_fault(unsigned long addr, struct
cpu_user_regs *regs)
return 0;
}
-void asmlinkage do_page_fault(struct cpu_user_regs *regs)
+static void handle_PF(struct cpu_user_regs *regs, unsigned long addr /* cr2 */)
{
- unsigned long addr;
unsigned int error_code;
- addr = read_cr2();
-
- /*
- * Don't re-enable interrupts if we were running an IRQ-off region when
- * we hit the page fault, or we'll break that code.
- */
- ASSERT(!local_irq_is_enabled());
- if ( regs->flags & X86_EFLAGS_IF )
- local_irq_enable();
-
/* fixup_page_fault() might change regs->error_code, so cache it here. */
error_code = regs->error_code;
@@ -1751,6 +1740,19 @@ void asmlinkage do_page_fault(struct cpu_user_regs *regs)
pv_inject_page_fault(regs->error_code, addr);
}
+/*
+ * When using IDT delivery, it is our responsibility to read %cr2.
+ */
+void asmlinkage handle_PF_IDT(struct cpu_user_regs *regs)
+{
+ unsigned long addr = read_cr2();
+
+ if ( regs->flags & X86_EFLAGS_IF )
+ local_irq_enable();
+
+ handle_PF(regs, addr);
+}
+
/*
* Early #PF handler to print CR2, error code, and stack.
*
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 789687488c..c02245ac06 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -871,7 +871,7 @@ handle_exception_saved:
* reading %cr2. Otherwise a page fault in the nested interrupt handler
* would corrupt %cr2.
*/
- DISPATCH(X86_EXC_PF, do_page_fault)
+ DISPATCH(X86_EXC_PF, handle_PF_IDT)
/* Only re-enable IRQs if they were active before taking the fault */
testb $X86_EFLAGS_IF >> 8, UREGS_eflags + 1(%rsp)
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |