summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1998-01-19 15:27:56 +0000
committerbde <bde@FreeBSD.org>1998-01-19 15:27:56 +0000
commitb0334344b1d69ff73231aee35f821e663d30c1d9 (patch)
tree34915be29add3e334bcddb5b43c78834e92536a6 /gnu
parent314c0741a961ab83f999b41d7edf55acc00569b6 (diff)
downloadFreeBSD-src-b0334344b1d69ff73231aee35f821e663d30c1d9.zip
FreeBSD-src-b0334344b1d69ff73231aee35f821e663d30c1d9.tar.gz
Fixed accesses to addresses between VM_MAXUSER_ADDRESS (normally
0xefbfe000) and kernel_start (normally 0xf0100000). Things are unnecessarily (?) difficult because procfs is used to access user addresses in the live-kernel case although we must have access to /dev/mem to work at all, and whatever works for the dead-kernel case should work in all cases (modulo volatility of live kernel variables). We used the wrong range [0, kernel_start) for user addresses. Procfs should only work up to VM_MAXUSER_ADDRESS, but it bogusly works for reads up to the address 2 pages higher (the user area, including the kernel stack, is mapped to where the user area used to be (WTUAUTB)). Procfs can not work at all for addresses between WTUAUTB and kernel_start. Now we use procfs only to access addresses up to VM_MAXUSER_ADDRESS. Higher addresses are translated normally using kvtophys(), so the user ptd is used for addresses below the real kernel start (0xf0000000; see INKERNEL()) and nothing is found WTUAUTB. Strange accesses that cross the user-kernel boundary are now handled, but such ranges are currently always errors because they necessarily overlap the hole WTUAUTB. Short reads are still not handled.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c33
-rw-r--r--gnu/usr.bin/binutils/gdb/kvm-fbsd.c33
-rw-r--r--gnu/usr.bin/gdb/gdb/kvm-fbsd.c33
3 files changed, 63 insertions, 36 deletions
diff --git a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c
index 970d3a8..3c869f2 100644
--- a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c
+++ b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c
@@ -382,21 +382,30 @@ kcore_xfer_kmem (memaddr, myaddr, len, write, target)
int write;
struct target_ops *target;
{
- int n;
-
- if (!memaddr)
- return (0);
+ int ns;
+ int nu;
- if (memaddr < kernel_start)
- return xfer_umem (memaddr, myaddr, len, write);
+ if (memaddr >= (CORE_ADDR)VM_MAXUSER_ADDRESS)
+ nu = 0;
+ else
+ {
+ nu = xfer_umem (memaddr, myaddr, len, write);
+ if (nu <= 0)
+ return (0);
+ if (nu == len)
+ return (nu);
+ memaddr += nu;
+ if (memaddr != (CORE_ADDR)VM_MAXUSER_ADDRESS)
+ return (nu);
+ myaddr += nu;
+ len -= nu;
+ }
- n = write ?
- kvm_write (core_kd, memaddr, myaddr, len) :
- kvm_read (core_kd, memaddr, myaddr, len) ;
+ ns = (write ? kvm_write : kvm_read) (core_kd, memaddr, myaddr, len);
+ if (ns < 0)
+ ns = 0;
- if (n < 0)
- return 0;
- return n;
+ return (nu + ns);
}
static int
diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
index 970d3a8..3c869f2 100644
--- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
+++ b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c
@@ -382,21 +382,30 @@ kcore_xfer_kmem (memaddr, myaddr, len, write, target)
int write;
struct target_ops *target;
{
- int n;
-
- if (!memaddr)
- return (0);
+ int ns;
+ int nu;
- if (memaddr < kernel_start)
- return xfer_umem (memaddr, myaddr, len, write);
+ if (memaddr >= (CORE_ADDR)VM_MAXUSER_ADDRESS)
+ nu = 0;
+ else
+ {
+ nu = xfer_umem (memaddr, myaddr, len, write);
+ if (nu <= 0)
+ return (0);
+ if (nu == len)
+ return (nu);
+ memaddr += nu;
+ if (memaddr != (CORE_ADDR)VM_MAXUSER_ADDRESS)
+ return (nu);
+ myaddr += nu;
+ len -= nu;
+ }
- n = write ?
- kvm_write (core_kd, memaddr, myaddr, len) :
- kvm_read (core_kd, memaddr, myaddr, len) ;
+ ns = (write ? kvm_write : kvm_read) (core_kd, memaddr, myaddr, len);
+ if (ns < 0)
+ ns = 0;
- if (n < 0)
- return 0;
- return n;
+ return (nu + ns);
}
static int
diff --git a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c b/gnu/usr.bin/gdb/gdb/kvm-fbsd.c
index 970d3a8..3c869f2 100644
--- a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c
+++ b/gnu/usr.bin/gdb/gdb/kvm-fbsd.c
@@ -382,21 +382,30 @@ kcore_xfer_kmem (memaddr, myaddr, len, write, target)
int write;
struct target_ops *target;
{
- int n;
-
- if (!memaddr)
- return (0);
+ int ns;
+ int nu;
- if (memaddr < kernel_start)
- return xfer_umem (memaddr, myaddr, len, write);
+ if (memaddr >= (CORE_ADDR)VM_MAXUSER_ADDRESS)
+ nu = 0;
+ else
+ {
+ nu = xfer_umem (memaddr, myaddr, len, write);
+ if (nu <= 0)
+ return (0);
+ if (nu == len)
+ return (nu);
+ memaddr += nu;
+ if (memaddr != (CORE_ADDR)VM_MAXUSER_ADDRESS)
+ return (nu);
+ myaddr += nu;
+ len -= nu;
+ }
- n = write ?
- kvm_write (core_kd, memaddr, myaddr, len) :
- kvm_read (core_kd, memaddr, myaddr, len) ;
+ ns = (write ? kvm_write : kvm_read) (core_kd, memaddr, myaddr, len);
+ if (ns < 0)
+ ns = 0;
- if (n < 0)
- return 0;
- return n;
+ return (nu + ns);
}
static int
OpenPOWER on IntegriCloud