Skip to content
  • Sergei Trofimovich's avatar
    alpha: fix page fault handling for r16-r18 targets · 491af60f
    Sergei Trofimovich authored
    Fix page fault handling code to fixup r16-r18 registers.
    Before the patch code had off-by-two registers bug.
    This bug caused overwriting of ps,pc,gp registers instead
    of fixing intended r16,r17,r18 (see `struct pt_regs`).
    
    More details:
    
    Initially Dmitry noticed a kernel bug as a failure
    on strace test suite. Test passes unmapped userspace
    pointer to io_submit:
    
    ```c
        #include <err.h>
        #include <unistd.h>
        #include <sys/mman.h>
        #include <asm/unistd.h>
        int main(void)
        {
            unsigned long ctx = 0;
            if (syscall(__NR_io_setup, 1, &ctx))
                err(1, "io_setup");
            const size_t page_size = sysconf(_SC_PAGESIZE);
            const size_t size = page_size * 2;
            void *ptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
                             MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
            if (MAP_FAILED == ptr)
                err(1, "mmap(%zu)", size);
            if (munmap(ptr, size))
                err(1, "munmap");
            syscal...
    491af60f