mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -tip 1/4] x86/elf: Use savesegment() for segment register reads in ELF core dump
@ 2026-03-30  8:59 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
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Uros Bizjak @ 2026-03-30  8:59 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin

ELF_CORE_COPY_REGS() currently reads %ds, %es, %fs, and %gs using
inline assembly and manual zero-extension. This results in redundant
instructions like `mov %eax,%eax`.

Replace the inline assembly with the `savesegment()` helper, which
automatically zero-extends the value to the full register width,
eliminating unnecessary instructions.

For example, the %ds load sequence changes from:

  d03: 8c d8                 mov    %ds,%eax
  d05: 89 c0                 mov    %eax,%eax
  d07: 48 89 84 24 38 01 00  mov    %rax,0x138(%rsp)
  d0e: 00

to:

  ce8: 8c d8                 mov    %ds,%eax
  cea: 48 89 84 24 38 01 00  mov    %rax,0x138(%rsp)
  cf1: 00

thus eliminating the unnecessary zero-extending `mov %eax,%eax`.

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/include/asm/elf.h | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 2ba5f166e58f..c7f98977663c 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -187,7 +187,6 @@ void set_personality_ia32(bool);
 
 #define ELF_CORE_COPY_REGS(pr_reg, regs)			\
 do {								\
-	unsigned v;						\
 	(pr_reg)[0] = (regs)->r15;				\
 	(pr_reg)[1] = (regs)->r14;				\
 	(pr_reg)[2] = (regs)->r13;				\
@@ -211,10 +210,10 @@ do {								\
 	(pr_reg)[20] = (regs)->ss;				\
 	(pr_reg)[21] = x86_fsbase_read_cpu();			\
 	(pr_reg)[22] = x86_gsbase_read_cpu_inactive();		\
-	asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v;	\
-	asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v;	\
-	asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v;	\
-	asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v;	\
+	savesegment(ds, (pr_reg)[23]);				\
+	savesegment(es, (pr_reg)[24]);				\
+	savesegment(fs, (pr_reg)[25]);				\
+	savesegment(gs, (pr_reg)[26]);				\
 } while (0);
 
 /* I'm not sure if we can use '-' here */
-- 
2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH -tip 2/4] x86/process/64: Use savesegment() in __show_regs() instead of inline asm
  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 ` Uros Bizjak
  2026-03-31  8:02   ` [tip: x86/asm] " tip-bot2 for Uros Bizjak
  2026-03-30  8:59 ` [PATCH -tip 3/4] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension Uros Bizjak
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Uros Bizjak @ 2026-03-30  8:59 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin

Replace direct 'movl' instructions for DS, ES, FS, and GS read in
__show_regs() with the savesegment() helper. This improves
readability, consistency, and ensures proper handling of
segment registers on x86_64.

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_64.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 08e72f429870..b85e715ebb30 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -104,10 +104,10 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode,
 		return;
 	}
 
-	asm("movl %%ds,%0" : "=r" (ds));
-	asm("movl %%es,%0" : "=r" (es));
-	asm("movl %%fs,%0" : "=r" (fsindex));
-	asm("movl %%gs,%0" : "=r" (gsindex));
+	savesegment(ds, ds);
+	savesegment(es, es);
+	savesegment(fs, fsindex);
+	savesegment(gs, gsindex);
 
 	rdmsrq(MSR_FS_BASE, fs);
 	rdmsrq(MSR_GS_BASE, gs);
-- 
2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH -tip 3/4] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension
  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-30  8:59 ` Uros Bizjak
  2026-03-31  8:02   ` [tip: x86/asm] " 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/elf: Use savesegment() for segment register reads in ELF core dump tip-bot2 for Uros Bizjak
  3 siblings, 1 reply; 8+ messages in thread
From: Uros Bizjak @ 2026-03-30  8:59 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH -tip 4/4] x86/tls: Clean up 'sel' variable usage in do_set_thread_area
  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-30  8:59 ` [PATCH -tip 3/4] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension Uros Bizjak
