Page MenuHomeFreeBSD

D7408.diff
No OneTemporary

D7408.diff

Index: head/sys/amd64/amd64/mem.c
===================================================================
--- head/sys/amd64/amd64/mem.c
+++ head/sys/amd64/amd64/mem.c
@@ -140,7 +140,7 @@
error = uiomove((void *)vd, c, uio);
break;
}
- if (v >= (1ULL << cpu_maxphyaddr)) {
+ if (v > cpu_getmaxphyaddr()) {
error = EFAULT;
break;
}
@@ -169,7 +169,7 @@
int prot __unused, vm_memattr_t *memattr __unused)
{
if (dev2unit(dev) == CDEV_MINOR_MEM) {
- if (offset >= (1ULL << cpu_maxphyaddr))
+ if (offset > cpu_getmaxphyaddr())
return (-1);
*paddr = offset;
return (0);
Index: head/sys/i386/i386/mem.c
===================================================================
--- head/sys/i386/i386/mem.c
+++ head/sys/i386/i386/mem.c
@@ -108,8 +108,11 @@
continue;
}
if (dev2unit(dev) == CDEV_MINOR_MEM) {
- pa = uio->uio_offset;
- pa &= ~PAGE_MASK;
+ if (uio->uio_offset > cpu_getmaxphyaddr()) {
+ error = EFAULT;
+ break;
+ }
+ pa = trunc_page(uio->uio_offset);
} else {
/*
* Extract the physical page since the mapping may
@@ -162,6 +165,8 @@
int prot __unused, vm_memattr_t *memattr __unused)
{
if (dev2unit(dev) == CDEV_MINOR_MEM) {
+ if (offset > cpu_getmaxphyaddr())
+ return (-1);
*paddr = offset;
return (0);
}
Index: head/sys/x86/include/x86_var.h
===================================================================
--- head/sys/x86/include/x86_var.h
+++ head/sys/x86/include/x86_var.h
@@ -94,6 +94,20 @@
*/
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);

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 11:58 AM (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14485576
Default Alt Text
D7408.diff (1 KB)

Event Timeline