Messages in this thread | | | Date | Mon, 20 Jul 1998 01:46:10 -0700 | From | Richard Henderson <> | Subject | Re: [PATCH] New phys_addr() syscall |
| |
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.
r~
- 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
| |