Skip to content

Commit

Permalink
Merge tag 'csky-for-linus-5.12-rc1' of git://github.com/c-sky/csky-linux
Browse files Browse the repository at this point in the history
Pull arch/csky updates from Guo Ren:
 "Features:
   - add new memory layout 2.5G(user):1.5G(kernel)
   - add kmemleak support
   - reconstruct VDSO framework: add VDSO with GENERIC_GETTIMEOFDAY,
     GENERIC_TIME_VSYSCALL, HAVE_GENERIC_VDSO
   - add faulthandler_disabled() check
   - support (fix) swapon
   - add (fix) _PAGE_ACCESSED for default pgprot
   - abort uaccess retries upon fatal signal (from arm)

  Fixes and optimizations:
   - fix perf probe failure
   - fix show_regs doesn't contain regs->usp
   - remove custom asm/atomic.h implementation
   - fix barrier design
   - fix futex SMP implementation
   - fix asm/cmpxchg.h with correct ordering barrier
   - cleanup asm/spinlock.h
   - fix PTE global for 2.5:1.5 virtual memory
   - remove prologue of page fault handler in entry.S
   - fix TLB maintenance synchronization problem
   - add show_tlb for CPU_CK860 debug
   - fix FAULT_FLAG_XXX param for handle_mm_fault
   - fix update_mmu_cache called with user io mapping
   - fix do_page_fault parent irq status
   - fix a size determination in gpr_get()
   - pgtable.h: Coding convention
   - kprobe: Fix code in simulate without 'long'
   - fix pfn_valid error with wrong max_mapnr
   - use free_initmem_default() in free_initmem()
   - fix compile error"

* tag 'csky-for-linus-5.12-rc1' of git://github.com/c-sky/csky-linux: (30 commits)
  csky: Fixup compile error
  csky: use free_initmem_default() in free_initmem()
  csky: Fixup pfn_valid error with wrong max_mapnr
  csky: Add VDSO with GENERIC_GETTIMEOFDAY, GENERIC_TIME_VSYSCALL, HAVE_GENERIC_VDSO
  csky: kprobe: Fixup code in simulate without 'long'
  csky: Fixup swapon
  csky: pgtable.h: Coding convention
  csky: Fixup _PAGE_ACCESSED for default pgprot
  csky: remove unused including <linux/version.h>
  csky: Fix a size determination in gpr_get()
  csky: Reconstruct VDSO framework
  csky: mm: abort uaccess retries upon fatal signal
  csky: Sync riscv mm/fault.c for easy maintenance
  csky: Fixup do_page_fault parent irq status
  csky: Add faulthandler_disabled() check
  csky: Fixup update_mmu_cache called with user io mapping
  csky: Fixup FAULT_FLAG_XXX param for handle_mm_fault
  csky: Add show_tlb for CPU_CK860 debug
  csky: Fix TLB maintenance synchronization problem
  csky: Add kmemleak support
  ...
  • Loading branch information
torvalds committed Feb 28, 2021
2 parents 7d19ea5 + 6607aa6 commit cd27845
Show file tree
Hide file tree
Showing 94 changed files with 1,347 additions and 992 deletions.
24 changes: 23 additions & 1 deletion arch/csky/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ config CSKY
select ARCH_HAS_SYNC_DMA_FOR_CPU
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_QUEUED_RWLOCKS if NR_CPUS>2
select ARCH_USE_QUEUED_RWLOCKS
select ARCH_WANT_FRAME_POINTERS if !CPU_CK610
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
select COMMON_CLK
Expand Down Expand Up @@ -35,6 +35,9 @@ config CSKY
select GENERIC_IRQ_MULTI_HANDLER
select GENERIC_SCHED_CLOCK
select GENERIC_SMP_IDLE_THREAD
select GENERIC_TIME_VSYSCALL
select GENERIC_VDSO_32
select GENERIC_GETTIMEOFDAY
select GX6605S_TIMER if CPU_CK610
select HAVE_ARCH_TRACEHOOK
select HAVE_ARCH_AUDITSYSCALL
Expand All @@ -43,11 +46,14 @@ config CSKY
select HAVE_CONTEXT_TRACKING
select HAVE_VIRT_CPU_ACCOUNTING_GEN
select HAVE_DEBUG_BUGVERBOSE
select HAVE_DEBUG_KMEMLEAK
select HAVE_DYNAMIC_FTRACE
select HAVE_DYNAMIC_FTRACE_WITH_REGS
select HAVE_GENERIC_VDSO
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FUNCTION_ERROR_INJECTION
select HAVE_FUTEX_CMPXCHG if FUTEX && SMP
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
Expand Down Expand Up @@ -192,6 +198,22 @@ config CPU_CK860
endchoice

choice
prompt "PAGE OFFSET"
default PAGE_OFFSET_80000000

config PAGE_OFFSET_80000000
bool "PAGE OFFSET 2G (user:kernel = 2:2)"

config PAGE_OFFSET_A0000000
bool "PAGE OFFSET 2.5G (user:kernel = 2.5:1.5)"
endchoice

config PAGE_OFFSET
hex
default 0x80000000 if PAGE_OFFSET_80000000
default 0xa0000000 if PAGE_OFFSET_A0000000
choice

prompt "C-SKY PMU type"
depends on PERF_EVENTS
depends on CPU_CK807 || CPU_CK810 || CPU_CK860
Expand Down
1 change: 0 additions & 1 deletion arch/csky/abiv1/inc/abi/cacheflush.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ABI_CSKY_CACHEFLUSH_H
#define __ABI_CSKY_CACHEFLUSH_H
Expand Down
10 changes: 5 additions & 5 deletions arch/csky/abiv1/inc/abi/ckmmu.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_CKMMUV1_H
#define __ASM_CSKY_CKMMUV1_H
Expand Down Expand Up @@ -89,13 +88,14 @@ static inline void tlb_invalid_indexed(void)
cpwcr("cpcr8", 0x02000000);
}

static inline void setup_pgd(unsigned long pgd, bool kernel)
static inline void setup_pgd(pgd_t *pgd, int asid)
{
cpwcr("cpcr29", pgd | BIT(0));
cpwcr("cpcr29", __pa(pgd) | BIT(0));
write_mmu_entryhi(asid);
}

static inline unsigned long get_pgd(void)
static inline pgd_t *get_pgd(void)
{
return cprcr("cpcr29") & ~BIT(0);
return __va(cprcr("cpcr29") & ~BIT(0));
}
#endif /* __ASM_CSKY_CKMMUV1_H */
1 change: 0 additions & 1 deletion arch/csky/abiv1/inc/abi/entry.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_ENTRY_H
#define __ASM_CSKY_ENTRY_H
Expand Down
1 change: 0 additions & 1 deletion arch/csky/abiv1/inc/abi/page.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#include <asm/shmparam.h>

Expand Down
40 changes: 26 additions & 14 deletions arch/csky/abiv1/inc/abi/pgtable-bits.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,49 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_PGTABLE_BITS_H
#define __ASM_CSKY_PGTABLE_BITS_H

/* implemented in software */
#define _PAGE_ACCESSED (1<<3)
#define PAGE_ACCESSED_BIT (3)

#define _PAGE_PRESENT (1<<0)
#define _PAGE_READ (1<<1)
#define _PAGE_WRITE (1<<2)
#define _PAGE_PRESENT (1<<0)

#define _PAGE_ACCESSED (1<<3)
#define _PAGE_MODIFIED (1<<4)
#define PAGE_MODIFIED_BIT (4)

/* implemented in hardware */
#define _PAGE_GLOBAL (1<<6)

#define _PAGE_VALID (1<<7)
#define PAGE_VALID_BIT (7)

#define _PAGE_DIRTY (1<<8)
#define PAGE_DIRTY_BIT (8)

