Skip to content

Commit d5be446

Browse files
committed
LoongArch: Set correct protection_map[] for VM_NONE/VM_SHARED
For 32BIT platform _PAGE_PROTNONE is 0, so set a VMA to be VM_NONE or VM_SHARED will make pages non-present, then cause Oops with kernel page fault. Fix it by set correct protection_map[] for VM_NONE/VM_SHARED, replacing _PAGE_PROTNONE with _PAGE_PRESENT. Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent 807e5d3 commit d5be446

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

arch/loongarch/mm/cache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ void cpu_cache_init(void)
160160

161161
static const pgprot_t protection_map[16] = {
162162
[VM_NONE] = __pgprot(_CACHE_CC | _PAGE_USER |
163-
_PAGE_PROTNONE | _PAGE_NO_EXEC |
164-
_PAGE_NO_READ),
163+
_PAGE_NO_EXEC | _PAGE_NO_READ |
164+
(_PAGE_PROTNONE ? : _PAGE_PRESENT)),
165165
[VM_READ] = __pgprot(_CACHE_CC | _PAGE_VALID |
166166
_PAGE_USER | _PAGE_PRESENT |
167167
_PAGE_NO_EXEC),
@@ -180,8 +180,8 @@ static const pgprot_t protection_map[16] = {
180180
[VM_EXEC | VM_WRITE | VM_READ] = __pgprot(_CACHE_CC | _PAGE_VALID |
181181
_PAGE_USER | _PAGE_PRESENT),
182182
[VM_SHARED] = __pgprot(_CACHE_CC | _PAGE_USER |
183-
_PAGE_PROTNONE | _PAGE_NO_EXEC |
184-
_PAGE_NO_READ),
183+
_PAGE_NO_EXEC | _PAGE_NO_READ |
184+
(_PAGE_PROTNONE ? : _PAGE_PRESENT)),
185185
[VM_SHARED | VM_READ] = __pgprot(_CACHE_CC | _PAGE_VALID |
186186
_PAGE_USER | _PAGE_PRESENT |
187187
_PAGE_NO_EXEC),

0 commit comments

Comments
 (0)