[GIT pull] x86 fixes for 4.13

2017-09-03 Thread Thomas Gleixner
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

This update contains:

 - Expand the space for uncompressing as the LZ4 worst case does not fit
   into the currently reserved space.

 - Validate boot parameters more strictly to prevent out of bound access in
   the decompressor/boot code.

 - Fix off by one errors in get_segment_base().

Thanks,

tglx

-->
Dan Carpenter (1):
  x86/ldt: Fix off by one in get_segment_base()

Jan H. Schönherr (2):
  x86/boot: Provide more slack space during decompression
  x86/boot: Prevent faulty bootparams.screeninfo from causing harm


 arch/x86/boot/compressed/misc.c | 3 +--
 arch/x86/boot/header.S  | 8 +++-
 arch/x86/events/core.c  | 7 ++-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index a0838ab929f2..c14217cd0155 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -116,8 +116,7 @@ void __putstr(const char *s)
}
}
 
-   if (boot_params->screen_info.orig_video_mode == 0 &&
-   lines == 0 && cols == 0)
+   if (lines == 0 || cols == 0)
return;
 
x = boot_params->screen_info.orig_x;
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 2ed8f0c25def..1bb08ecffd24 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -520,8 +520,14 @@ pref_address:  .quad LOAD_PHYSICAL_ADDR
# preferred load addr
 # the description in lib/decompressor_xxx.c for specific information.
 #
 # extra_bytes = (uncompressed_size >> 12) + 65536 + 128
+#
+# LZ4 is even worse: data that cannot be further compressed grows by 0.4%,
+# or one byte per 256 bytes. OTOH, we can safely get rid of the +128 as
+# the size-dependent part now grows so fast.
+#
+# extra_bytes = (uncompressed_size >> 8) + 65536
 
-#define ZO_z_extra_bytes   ((ZO_z_output_len >> 12) + 65536 + 128)
+#define ZO_z_extra_bytes   ((ZO_z_output_len >> 8) + 65536)
 #if ZO_z_output_len > ZO_z_input_len
 # define ZO_z_extract_offset   (ZO_z_output_len + ZO_z_extra_bytes - \
 ZO_z_input_len)
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
index af12e294caed..939050169d12 100644
--- a/arch/x86/events/core.c
+++ b/arch/x86/events/core.c
@@ -2335,12 +2335,9 @@ static unsigned long get_segment_base(unsigned int 
segment)
 #ifdef CONFIG_MODIFY_LDT_SYSCALL
struct ldt_struct *ldt;
 
-   if (idx > LDT_ENTRIES)
-   return 0;
-
/* IRQs are off, so this synchronizes with smp_store_release */
ldt = lockless_dereference(current->active_mm->context.ldt);
-   if (!ldt || idx > ldt->nr_entries)
+   if (!ldt || idx >= ldt->nr_entries)
return 0;
 
desc = &ldt->entries[idx];
@@ -2348,7 +2345,7 @@ static unsigned long get_segment_base(unsigned int 
segment)
return 0;
 #endif
} else {
-   if (idx > GDT_ENTRIES)
+   if (idx >= GDT_ENTRIES)
return 0;
 
desc = raw_cpu_ptr(gdt_page.gdt) + idx;

[GIT pull] x86 fixes for 4.13

2017-08-20 Thread Thomas Gleixner
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

Another pile of small fixes and updates for x86:

 - Plug a hole in the SMAP implementation which misses to clear AC on NMI
   entry

 - Fix the norandmaps/ADDR_NO_RANDOMIZE logic so the command line parameter
   works correctly again

 - Use the proper accessor in the startup64 code for next_early_pgt to
   prevent accessing of invalid addresses and faulting in the early boot
   code.

 - Prevent CPU hotplug lock recursion in the MTRR code

 - Unbreak CPU0 hotplugging

 - Rename overly long CPUID bits which got introduced in this cycle

 - Two commits which mark data 'const' and restrict the scope of data and
   functions to file scope by making them 'static'.


Thanks,

tglx

-->
Alexander Potapenko (1):
  x86/boot/64/clang: Use fixup_pointer() to access 'next_early_pgt'

Andy Lutomirski (1):
  x86/asm/64: Clear AC on NMI entries

Arvind Yadav (1):
  x86: Constify attribute_group structures

Borislav Petkov (1):
  x86/cpufeature, kvm/svm: Rename (shorten) the new "virtualized 
VMSAVE/VMLOAD" CPUID flag

Colin Ian King (1):
  x86: Mark various structures and functions as 'static'

Oleg Nesterov (2):
  x86: Fix norandmaps/ADDR_NO_RANDOMIZE
  x86/elf: Remove the unnecessary ADDR_NO_RANDOMIZE checks

Thomas Gleixner (1):
  x86/mtrr: Prevent CPU hotplug lock recursion

Vitaly Kuznetsov (1):
  x86/smpboot: Unbreak CPU0 hotplug


 arch/x86/entry/entry_64.S|  2 ++
 arch/x86/events/intel/bts.c  |  2 +-
 arch/x86/events/intel/p4.c   |  2 +-
 arch/x86/events/intel/rapl.c |  2 +-
 arch/x86/events/intel/uncore.c   |  2 +-
 arch/x86/events/intel/uncore_nhmex.c | 12 -
 arch/x86/events/intel/uncore_snb.c   |  6 ++---
 arch/x86/events/intel/uncore_snbep.c | 42 
 arch/x86/include/asm/cpufeatures.h   |  2 +-
 arch/x86/kernel/cpu/mcheck/therm_throt.c |  2 +-
 arch/x86/kernel/cpu/microcode/core.c |  4 +--
 arch/x86/kernel/cpu/mtrr/main.c  | 18 +++---
 arch/x86/kernel/head64.c |  7 +++---
 arch/x86/kernel/ksysfs.c |  4 +--
 arch/x86/kernel/smpboot.c| 30 +--
 arch/x86/kvm/svm.c   |  2 +-
 arch/x86/mm/mmap.c   |  7 +++---
 arch/x86/platform/uv/tlb_uv.c|  4 +--
 fs/binfmt_elf.c  |  3 +--
 19 files changed, 85 insertions(+), 68 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index d271fb79248f..6d078b89a5e8 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -1211,6 +1211,8 @@ ENTRY(nmi)
 * other IST entries.
 */
 
+   ASM_CLAC
+
/* Use %rdx as our temp variable throughout */
pushq   %rdx
 
diff --git a/arch/x86/events/intel/bts.c b/arch/x86/events/intel/bts.c
index 8ae8c5ce3a1f..ddd8d3516bfc 100644
--- a/arch/x86/events/intel/bts.c
+++ b/arch/x86/events/intel/bts.c
@@ -69,7 +69,7 @@ struct bts_buffer {
struct bts_phys buf[0];
 };
 
-struct pmu bts_pmu;
+static struct pmu bts_pmu;
 
 static size_t buf_size(struct page *page)
 {
diff --git a/arch/x86/events/intel/p4.c b/arch/x86/events/intel/p4.c
index eb0533558c2b..d32c0eed38ca 100644
--- a/arch/x86/events/intel/p4.c
+++ b/arch/x86/events/intel/p4.c
@@ -587,7 +587,7 @@ static __initconst const u64 p4_hw_cache_event_ids
  * P4_CONFIG_ALIASABLE or bits for P4_PEBS_METRIC, they are
  * either up to date automatically or not applicable at all.
  */
-struct p4_event_alias {
+static struct p4_event_alias {
u64 original;
u64 alternative;
 } p4_event_aliases[] = {
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index a45e2114a846..8e2457cb6b4a 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -559,7 +559,7 @@ static struct attribute_group rapl_pmu_format_group = {
.attrs = rapl_formats_attr,
 };
 
-const struct attribute_group *rapl_attr_groups[] = {
+static const struct attribute_group *rapl_attr_groups[] = {
&rapl_pmu_attr_group,
&rapl_pmu_format_group,
&rapl_pmu_events_group,
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
index 44ec523287f6..1c5390f1cf09 100644
--- a/arch/x86/events/intel/uncore.c
+++ b/arch/x86/events/intel/uncore.c
@@ -721,7 +721,7 @@ static struct attribute *uncore_pmu_attrs[] = {
NULL,
 };
 
-static struct attribute_group uncore_pmu_attr_group = {
+static const struct attribute_group uncore_pmu_attr_group = {
.attrs = uncore_pmu_attrs,
 };
 
diff --git a/arch/x86/events/intel/uncore_nhmex.c 
b/arch/x86/events/intel/uncore_nhmex.c
index cda569332005..6a5cbe90f859 100644
--- a/arch/x86/events/intel/uncore_nhmex.c
+++ b/arch/x86/events/intel

[GIT pull] x86 fixes for 4.13

2017-07-30 Thread Thomas Gleixner
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

A small set of x86 fixes:

  - Prevent the kernel from using the EFI reboot method when EFI is
disabled.

  - Two patches addressing clang issues
  

Thanks,

tglx

-->
Matthias Kaehlcke (1):
  x86/boot: Disable the address-of-packed-member compiler warning

Michael Davidson (1):
  x86/boot: #undef memcpy() et al in string.c

Stefan Assmann (1):
  x86/efi: Fix reboot_mode when EFI runtime services are disabled


 arch/x86/boot/compressed/Makefile | 1 +
 arch/x86/boot/string.c| 9 +
 arch/x86/kernel/reboot.c  | 6 +++---
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/Makefile 
b/arch/x86/boot/compressed/Makefile
index 2c860ad4fe06..8a958274b54c 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -34,6 +34,7 @@ KBUILD_CFLAGS += $(cflags-y)
 KBUILD_CFLAGS += -mno-mmx -mno-sse
 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
 
 KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
 GCOV_PROFILE := n
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 630e3664906b..16f49123d747 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -16,6 +16,15 @@
 #include "ctype.h"
 #include "string.h"
 
+/*
+ * Undef these macros so that the functions that we provide
+ * here will have the correct names regardless of how string.h
+ * may have chosen to #define them.
+ */
+#undef memcpy
+#undef memset
+#undef memcmp
+
 int memcmp(const void *s1, const void *s2, size_t len)
 {
bool diff;
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 67393fc88353..a56bf6051f4e 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -471,12 +471,12 @@ static int __init reboot_init(void)
 
/*
 * The DMI quirks table takes precedence. If no quirks entry
-* matches and the ACPI Hardware Reduced bit is set, force EFI
-* reboot.
+* matches and the ACPI Hardware Reduced bit is set and EFI
+* runtime services are enabled, force EFI reboot.
 */
rv = dmi_check_system(reboot_dmi_table);
 
-   if (!rv && efi_reboot_required())
+   if (!rv && efi_reboot_required() && !efi_runtime_disabled())
reboot_type = BOOT_EFI;
 
return 0;