Skip to content

Commit 786b71f

Browse files
committed
Merge tag 'nds32-for-linus-4.17-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/greentime/linux
Pull nds32 fixes from Greentime Hu: "Bug fixes and build error fixes for nds32" * tag 'nds32-for-linus-4.17-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/greentime/linux: nds32: Fix compiler warning, Wstringop-overflow, in vdso.c nds32: Disable local irq before calling cpu_dcache_wb_page in copy_user_highpage nds32: Flush the cache of the page at vmaddr instead of kaddr in flush_anon_page nds32: Correct flush_dcache_page function nds32: Fix the unaligned access handler nds32: Renaming the file for unaligned access nds32: To fix a cache inconsistency issue by setting correct cacheability of NTC nds32: To refine readability of INT_MASK_INITAIAL_VAL nds32: Fix the virtual address may map too much range by tlbop issue. nds32: Fix the allmodconfig build. To make sure CONFIG_CPU_LITTLE_ENDIAN is default y nds32: Fix build failed because arch_trace_hardirqs_off is changed to trace_hardirqs_off. nds32: Fix the unknown type u8 issue. nds32: Fix the symbols undefined issue by exporting them. nds32: Fix xfs_buf built failed by export invalidate_kernel_vmap_range and flush_kernel_vmap_range nds32: Fix drivers/gpu/drm/udl/udl_fb.c building error by defining PAGE_SHARED nds32: Fix building error of crypto/xor.c by adding xor.h nds32: Fix building error when CONFIG_FREEZE is enabled. nds32: lib: To use generic lib instead of libgcc to prevent the symbol undefined issue.
2 parents b04e217 + a30e7d1 commit 786b71f

File tree

18 files changed

+130
-34
lines changed

18 files changed

+130
-34
lines changed

arch/nds32/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ config NDS32
99
select CLKSRC_MMIO
1010
select CLONE_BACKWARDS
1111
select COMMON_CLK
12+
select GENERIC_ASHLDI3
13+
select GENERIC_ASHRDI3
14+
select GENERIC_LSHRDI3
15+
select GENERIC_CMPDI2
16+
select GENERIC_MULDI3
17+
select GENERIC_UCMPDI2
1218
select GENERIC_ATOMIC64
1319
select GENERIC_CPU_DEVICES
1420
select GENERIC_CLOCKEVENTS
@@ -82,6 +88,7 @@ endmenu
8288

8389
menu "Kernel Features"
8490
source "kernel/Kconfig.preempt"
91+
source "kernel/Kconfig.freezer"
8592
source "mm/Kconfig"
8693
source "kernel/Kconfig.hz"
8794
endmenu

arch/nds32/Kconfig.cpu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
comment "Processor Features"
22

33
config CPU_BIG_ENDIAN
4-
bool "Big endian"
4+
def_bool !CPU_LITTLE_ENDIAN
55

66
config CPU_LITTLE_ENDIAN
7-
def_bool !CPU_BIG_ENDIAN
7+
bool "Little endian"
8+
default y
89

910
config HWZOL
1011
bool "hardware zero overhead loop support"

arch/nds32/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ export TEXTADDR
2323
# If we have a machine-specific directory, then include it in the build.
2424
core-y += arch/nds32/kernel/ arch/nds32/mm/
2525
libs-y += arch/nds32/lib/
26-
LIBGCC_PATH := \
27-
$(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name)
28-
libs-y += $(LIBGCC_PATH)
2926

3027
ifneq '$(CONFIG_NDS32_BUILTIN_DTB)' '""'
3128
BUILTIN_DTB := y
@@ -35,8 +32,12 @@ endif
3532

3633
ifdef CONFIG_CPU_LITTLE_ENDIAN
3734
KBUILD_CFLAGS += $(call cc-option, -EL)
35+
KBUILD_AFLAGS += $(call cc-option, -EL)
36+
LDFLAGS += $(call cc-option, -EL)
3837
else
3938
KBUILD_CFLAGS += $(call cc-option, -EB)
39+
KBUILD_AFLAGS += $(call cc-option, -EB)
40+
LDFLAGS += $(call cc-option, -EB)
4041
endif
4142

