forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'riscv-for-linus-5.6-mw0' of git://git.kernel.org/pub/scm/l…
…inux/kernel/git/riscv/linux Pull RISC-V updates from Palmer Dabbelt: "This contains a handful of patches for this merge window: - Support for kasan - 32-bit physical addresses on rv32i-based systems - Support for CONFIG_DEBUG_VIRTUAL - DT entry for the FU540 GPIO controller, which has recently had a device driver merged These boot a buildroot-based system on QEMU's virt board for me" * tag 'riscv-for-linus-5.6-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: dts: Add DT support for SiFive FU540 GPIO driver riscv: mm: add support for CONFIG_DEBUG_VIRTUAL riscv: keep 32-bit kernel to 32-bit phys_addr_t kasan: Add riscv to KASAN documentation. riscv: Add KASAN support kasan: No KASAN's memmove check if archs don't have it.
- Loading branch information
Showing
18 changed files
with
245 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,3 +94,7 @@ | |
&pwm1 { | ||
status = "okay"; | ||
}; | ||
|
||
&gpio { | ||
status = "okay"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (C) 2019 Andes Technology Corporation */ | ||
|
||
#ifndef __ASM_KASAN_H | ||
#define __ASM_KASAN_H | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#ifdef CONFIG_KASAN | ||
|
||
#include <asm/pgtable.h> | ||
|
||
#define KASAN_SHADOW_SCALE_SHIFT 3 | ||
|
||
#define KASAN_SHADOW_SIZE (UL(1) << (38 - KASAN_SHADOW_SCALE_SHIFT)) | ||
#define KASAN_SHADOW_START 0xffffffc000000000 /* 2^64 - 2^38 */ | ||
#define KASAN_SHADOW_END (KASAN_SHADOW_START + KASAN_SHADOW_SIZE) | ||
|
||
#define KASAN_SHADOW_OFFSET (KASAN_SHADOW_END - (1ULL << \ | ||
(64 - KASAN_SHADOW_SCALE_SHIFT))) | ||
|
||
void kasan_init(void); | ||
asmlinkage void kasan_early_init(void); | ||
|
||
#endif | ||
#endif | ||
#endif /* __ASM_KASAN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ | |
*/ | ||
EXPORT_SYMBOL(memset); | ||
EXPORT_SYMBOL(memcpy); | ||
EXPORT_SYMBOL(__memset); | ||
EXPORT_SYMBOL(__memcpy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ SECTIONS | |
KPROBES_TEXT | ||
ENTRY_TEXT | ||
IRQENTRY_TEXT | ||
SOFTIRQENTRY_TEXT | ||
*(.fixup) | ||
_etext = .; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
// Copyright (C) 2019 Andes Technology Corporation | ||
|
||
#include <linux/pfn.h> | ||
#include <linux/init_task.h> | ||
#include <linux/kasan.h> | ||
#include <linux/kernel.h> | ||
#include <linux/memblock.h> | ||
#include <asm/tlbflush.h> | ||
#include <asm/pgtable.h> | ||
#include <asm/fixmap.h> | ||
|
||
extern pgd_t early_pg_dir[PTRS_PER_PGD]; | ||
asmlinkage void __init kasan_early_init(void) | ||
{ | ||
uintptr_t i; | ||
pgd_t *pgd = early_pg_dir + pgd_index(KASAN_SHADOW_START); | ||
|
||
for (i = 0; i < PTRS_PER_PTE; ++i) | ||
set_pte(kasan_early_shadow_pte + i, | ||
mk_pte(virt_to_page(kasan_early_shadow_page), | ||
PAGE_KERNEL)); | ||
|
||
for (i = 0; i < PTRS_PER_PMD; ++i) | ||
set_pmd(kasan_early_shadow_pmd + i, | ||
pfn_pmd(PFN_DOWN(__pa((uintptr_t)kasan_early_shadow_pte)), | ||
__pgprot(_PAGE_TABLE))); | ||
|
||
for (i = KASAN_SHADOW_START; i < KASAN_SHADOW_END; | ||
i += PGDIR_SIZE, ++pgd) | ||
set_pgd(pgd, | ||
pfn_pgd(PFN_DOWN(__pa(((uintptr_t)kasan_early_shadow_pmd))), | ||
__pgprot(_PAGE_TABLE))); | ||
|
||
/* init for swapper_pg_dir */ | ||
pgd = pgd_offset_k(KASAN_SHADOW_START); | ||
|
||
for (i = KASAN_SHADOW_START; i < KASAN_SHADOW_END; | ||
i += PGDIR_SIZE, ++pgd) | ||
set_pgd(pgd, | ||
pfn_pgd(PFN_DOWN(__pa(((uintptr_t)kasan_early_shadow_pmd))), | ||
__pgprot(_PAGE_TABLE))); | ||
|
||
flush_tlb_all(); | ||
} | ||
|
||
static void __init populate(void *start, void *end) | ||
{ | ||
unsigned long i; | ||
unsigned long vaddr = (unsigned long)start & PAGE_MASK; | ||
unsigned long vend = PAGE_ALIGN((unsigned long)end); | ||
unsigned long n_pages = (vend - vaddr) / PAGE_SIZE; | ||
unsigned long n_pmds = | ||
(n_pages % PTRS_PER_PTE) ? n_pages / PTRS_PER_PTE + 1 : | ||
n_pages / PTRS_PER_PTE; | ||
pgd_t *pgd = pgd_offset_k(vaddr); | ||
pmd_t *pmd = memblock_alloc(n_pmds * sizeof(pmd_t), PAGE_SIZE); | ||
pte_t *pte = memblock_alloc(n_pages * sizeof(pte_t), PAGE_SIZE); | ||
|
||
for (i = 0; i < n_pages; i++) { | ||
phys_addr_t phys = memblock_phys_alloc(PAGE_SIZE, PAGE_SIZE); | ||
|
||
set_pte(pte + i, pfn_pte(PHYS_PFN(phys), PAGE_KERNEL)); | ||
} | ||
|
||
for (i = 0; i < n_pmds; ++pgd, i += PTRS_PER_PMD) | ||
set_pgd(pgd, pfn_pgd(PFN_DOWN(__pa(((uintptr_t)(pmd + i)))), | ||
__pgprot(_PAGE_TABLE))); | ||
|
||
for (i = 0; i < n_pages; ++pmd, i += PTRS_PER_PTE) | ||
set_pmd(pmd, pfn_pmd(PFN_DOWN(__pa((uintptr_t)(pte + i))), | ||
__pgprot(_PAGE_TABLE))); | ||
|
||
flush_tlb_all(); | ||
memset(start, 0, end - start); | ||
} | ||
|
||
void __init kasan_init(void) | ||
{ | ||
struct memblock_region *reg; | ||
unsigned long i; | ||
|
||
kasan_populate_early_shadow((void *)KASAN_SHADOW_START, | ||
(void *)kasan_mem_to_shadow((void *)VMALLOC_END)); | ||
|
||
for_each_memblock(memory, reg) { | ||
void *start = (void *)__va(reg->base); | ||
void *end = (void *)__va(reg->base + reg->size); | ||
|
||
if (start >= end) | ||
break; | ||
|
||
populate(kasan_mem_to_shadow(start), | ||
kasan_mem_to_shadow(end)); | ||
}; | ||
|
||
for (i = 0; i < PTRS_PER_PTE; i++) | ||
set_pte(&kasan_early_shadow_pte[i], | ||
mk_pte(virt_to_page(kasan_early_shadow_page), | ||
__pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_ACCESSED))); | ||
|
||
memset(kasan_early_shadow_page, 0, PAGE_SIZE); | ||
init_task.kasan_depth = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/types.h> | ||
#include <linux/mmdebug.h> | ||
#include <linux/mm.h> | ||
#include <asm/page.h> | ||
#include <asm/sections.h> | ||
|
||
phys_addr_t __virt_to_phys(unsigned long x) | ||
{ | ||
phys_addr_t y = x - PAGE_OFFSET; | ||
|
||
/* | ||
* Boundary checking aginst the kernel linear mapping space. | ||
*/ | ||
WARN(y >= KERN_VIRT_SIZE, | ||
"virt_to_phys used for non-linear address: %pK (%pS)\n", | ||
(void *)x, (void *)x); | ||
|
||
return __va_to_pa_nodebug(x); | ||
} | ||
EXPORT_SYMBOL(__virt_to_phys); | ||
|
||
phys_addr_t __phys_addr_symbol(unsigned long x) | ||
{ | ||
unsigned long kernel_start = (unsigned long)PAGE_OFFSET; | ||
unsigned long kernel_end = (unsigned long)_end; | ||
|
||
/* | ||
* Boundary checking aginst the kernel image mapping. | ||
* __pa_symbol should only be used on kernel symbol addresses. | ||
*/ | ||
VIRTUAL_BUG_ON(x < kernel_start || x > kernel_end); | ||
|
||
return __va_to_pa_nodebug(x); | ||
} | ||
EXPORT_SYMBOL(__phys_addr_symbol); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters