Skip to content

Commit

Permalink
Merge tag 'csky-for-linus-5.2-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:

 - Fixup vdsp&fpu issues in kernel

 - Add dynamic function tracer

 - Use in_syscall & forget_syscall instead of r11_sig

 - Reconstruct signal processing

 - Support dynamic start physical address

 - Fixup wrong update_mmu_cache implementation

 - Support vmlinux bootup with MMU off

 - Use va_pa_offset instead of phys_offset

 - Fixup syscall_trace return processing flow

 - Add perf callchain support

 - Add perf_arch_fetch_caller_regs support

 - Add page fault perf event support

 - Add support for perf registers sampling

* tag 'csky-for-linus-5.2-rc1' of git://github.com/c-sky/csky-linux:
  csky/syscall_trace: Fixup return processing flow
  csky: Fixup compile warning
  csky: Add support for perf registers sampling
  csky: add page fault perf event support
  csky: Use va_pa_offset instead of phys_offset
  csky: Support vmlinux bootup with MMU off
  csky: Add perf_arch_fetch_caller_regs support
  csky: Fixup wrong update_mmu_cache implementation
  csky: Support dynamic start physical address
  csky: Reconstruct signal processing
  csky: Use in_syscall & forget_syscall instead of r11_sig
  csky: Add non-uapi asm/ptrace.h namespace
  csky: mm/fault.c: Remove duplicate header
  csky: remove redundant generic-y
  csky: Update syscall_trace_enter/exit implementation
  csky: Add perf callchain support
  csky/ftrace: Add dynamic function tracer (include graph tracer)
  csky: Fixup vdsp&fpu issues in kernel
  • Loading branch information
Linus Torvalds committed May 8, 2019
2 parents e7a1414 + a691f33 commit ce45327
Show file tree
Hide file tree
Showing 34 changed files with 890 additions and 502 deletions.
7 changes: 6 additions & 1 deletion arch/csky/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ config CSKY
select GENERIC_SCHED_CLOCK
select GENERIC_SMP_IDLE_THREAD
select HAVE_ARCH_TRACEHOOK
select HAVE_ARCH_AUDITSYSCALL
select HAVE_DYNAMIC_FTRACE
select HAVE_FUNCTION_TRACER
select HAVE_FUNCTION_GRAPH_TRACER
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZO
select HAVE_KERNEL_LZMA
select HAVE_PERF_EVENTS
select HAVE_C_RECORDMCOUNT
select HAVE_PERF_REGS
select HAVE_PERF_USER_STACK_DUMP
select HAVE_DMA_API_DEBUG
select HAVE_DMA_CONTIGUOUS
select HAVE_SYSCALL_TRACEPOINTS
select MAY_HAVE_SPARSE_IRQ
select MODULES_USE_ELF_RELA if MODULES
select OF
Expand Down
2 changes: 1 addition & 1 deletion arch/csky/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ endif

ifneq ($(CSKYABI),)
MCPU_STR = $(CPUTYPE)$(FPUEXT)$(VDSPEXT)$(TEEEXT)
KBUILD_CFLAGS += -mcpu=$(MCPU_STR)
KBUILD_CFLAGS += -mcpu=$(CPUTYPE) -Wa,-mcpu=$(MCPU_STR)
KBUILD_CFLAGS += -DCSKYCPU_DEF_NAME=\"$(MCPU_STR)\"
KBUILD_CFLAGS += -msoft-float -mdiv
KBUILD_CFLAGS += -fno-tree-vectorize
Expand Down
24 changes: 22 additions & 2 deletions arch/csky/abiv1/inc/abi/ckmmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ static inline void write_mmu_entryhi(int value)
cpwcr("cpcr4", value);
}

static inline unsigned long read_mmu_msa0(void)
{
return cprcr("cpcr30");
}

static inline void write_mmu_msa0(unsigned long value)
{
cpwcr("cpcr30", value);
}

static inline unsigned long read_mmu_msa1(void)
{
return cprcr("cpcr31");
}

static inline void write_mmu_msa1(unsigned long value)
{
cpwcr("cpcr31", value);
}

/*
* TLB operations.
*/
Expand All @@ -65,11 +85,11 @@ static inline void tlb_invalid_indexed(void)

static inline void setup_pgd(unsigned long pgd, bool kernel)
{
cpwcr("cpcr29", pgd);
cpwcr("cpcr29", pgd | BIT(0));
}

static inline unsigned long get_pgd(void)
{
return cprcr("cpcr29");
return cprcr("cpcr29") & ~BIT(0);
}
#endif /* __ASM_CSKY_CKMMUV1_H */
41 changes: 29 additions & 12 deletions arch/csky/abiv1/inc/abi/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
#define LSAVE_A4 40
#define LSAVE_A5 44

#define EPC_INCREASE 2
#define EPC_KEEP 0

.macro USPTOKSP
mtcr sp, ss1
mfcr sp, ss0
Expand All @@ -29,10 +26,6 @@
mfcr sp, ss1
.endm

.macro INCTRAP rx
addi \rx, EPC_INCREASE
.endm

.macro SAVE_ALL epc_inc
mtcr r13, ss2
mfcr r13, epsr
Expand Down Expand Up @@ -150,11 +143,35 @@
cpwcr \rx, cpcr8
.endm

.macro SETUP_MMU rx
lrw \rx, PHYS_OFFSET | 0xe
cpwcr \rx, cpcr30
lrw \rx, (PHYS_OFFSET + 0x20000000) | 0xe
cpwcr \rx, cpcr31
.macro SETUP_MMU
/* Init psr and enable ee */
lrw r6, DEFAULT_PSR_VALUE
mtcr r6, psr
psrset ee

/* Select MMU as co-processor */
cpseti cp15

/*
* cpcr30 format:
* 31 - 29 | 28 - 4 | 3 | 2 | 1 | 0
* BA Reserved C D V
*/
cprcr r6, cpcr30
lsri r6, 28
lsli r6, 28
addi r6, 0xe
cpwcr r6, cpcr30

lsri r6, 28
addi r6, 2
lsli r6, 28
addi r6, 0xe
cpwcr r6, cpcr31
.endm

.macro ANDI_R3 rx, imm
lsri \rx, 3
andi \rx, (\imm >> 3)
.endm
#endif /* __ASM_CSKY_ENTRY_H */
5 changes: 3 additions & 2 deletions arch/csky/abiv1/inc/abi/regdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#define __ASM_CSKY_REGDEF_H

#define syscallid r1
#define r11_sig r11

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

/*
* PSR format:
Expand All @@ -23,4 +22,6 @@

#define SYSTRACE_SAVENUM 2

#define TRAP0_SIZE 2

#endif /* __ASM_CSKY_REGDEF_H */
13 changes: 2 additions & 11 deletions arch/csky/abiv2/cacheflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
{
unsigned long addr, pfn;
struct page *page;
void *va;

if (!(vma->vm_flags & VM_EXEC))
return;

pfn = pte_pfn(*pte);
if (unlikely(!pfn_valid(pfn)))
Expand All @@ -47,14 +43,9 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
if (page == ZERO_PAGE(0))
return;

va = page_address(page);
addr = (unsigned long) va;

if (va == NULL && PageHighMem(page))
addr = (unsigned long) kmap_atomic(page);
addr = (unsigned long) kmap_atomic(page);

cache_wbinv_range(addr, addr + PAGE_SIZE);

if (va == NULL && PageHighMem(page))
kunmap_atomic((void *) addr);
kunmap_atomic((void *) addr);
}
34 changes: 26 additions & 8 deletions arch/csky/abiv2/inc/abi/ckmmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ static inline void write_mmu_entryhi(int value)
mtcr("cr<4, 15>", value);
}

static inline unsigned long read_mmu_msa0(void)
{
return mfcr("cr<30, 15>");
}

static inline void write_mmu_msa0(unsigned long value)
{
mtcr("cr<30, 15>", value);
}

static inline unsigned long read_mmu_msa1(void)
{
return mfcr("cr<31, 15>");
}

static inline void write_mmu_msa1(unsigned long value)
{
mtcr("cr<31, 15>", value);
}

/*
* TLB operations.
*/
Expand Down Expand Up @@ -70,18 +90,16 @@ static inline void tlb_invalid_indexed(void)
mtcr("cr<8, 15>", 0x02000000);
}

