17 Jun, 2020

1 commit


03 Jun, 2020

4 commits

  • [ Upstream commit 51bb38cb78363fdad1f89e87357b7bc73e39ba88 ]

    If raw_copy_from_user(to, from, N) returns K, callers expect
    the first N - K bytes starting at to to have been replaced with
    the contents of corresponding area starting at from and the last
    K bytes of destination *left* *unmodified*.

    What arch/sky/lib/usercopy.c is doing is broken - it can lead to e.g.
    data corruption on write(2).

    raw_copy_to_user() is inaccurate about return value, which is a bug,
    but consequences are less drastic than for raw_copy_from_user().
    And just what are those access_ok() doing in there? I mean, look into
    linux/uaccess.h; that's where we do that check (as well as zero tail
    on failure in the callers that need zeroing).

    AFAICS, all of that shouldn't be hard to fix; something like a patch
    below might make a useful starting point.

    I would suggest moving these macros into usercopy.c (they are never
    used anywhere else) and possibly expanding them there; if you leave
    them alive, please at least rename __copy_user_zeroing(). Again,
    it must not zero anything on failed read.

    Said that, I'm not sure we won't be better off simply turning
    usercopy.c into usercopy.S - all that is left there is a couple of
    functions, each consisting only of inline asm.

    Guo Ren reply:

    Yes, raw_copy_from_user is wrong, it's no need zeroing code.

    unsigned long _copy_from_user(void *to, const void __user *from,
    unsigned long n)
    {
    unsigned long res = n;
    might_fault();
    if (likely(access_ok(from, n))) {
    kasan_check_write(to, n);
    res = raw_copy_from_user(to, from, n);
    }
    if (unlikely(res))
    memset(to + (n - res), 0, res);
    return res;
    }
    EXPORT_SYMBOL(_copy_from_user);

    You are right and access_ok() should be removed.

    but, how about:
    do {
    ...
    "2: stw %3, (%1, 0) \n" \
    + " subi %0, 4 \n" \
    "9: stw %4, (%1, 4) \n" \
    + " subi %0, 4 \n" \
    "10: stw %5, (%1, 8) \n" \
    + " subi %0, 4 \n" \
    "11: stw %6, (%1, 12) \n" \
    + " subi %0, 4 \n" \
    " addi %2, 16 \n" \
    " addi %1, 16 \n" \

    Don't expand __ex_table

    AI Viro reply:

    Hey, I've no idea about the instruction scheduling on csky -
    if that doesn't slow the things down, all the better. It's just
    that copy_to_user() and friends are on fairly hot codepaths,
    and in quite a few situations they will dominate the speed of
    e.g. read(2). So I tried to keep the fast path unchanged.
    Up to the architecture maintainers, obviously. Which would be
    you...

    As for the fixups size increase (__ex_table size is unchanged)...
    You have each of those macros expanded exactly once.
    So the size is not a serious argument, IMO - useless complexity
    would be, if it is, in fact, useless; the size... not really,
    especially since those extra subi will at least offset it.

    Again, up to you - asm optimizations of (essentially)
    memcpy()-style loops are tricky and can depend upon the
    fairly subtle details of architecture. So even on something
    I know reasonably well I would resort to direct experiments
    if I can't pass the buck to architecture maintainers.

    It *is* worth optimizing - this is where read() from a file
    that is already in page cache spends most of the time, etc.

    Guo Ren reply:

    Thx, after fixup some typo “sub %0, 4”, apply the patch.

    TODO:
    - user copy/from codes are still need optimizing.

    Signed-off-by: Al Viro
    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Al Viro
     
  • [ Upstream commit 6633a5aa8eb6bda70eb3a9837efd28a67ccc6e0a ]

    Interrupt has been disabled in __schedule() with local_irq_disable()
    and enabled in finish_task_switch->finish_lock_switch() with
    local_irq_enabled(), So needn't to disable irq here.

    Signed-off-by: Liu Yibin
    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Liu Yibin
     
  • [ Upstream commit 229a0ddee1108a3f82a873e6cbbe35c92c540444 ]

    [ 5221.974084] Unable to handle kernel paging request at virtual address 0xfffff000, pc: 0x8002c18e
    [ 5221.985929] Oops: 00000000
    [ 5221.989488]
    [ 5221.989488] CURRENT PROCESS:
    [ 5221.989488]
    [ 5221.992877] COMM=callchain_test PID=11962
    [ 5221.995213] TEXT=00008000-000087e0 DATA=00009f1c-0000a018 BSS=0000a018-0000b000
    [ 5221.999037] USER-STACK=7fc18e20 KERNEL-STACK=be204680
    [ 5221.999037]
    [ 5222.003292] PC: 0x8002c18e (perf_callchain_kernel+0x3e/0xd4)
    [ 5222.007957] LR: 0x8002c198 (perf_callchain_kernel+0x48/0xd4)
    [ 5222.074873] Call Trace:
    [ 5222.074873] [] get_perf_callchain+0x20a/0x29c
    [ 5222.074873] [] perf_callchain+0x64/0x80
    [ 5222.074873] [] perf_prepare_sample+0x29c/0x4b8
    [ 5222.074873] [] perf_event_output_forward+0x36/0x98
    [ 5222.074873] [] search_exception_tables+0x20/0x44
    [ 5222.074873] [] do_page_fault+0x92/0x378
    [ 5222.074873] [] __perf_event_overflow+0x54/0xdc
    [ 5222.074873] [] perf_swevent_hrtimer+0xe8/0x164
    [ 5222.074873] [] update_mmu_cache+0x0/0xd8
    [ 5222.074873] [] user_backtrace+0x58/0xc4
    [ 5222.074873] [] perf_callchain_user+0x34/0xd0
    [ 5222.074873] [] get_perf_callchain+0x1be/0x29c
    [ 5222.074873] [] perf_callchain+0x64/0x80
    [ 5222.074873] [] perf_output_sample+0x78c/0x858
    [ 5222.074873] [] perf_prepare_sample+0x29c/0x4b8
    [ 5222.074873] [] perf_event_output_forward+0x5c/0x98
    [ 5222.097846]
    [ 5222.097846] [] perf_event_exit_task+0x58/0x43c
    [ 5222.097846] [] hrtimer_interrupt+0x104/0x2ec
    [ 5222.097846] [] perf_event_exit_task+0x58/0x43c
    [ 5222.097846] [] dw_apb_clockevent_irq+0x2a/0x4c
    [ 5222.097846] [] hrtimer_interrupt+0x0/0x2ec
    [ 5222.097846] [] __handle_irq_event_percpu+0xac/0x19c
    [ 5222.097846] [] dw_apb_clockevent_irq+0x2a/0x4c
    [ 5222.097846] [] handle_irq_event_percpu+0x34/0x88
    [ 5222.097846] [] handle_irq_event+0x24/0x64
    [ 5222.097846] [] handle_level_irq+0x68/0xdc
    [ 5222.097846] [] __handle_domain_irq+0x56/0xa8
    [ 5222.097846] [] ck_irq_handler+0xac/0xe4
    [ 5222.097846] [] csky_do_IRQ+0x12/0x24
    [ 5222.097846] [] csky_irq+0x70/0x80
    [ 5222.097846] [] alloc_set_pte+0xd2/0x238
    [ 5222.097846] [] update_mmu_cache+0x0/0xd8
    [ 5222.097846] [] perf_event_exit_task+0x98/0x43c

    The original fp check doesn't base on the real kernal stack region.
    Invalid fp address may cause kernel panic.

    Signed-off-by: Mao Han
    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Mao Han
     
  • [ Upstream commit 165f2d2858013253042809df082b8df7e34e86d7 ]

    Just as comment mentioned, the msa format:

    cr MSA register format:
    31 - 29 | 28 - 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
    BA Reserved SH WA B SO SEC C D V

    So we should shift 29 bits not 28 bits for mask

    Signed-off-by: Liu Yibin
    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Liu Yibin
     

23 Apr, 2020

3 commits

  • [ Upstream commit 12879bda3c2a974b7e4fe199a9c21f0c5f6bca04 ]

    WARNING: vmlinux.o(.text+0x2366): Section mismatch in reference from the
    function csky_start_secondary() to the function .init.text:init_fpu()

    The function csky_start_secondary() references
    the function __init init_fpu().
    This is often because csky_start_secondary lacks a __init
    annotation or the annotation of init_fpu is wrong.

    Reported-by: Lu Chongzhi
    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Guo Ren
     
  • [ Upstream commit 9c0e343d7654a329d1f9b53d253cbf7fb6eff85d ]

    We should get psr value from regs->psr in stack, not directly get
    it from phyiscal register then save the vector number in
    tsk->trap_no.

    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Guo Ren
     
  • [ Upstream commit aefd9461d34a1b0a2acad0750c43216c1c27b9d4 ]

    For the memory size ( > 512MB, < 1GB), the MSA setting is:

    - SSEG0: PHY_START , PHY_START + 512MB
    - SSEG1: PHY_START + 512MB, PHY_START + 1GB

    But the real memory is no more than 1GB, there is a gap between the
    end size of memory and border of 1GB. CPU could speculatively
    execute to that gap and if the gap of the bus couldn't respond to
    the CPU request, then the crash will happen.

    Now make the setting with:

    - SSEG0: PHY_START , PHY_START + 512MB (no change)
    - SSEG1: Disabled (We use highmem to use the memory of 512MB~1GB)

    We also deprecated zhole_szie[] settings, it's only used by arm
    style CPUs. All memory gap should use Reserved setting of dts in
    csky system.

    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Guo Ren
     

12 Mar, 2020

7 commits

  • commit 0b9f386c4be6493d282aab0af6f9b70c62142777 upstream.

    This is required for clone3 which passes the TLS value through a
    struct rather than a register.

    Cc: Amanieu d'Antras
    Signed-off-by: Guo Ren
    Signed-off-by: Greg Kroah-Hartman

    Guo Ren
     
  • [ Upstream commit bebd26ab623616728d6e72b5c74a47bfff5287d8 ]

    Fix wording in help text for the CPU_HAS_LDSTEX symbol.

    Signed-off-by: Randy Dunlap
    Signed-off-by: Guo Ren
    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Randy Dunlap
     
  • [ Upstream commit 2305f60b76110cb3e8658a4ae85d1f7eb0c66a5b ]

    Implement fstat64, fstatat64, clone3 syscalls to fixup
    checksyscalls.sh compile warnings.

    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Guo Ren
     
  • [ Upstream commit 359ae00d12589c31cf103894d0f32588d523ca83 ]

    During ftrace init, linux will replace all function prologues
    (call_mcout) with nops, but it need flush_dcache and
    invalidate_icache to make it work. So flush_cache functions
    couldn't be nested called by ftrace framework.

    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Guo Ren
     
  • [ Upstream commit c9492737b25ca32679ba3163609d938c9abfd508 ]

    If we use a non-ipi-support interrupt controller, it will cause panic here.
    We should let cpu up and work with CONFIG_SMP, when we use a non-ipi intc.

    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Guo Ren
     
  • [ Upstream commit f8e17c17b81070f38062dce79ca7f4541851dadd ]

    In the past, we didn't care about kernel sp when saving pt_reg. But in some
    cases, we still need pt_reg->usp to represent the kernel stack before enter
    exception.

    For cmpxhg in atomic.S, we need save and restore usp for above.

    Signed-off-by: Guo Ren
    Signed-off-by: Sasha Levin

    Guo Ren
     
  • [ Upstream commit 7f4a567332f035ab16b29010fbd04a0f10183c77 ]

    There is no present bit in csky pmd hardware, so we need to prepare invalid_pte_table
    for empty pmd entry and the functions (pmd_none & pmd_present) in pgtable.h need
    invalid_pte_talbe to get result. If a module use these functions, we need export the
    symbol for it.

    Signed-off-by: Guo Ren
    Cc: Mo Qihui
    Cc: Zhange Jian
    Signed-off-by: Sasha Levin

    Guo Ren
     

01 Oct, 2019

1 commit

  • Pull csky updates from Guo Ren:
    "This round of csky subsystem just some fixups:

    - Fix mb() synchronization problem

    - Fix dma_alloc_coherent with PAGE_SO attribute

    - Fix cache_op failed when cross memory ZONEs

    - Optimize arch_sync_dma_for_cpu/device with dma_inv_range

    - Fix ioremap function losing

    - Fix arch_get_unmapped_area() implementation

    - Fix defer cache flush for 610

    - Support kernel non-aligned access

    - Fix 610 vipt cache flush mechanism

    - Fix add zero_fp fixup perf backtrace panic

    - Move static keyword to the front of declaration

    - Fix csky_pmu.max_period assignment

    - Use generic free_initrd_mem()

    - entry: Remove unneeded need_resched() loop"

    * tag 'csky-for-linus-5.4-rc1' of git://github.com/c-sky/csky-linux:
    csky: Move static keyword to the front of declaration
    csky: entry: Remove unneeded need_resched() loop
    csky: Fixup csky_pmu.max_period assignment
    csky: Fixup add zero_fp fixup perf backtrace panic
    csky: Use generic free_initrd_mem()
    csky: Fixup 610 vipt cache flush mechanism
    csky: Support kernel non-aligned access
    csky: Fixup defer cache flush for 610
    csky: Fixup arch_get_unmapped_area() implementation
    csky: Fixup ioremap function losing
    csky: Optimize arch_sync_dma_for_cpu/device with dma_inv_range
    csky/dma: Fixup cache_op failed when cross memory ZONEs
    csky: Fixup dma_alloc_coherent with PAGE_SO attribute
    csky: Fixup mb() synchronization problem

    Linus Torvalds
     

30 Sep, 2019

5 commits


27 Sep, 2019

1 commit

  • The naming of pgtable_page_{ctor,dtor}() seems to have confused a few
    people, and until recently arm64 used these erroneously/pointlessly for
    other levels of page table.

    To make it incredibly clear that these only apply to the PTE level, and to
    align with the naming of pgtable_pmd_page_{ctor,dtor}(), let's rename them
    to pgtable_pte_page_{ctor,dtor}().

    These changes were generated with the following shell script:

    ----
    git grep -lw 'pgtable_page_.tor' | while read FILE; do
    sed -i '{s/pgtable_page_ctor/pgtable_pte_page_ctor/}' $FILE;
    sed -i '{s/pgtable_page_dtor/pgtable_pte_page_dtor/}' $FILE;
    done
    ----

    ... with the documentation re-flowed to remain under 80 columns, and
    whitespace fixed up in macros to keep backslashes aligned.

    There should be no functional change as a result of this patch.

    Link: http://lkml.kernel.org/r/20190722141133.3116-1-mark.rutland@arm.com
    Signed-off-by: Mark Rutland
    Reviewed-by: Mike Rapoport
    Acked-by: Geert Uytterhoeven [m68k]
    Cc: Anshuman Khandual
    Cc: Matthew Wilcox
    Cc: Michal Hocko
    Cc: Yu Zhao
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mark Rutland
     

25 Sep, 2019

2 commits

  • Both pgtable_cache_init() and pgd_cache_init() are used to initialize kmem
    cache for page table allocations on several architectures that do not use
    PAGE_SIZE tables for one or more levels of the page table hierarchy.

    Most architectures do not implement these functions and use __weak default
    NOP implementation of pgd_cache_init(). Since there is no such default
    for pgtable_cache_init(), its empty stub is duplicated among most
    architectures.

    Rename the definitions of pgd_cache_init() to pgtable_cache_init() and
    drop empty stubs of pgtable_cache_init().

    Link: http://lkml.kernel.org/r/1566457046-22637-1-git-send-email-rppt@linux.ibm.com
    Signed-off-by: Mike Rapoport
    Acked-by: Will Deacon [arm64]
    Acked-by: Thomas Gleixner [x86]
    Cc: Catalin Marinas
    Cc: Ingo Molnar
    Cc: Borislav Petkov
    Cc: Matthew Wilcox
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Rapoport
     
  • Patch series "mm: remove quicklist page table caches".

    A while ago Nicholas proposed to remove quicklist page table caches [1].

    I've rebased his patch on the curren upstream and switched ia64 and sh to
    use generic versions of PTE allocation.

    [1] https://lore.kernel.org/linux-mm/20190711030339.20892-1-npiggin@gmail.com

    This patch (of 3):

    Remove page table allocator "quicklists". These have been around for a
    long time, but have not got much traction in the last decade and are only
    used on ia64 and sh architectures.

    The numbers in the initial commit look interesting but probably don't
    apply anymore. If anybody wants to resurrect this it's in the git
    history, but it's unhelpful to have this code and divergent allocator
    behaviour for minor archs.

    Also it might be better to instead make more general improvements to page
    allocator if this is still so slow.

    Link: http://lkml.kernel.org/r/1565250728-21721-2-git-send-email-rppt@linux.ibm.com
    Signed-off-by: Nicholas Piggin
    Signed-off-by: Mike Rapoport
    Cc: Tony Luck
    Cc: Yoshinori Sato
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicholas Piggin
     

22 Sep, 2019

1 commit

  • Pull hmm updates from Jason Gunthorpe:
    "This is more cleanup and consolidation of the hmm APIs and the very
    strongly related mmu_notifier interfaces. Many places across the tree
    using these interfaces are touched in the process. Beyond that a
    cleanup to the page walker API and a few memremap related changes
    round out the series:

    - General improvement of hmm_range_fault() and related APIs, more
    documentation, bug fixes from testing, API simplification &
    consolidation, and unused API removal

    - Simplify the hmm related kconfigs to HMM_MIRROR and DEVICE_PRIVATE,
    and make them internal kconfig selects

    - Hoist a lot of code related to mmu notifier attachment out of
    drivers by using a refcount get/put attachment idiom and remove the
    convoluted mmu_notifier_unregister_no_release() and related APIs.

    - General API improvement for the migrate_vma API and revision of its
    only user in nouveau

    - Annotate mmu_notifiers with lockdep and sleeping region debugging

    Two series unrelated to HMM or mmu_notifiers came along due to
    dependencies:

    - Allow pagemap's memremap_pages family of APIs to work without
    providing a struct device

    - Make walk_page_range() and related use a constant structure for
    function pointers"

    * tag 'for-linus-hmm' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (75 commits)
    libnvdimm: Enable unit test infrastructure compile checks
    mm, notifier: Catch sleeping/blocking for !blockable
    kernel.h: Add non_block_start/end()
    drm/radeon: guard against calling an unpaired radeon_mn_unregister()
    csky: add missing brackets in a macro for tlb.h
    pagewalk: use lockdep_assert_held for locking validation
    pagewalk: separate function pointers from iterator data
    mm: split out a new pagewalk.h header from mm.h
    mm/mmu_notifiers: annotate with might_sleep()
    mm/mmu_notifiers: prime lockdep
    mm/mmu_notifiers: add a lockdep map for invalidate_range_start/end
    mm/mmu_notifiers: remove the __mmu_notifier_invalidate_range_start/end exports
    mm/hmm: hmm_range_fault() infinite loop
    mm/hmm: hmm_range_fault() NULL pointer bug
    mm/hmm: fix hmm_range_fault()'s handling of swapped out pages
    mm/mmu_notifiers: remove unregister_no_release
    RDMA/odp: remove ib_ucontext from ib_umem
    RDMA/odp: use mmu_notifier_get/put for 'struct ib_ucontext_per_mm'
    RDMA/mlx5: Use odp instead of mr->umem in pagefault_mr
    RDMA/mlx5: Use ib_umem_start instead of umem.address
    ...

    Linus Torvalds
     

07 Sep, 2019

1 commit

  • As an earlier patch made the macro argument more complicated, compilation
    now fails with:

    In file included from mm/madvise.c:30:
    mm/madvise.c: In function 'madvise_free_single_vma':
    arch/csky/include/asm/tlb.h:11:11: error:
    invalid type argument of '->' (have 'struct mmu_gather')

    Link: https://lore.kernel.org/r/20190901193601.GB5208@mellanox.com
    Fixes: 923bfc561e75 ("pagewalk: separate function pointers from iterator data")
    Reported-by: Guenter Roeck
    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     

29 Aug, 2019

1 commit


22 Aug, 2019

1 commit

  • 610 has vipt aliasing issue, so we need to finish the cache flush
    apis mentioned in cachetlb.rst to avoid data corruption.

    Here is the list of modified apis in the patch:

    - flush_kernel_dcache_page (new add)
    - flush_dcache_mmap_lock (new add)
    - flush_dcache_mmap_unlock (new add)
    - flush_kernel_vmap_range (new add)
    - invalidate_kernel_vmap_range (new add)
    - flush_anon_page (new add)
    - flush_cache_range (new add)
    - flush_cache_vmap (flush all)
    - flush_cache_vunmap (flush all)
    - flush_cache_mm (only dcache flush)
    - flush_icache_page (just nop)
    - copy_from_user_page (remove no need flush)
    - copy_to_user_page (remove no need flush)

    Change to V2:
    - Fixup compile error with xa_lock*(&mapping->i_pages)

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann
    Cc: Christoph Hellwig

    Guo Ren
     

20 Aug, 2019

3 commits

  • We prohibit non-aligned access in kernel mode, but some special NIC
    driver needs to support kernel-state unaligned access. For example,
    when the bus does not support unaligned access, IP header parsing
    will cause non-aligned access and driver does not recopy the skb
    buffer to dma for performance reasons.

    Added kernel_enable & user_enable to control unaligned access and
    added kernel_count & user_count for statistical unaligned access.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • We use defer cache flush mechanism to improve the performance of
    610, but the implementation is wrong. We fix it up now and update
    the mechanism:

    - Zero page needn't be flushed.
    - If page is file mapping & non-touched in user space, defer flush.
    - If page is anon mapping or dirty file mapping, flush immediately.
    - In update_mmu_cache finish the defer flush by flush_dcache_page().

    For 610 we need take care the dcache aliasing issue:
    - VIPT cache with 8K-bytes size per way in 4K page granularity.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • Current arch_get_unmapped_area() of abiv1 doesn't use standard kernel
    api. After referring to the implementation of arch/arm, we implement
    it with vm_unmapped_area() from linux/mm.h.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     

15 Aug, 2019

1 commit

  • Implement the following apis to meet usage in different scenarios.

    - ioremap (NonCache + StrongOrder)
    - ioremap_nocache (NonCache + StrongOrder)
    - ioremap_wc (NonCache + WeakOrder )
    - ioremap_cache ( Cache + WeakOrder )

    Also change flag VM_ALLOC to VM_IOREMAP in get_vm_area_caller.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann
    Cc: Christoph Hellwig

    Guo Ren
     

06 Aug, 2019

2 commits

  • DMA_FROM_DEVICE only need to read dma data of memory into CPU cache,
    so there is no need to clear cache before. Also clear + inv for
    DMA_FROM_DEVICE won't cause problem, because the memory range for dma
    won't be touched by software during dma working.

    Changes for V2:
    - Remove clr cache and ignore the DMA_TO_DEVICE in _for_cpu.
    - Change inv to wbinv cache with DMA_FROM_DEVICE in _for_device.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • If the paddr and size are cross between NORMAL_ZONE and HIGHMEM_ZONE
    memory range, cache_op will panic in do_page_fault with bad_area.

    Optimize the code to support the range which cross memory ZONEs.

    Changes for V2:
    - Revert back to postcore_initcall

    Signed-off-by: Guo Ren
    Cc: Christoph Hellwig
    Cc: Arnd Bergmann

    Guo Ren
     

31 Jul, 2019

2 commits

  • This bug is from commit: 2b070ccdf8c0 (fixup abiv2 mmap(... O_SYNC)
    failed). In that patch we remove the _PAGE_SO for memory noncache
    mapping and this will cause problem when drivers use dma descriptors
    to control the transcations without dma_w/rmb().

    After referencing other archs' implementation, pgprot_writecombine is
    introduced for mmap(... O_SYNC).

    Signed-off-by: Guo Ren

    Guo Ren
     
  • The mb() is the superset of dma and smp. Using bar.xxx to implement
    mb() will cause problem when sync data with dma device, becasue
    bar.xxx couldn't guarantee bus transactions finished at outside bus
    level.

    We must use sync.s instead of bar.xxx for dma data synchronization
    and it will guarantee retirement after getting the bus bresponse.

    Changes for V2:
    - Use sync.s for all mb, rmb, wmb, dma_wmb, dma_rmb.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     

25 Jul, 2019

1 commit

  • UAPI headers licensed under GPL are supposed to have exception
    "WITH Linux-syscall-note" so that they can be included into non-GPL
    user space application code.

    The exception note is missing in some UAPI headers.

    Some of them slipped in by the treewide conversion commit b24413180f56
    ("License cleanup: add SPDX GPL-2.0 license identifier to files with
    no license"). Just run:

    $ git show --oneline b24413180f56 -- arch/x86/include/uapi/asm/

    I believe they are not intentional, and should be fixed too.

    This patch was generated by the following script:

    git grep -l --not -e Linux-syscall-note --and -e SPDX-License-Identifier \
    -- :arch/*/include/uapi/asm/*.h :include/uapi/ :^*/Kbuild |
    while read file
    do
    sed -i -e '/[[:space:]]OR[[:space:]]/s/\(GPL-[^[:space:]]*\)/(\1 WITH Linux-syscall-note)/g' \
    -e '/[[:space:]]or[[:space:]]/s/\(GPL-[^[:space:]]*\)/(\1 WITH Linux-syscall-note)/g' \
    -e '/[[:space:]]OR[[:space:]]/!{/[[:space:]]or[[:space:]]/!s/\(GPL-[^[:space:]]*\)/\1 WITH Linux-syscall-note/g}' $file
    done

    After this patch is applied, there are 5 UAPI headers that do not contain
    "WITH Linux-syscall-note". They are kept untouched since this exception
    applies only to GPL variants.

    $ git grep --not -e Linux-syscall-note --and -e SPDX-License-Identifier \
    -- :arch/*/include/uapi/asm/*.h :include/uapi/ :^*/Kbuild
    include/uapi/drm/panfrost_drm.h:/* SPDX-License-Identifier: MIT */
    include/uapi/linux/batman_adv.h:/* SPDX-License-Identifier: MIT */
    include/uapi/linux/qemu_fw_cfg.h:/* SPDX-License-Identifier: BSD-3-Clause */
    include/uapi/linux/vbox_err.h:/* SPDX-License-Identifier: MIT */
    include/uapi/linux/virtio_iommu.h:/* SPDX-License-Identifier: BSD-3-Clause */

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Masahiro Yamada
     

20 Jul, 2019

1 commit

  • Pull arch/csky pupdates from Guo Ren:
    "This round of csky subsystem gives two features (ASID algorithm
    update, Perf pmu record support) and some fixups.

    ASID updates:
    - Revert mmu ASID mechanism
    - Add new asid lib code from arm
    - Use generic asid algorithm to implement switch_mm
    - Improve tlb operation with help of asid

    Perf pmu record support:
    - Init pmu as a device
    - Add count-width property for csky pmu
    - Add pmu interrupt support
    - Fix perf record in kernel/user space
    - dt-bindings: Add csky PMU bindings

    Fixes:
    - Fixup no panic in kernel for some traps
    - Fixup some error count in 810 & 860.
    - Fixup abiv1 memset error"

    * tag 'csky-for-linus-5.3-rc1' of git://github.com/c-sky/csky-linux:
    csky: Fixup abiv1 memset error
    csky: Improve tlb operation with help of asid
    csky: Use generic asid algorithm to implement switch_mm
    csky: Add new asid lib code from arm
    csky: Revert mmu ASID mechanism
    dt-bindings: csky: Add csky PMU bindings
    dt-bindings: interrupt-controller: Update csky mpintc
    csky: Fixup some error count in 810 & 860.
    csky: Fix perf record in kernel/user space
    csky: Add pmu interrupt support
    csky: Add count-width property for csky pmu
    csky: Init pmu as a device
    csky: Fixup no panic in kernel for some traps
    csky: Select intc & timer drivers

    Linus Torvalds
     

19 Jul, 2019

2 commits

  • Current memset implementation in abiv1 is wrong and it'll cause unalign
    access. Just remove it and use the generic one. This patch will cause
    performance degradation and we will improve it with a new design in next
    patchset.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren
     
  • There are two generations of tlb operation instruction for C-SKY.
    First generation is use mcr register and it need software do more
    things, second generation is use specific instructions, eg:
    tlbi.va, tlbi.vas, tlbi.alls

    We implemented the following functions:

    - flush_tlb_range (a range of entries)
    - flush_tlb_page (one entry)

    Above functions use asid from vma->mm to invalid tlb entries and
    we could use tlbi.vas instruction for newest generation csky cpu.

    - flush_tlb_kernel_range
    - flush_tlb_one

    Above functions don't care asid and it invalid the tlb entries only
    with vpn and we could use tlbi.vaas instruction for newest generat-
    ion csky cpu.

    Signed-off-by: Guo Ren
    Cc: Arnd Bergmann

    Guo Ren