• Yanan Wang's avatar
    KVM: arm64: Add usage of stage 2 fault lookup level in user_mem_abort() · 7d894834
    Yanan Wang authored
    If we get a FSC_PERM fault, just using (logging_active && writable) to
    determine calling kvm_pgtable_stage2_map(). There will be two more cases
    we should consider.
    
    (1) After logging_active is configged back to false from true. When we
    get a FSC_PERM fault with write_fault and adjustment of hugepage is needed,
    we should merge tables back to a block entry. This case is ignored by still
    calling kvm_pgtable_stage2_relax_perms(), which will lead to an endless
    loop and guest panic due to soft lockup.
    
    (2) We use (FSC_PERM && logging_active && writable) to determine
    collapsing a block entry into a table by calling kvm_pgtable_stage2_map().
    But sometimes we may only need to relax permissions when trying to write
    to a page other than a block.
    In this condition,using kvm_pgtable_stage2_relax_perms() will be fine.
    
    The ISS filed bit[1:0] in ESR_EL2 regesiter indicates the stage2 lookup
    level at which a D-abort or I-abort occurred. By comparing granule of
    the fault lookup level with vma_pagesize, we can strictly distinguish
    conditions of calling kvm_pgtable_stage2_relax_perms() or
    kvm_pgtable_stage2_map(), and the above two cases will be well considered.
    Suggested-by: default avatarKeqian Zhu <zhukeqian1@huawei.com>
    Signed-off-by: default avatarYanan Wang <wangyanan55@huawei.com>
    Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
    Acked-by: default avatarWill Deacon <will@kernel.org>
    Link: https://lore.kernel.org/r/20201201201034.116760-4-wangyanan55@huawei.com
    7d894834
kvm_emulate.h 12.7 KB