mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-12 12:25:18 +02:00
ANDROID: KVM: arm64: Drop level from struct hyp_fixmap_slot
The level of a fixmap slot can always be inferred from the PTE itself, so drop the level member from struct hyp_fixmap_slot for clarity. Bug: 278749606 Bug: 278011447 Change-Id: I610e78dbaa3184a825c84d17eba9a64193405c8c Signed-off-by: Quentin Perret <qperret@google.com>
This commit is contained in:
parent
7d5179c2a1
commit
06007d8930
|
@ -30,7 +30,6 @@ static u64 __io_map_base;
|
||||||
struct hyp_fixmap_slot {
|
struct hyp_fixmap_slot {
|
||||||
u64 addr;
|
u64 addr;
|
||||||
kvm_pte_t *ptep;
|
kvm_pte_t *ptep;
|
||||||
u8 level;
|
|
||||||
};
|
};
|
||||||
static DEFINE_PER_CPU(struct hyp_fixmap_slot, fixmap_slots);
|
static DEFINE_PER_CPU(struct hyp_fixmap_slot, fixmap_slots);
|
||||||
|
|
||||||
|
@ -332,6 +331,12 @@ static void fixmap_clear_slot(struct hyp_fixmap_slot *slot)
|
||||||
{
|
{
|
||||||
kvm_pte_t *ptep = slot->ptep;
|
kvm_pte_t *ptep = slot->ptep;
|
||||||
u64 addr = slot->addr;
|
u64 addr = slot->addr;
|
||||||
|
u32 level;
|
||||||
|
|
||||||
|
if (FIELD_GET(KVM_PTE_TYPE, *ptep) == KVM_PTE_TYPE_PAGE)
|
||||||
|
level = KVM_PGTABLE_MAX_LEVELS - 1;
|
||||||
|
else
|
||||||
|
level = KVM_PGTABLE_MAX_LEVELS - 2; /* create_fixblock() guarantees PMD level */
|
||||||
|
|
||||||
WRITE_ONCE(*ptep, *ptep & ~KVM_PTE_VALID);
|
WRITE_ONCE(*ptep, *ptep & ~KVM_PTE_VALID);
|
||||||
|
|
||||||
|
@ -345,7 +350,7 @@ static void fixmap_clear_slot(struct hyp_fixmap_slot *slot)
|
||||||
* https://lore.kernel.org/kvm/20221017115209.2099-1-will@kernel.org/T/#mf10dfbaf1eaef9274c581b81c53758918c1d0f03
|
* https://lore.kernel.org/kvm/20221017115209.2099-1-will@kernel.org/T/#mf10dfbaf1eaef9274c581b81c53758918c1d0f03
|
||||||
*/
|
*/
|
||||||
dsb(ishst);
|
dsb(ishst);
|
||||||
__tlbi_level(vale2is, __TLBI_VADDR(addr, 0), slot->level);
|
__tlbi_level(vale2is, __TLBI_VADDR(addr, 0), level);
|
||||||
dsb(ish);
|
dsb(ish);
|
||||||
isb();
|
isb();
|
||||||
}
|
}
|
||||||
|
@ -360,7 +365,7 @@ static int __create_fixmap_slot_cb(const struct kvm_pgtable_visit_ctx *ctx,
|
||||||
{
|
{
|
||||||
struct hyp_fixmap_slot *slot = (struct hyp_fixmap_slot *)ctx->arg;
|
struct hyp_fixmap_slot *slot = (struct hyp_fixmap_slot *)ctx->arg;
|
||||||
|
|
||||||
if (!kvm_pte_valid(ctx->old) || ctx->level != slot->level)
|
if (!kvm_pte_valid(ctx->old) || (ctx->end - ctx->start) != kvm_granule_size(ctx->level))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
slot->addr = ctx->addr;
|
slot->addr = ctx->addr;
|
||||||
|
@ -384,8 +389,6 @@ static int create_fixmap_slot(u64 addr, u64 cpu)
|
||||||
.arg = (void *)per_cpu_ptr(&fixmap_slots, cpu),
|
.arg = (void *)per_cpu_ptr(&fixmap_slots, cpu),
|
||||||
};
|
};
|
||||||
|
|
||||||
per_cpu_ptr(&fixmap_slots, cpu)->level = KVM_PGTABLE_MAX_LEVELS - 1;
|
|
||||||
|
|
||||||
return kvm_pgtable_walk(&pkvm_pgtable, addr, PAGE_SIZE, &walker);
|
return kvm_pgtable_walk(&pkvm_pgtable, addr, PAGE_SIZE, &walker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +442,6 @@ static int create_fixblock(void)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto unlock;
|
goto unlock;
|
||||||
|
|
||||||
hyp_fixblock_slot.level = KVM_PGTABLE_MAX_LEVELS - 2;
|
|
||||||
ret = kvm_pgtable_walk(&pkvm_pgtable, addr, PMD_SIZE, &walker);
|
ret = kvm_pgtable_walk(&pkvm_pgtable, addr, PMD_SIZE, &walker);
|
||||||
unlock:
|
unlock:
|
||||||
hyp_spin_unlock(&pkvm_pgd_lock);
|
hyp_spin_unlock(&pkvm_pgd_lock);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user