Skip to content

Commit 03e560a

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: selftests: Add helper for enabling LPIs on a redistributor
The selftests GIC library presently does not support LPIs. Add a userspace helper for configuring a redistributor for LPIs, installing an LPI configuration table and LPI pending table. Signed-off-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent be26db6 commit 03e560a

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

tools/testing/selftests/kvm/include/aarch64/gic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@ void gic_irq_clear_pending(unsigned int intid);
5858
bool gic_irq_get_pending(unsigned int intid);
5959
void gic_irq_set_config(unsigned int intid, bool is_edge);
6060

61+
void gic_rdist_enable_lpis(vm_paddr_t cfg_table, size_t cfg_table_size,
62+
vm_paddr_t pend_table);
63+
6164
#endif /* SELFTEST_KVM_GIC_H */

tools/testing/selftests/kvm/lib/aarch64/gic_v3.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,27 @@ const struct gic_common_ops gicv3_ops = {
401401
.gic_irq_get_pending = gicv3_irq_get_pending,
402402
.gic_irq_set_config = gicv3_irq_set_config,
403403
};
404+
405+
void gic_rdist_enable_lpis(vm_paddr_t cfg_table, size_t cfg_table_size,
406+
vm_paddr_t pend_table)
407+
{
408+
volatile void *rdist_base = gicr_base_cpu(guest_get_vcpuid());
409+
410+
u32 ctlr;
411+
u64 val;
412+
413+
val = (cfg_table |
414+
GICR_PROPBASER_InnerShareable |
415+
GICR_PROPBASER_RaWaWb |
416+
((ilog2(cfg_table_size) - 1) & GICR_PROPBASER_IDBITS_MASK));
417+
writeq_relaxed(val, rdist_base + GICR_PROPBASER);
418+
419+
val = (pend_table |
420+
GICR_PENDBASER_InnerShareable |
421+
GICR_PENDBASER_RaWaWb);
422+
writeq_relaxed(val, rdist_base + GICR_PENDBASER);
423+
424+
ctlr = readl_relaxed(rdist_base + GICR_CTLR);
425+
ctlr |= GICR_CTLR_ENABLE_LPIS;
426+
writel_relaxed(ctlr, rdist_base + GICR_CTLR);
427+
}

tools/testing/selftests/kvm/lib/aarch64/vgic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
* ARM Generic Interrupt Controller (GIC) v3 host support
44
*/
55

6+
#include <linux/kernel.h>
67
#include <linux/kvm.h>
78
#include <linux/sizes.h>
9+
#include <asm/cputype.h>
810
#include <asm/kvm_para.h>
911
#include <asm/kvm.h>
1012

0 commit comments

Comments
 (0)