Skip to content

Commit e57d9f6

Browse files
committed
Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mm updates from Ingo Molnar: "The main changes in this cycle were: - Update and clean up x86 fault handling, by Andy Lutomirski. - Drop usage of __flush_tlb_all() in kernel_physical_mapping_init() and related fallout, by Dan Williams. - CPA cleanups and reorganization by Peter Zijlstra: simplify the flow and remove a few warts. - Other misc cleanups" * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (29 commits) x86/mm/dump_pagetables: Use DEFINE_SHOW_ATTRIBUTE() x86/mm/cpa: Rename @addrinarray to @numpages x86/mm/cpa: Better use CLFLUSHOPT x86/mm/cpa: Fold cpa_flush_range() and cpa_flush_array() into a single cpa_flush() function x86/mm/cpa: Make cpa_data::numpages invariant x86/mm/cpa: Optimize cpa_flush_array() TLB invalidation x86/mm/cpa: Simplify the code after making cpa->vaddr invariant x86/mm/cpa: Make cpa_data::vaddr invariant x86/mm/cpa: Add __cpa_addr() helper x86/mm/cpa: Add ARRAY and PAGES_ARRAY selftests x86/mm: Drop usage of __flush_tlb_all() in kernel_physical_mapping_init() x86/mm: Validate kernel_physical_mapping_init() PTE population generic/pgtable: Introduce set_pte_safe() generic/pgtable: Introduce {p4d,pgd}_same() generic/pgtable: Make {pmd, pud}_same() unconditionally available x86/fault: Clean up the page fault oops decoder a bit x86/fault: Decode page fault OOPSes better x86/vsyscall/64: Use X86_PF constants in the simulated #PF error code x86/oops: Show the correct CS value in show_regs() x86/fault: Don't try to recover from an implicit supervisor access ...
2 parents d6e867a + 6848ac7 commit e57d9f6

File tree

16 files changed

+396
-346
lines changed

16 files changed

+396
-346
lines changed

arch/x86/entry/vsyscall/vsyscall_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static bool write_ok_or_segv(unsigned long ptr, size_t size)
102102
if (!access_ok(VERIFY_WRITE, (void __user *)ptr, size)) {
103103
struct thread_struct *thread = &current->thread;
104104

105-
thread->error_code = 6; /* user fault, no page, write */
105+
thread->error_code = X86_PF_USER | X86_PF_WRITE;
106106
thread->cr2 = ptr;
107107
thread->trap_nr = X86_TRAP_PF;
108108

arch/x86/include/asm/disabled-features.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
# define DISABLE_MPX (1<<(X86_FEATURE_MPX & 31))
1717
#endif
1818

19+
#ifdef CONFIG_X86_SMAP
20+
# define DISABLE_SMAP 0
21+
#else
22+
# define DISABLE_SMAP (1<<(X86_FEATURE_SMAP & 31))
23+
#endif
24+
1925
#ifdef CONFIG_X86_INTEL_UMIP
2026
# define DISABLE_UMIP 0
2127
#else
@@ -68,7 +74,7 @@
6874
#define DISABLED_MASK6 0
6975
#define DISABLED_MASK7 (DISABLE_PTI)
7076
#define DISABLED_MASK8 0
71-
#define DISABLED_MASK9 (DISABLE_MPX)
77+
#define DISABLED_MASK9 (DISABLE_MPX|DISABLE_SMAP)
7278
#define DISABLED_MASK10 0
7379
#define DISABLED_MASK11 0
7480
#define DISABLED_MASK12 0

arch/x86/include/asm/pgalloc.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
8080
set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
8181
}
8282

83+
static inline void pmd_populate_kernel_safe(struct mm_struct *mm,
84+
pmd_t *pmd, pte_t *pte)
85+
{
86+
paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
87+
set_pmd_safe(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
88+
}
89+
8390
static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
8491
struct page *pte)
8592
{
@@ -132,6 +139,12 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
132139
paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
133140
set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
134141
}
142+
143+
static inline void pud_populate_safe(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
144+
{
145+
paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
146+
set_pud_safe(pud, __pud(_PAGE_TABLE | __pa(pmd)));
147+
}
135148
#endif /* CONFIG_X86_PAE */
136149

137150
#if CONFIG_PGTABLE_LEVELS > 3
@@ -141,6 +154,12 @@ static inline void p4d_populate(struct mm_struct *mm, p4d_t *p4d, pud_t *pud)
141154
set_p4d(p4d, __p4d(_PAGE_TABLE | __pa(pud)));
142155
}
143156

157+
static inline void p4d_populate_safe(struct mm_struct *mm, p4d_t *p4d, pud_t *pud)
158+
{
159+
paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
160+
set_p4d_safe(p4d, __p4d(_PAGE_TABLE | __pa(pud)));
161+
}
162+
144163
static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
145164
{
146165
gfp_t gfp = GFP_KERNEL_ACCOUNT;
@@ -173,6 +192,14 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, p4d_t *p4d)
173192
set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(p4d)));
174193
}
175194

