diff options
author | Will Deacon <willdeacon@google.com> | 2023-04-26 15:38:32 +0100 |
---|---|---|
committer | Lee Jones <joneslee@google.com> | 2023-06-15 11:19:39 +0100 |
commit | 3a84e24200a10c953e254eed0db69420f4376d0f (patch) | |
tree | af217cac2e358e44074f686b328177abc2f91c0a | |
parent | 89f7f99321451258dbd8d30834a15b8e29f93f75 (diff) | |
download | common-3a84e24200a10c953e254eed0db69420f4376d0f.tar.gz |
ANDROID: KVM: arm64: Move addr_is_allowed_memory() check into host callbackandroid13-5.10-2023-01_r9
Since host stage-2 mappings are created lazily, we cannot rely on the
pte in order to recover the target physical address when checking a
host-initiated memory transition.
Instead, move the addr_is_allowed_memory() check into the host callback
function where it is passed the physical address directly from the
walker.
Bug: 279739439
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I84bdc43eded79f1f5e5a489dbc0874604491e5c8
(cherry picked from commit b35a06182451f71cc0543cfe36a3f21fad6f6f02)
Signed-off-by: Lee Jones <joneslee@google.com>
-rw-r--r-- | arch/arm64/kvm/hyp/nvhe/mem_protect.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 821b512b0987..1c902f6254ef 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -792,9 +792,6 @@ static int __check_page_state_visitor(u64 addr, u64 end, u32 level, struct check_walk_data *d = arg; kvm_pte_t pte = *ptep; - if (kvm_pte_valid(pte) && !addr_is_allowed_memory(kvm_pte_to_phys(pte))) - return -EINVAL; - return d->get_page_state(pte, addr) == d->desired ? 0 : -EPERM; } @@ -812,6 +809,9 @@ static int check_page_state_range(struct kvm_pgtable *pgt, u64 addr, u64 size, static enum pkvm_page_state host_get_page_state(kvm_pte_t pte, u64 addr) { + if (!addr_is_allowed_memory(addr)) + return PKVM_NOPAGE; + if (!kvm_pte_valid(pte) && pte) return PKVM_NOPAGE; |