xen: event channel arrays are xen_ulong_t and not unsigned long
Subsystems (5)
PATCH v2 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
The following two patches (one for Xen, one for Linux) switch Xen event channels from unsigned long to xen_ulong_t.
On arm, this enables us to have the same interface on arm32 and arm64 because xen_ulong_t is a 64-bit type on ARM.
On x86 there is no change because xen_ulong_t is unsigned long on x86.
Since this is an ABI change on ARM I hope we can get this in for the 3.9 merge window. I have deferred the other changes which I previously posted along side this since they are not so critical.
Ian.
PATCH 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 ++++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 103 ++++++++++++++++++++----------------- include/xen/interface/xen.h | 8 ++-- 4 files changed, 84 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ read_evtchn_pending_sel\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +55 -48
288 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5
Quoted 16 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.org---
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
Quoted 6 lines
--- arch/arm/include/asm/xen/events.h | 22 ++++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 103 ++++++++++++++++++++----------------- include/xen/interface/xen.h | 8 ++-- 4 files changed, 84 insertions(+), 52 deletions(-)
You might have to rebase this patch: it doesn't apply on Linux 3.8.
Quoted 10 lines
arch/arm/include/asm/xen/events.h +2
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 10 lines
arch/arm/include/asm/xen/events.h +10
-0+* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"
^ do we need this?
Quoted 11 lines
arch/arm/include/asm/xen/events.h +10
-0+ "1: ldrexd %0, %H0, [%3]\n" + " strexd %1, %2, %H2, [%3]\n" + " teq %1, #0\n" + " bne 1b" + : "=&r" (oldval), "=&r" (tmp) + : "r" (val), "r" (ptr) + : "memory", "cc"); + return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
[...]
Quoted 6 lines
arch/arm/include/asm/xen/events.h +1
-1@@ -1295,18 +1306,14 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words;
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1308
Quoted 10 lines
arch/arm/include/asm/xen/events.h +0
-4vcpu_info->evtchn_upcall_pending =0 ;if (__this_cpu_inc_return (xed_nesting_count) -1 ) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif
Even though I understand that moving wmb() into xchg_xen_ulong gets rid of an ugly ifndef, I am not sure whether it is a good thing from the code readability point of view. I'll let Konrad decide on this one.
Quoted 17 lines
arch/arm/include/asm/xen/events.h +3
-3- pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); + pending_words =xchg_xen_ulong (&vcpu_info->evtchn_pending_sel,0 ); start_word_idx =__this_cpu_read (current_word_idx); start_bit_idx =__this_cpu_read (current_bit_idx);@@ -1314,8 +1321,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1340
Quoted 8 lines
arch/arm/include/asm/xen/events.h +1
-1@@ -1327,7 +1334,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */
is that because find_first_bit can actually cope with a bit number >= 32 and __ffs can't?
In that case it is worth adding a comment somewhere in this file, reminding people to only use bit operations that can handle size > unsigned long
Quoted 24 lines · Stefano Stabellini
Quoted 16 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.org---
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...Quoted 6 lines
--- arch/arm/include/asm/xen/events.h | 22 ++++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 103 ++++++++++++++++++++----------------- include/xen/interface/xen.h | 8 ++-- 4 files changed, 84 insertions(+), 52 deletions(-)
Quoted 1 line
You might have to rebase this patch: it doesn't apply on Linux 3.8.
Will do.
Quoted 10 lines
Quoted 10 lines
arch/arm/include/asm/xen/events.h +0
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); }
Quoted 13 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 12 lines
arch/arm/include/asm/xen/events.h +12
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"^ do we need this?
It means that the .s files (if you create them) and such are a bit more readable, it's not that uncommon in the ARM inline assembly.
Quoted 26 lines
Quoted 11 lines
arch/arm/include/asm/xen/events.h +10
-0+ "1: ldrexd %0, %H0, [%3]\n" + " strexd %1, %2, %H2, [%3]\n" + " teq %1, #0\n" + " bne 1b" + : "=&r" (oldval), "=&r" (tmp) + : "r" (val), "r" (ptr) + : "memory", "cc"); + return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ [...]
Quoted 12 lines
arch/arm/include/asm/xen/events.h +1
-1@@ -1295,18 +1306,14 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out;
Quoted 8 lines
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1308
Quoted 4 lines
arch/arm/include/asm/xen/events.h +0
-4-#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif Even though I understand that moving
wmb()intoxchg_xen_ulonggets rid of an ugly ifndef, I am not sure whether it is a good thing from the code readability point of view. I'll let Konrad decide on this one.
I actually see this the other way -- this barrier is logically part of the exchange operation, implicitly on x86 and explicitly on ARM. I will add a comment here though, which I think is best of both.
Quoted 25 lines
Quoted 25 lines
arch/arm/include/asm/xen/events.h +4
-4- pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); + pending_words =xchg_xen_ulong (&vcpu_info->evtchn_pending_sel,0 ); start_word_idx =__this_cpu_read (current_word_idx); start_bit_idx =__this_cpu_read (current_bit_idx);@@ -1314,8 +1321,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1334,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words));
Quoted 5 lines
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1340
Quoted 2 lines
arch/arm/include/asm/xen/events.h +0
-0pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ is that because
find_first_bitcan actually cope with a bit number >= 32 and__ffscan't?
Yes.
Quoted 3 lines
In that case it is worth adding a comment somewhere in this file, reminding people to only use bit operations that can handle size > unsigned long
Will do.
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Stefano Stabellini
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 12 lines · Ian Campbell
arch/arm/include/asm/xen/events.h +12
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"^ do we need this?
Quoted 2 lines
It means that the .s files (if you create them) and such are a bit more readable, it's not that uncommon in the ARM inline assembly.
+1. s/read_evtchn_pending_sel/xchg_xen_ulong/ though.
Tim.
Quoted 17 lines · Tim Deegan
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Stefano Stabellini
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 12 lines · Ian Campbell
arch/arm/include/asm/xen/events.h +12
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"^ do we need this?
Quoted 4 lines
Quoted 2 lines
It means that the .s files (if you create them) and such are a bit more readable, it's not that uncommon in the ARM inline assembly.
+1. s/read_evtchn_pending_sel/xchg_xen_ulong/ though.
Damn, yes. I just sent v3 too :-(
Ian.
Quoted 17 lines · Tim Deegan
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Stefano Stabellini
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 12 lines · Ian Campbell
arch/arm/include/asm/xen/events.h +12
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"^ do we need this?
Quoted 4 lines
Quoted 2 lines
It means that the .s files (if you create them) and such are a bit more readable, it's not that uncommon in the ARM inline assembly.
+1. s/read_evtchn_pending_sel/xchg_xen_ulong/ though.
Damn, yes. I just sent v3 too :-(
Ian.
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Stefano Stabellini
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 12 lines · Ian Campbell
arch/arm/include/asm/xen/events.h +12
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"^ do we need this?
Quoted 2 lines
It means that the .s files (if you create them) and such are a bit more readable, it's not that uncommon in the ARM inline assembly.
+1. s/read_evtchn_pending_sel/xchg_xen_ulong/ though.
Tim.
Quoted 24 lines · Stefano Stabellini
Quoted 16 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>---
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...Quoted 6 lines
--- arch/arm/include/asm/xen/events.h | 22 ++++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 103 ++++++++++++++++++++----------------- include/xen/interface/xen.h | 8 ++-- 4 files changed, 84 insertions(+), 52 deletions(-)
Quoted 1 line
You might have to rebase this patch: it doesn't apply on Linux 3.8.
Will do.
Quoted 10 lines
Quoted 10 lines
arch/arm/include/asm/xen/events.h +0
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); }
Quoted 13 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 12 lines
arch/arm/include/asm/xen/events.h +12
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"^ do we need this?
It means that the .s files (if you create them) and such are a bit more readable, it's not that uncommon in the ARM inline assembly.
Quoted 26 lines
Quoted 11 lines
arch/arm/include/asm/xen/events.h +10
-0+ "1: ldrexd %0, %H0, [%3]\n" + " strexd %1, %2, %H2, [%3]\n" + " teq %1, #0\n" + " bne 1b" + : "=&r" (oldval), "=&r" (tmp) + : "r" (val), "r" (ptr) + : "memory", "cc"); + return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ [...]
Quoted 12 lines
arch/arm/include/asm/xen/events.h +1
-1@@ -1295,18 +1306,14 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out;
Quoted 8 lines
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1308
Quoted 4 lines
arch/arm/include/asm/xen/events.h +0
-4-#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif Even though I understand that moving
wmb()intoxchg_xen_ulonggets rid of an ugly ifndef, I am not sure whether it is a good thing from the code readability point of view. I'll let Konrad decide on this one.
I actually see this the other way -- this barrier is logically part of the exchange operation, implicitly on x86 and explicitly on ARM. I will add a comment here though, which I think is best of both.
Quoted 25 lines
Quoted 25 lines
arch/arm/include/asm/xen/events.h +4
-4- pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); + pending_words =xchg_xen_ulong (&vcpu_info->evtchn_pending_sel,0 ); start_word_idx =__this_cpu_read (current_word_idx); start_bit_idx =__this_cpu_read (current_bit_idx);@@ -1314,8 +1321,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1334,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words));
Quoted 5 lines
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1340
Quoted 2 lines
arch/arm/include/asm/xen/events.h +0
-0pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ is that because
find_first_bitcan actually cope with a bit number >= 32 and__ffscan't?
Yes.
Quoted 3 lines
In that case it is worth adding a comment somewhere in this file, reminding people to only use bit operations that can handle size > unsigned long
Will do.
Quoted 16 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>---
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
Quoted 6 lines
--- arch/arm/include/asm/xen/events.h | 22 ++++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 103 ++++++++++++++++++++----------------- include/xen/interface/xen.h | 8 ++-- 4 files changed, 84 insertions(+), 52 deletions(-)
You might have to rebase this patch: it doesn't apply on Linux 3.8.
Quoted 10 lines
arch/arm/include/asm/xen/events.h +2
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 29
Quoted 10 lines
arch/arm/include/asm/xen/events.h +10
-0+* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asm volatile("@ read_evtchn_pending_sel\n"
^ do we need this?
Quoted 11 lines
arch/arm/include/asm/xen/events.h +10
-0+ "1: ldrexd %0, %H0, [%3]\n" + " strexd %1, %2, %H2, [%3]\n" + " teq %1, #0\n" + " bne 1b" + : "=&r" (oldval), "=&r" (tmp) + : "r" (val), "r" (ptr) + : "memory", "cc"); + return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
[...]
Quoted 6 lines
arch/arm/include/asm/xen/events.h +1
-1@@ -1295,18 +1306,14 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words;
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1308
Quoted 10 lines
arch/arm/include/asm/xen/events.h +0
-4vcpu_info->evtchn_upcall_pending =0 ;if (__this_cpu_inc_return (xed_nesting_count) -1 ) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif
Even though I understand that moving wmb() into xchg_xen_ulong gets rid of an ugly ifndef, I am not sure whether it is a good thing from the code readability point of view. I'll let Konrad decide on this one.
Quoted 17 lines
arch/arm/include/asm/xen/events.h +3
-3- pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); + pending_words =xchg_xen_ulong (&vcpu_info->evtchn_pending_sel,0 ); start_word_idx =__this_cpu_read (current_word_idx); start_bit_idx =__this_cpu_read (current_bit_idx);@@ -1314,8 +1321,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);
arch/arm/include/asm/xen/events.h static void __xen_evtchn_do_upcall(void) · line 1340
Quoted 8 lines
arch/arm/include/asm/xen/events.h +1
-1@@ -1327,7 +1334,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */
is that because find_first_bit can actually cope with a bit number >= 32 and __ffs can't?
In that case it is worth adding a comment somewhere in this file, reminding people to only use bit operations that can handle size > unsigned long
PATCH 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 ++++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 103 ++++++++++++++++++++----------------- include/xen/interface/xen.h | 8 ++-- 4 files changed, 84 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ read_evtchn_pending_sel\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +55 -48
288 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5
PATCH 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)
tools/include/xen-foreign/mkheader.py +6 -0
@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1
@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
xen/include/public/xen.h +4 -4
@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */
@@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.9.1
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 8 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.org
Quoted 71 lines
tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +4
-4@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base Signature · 1 line
1.7.9.1
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 8 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>
Quoted 71 lines
tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +4
-4@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base Signature · 1 line
1.7.9.1
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>
Are you guys (un)happy with this change from the Xen & x86 side?
Quoted 74 lines
Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.org--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +4
-4@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Fine by me.
-- Keir
Quoted 78 lines
Quoted 76 lines
Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.org--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +1
-1@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*xen/include/public/xen.h +3
-3@@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Quoted 7 lines · Keir Fraser
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Fine by me.
I'm going to take that as an Acked-by then, assuming that's ok with you. I suppose Fine-by: Keir would do too ;-)
Ian.
Quoted 7 lines · Keir Fraser
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Fine by me.
I'm going to take that as an Acked-by then, assuming that's ok with you. I suppose Fine-by: Keir would do too ;-)
Ian.
Quoted 10 lines · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Fine by me.
-- Keir
Quoted 78 lines
Quoted 76 lines
Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +1
-1@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*xen/include/public/xen.h +3
-3@@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
I don't see any problem with it.
Jan
Quoted 76 lines
Review
Quoted 11 lines
Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/tools/include/xen-foreign/mkheader.pyQuoted 35 lines
index d189b07..57681fa 100644
tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +0
-0xen/include/public/xen.h DEFINE_XEN_GUEST_HANDLE(multicall_entry_t); · line 559
Quoted 4 lines
xen/include/public/xen.h +0
-1@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) *64)
Quoted 24 lines
xen/include/public/xen.h +4
-3+#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Ian.
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Are you guys (un)happy with this change from the Xen & x86 side?
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Well, I specifically didn't say "ack": I don't really mind the change, but I'm also not eager see it go in. Not seeing a problem with it doesn't really mean there's none lurking - type changes in public interfaces are always an at least slightly risky business.
Jan
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Well, I specifically didn't say "ack": I don't really mind the change, but I'm also not eager see it go in. Not seeing a problem with it doesn't really mean there's none lurking - type changes in public interfaces are always an at least slightly risky business.
For x86 there is no change here since:
xen/include/public/arch-x86/xen.h:typedef unsigned long xen_ulong_t;
Also the tools/include/xen-foreign checks show no change in the size of things on x86.
On ARM the change is deliberate, if there is any fallout we can fix it.
Ian.
Quoted 25 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Well, I specifically didn't say "ack": I don't really mind the change, but I'm also not eager see it go in. Not seeing a problem with it doesn't really mean there's none lurking - type changes in public interfaces are always an at least slightly risky business.
Quoted 5 lines
For x86 there is no change here since:
xen/include/public/arch-x86/xen.h:typedef unsigned longxen_ulong_t;Also the
tools/include/xen-foreignchecks show no change in the size of things on x86.
Which is why I said I see no problem with it.
Quoted 1 line
On ARM the change is deliberate, if there is any fallout we can fix it.
I understand that.
Jan
Quoted 25 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Well, I specifically didn't say "ack": I don't really mind the change, but I'm also not eager see it go in. Not seeing a problem with it doesn't really mean there's none lurking - type changes in public interfaces are always an at least slightly risky business.
Quoted 5 lines
For x86 there is no change here since:
xen/include/public/arch-x86/xen.h:typedef unsigned longxen_ulong_t;Also the
tools/include/xen-foreignchecks show no change in the size of things on x86.
Which is why I said I see no problem with it.
Quoted 1 line
On ARM the change is deliberate, if there is any fallout we can fix it.
I understand that.
Jan
Quoted 14 lines · Jan Beulich
Quoted 14 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 12 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Well, I specifically didn't say "ack": I don't really mind the change, but I'm also not eager see it go in. Not seeing a problem with it doesn't really mean there's none lurking - type changes in public interfaces are always an at least slightly risky business.
For x86 there is no change here since:
xen/include/public/arch-x86/xen.h:typedef unsigned long xen_ulong_t;
Also the tools/include/xen-foreign checks show no change in the size of things on x86.
On ARM the change is deliberate, if there is any fallout we can fix it.
Ian.
Quoted 12 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Are you guys (un)happy with this change from the Xen & x86 side?
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Well, I specifically didn't say "ack": I don't really mind the change, but I'm also not eager see it go in. Not seeing a problem with it doesn't really mean there's none lurking - type changes in public interfaces are always an at least slightly risky business.
Jan
Quoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
I don't see any problem with it.
I'll take this as an Acked-by if that's ok with you.
Ian.
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Are you guys (un)happy with this change from the Xen & x86 side?
I don't see any problem with it.
Jan
Quoted 76 lines
Review
Quoted 11 lines
Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)(quoted diff) +0
-0
b/tools/include/xen-foreign/mkheader.pyQuoted 35 lines
index d189b07..57681fa 100644
tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +0
-0xen/include/public/xen.h DEFINE_XEN_GUEST_HANDLE(multicall_entry_t); · line 559
Quoted 4 lines
xen/include/public/xen.h +0
-1@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) *64)
Quoted 24 lines
xen/include/public/xen.h +4
-3+#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Quoted 7 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>
Are you guys (un)happy with this change from the Xen & x86 side?
Quoted 74 lines
Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)tools/include/xen-foreign/mkheader.py +6
-0@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)xen/include/public/xen.h +4
-4@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */ @@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
PATCH 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
--- tools/include/xen-foreign/mkheader.py | 6 ++++++ xen/include/public/xen.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-)
tools/include/xen-foreign/mkheader.py +6 -0
@@ -21,13 +21,18 @@ inttypes["arm"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint64_t", + "xen_ulong_t" : "uint64_t", }; +header["arm"] = """ +#define __arm___ARM32 1 +"""; # x86_32 inttypes["x86_32"] = { "unsigned long" : "uint32_t", "long" : "uint32_t", "xen_pfn_t" : "uint32_t", + "xen_ulong_t" : "uint32_t", }; header["x86_32"] = """ #define __i386___X86_32 1
@@ -42,6 +47,7 @@ inttypes["x86_64"] = { "unsigned long" : "__align8__ uint64_t", "long" : "__align8__ uint64_t", "xen_pfn_t" : "__align8__ uint64_t", + "xen_ulong_t" : "__align8__ uint64_t", }; header["x86_64"] = """ #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
xen/include/public/xen.h +4 -4
@@ -556,7 +556,7 @@ DEFINE_XEN_GUEST_HANDLE(multicall_entry_t);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -613,7 +613,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct vcpu_time_info time; };/* 64 bytes (x86) */
@@ -663,8 +663,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.9.1
PATCH v3 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements on xchg_xen_ulong.
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ read_evtchn_pending_sel\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +65 -48
298 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5
PATCH v3 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements on xchg_xen_ulong.
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ read_evtchn_pending_sel\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +65 -48
298 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5
PATCH v4 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements on xchg_xen_ulong.
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +65 -48
298 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>
Quoted 10 lines
---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
still doesn't apply to 3.8
Quoted 9 lines
do {drivers/xen/events.c +1
-1-unsigned long pending_words; +xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending =0 ;if (__this_cpu_inc_return (xed_nesting_count) -1 ) goto out;
drivers/xen/events.c static void __xen_evtchn_do_upcall(void) · line 1325
Quoted 10 lines
drivers/xen/events.c +5
-5-#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif - pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); +/* +* Master flag must be /before/ clearing selector +* flag. xchg_xen_ulong must contain an appropriate +* barrier. +*/
Master flag must be *cleared* ...
Quoted 4 lines
+
pending_words=xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0);start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);
Quoted 24 lines · Stefano Stabellini
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>Quoted 10 lines
---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
Quoted 1 line
still doesn't apply to 3.8
Weird. It applied to my tree (stable/for-linus-3.9) without fuss.
Quoted 28 lines
Quoted 11 lines
do {drivers/xen/events.c +1
-1-unsigned long pending_words; +xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending =0 ;if (__this_cpu_inc_return (xed_nesting_count) -1 ) goto out;drivers/xen/events.c static void __xen_evtchn_do_upcall(void) · line 1325
Quoted 10 lines
drivers/xen/events.c +5
-5-#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif - pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); +/* +* Master flag must be /before/ clearing selector +* flag. xchg_xen_ulong must contain an appropriate +* barrier. +*/ Master flag must be *cleared* ...
Quoted 4 lines
+
pending_words=xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0);start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);
Quoted 24 lines · Stefano Stabellini
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Quoted 10 lines
---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
Quoted 1 line
still doesn't apply to 3.8
Weird. It applied to my tree (stable/for-linus-3.9) without fuss.
Quoted 28 lines
Quoted 11 lines
do {drivers/xen/events.c +1
-1-unsigned long pending_words; +xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending =0 ;if (__this_cpu_inc_return (xed_nesting_count) -1 ) goto out;drivers/xen/events.c static void __xen_evtchn_do_upcall(void) · line 1325
Quoted 10 lines
drivers/xen/events.c +5
-5-#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif - pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); +/* +* Master flag must be /before/ clearing selector +* flag. xchg_xen_ulong must contain an appropriate +* barrier. +*/ Master flag must be *cleared* ...
Quoted 4 lines
+
pending_words=xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0);start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>
Quoted 10 lines
---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
still doesn't apply to 3.8
Quoted 9 lines
do {drivers/xen/events.c +1
-1-unsigned long pending_words; +xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending =0 ;if (__this_cpu_inc_return (xed_nesting_count) -1 ) goto out;
drivers/xen/events.c static void __xen_evtchn_do_upcall(void) · line 1325
Quoted 10 lines
drivers/xen/events.c +5
-5-#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ -/* Clear master flag /before/ clearing selector flag. */ -wmb (); -#endif - pending_words =xchg (&vcpu_info->evtchn_pending_sel,0 ); +/* +* Master flag must be /before/ clearing selector +* flag. xchg_xen_ulong must contain an appropriate +* barrier. +*/
Master flag must be *cleared* ...
Quoted 4 lines
+
pending_words=xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0);start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);
Quoted 3 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Hehe. You didn't test this, did you :-)
It hangs bootup on X86.
Quoted 429 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +65
-48@@ -80,6 +80,12 @@ enum xen_irq_type { };/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) + +/* * Packed IRQ information: * type - enum xen_irq_type * event channel - irq->event channel mapping @@ -120,7 +126,14 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g test_bit and +* friends but not __ffs). +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +307,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +325,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +352,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +388,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +402,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +416,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +424,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1202,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1218,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1227,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1289,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1311,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be /before/ clearing selector + * flag. xchg_xen_ulong must contain an appropriate + * barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1331,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1344,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1359,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1369,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =find_first_bit (BM (&bits),sizeof (bits));/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1381,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1394,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1504,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1553,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-4@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base Signature · 1 line
1.7.2.5
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Hehe. You didn't test this, did you :-)
It hangs bootup on X86.
Ah wait. The version that hangs was the first posted - I hadn't tested this one yet. I will wait until later on Wednesday to do that.
Quoted 429 lines
Quoted 429 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +65
-48@@ -80,6 +80,12 @@ enum xen_irq_type { };/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) + +/* * Packed IRQ information: * type - enum xen_irq_type * event channel - irq->event channel mapping @@ -120,7 +126,14 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g test_bit and +* friends but not __ffs). +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +307,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +325,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +352,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +388,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +402,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +416,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +424,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1202,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1218,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1227,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1289,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1311,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be /before/ clearing selector + * flag. xchg_xen_ulong must contain an appropriate + * barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1331,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1344,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1359,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1369,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =find_first_bit (BM (&bits),sizeof (bits));/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1381,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1394,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1504,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1553,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-4@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base Signature · 1 line
1.7.2.5
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
This is an ABI change on ARM. X86 does not change.
Hehe. You didn't test this, did you :-)
It hangs bootup on X86.
Ah wait. The version that hangs was the first posted - I hadn't tested this one yet. I will wait until later on Wednesday to do that.
I don't know what I tested yesterday but it surely wasn't this patch because it hangs for me too this morning :-/
Sorry about this, will investigate...
Ian.
Quoted 431 lines
Quoted 431 lines
Quoted 431 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +65
-48@@ -80,6 +80,12 @@ enum xen_irq_type { };/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) + +/* * Packed IRQ information: * type - enum xen_irq_type * event channel - irq->event channel mapping @@ -120,7 +126,14 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g test_bit and +* friends but not __ffs). +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +307,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +325,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +352,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +388,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +402,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +416,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +424,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1202,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1218,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1227,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1289,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1311,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be /before/ clearing selector + * flag. xchg_xen_ulong must contain an appropriate + * barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1331,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1344,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1359,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1369,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =find_first_bit (BM (&bits),sizeof (bits));/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1381,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1394,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1504,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1553,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-5@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base -- 1.7.2.5
Quoted 4 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Konrad Rzeszutek Wilk
Quoted 2 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
This is an ABI change on ARM. X86 does not change.
Hehe. You didn't test this, did you :-)
It hangs bootup on X86.
Ah wait. The version that hangs was the first posted - I hadn't tested this one yet. I will wait until later on Wednesday to do that.
I don't know what I tested yesterday but it surely wasn't this patch because it hangs for me too this morning :-/
Sorry about this, will investigate...
Ian.
Quoted 431 lines
Quoted 431 lines
Quoted 431 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +65
-48@@ -80,6 +80,12 @@ enum xen_irq_type { };/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) + +/* * Packed IRQ information: * type - enum xen_irq_type * event channel - irq->event channel mapping @@ -120,7 +126,14 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g test_bit and +* friends but not __ffs). +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +307,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +325,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +352,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +388,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +402,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +416,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +424,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1202,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1218,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1227,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1289,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1311,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be /before/ clearing selector + * flag. xchg_xen_ulong must contain an appropriate + * barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1331,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1344,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1359,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1369,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =find_first_bit (BM (&bits),sizeof (bits));/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1381,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1394,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1504,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1553,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-5@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base -- 1.7.2.5
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 3 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Hehe. You didn't test this, did you :-)
It hangs bootup on X86.
Ah wait. The version that hangs was the first posted - I hadn't tested this one yet. I will wait until later on Wednesday to do that.
Quoted 429 lines
Quoted 429 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +65
-48@@ -80,6 +80,12 @@ enum xen_irq_type { };/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) + +/* * Packed IRQ information: * type - enum xen_irq_type * event channel - irq->event channel mapping @@ -120,7 +126,14 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g test_bit and +* friends but not __ffs). +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +307,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +325,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +352,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +388,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +402,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +416,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +424,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1202,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1218,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1227,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1289,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1311,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be /before/ clearing selector + * flag. xchg_xen_ulong must contain an appropriate + * barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1331,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1344,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1359,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1369,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =find_first_bit (BM (&bits),sizeof (bits));/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1381,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1394,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1504,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1553,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-4@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base Signature · 1 line
1.7.2.5
Quoted 3 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Hehe. You didn't test this, did you :-)
It hangs bootup on X86.
Quoted 429 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +65
-48@@ -80,6 +80,12 @@ enum xen_irq_type { };/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) + +/* * Packed IRQ information: * type - enum xen_irq_type * event channel - irq->event channel mapping @@ -120,7 +126,14 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g test_bit and +* friends but not __ffs). +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +307,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +325,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +352,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +388,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +402,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +416,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +424,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1202,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1218,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1227,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1289,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1311,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be /before/ clearing selector + * flag. xchg_xen_ulong must contain an appropriate + * barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1331,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1344,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =find_first_bit (BM (&words),sizeof (words)); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1359,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1369,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =find_first_bit (BM (&bits),sizeof (bits));/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1381,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1394,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1504,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1553,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-4@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base Signature · 1 line
1.7.2.5
PATCH v4 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements on xchg_xen_ulong.
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 113 +++++++++++++++++++++---------------- include/xen/interface/xen.h | 8 +- 4 files changed, 94 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +65 -48
298 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5
PATCH v5 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V4
Rebase onto v3.8
Fix wording of comment
Fix bitmask length passed to find_first_bit, need sizeof*8 for bits not just sizeof. Use BITS_PER_EVTCHN_WORD and provide a convenience wrapper.
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements on xchg_xen_ulong.
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 115 +++++++++++++++++++++--------------- include/xen/interface/xen.h | 8 +- 4 files changed, 96 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +67 -48
294 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 8 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>
Quoted 419 lines
Changes since V4
Rebase onto v3.8
Fix wording of comment
Fix bitmask length passed tofind_first_bit, need sizeof*8 for bits not just sizeof. UseBITS_PER_EVTCHN_WORDand provide a convenience wrapper.
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 115 +++++++++++++++++++++--------------- include/xen/interface/xen.h | 8 +- 4 files changed, 96 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +67
-48@@ -120,7 +120,22 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g +* test_bit/find_first_bit and friends but not __ffs) and to pass +* BITS_PER_EVTCHN_WORD as the bitmask length. +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) +/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) +/* Find the first set bit in a evtchn mask */ +#define EVTCHN_FIRST_BIT (w) find_first_bit(BM(&(w)), BITS_PER_EVTCHN_WORD) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +309,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +327,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +354,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +390,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +404,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +418,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +426,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1204,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1220,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1229,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1291,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1313,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be cleared /before/ clearing + * selector flag. xchg_xen_ulong must contain an + * appropriate barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1333,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1346,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =EVTCHN_FIRST_BIT (words); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1361,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1371,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =EVTCHN_FIRST_BIT (bits);/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1383,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1396,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1506,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1555,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-5@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base -- 1.7.2.5
Quoted 4 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Quoted 8 lines
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>
Quoted 419 lines
Changes since V4
Rebase onto v3.8
Fix wording of comment
Fix bitmask length passed tofind_first_bit, need sizeof*8 for bits not just sizeof. UseBITS_PER_EVTCHN_WORDand provide a convenience wrapper.
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 115 +++++++++++++++++++++--------------- include/xen/interface/xen.h | 8 +- 4 files changed, 96 insertions(+), 52 deletions(-)arch/arm/include/asm/xen/events.h +22
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */ arch/x86/include/asm/xen/events.h +3
-0@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */ drivers/xen/events.c +67
-48@@ -120,7 +120,22 @@ static unsigned long *pirq_eoi_map;#endif static bool (*pirq_needs_eoi)(unsigned irq); -static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], +/* +* Note sizeof(xen_ulong_t) can be more than sizeof(unsigned long). Be +* careful to only use bitops which allow for this (e.g +* test_bit/find_first_bit and friends but not __ffs) and to pass +* BITS_PER_EVTCHN_WORD as the bitmask length. +*/ +#define BITS_PER_EVTCHN_WORD (sizeof(xen_ulong_t)*8) +/* +* Make a bitmask (i.e. unsigned long *) of a xen_ulong_t +* array. Primarily to avoid long lines (hence the terse name). +*/ +#define BM (x) (unsigned long *)(x) +/* Find the first set bit in a evtchn mask */ +#define EVTCHN_FIRST_BIT (w) find_first_bit(BM(&(w)), BITS_PER_EVTCHN_WORD) + +static DEFINE_PER_CPU(xen_ulong_t [NR_EVENT_CHANNELS/BITS_PER_EVTCHN_WORD], cpu_evtchn_mask);/* Xen will never allocate port zero for any purpose. */ @@ -294,9 +309,9 @@ static bool pirq_needs_eoi_flag(unsigned irq)return info->u.pirq.flags &PIRQ_NEEDS_EOI ; } -static inline unsigned long active_evtchns (unsigned int cpu, -struct shared_info *sh, -unsigned int idx) +static inline xen_ulong_t active_evtchns (unsigned int cpu, +struct shared_info *sh, +unsigned int idx) {return sh->evtchn_pending[idx] & per_cpu(cpu_evtchn_mask, cpu)[idx] &@@ -312,8 +327,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu));#endif -clear_bit (chn,per_cpu (cpu_evtchn_mask,cpu_from_irq (irq))); -set_bit (chn,per_cpu (cpu_evtchn_mask, cpu)); +clear_bit (chn,BM (per_cpu (cpu_evtchn_mask,cpu_from_irq (irq)))); +set_bit (chn,BM (per_cpu (cpu_evtchn_mask, cpu)));info_for_irq (irq)->cpu = cpu; }@@ -339,19 +354,19 @@ static void init_evtchn_cpu_bindings(void)static inline void clear_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_clear_bit (port, &s->evtchn_pending[0 ]); +sync_clear_bit (port,BM (&s->evtchn_pending[0 ])); }static inline void set_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_pending[0 ]); +sync_set_bit (port,BM (&s->evtchn_pending[0 ])); }static inline int test_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_bit (port, &s->evtchn_pending[0 ]); +return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); }@@ -375,7 +390,7 @@ EXPORT_SYMBOL_GPL(notify_remote_via_irq);static void mask_evtchn (int port) {struct shared_info *s = HYPERVISOR_shared_info; -sync_set_bit (port, &s->evtchn_mask[0 ]); +sync_set_bit (port,BM (&s->evtchn_mask[0 ])); }static void unmask_evtchn (int port)@@ -389,7 +404,7 @@ static void unmask_evtchn(int port)if (unlikely ((cpu !=cpu_from_evtchn (port)))) do_hypercall =1 ;else - evtchn_pending =sync_test_bit (port, &s->evtchn_pending[0 ]); + evtchn_pending =sync_test_bit (port,BM (&s->evtchn_pending[0 ]));if (unlikely (evtchn_pending &&xen_hvm_domain ())) do_hypercall =1 ;@@ -403,7 +418,7 @@ static void unmask_evtchn(int port) }else {struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu); -sync_clear_bit (port, &s->evtchn_mask[0 ]); +sync_clear_bit (port,BM (&s->evtchn_mask[0 ]));/* * The following is basically the equivalent of @@ -411,8 +426,8 @@ static void unmask_evtchn(int port)* the interrupt edge' if the channel is masked. */ if (evtchn_pending && - !sync_test_and_set_bit (port /BITS_PER_LONG , - &vcpu_info->evtchn_pending_sel)) + !sync_test_and_set_bit (port /BITS_PER_EVTCHN_WORD , +BM (&vcpu_info->evtchn_pending_sel))) vcpu_info->evtchn_upcall_pending =1 ; }@@ -1189,7 +1204,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) {struct shared_info *sh = HYPERVISOR_shared_info;int cpu =smp_processor_id (); -unsigned long *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu); +xen_ulong_t *cpu_evtchn =per_cpu (cpu_evtchn_mask, cpu);int i;unsigned long flags;static DEFINE_SPINLOCK (debug_lock);@@ -1205,7 +1220,7 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id) pending = (get_irq_regs () && i == cpu) ?xen_irqs_disabled (get_irq_regs ()) : v->evtchn_upcall_mask; -printk ("%d: masked=%d pending=%d event_sel %0*lx\n " , i, +printk ("%d: masked=%d pending=%d event_sel %0*" PRI_xen_ulong"\n " , i, pending, v->evtchn_upcall_pending, (int )(sizeof (v->evtchn_pending_sel)*2 ), v->evtchn_pending_sel);@@ -1214,49 +1229,52 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)printk ("\npending:\n " );for (i =ARRAY_SIZE (sh->evtchn_pending)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )sizeof (sh->evtchn_pending[0 ])*2 , +printk ("%0*" PRI_xen_ulong"%s" , + (int )sizeof (sh->evtchn_pending[0 ])*2 , sh->evtchn_pending[i], i %8 ==0 ?"\n " :" " );printk ("\nglobal mask:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nglobally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), sh->evtchn_pending[i] & ~sh->evtchn_mask[i], i %8 ==0 ?"\n " :" " );printk ("\nlocal cpu%d mask:\n " , cpu); -for (i = (NR_EVENT_CHANNELS /BITS_PER_LONG )-1 ; i >=0 ; i--) -printk ("%0*lx%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), +for (i = (NR_EVENT_CHANNELS /BITS_PER_EVTCHN_WORD )-1 ; i >=0 ; i--) +printk ("%0*" PRI_xen_ulong"%s" , (int )(sizeof (cpu_evtchn[0 ])*2 ), cpu_evtchn[i], i %8 ==0 ?"\n " :" " );printk ("\nlocally unmasked:\n " );for (i =ARRAY_SIZE (sh->evtchn_mask)-1 ; i >=0 ; i--) { -unsigned long pending = sh->evtchn_pending[i] +xen_ulong_t pending = sh->evtchn_pending[i] & ~sh->evtchn_mask[i] & cpu_evtchn[i]; -printk ("%0*lx%s" , (int )(sizeof (sh->evtchn_mask[0 ])*2 ), +printk ("%0*" PRI_xen_ulong"%s" , + (int )(sizeof (sh->evtchn_mask[0 ])*2 ), pending, i %8 ==0 ?"\n " :" " ); }printk ("\npending list:\n" );for (i =0 ; i <NR_EVENT_CHANNELS ; i++) { -if (sync_test_bit (i, sh->evtchn_pending)) { -int word_idx = i /BITS_PER_LONG ; +if (sync_test_bit (i,BM (sh->evtchn_pending))) { +int word_idx = i /BITS_PER_EVTCHN_WORD ;printk (" %d: event %d -> irq %d%s%s%s\n" ,cpu_from_evtchn (i), i, evtchn_to_irq[i], -sync_test_bit (word_idx, &v->evtchn_pending_sel) +sync_test_bit (word_idx,BM (&v->evtchn_pending_sel)) ?"" :" l2-clear" , - !sync_test_bit (i, sh->evtchn_mask) + !sync_test_bit (i,BM (sh->evtchn_mask)) ?"" :" globally-masked" , -sync_test_bit (i, cpu_evtchn) +sync_test_bit (i,BM (cpu_evtchn)) ?"" :" locally-masked" ); } }@@ -1273,7 +1291,7 @@ static DEFINE_PER_CPU(unsigned int, current_bit_idx);/* * Mask out the i least significant bits of w */ -#define MASK_LSBS (w, i) (w & ((~0UL) << i)) +#define MASK_LSBS (w, i) (w & ((~((xen_ulong_t)0UL)) << i))/* * Search the CPUs pending events bitmasks. For each one found, map @@ -1295,18 +1313,19 @@ static void __xen_evtchn_do_upcall(void)unsigned count; do { - unsigned long pending_words; + xen_ulong_t pending_words; vcpu_info->evtchn_upcall_pending = 0; if (__this_cpu_inc_return(xed_nesting_count) - 1) goto out; -#ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ - /* Clear master flag /before/ clearing selector flag. */ - wmb(); -#endif - pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); + /* + * Master flag must be cleared /before/ clearing + * selector flag. xchg_xen_ulong must contain an + * appropriate barrier. + */ + pending_words = xchg_xen_ulong(&vcpu_info->evtchn_pending_sel, 0); start_word_idx = __this_cpu_read(current_word_idx); start_bit_idx = __this_cpu_read(current_bit_idx);@@ -1314,8 +1333,8 @@ static void __xen_evtchn_do_upcall(void) word_idx = start_word_idx;for (i =0 ; pending_words !=0 ; i++) { -unsigned long pending_bits; -unsigned long words; +xen_ulong_t pending_bits; +xen_ulong_t words; words =MASK_LSBS (pending_words, word_idx);@@ -1327,7 +1346,7 @@ static void __xen_evtchn_do_upcall(void) bit_idx =0 ;continue ; } - word_idx =__ffs (words); + word_idx =EVTCHN_FIRST_BIT (words); pending_bits =active_evtchns (cpu, s, word_idx); bit_idx =0 ;/* usually scan entire word from start */ @@ -1342,7 +1361,7 @@ static void __xen_evtchn_do_upcall(void) } do { - unsigned long bits; + xen_ulong_t bits; int port, irq; struct irq_desc *desc;@@ -1352,10 +1371,10 @@ static void __xen_evtchn_do_upcall(void)if (bits ==0 )break ; - bit_idx =__ffs (bits); + bit_idx =EVTCHN_FIRST_BIT (bits);/* Process port. */ - port = (word_idx *BITS_PER_LONG ) + bit_idx; + port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq = evtchn_to_irq[port];if (irq !=-1 ) {@@ -1364,12 +1383,12 @@ static void __xen_evtchn_do_upcall(void)generic_handle_irq_desc (irq, desc); } - bit_idx = (bit_idx +1 ) %BITS_PER_LONG ; + bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;/* Next caller starts at last processed + 1 */ __this_cpu_write (current_word_idx, bit_idx ? word_idx : - (word_idx+1 ) %BITS_PER_LONG ); + (word_idx+1 ) %BITS_PER_EVTCHN_WORD );__this_cpu_write (current_bit_idx, bit_idx); }while (bit_idx !=0 );@@ -1377,7 +1396,7 @@ static void __xen_evtchn_do_upcall(void)if ((word_idx != start_word_idx) || (i !=0 )) pending_words &= ~(1UL << word_idx); - word_idx = (word_idx +1 ) %BITS_PER_LONG ; + word_idx = (word_idx +1 ) %BITS_PER_EVTCHN_WORD ; }BUG_ON (!irqs_disabled ());@@ -1487,8 +1506,8 @@ int resend_irq_on_evtchn(unsigned int irq)if (!VALID_EVTCHN (evtchn))return 1 ; - masked =sync_test_and_set_bit (evtchn, s->evtchn_mask); -sync_set_bit (evtchn, s->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (s->evtchn_mask)); +sync_set_bit (evtchn,BM (s->evtchn_pending));if (!masked)unmask_evtchn (evtchn);@@ -1536,8 +1555,8 @@ static int retrigger_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {int masked; - masked =sync_test_and_set_bit (evtchn, sh->evtchn_mask); -sync_set_bit (evtchn, sh->evtchn_pending); + masked =sync_test_and_set_bit (evtchn,BM (sh->evtchn_mask)); +sync_set_bit (evtchn,BM (sh->evtchn_pending));if (!masked)unmask_evtchn (evtchn); ret =1 ;include/xen/interface/xen.h +4
-5@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/* @@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */ @@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base -- 1.7.2.5
Quoted 27 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V4
Rebase onto v3.8
Fix wording of comment
Fix bitmask length passed tofind_first_bit, need sizeof*8 for bits not just sizeof. UseBITS_PER_EVTCHN_WORDand provide a convenience wrapper.
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
Quoted 7 lines
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 115 +++++++++++++++++++++--------------- include/xen/interface/xen.h | 8 +- 4 files changed, 96 insertions(+), 52 deletions(-)
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'
This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 21
Quoted 12 lines
arch/arm/include/asm/xen/events.h +4
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions.
Why does atomic64_cmpxchg not work here?
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 28
Quoted 7 lines
arch/arm/include/asm/xen/events.h +7
-0+*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb ();
Based on atomic64_cmpxchg implementation, you could use smp_mb here which avoids an outer cache flush.
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );
And a smp_mb is needed here.
Rob
Quoted 2 lines
arch/arm/include/asm/xen/events.h +2
-0+return oldval; +}
Hi guys,
Quoted 13 lines · Rob Herring
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>
[...]
Quoted 11 lines
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to
atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.
[...]
Quoted 8 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );
I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
Will
Quoted 33 lines · Will Deacon
Hi guys,
Quoted 13 lines · Rob Herring
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>[...]
Quoted 11 lines
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to
atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.[...]
Quoted 11 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
I fixed something along these lines before v5 of this patch, although I must confess I don't recall what it was that I changed (and looking at the older versions of the patch isn't giving me any clues). I can't reproduce it now though :-(
I'm using the 4.6.3 cross compiler from kernel.org:
ftp://ftp.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.6.3/
Ian.
Quoted 33 lines · Will Deacon
Hi guys,
Quoted 13 lines · Rob Herring
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>[...]
Quoted 11 lines
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to
atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.[...]
Quoted 11 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
I fixed something along these lines before v5 of this patch, although I must confess I don't recall what it was that I changed (and looking at the older versions of the patch isn't giving me any clues). I can't reproduce it now though :-(
I'm using the 4.6.3 cross compiler from kernel.org:
ftp://ftp.kernel.org/pub/tools/crosstool/files/bin/x86_64/4.6.3/
Ian.
Quoted 33 lines · Will Deacon
Hi guys,
Quoted 13 lines · Rob Herring
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc xen-devel at lists.xen.orgCc Konrad Rzeszutek Wilk <[email protected]>[...]
Quoted 11 lines
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to
atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.[...]
Quoted 12 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
Here's a config:
CONFIG_SYSVIPC=yCONFIG_POSIX_MQUEUE=yCONFIG_FHANDLE=yCONFIG_IKCONFIG=yCONFIG_CGROUP_FREEZER=yCONFIG_CGROUP_DEVICE=yCONFIG_CPUSETS=y
# CONFIG_PROC_PID_CPUSET is not setCONFIG_CGROUP_CPUACCT=yCONFIG_RESOURCE_COUNTERS=yCONFIG_MEMCG=yCONFIG_MEMCG_KMEM=yCONFIG_MEMCG_DEBUG_ASYNC_DESTROY=yCONFIG_CHECKPOINT_RESTORE=yCONFIG_UIDGID_STRICT_TYPE_CHECKS=yCONFIG_SCHED_AUTOGROUP=yCONFIG_RELAY=yCONFIG_BLK_DEV_INITRD=yCONFIG_RD_BZIP2=yCONFIG_RD_LZMA=yCONFIG_RD_XZ=yCONFIG_RD_LZO=yCONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_PRINTK is not set
# CONFIG_BUG is not set
# CONFIG_BASE_FULL is not set
# CONFIG_EPOLL is not set
# CONFIG_TIMERFD is not set
# CONFIG_SHMEM is not set
# CONFIG_AIO is not setCONFIG_EMBEDDED=y
# CONFIG_PERF_EVENTS is not setCONFIG_PROFILING=y
# CONFIG_BLOCK is not setCONFIG_ARCH_BCM=yCONFIG_GPIO_PCA953X=yCONFIG_ARCH_MXC=yCONFIG_MACH_IMX51_DT=yCONFIG_MACH_EUKREA_CPUIMX51SD=yCONFIG_SOC_IMX53=yCONFIG_ARCH_SOCFPGA=yCONFIG_ARCH_SUNXI=yCONFIG_ARCH_VEXPRESS_CA9X4=yCONFIG_CPU_ICACHE_DISABLE=yCONFIG_CPU_DCACHE_DISABLE=yCONFIG_ARM_ERRATA_430973=yCONFIG_PL310_ERRATA_727915=yCONFIG_HAVE_ARM_ARCH_TIMER=y
# CONFIG_COMPACTION is not set
# CONFIG_CROSS_MEMORY_ATTACH is not setCONFIG_SECCOMP=yCONFIG_CC_STACKPROTECTOR=yCONFIG_XEN=y
# CONFIG_ATAGS is not setCONFIG_ARM_APPENDED_DTB=yCONFIG_ARM_ATAG_DTB_COMPAT=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_FPE_FASTFPE=y
# CONFIG_BINFMT_ELF is not setCONFIG_PM_AUTOSLEEP=yCONFIG_PM_RUNTIME=yCONFIG_PM_DEBUG=yCONFIG_APM_EMULATION=yCONFIG_NET=yCONFIG_XFRM_SUB_POLICY=yCONFIG_XFRM_MIGRATE=yCONFIG_NET_KEY=yCONFIG_NETWORK_PHY_TIMESTAMPING=yCONFIG_NETFILTER=yCONFIG_NETFILTER_DEBUG=yCONFIG_DECNET_NF_GRABULATOR=yCONFIG_ATM=yCONFIG_BRIDGE=yCONFIG_BRIDGE_VLAN_FILTERING=yCONFIG_VLAN_8021Q=yCONFIG_DECNET=yCONFIG_DECNET_ROUTER=yCONFIG_LLC2=yCONFIG_ATALK=yCONFIG_DEV_APPLETALK=yCONFIG_LAPB=yCONFIG_NET_SCHED=yCONFIG_NET_SCH_HTB=yCONFIG_NET_SCH_HFSC=yCONFIG_NET_SCH_ATM=yCONFIG_NET_SCH_PRIO=yCONFIG_NET_SCH_MULTIQ=yCONFIG_NET_SCH_SFB=yCONFIG_NET_SCH_TBF=yCONFIG_NET_SCH_GRED=yCONFIG_NET_SCH_NETEM=yCONFIG_NET_SCH_CHOKE=yCONFIG_NET_SCH_QFQ=yCONFIG_NET_SCH_CODEL=yCONFIG_NET_CLS_TCINDEX=yCONFIG_NET_CLS_U32=yCONFIG_NET_CLS_RSVP=yCONFIG_NET_CLS_ACT=yCONFIG_NET_ACT_SKBEDIT=yCONFIG_NET_CLS_IND=yCONFIG_DCB=yCONFIG_VSOCKETS=yCONFIG_BT=yCONFIG_BT_BNEP=yCONFIG_BT_BNEP_PROTO_FILTER=yCONFIG_BT_HCIUART=yCONFIG_BT_HCIUART_BCSP=yCONFIG_BT_HCIUART_ATH3K=yCONFIG_BT_HCIUART_LL=yCONFIG_BT_HCIBPA10X=yCONFIG_BT_HCIBFUSB=y
# CONFIG_WIRELESS is not setCONFIG_WIMAX=yCONFIG_RFKILL_REGULATOR=yCONFIG_CAIF=yCONFIG_CAIF_DEBUG=yCONFIG_DEVTMPFS=y
# CONFIG_STANDALONE is not set
# CONFIG_FW_LOADER_USER_HELPER is not setCONFIG_DEBUG_DRIVER=yCONFIG_CONNECTOR=y
# CONFIG_PROC_EVENTS is not setCONFIG_ATMEL_PWM=yCONFIG_ENCLOSURE_SERVICES=yCONFIG_ISL29003=yCONFIG_SENSORS_BH1770=yCONFIG_ARM_CHARLCD=yCONFIG_BMP085_I2C=yCONFIG_USB_SWITCH_FSA9480=yCONFIG_EEPROM_AT24=yCONFIG_TI_ST=yCONFIG_ALTERA_STAPL=yCONFIG_NETDEVICES=yCONFIG_DUMMY=yCONFIG_IFB=yCONFIG_MACVLAN=yCONFIG_NETCONSOLE=yCONFIG_VIRTIO_NET=yCONFIG_CAIF_HSI=yCONFIG_NET_DSA_MV88E6060=y
# CONFIG_ETHERNET is not setCONFIG_AMD_PHY=yCONFIG_MARVELL_PHY=yCONFIG_DAVICOM_PHY=yCONFIG_QSEMI_PHY=yCONFIG_VITESSE_PHY=yCONFIG_BCM87XX_PHY=yCONFIG_ICPLUS_PHY=yCONFIG_REALTEK_PHY=yCONFIG_NATIONAL_PHY=yCONFIG_LSI_ET1011C_PHY=yCONFIG_FIXED_PHY=yCONFIG_PPP=yCONFIG_PPP_BSDCOMP=yCONFIG_PPP_DEFLATE=yCONFIG_PPP_MPPE=yCONFIG_PPP_ASYNC=yCONFIG_PPP_SYNC_TTY=yCONFIG_USB_KAWETH=yCONFIG_USB_PEGASUS=yCONFIG_USB_RTL8150=yCONFIG_USB_USBNET=y
# CONFIG_USB_NET_AX8817X is not setCONFIG_USB_NET_CDC_EEM=yCONFIG_USB_NET_SMSC75XX=yCONFIG_USB_NET_GL620A=yCONFIG_USB_NET_MCS7830=y
# CONFIG_USB_NET_CDC_SUBSET is not set
# CONFIG_USB_NET_ZAURUS is not setCONFIG_USB_NET_CX82310_ETH=yCONFIG_USB_NET_KALMIA=yCONFIG_USB_NET_INT51X1=y
# CONFIG_WLAN is not set
# CONFIG_XEN_NETDEV_FRONTEND is not setCONFIG_ISDN=yCONFIG_ISDN_I4L=yCONFIG_ISDN_CAPI=y
# CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON is not set
# CONFIG_CAPI_TRACE is not setCONFIG_ISDN_CAPI_CAPI20=yCONFIG_CAPI_AVM=yCONFIG_CAPI_EICON=yCONFIG_ISDN_DRV_GIGASET=yCONFIG_GIGASET_BASE=yCONFIG_GIGASET_M105=yCONFIG_GIGASET_M101=yCONFIG_GIGASET_DEBUG=yCONFIG_MISDN=y
# CONFIG_INPUT_MOUSEDEV is not setCONFIG_INPUT_JOYDEV=yCONFIG_INPUT_EVDEV=yCONFIG_INPUT_EVBUG=yCONFIG_INPUT_APMPOWER=y
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not setCONFIG_SERIO_LIBPS2=yCONFIG_SERIO_RAW=yCONFIG_SERIO_ALTERA_PS2=yCONFIG_SERIO_PS2MULT=y
# CONFIG_UNIX98_PTYS is not set
# CONFIG_LEGACY_PTYS is not setCONFIG_SERIAL_NONSTANDARD=yCONFIG_N_GSM=yCONFIG_TRACE_SINK=yCONFIG_STALDRV=yCONFIG_SERIAL_AMBA_PL011=yCONFIG_SERIAL_AMBA_PL011_CONSOLE=yCONFIG_SERIAL_SCCNXP=yCONFIG_SERIAL_SCCNXP_CONSOLE=yCONFIG_SERIAL_ALTERA_UART=yCONFIG_SERIAL_ALTERA_UART_CONSOLE=yCONFIG_SERIAL_XILINX_PS_UART=yCONFIG_HVC_DCC=yCONFIG_VIRTIO_CONSOLE=yCONFIG_IPMI_HANDLER=yCONFIG_IPMI_DEVICE_INTERFACE=yCONFIG_HW_RANDOM_TIMERIOMEM=yCONFIG_HW_RANDOM_VIRTIO=y
# CONFIG_HW_RANDOM_TPM is not setCONFIG_R3964=yCONFIG_TCG_TIS_I2C_INFINEON=yCONFIG_I2C_MUX=yCONFIG_I2C_MUX_PINCTRL=y
# CONFIG_I2C_HELPER_AUTO is not setCONFIG_I2C_CBUS_GPIO=yCONFIG_I2C_NOMADIK=yCONFIG_I2C_OCORES=yCONFIG_I2C_PCA_PLATFORM=yCONFIG_I2C_SIMTEC=yCONFIG_I2C_TAOS_EVM=yCONFIG_I2C_TINY_USB=yCONFIG_I2C_DEBUG_CORE=yCONFIG_HSI=yCONFIG_NTP_PPS=yCONFIG_PPS_CLIENT_KTIMER=yCONFIG_PPS_CLIENT_LDISC=yCONFIG_PTP_1588_CLOCK_PCH=yCONFIG_PINCTRL_SINGLE=yCONFIG_PINCTRL_EXYNOS5440=yCONFIG_GPIO_SYSFS=yCONFIG_GPIO_MAX732X=yCONFIG_GPIO_MAX732X_IRQ=yCONFIG_GPIO_SX150X=yCONFIG_GPIO_STMPE=yCONFIG_GPIO_TWL4030=yCONFIG_GPIO_WM831X=yCONFIG_GPIO_WM8350=yCONFIG_GPIO_ADP5520=yCONFIG_GPIO_ADP5588=yCONFIG_GPIO_ADNP=yCONFIG_GPIO_MCP23S08=yCONFIG_GPIO_TPS6586X=yCONFIG_GPIO_VIPERBOARD=yCONFIG_HWMON_DEBUG_CHIP=yCONFIG_SENSORS_AD7418=yCONFIG_SENSORS_ADM1025=yCONFIG_SENSORS_ADT7410=yCONFIG_SENSORS_ADT7462=yCONFIG_SENSORS_ADT7470=yCONFIG_SENSORS_ASC7621=yCONFIG_SENSORS_DS620=yCONFIG_SENSORS_F71805F=yCONFIG_SENSORS_F75375S=yCONFIG_SENSORS_GL518SM=yCONFIG_SENSORS_GL520SM=yCONFIG_SENSORS_GPIO_FAN=yCONFIG_SENSORS_HIH6130=yCONFIG_SENSORS_IBMAEM=yCONFIG_SENSORS_IBMPEX=yCONFIG_SENSORS_IT87=yCONFIG_SENSORS_LM63=yCONFIG_SENSORS_LM73=yCONFIG_SENSORS_LM77=yCONFIG_SENSORS_LM80=yCONFIG_SENSORS_LM83=yCONFIG_SENSORS_LM92=yCONFIG_SENSORS_LTC4215=yCONFIG_SENSORS_LM95241=yCONFIG_SENSORS_MAX6639=yCONFIG_SENSORS_MAX6642=yCONFIG_SENSORS_MAX6650=yCONFIG_SENSORS_MAX6697=yCONFIG_SENSORS_MCP3021=yCONFIG_SENSORS_NTC_THERMISTOR=yCONFIG_SENSORS_PCF8591=yCONFIG_PMBUS=y
# CONFIG_SENSORS_PMBUS is not setCONFIG_SENSORS_ADM1275=yCONFIG_SENSORS_LM25066=yCONFIG_SENSORS_LTC2978=yCONFIG_SENSORS_MAX34440=yCONFIG_SENSORS_ZL6100=yCONFIG_SENSORS_SHT15=yCONFIG_SENSORS_SMM665=yCONFIG_SENSORS_EMC1403=yCONFIG_SENSORS_EMC2103=yCONFIG_SENSORS_EMC6W201=yCONFIG_SENSORS_SMSC47M1=yCONFIG_SENSORS_SCH5627=yCONFIG_SENSORS_SCH5636=yCONFIG_SENSORS_ADS7828=yCONFIG_SENSORS_INA2XX=yCONFIG_SENSORS_TMP102=yCONFIG_SENSORS_TMP401=yCONFIG_SENSORS_TMP421=yCONFIG_SENSORS_W83791D=yCONFIG_SENSORS_W83793=yCONFIG_SENSORS_W83795=yCONFIG_SENSORS_WM831X=yCONFIG_SENSORS_WM8350=yCONFIG_SENSORS_MC13783_ADC=yCONFIG_WATCHDOG=yCONFIG_SOFT_WATCHDOG=yCONFIG_ARM_SP805_WATCHDOG=yCONFIG_TWL4030_WATCHDOG=yCONFIG_MAX63XX_WATCHDOG=yCONFIG_IMX2_WDT=yCONFIG_RETU_WATCHDOG=yCONFIG_USBPCWATCHDOG=yCONFIG_SSB=yCONFIG_SSB_SDIOHOST=yCONFIG_SSB_SILENT=yCONFIG_SSB_DRIVER_GPIO=yCONFIG_BCMA=yCONFIG_BCMA_DRIVER_GMAC_CMN=yCONFIG_BCMA_DRIVER_GPIO=yCONFIG_MFD_88PM860X=yCONFIG_MFD_88PM805=yCONFIG_MFD_SM501=yCONFIG_MFD_SM501_GPIO=yCONFIG_HTC_EGPIO=yCONFIG_HTC_PASIC3=yCONFIG_HTC_I2CPLD=yCONFIG_TPS6507X=yCONFIG_MFD_TPS65217=yCONFIG_MFD_TPS6586X=yCONFIG_TWL4030_CORE=yCONFIG_TWL4030_POWER=yCONFIG_TWL6040_CORE=yCONFIG_MFD_STMPE=y
# CONFIG_STMPE_I2C is not setCONFIG_MFD_T7L66XB=yCONFIG_MFD_TC6387XB=yCONFIG_MFD_TC6393XB=yCONFIG_PMIC_ADP5520=yCONFIG_MFD_LP8788=yCONFIG_MFD_MAX77686=yCONFIG_MFD_MAX77693=yCONFIG_MFD_MAX8998=yCONFIG_MFD_SEC_CORE=yCONFIG_MFD_WM831X_I2C=yCONFIG_MFD_WM8350_I2C=yCONFIG_MFD_PCF50633=yCONFIG_PCF50633_ADC=yCONFIG_MFD_MC13XXX_I2C=yCONFIG_ABX500_CORE=yCONFIG_AB3100_CORE=yCONFIG_MFD_WL1273_CORE=yCONFIG_MFD_VIPERBOARD=yCONFIG_MFD_RETU=yCONFIG_MFD_AS3711=yCONFIG_REGULATOR=yCONFIG_REGULATOR_DUMMY=yCONFIG_REGULATOR_USERSPACE_CONSUMER=yCONFIG_REGULATOR_AD5398=yCONFIG_REGULATOR_MC13892=yCONFIG_REGULATOR_MAX8660=yCONFIG_REGULATOR_MAX8998=yCONFIG_REGULATOR_LP872X=yCONFIG_REGULATOR_LP8755=yCONFIG_REGULATOR_PCF50633=y
# CONFIG_REGULATOR_AB3100 is not setCONFIG_REGULATOR_TPS6586X=yCONFIG_REGULATOR_VEXPRESS=yCONFIG_REGULATOR_WM831X=yCONFIG_REGULATOR_AS3711=yCONFIG_DRM=yCONFIG_DRM_I2C_CH7006=yCONFIG_DRM_I2C_SIL164=yCONFIG_DRM_I2C_NXP_TDA998X=yCONFIG_DRM_EXYNOS=yCONFIG_DRM_EXYNOS_DMABUF=yCONFIG_DRM_EXYNOS_VIDI=yCONFIG_VIDEO_OUTPUT_CONTROL=yCONFIG_OF_DISPLAY_TIMING=yCONFIG_FB_TILEBLITTING=yCONFIG_FB_ARMCLCD=yCONFIG_FB_TMIO=yCONFIG_FB_SMSCUFX=yCONFIG_FB_GOLDFISH=y
# CONFIG_XEN_FBDEV_FRONTEND is not setCONFIG_FB_AUO_K190X=yCONFIG_FB_AUO_K1901=yCONFIG_EXYNOS_VIDEO=yCONFIG_BACKLIGHT_LCD_SUPPORT=y
# CONFIG_BACKLIGHT_GENERIC is not setCONFIG_BACKLIGHT_WM831X=yCONFIG_BACKLIGHT_ADP5520=yCONFIG_BACKLIGHT_PCF50633=yCONFIG_BACKLIGHT_LM3630=yCONFIG_BACKLIGHT_LP855X=yCONFIG_BACKLIGHT_LP8788=yCONFIG_BACKLIGHT_PANDORA=yCONFIG_BACKLIGHT_TPS65217=yCONFIG_BACKLIGHT_AS3711=yCONFIG_FRAMEBUFFER_CONSOLE=yCONFIG_FRAMEBUFFER_CONSOLE_ROTATION=yCONFIG_FONTS=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
CONFIG_FONT_MINI_4x6=y
CONFIG_FONT_10x18=yCONFIG_LOGO=yCONFIG_SOUND=yCONFIG_HIDRAW=yCONFIG_HID_A4TECH=yCONFIG_HID_AUREAL=yCONFIG_HID_BELKIN=yCONFIG_HID_CHERRY=yCONFIG_HID_CYPRESS=yCONFIG_HID_DRAGONRISE=yCONFIG_HID_UCLOGIC=yCONFIG_HID_GYRATION=yCONFIG_HID_LENOVO_TPKBD=yCONFIG_HID_LOGITECH=yCONFIG_HID_LOGITECH_DJ=yCONFIG_LOGITECH_FF=yCONFIG_LOGIRUMBLEPAD2_FF=yCONFIG_HID_MONTEREY=yCONFIG_HID_PANTHERLORD=yCONFIG_HID_PETALYNX=yCONFIG_HID_PICOLCD=yCONFIG_HID_PICOLCD_BACKLIGHT=yCONFIG_HID_PRIMAX=yCONFIG_HID_ROCCAT=yCONFIG_HID_SAITEK=yCONFIG_HID_SAMSUNG=yCONFIG_HID_SONY=yCONFIG_HID_SPEEDLINK=yCONFIG_HID_STEELSERIES=yCONFIG_HID_SUNPLUS=yCONFIG_HID_TOPSEED=yCONFIG_HID_THINGM=yCONFIG_HID_THRUSTMASTER=yCONFIG_USB=yCONFIG_USB_DYNAMIC_MINORS=yCONFIG_USB_SUSPEND=yCONFIG_USB_OTG=y
# CONFIG_USB_OTG_WHITELIST is not setCONFIG_USB_DWC3=yCONFIG_USB_MON=yCONFIG_USB_WUSB_CBAF=yCONFIG_USB_WUSB_CBAF_DEBUG=yCONFIG_USB_OXU210HP_HCD=yCONFIG_USB_ISP116X_HCD=yCONFIG_USB_ISP1760_HCD=yCONFIG_USB_ISP1362_HCD=yCONFIG_USB_R8A66597_HCD=yCONFIG_USB_HCD_SSB=yCONFIG_USB_CHIPIDEA=yCONFIG_USB_ACM=yCONFIG_USB_TMC=yCONFIG_USB_SERIAL=yCONFIG_USB_SERIAL_GENERIC=yCONFIG_USB_SERIAL_AIRCABLE=yCONFIG_USB_SERIAL_ARK3116=yCONFIG_USB_SERIAL_BELKIN=yCONFIG_USB_SERIAL_CH341=yCONFIG_USB_SERIAL_WHITEHEAT=yCONFIG_USB_SERIAL_DIGI_ACCELEPORT=yCONFIG_USB_SERIAL_EMPEG=yCONFIG_USB_SERIAL_IPAQ=yCONFIG_USB_SERIAL_IR=yCONFIG_USB_SERIAL_F81232=yCONFIG_USB_SERIAL_GARMIN=yCONFIG_USB_SERIAL_KEYSPAN_PDA=yCONFIG_USB_SERIAL_KEYSPAN=yCONFIG_USB_SERIAL_KEYSPAN_MPR=yCONFIG_USB_SERIAL_KEYSPAN_USA28=yCONFIG_USB_SERIAL_KEYSPAN_USA28X=yCONFIG_USB_SERIAL_KEYSPAN_USA28XA=yCONFIG_USB_SERIAL_KEYSPAN_USA28XB=yCONFIG_USB_SERIAL_KEYSPAN_USA19=yCONFIG_USB_SERIAL_KEYSPAN_USA18X=yCONFIG_USB_SERIAL_KEYSPAN_USA19W=yCONFIG_USB_SERIAL_KEYSPAN_USA19QI=yCONFIG_USB_SERIAL_KLSI=yCONFIG_USB_SERIAL_MCT_U232=yCONFIG_USB_SERIAL_MOS7720=yCONFIG_USB_SERIAL_MOTOROLA=yCONFIG_USB_SERIAL_QCAUX=yCONFIG_USB_SERIAL_SPCP8X5=yCONFIG_USB_SERIAL_HP4X=yCONFIG_USB_SERIAL_SAFE=yCONFIG_USB_SERIAL_SAFE_PADDED=yCONFIG_USB_SERIAL_SYMBOL=yCONFIG_USB_SERIAL_TI=yCONFIG_USB_SERIAL_CYBERJACK=yCONFIG_USB_SERIAL_XIRCOM=yCONFIG_USB_SERIAL_OPTION=yCONFIG_USB_SERIAL_VIVOPAY_SERIAL=yCONFIG_USB_SERIAL_ZIO=yCONFIG_USB_SERIAL_ZTE=yCONFIG_USB_SERIAL_SSU100=yCONFIG_USB_SERIAL_DEBUG=yCONFIG_USB_ADUTUX=yCONFIG_USB_SEVSEG=yCONFIG_USB_CYPRESS_CY7C63=yCONFIG_USB_CYTHERM=yCONFIG_USB_IDMOUSE=yCONFIG_USB_FTDI_ELAN=yCONFIG_USB_LD=yCONFIG_USB_RCAR_PHY=yCONFIG_USB_GPIO_VBUS=yCONFIG_USB_MXS_PHY=yCONFIG_MMC=yCONFIG_MMC_DEBUG=yCONFIG_MMC_TEST=yCONFIG_MMC_ARMMMCI=yCONFIG_MMC_SDHCI=yCONFIG_MMC_VUB300=yCONFIG_MMC_USHC=yCONFIG_LEDS_88PM860X=yCONFIG_LEDS_LM3642=yCONFIG_LEDS_PCA9532=yCONFIG_LEDS_GPIO=yCONFIG_LEDS_LP5521=yCONFIG_LEDS_LP5523=yCONFIG_LEDS_PCA955X=yCONFIG_LEDS_PCA9633=yCONFIG_LEDS_WM8350=yCONFIG_LEDS_ADP5520=yCONFIG_LEDS_RENESAS_TPU=y
CONFIG_LEDS_LM355x=yCONFIG_LEDS_BLINKM=yCONFIG_LEDS_TRIGGERS=yCONFIG_LEDS_TRIGGER_TIMER=yCONFIG_LEDS_TRIGGER_ONESHOT=yCONFIG_LEDS_TRIGGER_BACKLIGHT=yCONFIG_LEDS_TRIGGER_GPIO=yCONFIG_ACCESSIBILITY=yCONFIG_A11Y_BRAILLE_CONSOLE=yCONFIG_UIO=yCONFIG_UIO_PDRV_GENIRQ=yCONFIG_VIRTIO_BALLOON=yCONFIG_VIRTIO_MMIO=y
# CONFIG_XEN_BACKEND is not set
# CONFIG_XEN_SYS_HYPERVISOR is not set
# CONFIG_XEN_GNTDEV is not setCONFIG_STAGING=yCONFIG_USBIP_CORE=yCONFIG_USBIP_DEBUG=yCONFIG_USB_SERIAL_QUATECH2=yCONFIG_AD799X=yCONFIG_ADT7410=yCONFIG_ADT7316=yCONFIG_ADT7316_I2C=yCONFIG_AD7152=yCONFIG_SENSORS_ISL29018=yCONFIG_IIO_GPIO_TRIGGER=yCONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4=yCONFIG_STAGING_MEDIA=yCONFIG_USB_WPAN_HCD=yCONFIG_CED1401=yCONFIG_DRM_IMX=yCONFIG_DRM_IMX_PARALLEL_DISPLAY=yCONFIG_DGRP=yCONFIG_MAILBOX=y
# CONFIG_IOMMU_SUPPORT is not setCONFIG_VIRT_DRIVERS=yCONFIG_PM_DEVFREQ=yCONFIG_DEVFREQ_GOV_PERFORMANCE=yCONFIG_DEVFREQ_GOV_USERSPACE=yCONFIG_EXTCON=yCONFIG_EXTCON_ADC_JACK=yCONFIG_EXTCON_MAX77693=yCONFIG_MEMORY=yCONFIG_IIO=yCONFIG_IIO_BUFFER_CB=yCONFIG_AD5380=yCONFIG_AD5446=yCONFIG_MAX517=yCONFIG_MCP4725=yCONFIG_IIO_ST_GYRO_3AXIS=yCONFIG_ITG3200=yCONFIG_INV_MPU6050_IIO=yCONFIG_IIO_ST_MAGN_3AXIS=yCONFIG_IPACK_BUS=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_PROC_FS is not setCONFIG_CONFIGFS_FS=y
# CONFIG_MISC_FILESYSTEMS is not set
# CONFIG_NETWORK_FILESYSTEMS is not setCONFIG_NLS_CODEPAGE_775=yCONFIG_NLS_CODEPAGE_850=yCONFIG_NLS_CODEPAGE_862=yCONFIG_NLS_CODEPAGE_864=yCONFIG_NLS_CODEPAGE_865=yCONFIG_NLS_CODEPAGE_866=yCONFIG_NLS_CODEPAGE_936=yCONFIG_NLS_ASCII=yCONFIG_NLS_ISO8859_2=yCONFIG_NLS_ISO8859_3=yCONFIG_NLS_ISO8859_4=yCONFIG_NLS_ISO8859_6=yCONFIG_NLS_ISO8859_7=yCONFIG_NLS_ISO8859_14=yCONFIG_NLS_MAC_CROATIAN=yCONFIG_NLS_MAC_GAELIC=yCONFIG_NLS_MAC_GREEK=yCONFIG_NLS_MAC_ICELAND=yCONFIG_NLS_MAC_INUIT=yCONFIG_NLS_MAC_ROMANIAN=y
# CONFIG_ENABLE_MUST_CHECK is not setCONFIG_READABLE_ASM=yCONFIG_HEADERS_CHECK=yCONFIG_DEBUG_SECTION_MISMATCH=yCONFIG_PANIC_ON_OOPS=yCONFIG_DETECT_HUNG_TASK=yCONFIG_DEBUG_OBJECTS=yCONFIG_DEBUG_OBJECTS_SELFTEST=yCONFIG_DEBUG_OBJECTS_TIMERS=yCONFIG_DEBUG_OBJECTS_WORK=yCONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=yCONFIG_RT_MUTEX_TESTER=yCONFIG_LOCK_STAT=yCONFIG_DEBUG_LOCKDEP=yCONFIG_DEBUG_MEMORY_INIT=yCONFIG_TEST_LIST_SORT=yCONFIG_DEBUG_NOTIFIERS=yCONFIG_SPARSE_RCU_POINTER=yCONFIG_DEBUG_FORCE_WEAK_PER_CPU=y
# CONFIG_FTRACE is not setCONFIG_DMA_API_DEBUG=yCONFIG_TEST_KSTRTOX=yCONFIG_STRICT_DEVMEM=yCONFIG_DEBUG_USER=yCONFIG_DEBUG_LL=yCONFIG_PID_IN_CONTEXTIDR=yCONFIG_SECURITY_DMESG_RESTRICT=yCONFIG_SECURITY=yCONFIG_SECURITY_NETWORK_XFRM=yCONFIG_SECURITY_TOMOYO=yCONFIG_SECURITY_APPARMOR=yCONFIG_SECURITY_YAMA=yCONFIG_SECURITY_YAMA_STACKED=yCONFIG_IMA=y
# CONFIG_IMA_AUDIT is not setCONFIG_CRYPTO_USER=yCONFIG_CRYPTO_GCM=yCONFIG_CRYPTO_CBC=yCONFIG_CRYPTO_CTS=yCONFIG_CRYPTO_PCBC=yCONFIG_CRYPTO_XTS=yCONFIG_CRYPTO_VMAC=yCONFIG_CRYPTO_MD4=yCONFIG_CRYPTO_RMD128=yCONFIG_CRYPTO_RMD160=yCONFIG_CRYPTO_RMD256=yCONFIG_CRYPTO_RMD320=yCONFIG_CRYPTO_SHA512=yCONFIG_CRYPTO_TGR192=yCONFIG_CRYPTO_ANUBIS=yCONFIG_CRYPTO_CAST5=yCONFIG_CRYPTO_DES=yCONFIG_CRYPTO_SERPENT=yCONFIG_CRYPTO_DEFLATE=yCONFIG_CRYPTO_LZO=yCONFIG_CRC_ITU_T=yCONFIG_XZ_DEC_X86=yCONFIG_XZ_DEC_POWERPC=yCONFIG_XZ_DEC_IA64=yCONFIG_AVERAGE=yCONFIG_VIRTUALIZATION=y
Quoted 1 line · Rob Herring
Here's a config:
Was it truncated? oldconfig is asking a ton of questions, far more than I would expect for something like variance between our HEADs etc.
If I just answer the default to all the questions then I get a .config with Xen on etc, but I still don't see the issue.
Ian.
Quoted 1 line · Rob Herring
Here's a config:
Was it truncated? oldconfig is asking a ton of questions, far more than I would expect for something like variance between our HEADs etc.
If I just answer the default to all the questions then I get a .config with Xen on etc, but I still don't see the issue.
Ian.
Quoted 5 lines · Rob Herring
Quoted 3 lines
I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
Here's a config:
[...]
Cheers Rob, that was enough to reproduce for me. The problem is likely that CONFIG_AEABI=n, so the ABI doesn't actually mandate even base registers for 64-bit values in registers.
Ian -- this would be fixed if you used our atomic64 routines instead of inventing your own :)
Will
Quoted 3 lines · Will Deacon
Cheers Rob, that was enough to reproduce for me. The problem is likely that
CONFIG_AEABI=n, so the ABI doesn't actually mandate even base registers for 64-bit values in registers.
Me too.
Quoted 2 lines
Ian -- this would be fixed if you used our atomic64 routines instead of inventing your own :)
I looked and couldn't see an existing 64 bit xchg, was I looking in the wrong place? Ah, wait, I see atomic64_xchg now. But that needs an atomic64_t while I have a xen_ulong_t (which == 64 bits on ARM). This is a kernel<->hypervisor ABI so I can't just change it to an atomic64_t. I suppose I could cast (see below, untested) but that seems rather icky.
Ian.
arch/arm/include/asm/xen/events.h +2 -22
@@ -2,6 +2,7 @@#define _ASM_ARM_XEN_EVENTS_H#include <asm/ptrace.h> +#include <asm/atomic.h> enum ipi_vector {XEN_PLACEHOLDER_VECTOR ,
@@ -15,27 +16,6 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } -/* -* We cannot use xchg because it does not support 8-byte -* values. However it is safe to use {ldr,dtd}exd directly because all -* platforms which Xen can run on support those instructions. -*/ -static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) -{ -xen_ulong_t oldval; -unsigned int tmp; - -smp_wmb (); - asmvolatile ("@ xchg_xen_ulong\n" -"1: ldrexd %0, %H0, [%3]\n" -" strexd %1, %2, %H2, [%3]\n" -" teq %1, #0\n" -" bne 1b" - :"=&r" (oldval),"=&r" (tmp) - :"r" (val),"r" (ptr) - :"memory" ,"cc" ); -smp_wmb (); -return oldval; -} +#define xchg_xen_ulong (ptr, val) atomic64_xchg((atomic64_t *)(ptr), (val))#endif /* _ASM_ARM_XEN_EVENTS_H */
Hi Ian,
Quoted 7 lines · Ian Campbell
Quoted 3 lines · Will Deacon
Cheers Rob, that was enough to reproduce for me. The problem is likely that
CONFIG_AEABI=n, so the ABI doesn't actually mandate even base registers for 64-bit values in registers.Me too.
Quoted 8 lines
Quoted 2 lines
Ian -- this would be fixed if you used our atomic64 routines instead of inventing your own :)
I looked and couldn't see an existing 64 bit xchg, was I looking in the wrong place? Ah, wait, I see
atomic64_xchgnow. But that needs anatomic64_twhile I have axen_ulong_t(which == 64 bits on ARM). This is a kernel<->hypervisor ABI so I can't just change it to anatomic64_t. I suppose I could cast (see below, untested) but that seems rather icky.
You can play some container_of tricks, like we do in cmpxchg64 to get this right. Alternatively, we could look at an xchg8 implementation which some other architectures have (although they seem to be 64-bit machines).
Will
Quoted 9 lines · Will Deacon
Quoted 5 lines
I looked and couldn't see an existing 64 bit xchg, was I looking in the wrong place? Ah, wait, I see
atomic64_xchgnow. But that needs anatomic64_twhile I have axen_ulong_t(which == 64 bits on ARM). This is a kernel<->hypervisor ABI so I can't just change it to anatomic64_t. I suppose I could cast (see below, untested) but that seems rather icky.You can play some
container_oftricks, like we do in cmpxchg64 to get this right. Alternatively, we could look at an xchg8 implementation which some other architectures have (although they seem to be 64-bit machines).
I went with the container of trick + appropriate Kconfig depends and sent a patch out a couple of seconds ago.
Thanks for your help/advice!
Ian.
Quoted 9 lines · Will Deacon
Quoted 5 lines
I looked and couldn't see an existing 64 bit xchg, was I looking in the wrong place? Ah, wait, I see
atomic64_xchgnow. But that needs anatomic64_twhile I have axen_ulong_t(which == 64 bits on ARM). This is a kernel<->hypervisor ABI so I can't just change it to anatomic64_t. I suppose I could cast (see below, untested) but that seems rather icky.You can play some
container_oftricks, like we do in cmpxchg64 to get this right. Alternatively, we could look at an xchg8 implementation which some other architectures have (although they seem to be 64-bit machines).
I went with the container of trick + appropriate Kconfig depends and sent a patch out a couple of seconds ago.
Thanks for your help/advice!
Ian.
Hi Ian,
Quoted 7 lines · Ian Campbell
Quoted 3 lines · Will Deacon
Cheers Rob, that was enough to reproduce for me. The problem is likely that
CONFIG_AEABI=n, so the ABI doesn't actually mandate even base registers for 64-bit values in registers.Me too.
Quoted 8 lines
Quoted 2 lines
Ian -- this would be fixed if you used our atomic64 routines instead of inventing your own :)
I looked and couldn't see an existing 64 bit xchg, was I looking in the wrong place? Ah, wait, I see
atomic64_xchgnow. But that needs anatomic64_twhile I have axen_ulong_t(which == 64 bits on ARM). This is a kernel<->hypervisor ABI so I can't just change it to anatomic64_t. I suppose I could cast (see below, untested) but that seems rather icky.
You can play some container_of tricks, like we do in cmpxchg64 to get this right. Alternatively, we could look at an xchg8 implementation which some other architectures have (although they seem to be 64-bit machines).
Will
Quoted 3 lines · Will Deacon
Cheers Rob, that was enough to reproduce for me. The problem is likely that
CONFIG_AEABI=n, so the ABI doesn't actually mandate even base registers for 64-bit values in registers.
Me too.
Quoted 2 lines
Ian -- this would be fixed if you used our atomic64 routines instead of inventing your own :)
I looked and couldn't see an existing 64 bit xchg, was I looking in the wrong place? Ah, wait, I see atomic64_xchg now. But that needs an atomic64_t while I have a xen_ulong_t (which == 64 bits on ARM). This is a kernel<->hypervisor ABI so I can't just change it to an atomic64_t. I suppose I could cast (see below, untested) but that seems rather icky.
Ian.
arch/arm/include/asm/xen/events.h +2 -22
@@ -2,6 +2,7 @@#define _ASM_ARM_XEN_EVENTS_H#include <asm/ptrace.h> +#include <asm/atomic.h> enum ipi_vector {XEN_PLACEHOLDER_VECTOR ,
@@ -15,27 +16,6 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } -/* -* We cannot use xchg because it does not support 8-byte -* values. However it is safe to use {ldr,dtd}exd directly because all -* platforms which Xen can run on support those instructions. -*/ -static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) -{ -xen_ulong_t oldval; -unsigned int tmp; - -smp_wmb (); - asmvolatile ("@ xchg_xen_ulong\n" -"1: ldrexd %0, %H0, [%3]\n" -" strexd %1, %2, %H2, [%3]\n" -" teq %1, #0\n" -" bne 1b" - :"=&r" (oldval),"=&r" (tmp) - :"r" (val),"r" (ptr) - :"memory" ,"cc" ); -smp_wmb (); -return oldval; -} +#define xchg_xen_ulong (ptr, val) atomic64_xchg((atomic64_t *)(ptr), (val))#endif /* _ASM_ARM_XEN_EVENTS_H */
Quoted 5 lines · Rob Herring
Quoted 3 lines
I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
Here's a config:
[...]
Cheers Rob, that was enough to reproduce for me. The problem is likely that CONFIG_AEABI=n, so the ABI doesn't actually mandate even base registers for 64-bit values in registers.
Ian -- this would be fixed if you used our atomic64 routines instead of inventing your own :)
Will
Quoted 33 lines · Will Deacon
Hi guys,
Quoted 13 lines · Rob Herring
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>[...]
Quoted 11 lines
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to
atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.[...]
Quoted 12 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
Here's a config:
CONFIG_SYSVIPC=yCONFIG_POSIX_MQUEUE=yCONFIG_FHANDLE=yCONFIG_IKCONFIG=yCONFIG_CGROUP_FREEZER=yCONFIG_CGROUP_DEVICE=yCONFIG_CPUSETS=y
# CONFIG_PROC_PID_CPUSET is not setCONFIG_CGROUP_CPUACCT=yCONFIG_RESOURCE_COUNTERS=yCONFIG_MEMCG=yCONFIG_MEMCG_KMEM=yCONFIG_MEMCG_DEBUG_ASYNC_DESTROY=yCONFIG_CHECKPOINT_RESTORE=yCONFIG_UIDGID_STRICT_TYPE_CHECKS=yCONFIG_SCHED_AUTOGROUP=yCONFIG_RELAY=yCONFIG_BLK_DEV_INITRD=yCONFIG_RD_BZIP2=yCONFIG_RD_LZMA=yCONFIG_RD_XZ=yCONFIG_RD_LZO=yCONFIG_CC_OPTIMIZE_FOR_SIZE=y
# CONFIG_PRINTK is not set
# CONFIG_BUG is not set
# CONFIG_BASE_FULL is not set
# CONFIG_EPOLL is not set
# CONFIG_TIMERFD is not set
# CONFIG_SHMEM is not set
# CONFIG_AIO is not setCONFIG_EMBEDDED=y
# CONFIG_PERF_EVENTS is not setCONFIG_PROFILING=y
# CONFIG_BLOCK is not setCONFIG_ARCH_BCM=yCONFIG_GPIO_PCA953X=yCONFIG_ARCH_MXC=yCONFIG_MACH_IMX51_DT=yCONFIG_MACH_EUKREA_CPUIMX51SD=yCONFIG_SOC_IMX53=yCONFIG_ARCH_SOCFPGA=yCONFIG_ARCH_SUNXI=yCONFIG_ARCH_VEXPRESS_CA9X4=yCONFIG_CPU_ICACHE_DISABLE=yCONFIG_CPU_DCACHE_DISABLE=yCONFIG_ARM_ERRATA_430973=yCONFIG_PL310_ERRATA_727915=yCONFIG_HAVE_ARM_ARCH_TIMER=y
# CONFIG_COMPACTION is not set
# CONFIG_CROSS_MEMORY_ATTACH is not setCONFIG_SECCOMP=yCONFIG_CC_STACKPROTECTOR=yCONFIG_XEN=y
# CONFIG_ATAGS is not setCONFIG_ARM_APPENDED_DTB=yCONFIG_ARM_ATAG_DTB_COMPAT=yCONFIG_KEXEC=yCONFIG_CRASH_DUMP=yCONFIG_FPE_FASTFPE=y
# CONFIG_BINFMT_ELF is not setCONFIG_PM_AUTOSLEEP=yCONFIG_PM_RUNTIME=yCONFIG_PM_DEBUG=yCONFIG_APM_EMULATION=yCONFIG_NET=yCONFIG_XFRM_SUB_POLICY=yCONFIG_XFRM_MIGRATE=yCONFIG_NET_KEY=yCONFIG_NETWORK_PHY_TIMESTAMPING=yCONFIG_NETFILTER=yCONFIG_NETFILTER_DEBUG=yCONFIG_DECNET_NF_GRABULATOR=yCONFIG_ATM=yCONFIG_BRIDGE=yCONFIG_BRIDGE_VLAN_FILTERING=yCONFIG_VLAN_8021Q=yCONFIG_DECNET=yCONFIG_DECNET_ROUTER=yCONFIG_LLC2=yCONFIG_ATALK=yCONFIG_DEV_APPLETALK=yCONFIG_LAPB=yCONFIG_NET_SCHED=yCONFIG_NET_SCH_HTB=yCONFIG_NET_SCH_HFSC=yCONFIG_NET_SCH_ATM=yCONFIG_NET_SCH_PRIO=yCONFIG_NET_SCH_MULTIQ=yCONFIG_NET_SCH_SFB=yCONFIG_NET_SCH_TBF=yCONFIG_NET_SCH_GRED=yCONFIG_NET_SCH_NETEM=yCONFIG_NET_SCH_CHOKE=yCONFIG_NET_SCH_QFQ=yCONFIG_NET_SCH_CODEL=yCONFIG_NET_CLS_TCINDEX=yCONFIG_NET_CLS_U32=yCONFIG_NET_CLS_RSVP=yCONFIG_NET_CLS_ACT=yCONFIG_NET_ACT_SKBEDIT=yCONFIG_NET_CLS_IND=yCONFIG_DCB=yCONFIG_VSOCKETS=yCONFIG_BT=yCONFIG_BT_BNEP=yCONFIG_BT_BNEP_PROTO_FILTER=yCONFIG_BT_HCIUART=yCONFIG_BT_HCIUART_BCSP=yCONFIG_BT_HCIUART_ATH3K=yCONFIG_BT_HCIUART_LL=yCONFIG_BT_HCIBPA10X=yCONFIG_BT_HCIBFUSB=y
# CONFIG_WIRELESS is not setCONFIG_WIMAX=yCONFIG_RFKILL_REGULATOR=yCONFIG_CAIF=yCONFIG_CAIF_DEBUG=yCONFIG_DEVTMPFS=y
# CONFIG_STANDALONE is not set
# CONFIG_FW_LOADER_USER_HELPER is not setCONFIG_DEBUG_DRIVER=yCONFIG_CONNECTOR=y
# CONFIG_PROC_EVENTS is not setCONFIG_ATMEL_PWM=yCONFIG_ENCLOSURE_SERVICES=yCONFIG_ISL29003=yCONFIG_SENSORS_BH1770=yCONFIG_ARM_CHARLCD=yCONFIG_BMP085_I2C=yCONFIG_USB_SWITCH_FSA9480=yCONFIG_EEPROM_AT24=yCONFIG_TI_ST=yCONFIG_ALTERA_STAPL=yCONFIG_NETDEVICES=yCONFIG_DUMMY=yCONFIG_IFB=yCONFIG_MACVLAN=yCONFIG_NETCONSOLE=yCONFIG_VIRTIO_NET=yCONFIG_CAIF_HSI=yCONFIG_NET_DSA_MV88E6060=y
# CONFIG_ETHERNET is not setCONFIG_AMD_PHY=yCONFIG_MARVELL_PHY=yCONFIG_DAVICOM_PHY=yCONFIG_QSEMI_PHY=yCONFIG_VITESSE_PHY=yCONFIG_BCM87XX_PHY=yCONFIG_ICPLUS_PHY=yCONFIG_REALTEK_PHY=yCONFIG_NATIONAL_PHY=yCONFIG_LSI_ET1011C_PHY=yCONFIG_FIXED_PHY=yCONFIG_PPP=yCONFIG_PPP_BSDCOMP=yCONFIG_PPP_DEFLATE=yCONFIG_PPP_MPPE=yCONFIG_PPP_ASYNC=yCONFIG_PPP_SYNC_TTY=yCONFIG_USB_KAWETH=yCONFIG_USB_PEGASUS=yCONFIG_USB_RTL8150=yCONFIG_USB_USBNET=y
# CONFIG_USB_NET_AX8817X is not setCONFIG_USB_NET_CDC_EEM=yCONFIG_USB_NET_SMSC75XX=yCONFIG_USB_NET_GL620A=yCONFIG_USB_NET_MCS7830=y
# CONFIG_USB_NET_CDC_SUBSET is not set
# CONFIG_USB_NET_ZAURUS is not setCONFIG_USB_NET_CX82310_ETH=yCONFIG_USB_NET_KALMIA=yCONFIG_USB_NET_INT51X1=y
# CONFIG_WLAN is not set
# CONFIG_XEN_NETDEV_FRONTEND is not setCONFIG_ISDN=yCONFIG_ISDN_I4L=yCONFIG_ISDN_CAPI=y
# CONFIG_ISDN_DRV_AVMB1_VERBOSE_REASON is not set
# CONFIG_CAPI_TRACE is not setCONFIG_ISDN_CAPI_CAPI20=yCONFIG_CAPI_AVM=yCONFIG_CAPI_EICON=yCONFIG_ISDN_DRV_GIGASET=yCONFIG_GIGASET_BASE=yCONFIG_GIGASET_M105=yCONFIG_GIGASET_M101=yCONFIG_GIGASET_DEBUG=yCONFIG_MISDN=y
# CONFIG_INPUT_MOUSEDEV is not setCONFIG_INPUT_JOYDEV=yCONFIG_INPUT_EVDEV=yCONFIG_INPUT_EVBUG=yCONFIG_INPUT_APMPOWER=y
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not setCONFIG_SERIO_LIBPS2=yCONFIG_SERIO_RAW=yCONFIG_SERIO_ALTERA_PS2=yCONFIG_SERIO_PS2MULT=y
# CONFIG_UNIX98_PTYS is not set
# CONFIG_LEGACY_PTYS is not setCONFIG_SERIAL_NONSTANDARD=yCONFIG_N_GSM=yCONFIG_TRACE_SINK=yCONFIG_STALDRV=yCONFIG_SERIAL_AMBA_PL011=yCONFIG_SERIAL_AMBA_PL011_CONSOLE=yCONFIG_SERIAL_SCCNXP=yCONFIG_SERIAL_SCCNXP_CONSOLE=yCONFIG_SERIAL_ALTERA_UART=yCONFIG_SERIAL_ALTERA_UART_CONSOLE=yCONFIG_SERIAL_XILINX_PS_UART=yCONFIG_HVC_DCC=yCONFIG_VIRTIO_CONSOLE=yCONFIG_IPMI_HANDLER=yCONFIG_IPMI_DEVICE_INTERFACE=yCONFIG_HW_RANDOM_TIMERIOMEM=yCONFIG_HW_RANDOM_VIRTIO=y
# CONFIG_HW_RANDOM_TPM is not setCONFIG_R3964=yCONFIG_TCG_TIS_I2C_INFINEON=yCONFIG_I2C_MUX=yCONFIG_I2C_MUX_PINCTRL=y
# CONFIG_I2C_HELPER_AUTO is not setCONFIG_I2C_CBUS_GPIO=yCONFIG_I2C_NOMADIK=yCONFIG_I2C_OCORES=yCONFIG_I2C_PCA_PLATFORM=yCONFIG_I2C_SIMTEC=yCONFIG_I2C_TAOS_EVM=yCONFIG_I2C_TINY_USB=yCONFIG_I2C_DEBUG_CORE=yCONFIG_HSI=yCONFIG_NTP_PPS=yCONFIG_PPS_CLIENT_KTIMER=yCONFIG_PPS_CLIENT_LDISC=yCONFIG_PTP_1588_CLOCK_PCH=yCONFIG_PINCTRL_SINGLE=yCONFIG_PINCTRL_EXYNOS5440=yCONFIG_GPIO_SYSFS=yCONFIG_GPIO_MAX732X=yCONFIG_GPIO_MAX732X_IRQ=yCONFIG_GPIO_SX150X=yCONFIG_GPIO_STMPE=yCONFIG_GPIO_TWL4030=yCONFIG_GPIO_WM831X=yCONFIG_GPIO_WM8350=yCONFIG_GPIO_ADP5520=yCONFIG_GPIO_ADP5588=yCONFIG_GPIO_ADNP=yCONFIG_GPIO_MCP23S08=yCONFIG_GPIO_TPS6586X=yCONFIG_GPIO_VIPERBOARD=yCONFIG_HWMON_DEBUG_CHIP=yCONFIG_SENSORS_AD7418=yCONFIG_SENSORS_ADM1025=yCONFIG_SENSORS_ADT7410=yCONFIG_SENSORS_ADT7462=yCONFIG_SENSORS_ADT7470=yCONFIG_SENSORS_ASC7621=yCONFIG_SENSORS_DS620=yCONFIG_SENSORS_F71805F=yCONFIG_SENSORS_F75375S=yCONFIG_SENSORS_GL518SM=yCONFIG_SENSORS_GL520SM=yCONFIG_SENSORS_GPIO_FAN=yCONFIG_SENSORS_HIH6130=yCONFIG_SENSORS_IBMAEM=yCONFIG_SENSORS_IBMPEX=yCONFIG_SENSORS_IT87=yCONFIG_SENSORS_LM63=yCONFIG_SENSORS_LM73=yCONFIG_SENSORS_LM77=yCONFIG_SENSORS_LM80=yCONFIG_SENSORS_LM83=yCONFIG_SENSORS_LM92=yCONFIG_SENSORS_LTC4215=yCONFIG_SENSORS_LM95241=yCONFIG_SENSORS_MAX6639=yCONFIG_SENSORS_MAX6642=yCONFIG_SENSORS_MAX6650=yCONFIG_SENSORS_MAX6697=yCONFIG_SENSORS_MCP3021=yCONFIG_SENSORS_NTC_THERMISTOR=yCONFIG_SENSORS_PCF8591=yCONFIG_PMBUS=y
# CONFIG_SENSORS_PMBUS is not setCONFIG_SENSORS_ADM1275=yCONFIG_SENSORS_LM25066=yCONFIG_SENSORS_LTC2978=yCONFIG_SENSORS_MAX34440=yCONFIG_SENSORS_ZL6100=yCONFIG_SENSORS_SHT15=yCONFIG_SENSORS_SMM665=yCONFIG_SENSORS_EMC1403=yCONFIG_SENSORS_EMC2103=yCONFIG_SENSORS_EMC6W201=yCONFIG_SENSORS_SMSC47M1=yCONFIG_SENSORS_SCH5627=yCONFIG_SENSORS_SCH5636=yCONFIG_SENSORS_ADS7828=yCONFIG_SENSORS_INA2XX=yCONFIG_SENSORS_TMP102=yCONFIG_SENSORS_TMP401=yCONFIG_SENSORS_TMP421=yCONFIG_SENSORS_W83791D=yCONFIG_SENSORS_W83793=yCONFIG_SENSORS_W83795=yCONFIG_SENSORS_WM831X=yCONFIG_SENSORS_WM8350=yCONFIG_SENSORS_MC13783_ADC=yCONFIG_WATCHDOG=yCONFIG_SOFT_WATCHDOG=yCONFIG_ARM_SP805_WATCHDOG=yCONFIG_TWL4030_WATCHDOG=yCONFIG_MAX63XX_WATCHDOG=yCONFIG_IMX2_WDT=yCONFIG_RETU_WATCHDOG=yCONFIG_USBPCWATCHDOG=yCONFIG_SSB=yCONFIG_SSB_SDIOHOST=yCONFIG_SSB_SILENT=yCONFIG_SSB_DRIVER_GPIO=yCONFIG_BCMA=yCONFIG_BCMA_DRIVER_GMAC_CMN=yCONFIG_BCMA_DRIVER_GPIO=yCONFIG_MFD_88PM860X=yCONFIG_MFD_88PM805=yCONFIG_MFD_SM501=yCONFIG_MFD_SM501_GPIO=yCONFIG_HTC_EGPIO=yCONFIG_HTC_PASIC3=yCONFIG_HTC_I2CPLD=yCONFIG_TPS6507X=yCONFIG_MFD_TPS65217=yCONFIG_MFD_TPS6586X=yCONFIG_TWL4030_CORE=yCONFIG_TWL4030_POWER=yCONFIG_TWL6040_CORE=yCONFIG_MFD_STMPE=y
# CONFIG_STMPE_I2C is not setCONFIG_MFD_T7L66XB=yCONFIG_MFD_TC6387XB=yCONFIG_MFD_TC6393XB=yCONFIG_PMIC_ADP5520=yCONFIG_MFD_LP8788=yCONFIG_MFD_MAX77686=yCONFIG_MFD_MAX77693=yCONFIG_MFD_MAX8998=yCONFIG_MFD_SEC_CORE=yCONFIG_MFD_WM831X_I2C=yCONFIG_MFD_WM8350_I2C=yCONFIG_MFD_PCF50633=yCONFIG_PCF50633_ADC=yCONFIG_MFD_MC13XXX_I2C=yCONFIG_ABX500_CORE=yCONFIG_AB3100_CORE=yCONFIG_MFD_WL1273_CORE=yCONFIG_MFD_VIPERBOARD=yCONFIG_MFD_RETU=yCONFIG_MFD_AS3711=yCONFIG_REGULATOR=yCONFIG_REGULATOR_DUMMY=yCONFIG_REGULATOR_USERSPACE_CONSUMER=yCONFIG_REGULATOR_AD5398=yCONFIG_REGULATOR_MC13892=yCONFIG_REGULATOR_MAX8660=yCONFIG_REGULATOR_MAX8998=yCONFIG_REGULATOR_LP872X=yCONFIG_REGULATOR_LP8755=yCONFIG_REGULATOR_PCF50633=y
# CONFIG_REGULATOR_AB3100 is not setCONFIG_REGULATOR_TPS6586X=yCONFIG_REGULATOR_VEXPRESS=yCONFIG_REGULATOR_WM831X=yCONFIG_REGULATOR_AS3711=yCONFIG_DRM=yCONFIG_DRM_I2C_CH7006=yCONFIG_DRM_I2C_SIL164=yCONFIG_DRM_I2C_NXP_TDA998X=yCONFIG_DRM_EXYNOS=yCONFIG_DRM_EXYNOS_DMABUF=yCONFIG_DRM_EXYNOS_VIDI=yCONFIG_VIDEO_OUTPUT_CONTROL=yCONFIG_OF_DISPLAY_TIMING=yCONFIG_FB_TILEBLITTING=yCONFIG_FB_ARMCLCD=yCONFIG_FB_TMIO=yCONFIG_FB_SMSCUFX=yCONFIG_FB_GOLDFISH=y
# CONFIG_XEN_FBDEV_FRONTEND is not setCONFIG_FB_AUO_K190X=yCONFIG_FB_AUO_K1901=yCONFIG_EXYNOS_VIDEO=yCONFIG_BACKLIGHT_LCD_SUPPORT=y
# CONFIG_BACKLIGHT_GENERIC is not setCONFIG_BACKLIGHT_WM831X=yCONFIG_BACKLIGHT_ADP5520=yCONFIG_BACKLIGHT_PCF50633=yCONFIG_BACKLIGHT_LM3630=yCONFIG_BACKLIGHT_LP855X=yCONFIG_BACKLIGHT_LP8788=yCONFIG_BACKLIGHT_PANDORA=yCONFIG_BACKLIGHT_TPS65217=yCONFIG_BACKLIGHT_AS3711=yCONFIG_FRAMEBUFFER_CONSOLE=yCONFIG_FRAMEBUFFER_CONSOLE_ROTATION=yCONFIG_FONTS=y
CONFIG_FONT_8x8=y
CONFIG_FONT_8x16=y
CONFIG_FONT_MINI_4x6=y
CONFIG_FONT_10x18=yCONFIG_LOGO=yCONFIG_SOUND=yCONFIG_HIDRAW=yCONFIG_HID_A4TECH=yCONFIG_HID_AUREAL=yCONFIG_HID_BELKIN=yCONFIG_HID_CHERRY=yCONFIG_HID_CYPRESS=yCONFIG_HID_DRAGONRISE=yCONFIG_HID_UCLOGIC=yCONFIG_HID_GYRATION=yCONFIG_HID_LENOVO_TPKBD=yCONFIG_HID_LOGITECH=yCONFIG_HID_LOGITECH_DJ=yCONFIG_LOGITECH_FF=yCONFIG_LOGIRUMBLEPAD2_FF=yCONFIG_HID_MONTEREY=yCONFIG_HID_PANTHERLORD=yCONFIG_HID_PETALYNX=yCONFIG_HID_PICOLCD=yCONFIG_HID_PICOLCD_BACKLIGHT=yCONFIG_HID_PRIMAX=yCONFIG_HID_ROCCAT=yCONFIG_HID_SAITEK=yCONFIG_HID_SAMSUNG=yCONFIG_HID_SONY=yCONFIG_HID_SPEEDLINK=yCONFIG_HID_STEELSERIES=yCONFIG_HID_SUNPLUS=yCONFIG_HID_TOPSEED=yCONFIG_HID_THINGM=yCONFIG_HID_THRUSTMASTER=yCONFIG_USB=yCONFIG_USB_DYNAMIC_MINORS=yCONFIG_USB_SUSPEND=yCONFIG_USB_OTG=y
# CONFIG_USB_OTG_WHITELIST is not setCONFIG_USB_DWC3=yCONFIG_USB_MON=yCONFIG_USB_WUSB_CBAF=yCONFIG_USB_WUSB_CBAF_DEBUG=yCONFIG_USB_OXU210HP_HCD=yCONFIG_USB_ISP116X_HCD=yCONFIG_USB_ISP1760_HCD=yCONFIG_USB_ISP1362_HCD=yCONFIG_USB_R8A66597_HCD=yCONFIG_USB_HCD_SSB=yCONFIG_USB_CHIPIDEA=yCONFIG_USB_ACM=yCONFIG_USB_TMC=yCONFIG_USB_SERIAL=yCONFIG_USB_SERIAL_GENERIC=yCONFIG_USB_SERIAL_AIRCABLE=yCONFIG_USB_SERIAL_ARK3116=yCONFIG_USB_SERIAL_BELKIN=yCONFIG_USB_SERIAL_CH341=yCONFIG_USB_SERIAL_WHITEHEAT=yCONFIG_USB_SERIAL_DIGI_ACCELEPORT=yCONFIG_USB_SERIAL_EMPEG=yCONFIG_USB_SERIAL_IPAQ=yCONFIG_USB_SERIAL_IR=yCONFIG_USB_SERIAL_F81232=yCONFIG_USB_SERIAL_GARMIN=yCONFIG_USB_SERIAL_KEYSPAN_PDA=yCONFIG_USB_SERIAL_KEYSPAN=yCONFIG_USB_SERIAL_KEYSPAN_MPR=yCONFIG_USB_SERIAL_KEYSPAN_USA28=yCONFIG_USB_SERIAL_KEYSPAN_USA28X=yCONFIG_USB_SERIAL_KEYSPAN_USA28XA=yCONFIG_USB_SERIAL_KEYSPAN_USA28XB=yCONFIG_USB_SERIAL_KEYSPAN_USA19=yCONFIG_USB_SERIAL_KEYSPAN_USA18X=yCONFIG_USB_SERIAL_KEYSPAN_USA19W=yCONFIG_USB_SERIAL_KEYSPAN_USA19QI=yCONFIG_USB_SERIAL_KLSI=yCONFIG_USB_SERIAL_MCT_U232=yCONFIG_USB_SERIAL_MOS7720=yCONFIG_USB_SERIAL_MOTOROLA=yCONFIG_USB_SERIAL_QCAUX=yCONFIG_USB_SERIAL_SPCP8X5=yCONFIG_USB_SERIAL_HP4X=yCONFIG_USB_SERIAL_SAFE=yCONFIG_USB_SERIAL_SAFE_PADDED=yCONFIG_USB_SERIAL_SYMBOL=yCONFIG_USB_SERIAL_TI=yCONFIG_USB_SERIAL_CYBERJACK=yCONFIG_USB_SERIAL_XIRCOM=yCONFIG_USB_SERIAL_OPTION=yCONFIG_USB_SERIAL_VIVOPAY_SERIAL=yCONFIG_USB_SERIAL_ZIO=yCONFIG_USB_SERIAL_ZTE=yCONFIG_USB_SERIAL_SSU100=yCONFIG_USB_SERIAL_DEBUG=yCONFIG_USB_ADUTUX=yCONFIG_USB_SEVSEG=yCONFIG_USB_CYPRESS_CY7C63=yCONFIG_USB_CYTHERM=yCONFIG_USB_IDMOUSE=yCONFIG_USB_FTDI_ELAN=yCONFIG_USB_LD=yCONFIG_USB_RCAR_PHY=yCONFIG_USB_GPIO_VBUS=yCONFIG_USB_MXS_PHY=yCONFIG_MMC=yCONFIG_MMC_DEBUG=yCONFIG_MMC_TEST=yCONFIG_MMC_ARMMMCI=yCONFIG_MMC_SDHCI=yCONFIG_MMC_VUB300=yCONFIG_MMC_USHC=yCONFIG_LEDS_88PM860X=yCONFIG_LEDS_LM3642=yCONFIG_LEDS_PCA9532=yCONFIG_LEDS_GPIO=yCONFIG_LEDS_LP5521=yCONFIG_LEDS_LP5523=yCONFIG_LEDS_PCA955X=yCONFIG_LEDS_PCA9633=yCONFIG_LEDS_WM8350=yCONFIG_LEDS_ADP5520=yCONFIG_LEDS_RENESAS_TPU=y
CONFIG_LEDS_LM355x=yCONFIG_LEDS_BLINKM=yCONFIG_LEDS_TRIGGERS=yCONFIG_LEDS_TRIGGER_TIMER=yCONFIG_LEDS_TRIGGER_ONESHOT=yCONFIG_LEDS_TRIGGER_BACKLIGHT=yCONFIG_LEDS_TRIGGER_GPIO=yCONFIG_ACCESSIBILITY=yCONFIG_A11Y_BRAILLE_CONSOLE=yCONFIG_UIO=yCONFIG_UIO_PDRV_GENIRQ=yCONFIG_VIRTIO_BALLOON=yCONFIG_VIRTIO_MMIO=y
# CONFIG_XEN_BACKEND is not set
# CONFIG_XEN_SYS_HYPERVISOR is not set
# CONFIG_XEN_GNTDEV is not setCONFIG_STAGING=yCONFIG_USBIP_CORE=yCONFIG_USBIP_DEBUG=yCONFIG_USB_SERIAL_QUATECH2=yCONFIG_AD799X=yCONFIG_ADT7410=yCONFIG_ADT7316=yCONFIG_ADT7316_I2C=yCONFIG_AD7152=yCONFIG_SENSORS_ISL29018=yCONFIG_IIO_GPIO_TRIGGER=yCONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4=yCONFIG_STAGING_MEDIA=yCONFIG_USB_WPAN_HCD=yCONFIG_CED1401=yCONFIG_DRM_IMX=yCONFIG_DRM_IMX_PARALLEL_DISPLAY=yCONFIG_DGRP=yCONFIG_MAILBOX=y
# CONFIG_IOMMU_SUPPORT is not setCONFIG_VIRT_DRIVERS=yCONFIG_PM_DEVFREQ=yCONFIG_DEVFREQ_GOV_PERFORMANCE=yCONFIG_DEVFREQ_GOV_USERSPACE=yCONFIG_EXTCON=yCONFIG_EXTCON_ADC_JACK=yCONFIG_EXTCON_MAX77693=yCONFIG_MEMORY=yCONFIG_IIO=yCONFIG_IIO_BUFFER_CB=yCONFIG_AD5380=yCONFIG_AD5446=yCONFIG_MAX517=yCONFIG_MCP4725=yCONFIG_IIO_ST_GYRO_3AXIS=yCONFIG_ITG3200=yCONFIG_INV_MPU6050_IIO=yCONFIG_IIO_ST_MAGN_3AXIS=yCONFIG_IPACK_BUS=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_PROC_FS is not setCONFIG_CONFIGFS_FS=y
# CONFIG_MISC_FILESYSTEMS is not set
# CONFIG_NETWORK_FILESYSTEMS is not setCONFIG_NLS_CODEPAGE_775=yCONFIG_NLS_CODEPAGE_850=yCONFIG_NLS_CODEPAGE_862=yCONFIG_NLS_CODEPAGE_864=yCONFIG_NLS_CODEPAGE_865=yCONFIG_NLS_CODEPAGE_866=yCONFIG_NLS_CODEPAGE_936=yCONFIG_NLS_ASCII=yCONFIG_NLS_ISO8859_2=yCONFIG_NLS_ISO8859_3=yCONFIG_NLS_ISO8859_4=yCONFIG_NLS_ISO8859_6=yCONFIG_NLS_ISO8859_7=yCONFIG_NLS_ISO8859_14=yCONFIG_NLS_MAC_CROATIAN=yCONFIG_NLS_MAC_GAELIC=yCONFIG_NLS_MAC_GREEK=yCONFIG_NLS_MAC_ICELAND=yCONFIG_NLS_MAC_INUIT=yCONFIG_NLS_MAC_ROMANIAN=y
# CONFIG_ENABLE_MUST_CHECK is not setCONFIG_READABLE_ASM=yCONFIG_HEADERS_CHECK=yCONFIG_DEBUG_SECTION_MISMATCH=yCONFIG_PANIC_ON_OOPS=yCONFIG_DETECT_HUNG_TASK=yCONFIG_DEBUG_OBJECTS=yCONFIG_DEBUG_OBJECTS_SELFTEST=yCONFIG_DEBUG_OBJECTS_TIMERS=yCONFIG_DEBUG_OBJECTS_WORK=yCONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=yCONFIG_RT_MUTEX_TESTER=yCONFIG_LOCK_STAT=yCONFIG_DEBUG_LOCKDEP=yCONFIG_DEBUG_MEMORY_INIT=yCONFIG_TEST_LIST_SORT=yCONFIG_DEBUG_NOTIFIERS=yCONFIG_SPARSE_RCU_POINTER=yCONFIG_DEBUG_FORCE_WEAK_PER_CPU=y
# CONFIG_FTRACE is not setCONFIG_DMA_API_DEBUG=yCONFIG_TEST_KSTRTOX=yCONFIG_STRICT_DEVMEM=yCONFIG_DEBUG_USER=yCONFIG_DEBUG_LL=yCONFIG_PID_IN_CONTEXTIDR=yCONFIG_SECURITY_DMESG_RESTRICT=yCONFIG_SECURITY=yCONFIG_SECURITY_NETWORK_XFRM=yCONFIG_SECURITY_TOMOYO=yCONFIG_SECURITY_APPARMOR=yCONFIG_SECURITY_YAMA=yCONFIG_SECURITY_YAMA_STACKED=yCONFIG_IMA=y
# CONFIG_IMA_AUDIT is not setCONFIG_CRYPTO_USER=yCONFIG_CRYPTO_GCM=yCONFIG_CRYPTO_CBC=yCONFIG_CRYPTO_CTS=yCONFIG_CRYPTO_PCBC=yCONFIG_CRYPTO_XTS=yCONFIG_CRYPTO_VMAC=yCONFIG_CRYPTO_MD4=yCONFIG_CRYPTO_RMD128=yCONFIG_CRYPTO_RMD160=yCONFIG_CRYPTO_RMD256=yCONFIG_CRYPTO_RMD320=yCONFIG_CRYPTO_SHA512=yCONFIG_CRYPTO_TGR192=yCONFIG_CRYPTO_ANUBIS=yCONFIG_CRYPTO_CAST5=yCONFIG_CRYPTO_DES=yCONFIG_CRYPTO_SERPENT=yCONFIG_CRYPTO_DEFLATE=yCONFIG_CRYPTO_LZO=yCONFIG_CRC_ITU_T=yCONFIG_XZ_DEC_X86=yCONFIG_XZ_DEC_POWERPC=yCONFIG_XZ_DEC_IA64=yCONFIG_AVERAGE=yCONFIG_VIRTUALIZATION=y
Hi guys,
Quoted 13 lines · Rob Herring
Quoted 12 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>
[...]
Quoted 11 lines
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to
atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.
[...]
Quoted 8 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );
I also can't immediately see why GCC would allocate oldval to an odd base register. Can you share your .config please?
Will
Quoted 8 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h +0
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); }
Quoted 6 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 21
Quoted 4 lines
arch/arm/include/asm/xen/events.h +4
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. Why does
atomic64_cmpxchgnot work here?
Just that we don't want/need the cmp aspect, we don't mind if an extra bit gets set as we read the value, so long as we atomically read and set to zero.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 28
Quoted 7 lines
arch/arm/include/asm/xen/events.h +7
-0+*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb ();Based on
atomic64_cmpxchgimplementation, you could usesmp_mbhere which avoids an outer cache flush.
Good point.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );And a
smp_mbis needed here.
I think for the specific caller which we have here it isn't strictly necessary, but for generic correctness I think you are right.
Thanks for reviewing.
Konrad, IIRC you have already picked this up (and sent to Linus?) so an incremental fix is required? See below.
Ian.
8<------------------------------------
Quoted 1 line
From
4ed928274dad4c3ed610e769b2ae11eb2d1ea433Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Tue, 5 Mar 2013 03:37:23 +0000
Subject: [PATCH] arm: xen: correct barriers in xchg_xen_ulong
We can use an smp_wmb rather than a wmb here and we also need one after the exchange. Spotted by Rob Herring.
--- arch/arm/include/asm/xen/events.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/include/asm/xen/events.h +2 -1
@@ -25,7 +25,7 @@ static inline xen_ulong_t xchg_xen_ulong(xen_ulong_t *ptr, xen_ulong_t val)xen_ulong_t oldval;unsigned int tmp; -wmb (); +smp_wmb (); asmvolatile ("@ xchg_xen_ulong\n" "1: ldrexd %0, %H0, [%3]\n" " strexd %1, %2, %H2, [%3]\n"
@@ -34,6 +34,7 @@ static inline xen_ulong_t xchg_xen_ulong(xen_ulong_t *ptr, xen_ulong_t val) : "=&r" (oldval), "=&r" (tmp) : "r" (val), "r" (ptr) : "memory", "cc"); +smp_wmb ();return oldval; }
Signature · 1 line
1.7.10.4
Quoted 43 lines · Ian Campbell
Quoted 8 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h +0
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); }Quoted 6 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 21
Quoted 4 lines
arch/arm/include/asm/xen/events.h +4
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. Why does
atomic64_cmpxchgnot work here?Just that we don't want/need the cmp aspect, we don't mind if an extra bit gets set as we read the value, so long as we atomically read and set to zero.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 28
Quoted 7 lines
arch/arm/include/asm/xen/events.h +7
-0+*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb ();Based on
atomic64_cmpxchgimplementation, you could usesmp_mbhere which avoids an outer cache flush.Good point.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );And a
smp_mbis needed here.
Quoted 6 lines
I think for the specific caller which we have here it isn't strictly necessary, but for generic correctness I think you are right.
Thanks for reviewing.
Konrad, IIRC you have already picked this up (and sent to Linus?) so an
Yes.
Quoted 1 line
incremental fix is required? See below.
Why don't I wait a bit and wait until you are back from conferences and can post a nice series that fixes the smp_wmb() and also the atomic one and has been run-time tested with Xen on ARM.
Quoted 43 lines · Ian Campbell
Quoted 8 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h +0
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); }Quoted 6 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 21
Quoted 4 lines
arch/arm/include/asm/xen/events.h +4
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. Why does
atomic64_cmpxchgnot work here?Just that we don't want/need the cmp aspect, we don't mind if an extra bit gets set as we read the value, so long as we atomically read and set to zero.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 28
Quoted 7 lines
arch/arm/include/asm/xen/events.h +7
-0+*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb ();Based on
atomic64_cmpxchgimplementation, you could usesmp_mbhere which avoids an outer cache flush.Good point.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );And a
smp_mbis needed here.
Quoted 6 lines
I think for the specific caller which we have here it isn't strictly necessary, but for generic correctness I think you are right.
Thanks for reviewing.
Konrad, IIRC you have already picked this up (and sent to Linus?) so an
Yes.
Quoted 1 line
incremental fix is required? See below.
Why don't I wait a bit and wait until you are back from conferences and can post a nice series that fixes the smp_wmb() and also the atomic one and has been run-time tested with Xen on ARM.
Quoted 8 lines
Quoted 8 lines
arch/arm/include/asm/xen/events.h +0
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); }
Quoted 6 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 21
Quoted 4 lines
arch/arm/include/asm/xen/events.h +4
-0+/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. Why does
atomic64_cmpxchgnot work here?
Just that we don't want/need the cmp aspect, we don't mind if an extra bit gets set as we read the value, so long as we atomically read and set to zero.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 28
Quoted 7 lines
arch/arm/include/asm/xen/events.h +7
-0+*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb ();Based on
atomic64_cmpxchgimplementation, you could usesmp_mbhere which avoids an outer cache flush.
Good point.
Quoted 10 lines
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );And a
smp_mbis needed here.
I think for the specific caller which we have here it isn't strictly necessary, but for generic correctness I think you are right.
Thanks for reviewing.
Konrad, IIRC you have already picked this up (and sent to Linus?) so an incremental fix is required? See below.
Ian.
8<------------------------------------
Quoted 1 line
From
4ed928274dad4c3ed610e769b2ae11eb2d1ea433Mon Sep 17 00:00:00 2001
From: Ian Campbell <[email protected]>
Date: Tue, 5 Mar 2013 03:37:23 +0000
Subject: [PATCH] arm: xen: correct barriers in xchg_xen_ulong
We can use an smp_wmb rather than a wmb here and we also need one after the exchange. Spotted by Rob Herring.
--- arch/arm/include/asm/xen/events.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/include/asm/xen/events.h +2 -1
@@ -25,7 +25,7 @@ static inline xen_ulong_t xchg_xen_ulong(xen_ulong_t *ptr, xen_ulong_t val)xen_ulong_t oldval;unsigned int tmp; -wmb (); +smp_wmb (); asmvolatile ("@ xchg_xen_ulong\n" "1: ldrexd %0, %H0, [%3]\n" " strexd %1, %2, %H2, [%3]\n"
@@ -34,6 +34,7 @@ static inline xen_ulong_t xchg_xen_ulong(xen_ulong_t *ptr, xen_ulong_t val) : "=&r" (oldval), "=&r" (tmp) : "r" (val), "r" (ptr) : "memory", "cc"); +smp_wmb ();return oldval; }
Signature · 1 line
1.7.10.4
Quoted 27 lines · Ian Campbell
On ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
Signed-off-by Ian Campbell <[email protected]>Cc Jan Beulich <[email protected]>Cc Keir (Xen.org) <[email protected]>Cc Tim Deegan <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>---
Changes since V4
Rebase onto v3.8
Fix wording of comment
Fix bitmask length passed tofind_first_bit, need sizeof*8 for bits not just sizeof. UseBITS_PER_EVTCHN_WORDand provide a convenience wrapper.
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements onxchg_xen_ulong.
Changes since V1
usefind_first_setnot__ffs
fix some more unsigned long ->xen_ulong_t
use more genericxchg_xen_ulonginstead of ...read_evtchn...
Quoted 7 lines
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 115 +++++++++++++++++++++--------------- include/xen/interface/xen.h | 8 +- 4 files changed, 96 insertions(+), 52 deletions(-)
I'm seeing some some build failures on randconfig builds with this change:
/tmp/ccJaIZOW.s: Assembler messages:/tmp/ccJaIZOW.s:831: Error: even register required -- `ldrexd r5,r6,[r4]'
This is with ubuntu 12.04 cross compiler (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)).
This register restriction is on ARM, but not Thumb builds. Comparing this to atomic64_cmpxchg, I don't see how to fix this. Perhaps Will or Nico have thoughts.
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 21
Quoted 12 lines
arch/arm/include/asm/xen/events.h +4
-0@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)return raw_irqs_disabled_flags (regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions.
Why does atomic64_cmpxchg not work here?
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 28
Quoted 7 lines
arch/arm/include/asm/xen/events.h +7
-0+*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb ();
Based on atomic64_cmpxchg implementation, you could use smp_mb here which avoids an outer cache flush.
arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 36
Quoted 8 lines
arch/arm/include/asm/xen/events.h +8
-0+ asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" );
And a smp_mb is needed here.
Rob
Quoted 2 lines
arch/arm/include/asm/xen/events.h +2
-0+return oldval; +}
PATCH v5 1/1 xen: event channel arrays are xen_ulong_t and not unsigned long
In reply to Ian CampbellOn ARM we want these to be the same size on 32- and 64-bit.
This is an ABI change on ARM. X86 does not change.
---
Changes since V4
Rebase onto v3.8
Fix wording of comment
Fix bitmask length passed to find_first_bit, need sizeof*8 for bits not just sizeof. Use BITS_PER_EVTCHN_WORD and provide a convenience wrapper.
Changes since V3
s/read_evtchn_pending_sel/xchg_xen_ulong/ in a comment.
Changes since V2
Add comments about the correct bitops to use, and on the ordering/barrier requirements on xchg_xen_ulong.
Changes since V1
use find_first_set not __ffs
fix some more unsigned long -> xen_ulong_t
use more generic xchg_xen_ulong instead of ...read_evtchn...
--- arch/arm/include/asm/xen/events.h | 22 +++++++ arch/x86/include/asm/xen/events.h | 3 + drivers/xen/events.c | 115 +++++++++++++++++++++--------------- include/xen/interface/xen.h | 8 +- 4 files changed, 96 insertions(+), 52 deletions(-)
arch/arm/include/asm/xen/events.h +22 -0
@@ -15,4 +15,26 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->ARM_cpsr); } +/* +* We cannot use xchg because it does not support 8-byte +* values. However it is safe to use {ldr,dtd}exd directly because all +* platforms which Xen can run on support those instructions. +*/ +static inline xen_ulong_t xchg_xen_ulong (xen_ulong_t *ptr,xen_ulong_t val) +{ +xen_ulong_t oldval; +unsigned int tmp; + +wmb (); + asmvolatile ("@ xchg_xen_ulong\n" +"1: ldrexd %0, %H0, [%3]\n" +" strexd %1, %2, %H2, [%3]\n" +" teq %1, #0\n" +" bne 1b" + :"=&r" (oldval),"=&r" (tmp) + :"r" (val),"r" (ptr) + :"memory" ,"cc" ); +return oldval; +} +#endif /* _ASM_ARM_XEN_EVENTS_H */
arch/x86/include/asm/xen/events.h +3 -0
@@ -16,4 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs) return raw_irqs_disabled_flags(regs->flags); } +/* No need for a barrier -- XCHG is a barrier on x86. */ +#define xchg_xen_ulong (ptr, val) xchg((ptr), (val)) +#endif /* _ASM_X86_XEN_EVENTS_H */
drivers/xen/events.c +67 -48
294 lines not on this page · raw message
include/xen/interface/xen.h +4 -4
@@ -285,7 +285,7 @@ DEFINE_GUEST_HANDLE_STRUCT(multicall_entry);* Event channel endpoints per domain: * 1024 if a long is 32 bits; 4096 if a long is 64 bits. */ -#define NR_EVENT_CHANNELS (sizeof(unsigned long) * sizeof(unsigned long) * 64) +#define NR_EVENT_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64)struct vcpu_time_info {/*
@@ -341,7 +341,7 @@ struct vcpu_info {*/ uint8_t evtchn_upcall_pending;uint8_t evtchn_upcall_mask; -unsigned long evtchn_pending_sel; +xen_ulong_t evtchn_pending_sel;struct arch_vcpu_info arch;struct pvclock_vcpu_time_info time; };/* 64 bytes (x86) */
@@ -384,8 +384,8 @@ struct shared_info {* per-vcpu selector word to be set. Each bit in the selector covers a * 'C long' in the PENDING bitfield array. */ -unsigned long evtchn_pending[sizeof (unsigned long ) *8 ]; -unsigned long evtchn_mask[sizeof (unsigned long ) *8 ]; +xen_ulong_t evtchn_pending[sizeof (xen_ulong_t) *8 ]; +xen_ulong_t evtchn_mask[sizeof (xen_ulong_t) *8 ];/* * Wallclock time: updated only by control software. Guests should base
Signature · 1 line
1.7.2.5