#define _PAGE_CACHE (3<<9)
#define _PAGE_UNCACHE (2<<9)
#define _PAGE_SO _PAGE_UNCACHE

#define _CACHE_MASK (7<<9)

#define _CACHE_CACHED (_PAGE_VALID | _PAGE_CACHE)
#define _CACHE_UNCACHED (_PAGE_VALID | _PAGE_UNCACHE)
#define _CACHE_CACHED _PAGE_CACHE
#define _CACHE_UNCACHED _PAGE_UNCACHE

#define _PAGE_PROT_NONE _PAGE_READ

/*
* Encode and decode a swap entry
*
* Format of swap PTE:
* bit 0: _PAGE_PRESENT (zero)
* bit 1: _PAGE_READ (zero)
* bit 2 - 5: swap type[0 - 3]
* bit 6: _PAGE_GLOBAL (zero)
* bit 7: _PAGE_VALID (zero)
* bit 8: swap type[4]
* bit 9 - 31: swap offset
*/
#define __swp_type(x) ((((x).val >> 2) & 0xf) | \
(((x).val >> 4) & 0x10))
#define __swp_offset(x) ((x).val >> 9)
#define __swp_entry(type, offset) ((swp_entry_t) { \
((type & 0xf) << 2) | \
((type & 0x10) << 4) | \
((offset) << 9)})

#define HAVE_ARCH_UNMAPPED_AREA

Expand Down
1 change: 0 additions & 1 deletion arch/csky/abiv1/inc/abi/reg_ops.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ABI_REG_OPS_H
#define __ABI_REG_OPS_H
Expand Down
6 changes: 5 additions & 1 deletion arch/csky/abiv1/inc/abi/regdef.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_REGDEF_H
#define __ASM_CSKY_REGDEF_H

#ifdef __ASSEMBLY__
#define syscallid r1
#else
#define syscallid "r1"
#endif

#define regs_syscallid(regs) regs->regs[9]
#define regs_fp(regs) regs->regs[2]

Expand Down
1 change: 0 additions & 1 deletion arch/csky/abiv1/inc/abi/string.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ABI_CSKY_STRING_H
#define __ABI_CSKY_STRING_H
Expand Down
1 change: 0 additions & 1 deletion arch/csky/abiv1/inc/abi/switch_context.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ABI_CSKY_PTRACE_H
#define __ABI_CSKY_PTRACE_H
Expand Down
18 changes: 5 additions & 13 deletions arch/csky/abiv1/inc/abi/vdso.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0 */

#include <linux/uaccess.h>
#ifndef __ABI_CSKY_VDSO_H
#define __ABI_CSKY_VDSO_H

static inline int setup_vdso_page(unsigned short *ptr)
{
int err = 0;
/* movi r1, 127; addi r1, (139 - 127) */
#define SET_SYSCALL_ID .long 0x20b167f1

/* movi r1, 127 */
err |= __put_user(0x67f1, ptr + 0);
/* addi r1, (139 - 127) */
err |= __put_user(0x20b1, ptr + 1);
/* trap 0 */
err |= __put_user(0x0008, ptr + 2);

return err;
}
#endif /* __ABI_CSKY_VDSO_H */
3 changes: 3 additions & 0 deletions arch/csky/abiv2/cacheflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
unsigned long addr;
struct page *page;

if (!pfn_valid(pte_pfn(*pte)))
return;

