Skip to content

Commit 7911b65

Browse files
benzeajmberg-intel
authored andcommitted
um: remove LDT support
The current LDT code has a few issues that mean it should be redone in a different way once we always start with a fresh MM even when cloning. In a new and better world, the kernel would just ensure its own LDT is clear at startup. At that point, all that is needed is a simple function to populate the LDT from another MM in arch_dup_mmap combined with some tracking of the installed LDT entries for each MM. Note that the old implementation was even incorrect with regard to reading, as it copied out the LDT entries in the internal format rather than converting them to the userspace structure. Removal should be fine as the LDT is not used for thread-local storage anymore. Signed-off-by: Benjamin Berg <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Johannes Berg <[email protected]>
1 parent 6d8992e commit 7911b65

File tree

9 files changed

+10
-477
lines changed

9 files changed

+10
-477
lines changed

arch/um/include/asm/mmu.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77
#define __ARCH_UM_MMU_H
88

99
#include <mm_id.h>
10-
#include <asm/mm_context.h>
1110

1211
typedef struct mm_context {
1312
struct mm_id id;
14-
struct uml_arch_mm_context arch;
1513
} mm_context_t;
1614

17-
/* Avoid tangled inclusion with asm/ldt.h */
18-
extern long init_new_ldt(struct mm_context *to_mm, struct mm_context *from_mm);
19-
extern void free_ldt(struct mm_context *mm);
20-
2115
#endif

arch/um/include/shared/skas/stub-data.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,16 @@ enum stub_syscall_type {
2020
STUB_SYSCALL_MMAP,
2121
STUB_SYSCALL_MUNMAP,
2222
STUB_SYSCALL_MPROTECT,
23-
STUB_SYSCALL_LDT,
2423
};
2524

2625
struct stub_syscall {
27-
union {
28-
struct {
29-
unsigned long addr;
30-
unsigned long length;
31-
unsigned long offset;
32-
int fd;
33-
int prot;
34-
} mem;
35-
struct {
36-
user_desc_t desc;
37-
int func;
38-
} ldt;
39-
};
26+
struct {
27+
unsigned long addr;
28+
unsigned long length;
29+
unsigned long offset;
30+
int fd;
31+
int prot;
32+
} mem;
4033

4134
enum stub_syscall_type syscall;
4235
};

arch/um/kernel/skas/mmu.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
4646
goto out_free;
4747
}
4848

49-
ret = init_new_ldt(to_mm, from_mm);
50-
if (ret < 0) {
51-
printk(KERN_ERR "init_new_context_skas - init_ldt"
52-
" failed, errno = %d\n", ret);
53-
goto out_free;
54-
}
55-
5649
return 0;
5750

5851
out_free:
@@ -80,5 +73,4 @@ void destroy_context(struct mm_struct *mm)
8073
os_kill_ptraced_process(mmu->id.u.pid, 1);
8174

8275
free_pages(mmu->id.stack, ilog2(STUB_DATA_PAGES));
83-
free_ldt(mmu);
8476
}

arch/um/kernel/skas/stub.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,6 @@ static __always_inline int syscall_handler(struct stub_data *d)
4545
return -1;
4646
}
4747
break;
48-
case STUB_SYSCALL_LDT:
49-
res = stub_syscall3(__NR_modify_ldt, sc->ldt.func,
50-
(unsigned long) &sc->ldt.desc,
51-
sizeof(sc->ldt.desc));
52-
/* We only write, so the expected result is zero */
53-
if (res) {
54-
d->err = res;
55-
d->syscall_data_len = i;
56-
return -1;
57-
}
58-
break;
5948
default:
6049
d->err = -95; /* EOPNOTSUPP */
6150
d->syscall_data_len = i;

arch/um/os-Linux/start_up.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <sys/wait.h>
1818
#include <sys/time.h>
1919
#include <sys/resource.h>
20+
#include <asm/ldt.h>
2021
#include <asm/unistd.h>
2122
#include <init.h>
2223
#include <os.h>

arch/x86/um/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ else
99
BITS := 64
1010
endif
1111

12-
obj-y = bugs_$(BITS).o delay.o fault.o ldt.o \
12+
obj-y = bugs_$(BITS).o delay.o fault.o \
1313
ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal.o \
1414
stub_segv.o \
1515
sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o \

arch/x86/um/asm/mm_context.h

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)