Skip to content

Commit 695c39b

Browse files
Brian Gerstsuryasaimadhu
authored andcommitted
x86: Remove __USER32_DS
Replace all users with the equivalent __USER_DS, which will make merging native and compat code simpler. Signed-off-by: Brian Gerst <brgerst@gmail.com> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Link: https://lore.kernel.org/r/20220606203802.158958-5-brgerst@gmail.com Signed-off-by: Borislav Petkov <bp@suse.de>
1 parent 6537142 commit 695c39b

5 files changed

Lines changed: 13 additions & 18 deletions

File tree

arch/x86/entry/entry_64_compat.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ SYM_CODE_START(entry_SYSENTER_compat)
6161
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
6262

6363
/* Construct struct pt_regs on stack */
64-
pushq $__USER32_DS /* pt_regs->ss */
64+
pushq $__USER_DS /* pt_regs->ss */
6565
pushq $0 /* pt_regs->sp = 0 (placeholder) */
6666

6767
/*
@@ -197,7 +197,7 @@ SYM_INNER_LABEL(entry_SYSCALL_compat_safe_stack, SYM_L_GLOBAL)
197197
ANNOTATE_NOENDBR
198198

199199
/* Construct struct pt_regs on stack */
200-
pushq $__USER32_DS /* pt_regs->ss */
200+
pushq $__USER_DS /* pt_regs->ss */
201201
pushq %r8 /* pt_regs->sp */
202202
pushq %r11 /* pt_regs->flags */
203203
pushq $__USER32_CS /* pt_regs->cs */

arch/x86/ia32/ia32_signal.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
212212
if (ksig->ka.sa.sa_flags & SA_ONSTACK)
213213
sp = sigsp(sp, ksig);
214214
/* This is the legacy signal stack switching. */
215-
else if (regs->ss != __USER32_DS &&
215+
else if (regs->ss != __USER_DS &&
216216
!(ksig->ka.sa.sa_flags & SA_RESTORER) &&
217217
ksig->ka.sa.sa_restorer)
218218
sp = (unsigned long) ksig->ka.sa.sa_restorer;
@@ -284,11 +284,11 @@ int ia32_setup_frame(struct ksignal *ksig, struct pt_regs *regs)
284284
regs->dx = 0;
285285
regs->cx = 0;
286286

287-
loadsegment(ds, __USER32_DS);
288-
loadsegment(es, __USER32_DS);
287+
loadsegment(ds, __USER_DS);
288+
loadsegment(es, __USER_DS);
289289

290290
regs->cs = __USER32_CS;
291-
regs->ss = __USER32_DS;
291+
regs->ss = __USER_DS;
292292

293293
return 0;
294294
Efault:
@@ -361,11 +361,11 @@ int ia32_setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
361361
regs->dx = (unsigned long) &frame->info;
362362
regs->cx = (unsigned long) &frame->uc;
363363

364-
loadsegment(ds, __USER32_DS);
365-
loadsegment(es, __USER32_DS);
364+
loadsegment(ds, __USER_DS);
365+
loadsegment(es, __USER_DS);
366366

367367
regs->cs = __USER32_CS;
368-
regs->ss = __USER32_DS;
368+
regs->ss = __USER_DS;
369369

370370
return 0;
371371
Efault:

arch/x86/include/asm/elf.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ do { \
152152
(elf_check_arch_ia32(x) || \
153153
(IS_ENABLED(CONFIG_X86_X32_ABI) && (x)->e_machine == EM_X86_64))
154154

155-
#if __USER32_DS != __USER_DS
156-
# error "The following code assumes __USER32_DS == __USER_DS"
157-
#endif
158-
159155
static inline void elf_common_init(struct thread_struct *t,
160156
struct pt_regs *regs, const u16 ds)
161157
{

arch/x86/include/asm/segment.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@
210210
#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
211211
#define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8 + 3)
212212
#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8 + 3)
213-
#define __USER32_DS __USER_DS
214213
#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8 + 3)
215214
#define __CPUNODE_SEG (GDT_ENTRY_CPUNODE*8 + 3)
216215

arch/x86/xen/xen-asm.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ SYM_CODE_START(xen_entry_SYSCALL_compat)
262262

263263
/*
264264
* Neither Xen nor the kernel really knows what the old SS and
265-
* CS were. The kernel expects __USER32_DS and __USER32_CS, so
265+
* CS were. The kernel expects __USER_DS and __USER32_CS, so
266266
* report those values even though Xen will guess its own values.
267267
*/
268-
movq $__USER32_DS, 4*8(%rsp)
268+
movq $__USER_DS, 4*8(%rsp)
269269
movq $__USER32_CS, 1*8(%rsp)
270270

271271
jmp entry_SYSCALL_compat_after_hwframe
@@ -284,10 +284,10 @@ SYM_CODE_START(xen_entry_SYSENTER_compat)
284284

285285
/*
286286
* Neither Xen nor the kernel really knows what the old SS and
287-
* CS were. The kernel expects __USER32_DS and __USER32_CS, so
287+
* CS were. The kernel expects __USER_DS and __USER32_CS, so
288288
* report those values even though Xen will guess its own values.
289289
*/
290-
movq $__USER32_DS, 4*8(%rsp)
290+
movq $__USER_DS, 4*8(%rsp)
291291
movq $__USER32_CS, 1*8(%rsp)
292292

293293
jmp entry_SYSENTER_compat_after_hwframe

0 commit comments

Comments
 (0)