@ 2026-03-30  8:59 ` 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
  3 siblings, 1 reply; 8+ messages in thread
From: Uros Bizjak @ 2026-03-30  8:59 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Uros Bizjak, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, H. Peter Anvin

The top-level 'sel' variable in do_set_thread_area() was previously
marked __maybe_unused, but it is now only needed locally when
updating the current task.

Remove the unused top-level declaration and introduce a local 'sel'
variable where it is actually used

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/tls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 3ffbab0081f4..86b4186a0d4f 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -117,7 +117,7 @@ int do_set_thread_area(struct task_struct *p, int idx,
 		       int can_allocate)
 {
 	struct user_desc info;
-	unsigned short __maybe_unused sel, modified_sel;
+	unsigned short modified_sel;
 
 	if (copy_from_user(&info, u_info, sizeof(info)))
 		return -EFAULT;
@@ -153,6 +153,8 @@ int do_set_thread_area(struct task_struct *p, int idx,
 	modified_sel = (idx << 3) | 3;
 
 	if (p == current) {
+		unsigned short sel;
+
 #ifdef CONFIG_X86_64
 		savesegment(ds, sel);
 		if (sel == modified_sel)
-- 
2.53.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [tip: x86/asm] x86/tls: Clean up 'sel' variable usage in do_set_thread_area()
  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-bot2 for Uros Bizjak
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2026-03-31  8:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Uros Bizjak, Ingo Molnar, H. Peter Anvin, Linus Torvalds, x86,
	linux-kernel

The following commit has been merged into the x86/asm branch of tip:

Commit-ID:     3b19e22cffe61bcdf10ee5e7584cfa3c1c54dc92
Gitweb:        https://git.kernel.org/tip/3b19e22cffe61bcdf10ee5e7584cfa3c1c54dc92
Author:        Uros Bizjak <ubizjak@gmail.com>
AuthorDate:    Mon, 30 Mar 2026 10:59:23 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 31 Mar 2026 09:50:11 +02:00

x86/tls: Clean up 'sel' variable usage in do_set_thread_area()

The top-level 'sel' variable in do_set_thread_area() was previously
marked __maybe_unused, but it is now only needed locally when
updating the current task.

Remove the unused top-level declaration and introduce a local 'sel'
variable where it is actually used

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://patch.msgid.link/20260330085938.67985-4-ubizjak@gmail.com
---
 arch/x86/kernel/tls.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 3ffbab0..86b4186 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -117,7 +117,7 @@ int do_set_thread_area(struct task_struct *p, int idx,
 		       int can_allocate)
 {
 	struct user_desc info;
-	unsigned short __maybe_unused sel, modified_sel;
+	unsigned short modified_sel;
 
 	if (copy_from_user(&info, u_info, sizeof(info)))
 		return -EFAULT;
@@ -153,6 +153,8 @@ int do_set_thread_area(struct task_struct *p, int idx,
 	modified_sel = (idx << 3) | 3;
 
 	if (p == current) {
+		unsigned short sel;
+
 #ifdef CONFIG_X86_64
 		savesegment(ds, sel);
 		if (sel == modified_sel)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [tip: x86/asm] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension
  2026-03-30  8:59 ` [PATCH -tip 3/4] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension Uros Bizjak
@ 2026-03-31  8:02   ` tip-bot2 for Uros Bizjak
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2026-03-31  8:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Uros Bizjak, Ingo Molnar, H. Peter Anvin, Linus Torvalds, x86,
	linux-kernel

The following commit has been merged into the x86/asm branch of tip:

Commit-ID:     6829f19810e96903d7b532145c3d1701b4d9a0f6
Gitweb:        https://git.kernel.org/tip/6829f19810e96903d7b532145c3d1701b4d9a0f6
Author:        Uros Bizjak <ubizjak@gmail.com>
AuthorDate:    Mon, 30 Mar 2026 10:59:22 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 31 Mar 2026 09:50:10 +02:00

x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension

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>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://patch.msgid.link/20260330085938.67985-3-ubizjak@gmail.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 3ef15c2..168dabf 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);
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [tip: x86/asm] x86/process/64: Use savesegment() in __show_regs() instead of inline asm
  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-bot2 for Uros Bizjak
  0 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2026-03-31  8:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Uros Bizjak, Ingo Molnar, H. Peter Anvin, Linus Torvalds, x86,
	linux-kernel

The following commit has been merged into the x86/asm branch of tip:

Commit-ID:     81310ce4287a23b8ff6e8684de73cfaae88782ca
Gitweb:        https://git.kernel.org/tip/81310ce4287a23b8ff6e8684de73cfaae88782ca
Author:        Uros Bizjak <ubizjak@gmail.com>
AuthorDate:    Mon, 30 Mar 2026 10:59:21 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 31 Mar 2026 09:50:10 +02:00

x86/process/64: Use savesegment() in __show_regs() instead of inline asm

Replace direct 'movl' instructions for DS, ES, FS, and GS read in
__show_regs() with the savesegment() helper. This improves
readability, consistency, and ensures proper handling of
segment registers on x86_64.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://patch.msgid.link/20260330085938.67985-2-ubizjak@gmail.com
---
 arch/x86/kernel/process_64.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 08e72f4..b85e715 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -104,10 +104,10 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode,
 		return;
 	}
 
-	asm("movl %%ds,%0" : "=r" (ds));
-	asm("movl %%es,%0" : "=r" (es));
-	asm("movl %%fs,%0" : "=r" (fsindex));
-	asm("movl %%gs,%0" : "=r" (gsindex));
+	savesegment(ds, ds);
+	savesegment(es, es);
+	savesegment(fs, fsindex);
+	savesegment(gs, gsindex);
 
 	rdmsrq(MSR_FS_BASE, fs);
 	rdmsrq(MSR_GS_BASE, gs);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [tip: x86/asm] x86/elf: Use savesegment() for segment register reads in ELF core dump
  2026-03-30  8:59 [PATCH -tip 1/4] x86/elf: Use savesegment() for segment register reads in ELF core dump Uros Bizjak
                   ` (2 preceding siblings ...)
  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-bot2 for Uros Bizjak
  3 siblings, 0 replies; 8+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2026-03-31  8:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Uros Bizjak, Ingo Molnar, H. Peter Anvin, Linus Torvalds, x86,
	linux-kernel

