Page MenuHomeFreeBSD

D47817.diff
No OneTemporary

D47817.diff

diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -187,11 +187,6 @@
{
/*
- * The LLVM integrated assembler doesn't understand the PAN
- * PSTATE field. Because of this we need to manually create
- * the instruction in an asm block. This is equivalent to:
- * msr pan, #1
- *
* This sets the PAN bit, stopping the kernel from accessing
* memory when userspace can also access it unless the kernel
* uses the userspace load/store instructions.
@@ -199,7 +194,10 @@
if (has_pan) {
WRITE_SPECIALREG(sctlr_el1,
READ_SPECIALREG(sctlr_el1) & ~SCTLR_SPAN);
- __asm __volatile(".inst 0xd500409f | (0x1 << 8)");
+ __asm __volatile(
+ ".arch_extension pan \n"
+ "msr pan, #1 \n"
+ ".arch_extension nopan \n");
}
}
diff --git a/sys/arm64/include/asm.h b/sys/arm64/include/asm.h
--- a/sys/arm64/include/asm.h
+++ b/sys/arm64/include/asm.h
@@ -87,19 +87,25 @@
ldr tmp, =has_pan; /* Get the addr of has_pan */ \
ldr reg, [tmp]; /* Read it */ \
cbz reg, 997f; /* If no PAN skip */ \
- .inst 0xd500409f | (0 << 8); /* Clear PAN */ \
+ .arch_extension pan; \
+ msr pan, #0; /* Disable PAN checks */ \
+ .arch_extension nopan; \
997:
#define EXIT_USER_ACCESS(reg) \
cbz reg, 998f; /* If no PAN skip */ \
- .inst 0xd500409f | (1 << 8); /* Set PAN */ \
+ .arch_extension pan; \
+ msr pan, #1; /* Enable PAN checks */ \
+ .arch_extension nopan; \
998:
#define EXIT_USER_ACCESS_CHECK(reg, tmp) \
ldr tmp, =has_pan; /* Get the addr of has_pan */ \
ldr reg, [tmp]; /* Read it */ \
cbz reg, 999f; /* If no PAN skip */ \
- .inst 0xd500409f | (1 << 8); /* Set PAN */ \
+ .arch_extension pan; \
+ msr pan, #1; /* Enable PAN checks */ \
+ .arch_extension nopan; \
999:
/*

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 15, 1:02 AM (10 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15803467
Default Alt Text
D47817.diff (1 KB)

Event Timeline