diff options
author | John Baldwin <jhb@FreeBSD.org> | 2016-10-27 21:23:14 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2016-10-27 21:23:14 +0000 |
commit | 16dcd7734fa83ba7bd7daf822e2b7fa4fa2cba5a (patch) | |
tree | f54b53e25ee3068d72a1f411fcd73653fb3c4ca0 /sys/x86 | |
parent | c4e24caf4ec787d4092a953f535021682744f3ba (diff) | |
download | src-16dcd7734fa83ba7bd7daf822e2b7fa4fa2cba5a.tar.gz src-16dcd7734fa83ba7bd7daf822e2b7fa4fa2cba5a.zip |
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.
Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D7408
Notes
Notes:
svn path=/head/; revision=308004
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/include/x86_var.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index 12bc1e07d4c0..92c9f1dafa21 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); |