summaryrefslogtreecommitdiffstats
path: root/sys/x86/include/x86_var.h
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-12-02 19:02:12 +0000
committerjhb <jhb@FreeBSD.org>2016-12-02 19:02:12 +0000
commitf264e4e233ec1083a30cb6b50d0d0ac53cc6fb86 (patch)
tree640c3f7b80a315fde7c31532ac9cf3676da35285 /sys/x86/include/x86_var.h
parent5c325f007b252a394e014fef7ff608a260222247 (diff)
downloadFreeBSD-src-f264e4e233ec1083a30cb6b50d0d0ac53cc6fb86.zip
FreeBSD-src-f264e4e233ec1083a30cb6b50d0d0ac53cc6fb86.tar.gz
MFC 303753,308004: Add bounds checking on addresses used with /dev/mem.
303753: Don't permit mappings of invalid physical addresses on amd64 via /dev/mem. 308004: MFamd64: Add bounds checks on addresses used with /dev/mem. Reject attempts to read from or memory map offsets in /dev/mem that are beyond the maximum-supported physical address of the current CPU.
Diffstat (limited to 'sys/x86/include/x86_var.h')
-rw-r--r--sys/x86/include/x86_var.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h
index 12bc1e0..92c9f1d 100644
--- a/sys/x86/include/x86_var.h
+++ b/sys/x86/include/x86_var.h
@@ -94,6 +94,20 @@ struct trapframe;
*/
typedef void alias_for_inthand_t(void);
+/*
+ * Returns the maximum physical address that can be used with the
+ * current system.
+ */
+static __inline vm_paddr_t
+cpu_getmaxphyaddr(void)
+{
+#if defined(__i386__) && !defined(PAE)
+ return (0xffffffff);
+#else
+ return ((1ULL << cpu_maxphyaddr) - 1);
+#endif
+}
+
void *alloc_fpusave(int flags);
void busdma_swi(void);
bool cpu_mwait_usable(void);
OpenPOWER on IntegriCloud