Skip to content

Commit 0c54714

Browse files
author
Marc Zyngier
committed
KVM: arm64: Add filtering hook to S1 page table walk
Add a filtering hook that can get called on each level of the walk, and providing access to the full state. Crucially, this is called *before* the access is made, so that it is possible to track down the level of a faulting access. Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 61b0280 commit 0c54714

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

arch/arm64/include/asm/kvm_nested.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,21 @@ enum trans_regime {
288288
TR_EL2,
289289
};
290290

291+
struct s1_walk_info;
292+
293+
struct s1_walk_context {
294+
struct s1_walk_info *wi;
295+
u64 table_ipa;
296+
int level;
297+
};
298+
299+
struct s1_walk_filter {
300+
int (*fn)(struct s1_walk_context *, void *);
301+
void *priv;
302+
};
303+
291304
struct s1_walk_info {
305+
struct s1_walk_filter *filter;
292306
u64 baddr;
293307
enum trans_regime regime;
294308
unsigned int max_oa_bits;

arch/arm64/kvm/at.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,17 @@ static int walk_s1(struct kvm_vcpu *vcpu, struct s1_walk_info *wi,
404404
ipa = kvm_s2_trans_output(&s2_trans);
405405
}
406406

407+
if (wi->filter) {
408+
ret = wi->filter->fn(&(struct s1_walk_context)
409+
{
410+
.wi = wi,
411+
.table_ipa = baddr,
412+
.level = level,
413+
}, wi->filter->priv);
414+
if (ret)
415+
return ret;
416+
}
417+
407418
ret = kvm_read_guest(vcpu->kvm, ipa, &desc, sizeof(desc));
408419
if (ret) {
409420
fail_s1_walk(wr, ESR_ELx_FSC_SEA_TTW(level), false);

0 commit comments

Comments
 (0)