195+
static inline void pgd_populate_safe(struct mm_struct *mm, pgd_t *pgd, p4d_t *p4d)
196+
{
197+
if (!pgtable_l5_enabled())
198+
return;
199+
paravirt_alloc_p4d(mm, __pa(p4d) >> PAGE_SHIFT);
200+
set_pgd_safe(pgd, __pgd(_PAGE_TABLE | __pa(p4d)));
201+
}
202+
176203
static inline p4d_t *p4d_alloc_one(struct mm_struct *mm, unsigned long addr)
177204
{
178205
gfp_t gfp = GFP_KERNEL_ACCOUNT;

arch/x86/kernel/process_64.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
6868
unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
6969
unsigned long d0, d1, d2, d3, d6, d7;
7070
unsigned int fsindex, gsindex;
71-
unsigned int ds, cs, es;
71+
unsigned int ds, es;
7272

7373
show_iret_regs(regs);
7474

@@ -100,7 +100,6 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
100100
}
101101

102102
asm("movl %%ds,%0" : "=r" (ds));
103-
asm("movl %%cs,%0" : "=r" (cs));
104103
asm("movl %%es,%0" : "=r" (es));
105104
asm("movl %%fs,%0" : "=r" (fsindex));
106105
asm("movl %%gs,%0" : "=r" (gsindex));
@@ -116,7 +115,7 @@ void __show_regs(struct pt_regs *regs, enum show_regs_mode mode)
116115

117116
printk(KERN_DEFAULT "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n",
118117
fs, fsindex, gs, gsindex, shadowgs);
119-
printk(KERN_DEFAULT "CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds,
118+
printk(KERN_DEFAULT "CS: %04lx DS: %04x ES: %04x CR0: %016lx\n", regs->cs, ds,
120119
es, cr0);
121120
printk(KERN_DEFAULT "CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3,
122121
cr4);

arch/x86/mm/debug_pagetables.c

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,9 @@ static int ptdump_show(struct seq_file *m, void *v)
1010
return 0;
1111
}
1212

13-
static int ptdump_open(struct inode *inode, struct file *filp)
14-
{
15-
return single_open(filp, ptdump_show, NULL);
16-
}
17-
18-
static const struct file_operations ptdump_fops = {
19-
.owner = THIS_MODULE,
20-
.open = ptdump_open,
21-
.read = seq_read,
22-
.llseek = seq_lseek,
23-
.release = single_release,
24-
};
13+
DEFINE_SHOW_ATTRIBUTE(ptdump);
2514

26-
static int ptdump_show_curknl(struct seq_file *m, void *v)
15+
static int ptdump_curknl_show(struct seq_file *m, void *v)
2716
{
2817
if (current->mm->pgd) {
2918
down_read(&current->mm->mmap_sem);
@@ -33,23 +22,12 @@ static int ptdump_show_curknl(struct seq_file *m, void *v)
3322
return 0;
3423
}
3524

36-
static int ptdump_open_curknl(struct inode *inode, struct file *filp)
37-
{
38-
return single_open(filp, ptdump_show_curknl, NULL);
39-
}
40-
41-
static const struct file_operations ptdump_curknl_fops = {
42-
.owner = THIS_MODULE,
43-
.open = ptdump_open_curknl,
44-
.read = seq_read,
45-
.llseek = seq_lseek,
46-
.release = single_release,
47-
};
25+
DEFINE_SHOW_ATTRIBUTE(ptdump_curknl);
4826

4927
#ifdef CONFIG_PAGE_TABLE_ISOLATION
5028
static struct dentry *pe_curusr;
5129

52-
static int ptdump_show_curusr(struct seq_file *m, void *v)
30+
static int ptdump_curusr_show(struct seq_file *m, void *v)
5331
{
5432
if (current->mm->pgd) {
5533
down_read(&current->mm->mmap_sem);
@@ -59,42 +37,20 @@ static int ptdump_show_curusr(struct seq_file *m, void *v)
5937
return 0;
6038
}
6139

62-
static int ptdump_open_curusr(struct inode *inode, struct file *filp)
63-
{
64-
return single_open(filp, ptdump_show_curusr, NULL);
65-
}
66-
67-
static const struct file_operations ptdump_curusr_fops = {
68-
.owner = THIS_MODULE,
69-
.open = ptdump_open_curusr,
70-
.read = seq_read,
71-
.llseek = seq_lseek,
72-
.release = single_release,
73-
};
40+
DEFINE_SHOW_ATTRIBUTE(ptdump_curusr);
7441
#endif
7542

7643
#if defined(CONFIG_EFI) && defined(CONFIG_X86_64)
7744
static struct dentry *pe_efi;
7845

79-
static int ptdump_show_efi(struct seq_file *m, void *v)
46+
static int ptdump_efi_show(struct seq_file *m, void *v)
8047
{
8148
if (efi_mm.pgd)
8249
ptdump_walk_pgd_level_debugfs(m, efi_mm.pgd, false);
8350
return 0;
8451
}
8552

86-
static int ptdump_open_efi(struct inode *inode, struct file *filp)
87-
{
88-
return single_open(filp, ptdump_show_efi, NULL);
89-
}
90-
91-
static const struct file_operations ptdump_efi_fops = {
92-
.owner = THIS_MODULE,
93-
.open = ptdump_open_efi,
94-
.read = seq_read,
95-
.llseek = seq_lseek,
96-
.release = single_release,
97-
};
53+
DEFINE_SHOW_ATTRIBUTE(ptdump_efi);
9854
#endif
9955

10056
static struct dentry *dir, *pe_knl, *pe_curknl;

0 commit comments

Comments
 (0)