mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Uros Bizjak <ubizjak@gmail.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH -tip 3/4] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension
Date: Mon, 30 Mar 2026 10:59:22 +0200	[thread overview]
Message-ID: <20260330085938.67985-3-ubizjak@gmail.com> (raw)
In-Reply-To: <20260330085938.67985-1-ubizjak@gmail.com>

Change the type of 'gs' variable in __show_regs() from
'unsigned short' to 'unsigned int'. This prevents unwanted
zero-extension when storing the 16-bit segment register
into a wider general purpose register.

The code improves from:

  50:	8c ee                	mov    %gs,%esi
  52:	0f b7 f6             	movzwl %si,%esi
  ...
  be:	89 74 24 14          	mov    %esi,0x14(%esp)

to:

  50:	8c ef                	mov    %gs,%edi
  ...
  bb:	89 7c 24 14          	mov    %edi,0x14(%esp)

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
---
 arch/x86/kernel/process_32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 3ef15c2f152f..168dabf9853f 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -61,7 +61,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode,
 {
 	unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
 	unsigned long d0, d1, d2, d3, d6, d7;
-	unsigned short gs;
+	unsigned int gs;
 
 	savesegment(gs, gs);
 
-- 
2.53.0


  parent reply	other threads:[~2026-03-30  8:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30  8:59 [PATCH -tip 1/4] x86/elf: Use savesegment() for segment register reads in ELF core dump Uros Bizjak
2026-03-30  8:59 ` [PATCH -tip 2/4] x86/process/64: Use savesegment() in __show_regs() instead of inline asm Uros Bizjak
2026-03-31  8:02   ` [tip: x86/asm] " tip-bot2 for Uros Bizjak
2026-03-30  8:59 ` Uros Bizjak [this message]
2026-03-31  8:02   ` [tip: x86/asm] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension tip-bot2 for Uros Bizjak
2026-03-30  8:59 ` [PATCH -tip 4/4] x86/tls: Clean up 'sel' variable usage in do_set_thread_area Uros Bizjak
2026-03-31  8:02   ` [tip: x86/asm] x86/tls: Clean up 'sel' variable usage in do_set_thread_area() tip-bot2 for Uros Bizjak
2026-03-31  8:02 ` [tip: x86/asm] x86/elf: Use savesegment() for segment register reads in ELF core dump tip-bot2 for Uros Bizjak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260330085938.67985-3-ubizjak@gmail.com \
    --to=ubizjak@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox