[PATCH v1] x86/gdt: Replace u16 castings by bitwise & in GDT_ENTRY_INIT()

From: Andy Shevchenko
Date: Tue Jun 02 2020 - 05:19:48 EST


It appears that the original commit 1e5de18278e6
("x86: Introduce GDT_ENTRY_INIT()") used bitwise operations on the parameters
when the commit 38e9e81f4c81 ("x86/gdt: Use bitfields for initialization")
changed them to simple castings. The latter change recently made sparse not
happy about. To satisfy it return to bitwise operations in GDT_ENTRY_INIT().

Fixes: 38e9e81f4c81 ("x86/gdt: Use bitfields for initialization")
Reported-by: kbuild test robot <lkp@xxxxxxxxx>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
arch/x86/include/asm/desc_defs.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
index a91f3b6e4f2a..0d17a86fc1df 100644
--- a/arch/x86/include/asm/desc_defs.h
+++ b/arch/x86/include/asm/desc_defs.h
@@ -22,9 +22,9 @@ struct desc_struct {

#define GDT_ENTRY_INIT(flags, base, limit) \
{ \
- .limit0 = (u16) (limit), \
+ .limit0 = ((limit) >> 0) & 0xFFFF, \
.limit1 = ((limit) >> 16) & 0x0F, \
- .base0 = (u16) (base), \
+ .base0 = ((base) >> 0) & 0xFFFF, \
.base1 = ((base) >> 16) & 0xFF, \
.base2 = ((base) >> 24) & 0xFF, \
.type = (flags & 0x0f), \
--
2.27.0.rc2