Skip to content

Commit e2fa790

Browse files
neerajupadhyasean-jc
authored andcommitted
KVM: x86: Change lapic regs base address to void pointer
Change APIC base address from "char *" to "void *" in KVM lapic's set/get helper functions. Pointer arithmetic for "void *" and "char *" operate identically. With "void *" there is less of a chance of doing the wrong thing, e.g. neglecting to cast and reading a byte instead of the desired APIC register size. No functional change intended. Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com> Acked-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20250709033242.267892-6-Neeraj.Upadhyay@amd.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 9cbb5fd commit e2fa790

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

arch/x86/kvm/lapic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module_param(lapic_timer_advance, bool, 0444);
7979
static int kvm_lapic_msr_read(struct kvm_lapic *apic, u32 reg, u64 *data);
8080
static int kvm_lapic_msr_write(struct kvm_lapic *apic, u32 reg, u64 data);
8181

82-
static inline void __kvm_lapic_set_reg(char *regs, int reg_off, u32 val)
82+
static inline void __kvm_lapic_set_reg(void *regs, int reg_off, u32 val)
8383
{
8484
*((u32 *) (regs + reg_off)) = val;
8585
}
@@ -89,7 +89,7 @@ static inline void kvm_lapic_set_reg(struct kvm_lapic *apic, int reg_off, u32 va
8989
__kvm_lapic_set_reg(apic->regs, reg_off, val);
9090
}
9191

92-
static __always_inline u64 __kvm_lapic_get_reg64(char *regs, int reg)
92+
static __always_inline u64 __kvm_lapic_get_reg64(void *regs, int reg)
9393
{
9494
BUILD_BUG_ON(reg != APIC_ICR);
9595
return *((u64 *) (regs + reg));
@@ -100,7 +100,7 @@ static __always_inline u64 kvm_lapic_get_reg64(struct kvm_lapic *apic, int reg)
100100
return __kvm_lapic_get_reg64(apic->regs, reg);
101101
}
102102

103-
static __always_inline void __kvm_lapic_set_reg64(char *regs, int reg, u64 val)
103+
static __always_inline void __kvm_lapic_set_reg64(void *regs, int reg, u64 val)
104104
{
105105
BUILD_BUG_ON(reg != APIC_ICR);
106106
*((u64 *) (regs + reg)) = val;

arch/x86/kvm/lapic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static inline void kvm_lapic_set_irr(int vec, struct kvm_lapic *apic)
165165
apic->irr_pending = true;
166166
}
167167

168-
static inline u32 __kvm_lapic_get_reg(char *regs, int reg_off)
168+
static inline u32 __kvm_lapic_get_reg(void *regs, int reg_off)
169169
{
170170
return *((u32 *) (regs + reg_off));
171171
}

0 commit comments

Comments
 (0)