summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/mem.c8
-rw-r--r--sys/amd64/include/md_var.h10
2 files changed, 15 insertions, 3 deletions
diff --git a/sys/amd64/amd64/mem.c b/sys/amd64/amd64/mem.c
index 225fe66..7325664 100644
--- a/sys/amd64/amd64/mem.c
+++ b/sys/amd64/amd64/mem.c
@@ -140,7 +140,7 @@ memrw(struct cdev *dev, struct uio *uio, int flags)
error = uiomove((void *)vd, c, uio);
break;
}
- if (v >= (1ULL << cpu_maxphyaddr)) {
+ if (v > cpu_getmaxphyaddr()) {
error = EFAULT;
break;
}
@@ -168,9 +168,11 @@ int
memmmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr,
int prot __unused, vm_memattr_t *memattr __unused)
{
- if (dev2unit(dev) == CDEV_MINOR_MEM)
+ if (dev2unit(dev) == CDEV_MINOR_MEM) {
+ if (offset > cpu_getmaxphyaddr())
+ return (-1);
*paddr = offset;
- else if (dev2unit(dev) == CDEV_MINOR_KMEM)
+ } else if (dev2unit(dev) == CDEV_MINOR_KMEM)
*paddr = vtophys(offset);
/* else panic! */
return (0);
diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h
index 36a6d7f..63f2587 100644
--- a/sys/amd64/include/md_var.h
+++ b/sys/amd64/include/md_var.h
@@ -89,6 +89,16 @@ struct fpreg;
struct dbreg;
struct dumperinfo;
+/*
+ * Returns the maximum physical address that can be used with the
+ * current system.
+ */
+static __inline vm_paddr_t
+cpu_getmaxphyaddr(void)
+{
+ return ((1ULL << cpu_maxphyaddr) - 1);
+}
+
void *alloc_fpusave(int flags);
void amd64_syscall(struct thread *td, int traced);
void busdma_swi(void);
OpenPOWER on IntegriCloud