4243
boot := arch/nds32/boot

arch/nds32/include/asm/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ generic-y += dma.h
1616
generic-y += emergency-restart.h
1717
generic-y += errno.h
1818
generic-y += exec.h
19+
generic-y += export.h
1920
generic-y += fb.h
2021
generic-y += fcntl.h
2122
generic-y += ftrace.h
@@ -49,6 +50,7 @@ generic-y += switch_to.h
4950
generic-y += timex.h
5051
generic-y += topology.h
5152
generic-y += trace_clock.h
53+
generic-y += xor.h
5254
generic-y += unaligned.h
5355
generic-y += user.h
5456
generic-y += vga.h

arch/nds32/include/asm/bitfield.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@
336336
#define INT_MASK_mskIDIVZE ( 0x1 << INT_MASK_offIDIVZE )
337337
#define INT_MASK_mskDSSIM ( 0x1 << INT_MASK_offDSSIM )
338338

339-
#define INT_MASK_INITAIAL_VAL 0x10003
339+
#define INT_MASK_INITAIAL_VAL (INT_MASK_mskDSSIM|INT_MASK_mskIDIVZE)
340340

341341
/******************************************************************************
342342
* ir15: INT_PEND (Interrupt Pending Register)
@@ -396,6 +396,7 @@
396396
#define MMU_CTL_D8KB 1
397397
#define MMU_CTL_UNA ( 0x1 << MMU_CTL_offUNA )
398398

399+
#define MMU_CTL_CACHEABLE_NON 0
399400
#define MMU_CTL_CACHEABLE_WB 2
400401
#define MMU_CTL_CACHEABLE_WT 3
401402

arch/nds32/include/asm/cacheflush.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void flush_anon_page(struct vm_area_struct *vma,
3232

3333
#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
3434
void flush_kernel_dcache_page(struct page *page);
35+
void flush_kernel_vmap_range(void *addr, int size);
36+
void invalidate_kernel_vmap_range(void *addr, int size);
3537
void flush_icache_range(unsigned long start, unsigned long end);
3638
void flush_icache_page(struct vm_area_struct *vma, struct page *page);
3739
#define flush_dcache_mmap_lock(mapping) xa_lock_irq(&(mapping)->i_pages)

arch/nds32/include/asm/io.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef __ASM_NDS32_IO_H
55
#define __ASM_NDS32_IO_H
66

7+
#include <linux/types.h>
8+
79
extern void iounmap(volatile void __iomem *addr);
810
#define __raw_writeb __raw_writeb
911
static inline void __raw_writeb(u8 val, volatile void __iomem *addr)

arch/nds32/include/asm/page.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ extern void copy_user_highpage(struct page *to, struct page *from,
2727
unsigned long vaddr, struct vm_area_struct *vma);
2828
extern void clear_user_highpage(struct page *page, unsigned long vaddr);
2929

30+
void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
31+
struct page *to);
32+
void clear_user_page(void *addr, unsigned long vaddr, struct page *page);
3033
#define __HAVE_ARCH_COPY_USER_HIGHPAGE
3134
#define clear_user_highpage clear_user_highpage
3235
#else

arch/nds32/include/asm/pgtable.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val);
152152
#define PAGE_CACHE_L1 __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE)
153153
#define PAGE_MEMORY __pgprot(_HAVE_PAGE_L | _PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD)
154154
#define PAGE_KERNEL __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_E | _PAGE_G | _PAGE_CACHE_SHRD)
155+
#define PAGE_SHARED __pgprot(_PAGE_V | _PAGE_M_URW_KRW | _PAGE_D | _PAGE_CACHE_SHRD)
155156
#define PAGE_DEVICE __pgprot(_PAGE_V | _PAGE_M_KRW | _PAGE_D | _PAGE_G | _PAGE_C_DEV)
156157
#endif /* __ASSEMBLY__ */
157158

