|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/4] xen/arch: Switch local_save_flags() to being a static inline helper
... rather than a macro which writes to its parameter by name. A consequence
of this change is that the local variables in local_*_is_enabled() can be
dropped.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>
---
xen/arch/x86/io_apic.c | 2 +-
xen/include/asm-arm/arm32/system.h | 30 +++++++++++++-----------------
xen/include/asm-arm/arm64/system.h | 32 ++++++++++++--------------------
xen/include/asm-arm/system.h | 6 +-----
xen/include/asm-x86/system.h | 22 +++++++++++-----------
5 files changed, 38 insertions(+), 54 deletions(-)
diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index daa5e9e..aca4f63 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -1486,7 +1486,7 @@ static int __init timer_irq_works(void)
t1 = ACCESS_ONCE(pit0_ticks);
- local_save_flags(flags);
+ flags = local_save_flags();
local_irq_enable();
/* Let ten ticks pass... */
mdelay((10 * 1000) / HZ);
diff --git a/xen/include/asm-arm/arm32/system.h
b/xen/include/asm-arm/arm32/system.h
index 58c8fb3..cbfa91d 100644
--- a/xen/include/asm-arm/arm32/system.h
+++ b/xen/include/asm-arm/arm32/system.h
@@ -7,15 +7,19 @@
#define local_irq_disable() asm volatile ( "cpsid i @ local_irq_disable\n" : :
: "cc" )
#define local_irq_enable() asm volatile ( "cpsie i @ local_irq_enable\n" : :
: "cc" )
-#define local_save_flags(x) \
-({ \
- BUILD_BUG_ON(sizeof(x) != sizeof(long)); \
- asm volatile ( "mrs %0, cpsr @ local_save_flags\n" \
- : "=r" (x) :: "memory", "cc" ); \
-})
+static inline unsigned long local_save_flags(void)
+{
+ unsigned long flags;
+
+ asm volatile ( "mrs %0, cpsr @ local_SAVE_flags\n"
+ : "=r" (flags) :: "memory", "cc" );
+
+ return flags;
+}
+
#define local_irq_save(x) \
({ \
- local_save_flags(x); \
+ x = local_save_flags(); \
local_irq_disable(); \
})
#define local_irq_restore(x) \
@@ -30,11 +34,7 @@
static inline bool local_irq_is_enabled(void)
{
- unsigned long flags;
-
- local_save_flags(flags);
-
- return !(flags & PSR_IRQ_MASK);
+ return !(local_save_flags() & PSR_IRQ_MASK);
}
#define local_fiq_enable() __asm__("cpsie f @ __stf\n" : : : "memory", "cc")
@@ -45,11 +45,7 @@ static inline bool local_irq_is_enabled(void)
static inline bool local_fiq_is_enabled(void)
{
- unsigned long flags;
-
- local_save_flags(flags);
-
- return !(flags & PSR_FIQ_MASK);
+ return !(local_save_flags() & PSR_FIQ_MASK);
}
#define CSDB ".inst 0xe320f014"
diff --git a/xen/include/asm-arm/arm64/system.h
b/xen/include/asm-arm/arm64/system.h
index d17fc9d..89c5b64 100644
--- a/xen/include/asm-arm/arm64/system.h
+++ b/xen/include/asm-arm/arm64/system.h
@@ -19,19 +19,19 @@
#define local_abort_disable() asm volatile ( "msr daifset, #4\n" ::: "memory" )
#define local_abort_enable() asm volatile ( "msr daifclr, #4\n" ::: "memory" )
-#define local_save_flags(x) \
-({ \
- BUILD_BUG_ON(sizeof(x) != sizeof(long)); \
- asm volatile( \
- "mrs %0, daif // local_save_flags\n" \
- : "=r" (x) \
- : \
- : "memory"); \
-})
+static inline unsigned long local_save_flags(void)
+{
+ unsigned long flags;
+
+ asm volatile ( "mrs %0, daif // local_SAVE_flags\n"
+ : "=r" (flags) :: "memory");
+
+ return flags;
+}
#define local_irq_save(x) \
({ \
- local_save_flags(x); \
+ x = local_save_flags(); \
local_irq_disable(); \
})
#define local_irq_restore(x) \
@@ -46,20 +46,12 @@
static inline bool local_irq_is_enabled(void)
{
- unsigned long flags;
-
- local_save_flags(flags);
-
- return !(flags & PSR_IRQ_MASK);
+ return !(local_save_flags() & PSR_IRQ_MASK);
}
static inline bool local_fiq_is_enabled(void)
{
- unsigned long flags;
-
- local_save_flags(flags);
-
- return !(flags & PSR_FIQ_MASK);
+ return !(local_save_flags() & PSR_FIQ_MASK);
}
#define csdb() asm volatile ( "hint #20" : : : "memory" )
diff --git a/xen/include/asm-arm/system.h b/xen/include/asm-arm/system.h
index bc51300..6566528 100644
--- a/xen/include/asm-arm/system.h
+++ b/xen/include/asm-arm/system.h
@@ -53,11 +53,7 @@
static inline bool local_abort_is_enabled(void)
{
- unsigned long flags;
-
- local_save_flags(flags);
-
- return !(flags & PSR_ABT_MASK);
+ return !(local_save_flags() & PSR_ABT_MASK);
}
#define arch_fetch_and_add(x, v) __sync_fetch_and_add(x, v)
diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
index 4b7056d..faf2efe 100644
--- a/xen/include/asm-x86/system.h
+++ b/xen/include/asm-x86/system.h
@@ -253,14 +253,18 @@ static inline unsigned long
array_index_mask_nospec(unsigned long index,
/* used when interrupts are already enabled or to shutdown the processor */
#define halt() asm volatile ( "hlt" : : : "memory" )
-#define local_save_flags(x) \
-({ \
- BUILD_BUG_ON(sizeof(x) != sizeof(long)); \
- asm volatile ( "pushf" __OS " ; pop" __OS " %0" : "=g" (x)); \
-})
+static inline unsigned long local_save_flags(void)
+{
+ unsigned long flags;
+
+ asm volatile ( "pushf; pop %0;" : "=g" (flags) );
+
+ return flags;
+}
+
#define local_irq_save(x) \
({ \
- local_save_flags(x); \
+ x = local_save_flags(); \
local_irq_disable(); \
})
#define local_irq_restore(x) \
@@ -276,11 +280,7 @@ static inline unsigned long
array_index_mask_nospec(unsigned long index,
static inline bool local_irq_is_enabled(void)
{
- unsigned long flags;
-
- local_save_flags(flags);
-
- return flags & X86_EFLAGS_IF;
+ return local_save_flags() & X86_EFLAGS_IF;
}
#define BROKEN_ACPI_Sx 0x0001
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |