• Vineet Gupta's avatar
    ARC: mm: vmalloc sync from kernel to user table to update PMD ... · 56809a28
    Vineet Gupta authored
    ... not PGD
    
    vmalloc() sets up the kernel page table (starting from @swapper_pg_dir).
    But when vmalloc area is accessed in context of a user task, say opening
    terminal in n_tty_open(), the user page tables need to be synced from
    kernel page tables so that TLB entry is created in "user context".
    
    The old code was doing this incorrectly, as it was updating the user pgd
    entry (first level itself) to point to kernel pud table (2nd level),
    effectively yanking away the entire user space translation with kernel one.
    
    The correct way to do this is to ONLY update a user space pgd/pud/pmd entry
    if it is not popluated already. This ensures that only the missing leaf
    pmd entry gets updated to point to relevant kernel pte table.
    
    From code change pov, we are chaging the pattern:
    
    	p4d = p4d_offset(pgd, address);
    	p4d_k = p4d_offset(pgd_k, address);
    	if (!p4d_present(*p4d_k))
    		goto bad_area;
    	set_p4d(p4d, *p4d_k);
    
    with
    	p4d = p4d_offset(pgd, address);
    	p4d_k = p4d_offset(pgd_k, address);
    	if (p4d_none(*p4d_k))
    		goto bad_area;
    	if (!p4d_present(*p4d))
    		set_p4d(p4d, *p4d_k);
    Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
    56809a28
fault.c 4.33 KB