Commit 3fab8234 authored by Quentin Perret's avatar Quentin Perret Committed by Marc Zyngier

KVM: arm64: Refactor the *_map_set_prot_attr() helpers

In order to ease their re-use in other code paths, refactor the
*_map_set_prot_attr() helpers to not depend on a map_data struct.
No functional change intended.
Acked-by: default avatarWill Deacon <will@kernel.org>
Signed-off-by: default avatarQuentin Perret <qperret@google.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210319100146.1149909-31-qperret@google.com
parent 807923e0
...@@ -325,8 +325,7 @@ struct hyp_map_data { ...@@ -325,8 +325,7 @@ struct hyp_map_data {
struct kvm_pgtable_mm_ops *mm_ops; struct kvm_pgtable_mm_ops *mm_ops;
}; };
static int hyp_map_set_prot_attr(enum kvm_pgtable_prot prot, static int hyp_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep)
struct hyp_map_data *data)
{ {
bool device = prot & KVM_PGTABLE_PROT_DEVICE; bool device = prot & KVM_PGTABLE_PROT_DEVICE;
u32 mtype = device ? MT_DEVICE_nGnRE : MT_NORMAL; u32 mtype = device ? MT_DEVICE_nGnRE : MT_NORMAL;
...@@ -351,7 +350,8 @@ static int hyp_map_set_prot_attr(enum kvm_pgtable_prot prot, ...@@ -351,7 +350,8 @@ static int hyp_map_set_prot_attr(enum kvm_pgtable_prot prot,
attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_AP, ap); attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_AP, ap);
attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_SH, sh); attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S1_SH, sh);
attr |= KVM_PTE_LEAF_ATTR_LO_S1_AF; attr |= KVM_PTE_LEAF_ATTR_LO_S1_AF;
data->attr = attr; *ptep = attr;
return 0; return 0;
} }
...@@ -408,7 +408,7 @@ int kvm_pgtable_hyp_map(struct kvm_pgtable *pgt, u64 addr, u64 size, u64 phys, ...@@ -408,7 +408,7 @@ int kvm_pgtable_hyp_map(struct kvm_pgtable *pgt, u64 addr, u64 size, u64 phys,
.arg = &map_data, .arg = &map_data,
}; };
ret = hyp_map_set_prot_attr(prot, &map_data); ret = hyp_set_prot_attr(prot, &map_data.attr);
if (ret) if (ret)
return ret; return ret;
...@@ -501,8 +501,7 @@ u64 kvm_get_vtcr(u64 mmfr0, u64 mmfr1, u32 phys_shift) ...@@ -501,8 +501,7 @@ u64 kvm_get_vtcr(u64 mmfr0, u64 mmfr1, u32 phys_shift)
return vtcr; return vtcr;
} }
static int stage2_map_set_prot_attr(enum kvm_pgtable_prot prot, static int stage2_set_prot_attr(enum kvm_pgtable_prot prot, kvm_pte_t *ptep)
struct stage2_map_data *data)
{ {
bool device = prot & KVM_PGTABLE_PROT_DEVICE; bool device = prot & KVM_PGTABLE_PROT_DEVICE;
kvm_pte_t attr = device ? PAGE_S2_MEMATTR(DEVICE_nGnRE) : kvm_pte_t attr = device ? PAGE_S2_MEMATTR(DEVICE_nGnRE) :
...@@ -522,7 +521,8 @@ static int stage2_map_set_prot_attr(enum kvm_pgtable_prot prot, ...@@ -522,7 +521,8 @@ static int stage2_map_set_prot_attr(enum kvm_pgtable_prot prot,
attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S2_SH, sh); attr |= FIELD_PREP(KVM_PTE_LEAF_ATTR_LO_S2_SH, sh);
attr |= KVM_PTE_LEAF_ATTR_LO_S2_AF; attr |= KVM_PTE_LEAF_ATTR_LO_S2_AF;
data->attr = attr; *ptep = attr;
return 0; return 0;
} }
...@@ -742,7 +742,7 @@ int kvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size, ...@@ -742,7 +742,7 @@ int kvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size,
.arg = &map_data, .arg = &map_data,
}; };
ret = stage2_map_set_prot_attr(prot, &map_data); ret = stage2_set_prot_attr(prot, &map_data.attr);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment