Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107748371
D30594.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D30594.diff
View Options
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -172,6 +172,39 @@
&nmi_flush_l1d_sw, 0,
"Flush L1 Data Cache on NMI exit, software bhyve L1TF mitigation assist");
+/*
+ * Table of handlers for various segment load faults.
+ */
+static const struct {
+ uintptr_t faddr;
+ uintptr_t fhandler;
+} sfhandlers[] = {
+ {
+ .faddr = (uintptr_t)ld_ds,
+ .fhandler = (uintptr_t)ds_load_fault,
+ },
+ {
+ .faddr = (uintptr_t)ld_es,
+ .fhandler = (uintptr_t)es_load_fault,
+ },
+ {
+ .faddr = (uintptr_t)ld_fs,
+ .fhandler = (uintptr_t)fs_load_fault,
+ },
+ {
+ .faddr = (uintptr_t)ld_gs,
+ .fhandler = (uintptr_t)gs_load_fault,
+ },
+ {
+ .faddr = (uintptr_t)ld_gsbase,
+ .fhandler = (uintptr_t)gsbase_load_fault
+ },
+ {
+ .faddr = (uintptr_t)ld_fsbase,
+ .fhandler = (uintptr_t)fsbase_load_fault,
+ },
+};
+
/*
* Exception, fault, and trap interface to the FreeBSD kernel.
* This common code is called from assembly language IDT gate entry
@@ -186,6 +219,7 @@
struct thread *td;
struct proc *p;
register_t addr, dr6;
+ size_t i;
int pf, signo, ucode;
u_int type;
@@ -450,9 +484,9 @@
* Magic '5' is the number of qwords occupied by
* the hardware trap frame.
*/
- KASSERT((read_rflags() & PSL_I) == 0,
- ("interrupts enabled"));
if (frame->tf_rip == (long)doreti_iret) {
+ KASSERT((read_rflags() & PSL_I) == 0,
+ ("interrupts enabled"));
frame->tf_rip = (long)doreti_iret_fault;
if ((PCPU_GET(curpmap)->pm_ucr3 !=
PMAP_NO_CR3) &&
@@ -463,30 +497,16 @@
}
return;
}
- if (frame->tf_rip == (long)ld_ds) {
- frame->tf_rip = (long)ds_load_fault;
- return;
- }
- if (frame->tf_rip == (long)ld_es) {
- frame->tf_rip = (long)es_load_fault;
- return;
- }
- if (frame->tf_rip == (long)ld_fs) {
- frame->tf_rip = (long)fs_load_fault;
- return;
- }
- if (frame->tf_rip == (long)ld_gs) {
- frame->tf_rip = (long)gs_load_fault;
- return;
- }
- if (frame->tf_rip == (long)ld_gsbase) {
- frame->tf_rip = (long)gsbase_load_fault;
- return;
- }
- if (frame->tf_rip == (long)ld_fsbase) {
- frame->tf_rip = (long)fsbase_load_fault;
- return;
+
+ for (i = 0; i < nitems(sfhandlers); i++) {
+ if (frame->tf_rip == sfhandlers[i].faddr) {
+ KASSERT((read_rflags() & PSL_I) == 0,
+ ("interrupts enabled"));
+ frame->tf_rip = sfhandlers[i].fhandler;
+ return;
+ }
}
+
if (curpcb->pcb_onfault != NULL) {
frame->tf_rip = (long)curpcb->pcb_onfault;
return;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 18, 10:58 PM (21 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15901942
Default Alt Text
D30594.diff (2 KB)
Attached To
Mode
D30594: amd64: Relax the assertion added in commit 4a59cbc12
Attached
Detach File
Event Timeline
Log In to Comment