/* setup hardrefil pgd */
static inline unsigned long get_pgd(void)
{
return mfcr("cr<29, 15>");
}

static inline void setup_pgd(unsigned long pgd, bool kernel)
{
if (kernel)
mtcr("cr<28, 15>", pgd);
mtcr("cr<28, 15>", pgd | BIT(0));
else
mtcr("cr<29, 15>", pgd);
mtcr("cr<29, 15>", pgd | BIT(0));
}

static inline unsigned long get_pgd(void)
{
return mfcr("cr<29, 15>") & ~BIT(0);
}
#endif /* __ASM_CSKY_CKMMUV2_H */
87 changes: 75 additions & 12 deletions arch/csky/abiv2/inc/abi/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@
#define LSAVE_A2 32
#define LSAVE_A3 36

#define EPC_INCREASE 4
#define EPC_KEEP 0

#define KSPTOUSP
#define USPTOKSP

#define usp cr<14, 1>

.macro INCTRAP rx
addi \rx, EPC_INCREASE
.endm

.macro SAVE_ALL epc_inc
subi sp, 152
stw tls, (sp, 0)
Expand Down Expand Up @@ -169,10 +162,80 @@
mtcr \rx, cr<8, 15>
.endm

.macro SETUP_MMU rx
lrw \rx, PHYS_OFFSET | 0xe
mtcr \rx, cr<30, 15>
lrw \rx, (PHYS_OFFSET + 0x20000000) | 0xe
mtcr \rx, cr<31, 15>
.macro SETUP_MMU
/* Init psr and enable ee */
lrw r6, DEFAULT_PSR_VALUE
mtcr r6, psr
psrset ee

/* Invalid I/Dcache BTB BHT */
movi r6, 7
lsli r6, 16
addi r6, (1<<4) | 3
mtcr r6, cr17

/* Invalid all TLB */
bgeni r6, 26
mtcr r6, cr<8, 15> /* Set MCIR */

/* Check MMU on/off */
mfcr r6, cr18
btsti r6, 0
bt 1f

/* MMU off: setup mapping tlb entry */
movi r6, 0
mtcr r6, cr<6, 15> /* Set MPR with 4K page size */

grs r6, 1f /* Get current pa by PC */
bmaski r7, (PAGE_SHIFT + 1) /* r7 = 0x1fff */
andn r6, r7
mtcr r6, cr<4, 15> /* Set MEH */

mov r8, r6
movi r7, 0x00000006
or r8, r7
mtcr r8, cr<2, 15> /* Set MEL0 */
movi r7, 0x00001006
or r8, r7
mtcr r8, cr<3, 15> /* Set MEL1 */

bgeni r8, 28
mtcr r8, cr<8, 15> /* Set MCIR to write TLB */

br 2f
1:
/*
* MMU on: use origin MSA value from bootloader
*
* cr<30/31, 15> 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
*/
mfcr r6, cr<30, 15> /* Get MSA0 */
2:
lsri r6, 28
lsli r6, 28
addi r6, 0x1ce
mtcr r6, cr<30, 15> /* Set MSA0 */

lsri r6, 28
addi r6, 2
lsli r6, 28
addi r6, 0x1ce
mtcr r6, cr<31, 15> /* Set MSA1 */

/* enable MMU */
mfcr r6, cr18
bseti r6, 0
mtcr r6, cr18

jmpi 3f /* jump to va */
3:
.endm

.macro ANDI_R3 rx, imm
lsri \rx, 3
andi \rx, (\imm >> 3)
.endm
#endif /* __ASM_CSKY_ENTRY_H */
5 changes: 3 additions & 2 deletions arch/csky/abiv2/inc/abi/regdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#define __ASM_CSKY_REGDEF_H

#define syscallid r7
#define r11_sig r11

#define regs_syscallid(regs) regs->regs[3]
#define regs_fp(regs) regs->regs[4]

/*
* PSR format:
Expand All @@ -23,4 +22,6 @@

#define SYSTRACE_SAVENUM 5

#define TRAP0_SIZE 4

#endif /* __ASM_CSKY_REGDEF_H */
Loading

0 comments on commit ce45327

Please sign in to comment.