Messages in this thread | | | Date | Tue, 21 Jul 1998 16:47:13 +1000 | From | Richard Gooch <> | Subject | Re: [PATCH] New phys_addr() syscall |
| |
Richard Henderson writes: > On Sun, Jul 19, 1998 at 03:53:24PM +1000, Richard.Gooch@atnf.csiro.au wrote: > > +asmlinkage int sys_phys_addr(unsigned long *address) > > +{ > > + int error = 0; > > + unsigned long addr; > > + pte_t *pte; > > + > > + error = copy_from_user (&addr, address, sizeof addr); > > + if (error < 0) return error; > > + pte = pte_offset (pmd_offset (pgd_offset (current->mm, addr), addr), > > + addr); > > + if ( !pte_present (*pte) ) return -EINVAL; > > + addr = __pa (pte_page (*pte)) + (addr & (PAGE_SIZE-1)); > > + return copy_to_user (address, &addr, sizeof addr) ? -EFAULT : 0; > > +} > > There is no point in copying to and from memory. An error return will > be a non-page-aligned value > -PAGE_SIZE. Just get the pa of address > and return the result.
Aside: I've switched to an ioctl(2) interface on /proc/*/mem. The problem is that the return value is an int, which is only 32 bits. Won't this be a problem for 64 machines with over 4 GBytes of RAM?
Regards,
Richard....
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html
| |