diff options
author | sigsegv7 <ian@vegaa.systems> | 2023-09-28 15:37:15 -0400 |
---|---|---|
committer | sigsegv7 <ian@vegaa.systems> | 2023-09-28 15:37:15 -0400 |
commit | 76a6a3da6be53621d017416bfd81f1fda265ac7c (patch) | |
tree | a4f03cb4f52deea08bca6f1156d74eb9b96552cb /sys/include | |
parent | 215efd60900f28bb543ffab400306fbd01a4f76c (diff) |
kernel: mmio: Add memory barriers to helpers
This commit introduces memory barriers to MMIO read/write helpers to
ensure the compiler does not re-order these critical memory accesses
which would in turn result in very strange behaviour if it were to be
re-ordered.
Signed-off-by: sigsegv7 <ian@vegaa.systems>
Diffstat (limited to 'sys/include')
-rw-r--r-- | sys/include/sys/mmio.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/include/sys/mmio.h b/sys/include/sys/mmio.h index f840bf8..0cc1983 100644 --- a/sys/include/sys/mmio.h +++ b/sys/include/sys/mmio.h @@ -31,6 +31,7 @@ #define _SYS_MMIO_H_ #include <sys/types.h> +#include <sys/cdefs.h> #include <vm/vm.h> /* @@ -57,6 +58,7 @@ tmp += VM_HIGHER_HALF; \ } \ *(volatile TYPE *)tmp = val; \ + __mem_barrier(); \ } /* @@ -74,6 +76,8 @@ if (tmp < VM_HIGHER_HALF) { \ tmp += VM_HIGHER_HALF; \ } \ + \ + __mem_barrier(); /* Ensure writes complete */ \ return *(volatile TYPE *)tmp; \ } |