x86/fpu: Use unsigned long long shift in xfeature_uncompacted_offset()
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Wed, 28 Nov 2018 22:20:07 +0000 (23:20 +0100)
committerBorislav Petkov <bp@suse.de>
Mon, 3 Dec 2018 17:40:28 +0000 (18:40 +0100)
The xfeature mask is 64-bit so a shift from a number to its mask should
have ULL suffix or else bits above position 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>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Rik van Riel <riel@surriel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: kvm ML <kvm@vger.kernel.org>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20181128222035.2996-2-bigeasy@linutronix.de
arch/x86/kernel/fpu/xstate.c

index 87a57b7..69d5740 100644 (file)
@@ -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;
        }