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 Catalin Marinas:

- enable 48-bit VA space now that KVM has been fixed, together with a
couple of fixes for pgd allocation alignment and initial memblock
current_limit. There is still a dependency on !ARM_SMMU which needs
to be updated as it uses the page table manipulation macros of the
host kernel
- eBPF fixes following changes/conflicts during the merging window
- Compat types affecting compat_elf_prpsinfo
- Compilation error on UP builds
- ASLR fix when /proc/sys/kernel/randomize_va_space == 0
- DT definitions for CLCD support on ARMv8 model platform

* tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux:
arm64: Fix memblock current_limit with 64K pages and 48-bit VA
arm64: ASLR: Don't randomise text when randomise_va_space == 0
arm64: vexpress: Add CLCD support to the ARMv8 model platform
arm64: Fix compilation error on UP builds
Documentation/arm64/memory.txt: fix typo
net: bpf: arm64: minor fix of type in jited
arm64: bpf: add 'load 64-bit immediate' instruction
arm64: bpf: add 'shift by register' instructions
net: bpf: arm64: address randomize and write protect JIT code
arm64: mm: Correct fixmap pagetable types
arm64: compat: fix compat types affecting struct compat_elf_prpsinfo
arm64: Align less than PAGE_SIZE pgds naturally
arm64: Allow 48-bits VA space without ARM_SMMU