page = pfn_to_page(pte_pfn(*pte));
if (page == ZERO_PAGE(0))
return;
Expand Down
44 changes: 34 additions & 10 deletions arch/csky/abiv2/inc/abi/ckmmu.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_CKMMUV2_H
#define __ASM_CSKY_CKMMUV2_H
Expand Down Expand Up @@ -78,8 +77,13 @@ static inline void tlb_read(void)
static inline void tlb_invalid_all(void)
{
#ifdef CONFIG_CPU_HAS_TLBI
asm volatile("tlbi.alls\n":::"memory");
sync_is();
asm volatile(
"tlbi.alls \n"
"sync.i \n"
:
:
: "memory");
#else
mtcr("cr<8, 15>", 0x04000000);
#endif
Expand All @@ -88,8 +92,13 @@ static inline void tlb_invalid_all(void)
static inline void local_tlb_invalid_all(void)
{
#ifdef CONFIG_CPU_HAS_TLBI
asm volatile("tlbi.all\n":::"memory");
sync_is();
asm volatile(
"tlbi.all \n"
"sync.i \n"
:
:
: "memory");
#else
tlb_invalid_all();
#endif
Expand All @@ -100,16 +109,31 @@ static inline void tlb_invalid_indexed(void)
mtcr("cr<8, 15>", 0x02000000);
}

static inline void setup_pgd(unsigned long pgd, bool kernel)
#define NOP32 ".long 0x4820c400\n"

static inline void setup_pgd(pgd_t *pgd, int asid)
{
if (kernel)
mtcr("cr<28, 15>", pgd | BIT(0));
else
mtcr("cr<29, 15>", pgd | BIT(0));
#ifdef CONFIG_CPU_HAS_TLBI
sync_is();
#else
mb();
#endif
asm volatile(
#ifdef CONFIG_CPU_HAS_TLBI
"mtcr %1, cr<28, 15> \n"
#endif
"mtcr %1, cr<29, 15> \n"
"mtcr %0, cr< 4, 15> \n"
".rept 64 \n"
NOP32
".endr \n"
:
:"r"(asid), "r"(__pa(pgd) | BIT(0))
:"memory");
}

static inline unsigned long get_pgd(void)
static inline pgd_t *get_pgd(void)
{
return mfcr("cr<29, 15>") & ~BIT(0);
return __va(mfcr("cr<29, 15>") & ~BIT(0));
}
#endif /* __ASM_CSKY_CKMMUV2_H */
20 changes: 16 additions & 4 deletions arch/csky/abiv2/inc/abi/entry.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_ENTRY_H
#define __ASM_CSKY_ENTRY_H
Expand All @@ -26,6 +25,9 @@
stw tls, (sp, 0)
stw lr, (sp, 4)

RD_MEH lr
WR_MEH lr

mfcr lr, epc
movi tls, \epc_inc
add lr, tls
Expand Down Expand Up @@ -231,6 +233,16 @@
mtcr \rx, cr<8, 15>
.endm

#ifdef CONFIG_PAGE_OFFSET_80000000
#define MSA_SET cr<30, 15>
#define MSA_CLR cr<31, 15>
#endif

#ifdef CONFIG_PAGE_OFFSET_A0000000
#define MSA_SET cr<31, 15>
#define MSA_CLR cr<30, 15>
#endif

.macro SETUP_MMU
/* Init psr and enable ee */
lrw r6, DEFAULT_PSR_VALUE
Expand Down Expand Up @@ -281,15 +293,15 @@
* 31 - 29 | 28 - 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
* BA Reserved SH WA B SO SEC C D V
*/
mfcr r6, cr<30, 15> /* Get MSA0 */
mfcr r6, MSA_SET /* Get MSA */
2:
lsri r6, 29
lsli r6, 29
addi r6, 0x1ce
mtcr r6, cr<30, 15> /* Set MSA0 */
mtcr r6, MSA_SET /* Set MSA */

movi r6, 0
mtcr r6, cr<31, 15> /* Clr MSA1 */
mtcr r6, MSA_CLR /* Clr MSA */

/* enable MMU */
mfcr r6, cr18
Expand Down
1 change: 0 additions & 1 deletion arch/csky/abiv2/inc/abi/fpu.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_FPU_H
#define __ASM_CSKY_FPU_H
Expand Down
1 change: 0 additions & 1 deletion arch/csky/abiv2/inc/abi/page.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

static inline void clear_user_page(void *addr, unsigned long vaddr,
struct page *page)
Expand Down
Loading

0 comments on commit cd27845

Please sign in to comment.