xen/arch/x86/apic.c | 4 ++-- xen/arch/x86/include/asm/apic.h | 10 +++++++--- xen/arch/x86/include/asm/apicdef.h | 2 -- xen/arch/x86/io_apic.c | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-)
Right now the apic_mem_*() helpers only compile because sizeof(void *) ==
sizeof(long long). Switch to using fix_to_virt() which is a void *type.
Also adjust the two places where the APIC/IO-APIC virtual address is rendered
in a printk().
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
Split out of %L patch.
---
xen/arch/x86/apic.c | 4 ++--
xen/arch/x86/include/asm/apic.h | 10 +++++++---
xen/arch/x86/include/asm/apicdef.h | 2 --
xen/arch/x86/io_apic.c | 4 ++--
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index 6567af685a1b..7869c30e83f6 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -938,8 +938,8 @@ void __init init_apic_mappings(void)
apic_phys = mp_lapic_addr;
set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
- apic_printk(APIC_VERBOSE, "mapped APIC to %08Lx (%08lx)\n", APIC_BASE,
- apic_phys);
+ apic_printk(APIC_VERBOSE, "mapped APIC to %p (%08lx)\n",
+ fix_to_virt(FIX_APIC_BASE), apic_phys);
__next:
/*
diff --git a/xen/arch/x86/include/asm/apic.h b/xen/arch/x86/include/asm/apic.h
index a7798de02993..25faa54d9d10 100644
--- a/xen/arch/x86/include/asm/apic.h
+++ b/xen/arch/x86/include/asm/apic.h
@@ -51,12 +51,16 @@ const struct genapic *apic_x2apic_probe(void);
static inline void apic_mem_write(unsigned int reg, uint32_t v)
{
- *((volatile u32 *)(APIC_BASE+reg)) = v;
+ volatile uint32_t *addr = fix_to_virt(FIX_APIC_BASE) + reg;
+
+ *addr = v;
}
-static inline u32 apic_mem_read(unsigned int reg)
+static inline uint32_t apic_mem_read(unsigned int reg)
{
- return *((volatile u32 *)(APIC_BASE+reg));
+ volatile uint32_t *addr = fix_to_virt(FIX_APIC_BASE) + reg;
+
+ return *addr;
}
/* NOTE: in x2APIC mode, we should use apic_icr_write()/apic_icr_read() to
diff --git a/xen/arch/x86/include/asm/apicdef.h b/xen/arch/x86/include/asm/apicdef.h
index b0790fad1cdb..49e29ec80156 100644
--- a/xen/arch/x86/include/asm/apicdef.h
+++ b/xen/arch/x86/include/asm/apicdef.h
@@ -117,8 +117,6 @@
/* Applicable to vectors, TPR, and PPR. */
#define APIC_PRIO_CLASS(v) ((v) & 0xF0)
-#define APIC_BASE __fix_to_virt(FIX_APIC_BASE)
-
#define MAX_IO_APICS 128
extern bool x2apic_enabled;
diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index 7744b43f2414..772700584639 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -2596,8 +2596,8 @@ static void __init ioapic_init_mappings(void)
}
set_fixmap_nocache(idx, ioapic_phys);
- apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08Lx (%08lx)\n",
- __fix_to_virt(idx), ioapic_phys);
+ apic_printk(APIC_VERBOSE, "mapped IOAPIC to %p (%08lx)\n",
+ fix_to_virt(idx), ioapic_phys);
if ( bad_ioapic_register(i) )
{
--
2.39.2
On 30.07.2024 14:17, Andrew Cooper wrote: > Right now the apic_mem_*() helpers only compile because sizeof(void *) == > sizeof(long long). Switch to using fix_to_virt() which is a void *type. > > Also adjust the two places where the APIC/IO-APIC virtual address is rendered > in a printk(). > > No functional change. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com> ideally ... > --- a/xen/arch/x86/include/asm/apic.h > +++ b/xen/arch/x86/include/asm/apic.h > @@ -51,12 +51,16 @@ const struct genapic *apic_x2apic_probe(void); > > static inline void apic_mem_write(unsigned int reg, uint32_t v) > { > - *((volatile u32 *)(APIC_BASE+reg)) = v; > + volatile uint32_t *addr = fix_to_virt(FIX_APIC_BASE) + reg; > + > + *addr = v; > } > > -static inline u32 apic_mem_read(unsigned int reg) > +static inline uint32_t apic_mem_read(unsigned int reg) > { > - return *((volatile u32 *)(APIC_BASE+reg)); > + volatile uint32_t *addr = fix_to_virt(FIX_APIC_BASE) + reg; ... with const added here. Jan
On 30/07/2024 1:20 pm, Jan Beulich wrote: > On 30.07.2024 14:17, Andrew Cooper wrote: >> Right now the apic_mem_*() helpers only compile because sizeof(void *) == >> sizeof(long long). Switch to using fix_to_virt() which is a void *type. >> >> Also adjust the two places where the APIC/IO-APIC virtual address is rendered >> in a printk(). >> >> No functional change. >> >> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> > Reviewed-by: Jan Beulich <jbeulich@suse.com> > ideally ... > >> --- a/xen/arch/x86/include/asm/apic.h >> +++ b/xen/arch/x86/include/asm/apic.h >> @@ -51,12 +51,16 @@ const struct genapic *apic_x2apic_probe(void); >> >> static inline void apic_mem_write(unsigned int reg, uint32_t v) >> { >> - *((volatile u32 *)(APIC_BASE+reg)) = v; >> + volatile uint32_t *addr = fix_to_virt(FIX_APIC_BASE) + reg; >> + >> + *addr = v; >> } >> >> -static inline u32 apic_mem_read(unsigned int reg) >> +static inline uint32_t apic_mem_read(unsigned int reg) >> { >> - return *((volatile u32 *)(APIC_BASE+reg)); >> + volatile uint32_t *addr = fix_to_virt(FIX_APIC_BASE) + reg; > ... with const added here. Oops yes. Will fix. Thanks. ~Andrew
© 2016 - 2024 Red Hat, Inc.