The following commit has been merged into the x86/asm branch of tip:

Commit-ID:     47d2f007615ace34c5ec9026cd5f286833c62c1b
Gitweb:        https://git.kernel.org/tip/47d2f007615ace34c5ec9026cd5f286833c62c1b
Author:        Uros Bizjak <ubizjak@gmail.com>
AuthorDate:    Mon, 30 Mar 2026 10:59:20 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 31 Mar 2026 09:50:10 +02:00

x86/elf: Use savesegment() for segment register reads in ELF core dump

ELF_CORE_COPY_REGS() currently reads %ds, %es, %fs, and %gs using
inline assembly and manual zero-extension. This results in redundant
instructions like `mov %eax,%eax`.

Replace the inline assembly with the `savesegment()` helper, which
automatically zero-extends the value to the full register width,
eliminating unnecessary instructions.

For example, the %ds load sequence changes from:

  d03: 8c d8                 mov    %ds,%eax
  d05: 89 c0                 mov    %eax,%eax
  d07: 48 89 84 24 38 01 00  mov    %rax,0x138(%rsp)
  d0e: 00

to:

  ce8: 8c d8                 mov    %ds,%eax
  cea: 48 89 84 24 38 01 00  mov    %rax,0x138(%rsp)
  cf1: 00

thus eliminating the unnecessary zero-extending `mov %eax,%eax`.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://patch.msgid.link/20260330085938.67985-1-ubizjak@gmail.com
---
 arch/x86/include/asm/elf.h |  9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
index 2ba5f16..c7f9897 100644
--- a/arch/x86/include/asm/elf.h
+++ b/arch/x86/include/asm/elf.h
@@ -187,7 +187,6 @@ void set_personality_ia32(bool);
 
 #define ELF_CORE_COPY_REGS(pr_reg, regs)			\
 do {								\
-	unsigned v;						\
 	(pr_reg)[0] = (regs)->r15;				\
 	(pr_reg)[1] = (regs)->r14;				\
 	(pr_reg)[2] = (regs)->r13;				\
@@ -211,10 +210,10 @@ do {								\
 	(pr_reg)[20] = (regs)->ss;				\
 	(pr_reg)[21] = x86_fsbase_read_cpu();			\
 	(pr_reg)[22] = x86_gsbase_read_cpu_inactive();		\
-	asm("movl %%ds,%0" : "=r" (v)); (pr_reg)[23] = v;	\
-	asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v;	\
-	asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v;	\
-	asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v;	\
+	savesegment(ds, (pr_reg)[23]);				\
+	savesegment(es, (pr_reg)[24]);				\
+	savesegment(fs, (pr_reg)[25]);				\
+	savesegment(gs, (pr_reg)[26]);				\
 } while (0);
 
 /* I'm not sure if we can use '-' here */

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-31  8:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH -tip 3/4] x86/process/32: Use correct type for 'gs' variable in __show_regs() to avoid zero-extension Uros Bizjak
2026-03-31  8:02   ` [tip: x86/asm] " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox