Linus,
Please pull the latest x86-urgent-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-for-linus
# HEAD: c88d47480d300eaad80c213d50c9bf6077fc49bc x86/fpu: Always restore_xinit_state() when use_eager_cpu()
EFI fixes, and FPU fix, a ticket spinlock boundary condition fix and
two build fixes.
out-of-topic modifications in x86-urgent-for-linus:
-----------------------------------------------------
drivers/firmware/efi/runtime-map.c # d67e199611b9: efi: Fix error handling in a
fs/efivarfs/super.c # c57dcb566d3d: efivarfs: Ensure VariableNam
Thanks,
Ingo
------------------>
Bobby Powers (1):
x86/fpu: Always restore_xinit_state() when use_eager_cpu()
Dan Carpenter (1):
efi: Fix error handling in add_sysfs_runtime_map_entry()
Ingo Molnar (1):
x86/mm: Clean up types in xlate_dev_mem_ptr()
Marc Dionne (1):
x86: Make cpu_tss available to external modules
Ross Lagerwall (1):
efivarfs: Ensure VariableName is NUL-terminated
Roy Franz (1):
x86/efi: Store upper bits of command line buffer address in ext_cmd_line_ptr
Tahsin Erdogan (1):
x86/spinlocks: Fix regression in spinlock contention detection
arch/x86/boot/compressed/eboot.c | 2 ++
arch/x86/include/asm/spinlock.h | 2 +-
arch/x86/kernel/process.c | 14 ++++++++------
arch/x86/mm/ioremap.c | 14 ++++++++------
drivers/firmware/efi/runtime-map.c | 6 +++---
fs/efivarfs/super.c | 2 +-
6 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index ef17683484e9..48304b89b601 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -1109,6 +1109,8 @@ struct boot_params *make_boot_params(struct efi_config *c)
if (!cmdline_ptr)
goto fail;
hdr->cmd_line_ptr = (unsigned long)cmdline_ptr;
+ /* Fill in upper bits of command line address, NOP on 32 bit */
+ boot_params->ext_cmd_line_ptr = (u64)(unsigned long)cmdline_ptr >> 32;
hdr->ramdisk_image = 0;
hdr->ramdisk_size = 0;
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index cf87de3fc390..64b611782ef0 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -169,7 +169,7 @@ static inline int arch_spin_is_contended(arch_spinlock_t *lock)
struct __raw_tickets tmp = READ_ONCE(lock->tickets);
tmp.head &= ~TICKET_SLOWPATH_FLAG;
- return (tmp.tail - tmp.head) > TICKET_LOCK_INC;
+ return (__ticket_t)(tmp.tail - tmp.head) > TICKET_LOCK_INC;
}
#define arch_spin_is_contended arch_spin_is_contended
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 8213da62b1b7..6e338e3b1dc0 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -57,7 +57,7 @@ __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = {
.io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 },
#endif
};
-EXPORT_PER_CPU_SYMBOL_GPL(cpu_tss);
+EXPORT_PER_CPU_SYMBOL(cpu_tss);
#ifdef CONFIG_X86_64
static DEFINE_PER_CPU(unsigned char, is_idle);
@@ -156,11 +156,13 @@ void flush_thread(void)
/* FPU state will be reallocated lazily at the first use. */
drop_fpu(tsk);
free_thread_xstate(tsk);
- } else if (!used_math()) {
- /* kthread execs. TODO: cleanup this horror. */
- if (WARN_ON(init_fpu(tsk)))
- force_sig(SIGKILL, tsk);
- user_fpu_begin();
+ } else {
+ if (!tsk_used_math(tsk)) {
+ /* kthread execs. TODO: cleanup this horror. */
+ if (WARN_ON(init_fpu(tsk)))
+ force_sig(SIGKILL, tsk);
+ user_fpu_begin();
+ }
restore_init_xstate();
}
}
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index fdf617c00e2f..4bf037b20f47 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -332,18 +332,20 @@ EXPORT_SYMBOL(iounmap);
*/
void *xlate_dev_mem_ptr(phys_addr_t phys)
{
- void *addr;
- unsigned long start = phys & PAGE_MASK;
+ unsigned long start = phys & PAGE_MASK;
+ unsigned long offset = phys & ~PAGE_MASK;
+ unsigned long vaddr;
/* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
if (page_is_ram(start >> PAGE_SHIFT))
return __va(phys);
- addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
- if (addr)
- addr = (void *)((unsigned long)addr | (phys & ~PAGE_MASK));
+ vaddr = (unsigned long)ioremap_cache(start, PAGE_SIZE);
+ /* Only add the offset on success and return NULL if the ioremap() failed: */
+ if (vaddr)
+ vaddr += offset;
- return addr;
+ return (void *)vaddr;
}
void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
index 87b8e3b900d2..5c55227a34c8 100644
--- a/drivers/firmware/efi/runtime-map.c
+++ b/drivers/firmware/efi/runtime-map.c
@@ -120,7 +120,8 @@ add_sysfs_runtime_map_entry(struct kobject *kobj, int nr)
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (!entry) {
kset_unregister(map_kset);
- return entry;
+ map_kset = NULL;
+ return ERR_PTR(-ENOMEM);
}
memcpy(&entry->md, efi_runtime_map + nr * efi_memdesc_size,
@@ -132,6 +133,7 @@ add_sysfs_runtime_map_entry(struct kobject *kobj, int nr)
if (ret) {
kobject_put(&entry->kobj);
kset_unregister(map_kset);
+ map_kset = NULL;
return ERR_PTR(ret);
}
@@ -195,8 +197,6 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj)
entry = *(map_entries + j);
kobject_put(&entry->kobj);
}
- if (map_kset)
- kset_unregister(map_kset);
out:
return ret;
}
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index ddbce42548c9..acf9a67f6770 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -121,7 +121,7 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
int len, i;
int err = -ENOMEM;
- entry = kmalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (!entry)
return err;
Ugh, I pulled, but:
On Wed, May 6, 2015 at 5:58 AM, Ingo Molnar <[email protected]> wrote:
>
> Ingo Molnar (1):
> x86/mm: Clean up types in xlate_dev_mem_ptr()
>
> diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
> index fdf617c00e2f..4bf037b20f47 100644
> --- a/arch/x86/mm/ioremap.c
> +++ b/arch/x86/mm/ioremap.c
> @@ -332,18 +332,20 @@ EXPORT_SYMBOL(iounmap);
> */
> void *xlate_dev_mem_ptr(phys_addr_t phys)
> {
> + unsigned long start = phys & PAGE_MASK;
> + unsigned long offset = phys & ~PAGE_MASK;
> + unsigned long vaddr;
That "unsigned long vaddr" is just stupid and not a cleanup.
It causes two pointless casts:
> + vaddr = (unsigned long)ioremap_cache(start, PAGE_SIZE);
> + /* Only add the offset on success and return NULL if the ioremap() failed: */
> + if (vaddr)
> + vaddr += offset;
>
> + return (void *)vaddr;
neither of which is helpful in the least. And the "vaddr += offset"
would work equally well in "void *", gcc is perfectly happy to treat
"void *" arithmetic as byte offsets, it's both documented and already
extensively used in the kernel.
So the cleanup to use "start/offset" is a good cleanup, but you should
have kept "addr" as a pointer.
Linus
* Linus Torvalds <[email protected]> wrote:
> Ugh, I pulled, but:
>
> On Wed, May 6, 2015 at 5:58 AM, Ingo Molnar <[email protected]> wrote:
> >
> > Ingo Molnar (1):
> > x86/mm: Clean up types in xlate_dev_mem_ptr()
> >
> > diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
> > index fdf617c00e2f..4bf037b20f47 100644
> > --- a/arch/x86/mm/ioremap.c
> > +++ b/arch/x86/mm/ioremap.c
> > @@ -332,18 +332,20 @@ EXPORT_SYMBOL(iounmap);
> > */
> > void *xlate_dev_mem_ptr(phys_addr_t phys)
> > {
> > + unsigned long start = phys & PAGE_MASK;
> > + unsigned long offset = phys & ~PAGE_MASK;
> > + unsigned long vaddr;
>
> That "unsigned long vaddr" is just stupid and not a cleanup.
>
> It causes two pointless casts:
>
> > + vaddr = (unsigned long)ioremap_cache(start, PAGE_SIZE);
> > + /* Only add the offset on success and return NULL if the ioremap() failed: */
> > + if (vaddr)
> > + vaddr += offset;
> >
> > + return (void *)vaddr;
>
> neither of which is helpful in the least. And the "vaddr += offset"
> would work equally well in "void *", gcc is perfectly happy to treat
> "void *" arithmetic as byte offsets, it's both documented and
> already extensively used in the kernel.
Yeah, not sure why I didn't notice that, I love void * arithmetics.
> So the cleanup to use "start/offset" is a good cleanup, but you
> should have kept "addr" as a pointer.
Something like the patch below?
Thanks,
Ingo
===================>
>From 562bfca4c80175d1d18eef5c3f4bb8dda53c03e4 Mon Sep 17 00:00:00 2001
From: Ingo Molnar <[email protected]>
Date: Fri, 8 May 2015 12:43:53 +0200
Subject: [PATCH] x86/mm: Clean up types in xlate_dev_mem_ptr() some more
So Linus noticed that in:
94d4b4765b7d ("x86/mm: Clean up types in xlate_dev_mem_ptr()")
... I added two nonsensical casts, due to the poor type choice
for 'vaddr'.
Change it to 'void *' and take advantage of void * arithmetics.
This removes the casts.
( Also remove a nonsensical return line from unxlate_dev_mem_ptr()
while at it. )
Suggested-by: Linus Torvalds <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
arch/x86/mm/ioremap.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 70e7444c6835..27ff21216dfa 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -353,18 +353,18 @@ void *xlate_dev_mem_ptr(phys_addr_t phys)
{
unsigned long start = phys & PAGE_MASK;
unsigned long offset = phys & ~PAGE_MASK;
- unsigned long vaddr;
+ void *vaddr;
/* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
if (page_is_ram(start >> PAGE_SHIFT))
return __va(phys);
- vaddr = (unsigned long)ioremap_cache(start, PAGE_SIZE);
+ vaddr = ioremap_cache(start, PAGE_SIZE);
/* Only add the offset on success and return NULL if the ioremap() failed: */
if (vaddr)
vaddr += offset;
- return (void *)vaddr;
+ return vaddr;
}
void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
@@ -373,7 +373,6 @@ void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
return;
iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
- return;
}
static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;