+160 -32
+1 -1
Documentation/arm64/memory.txt
··· 17 17 the same bits set to 1. TTBRx selection is given by bit 63 of the 18 18 virtual address. The swapper_pg_dir contains only kernel (global) 19 19 mappings while the user pgd contains only user (non-global) mappings. 20 - The swapper_pgd_dir address is written to TTBR1 and never written to 20 + The swapper_pg_dir address is written to TTBR1 and never written to 21 21 TTBR0. 22 22 23 23
+2 -1
arch/arm64/Kconfig
··· 1 1 config ARM64 2 2 def_bool y 3 + select ARCH_BINFMT_ELF_RANDOMIZE_PIE 3 4 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 4 5 select ARCH_HAS_SG_CHAIN 5 6 select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST ··· 233 232 234 233 config ARM64_VA_BITS_48 235 234 bool "48-bit" 236 - depends on BROKEN 235 + depends on !ARM_SMMU 237 236 238 237 endchoice 239 238
+34 -1
arch/arm64/boot/dts/rtsm_ve-motherboard.dtsi
··· 22 22 bank-width = <4>; 23 23 }; 24 24 25 - vram@2,00000000 { 25 + v2m_video_ram: vram@2,00000000 { 26 26 compatible = "arm,vexpress-vram"; 27 27 reg = <2 0x00000000 0x00800000>; 28 28 }; ··· 179 179 clcd@1f0000 { 180 180 compatible = "arm,pl111", "arm,primecell"; 181 181 reg = <0x1f0000 0x1000>; 182 + interrupt-names = "combined"; 182 183 interrupts = <14>; 183 184 clocks = <&v2m_oscclk1>, <&v2m_clk24mhz>; 184 185 clock-names = "clcdclk", "apb_pclk"; 186 + arm,pl11x,framebuffer = <0x18000000 0x00180000>; 187 + memory-region = <&v2m_video_ram>; 188 + max-memory-bandwidth = <130000000>; /* 16bpp @ 63.5MHz */ 189 + 190 + port { 191 + v2m_clcd_pads: endpoint { 192 + remote-endpoint = <&v2m_clcd_panel>; 193 + arm,pl11x,tft-r0g0b0-pads = <0 8 16>; 194 + }; 195 + }; 196 + 197 + panel { 198 + compatible = "panel-dpi"; 199 + 200 + port { 201 + v2m_clcd_panel: endpoint { 202 + remote-endpoint = <&v2m_clcd_pads>; 203 + }; 204 + }; 205 + 206 + panel-timing { 207 + clock-frequency = <63500127>; 208 + hactive = <1024>; 209 + hback-porch = <152>; 210 + hfront-porch = <48>; 211 + hsync-len = <104>; 212 + vactive = <768>; 213 + vback-porch = <23>; 214 + vfront-porch = <3>; 215 + vsync-len = <4>; 216 + }; 217 + }; 185 218 }; 186 219 187 220 virtio_block@0130000 {
+2
arch/arm64/configs/defconfig
··· 78 78 # CONFIG_WLAN is not set 79 79 CONFIG_INPUT_EVDEV=y 80 80 # CONFIG_SERIO_SERPORT is not set 81 + CONFIG_SERIO_AMBAKMI=y 81 82 CONFIG_LEGACY_PTY_COUNT=16 82 83 CONFIG_SERIAL_8250=y 83 84 CONFIG_SERIAL_8250_CONSOLE=y ··· 91 90 CONFIG_REGULATOR=y 92 91 CONFIG_REGULATOR_FIXED_VOLTAGE=y 93 92 CONFIG_FB=y 93 + CONFIG_FB_ARMCLCD=y 94 94 CONFIG_FRAMEBUFFER_CONSOLE=y 95 95 CONFIG_LOGO=y 96 96 # CONFIG_LOGO_LINUX_MONO is not set
+2 -2
arch/arm64/include/asm/compat.h
··· 37 37 typedef s32 compat_time_t; 38 38 typedef s32 compat_clock_t; 39 39 typedef s32 compat_pid_t; 40 - typedef u32 __compat_uid_t; 41 - typedef u32 __compat_gid_t; 40 + typedef u16 __compat_uid_t; 41 + typedef u16 __compat_gid_t; 42 42 typedef u16 __compat_uid16_t; 43 43 typedef u16 __compat_gid16_t; 44 44 typedef u32 __compat_uid32_t;
+2 -2
arch/arm64/include/asm/elf.h
··· 126 126 * that it will "exec", and that there is sufficient room for the brk. 127 127 */ 128 128 extern unsigned long randomize_et_dyn(unsigned long base); 129 - #define ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_64 / 3)) 129 + #define ELF_ET_DYN_BASE (2 * TASK_SIZE_64 / 3) 130 130 131 131 /* 132 132 * When the program starts, a1 contains a pointer to a function to be ··· 169 169 #define COMPAT_ELF_PLATFORM ("v8l") 170 170 #endif 171 171 172 - #define COMPAT_ELF_ET_DYN_BASE (randomize_et_dyn(2 * TASK_SIZE_32 / 3)) 172 + #define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3) 173 173 174 174 /* AArch32 registers. */ 175 175 #define COMPAT_ELF_NGREG 18
+11
arch/arm64/include/asm/irq_work.h
··· 1 1 #ifndef __ASM_IRQ_WORK_H 2 2 #define __ASM_IRQ_WORK_H 3 3 4 + #ifdef CONFIG_SMP 5 + 4 6 #include <asm/smp.h> 5 7 6 8 static inline bool arch_irq_work_has_interrupt(void) 7 9 { 8 10 return !!__smp_cross_call; 9 11 } 12 + 13 + #else 14 + 15 + static inline bool arch_irq_work_has_interrupt(void) 16 + { 17 + return false; 18 + } 19 + 20 + #endif 10 21 11 22 #endif /* __ASM_IRQ_WORK_H */
-5
arch/arm64/kernel/process.c
··· 378 378 { 379 379 return randomize_base(mm->brk); 380 380 } 381 - 382 - unsigned long randomize_et_dyn(unsigned long base) 383 - { 384 - return randomize_base(base); 385 - }
+2 -2
arch/arm64/mm/ioremap.c
··· 105 105 106 106 static pte_t bm_pte[PTRS_PER_PTE] __page_aligned_bss; 107 107 #if CONFIG_ARM64_PGTABLE_LEVELS > 2 108 - static pte_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss; 108 + static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss; 109 109 #endif 110 110 #if CONFIG_ARM64_PGTABLE_LEVELS > 3 111 - static pte_t bm_pud[PTRS_PER_PUD] __page_aligned_bss; 111 + static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss; 112 112 #endif 113 113 114 114 static inline pud_t * __init early_ioremap_pud(unsigned long addr)
+8 -4
arch/arm64/mm/mmu.c
··· 297 297 * create_mapping requires puds, pmds and ptes to be allocated from 298 298 * memory addressable from the initial direct kernel mapping. 299 299 * 300 - * The initial direct kernel mapping, located at swapper_pg_dir, 301 - * gives us PUD_SIZE memory starting from PHYS_OFFSET (which must be 302 - * aligned to 2MB as per Documentation/arm64/booting.txt). 300 + * The initial direct kernel mapping, located at swapper_pg_dir, gives 301 + * us PUD_SIZE (4K pages) or PMD_SIZE (64K pages) memory starting from 302 + * PHYS_OFFSET (which must be aligned to 2MB as per 303 + * Documentation/arm64/booting.txt). 303 304 */ 304 - limit = PHYS_OFFSET + PUD_SIZE; 305 + if (IS_ENABLED(CONFIG_ARM64_64K_PAGES)) 306 + limit = PHYS_OFFSET + PMD_SIZE; 307 + else 308 + limit = PHYS_OFFSET + PUD_SIZE; 305 309 memblock_set_current_limit(limit); 306 310 307 311 /* map all the memory banks */
+16 -2
arch/arm64/mm/pgd.c
··· 30 30 31 31 #define PGD_SIZE (PTRS_PER_PGD * sizeof(pgd_t)) 32 32 33 + static struct kmem_cache *pgd_cache; 34 + 33 35 pgd_t *pgd_alloc(struct mm_struct *mm) 34 36 { 35 37 if (PGD_SIZE == PAGE_SIZE) 36 38 return (pgd_t *)get_zeroed_page(GFP_KERNEL); 37 39 else 38 - return kzalloc(PGD_SIZE, GFP_KERNEL); 40 + return kmem_cache_zalloc(pgd_cache, GFP_KERNEL); 39 41 } 40 42 41 43 void pgd_free(struct mm_struct *mm, pgd_t *pgd) ··· 45 43 if (PGD_SIZE == PAGE_SIZE) 46 44 free_page((unsigned long)pgd); 47 45 else 48 - kfree(pgd); 46 + kmem_cache_free(pgd_cache, pgd); 49 47 } 48 + 49 + static int __init pgd_cache_init(void) 50 + { 51 + /* 52 + * Naturally aligned pgds required by the architecture. 53 + */ 54 + if (PGD_SIZE != PAGE_SIZE) 55 + pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_SIZE, 56 + SLAB_PANIC, NULL); 57 + return 0; 58 + } 59 + core_initcall(pgd_cache_init);
+6 -2
arch/arm64/net/bpf_jit.h
··· 144 144 145 145 /* Data-processing (2 source) */ 146 146 /* Rd = Rn OP Rm */ 147 - #define A64_UDIV(sf, Rd, Rn, Rm) aarch64_insn_gen_data2(Rd, Rn, Rm, \ 148 - A64_VARIANT(sf), AARCH64_INSN_DATA2_UDIV) 147 + #define A64_DATA2(sf, Rd, Rn, Rm, type) aarch64_insn_gen_data2(Rd, Rn, Rm, \ 148 + A64_VARIANT(sf), AARCH64_INSN_DATA2_##type) 149 + #define A64_UDIV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, UDIV) 150 + #define A64_LSLV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSLV) 151 + #define A64_LSRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, LSRV) 152 + #define A64_ASRV(sf, Rd, Rn, Rm) A64_DATA2(sf, Rd, Rn, Rm, ASRV) 149 153 150 154 /* Data-processing (3 source) */ 151 155 /* Rd = Ra + Rn * Rm */
+74 -10
arch/arm64/net/bpf_jit_comp.c
··· 19 19 #define pr_fmt(fmt) "bpf_jit: " fmt 20 20 21 21 #include <linux/filter.h> 22 - #include <linux/moduleloader.h> 23 22 #include <linux/printk.h> 24 23 #include <linux/skbuff.h> 25 24 #include <linux/slab.h> 25 + 26 26 #include <asm/byteorder.h> 27 27 #include <asm/cacheflush.h> 28 + #include <asm/debug-monitors.h> 28 29 29 30 #include "bpf_jit.h" 30 31 ··· 120 119 return to - from; 121 120 } 122 121 122 + static void jit_fill_hole(void *area, unsigned int size) 123 + { 124 + u32 *ptr; 125 + /* We are guaranteed to have aligned memory. */ 126 + for (ptr = area; size >= sizeof(u32); size -= sizeof(u32)) 127 + *ptr++ = cpu_to_le32(AARCH64_BREAK_FAULT); 128 + } 129 + 123 130 static inline int epilogue_offset(const struct jit_ctx *ctx) 124 131 { 125 132 int to = ctx->offset[ctx->prog->len - 1]; ··· 205 196 emit(A64_RET(A64_LR), ctx); 206 197 } 207 198 199 + /* JITs an eBPF instruction. 200 + * Returns: 201 + * 0 - successfully JITed an 8-byte eBPF instruction. 202 + * >0 - successfully JITed a 16-byte eBPF instruction. 203 + * <0 - failed to JIT. 204 + */ 208 205 static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx) 209 206 { 210 207 const u8 code = insn->code; ··· 266 251 emit(A64_UDIV(is64, tmp, dst, src), ctx); 267 252 emit(A64_MUL(is64, tmp, tmp, src), ctx); 268 253 emit(A64_SUB(is64, dst, dst, tmp), ctx); 254 + break; 255 + case BPF_ALU | BPF_LSH | BPF_X: 256 + case BPF_ALU64 | BPF_LSH | BPF_X: 257 + emit(A64_LSLV(is64, dst, dst, src), ctx); 258 + break; 259 + case BPF_ALU | BPF_RSH | BPF_X: 260 + case BPF_ALU64 | BPF_RSH | BPF_X: 261 + emit(A64_LSRV(is64, dst, dst, src), ctx); 262 + break; 263 + case BPF_ALU | BPF_ARSH | BPF_X: 264 + case BPF_ALU64 | BPF_ARSH | BPF_X: 265 + emit(A64_ASRV(is64, dst, dst, src), ctx); 269 266 break; 270 267 /* dst = -dst */ 271 268 case BPF_ALU | BPF_NEG: ··· 470 443 emit(A64_B(jmp_offset), ctx); 471 444 break; 472 445 446 + /* dst = imm64 */ 447 + case BPF_LD | BPF_IMM | BPF_DW: 448 + { 449 + const struct bpf_insn insn1 = insn[1]; 450 + u64 imm64; 451 + 452 + if (insn1.code != 0 || insn1.src_reg != 0 || 453 + insn1.dst_reg != 0 || insn1.off != 0) { 454 + /* Note: verifier in BPF core must catch invalid 455 + * instructions. 456 + */ 457 + pr_err_once("Invalid BPF_LD_IMM64 instruction\n"); 458 + return -EINVAL; 459 + } 460 + 461 + imm64 = (u64)insn1.imm << 32 | imm; 462 + emit_a64_mov_i64(dst, imm64, ctx); 463 + 464 + return 1; 465 + } 466 + 473 467 /* LDX: dst = *(size *)(src + off) */ 474 468 case BPF_LDX | BPF_MEM | BPF_W: 475 469 case BPF_LDX | BPF_MEM | BPF_H: ··· 642 594 ctx->offset[i] = ctx->idx; 643 595 644 596 ret = build_insn(insn, ctx); 597 + if (ret > 0) { 598 + i++; 599 + continue; 600 + } 645 601 if (ret) 646 602 return ret; 647 603 } ··· 665 613 666 614 void bpf_int_jit_compile(struct bpf_prog *prog) 667 615 { 616 + struct bpf_binary_header *header; 668 617 struct jit_ctx ctx; 669 618 int image_size; 619 + u8 *image_ptr; 670 620 671 621 if (!bpf_jit_enable) 672 622 return; ··· 690 636 goto out; 691 637 692 638 build_prologue(&ctx); 693 - 694 639 build_epilogue(&ctx); 695 640 696 641 /* Now we know the actual image size. */ 697 642 image_size = sizeof(u32) * ctx.idx; 698 - ctx.image = module_alloc(image_size); 699 - if (unlikely(ctx.image == NULL)) 643 + header = bpf_jit_binary_alloc(image_size, &image_ptr, 644 + sizeof(u32), jit_fill_hole); 645 + if (header == NULL) 700 646 goto out; 701 647 702 648 /* 2. Now, the actual pass. */ 703 649 650 + ctx.image = (u32 *)image_ptr; 704 651 ctx.idx = 0; 652 + 705 653 build_prologue(&ctx); 706 654 707 655 ctx.body_offset = ctx.idx; 708 656 if (build_body(&ctx)) { 709 - module_free(NULL, ctx.image); 657 + bpf_jit_binary_free(header); 710 658 goto out; 711 659 } 712 660 ··· 719 663 bpf_jit_dump(prog->len, image_size, 2, ctx.image); 720 664 721 665 bpf_flush_icache(ctx.image, ctx.image + ctx.idx); 722 - prog->bpf_func = (void *)ctx.image; 723 - prog->jited = 1; 724 666 667 + set_memory_ro((unsigned long)header, header->pages); 668 + prog->bpf_func = (void *)ctx.image; 669 + prog->jited = true; 725 670 out: 726 671 kfree(ctx.offset); 727 672 } 728 673 729 674 void bpf_jit_free(struct bpf_prog *prog) 730 675 { 731 - if (prog->jited) 732 - module_free(NULL, prog->bpf_func); 676 + unsigned long addr = (unsigned long)prog->bpf_func & PAGE_MASK; 677 + struct bpf_binary_header *header = (void *)addr; 733 678 734 - kfree(prog); 679 + if (!prog->jited) 680 + goto free_filter; 681 + 682 + set_memory_rw(addr, header->pages); 683 + bpf_jit_binary_free(header); 684 + 685 + free_filter: 686 + bpf_prog_unlock_free(prog); 735 687 }