lkml.org 
[lkml]   [2018]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] x86, nospec: Fix uninitialized mask in array_index_mask_nospec()
From
Date
Break the false dependency on the uninitialized value of 'mask' in
array_index_mask_nospec(). This potentially allows the CPU to rename the
register, avoids reports from tools that can detect uninitialized inline
asm arguments, and makes it explicit that this sequence wants the result
of (0 - 0 - CARRY).

Reported-by: Andi Kleen <ak@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
arch/x86/include/asm/barrier.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
index e1259f043ae9..b572b6a77e12 100644
--- a/arch/x86/include/asm/barrier.h
+++ b/arch/x86/include/asm/barrier.h
@@ -36,10 +36,10 @@
static inline unsigned long array_index_mask_nospec(unsigned long index,
unsigned long size)
{
- unsigned long mask;
+ unsigned long mask = 0;

- asm ("cmp %1,%2; sbb %0,%0;"
- :"=r" (mask)
+ asm ("cmp %1,%2; sbb $0,%0;"
+ :"+r" (mask)
:"g"(size),"r" (index)
:"cc");
return mask;
\
 
 \ /
  Last update: 2018-02-14 22:00    [W:0.028 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site