Skip to content

Commit 11cf9d8

Browse files
kvaneeshdjbw
authored andcommitted
fs/dax: Deposit pagetable even when installing zero page
Architectures like ppc64 use the deposited page table to store hardware page table slot information. Make sure we deposit a page table when using zero page at the pmd level for hash. Without this we hit Unable to handle kernel paging request for data at address 0x00000000 Faulting instruction address: 0xc000000000082a74 Oops: Kernel access of bad area, sig: 11 [#1] .... NIP [c000000000082a74] __hash_page_thp+0x224/0x5b0 LR [c0000000000829a4] __hash_page_thp+0x154/0x5b0 Call Trace: hash_page_mm+0x43c/0x740 do_hash_page+0x2c/0x3c copy_from_iter_flushcache+0xa4/0x4a0 pmem_copy_from_iter+0x2c/0x50 [nd_pmem] dax_copy_from_iter+0x40/0x70 dax_iomap_actor+0x134/0x360 iomap_apply+0xfc/0x1b0 dax_iomap_rw+0xac/0x130 ext4_file_write_iter+0x254/0x460 [ext4] __vfs_write+0x120/0x1e0 vfs_write+0xd8/0x220 SyS_write+0x6c/0x110 system_call+0x3c/0x130 Fixes: b5beae5 ("powerpc/pseries: Add driver for PAPR SCM regions") Cc: <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Aneesh Kumar K.V <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent e4b3448 commit 11cf9d8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fs/dax.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/sizes.h>
3434
#include <linux/mmu_notifier.h>
3535
#include <linux/iomap.h>
36+
#include <asm/pgalloc.h>
3637
#include "internal.h"
3738

3839
#define CREATE_TRACE_POINTS
@@ -1407,7 +1408,9 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf,
14071408
{
14081409
struct address_space *mapping = vmf->vma->vm_file->f_mapping;
14091410
unsigned long pmd_addr = vmf->address & PMD_MASK;
1411+
struct vm_area_struct *vma = vmf->vma;
14101412
struct inode *inode = mapping->host;
1413+
pgtable_t pgtable = NULL;
14111414
struct page *zero_page;
14121415
spinlock_t *ptl;
14131416
pmd_t pmd_entry;
@@ -1422,12 +1425,22 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf,
14221425
*entry = dax_insert_entry(xas, mapping, vmf, *entry, pfn,
14231426
DAX_PMD | DAX_ZERO_PAGE, false);
14241427

1428+
if (arch_needs_pgtable_deposit()) {
1429+
pgtable = pte_alloc_one(vma->vm_mm);
1430+
if (!pgtable)
1431+
return VM_FAULT_OOM;
1432+
}
1433+
14251434
ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd);
14261435
if (!pmd_none(*(vmf->pmd))) {
14271436
spin_unlock(ptl);
14281437
goto fallback;
14291438
}
14301439

1440+
if (pgtable) {
1441+
pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable);
1442+
mm_inc_nr_ptes(vma->vm_mm);
1443+
}
14311444
pmd_entry = mk_pmd(zero_page, vmf->vma->vm_page_prot);
14321445
pmd_entry = pmd_mkhuge(pmd_entry);
14331446
set_pmd_at(vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry);
@@ -1436,6 +1449,8 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf,
14361449
return VM_FAULT_NOPAGE;
14371450

14381451
fallback:
1452+
if (pgtable)
1453+
pte_free(vma->vm_mm, pgtable);
14391454
trace_dax_pmd_load_hole_fallback(inode, vmf, zero_page, *entry);
14401455
return VM_FAULT_FALLBACK;
14411456
}

0 commit comments

Comments
 (0)