arch/nds32/kernel/ex-entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ common_exception_handler:
118118
/* interrupt */
119119
2:
120120
#ifdef CONFIG_TRACE_IRQFLAGS
121-
jal arch_trace_hardirqs_off
121+
jal trace_hardirqs_off
122122
#endif
123123
move $r0, $sp
124124
sethi $lp, hi20(ret_from_intr)

arch/nds32/kernel/head.S

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,32 @@ _nodtb:
5757
isb
5858
mtsr $r4, $L1_PPTB ! load page table pointer\n"
5959

60-
/* set NTC0 cacheable/writeback, mutliple page size in use */
60+
#ifdef CONFIG_CPU_DCACHE_DISABLE
61+
#define MMU_CTL_NTCC MMU_CTL_CACHEABLE_NON
62+
#else
63+
#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
64+
#define MMU_CTL_NTCC MMU_CTL_CACHEABLE_WT
65+
#else
66+
#define MMU_CTL_NTCC MMU_CTL_CACHEABLE_WB
67+
#endif
68+
#endif
69+
70+
/* set NTC cacheability, mutliple page size in use */
6171
mfsr $r3, $MMU_CTL
62-
li $r0, #~MMU_CTL_mskNTC0
63-
and $r3, $r3, $r0
72+
#if CONFIG_MEMORY_START >= 0xc0000000
73+
ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC3)
74+
#elif CONFIG_MEMORY_START >= 0x80000000
75+
ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC2)
76+
#elif CONFIG_MEMORY_START >= 0x40000000
77+
ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC1)
78+
#else
79+
ori $r3, $r3, (MMU_CTL_NTCC << MMU_CTL_offNTC0)
80+
#endif
81+
6482
#ifdef CONFIG_ANDES_PAGE_SIZE_4KB
65-
ori $r3, $r3, #(MMU_CTL_mskMPZIU|(MMU_CTL_CACHEABLE_WB << MMU_CTL_offNTC0))
83+
ori $r3, $r3, #(MMU_CTL_mskMPZIU)
6684
#else
67-
ori $r3, $r3, #(MMU_CTL_mskMPZIU|(MMU_CTL_CACHEABLE_WB << MMU_CTL_offNTC0)|MMU_CTL_D8KB)
85+
ori $r3, $r3, #(MMU_CTL_mskMPZIU|MMU_CTL_D8KB)
6886
#endif
6987
#ifdef CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS
7088
li $r0, #MMU_CTL_UNA

arch/nds32/kernel/setup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ void __init setup_arch(char **cmdline_p)
293293
/* paging_init() sets up the MMU and marks all pages as reserved */
294294
paging_init();
295295

296+
/* invalidate all TLB entries because the new mapping is created */
297+
__nds32__tlbop_flua();
298+
296299
/* use generic way to parse */
297300
parse_early_param();
298301

arch/nds32/kernel/stacktrace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ void save_stack_trace(struct stack_trace *trace)
99
{
1010
save_stack_trace_tsk(current, trace);
1111
}
12+
EXPORT_SYMBOL_GPL(save_stack_trace);
1213

1314
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
1415
{
@@ -45,3 +46,4 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
4546
fpn = (unsigned long *)fpp;
4647
}
4748
}
49+
EXPORT_SYMBOL_GPL(save_stack_trace_tsk);

arch/nds32/kernel/vdso.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <asm/vdso_timer_info.h>
2424
#include <asm/cache_info.h>
2525
extern struct cache_info L1_cache_info[2];
26-
extern char vdso_start, vdso_end;
26+
extern char vdso_start[], vdso_end[];
2727
static unsigned long vdso_pages __ro_after_init;
2828
static unsigned long timer_mapping_base;
2929

