Skip to content

Commit 2800348

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner: "This update contains: - the manual revert of the SYSCALL32 changes which caused a regression - a fix for the MPX vma handling - three fixes for the ioremap 'is ram' checks. - PAT warning fixes - a trivial fix for the size calculation of TLB tracepoints - handle old EFI structures gracefully This also contains a PAT fix from Jan plus a revert thereof. Toshi explained why the code is correct" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm/pat: Revert 'Adjust default caching mode translation tables' x86/asm/entry/32: Revert 'Do not use R9 in SYSCALL32' commit x86/mm: Fix newly introduced printk format warnings mm: Fix bugs in region_is_ram() x86/mm: Remove region_is_ram() call from ioremap x86/mm: Move warning from __ioremap_check_ram() to the call site x86/mm/pat, drivers/media/ivtv: Move the PAT warning and replace WARN() with pr_warn() x86/mm/pat, drivers/infiniband/ipath: Replace WARN() with pr_warn() x86/mm/pat: Adjust default caching mode translation tables x86/fpu: Disable dependent CPU features on "noxsave" x86/mpx: Do not set ->vm_ops on MPX VMAs x86/mm: Add parenthesis for TLB tracepoint size calculation efi: Handle memory error structures produced based on old versions of standard
2 parents 26ae19a + 1a4e879 commit 2800348

File tree

11 files changed

+81
-59
lines changed

11 files changed

+81
-59
lines changed

arch/x86/entry/entry_64_compat.S

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ sysexit_from_sys_call:
205205
movl RDX(%rsp), %edx /* arg3 */
206206
movl RSI(%rsp), %ecx /* arg4 */
207207
movl RDI(%rsp), %r8d /* arg5 */
208-
movl %ebp, %r9d /* arg6 */
209208
.endm
210209

211210
.macro auditsys_exit exit
@@ -236,6 +235,7 @@ sysexit_from_sys_call:
236235

237236
sysenter_auditsys:
238237
auditsys_entry_common
238+
movl %ebp, %r9d /* reload 6th syscall arg */
239239
jmp sysenter_dispatch
240240

241241
sysexit_audit:
@@ -336,7 +336,7 @@ ENTRY(entry_SYSCALL_compat)
336336
* 32-bit zero extended:
337337
*/
338338
ASM_STAC
339-
1: movl (%r8), %ebp
339+
1: movl (%r8), %r9d
340340
_ASM_EXTABLE(1b, ia32_badarg)
341341
ASM_CLAC
342342
orl $TS_COMPAT, ASM_THREAD_INFO(TI_status, %rsp, SIZEOF_PTREGS)
@@ -346,7 +346,7 @@ ENTRY(entry_SYSCALL_compat)
346346
cstar_do_call:
347347
/* 32-bit syscall -> 64-bit C ABI argument conversion */
348348
movl %edi, %r8d /* arg5 */
349-
movl %ebp, %r9d /* arg6 */
349+
/* r9 already loaded */ /* arg6 */
350350
xchg %ecx, %esi /* rsi:arg2, rcx:arg4 */
351351
movl %ebx, %edi /* arg1 */
352352
movl %edx, %edx /* arg3 (zero extension) */
@@ -358,7 +358,6 @@ cstar_dispatch:
358358
call *ia32_sys_call_table(, %rax, 8)
359359
movq %rax, RAX(%rsp)
360360
1:
361-
movl RCX(%rsp), %ebp
362361
DISABLE_INTERRUPTS(CLBR_NONE)
363362
TRACE_IRQS_OFF
364363
testl $_TIF_ALLWORK_MASK, ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
@@ -392,7 +391,9 @@ sysretl_from_sys_call:
392391

393392
#ifdef CONFIG_AUDITSYSCALL
394393
cstar_auditsys:
394+
movl %r9d, R9(%rsp) /* register to be clobbered by call */
395395
auditsys_entry_common
396+
movl R9(%rsp), %r9d /* reload 6th syscall arg */
396397
jmp cstar_dispatch
397398

