Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163237319
D55950.id175629.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
D55950.id175629.diff
View Options
diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c
--- a/sys/arm64/arm64/exec_machdep.c
+++ b/sys/arm64/arm64/exec_machdep.c
@@ -445,6 +445,7 @@
else
new_tcr = 0;
td->td_proc->p_md.md_tcr = new_tcr;
+ td->td_md.md_sctlr = 0;
/* TODO: should create a pmap function for this... */
tcr = READ_SPECIALREG(tcr_el1);
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -9349,6 +9349,7 @@
{
pcpu_bp_harden bp_harden;
struct pcb *pcb;
+ uint64_t sctlr;
/* Store the new curthread */
PCPU_SET(curthread, new);
@@ -9357,6 +9358,16 @@
pcb = new->td_pcb;
PCPU_SET(curpcb, pcb);
+ if ((new->td_proc->p_flag & P_KPROC) == 0) {
+ sctlr = READ_SPECIALREG(sctlr_el1);
+ if ((sctlr & SCTLR_USER_MASK) != new->td_md.md_sctlr) {
+ sctlr &= ~SCTLR_USER_MASK;
+ sctlr |= new->td_md.md_sctlr;
+ WRITE_SPECIALREG(sctlr_el1, sctlr);
+ isb();
+ }
+ }
+
/*
* TODO: We may need to flush the cache here if switching
* to a user process.
diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c
--- a/sys/arm64/arm64/vm_machdep.c
+++ b/sys/arm64/arm64/vm_machdep.c
@@ -123,6 +123,8 @@
/* Copy the TCR_EL1 value */
td2->td_proc->p_md.md_tcr = td1->td_proc->p_md.md_tcr;
+ td2->td_md.md_sctlr = td1->td_md.md_sctlr;
+
#if defined(PERTHREAD_SSP)
/* Set the new canary */
arc4random_buf(&td2->td_md.md_canary, sizeof(td2->td_md.md_canary));
@@ -192,6 +194,8 @@
td->td_md.md_spinlock_count = 1;
td->td_md.md_saved_daif = PSR_DAIF_DEFAULT;
+ td->td_md.md_sctlr = td0->td_md.md_sctlr;
+
#if defined(PERTHREAD_SSP)
/* Set the new canary */
arc4random_buf(&td->td_md.md_canary, sizeof(td->td_md.md_canary));
diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h
--- a/sys/arm64/include/armreg.h
+++ b/sys/arm64/include/armreg.h
@@ -2803,6 +2803,7 @@
SCTLR_SA | \
SCTLR_C | \
SCTLR_M)
+#define SCTLR_USER_MASK (SCTLR_ATA0 | SCTLR_TCF0_MASK)
/* SCTLR_EL12 */
#define SCTLR_EL12_REG MRS_REG_ALT_NAME(SCTLR_EL12)
diff --git a/sys/arm64/include/proc.h b/sys/arm64/include/proc.h
--- a/sys/arm64/include/proc.h
+++ b/sys/arm64/include/proc.h
@@ -70,7 +70,8 @@
int md_efirt_dis_pf;
int md_reserved0;
- uint64_t md_reserved[2];
+ uint64_t md_sctlr;
+ uint64_t md_reserved1;
};
struct mdproc {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 22, 7:52 AM (11 m, 11 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35354870
Default Alt Text
D55950.id175629.diff (2 KB)
Attached To
Mode
D55950: arm64: Support some per-thread sctlr_el1 fields
Attached
Detach File
Event Timeline
Log In to Comment