@@ -66,24 +66,24 @@ static int __init vdso_init(void)
6666
int i;
6767
struct page **vdso_pagelist;
6868

69-
if (memcmp(&vdso_start, "\177ELF", 4)) {
69+
if (memcmp(vdso_start, "\177ELF", 4)) {
7070
pr_err("vDSO is not a valid ELF object!\n");
7171
return -EINVAL;
7272
}
7373
/* Creat a timer io mapping to get clock cycles counter */
7474
get_timer_node_info();
7575

76-
vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT;
76+
vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
7777
pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n",
78-
vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data);
78+
vdso_pages + 1, vdso_pages, vdso_start, 1L, vdso_data);
7979

8080
/* Allocate the vDSO pagelist */
8181
vdso_pagelist = kcalloc(vdso_pages, sizeof(struct page *), GFP_KERNEL);
8282
if (vdso_pagelist == NULL)
8383
return -ENOMEM;
8484

8585
for (i = 0; i < vdso_pages; i++)
86-
vdso_pagelist[i] = virt_to_page(&vdso_start + i * PAGE_SIZE);
86+
vdso_pagelist[i] = virt_to_page(vdso_start + i * PAGE_SIZE);
8787
vdso_spec[1].pages = &vdso_pagelist[0];
8888

8989
return 0;

arch/nds32/lib/copy_page.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Copyright (C) 2005-2017 Andes Technology Corporation
33

44
#include <linux/linkage.h>
5+
#include <asm/export.h>
56
#include <asm/page.h>
67

78
.text
@@ -16,6 +17,7 @@ ENTRY(copy_page)
1617
popm $r2, $r10
1718
ret
1819
ENDPROC(copy_page)
20+
EXPORT_SYMBOL(copy_page)
1921

2022
ENTRY(clear_page)
2123
pushm $r1, $r9
@@ -35,3 +37,4 @@ ENTRY(clear_page)
3537
popm $r1, $r9
3638
ret
3739
ENDPROC(clear_page)
40+
EXPORT_SYMBOL(clear_page)

arch/nds32/mm/alignment.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define RA(inst) (((inst) >> 15) & 0x1FUL)
2020
#define RB(inst) (((inst) >> 10) & 0x1FUL)
2121
#define SV(inst) (((inst) >> 8) & 0x3UL)
22-
#define IMM(inst) (((inst) >> 0) & 0x3FFFUL)
22+
#define IMM(inst) (((inst) >> 0) & 0x7FFFUL)
2323

2424
#define RA3(inst) (((inst) >> 3) & 0x7UL)
2525
#define RT3(inst) (((inst) >> 6) & 0x7UL)
@@ -28,6 +28,9 @@
2828
#define RA5(inst) (((inst) >> 0) & 0x1FUL)
2929
#define RT4(inst) (((inst) >> 5) & 0xFUL)
3030

31+
#define GET_IMMSVAL(imm_value) \
32+
(((imm_value >> 14) & 0x1) ? (imm_value - 0x8000) : imm_value)
33+
3134
#define __get8_data(val,addr,err) \
3235
__asm__( \
3336
"1: lbi.bi %1, [%2], #1\n" \
@@ -467,7 +470,7 @@ static inline int do_32(unsigned long inst, struct pt_regs *regs)
467470
}
468471

469472
if (imm)
470-
shift = IMM(inst) * len;
473+
shift = GET_IMMSVAL(IMM(inst)) * len;
471474
else
472475
shift = *idx_to_addr(regs, RB(inst)) << SV(inst);
473476

@@ -552,7 +555,7 @@ static struct ctl_table alignment_tbl[3] = {
552555

553556
static struct ctl_table nds32_sysctl_table[2] = {
554557
{
555-
.procname = "unaligned_acess",
558+
.procname = "unaligned_access",
556559
.mode = 0555,
557560
.child = alignment_tbl},
558561
{}

0 commit comments

Comments
 (0)