• Miles Chen's avatar
    arm64: mm: check virtual addr in virt_to_page() if CONFIG_DEBUG_VIRTUAL=y · eea1bb22
    Miles Chen authored
    This change uses the original virt_to_page() (the one with __pa()) to
    check the given virtual address if CONFIG_DEBUG_VIRTUAL=y.
    
    Recently, I worked on a bug: a driver passes a symbol address to
    dma_map_single() and the virt_to_page() (called by dma_map_single())
    does not work for non-linear addresses after commit 9f287591
    ("arm64: mm: restrict virt_to_page() to the linear mapping").
    
    I tried to trap the bug by enabling CONFIG_DEBUG_VIRTUAL but it
    did not work - bacause the commit removes the __pa() from
    virt_to_page() but CONFIG_DEBUG_VIRTUAL checks the virtual address
    in __pa()/__virt_to_phys().
    
    A simple solution is to use the original virt_to_page()
    (the one with__pa()) if CONFIG_DEBUG_VIRTUAL=y.
    
    Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: default avatarMiles Chen <miles.chen@mediatek.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    eea1bb22
memory.h 10.4 KB