Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Will Deacon:
"Unfortunately, we still have a number of outstanding issues so there
will be more fixes to come, but this lot are a good start.

- Fix handling of watchpoints triggered by uaccess routines

- Fix initialisation of gigantic pages for CMA buffers

- Raise minimum clang version for BTI to avoid miscompilation

- Fix data race in SVE vector length configuration code

- Ensure address tags are ignored in kern_addr_valid()

- Dump register state on fatal BTI exception

- kexec_file() cleanup to use struct_size() macro"

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
arm64: hw_breakpoint: Don't invoke overflow handler on uaccess watchpoints
arm64: kexec_file: Use struct_size() in kmalloc()
arm64: mm: reserve hugetlb CMA after numa_init
arm64: bti: Require clang >= 10.0.1 for in-kernel BTI support
arm64: sve: Fix build failure when ARM64_SVE=y and SYSCTL=n
arm64: pgtable: Clear the GP bit for non-executable kernel pages
arm64: mm: reset address tag set by kasan sw tagging
arm64: traps: Dump registers prior to panic() in bad_mode()
arm64/sve: Eliminate data races on sve_default_vl
docs/arm64: Fix typo'd #define in sve.rst
arm64: remove TEXT_OFFSET randomization

+66 -60
+3 -3
Documentation/arm64/sve.rst
··· 186 186 187 187 flags: 188 188 189 - PR_SVE_SET_VL_INHERIT 189 + PR_SVE_VL_INHERIT 190 190 191 191 Inherit the current vector length across execve(). Otherwise, the 192 192 vector length is reset to the system default at execve(). (See ··· 247 247 248 248 The following flag may be OR-ed into the result: 249 249 250 - PR_SVE_SET_VL_INHERIT 250 + PR_SVE_VL_INHERIT 251 251 252 252 Vector length will be inherited across execve(). 253 253 ··· 393 393 * At every execve() call, the new vector length of the new process is set to 394 394 the system default vector length, unless 395 395 396 - * PR_SVE_SET_VL_INHERIT (or equivalently SVE_PT_VL_INHERIT) is set for the 396 + * PR_SVE_VL_INHERIT (or equivalently SVE_PT_VL_INHERIT) is set for the 397 397 calling thread, or 398 398 399 399 * a deferred vector length change is pending, established via the
+2
arch/arm64/Kconfig
··· 1630 1630 depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI 1631 1631 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697 1632 1632 depends on !CC_IS_GCC || GCC_VERSION >= 100100 1633 + # https://reviews.llvm.org/rGb8ae3fdfa579dbf366b1bb1cbfdbf8c51db7fa55 1634 + depends on !CC_IS_CLANG || CLANG_VERSION >= 100001 1633 1635 depends on !(CC_IS_CLANG && GCOV_KERNEL) 1634 1636 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) 1635 1637 help
-15
arch/arm64/Kconfig.debug
··· 8 8 instructions during context switch. Say Y here only if you are 9 9 planning to use hardware trace tools with this kernel. 10 10 11 - config ARM64_RANDOMIZE_TEXT_OFFSET 12 - bool "Randomize TEXT_OFFSET at build time" 13 - help 14 - Say Y here if you want the image load offset (AKA TEXT_OFFSET) 15 - of the kernel to be randomized at build-time. When selected, 16 - this option will cause TEXT_OFFSET to be randomized upon any 17 - build of the kernel, and the offset will be reflected in the 18 - text_offset field of the resulting Image. This can be used to 19 - fuzz-test bootloaders which respect text_offset. 20 - 21 - This option is intended for bootloader and/or kernel testing 22 - only. Bootloaders must make no assumptions regarding the value 23 - of TEXT_OFFSET and platforms must not require a specific 24 - value. 25 - 26 11 config DEBUG_EFI 27 12 depends on EFI && DEBUG_INFO 28 13 bool "UEFI debugging"
-6
arch/arm64/Makefile
··· 121 121 head-y := arch/arm64/kernel/head.o 122 122 123 123 # The byte offset of the kernel image in RAM from the start of RAM. 124 - ifeq ($(CONFIG_ARM64_RANDOMIZE_TEXT_OFFSET), y) 125 - TEXT_OFFSET := $(shell awk "BEGIN {srand(); printf \"0x%06x\n\", \ 126 - int(2 * 1024 * 1024 / (2 ^ $(CONFIG_ARM64_PAGE_SHIFT)) * \ 127 - rand()) * (2 ^ $(CONFIG_ARM64_PAGE_SHIFT))}") 128 - else 129 124 TEXT_OFFSET := 0x0 130 - endif 131 125 132 126 ifeq ($(CONFIG_KASAN_SW_TAGS), y) 133 127 KASAN_SHADOW_SCALE_SHIFT := 4
+1 -1
arch/arm64/include/asm/pgtable.h
··· 416 416 __pgprot((pgprot_val(prot) & ~(mask)) | (bits)) 417 417 418 418 #define pgprot_nx(prot) \ 419 - __pgprot_modify(prot, 0, PTE_PXN) 419 + __pgprot_modify(prot, PTE_MAYBE_GP, PTE_PXN) 420 420 421 421 /* 422 422 * Mark the prot value as uncacheable and unbufferable.
+21 -10
arch/arm64/kernel/fpsimd.c
··· 12 12 #include <linux/bug.h> 13 13 #include <linux/cache.h> 14 14 #include <linux/compat.h> 15 + #include <linux/compiler.h> 15 16 #include <linux/cpu.h> 16 17 #include <linux/cpu_pm.h> 17 18 #include <linux/kernel.h> ··· 120 119 static DEFINE_PER_CPU(struct fpsimd_last_state_struct, fpsimd_last_state); 121 120 122 121 /* Default VL for tasks that don't set it explicitly: */ 123 - static int sve_default_vl = -1; 122 + static int __sve_default_vl = -1; 123 + 124 + static int get_sve_default_vl(void) 125 + { 126 + return READ_ONCE(__sve_default_vl); 127 + } 124 128 125 129 #ifdef CONFIG_ARM64_SVE 130 + 131 + static void set_sve_default_vl(int val) 132 + { 133 + WRITE_ONCE(__sve_default_vl, val); 134 + } 126 135 127 136 /* Maximum supported vector length across all CPUs (initially poisoned) */ 128 137 int __ro_after_init sve_max_vl = SVE_VL_MIN; ··· 349 338 return sve_vl_from_vq(__bit_to_vq(bit)); 350 339 } 351 340 352 - #ifdef CONFIG_SYSCTL 341 + #if defined(CONFIG_ARM64_SVE) && defined(CONFIG_SYSCTL) 353 342 354 343 static int sve_proc_do_default_vl(struct ctl_table *table, int write, 355 344 void *buffer, size_t *lenp, loff_t *ppos) 356 345 { 357 346 int ret; 358 - int vl = sve_default_vl; 347 + int vl = get_sve_default_vl(); 359 348 struct ctl_table tmp_table = { 360 349 .data = &vl, 361 350 .maxlen = sizeof(vl), ··· 372 361 if (!sve_vl_valid(vl)) 373 362 return -EINVAL; 374 363 375 - sve_default_vl = find_supported_vector_length(vl); 364 + set_sve_default_vl(find_supported_vector_length(vl)); 376 365 return 0; 377 366 } 378 367 ··· 394 383 return 0; 395 384 } 396 385 397 - #else /* ! CONFIG_SYSCTL */ 386 + #else /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */ 398 387 static int __init sve_sysctl_init(void) { return 0; } 399 - #endif /* ! CONFIG_SYSCTL */ 388 + #endif /* ! (CONFIG_ARM64_SVE && CONFIG_SYSCTL) */ 400 389 401 390 #define ZREG(sve_state, vq, n) ((char *)(sve_state) + \ 402 391 (SVE_SIG_ZREG_OFFSET(vq, n) - SVE_SIG_REGS_OFFSET)) ··· 879 868 * For the default VL, pick the maximum supported value <= 64. 880 869 * VL == 64 is guaranteed not to grow the signal frame. 881 870 */ 882 - sve_default_vl = find_supported_vector_length(64); 871 + set_sve_default_vl(find_supported_vector_length(64)); 883 872 884 873 bitmap_andnot(tmp_map, sve_vq_partial_map, sve_vq_map, 885 874 SVE_VQ_MAX); ··· 900 889 pr_info("SVE: maximum available vector length %u bytes per vector\n", 901 890 sve_max_vl); 902 891 pr_info("SVE: default vector length %u bytes per vector\n", 903 - sve_default_vl); 892 + get_sve_default_vl()); 904 893 905 894 /* KVM decides whether to support mismatched systems. Just warn here: */ 906 895 if (sve_max_virtualisable_vl < sve_max_vl) ··· 1040 1029 * vector length configured: no kernel task can become a user 1041 1030 * task without an exec and hence a call to this function. 1042 1031 * By the time the first call to this function is made, all 1043 - * early hardware probing is complete, so sve_default_vl 1032 + * early hardware probing is complete, so __sve_default_vl 1044 1033 * should be valid. 1045 1034 * If a bug causes this to go wrong, we make some noise and 1046 1035 * try to fudge thread.sve_vl to a safe value here. 1047 1036 */ 1048 1037 vl = current->thread.sve_vl_onexec ? 1049 - current->thread.sve_vl_onexec : sve_default_vl; 1038 + current->thread.sve_vl_onexec : get_sve_default_vl(); 1050 1039 1051 1040 if (WARN_ON(!sve_vl_valid(vl))) 1052 1041 vl = SVE_VL_MIN;
+26 -18
arch/arm64/kernel/hw_breakpoint.c
··· 730 730 return 0; 731 731 } 732 732 733 + static int watchpoint_report(struct perf_event *wp, unsigned long addr, 734 + struct pt_regs *regs) 735 + { 736 + int step = is_default_overflow_handler(wp); 737 + struct arch_hw_breakpoint *info = counter_arch_bp(wp); 738 + 739 + info->trigger = addr; 740 + 741 + /* 742 + * If we triggered a user watchpoint from a uaccess routine, then 743 + * handle the stepping ourselves since userspace really can't help 744 + * us with this. 745 + */ 746 + if (!user_mode(regs) && info->ctrl.privilege == AARCH64_BREAKPOINT_EL0) 747 + step = 1; 748 + else 749 + perf_bp_event(wp, regs); 750 + 751 + return step; 752 + } 753 + 733 754 static int watchpoint_handler(unsigned long addr, unsigned int esr, 734 755 struct pt_regs *regs) 735 756 { ··· 760 739 u64 val; 761 740 struct perf_event *wp, **slots; 762 741 struct debug_info *debug_info; 763 - struct arch_hw_breakpoint *info; 764 742 struct arch_hw_breakpoint_ctrl ctrl; 765 743 766 744 slots = this_cpu_ptr(wp_on_reg); ··· 797 777 if (dist != 0) 798 778 continue; 799 779 800 - info = counter_arch_bp(wp); 801 - info->trigger = addr; 802 - perf_bp_event(wp, regs); 803 - 804 - /* Do we need to handle the stepping? */ 805 - if (is_default_overflow_handler(wp)) 806 - step = 1; 780 + step = watchpoint_report(wp, addr, regs); 807 781 } 808 - if (min_dist > 0 && min_dist != -1) { 809 - /* No exact match found. */ 810 - wp = slots[closest_match]; 811 - info = counter_arch_bp(wp); 812 - info->trigger = addr; 813 - perf_bp_event(wp, regs); 814 782 815 - /* Do we need to handle the stepping? */ 816 - if (is_default_overflow_handler(wp)) 817 - step = 1; 818 - } 783 + /* No exact match found? */ 784 + if (min_dist > 0 && min_dist != -1) 785 + step = watchpoint_report(slots[closest_match], addr, regs); 786 + 819 787 rcu_read_unlock(); 820 788 821 789 if (!step)
+1 -2
arch/arm64/kernel/machine_kexec_file.c
··· 219 219 MEMBLOCK_NONE, &start, &end, NULL) 220 220 nr_ranges++; 221 221 222 - cmem = kmalloc(sizeof(struct crash_mem) + 223 - sizeof(struct crash_mem_range) * nr_ranges, GFP_KERNEL); 222 + cmem = kmalloc(struct_size(cmem, ranges, nr_ranges), GFP_KERNEL); 224 223 if (!cmem) 225 224 return -ENOMEM; 226 225
+1
arch/arm64/kernel/traps.c
··· 813 813 handler[reason], smp_processor_id(), esr, 814 814 esr_get_class_string(esr)); 815 815 816 + __show_regs(regs); 816 817 local_daif_mask(); 817 818 panic("bad mode"); 818 819 }
+10 -5
arch/arm64/mm/init.c
··· 404 404 high_memory = __va(memblock_end_of_DRAM() - 1) + 1; 405 405 406 406 dma_contiguous_reserve(arm64_dma32_phys_limit); 407 - 408 - #ifdef CONFIG_ARM64_4K_PAGES 409 - hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); 410 - #endif 411 - 412 407 } 413 408 414 409 void __init bootmem_init(void) ··· 419 424 min_low_pfn = min; 420 425 421 426 arm64_numa_init(); 427 + 428 + /* 429 + * must be done after arm64_numa_init() which calls numa_init() to 430 + * initialize node_online_map that gets used in hugetlb_cma_reserve() 431 + * while allocating required CMA size across online nodes. 432 + */ 433 + #ifdef CONFIG_ARM64_4K_PAGES 434 + hugetlb_cma_reserve(PUD_SHIFT - PAGE_SHIFT); 435 + #endif 436 + 422 437 /* 423 438 * Sparsemem tries to allocate bootmem in memory_present(), so must be 424 439 * done after the fixed reservations.
+1
arch/arm64/mm/mmu.c
··· 723 723 pmd_t *pmdp, pmd; 724 724 pte_t *ptep, pte; 725 725 726 + addr = arch_kasan_reset_tag(addr); 726 727 if ((((long)addr) >> VA_BITS) != -1UL) 727 728 return 0; 728 729