Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F159964051
D55250.id173798.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D55250.id173798.diff
View Options
diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c
--- a/sys/arm64/arm64/trap.c
+++ b/sys/arm64/arm64/trap.c
@@ -193,17 +193,19 @@
addr == &generic_bs_poke_8f);
}
-static void
+static bool
svc_handler(struct thread *td, struct trapframe *frame)
{
if ((frame->tf_esr & ESR_ELx_ISS_MASK) == 0) {
syscallenter(td);
syscallret(td);
+ /* Skip userret as syscallret already called it */
+ return (true);
} else {
call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr,
ESR_ELx_EXCEPTION(frame->tf_esr));
- userret(td, frame);
+ return (false);
}
}
@@ -220,7 +222,6 @@
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr,
ESR_ELx_EXCEPTION(frame->tf_esr));
- userret(td, frame);
}
@@ -231,7 +232,6 @@
if (lower) {
call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)far,
ESR_ELx_EXCEPTION(frame->tf_esr));
- userret(td, frame);
return;
}
@@ -416,9 +416,6 @@
frame->tf_elr, error);
}
}
-
- if (lower)
- userret(td, frame);
}
static void
@@ -672,6 +669,7 @@
uint32_t exception;
uint64_t esr, far;
int dfsc;
+ bool skip_userret;
/* Check we have a sane environment when entering from userland */
KASSERT((uintptr_t)get_pcpu() >= VM_MIN_KERNEL_ADDRESS,
@@ -699,6 +697,7 @@
CTR4(KTR_TRAP, "%s: exception=%lu, elr=0x%lx, esr=0x%lx",
__func__, exception, frame->tf_elr, esr);
+ skip_userret = false;
switch (exception) {
case EXCP_FP_SIMD:
#ifdef VFP
@@ -710,7 +709,6 @@
case EXCP_TRAP_FP:
#ifdef VFP
fpe_trap(td, (void *)frame->tf_elr, esr);
- userret(td, frame);
#else
panic("VFP exception in userland");
#endif
@@ -720,11 +718,10 @@
if (!sve_restore_state(td))
call_trapsignal(td, SIGILL, ILL_ILLTRP,
(void *)frame->tf_elr, exception);
- userret(td, frame);
break;
case EXCP_SVC32:
case EXCP_SVC64:
- svc_handler(td, frame);
+ skip_userret = svc_handler(td, frame);
break;
case EXCP_INSN_ABORT_L:
case EXCP_DATA_ABORT_L:
@@ -746,22 +743,18 @@
if (!undef_insn(frame))
call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)far,
exception);
- userret(td, frame);
break;
case EXCP_FPAC:
call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr,
exception);
- userret(td, frame);
break;
case EXCP_SP_ALIGN:
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_sp,
exception);
- userret(td, frame);
break;
case EXCP_PC_ALIGN:
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr,
exception);
- userret(td, frame);
break;
case EXCP_BRKPT_EL0:
case EXCP_BRK:
@@ -770,12 +763,10 @@
#endif /* COMPAT_FREEBSD32 */
call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_elr,
exception);
- userret(td, frame);
break;
case EXCP_WATCHPT_EL0:
call_trapsignal(td, SIGTRAP, TRAP_TRACE, (void *)far,
exception);
- userret(td, frame);
break;
case EXCP_MSR:
/*
@@ -786,7 +777,6 @@
if (!undef_insn(frame))
call_trapsignal(td, SIGILL, ILL_PRVOPC,
(void *)frame->tf_elr, exception);
- userret(td, frame);
break;
case EXCP_SOFTSTP_EL0:
PROC_LOCK(td->td_proc);
@@ -799,12 +789,10 @@
PROC_UNLOCK(td->td_proc);
call_trapsignal(td, SIGTRAP, TRAP_TRACE,
(void *)frame->tf_elr, exception);
- userret(td, frame);
break;
case EXCP_BTI:
call_trapsignal(td, SIGILL, ILL_ILLOPC, (void *)frame->tf_elr,
exception);
- userret(td, frame);
break;
case EXCP_MOE:
handle_moe(td, frame, esr);
@@ -813,10 +801,11 @@
default:
call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)frame->tf_elr,
exception);
- userret(td, frame);
break;
}
+ if (!skip_userret)
+ userret(td, frame);
KASSERT(
(td->td_pcb->pcb_fpflags & ~(PCB_FP_USERMASK|PCB_FP_SVEVALID)) == 0,
("Kernel VFP flags set while entering userspace"));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jun 21, 12:11 AM (21 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34133564
Default Alt Text
D55250.id173798.diff (3 KB)
Attached To
Mode
D55250: arm64: Have a common call to userret
Attached
Detach File
Event Timeline
Log In to Comment