Skip to content

Commit

Permalink
KVM: arm64: Introduce addr_is_memory()
Browse files Browse the repository at this point in the history
Introduce a helper usable in nVHE protected mode to check whether a
physical address is in a RAM region or not.

Signed-off-by: Quentin Perret <qperret@google.com>
Reviewed-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210809152448.1810400-16-qperret@google.com
  • Loading branch information
Quentin Perret authored and Marc Zyngier committed Aug 11, 2021
1 parent 2d77e23 commit e009dce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/arm64/kvm/hyp/include/nvhe/mem_protect.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ extern const u8 pkvm_hyp_id;
int __pkvm_prot_finalize(void);
int __pkvm_mark_hyp(phys_addr_t start, phys_addr_t end);

bool addr_is_memory(phys_addr_t phys);
int host_stage2_idmap_locked(phys_addr_t addr, u64 size, enum kvm_pgtable_prot prot);
int host_stage2_set_owner_locked(phys_addr_t addr, u64 size, u8 owner_id);
int kvm_host_prepare_stage2(void *pgt_pool_base);
Expand Down
7 changes: 7 additions & 0 deletions arch/arm64/kvm/hyp/nvhe/mem_protect.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ static bool find_mem_range(phys_addr_t addr, struct kvm_mem_range *range)
return false;
}

bool addr_is_memory(phys_addr_t phys)
{
struct kvm_mem_range range;

return find_mem_range(phys, &range);
}

static bool range_is_memory(u64 start, u64 end)
{
struct kvm_mem_range r1, r2;
Expand Down

0 comments on commit e009dce

Please sign in to comment.