Message ID | 20181128222035.2996-2-bigeasy@linutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [01/29] x86/fpu: Use ULL for shift in xfeature_uncompacted_offset() | expand |
On Wed, 2018-11-28 at 23:20 +0100, Sebastian Andrzej Siewior wrote: > The xfeature mask is 64bit so a shift from a number to its mask > should > have LL prefix or else nr > 31 will be lost. This is not a problem > now > but should XFEATURE_MASK_SUPERVISOR gain a bit >31 then this check > won't > catch it. > > Use BIT_ULL() to compute a mask from a number. > > Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Reviewed-by: Rik van Riel <riel@surriel.com>
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index 87a57b7642d36..69d5740ed2546 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -444,7 +444,7 @@ static int xfeature_uncompacted_offset(int xfeature_nr) * format. Checking a supervisor state's uncompacted offset is * an error. */ - if (XFEATURE_MASK_SUPERVISOR & (1 << xfeature_nr)) { + if (XFEATURE_MASK_SUPERVISOR & BIT_ULL(xfeature_nr)) { WARN_ONCE(1, "No fixed offset for xstate %d\n", xfeature_nr); return -1; }
The xfeature mask is 64bit so a shift from a number to its mask should have LL prefix or else nr > 31 will be lost. This is not a problem now but should XFEATURE_MASK_SUPERVISOR gain a bit >31 then this check won't catch it. Use BIT_ULL() to compute a mask from a number. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- arch/x86/kernel/fpu/xstate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)