x86/asm/32: Remove a bunch of '& 0xffff' from pt_regs segment reads
authorAndy Lutomirski <luto@kernel.org>
Fri, 28 Jul 2017 13:00:32 +0000 (06:00 -0700)
committerIngo Molnar <mingo@kernel.org>
Sun, 30 Jul 2017 10:04:41 +0000 (12:04 +0200)
Now that pt_regs properly defines segment fields as 16-bit on 32-bit
CPUs, there's no need to mask off the high word.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/ia32/ia32_signal.c
arch/x86/include/asm/elf.h
arch/x86/kernel/dumpstack.c
arch/x86/kernel/process_32.c
arch/x86/kernel/process_64.c
arch/x86/kernel/signal.c
arch/x86/kernel/step.c
arch/x86/mm/extable.c

index 724153797209e9da677412b89feab4a6e23337ec..e0bb46c0285752e73c8eb55420e29f97d88a818e 100644 (file)
@@ -226,7 +226,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
        if (ksig->ka.sa.sa_flags & SA_ONSTACK)
                sp = sigsp(sp, ksig);
        /* This is the legacy signal stack switching. */
-       else if ((regs->ss & 0xffff) != __USER32_DS &&
+       else if (regs->ss != __USER32_DS &&
                !(ksig->ka.sa.sa_flags & SA_RESTORER) &&
                 ksig->ka.sa.sa_restorer)
                sp = (unsigned long) ksig->ka.sa.sa_restorer;
index 1c18d83d3f094d1f5abfa09a08b67e9cb6b7376d..a62a12c472333280206c10e129bdf3efae40494a 100644 (file)
@@ -126,15 +126,15 @@ do {                                              \
        pr_reg[4] = regs->di;                   \
        pr_reg[5] = regs->bp;                   \
        pr_reg[6] = regs->ax;                   \
-       pr_reg[7] = regs->ds & 0xffff;          \
-       pr_reg[8] = regs->es & 0xffff;          \
-       pr_reg[9] = regs->fs & 0xffff;          \
+       pr_reg[7] = regs->ds;                   \
+       pr_reg[8] = regs->es;                   \
+       pr_reg[9] = regs->fs;                   \
        pr_reg[11] = regs->orig_ax;             \
        pr_reg[12] = regs->ip;                  \
-       pr_reg[13] = regs->cs & 0xffff;         \
+       pr_reg[13] = regs->cs;                  \
        pr_reg[14] = regs->flags;               \
        pr_reg[15] = regs->sp;                  \
-       pr_reg[16] = regs->ss & 0xffff;         \
+       pr_reg[16] = regs->ss;                  \
 } while (0);
 
 #define ELF_CORE_COPY_REGS(pr_reg, regs)       \
index bd265a4cf10879c2f4b444bd9d83f6fc86b8a6c2..f13b4c00a5de4b7a7b36c40d27311672bcc9d05c 100644 (file)
@@ -267,7 +267,7 @@ int __die(const char *str, struct pt_regs *regs, long err)
 #ifdef CONFIG_X86_32
        if (user_mode(regs)) {
                sp = regs->sp;
-               ss = regs->ss & 0xffff;
+               ss = regs->ss;
        } else {
                sp = kernel_stack_pointer(regs);
                savesegment(ss, ss);
index c6d6dc5f8bb2a2245bf0203c498abf38d6be0bc4..efc5eeb58292c2edc95b7def7731cebee37fcba8 100644 (file)
@@ -68,7 +68,7 @@ void __show_regs(struct pt_regs *regs, int all)
 
        if (user_mode(regs)) {
                sp = regs->sp;
-               ss = regs->ss & 0xffff;
+               ss = regs->ss;
                gs = get_user_gs(regs);
        } else {
                sp = kernel_stack_pointer(regs);
index 2987e3991c2b3fb28f9cdc5e082de33970d1ba32..e04941fb67fba42a87883673dcd310add2b057b9 100644 (file)
@@ -69,8 +69,7 @@ void __show_regs(struct pt_regs *regs, int all)
        unsigned int fsindex, gsindex;
        unsigned int ds, cs, es;
 
-       printk(KERN_DEFAULT "RIP: %04lx:%pS\n", regs->cs & 0xffff,
-               (void *)regs->ip);
+       printk(KERN_DEFAULT "RIP: %04lx:%pS\n", regs->cs, (void *)regs->ip);
        printk(KERN_DEFAULT "RSP: %04lx:%016lx EFLAGS: %08lx", regs->ss,
                regs->sp, regs->flags);
        if (regs->orig_ax != -1)
index cc30a74e4adb2c3499b52488c49498dea1851ae7..e04442345fc0977cf73f2573f77b3df71310f0a8 100644 (file)
@@ -256,7 +256,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size,
                        sp = current->sas_ss_sp + current->sas_ss_size;
        } else if (IS_ENABLED(CONFIG_X86_32) &&
                   !onsigstack &&
-                  (regs->ss & 0xffff) != __USER_DS &&
+                  regs->ss != __USER_DS &&
                   !(ka->sa.sa_flags & SA_RESTORER) &&
                   ka->sa.sa_restorer) {
                /* This is the legacy signal stack switching. */
index 5f25cfbd952ef4fa53aa8df178f65a518a6de54d..5ee663836c08fc8eaa78e18118f1b99bf15edb4b 100644 (file)
@@ -13,7 +13,7 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
        unsigned long addr, seg;
 
        addr = regs->ip;
-       seg = regs->cs & 0xffff;
+       seg = regs->cs;
        if (v8086_mode(regs)) {
                addr = (addr & 0xffff) + (seg << 4);
                return addr;
index 0ea8afcb929c031fdac01681ac277dcf74887e4e..fb2ddcdf7c73f3c834e3a6bbe878bc166960c7a2 100644 (file)
@@ -142,7 +142,7 @@ void __init early_fixup_exception(struct pt_regs *regs, int trapnr)
         * undefined.  I'm not sure which CPUs do this, but at least
         * the 486 DX works this way.
         */
-       if ((regs->cs & 0xFFFF) != __KERNEL_CS)
+       if (regs->cs != __KERNEL_CS)
                goto fail;
 
        /*