mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ANDROID: KVM: arm64: Correctly flag MMIO pages as PKVM_PAGE_RESTRICTED_PROT
The host_get_page_state() logic has currently a baked in assumption that it will only be used on memory, and checks against the default memory permssions to flag pages as having a RESTRICTED_PROT state. Add support for correctly flagging non-memory pages to prepare the ground for future patches. Bug: 244543039 Bug: 244373730 Change-Id: Idaaef96cb98c147c8b793059438064cf770af525 Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
@@ -897,13 +897,17 @@ static enum pkvm_page_state host_get_page_state(kvm_pte_t pte)
|
||||
{
|
||||
enum pkvm_page_state state = 0;
|
||||
enum kvm_pgtable_prot prot;
|
||||
phys_addr_t phys;
|
||||
|
||||
if (!kvm_pte_valid(pte) && pte)
|
||||
return PKVM_NOPAGE;
|
||||
|
||||
prot = kvm_pgtable_stage2_pte_prot(pte);
|
||||
if (kvm_pte_valid(pte) && ((prot & KVM_PGTABLE_PROT_RWX) != PKVM_HOST_MEM_PROT))
|
||||
state = PKVM_PAGE_RESTRICTED_PROT;
|
||||
if (kvm_pte_valid(pte)) {
|
||||
phys = kvm_pte_to_phys(pte);
|
||||
if ((prot & KVM_PGTABLE_PROT_RWX) != default_host_prot(addr_is_memory(phys)))
|
||||
state = PKVM_PAGE_RESTRICTED_PROT;
|
||||
}
|
||||
|
||||
return state | pkvm_getstate(prot);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user