398399
sysretl_audit:
@@ -404,14 +405,16 @@ cstar_tracesys:
404405
testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT), ASM_THREAD_INFO(TI_flags, %rsp, SIZEOF_PTREGS)
405406
jz cstar_auditsys
406407
#endif
408+
xchgl %r9d, %ebp
407409
SAVE_EXTRA_REGS
408410
xorl %eax, %eax /* Do not leak kernel information */
409411
movq %rax, R11(%rsp)
410412
movq %rax, R10(%rsp)
411-
movq %rax, R9(%rsp)
413+
movq %r9, R9(%rsp)
412414
movq %rax, R8(%rsp)
413415
movq %rsp, %rdi /* &pt_regs -> arg1 */
414416
call syscall_trace_enter
417+
movl R9(%rsp), %r9d
415418

416419
/* Reload arg registers from stack. (see sysenter_tracesys) */
417420
movl RCX(%rsp), %ecx
@@ -421,6 +424,7 @@ cstar_tracesys:
421424
movl %eax, %eax /* zero extension */
422425

423426
RESTORE_EXTRA_REGS
427+
xchgl %ebp, %r9d
424428
jmp cstar_do_call
425429
END(entry_SYSCALL_compat)
426430

arch/x86/kernel/fpu/init.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,15 @@ static int __init x86_noxsave_setup(char *s)
351351

352352
setup_clear_cpu_cap(X86_FEATURE_XSAVE);
353353
setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
354+
setup_clear_cpu_cap(X86_FEATURE_XSAVEC);
354355
setup_clear_cpu_cap(X86_FEATURE_XSAVES);
355356
setup_clear_cpu_cap(X86_FEATURE_AVX);
356357
setup_clear_cpu_cap(X86_FEATURE_AVX2);
358+
setup_clear_cpu_cap(X86_FEATURE_AVX512F);
359+
setup_clear_cpu_cap(X86_FEATURE_AVX512PF);
360+
setup_clear_cpu_cap(X86_FEATURE_AVX512ER);
361+
setup_clear_cpu_cap(X86_FEATURE_AVX512CD);
362+
setup_clear_cpu_cap(X86_FEATURE_MPX);
357363

358364
return 1;
359365
}

arch/x86/mm/ioremap.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ static int __ioremap_check_ram(unsigned long start_pfn, unsigned long nr_pages,
6363
!PageReserved(pfn_to_page(start_pfn + i)))
6464
return 1;
6565

66-
WARN_ONCE(1, "ioremap on RAM pfn 0x%lx\n", start_pfn);
67-
6866
return 0;
6967
}
7068

@@ -94,7 +92,6 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
9492
pgprot_t prot;
9593
int retval;
9694
void __iomem *ret_addr;
97-
int ram_region;
9895

9996
/* Don't allow wraparound or zero size */
10097
last_addr = phys_addr + size - 1;
@@ -117,23 +114,15 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
117114
/*
118115
* Don't allow anybody to remap normal RAM that we're using..
119116
*/
120-
/* First check if whole region can be identified as RAM or not */
121-
ram_region = region_is_ram(phys_addr, size);
122-
if (ram_region > 0) {
123-
WARN_ONCE(1, "ioremap on RAM at 0x%lx - 0x%lx\n",
124-
(unsigned long int)phys_addr,
125-
(unsigned long int)last_addr);
117+
pfn = phys_addr >> PAGE_SHIFT;
118+
last_pfn = last_addr >> PAGE_SHIFT;
119+
if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
120+
__ioremap_check_ram) == 1) {
121+
WARN_ONCE(1, "ioremap on RAM at %pa - %pa\n",
122+
&phys_addr, &last_addr);
126123
return NULL;
127124
}
128125

129-
/* If could not be identified(-1), check page by page */
130-
if (ram_region < 0) {
131-
pfn = phys_addr >> PAGE_SHIFT;
132-
last_pfn = last_addr >> PAGE_SHIFT;
133-
if (walk_system_ram_range(pfn, last_pfn - pfn + 1, NULL,
134-
__ioremap_check_ram) == 1)
135-
return NULL;
136-
}
137126
/*
138127
* Mappings have to be page-aligned
139128
*/

arch/x86/mm/mmap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
126126
mm->get_unmapped_area = arch_get_unmapped_area_topdown;
127127
}
128128
}
129+
130+
const char *arch_vma_name(struct vm_area_struct *vma)
131+
{
132+
if (vma->vm_flags & VM_MPX)
133+
return "[mpx]";
134+
return NULL;
135+
}

arch/x86/mm/mpx.c

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@
2020
#define CREATE_TRACE_POINTS
2121
#include <asm/trace/mpx.h>
2222

