aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2022-03-26 15:59:34 +0000
committerAndrew Turner <andrew@FreeBSD.org>2022-03-31 11:09:07 +0000
commit004da2d51f8427745c0d1287781d5ba546b19000 (patch)
treea8961b9c83838a511ed634625508f117e8224d43
parent30a1d38e6cbd1cef63eae1b352aaa72abf276ca7 (diff)
downloadsrc-004da2d51f8427745c0d1287781d5ba546b19000.tar.gz
src-004da2d51f8427745c0d1287781d5ba546b19000.zip
Treat cache write as a read in arm64 data faults
On arm64 we can ask the hardware to perform cache operations from userspace. These require read permission however when the memory is unmapped the kernel will receive a write exception. Add a check to see if the cause of the exception is from the cache and pass a memory read fault type to the vm subsystem. PR: 262836 Reported by: dch Sponsored by: The FreeBSD Foundation (cherry picked from commit 029c1c4828aab451ba262cd4e2e1d9362cf18b76)
-rw-r--r--sys/arm64/arm64/trap.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c
index a8d29ffaa9a7..849f26ee8220 100644
--- a/sys/arm64/arm64/trap.c
+++ b/sys/arm64/arm64/trap.c
@@ -317,8 +317,16 @@ data_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
ftype = VM_PROT_EXECUTE;
break;
default:
- ftype = (esr & ISS_DATA_WnR) == 0 ? VM_PROT_READ :
- VM_PROT_WRITE;
+ /*
+ * If the exception was because of a read or cache operation
+ * pass a read fault type into the vm code. Cache operations
+ * need read permission but will set the WnR flag when the
+ * memory is unmapped.
+ */
+ if ((esr & ISS_DATA_WnR) == 0 || (esr & ISS_DATA_CM) != 0)
+ ftype = VM_PROT_READ;
+ else
+ ftype = VM_PROT_WRITE;
break;
}