Skip to content

Commit 57902dc

Browse files
committed
Merge tag 'riscv-for-linus-5.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux
Pull RISC-V fixes from Palmer Dabbelt: "This contains a pair of bug fixes that I'd like to include in 5.0: - A fix to disambiguate swap from invalid PTEs, which fixes an error when trying to unmap PROT_NONE pages. - A revert to an optimization of the size of flat binaries. This is really a workaround to prevent breaking existing boot flows, but since the change was introduced as part of the 5.0 merge window I'd like to have the fix in before 5.0 so we can avoid a regression for any proper releases. With these I hope we're out of patches for 5.0 in RISC-V land" * tag 'riscv-for-linus-5.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux: Revert "RISC-V: Make BSS section as the last section in vmlinux.lds.S" riscv: Add pte bit to distinguish swap from invalid
2 parents 1d11025 + 41fb9d5 commit 57902dc

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

arch/riscv/include/asm/pgtable-bits.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
#define _PAGE_SPECIAL _PAGE_SOFT
3636
#define _PAGE_TABLE _PAGE_PRESENT
3737

38+
/*
39+
* _PAGE_PROT_NONE is set on not-present pages (and ignored by the hardware) to
40+
* distinguish them from swapped out pages
41+
*/
42+
#define _PAGE_PROT_NONE _PAGE_READ
43+
3844
#define _PAGE_PFN_SHIFT 10
3945

4046
/* Set of bits to preserve across pte_modify() */

arch/riscv/include/asm/pgtable.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
/* Page protection bits */
4545
#define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_USER)
4646

47-
#define PAGE_NONE __pgprot(0)
47+
#define PAGE_NONE __pgprot(_PAGE_PROT_NONE)
4848
#define PAGE_READ __pgprot(_PAGE_BASE | _PAGE_READ)
4949
#define PAGE_WRITE __pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_WRITE)
5050
#define PAGE_EXEC __pgprot(_PAGE_BASE | _PAGE_EXEC)
@@ -98,7 +98,7 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
9898

9999
static inline int pmd_present(pmd_t pmd)
100100
{
101-
return (pmd_val(pmd) & _PAGE_PRESENT);
101+
return (pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
102102
}
103103

104104
static inline int pmd_none(pmd_t pmd)
@@ -178,7 +178,7 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long addr)
178178

179179
static inline int pte_present(pte_t pte)
180180
{
181-
return (pte_val(pte) & _PAGE_PRESENT);
181+
return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
182182
}
183183

184184
static inline int pte_none(pte_t pte)
@@ -380,7 +380,7 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
380380
*
381381
* Format of swap PTE:
382382
* bit 0: _PAGE_PRESENT (zero)
383-
* bit 1: reserved for future use (zero)
383+
* bit 1: _PAGE_PROT_NONE (zero)
384384
* bits 2 to 6: swap type
385385
* bits 7 to XLEN-1: swap offset
386386
*/

arch/riscv/kernel/vmlinux.lds.S

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#include <asm/cache.h>
1919
#include <asm/thread_info.h>
2020

21-
#define MAX_BYTES_PER_LONG 0x10
22-
2321
OUTPUT_ARCH(riscv)
2422
ENTRY(_start)
2523

@@ -76,17 +74,15 @@ SECTIONS
7674
*(.sbss*)
7775
}
7876

77+
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
78+
7979
EXCEPTION_TABLE(0x10)
8080
NOTES
8181

8282
.rel.dyn : {
8383
*(.rel.dyn*)
8484
}
8585

86-
BSS_SECTION(MAX_BYTES_PER_LONG,
87-
MAX_BYTES_PER_LONG,
88-
MAX_BYTES_PER_LONG)
89-
9086
_end = .;
9187

9288
STABS_DEBUG

0 commit comments

Comments
 (0)