[RFC PATCH v7 13/37] KVM: x86: Move lapic get/set_reg64() helpers to common code
From: Neeraj Upadhyay
Date: Tue Jun 10 2025 - 14:00:40 EST
Move the apic_get_reg64() and apic_set_reg64() helper functions
to apic.h in order to reuse them in the Secure AVIC guest apic
driver in later patches to read/write APIC_ICR from/to the
APIC backing page.
No functional change intended.
Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@xxxxxxx>
---
Changes since v6:
- Moved function renames outside of this patch.
arch/x86/include/asm/apic.h | 12 ++++++++++++
arch/x86/kvm/lapic.c | 12 ------------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 904029f6530c..b8b5fe875bde 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -535,6 +535,18 @@ static inline void apic_set_reg(void *regs, int reg_off, u32 val)
*((u32 *) (regs + reg_off)) = val;
}
+static __always_inline u64 apic_get_reg64(void *regs, int reg)
+{
+ BUILD_BUG_ON(reg != APIC_ICR);
+ return *((u64 *) (regs + reg));
+}
+
+static __always_inline void apic_set_reg64(void *regs, int reg, u64 val)
+{
+ BUILD_BUG_ON(reg != APIC_ICR);
+ *((u64 *) (regs + reg)) = val;
+}
+
/*
* Warm reset vector position:
*/
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index b27f111a2634..85bc31747d54 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -82,23 +82,11 @@ static inline void kvm_lapic_set_reg(struct kvm_lapic *apic, int reg_off, u32 va
apic_set_reg(apic->regs, reg_off, val);
}
-static __always_inline u64 apic_get_reg64(void *regs, int reg)
-{
- BUILD_BUG_ON(reg != APIC_ICR);
- return *((u64 *) (regs + reg));
-}
-
static __always_inline u64 kvm_lapic_get_reg64(struct kvm_lapic *apic, int reg)
{
return apic_get_reg64(apic->regs, reg);
}
-static __always_inline void apic_set_reg64(void *regs, int reg, u64 val)
-{
- BUILD_BUG_ON(reg != APIC_ICR);
- *((u64 *) (regs + reg)) = val;
-}
-
static __always_inline void kvm_lapic_set_reg64(struct kvm_lapic *apic,
int reg, u64 val)
{
--
2.34.1