From: Greg Kroah-Hartman Date: Fri, 3 Oct 2014 03:10:56 +0000 (-0700) Subject: 3.10-stable patches X-Git-Tag: v3.16.4~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7938da80c76455907154c0ec0ce77cb03a650a6;p=thirdparty%2Fkernel%2Fstable-queue.git 3.10-stable patches added patches: kvm-x86-handle-idiv-overflow-at-kvm_write_tsc.patch regmap-fix-handling-of-volatile-registers-for-format_write-chips.patch shmem-fix-nlink-for-rename-overwrite-directory.patch x86-early_ioremap-increase-fix_btmaps_slots-to-8.patch --- diff --git a/queue-3.10/kvm-x86-handle-idiv-overflow-at-kvm_write_tsc.patch b/queue-3.10/kvm-x86-handle-idiv-overflow-at-kvm_write_tsc.patch new file mode 100644 index 00000000000..1732a1b414a --- /dev/null +++ b/queue-3.10/kvm-x86-handle-idiv-overflow-at-kvm_write_tsc.patch @@ -0,0 +1,71 @@ +From 8915aa27d5efbb9185357175b0acf884325565f9 Mon Sep 17 00:00:00 2001 +From: Marcelo Tosatti +Date: Tue, 11 Jun 2013 23:31:12 -0300 +Subject: KVM: x86: handle idiv overflow at kvm_write_tsc + +From: Marcelo Tosatti + +commit 8915aa27d5efbb9185357175b0acf884325565f9 upstream. + +Its possible that idivl overflows (due to large delta stored in usdiff, +valid scenario). + +Create an exception handler to catch the overflow exception (division by zero +is protected by vcpu->arch.virtual_tsc_khz check), and interpret it accordingly +(delta is larger than USEC_PER_SEC). + +Fixes https://bugzilla.redhat.com/show_bug.cgi?id=969644 + +Signed-off-by: Marcelo Tosatti +Signed-off-by: Gleb Natapov +Signed-off-by: Philipp Hahn +Tested-by: Philipp Hahn +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/kvm/x86.c | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -1196,20 +1196,37 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu + elapsed = ns - kvm->arch.last_tsc_nsec; + + if (vcpu->arch.virtual_tsc_khz) { ++ int faulted = 0; ++ + /* n.b - signed multiplication and division required */ + usdiff = data - kvm->arch.last_tsc_write; + #ifdef CONFIG_X86_64 + usdiff = (usdiff * 1000) / vcpu->arch.virtual_tsc_khz; + #else + /* do_div() only does unsigned */ +- asm("idivl %2; xor %%edx, %%edx" +- : "=A"(usdiff) +- : "A"(usdiff * 1000), "rm"(vcpu->arch.virtual_tsc_khz)); ++ asm("1: idivl %[divisor]\n" ++ "2: xor %%edx, %%edx\n" ++ " movl $0, %[faulted]\n" ++ "3:\n" ++ ".section .fixup,\"ax\"\n" ++ "4: movl $1, %[faulted]\n" ++ " jmp 3b\n" ++ ".previous\n" ++ ++ _ASM_EXTABLE(1b, 4b) ++ ++ : "=A"(usdiff), [faulted] "=r" (faulted) ++ : "A"(usdiff * 1000), [divisor] "rm"(vcpu->arch.virtual_tsc_khz)); ++ + #endif + do_div(elapsed, 1000); + usdiff -= elapsed; + if (usdiff < 0) + usdiff = -usdiff; ++ ++ /* idivl overflow => difference is larger than USEC_PER_SEC */ ++ if (faulted) ++ usdiff = USEC_PER_SEC; + } else + usdiff = USEC_PER_SEC; /* disable TSC match window below */ + diff --git a/queue-3.10/regmap-fix-handling-of-volatile-registers-for-format_write-chips.patch b/queue-3.10/regmap-fix-handling-of-volatile-registers-for-format_write-chips.patch new file mode 100644 index 00000000000..caa42bcd5a0 --- /dev/null +++ b/queue-3.10/regmap-fix-handling-of-volatile-registers-for-format_write-chips.patch @@ -0,0 +1,39 @@ +From 5844a8b9d98ec11ce1d77610daacf3f0a0e14715 Mon Sep 17 00:00:00 2001 +From: Mark Brown +Date: Tue, 26 Aug 2014 12:12:17 +0100 +Subject: regmap: Fix handling of volatile registers for format_write() chips + +From: Mark Brown + +commit 5844a8b9d98ec11ce1d77610daacf3f0a0e14715 upstream. + +A previous over-zealous factorisation of code means that we only treat +registers as volatile if they are readable. For most devices this is fine +since normally most registers can be read and volatility implies +readability but for format_write() devices where there is no readback from +the hardware and we use volatility to mean simply uncacheability this means +that we end up treating all registers as cacheble. + +A bigger refactoring of the code to clarify this is in order but as a fix +make a minimal change and only check readability when checking volatility +if there is no format_write() operation defined for the device. + +Signed-off-by: Mark Brown +Tested-by: Lars-Peter Clausen +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/base/regmap/regmap.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/base/regmap/regmap.c ++++ b/drivers/base/regmap/regmap.c +@@ -114,7 +114,7 @@ bool regmap_readable(struct regmap *map, + + bool regmap_volatile(struct regmap *map, unsigned int reg) + { +- if (!regmap_readable(map, reg)) ++ if (!map->format.format_write && !regmap_readable(map, reg)) + return false; + + if (map->volatile_reg) diff --git a/queue-3.10/series b/queue-3.10/series index c853ea50d2e..35c22f46f7e 100644 --- a/queue-3.10/series +++ b/queue-3.10/series @@ -68,3 +68,7 @@ arm-8165-1-alignment-don-t-break-misaligned-neon-load-store.patch mips-zboot-add-missing-linux-string.h-include.patch mips-mcount-adjust-stack-pointer-for-static-trace-in-mips32.patch acpica-update-to-gpio-region-handler-interface.patch +regmap-fix-handling-of-volatile-registers-for-format_write-chips.patch +kvm-x86-handle-idiv-overflow-at-kvm_write_tsc.patch +x86-early_ioremap-increase-fix_btmaps_slots-to-8.patch +shmem-fix-nlink-for-rename-overwrite-directory.patch diff --git a/queue-3.10/shmem-fix-nlink-for-rename-overwrite-directory.patch b/queue-3.10/shmem-fix-nlink-for-rename-overwrite-directory.patch new file mode 100644 index 00000000000..aaa28d6399a --- /dev/null +++ b/queue-3.10/shmem-fix-nlink-for-rename-overwrite-directory.patch @@ -0,0 +1,77 @@ +From b928095b0a7cff7fb9fcf4c706348ceb8ab2c295 Mon Sep 17 00:00:00 2001 +From: Miklos Szeredi +Date: Wed, 24 Sep 2014 17:56:17 +0200 +Subject: shmem: fix nlink for rename overwrite directory + +From: Miklos Szeredi + +commit b928095b0a7cff7fb9fcf4c706348ceb8ab2c295 upstream. + +If overwriting an empty directory with rename, then need to drop the extra +nlink. + +Test prog: + +#include +#include +#include +#include + +int main(void) +{ + const char *test_dir1 = "test-dir1"; + const char *test_dir2 = "test-dir2"; + int res; + int fd; + struct stat statbuf; + + res = mkdir(test_dir1, 0777); + if (res == -1) + err(1, "mkdir(\"%s\")", test_dir1); + + res = mkdir(test_dir2, 0777); + if (res == -1) + err(1, "mkdir(\"%s\")", test_dir2); + + fd = open(test_dir2, O_RDONLY); + if (fd == -1) + err(1, "open(\"%s\")", test_dir2); + + res = rename(test_dir1, test_dir2); + if (res == -1) + err(1, "rename(\"%s\", \"%s\")", test_dir1, test_dir2); + + res = fstat(fd, &statbuf); + if (res == -1) + err(1, "fstat(%i)", fd); + + if (statbuf.st_nlink != 0) { + fprintf(stderr, "nlink is %lu, should be 0\n", statbuf.st_nlink); + return 1; + } + + return 0; +} + +Signed-off-by: Miklos Szeredi +Signed-off-by: Al Viro +Signed-off-by: Greg Kroah-Hartman + +--- + mm/shmem.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/mm/shmem.c ++++ b/mm/shmem.c +@@ -2128,8 +2128,10 @@ static int shmem_rename(struct inode *ol + + if (new_dentry->d_inode) { + (void) shmem_unlink(new_dir, new_dentry); +- if (they_are_dirs) ++ if (they_are_dirs) { ++ drop_nlink(new_dentry->d_inode); + drop_nlink(old_dir); ++ } + } else if (they_are_dirs) { + drop_nlink(old_dir); + inc_nlink(new_dir); diff --git a/queue-3.10/x86-early_ioremap-increase-fix_btmaps_slots-to-8.patch b/queue-3.10/x86-early_ioremap-increase-fix_btmaps_slots-to-8.patch new file mode 100644 index 00000000000..bffcd1d1d7b --- /dev/null +++ b/queue-3.10/x86-early_ioremap-increase-fix_btmaps_slots-to-8.patch @@ -0,0 +1,109 @@ +From 3eddc69ffeba092d288c386646bfa5ec0fce25fd Mon Sep 17 00:00:00 2001 +From: Dave Young +Date: Tue, 26 Aug 2014 17:06:41 +0800 +Subject: x86 early_ioremap: Increase FIX_BTMAPS_SLOTS to 8 + +From: Dave Young + +commit 3eddc69ffeba092d288c386646bfa5ec0fce25fd upstream. + +3.16 kernel boot fail with earlyprintk=efi, it keeps scrolling at the +bottom line of screen. + +Bisected, the first bad commit is below: +commit 86dfc6f339886559d80ee0d4bd20fe5ee90450f0 +Author: Lv Zheng +Date: Fri Apr 4 12:38:57 2014 +0800 + + ACPICA: Tables: Fix table checksums verification before installation. + +I did some debugging by enabling both serial and efi earlyprintk, below is +some debug dmesg, seems early_ioremap fails in scroll up function due to +no free slot, see below dmesg output: + + WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:116 __early_ioremap+0x90/0x1c4() + __early_ioremap(ed00c800, 00000c80) not found slot + Modules linked in: + CPU: 0 PID: 0 Comm: swapper Not tainted 3.17.0-rc1+ #204 + Hardware name: Hewlett-Packard HP Z420 Workstation/1589, BIOS J61 v03.15 05/09/2013 + Call Trace: + dump_stack+0x4e/0x7a + warn_slowpath_common+0x75/0x8e + ? __early_ioremap+0x90/0x1c4 + warn_slowpath_fmt+0x47/0x49 + __early_ioremap+0x90/0x1c4 + ? sprintf+0x46/0x48 + early_ioremap+0x13/0x15 + early_efi_map+0x24/0x26 + early_efi_scroll_up+0x6d/0xc0 + early_efi_write+0x1b0/0x214 + call_console_drivers.constprop.21+0x73/0x7e + console_unlock+0x151/0x3b2 + ? vprintk_emit+0x49f/0x532 + vprintk_emit+0x521/0x532 + ? console_unlock+0x383/0x3b2 + printk+0x4f/0x51 + acpi_os_vprintf+0x2b/0x2d + acpi_os_printf+0x43/0x45 + acpi_info+0x5c/0x63 + ? __acpi_map_table+0x13/0x18 + ? acpi_os_map_iomem+0x21/0x147 + acpi_tb_print_table_header+0x177/0x186 + acpi_tb_install_table_with_override+0x4b/0x62 + acpi_tb_install_standard_table+0xd9/0x215 + ? early_ioremap+0x13/0x15 + ? __acpi_map_table+0x13/0x18 + acpi_tb_parse_root_table+0x16e/0x1b4 + acpi_initialize_tables+0x57/0x59 + acpi_table_init+0x50/0xce + acpi_boot_table_init+0x1e/0x85 + setup_arch+0x9b7/0xcc4 + start_kernel+0x94/0x42d + ? early_idt_handlers+0x120/0x120 + x86_64_start_reservations+0x2a/0x2c + x86_64_start_kernel+0xf3/0x100 + +Quote reply from Lv.zheng about the early ioremap slot usage in this case: + +""" +In early_efi_scroll_up(), 2 mapping entries will be used for the src/dst screen buffer. +In drivers/acpi/acpica/tbutils.c, we've improved the early table loading code in acpi_tb_parse_root_table(). +We now need 2 mapping entries: +1. One mapping entry is used for RSDT table mapping. Each RSDT entry contains an address for another ACPI table. +2. For each entry in RSDP, we need another mapping entry to map the table to perform necessary check/override before installing it. + +When acpi_tb_parse_root_table() prints something through EFI earlyprintk console, we'll have 4 mapping entries used. +The current 4 slots setting of early_ioremap() seems to be too small for such a use case. +""" + +Thus increase the slot to 8 in this patch to fix this issue. +boot-time mappings become 512 page with this patch. + +Signed-off-by: Dave Young +Signed-off-by: Matt Fleming +Signed-off-by: Greg Kroah-Hartman + +--- + arch/x86/include/asm/fixmap.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/arch/x86/include/asm/fixmap.h ++++ b/arch/x86/include/asm/fixmap.h +@@ -123,14 +123,14 @@ enum fixed_addresses { + __end_of_permanent_fixed_addresses, + + /* +- * 256 temporary boot-time mappings, used by early_ioremap(), ++ * 512 temporary boot-time mappings, used by early_ioremap(), + * before ioremap() is functional. + * +- * If necessary we round it up to the next 256 pages boundary so ++ * If necessary we round it up to the next 512 pages boundary so + * that we can have a single pgd entry and a single pte table: + */ + #define NR_FIX_BTMAPS 64 +-#define FIX_BTMAPS_SLOTS 4 ++#define FIX_BTMAPS_SLOTS 8 + #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) + FIX_BTMAP_END = + (__end_of_permanent_fixed_addresses ^