@@ -6,6 +6,28 @@
#include <asm/alternative.h>
+/**
+ * array_index_mask_nospec() - generate a mask that is ~0UL when the
+ * bounds check succeeds and 0 otherwise
+ * @index: array element index
+ * @size: number of elements in array
+ *
+ * Returns:
+ * 0 - (index < size)
+ */
+#define array_index_mask_nospec array_index_mask_nospec
+static inline unsigned long array_index_mask_nospec(unsigned long index,
+ unsigned long size)
+{
+ unsigned long mask;
+
+ asm volatile ( "cmp %[size], %[index]; sbb %[mask], %[mask];"
+ : [mask] "=r" (mask)
+ : [size] "g" (size), [index] "r" (index) );
+
+ return mask;
+}
+
/* Allow to insert a read memory barrier into conditionals */
static always_inline bool barrier_nospec_true(void)
{
@@ -233,30 +233,6 @@ static always_inline unsigned long __xadd(
#define set_mb(var, value) do { xchg(&var, value); } while (0)
#define set_wmb(var, value) do { var = value; smp_wmb(); } while (0)
-/**
- * array_index_mask_nospec() - generate a mask that is ~0UL when the
- * bounds check succeeds and 0 otherwise
- * @index: array element index
- * @size: number of elements in array
- *
- * Returns:
- * 0 - (index < size)
- */
-static inline unsigned long array_index_mask_nospec(unsigned long index,
- unsigned long size)
-{
- unsigned long mask;
-
- asm volatile ( "cmp %[size], %[index]; sbb %[mask], %[mask];"
- : [mask] "=r" (mask)
- : [size] "g" (size), [index] "r" (index) );
-
- return mask;
-}
-
-/* Override default implementation in nospec.h. */
-#define array_index_mask_nospec array_index_mask_nospec
-
#define local_irq_disable() asm volatile ( "cli" : : : "memory" )
#define local_irq_enable() asm volatile ( "sti" : : : "memory" )
@@ -7,7 +7,8 @@
#ifndef XEN_NOSPEC_H
#define XEN_NOSPEC_H
-#include <asm/system.h>
+#include <xen/compiler.h>
+
#include <asm/nospec.h>
/**
system.h isn't an appropriate place to live, now that asm/nospec.h exists. This should arguably have been part of c/s db591d6e76e No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> CC: Wei Liu <wl@xen.org> CC: Roger Pau Monné <roger.pau@citrix.com> CC: Juergen Gross <jgross@suse.com> This is probably post-4.13 content --- xen/include/asm-x86/nospec.h | 22 ++++++++++++++++++++++ xen/include/asm-x86/system.h | 24 ------------------------ xen/include/xen/nospec.h | 3 ++- 3 files changed, 24 insertions(+), 25 deletions(-)