lkml.org 
[lkml]   [1998]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [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

    \
     
     \ /
      Last update: 2005-03-22 13:43    [W:2.416 / U:0.624 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site