Merge tag 'riscv-for-linus-5.10-mw0' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 20 Oct 2020 01:18:30 +0000 (18:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 20 Oct 2020 01:18:30 +0000 (18:18 -0700)
Pull RISC-V updates from Palmer Dabbelt:
 "A handful of cleanups and new features:

   - A handful of cleanups for our page fault handling

   - Improvements to how we fill out cacheinfo

   - Support for EFI-based systems"

* tag 'riscv-for-linus-5.10-mw0' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (22 commits)
  RISC-V: Add page table dump support for uefi
  RISC-V: Add EFI runtime services
  RISC-V: Add EFI stub support.
  RISC-V: Add PE/COFF header for EFI stub
  RISC-V: Implement late mapping page table allocation functions
  RISC-V: Add early ioremap support
  RISC-V: Move DT mapping outof fixmap
  RISC-V: Fix duplicate included thread_info.h
  riscv/mm/fault: Set FAULT_FLAG_INSTRUCTION flag in do_page_fault()
  riscv/mm/fault: Fix inline placement in vmalloc_fault() declaration
  riscv: Add cache information in AUX vector
  riscv: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO
  riscv: Set more data to cacheinfo
  riscv/mm/fault: Move access error check to function
  riscv/mm/fault: Move FAULT_FLAG_WRITE handling in do_page_fault()
  riscv/mm/fault: Simplify mm_fault_error()
  riscv/mm/fault: Move fault error handling to mm_fault_error()
  riscv/mm/fault: Simplify fault error handling
  riscv/mm/fault: Move vmalloc fault handling to vmalloc_fault()
  riscv/mm/fault: Move bad area handling to bad_area()
  ...

1  2 
arch/riscv/Kconfig
arch/riscv/kernel/vmlinux.lds.S
arch/riscv/mm/init.c
drivers/firmware/efi/Kconfig
drivers/firmware/efi/Makefile
drivers/firmware/efi/libstub/Makefile

Simple merge
@@@ -66,8 -71,11 +70,13 @@@ SECTION
                _etext = .;
        }
  
+ #ifdef CONFIG_EFI
+       . = ALIGN(PECOFF_SECTION_ALIGNMENT);
+       __pecoff_text_end = .;
+ #endif
 +      INIT_DATA_SECTION(16)
 +
        /* Start of data section */
        _sdata = .;
        RO_DATA(SECTION_ALIGN)
@@@ -141,25 -152,23 +152,23 @@@ disable
  }
  #endif /* CONFIG_BLK_DEV_INITRD */
  
- static phys_addr_t dtb_early_pa __initdata;
  void __init setup_bootmem(void)
  {
 -      struct memblock_region *reg;
        phys_addr_t mem_size = 0;
        phys_addr_t total_mem = 0;
 -      phys_addr_t mem_start, end = 0;
 +      phys_addr_t mem_start, start, end = 0;
        phys_addr_t vmlinux_end = __pa_symbol(&_end);
        phys_addr_t vmlinux_start = __pa_symbol(&_start);
 +      u64 i;
  
        /* Find the memory region containing the kernel */
 -      for_each_memblock(memory, reg) {
 -              end = reg->base + reg->size;
 +      for_each_mem_range(i, &start, &end) {
 +              phys_addr_t size = end - start;
                if (!total_mem)
 -                      mem_start = reg->base;
 -              if (reg->base <= vmlinux_start && vmlinux_end <= end)
 -                      BUG_ON(reg->size == 0);
 -              total_mem = total_mem + reg->size;
 +                      mem_start = start;
 +              if (start <= vmlinux_start && vmlinux_end <= end)
 +                      BUG_ON(size == 0);
 +              total_mem = total_mem + size;
        }
  
        /*
@@@ -217,24 -236,31 +227,30 @@@ void __set_fixmap(enum fixed_addresses 
  
        ptep = &fixmap_pte[pte_index(addr)];
  
 -      if (pgprot_val(prot)) {
 +      if (pgprot_val(prot))
                set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, prot));
 -      } else {
 +      else
                pte_clear(&init_mm, addr, ptep);
 -              local_flush_tlb_page(addr);
 -      }
 +      local_flush_tlb_page(addr);
  }
  
- static pte_t *__init get_pte_virt(phys_addr_t pa)
+ static inline pte_t *__init get_pte_virt_early(phys_addr_t pa)
  {
-       if (mmu_enabled) {
-               clear_fixmap(FIX_PTE);
-               return (pte_t *)set_fixmap_offset(FIX_PTE, pa);
-       } else {
-               return (pte_t *)((uintptr_t)pa);
-       }
+       return (pte_t *)((uintptr_t)pa);
  }
  
- static phys_addr_t __init alloc_pte(uintptr_t va)
+ static inline pte_t *__init get_pte_virt_fixmap(phys_addr_t pa)
+ {
+       clear_fixmap(FIX_PTE);
+       return (pte_t *)set_fixmap_offset(FIX_PTE, pa);
+ }
+ static inline pte_t *get_pte_virt_late(phys_addr_t pa)
+ {
+       return (pte_t *) __va(pa);
+ }
+ static inline phys_addr_t __init alloc_pte_early(uintptr_t va)
  {
        /*
         * We only create PMD or PGD early mappings so we
@@@ -455,11 -548,18 +538,18 @@@ static void __init setup_vm_final(void
  {
        uintptr_t va, map_size;
        phys_addr_t pa, start, end;
 -      struct memblock_region *reg;
 +      u64 i;
  
-       /* Set mmu_enabled flag */
-       mmu_enabled = true;
+       /**
+        * MMU is enabled at this point. But page table setup is not complete yet.
+        * fixmap page table alloc functions should be used at this point
+        */
+       pt_ops.alloc_pte = alloc_pte_fixmap;
+       pt_ops.get_pte_virt = get_pte_virt_fixmap;
+ #ifndef __PAGETABLE_PMD_FOLDED
+       pt_ops.alloc_pmd = alloc_pmd_fixmap;
+       pt_ops.get_pmd_virt = get_pmd_virt_fixmap;
+ #endif
        /* Setup swapper PGD for fixmap */
        create_pgd_mapping(swapper_pg_dir, FIXADDR_START,
                           __pa_symbol(fixmap_pgd_next),
Simple merge
Simple merge
@@@ -64,13 -65,9 +66,14 @@@ lib-$(CONFIG_EFI_GENERIC_STUB)      += efi-s
  lib-$(CONFIG_ARM)             += arm32-stub.o
  lib-$(CONFIG_ARM64)           += arm64-stub.o
  lib-$(CONFIG_X86)             += x86-stub.o
+ lib-$(CONFIG_RISCV)           += riscv-stub.o
  CFLAGS_arm32-stub.o           := -DTEXT_OFFSET=$(TEXT_OFFSET)
 -CFLAGS_arm64-stub.o           := -DTEXT_OFFSET=$(TEXT_OFFSET)
 +
 +# Even when -mbranch-protection=none is set, Clang will generate a
 +# .note.gnu.property for code-less object files (like lib/ctype.c),
 +# so work around this by explicitly removing the unwanted section.
 +# https://bugs.llvm.org/show_bug.cgi?id=46480
 +STUBCOPY_FLAGS-y              += --remove-section=.note.gnu.property
  
  #
  # For x86, bootloaders like systemd-boot or grub-efi do not zero-initialize the