23-
static const char *mpx_mapping_name(struct vm_area_struct *vma)
24-
{
25-
return "[mpx]";
26-
}
27-
28-
static struct vm_operations_struct mpx_vma_ops = {
29-
.name = mpx_mapping_name,
30-
};
31-
32-
static int is_mpx_vma(struct vm_area_struct *vma)
33-
{
34-
return (vma->vm_ops == &mpx_vma_ops);
35-
}
36-
3723
static inline unsigned long mpx_bd_size_bytes(struct mm_struct *mm)
3824
{
3925
if (is_64bit_mm(mm))
@@ -53,9 +39,6 @@ static inline unsigned long mpx_bt_size_bytes(struct mm_struct *mm)
5339
/*
5440
* This is really a simplified "vm_mmap". it only handles MPX
5541
* bounds tables (the bounds directory is user-allocated).
56-
*
57-
* Later on, we use the vma->vm_ops to uniquely identify these
58-
* VMAs.
5942
*/
6043
static unsigned long mpx_mmap(unsigned long len)
6144
{
@@ -101,7 +84,6 @@ static unsigned long mpx_mmap(unsigned long len)
10184
ret = -ENOMEM;
10285
goto out;
10386
}
104-
vma->vm_ops = &mpx_vma_ops;
10587

10688
if (vm_flags & VM_LOCKED) {
10789
up_write(&mm->mmap_sem);
@@ -812,7 +794,7 @@ static noinline int zap_bt_entries_mapping(struct mm_struct *mm,
812794
* so stop immediately and return an error. This
813795
* probably results in a SIGSEGV.
814796
*/
815-
if (!is_mpx_vma(vma))
797+
if (!(vma->vm_flags & VM_MPX))
816798
return -EINVAL;
817799

818800
len = min(vma->vm_end, end) - addr;
@@ -945,9 +927,9 @@ static int try_unmap_single_bt(struct mm_struct *mm,
945927
* lots of tables even though we have no actual table
946928
* entries in use.
947929
*/
948-
while (next && is_mpx_vma(next))
930+
while (next && (next->vm_flags & VM_MPX))
949931
next = next->vm_next;
950-
while (prev && is_mpx_vma(prev))
932+
while (prev && (prev->vm_flags & VM_MPX))
951933
prev = prev->vm_prev;
952934
/*
953935
* We know 'start' and 'end' lie within an area controlled

arch/x86/mm/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static void flush_tlb_func(void *info)
117117
} else {
118118
unsigned long addr;
119119
unsigned long nr_pages =
120-
f->flush_end - f->flush_start / PAGE_SIZE;
120+
(f->flush_end - f->flush_start) / PAGE_SIZE;
121121
addr = f->flush_start;
122122
while (addr < f->flush_end) {
123123
__flush_tlb_single(addr);

drivers/firmware/efi/cper.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,17 @@ const char *cper_mem_err_unpack(struct trace_seq *p,
305305
return ret;
306306
}
307307

308-
static void cper_print_mem(const char *pfx, const struct cper_sec_mem_err *mem)
308+
static void cper_print_mem(const char *pfx, const struct cper_sec_mem_err *mem,
309+
int len)
309310
{
310311
struct cper_mem_err_compact cmem;
311312

313+
/* Don't trust UEFI 2.1/2.2 structure with bad validation bits */
314+
if (len == sizeof(struct cper_sec_mem_err_old) &&
315+
(mem->validation_bits & ~(CPER_MEM_VALID_RANK_NUMBER - 1))) {
316+
pr_err(FW_WARN "valid bits set for fields beyond structure\n");
317+
return;
318+
}
312319
if (mem->validation_bits & CPER_MEM_VALID_ERROR_STATUS)
313320
printk("%s""error_status: 0x%016llx\n", pfx, mem->error_status);
314321
if (mem->validation_bits & CPER_MEM_VALID_PA)
@@ -405,8 +412,10 @@ static void cper_estatus_print_section(
405412
} else if (!uuid_le_cmp(*sec_type, CPER_SEC_PLATFORM_MEM)) {
406413
struct cper_sec_mem_err *mem_err = (void *)(gdata + 1);
407414
printk("%s""section_type: memory error\n", newpfx);
408-
if (gdata->error_data_length >= sizeof(*mem_err))
409-
cper_print_mem(newpfx, mem_err);
415+
if (gdata->error_data_length >=
416+
sizeof(struct cper_sec_mem_err_old))
417+
cper_print_mem(newpfx, mem_err,
418+
gdata->error_data_length);
410419
else
411420
goto err_section_too_small;
412421
} else if (!uuid_le_cmp(*sec_type, CPER_SEC_PCIE)) {

drivers/infiniband/hw/ipath/ipath_driver.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* SOFTWARE.
3232
*/
3333

34+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
35+
3436
#include <linux/sched.h>
3537
#include <linux/spinlock.h>
3638
#include <linux/idr.h>
@@ -399,8 +401,8 @@ static int ipath_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
399401
u32 bar0 = 0, bar1 = 0;
400402

401403
#ifdef CONFIG_X86_64
402-
if (WARN(pat_enabled(),
403-
"ipath needs PAT disabled, boot with nopat kernel parameter\n")) {
404+
if (pat_enabled()) {
405+
pr_warn("ipath needs PAT disabled, boot with nopat kernel parameter\n");
404406
ret = -ENODEV;
405407
goto bail;
406408
}

drivers/media/pci/ivtv/ivtvfb.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3939
*/
4040

41+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
42+
4143
#include <linux/module.h>
4244
#include <linux/kernel.h>
4345
#include <linux/fb.h>
@@ -1171,6 +1173,13 @@ static int ivtvfb_init_card(struct ivtv *itv)
11711173
{
11721174
int rc;
11731175

1176+
#ifdef CONFIG_X86_64
1177+
if (pat_enabled()) {
1178+
pr_warn("ivtvfb needs PAT disabled, boot with nopat kernel parameter\n");
1179+
return -ENODEV;
1180+
}
1181+
#endif
1182+
11741183
if (itv->osd_info) {
11751184
IVTVFB_ERR("Card %d already initialised\n", ivtvfb_card_id);
11761185
return -EBUSY;
@@ -1265,12 +1274,6 @@ static int __init ivtvfb_init(void)
12651274
int registered = 0;
12661275
int err;
12671276

1268-
#ifdef CONFIG_X86_64
1269-
if (WARN(pat_enabled(),
1270-
"ivtvfb needs PAT disabled, boot with nopat kernel parameter\n")) {
1271-
return -ENODEV;
1272-
}
1273-
#endif
12741277

12751278
if (ivtvfb_card_id < -1 || ivtvfb_card_id >= IVTV_MAX_CARDS) {
12761279
printk(KERN_ERR "ivtvfb: ivtvfb_card_id parameter is out of range (valid range: -1 - %d)\n",

include/linux/cper.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,27 @@ struct cper_ia_proc_ctx {
340340
__u64 mm_reg_addr;
341341
};
342342

343-
/* Memory Error Section */
343+
/* Old Memory Error Section UEFI 2.1, 2.2 */
344+
struct cper_sec_mem_err_old {
345+
__u64 validation_bits;
346+
__u64 error_status;
347+
__u64 physical_addr;
348+
__u64 physical_addr_mask;
349+
__u16 node;
350+
__u16 card;
351+
__u16 module;
352+
__u16 bank;
353+
__u16 device;
354+
__u16 row;
355+
__u16 column;
356+
__u16 bit_pos;
357+
__u64 requestor_id;
358+
__u64 responder_id;
359+
__u64 target_id;
360+
__u8 error_type;
361+
};
362+
363+
/* Memory Error Section UEFI >= 2.3 */
344364
struct cper_sec_mem_err {
345365
__u64 validation_bits;
346366
__u64 error_status;

kernel/resource.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,13 @@ int region_is_ram(resource_size_t start, unsigned long size)
504504
{
505505
struct resource *p;
506506
resource_size_t end = start + size - 1;
507-
int flags = IORESOURCE_MEM | IORESOURCE_BUSY;
507+
unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY;
508508
const char *name = "System RAM";
509509
int ret = -1;
510510

511511
read_lock(&resource_lock);
512512
for (p = iomem_resource.child; p ; p = p->sibling) {
513-
if (end < p->start)
513+
if (p->end < start)
514514
continue;
515515

516516
if (p->start <= start && end <= p->end) {
@@ -521,7 +521,7 @@ int region_is_ram(resource_size_t start, unsigned long size)
521521
ret = 1;
522522
break;
523523
}
524-
if (p->end < start)
524+
if (end < p->start)
525525
break; /* not found */
526526
}
527527
read_unlock(&resource_lock);

0 commit comments

Comments
 (0)