Skip to content

Commit 232269e

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: selftests: Add quadword MMIO accessors
The base registers in the GIC ITS and redistributor for LPIs are 64 bits wide. Add quadword accessors to poke at them. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20240422200158.2606761-16-oliver.upton@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 1505bc7 commit 232269e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,28 @@ static __always_inline u32 __raw_readl(const volatile void *addr)
177177
return val;
178178
}
179179

180+
static __always_inline void __raw_writeq(u64 val, volatile void *addr)
181+
{
182+
asm volatile("str %0, [%1]" : : "rZ" (val), "r" (addr));
183+
}
184+
185+
static __always_inline u64 __raw_readq(const volatile void *addr)
186+
{
187+
u64 val;
188+
asm volatile("ldr %0, [%1]" : "=r" (val) : "r" (addr));
189+
return val;
190+
}
191+
180192
#define writel_relaxed(v,c) ((void)__raw_writel((__force u32)cpu_to_le32(v),(c)))
181193
#define readl_relaxed(c) ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
194+
#define writeq_relaxed(v,c) ((void)__raw_writeq((__force u64)cpu_to_le64(v),(c)))
195+
#define readq_relaxed(c) ({ u64 __r = le64_to_cpu((__force __le64)__raw_readq(c)); __r; })
182196

183197
#define writel(v,c) ({ __iowmb(); writel_relaxed((v),(c));})
184198
#define readl(c) ({ u32 __v = readl_relaxed(c); __iormb(__v); __v; })
199+
#define writeq(v,c) ({ __iowmb(); writeq_relaxed((v),(c));})
200+
#define readq(c) ({ u64 __v = readq_relaxed(c); __iormb(__v); __v; })
201+
185202

186203
static inline void local_irq_enable(void)
187204
{

0 commit comments

Comments
 (0)