lkml.org 
[lkml]   [2018]   [Feb]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 48/64] arch/tile: use mm locking wrappers
    Date
    From: Davidlohr Bueso <dave@stgolabs.net>

    * THIS IS A HACK *

    Breaks arch/um/. See comment in fix_range_common().

    Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
    ---
    arch/um/include/asm/mmu_context.h | 5 +++--
    arch/um/kernel/tlb.c | 12 +++++++++++-
    arch/um/kernel/trap.c | 6 +++---
    3 files changed, 17 insertions(+), 6 deletions(-)

    diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h
    index 98cc3e36385a..7dc202c611db 100644
    --- a/arch/um/include/asm/mmu_context.h
    +++ b/arch/um/include/asm/mmu_context.h
    @@ -49,14 +49,15 @@ extern void force_flush_all(void);

    static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
    {
    + DEFINE_RANGE_LOCK_FULL(mmrange);
    /*
    * This is called by fs/exec.c and sys_unshare()
    * when the new ->mm is used for the first time.
    */
    __switch_mm(&new->context.id);
    - down_write(&new->mmap_sem);
    + mm_write_lock(new, &mmrange);
    uml_setup_stubs(new);
    - up_write(&new->mmap_sem);
    + mm_write_unlock(new, &mmrange);
    }

    static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
    diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
    index 37508b190106..eeeeb048b6f4 100644
    --- a/arch/um/kernel/tlb.c
    +++ b/arch/um/kernel/tlb.c
    @@ -297,10 +297,20 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr,

    /* This is not an else because ret is modified above */
    if (ret) {
    + /*
    + * FIXME: this is _wrong_ and will break arch/um.
    + *
    + * The right thing to do is modify the flush_tlb_range()
    + * api, but that in turn would require file_operations
    + * knowing about mmrange... Compiles cleanly, but sucks
    + * otherwise.
    + */
    + DEFINE_RANGE_LOCK_FULL(mmrange);
    +
    printk(KERN_ERR "fix_range_common: failed, killing current "
    "process: %d\n", task_tgid_vnr(current));
    /* We are under mmap_sem, release it such that current can terminate */
    - up_write(&current->mm->mmap_sem);
    + mm_write_unlock(current->mm, &mmrange);
    force_sig(SIGKILL, current);
    do_signal(&current->thread.regs);
    }
    diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
    index e632a14e896e..14dcb83d00a9 100644
    --- a/arch/um/kernel/trap.c
    +++ b/arch/um/kernel/trap.c
    @@ -47,7 +47,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
    if (is_user)
    flags |= FAULT_FLAG_USER;
    retry:
    - down_read(&mm->mmap_sem);
    + mm_read_lock(mm, &mmrange);
    vma = find_vma(mm, address);
    if (!vma)
    goto out;
    @@ -123,7 +123,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
    #endif
    flush_tlb_page(vma, address);
    out:
    - up_read(&mm->mmap_sem);
    + mm_read_unlock(mm, &mmrange);
    out_nosemaphore:
    return err;

    @@ -132,7 +132,7 @@ int handle_page_fault(unsigned long address, unsigned long ip,
    * We ran out of memory, call the OOM killer, and return the userspace
    * (which will retry the fault, or kill us if we got oom-killed).
    */
    - up_read(&mm->mmap_sem);
    + mm_read_unlock(mm, &mmrange);
    if (!is_user)
    goto out_nosemaphore;
    pagefault_out_of_memory();
    --
    2.13.6
    \
     
     \ /
      Last update: 2018-02-05 02:33    [W:4.083 / U:1.236 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site