1. 25 7月, 2020 3 次提交
    • A
      riscv: Parse all memory blocks to remove unusable memory · fa5a1983
      Atish Patra 提交于
      Currently, maximum physical memory allowed is equal to -PAGE_OFFSET.
      That's why we remove any memory blocks spanning beyond that size. However,
      it is done only for memblock containing linux kernel which will not work
      if there are multiple memblocks.
      
      Process all memory blocks to figure out how much memory needs to be removed
      and remove at the end instead of updating the memblock list in place.
      Signed-off-by: NAtish Patra <atish.patra@wdc.com>
      Signed-off-by: NPalmer Dabbelt <palmerdabbelt@google.com>
      fa5a1983
    • A
      RISC-V: Do not rely on initrd_start/end computed during early dt parsing · 4400231c
      Atish Patra 提交于
      Currently, initrd_start/end are computed during early_init_dt_scan
      but used during arch_setup. We will get the following panic if initrd is used
      and CONFIG_DEBUG_VIRTUAL is turned on.
      
      [    0.000000] ------------[ cut here ]------------
      [    0.000000] kernel BUG at arch/riscv/mm/physaddr.c:33!
      [    0.000000] Kernel BUG [#1]
      [    0.000000] Modules linked in:
      [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.8.0-rc4-00015-ged0b226fed02 #886
      [    0.000000] epc: ffffffe0002058d2 ra : ffffffe0000053f0 sp : ffffffe001001f40
      [    0.000000]  gp : ffffffe00106e250 tp : ffffffe001009d40 t0 : ffffffe00107ee28
      [    0.000000]  t1 : 0000000000000000 t2 : ffffffe000a2e880 s0 : ffffffe001001f50
      [    0.000000]  s1 : ffffffe0001383e8 a0 : ffffffe00c087e00 a1 : 0000000080200000
      [    0.000000]  a2 : 00000000010bf000 a3 : ffffffe00106f3c8 a4 : ffffffe0010bf000
      [    0.000000]  a5 : ffffffe000000000 a6 : 0000000000000006 a7 : 0000000000000001
      [    0.000000]  s2 : ffffffe00106f068 s3 : ffffffe00106f070 s4 : 0000000080200000
      [    0.000000]  s5 : 0000000082200000 s6 : 0000000000000000 s7 : 0000000000000000
      [    0.000000]  s8 : 0000000080011010 s9 : 0000000080012700 s10: 0000000000000000
      [    0.000000]  s11: 0000000000000000 t3 : 000000000001fe30 t4 : 000000000001fe30
      [    0.000000]  t5 : 0000000000000000 t6 : ffffffe00107c471
      [    0.000000] status: 0000000000000100 badaddr: 0000000000000000 cause: 0000000000000003
      [    0.000000] random: get_random_bytes called from print_oops_end_marker+0x22/0x46 with crng_init=0
      
      To avoid the error, initrd_start/end can be computed from phys_initrd_start/size
      in setup itself. It also improves the initrd placement by aligning the start
      and size with the page size.
      
      Fixes: 76d2a049 ("RISC-V: Init and Halt Code")
      Signed-off-by: NAtish Patra <atish.patra@wdc.com>
      Signed-off-by: NPalmer Dabbelt <palmerdabbelt@google.com>
      4400231c
    • A
      RISC-V: Set maximum number of mapped pages correctly · d0d8aae6
      Atish Patra 提交于
      Currently, maximum number of mapper pages are set to the pfn calculated
      from the memblock size of the memblock containing kernel. This will work
      until that memblock spans the entire memory. However, it will be set to
      a wrong value if there are multiple memblocks defined in kernel
      (e.g. with efi runtime services).
      
      Set the the maximum value to the pfn calculated from dram size.
      Signed-off-by: NAtish Patra <atish.patra@wdc.com>
      Signed-off-by: NPalmer Dabbelt <palmerdabbelt@google.com>
      d0d8aae6
  2. 21 7月, 2020 1 次提交
  3. 19 7月, 2020 2 次提交
  4. 18 7月, 2020 3 次提交
  5. 16 7月, 2020 15 次提交
  6. 15 7月, 2020 2 次提交
  7. 14 7月, 2020 4 次提交
  8. 13 7月, 2020 4 次提交
    • L
      arm64: defconfig: Enable CONFIG_PCIE_RCAR_HOST · fecc5cfc
      Lad Prabhakar 提交于
      config option PCIE_RCAR internally selects PCIE_RCAR_HOST which builds
      the same driver. So this patch renames CONFIG_PCIE_RCAR to
      CONFIG_PCIE_RCAR_HOST so that PCIE_RCAR can be safely dropped from
      Kconfig file.
      Signed-off-by: NLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
      Reviewed-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Link: https://lore.kernel.org/r/1589494238-2933-1-git-send-email-prabhakar.mahadev-lad.rj@bp.renesas.comSigned-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      fecc5cfc
    • A
      powerpc/book3s64/pkeys: Fix pkey_access_permitted() for execute disable pkey · 192b6a78
      Aneesh Kumar K.V 提交于
      Even if the IAMR value denies execute access, the current code returns
      true from pkey_access_permitted() for an execute permission check, if
      the AMR read pkey bit is cleared.
      
      This results in repeated page fault loop with a test like below:
      
        #define _GNU_SOURCE
        #include <errno.h>
        #include <stdio.h>
        #include <stdlib.h>
        #include <signal.h>
        #include <inttypes.h>
      
        #include <assert.h>
        #include <malloc.h>
        #include <unistd.h>
        #include <pthread.h>
        #include <sys/mman.h>
      
        #ifdef SYS_pkey_mprotect
        #undef SYS_pkey_mprotect
        #endif
      
        #ifdef SYS_pkey_alloc
        #undef SYS_pkey_alloc
        #endif
      
        #ifdef SYS_pkey_free
        #undef SYS_pkey_free
        #endif
      
        #undef PKEY_DISABLE_EXECUTE
        #define PKEY_DISABLE_EXECUTE	0x4
      
        #define SYS_pkey_mprotect	386
        #define SYS_pkey_alloc		384
        #define SYS_pkey_free		385
      
        #define PPC_INST_NOP		0x60000000
        #define PPC_INST_BLR		0x4e800020
        #define PROT_RWX		(PROT_READ | PROT_WRITE | PROT_EXEC)
      
        static int sys_pkey_mprotect(void *addr, size_t len, int prot, int pkey)
        {
        	return syscall(SYS_pkey_mprotect, addr, len, prot, pkey);
        }
      
        static int sys_pkey_alloc(unsigned long flags, unsigned long access_rights)
        {
        	return syscall(SYS_pkey_alloc, flags, access_rights);
        }
      
        static int sys_pkey_free(int pkey)
        {
        	return syscall(SYS_pkey_free, pkey);
        }
      
        static void do_execute(void *region)
        {
        	/* jump to region */
        	asm volatile(
        		"mtctr	%0;"
        		"bctrl"
        		: : "r"(region) : "ctr", "lr");
        }
      
        static void do_protect(void *region)
        {
        	size_t pgsize;
        	int i, pkey;
      
        	pgsize = getpagesize();
      
        	pkey = sys_pkey_alloc(0, PKEY_DISABLE_EXECUTE);
        	assert (pkey > 0);
      
        	/* perform mprotect */
        	assert(!sys_pkey_mprotect(region, pgsize, PROT_RWX, pkey));
        	do_execute(region);
      
        	/* free pkey */
        	assert(!sys_pkey_free(pkey));
      
        }
      
        int main(int argc, char **argv)
        {
        	size_t pgsize, numinsns;
        	unsigned int *region;
        	int i;
      
        	/* allocate memory region to protect */
        	pgsize = getpagesize();
        	region = memalign(pgsize, pgsize);
        	assert(region != NULL);
        	assert(!mprotect(region, pgsize, PROT_RWX));
      
        	/* fill page with NOPs with a BLR at the end */
        	numinsns = pgsize / sizeof(region[0]);
        	for (i = 0; i < numinsns - 1; i++)
        		region[i] = PPC_INST_NOP;
        	region[i] = PPC_INST_BLR;
      
        	do_protect(region);
      
        	return EXIT_SUCCESS;
        }
      
      The fix is to only check the IAMR for an execute check, the AMR value
      is not relevant.
      
      Fixes: f2407ef3 ("powerpc: helper to validate key-access permissions of a pte")
      Cc: stable@vger.kernel.org # v4.16+
      Reported-by: NSandipan Das <sandipan@linux.ibm.com>
      Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      [mpe: Add detail to change log, tweak wording & formatting]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20200712132047.1038594-1-aneesh.kumar@linux.ibm.com
      192b6a78
    • B
      ARM: imx: Remove imx_add_imx_dma() unused irq_err argument · f8951dce
      Bjorn Helgaas 提交于
      No callers of imx_add_imx_dma() need an error IRQ, so they supply 0 as
      "irq_err", which means we register a resource of IRQ 0, which is invalid
      and causes a warning if used.
      
      Remove the "irq_err" argument altogether so there's no chance of trying to
      use the invalid IRQ 0.
      
      Fixes: a85a6c86 ("driver core: platform: Clarify that IRQ 0 is invalid")
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: kernel@pengutronix.de
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: linux-imx@nxp.com
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: NShawn Guo <shawnguo@kernel.org>
      f8951dce
    • G
      ARM: imx: Provide correct number of resources when registering gpio devices · 2a835440
      Guenter Roeck 提交于
      Since commit a85a6c86 ("driver core: platform: Clarify that IRQ 0 is
      invalid"), the kernel is a bit touchy when it encounters interrupt 0.
      As a result, there are lots of warnings such as the following when booting
      systems such as 'kzm'.
      
      WARNING: CPU: 0 PID: 1 at drivers/base/platform.c:224 platform_get_irq_optional+0x118/0x128
      0 is an invalid IRQ number
      Modules linked in:
      CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc3 #1
      Hardware name: Kyoto Microcomputer Co., Ltd. KZM-ARM11-01
      [<c01127d4>] (unwind_backtrace) from [<c010c620>] (show_stack+0x10/0x14)
      [<c010c620>] (show_stack) from [<c06f5f54>] (dump_stack+0xe8/0x120)
      [<c06f5f54>] (dump_stack) from [<c0128878>] (__warn+0xe4/0x108)
      [<c0128878>] (__warn) from [<c0128910>] (warn_slowpath_fmt+0x74/0xbc)
      [<c0128910>] (warn_slowpath_fmt) from [<c08b8e84>] (platform_get_irq_optional+0x118/0x128)
      [<c08b8e84>] (platform_get_irq_optional) from [<c08b8eb4>] (platform_irq_count+0x20/0x3c)
      [<c08b8eb4>] (platform_irq_count) from [<c0728660>] (mxc_gpio_probe+0x8c/0x494)
      [<c0728660>] (mxc_gpio_probe) from [<c08b93cc>] (platform_drv_probe+0x48/0x98)
      [<c08b93cc>] (platform_drv_probe) from [<c08b703c>] (really_probe+0x214/0x344)
      [<c08b703c>] (really_probe) from [<c08b7274>] (driver_probe_device+0x58/0xb4)
      [<c08b7274>] (driver_probe_device) from [<c08b7478>] (device_driver_attach+0x58/0x60)
      [<c08b7478>] (device_driver_attach) from [<c08b7504>] (__driver_attach+0x84/0xc0)
      [<c08b7504>] (__driver_attach) from [<c08b50f8>] (bus_for_each_dev+0x78/0xb8)
      [<c08b50f8>] (bus_for_each_dev) from [<c08b62cc>] (bus_add_driver+0x154/0x1e0)
      [<c08b62cc>] (bus_add_driver) from [<c08b82b8>] (driver_register+0x74/0x108)
      [<c08b82b8>] (driver_register) from [<c0102320>] (do_one_initcall+0x80/0x3b4)
      [<c0102320>] (do_one_initcall) from [<c1501008>] (kernel_init_freeable+0x170/0x208)
      [<c1501008>] (kernel_init_freeable) from [<c0e178d4>] (kernel_init+0x8/0x11c)
      [<c0e178d4>] (kernel_init) from [<c0100134>] (ret_from_fork+0x14/0x20)
      
      As it turns out, mxc_register_gpio() is a bit lax when setting the
      number of resources: it registers a resource with interrupt 0 when in
      reality there is no such interrupt. Fix the problem by not declaring
      the second interrupt resource if there is no second interrupt.
      
      Fixes: a85a6c86 ("driver core: platform: Clarify that IRQ 0 is invalid")
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NShawn Guo <shawnguo@kernel.org>
      2a835440
  9. 11 7月, 2020 2 次提交
  10. 10 7月, 2020 4 次提交
    • H
      KVM: MIPS: Fix build errors for 32bit kernel · 3d9fdc25
      Huacai Chen 提交于
      Commit dc6d95b1 ("KVM: MIPS: Add more MMIO load/store
      instructions emulation") introduced some 64bit load/store instructions
      emulation which are unavailable on 32bit platform, and it causes build
      errors:
      
      arch/mips/kvm/emulate.c: In function 'kvm_mips_emulate_store':
      arch/mips/kvm/emulate.c:1734:6: error: right shift count >= width of type [-Werror]
            ((vcpu->arch.gprs[rt] >> 56) & 0xff);
            ^
      arch/mips/kvm/emulate.c:1738:6: error: right shift count >= width of type [-Werror]
            ((vcpu->arch.gprs[rt] >> 48) & 0xffff);
            ^
      arch/mips/kvm/emulate.c:1742:6: error: right shift count >= width of type [-Werror]
            ((vcpu->arch.gprs[rt] >> 40) & 0xffffff);
            ^
      arch/mips/kvm/emulate.c:1746:6: error: right shift count >= width of type [-Werror]
            ((vcpu->arch.gprs[rt] >> 32) & 0xffffffff);
            ^
      arch/mips/kvm/emulate.c:1796:6: error: left shift count >= width of type [-Werror]
            (vcpu->arch.gprs[rt] << 32);
            ^
      arch/mips/kvm/emulate.c:1800:6: error: left shift count >= width of type [-Werror]
            (vcpu->arch.gprs[rt] << 40);
            ^
      arch/mips/kvm/emulate.c:1804:6: error: left shift count >= width of type [-Werror]
            (vcpu->arch.gprs[rt] << 48);
            ^
      arch/mips/kvm/emulate.c:1808:6: error: left shift count >= width of type [-Werror]
            (vcpu->arch.gprs[rt] << 56);
            ^
      cc1: all warnings being treated as errors
      make[3]: *** [arch/mips/kvm/emulate.o] Error 1
      
      So, use #if defined(CONFIG_64BIT) && defined(CONFIG_KVM_MIPS_VZ) to
      guard the 64bit load/store instructions emulation.
      Reported-by: Nkernel test robot <lkp@intel.com>
      Fixes: dc6d95b1 ("KVM: MIPS: Add more MMIO load/store instructions emulation")
      Signed-off-by: NHuacai Chen <chenhc@lemote.com>
      Message-Id: <1594365797-536-1-git-send-email-chenhc@lemote.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3d9fdc25
    • P
      KVM: nVMX: fixes for preemption timer migration · 83d31e52
      Paolo Bonzini 提交于
      Commit 850448f3 ("KVM: nVMX: Fix VMX preemption timer migration",
      2020-06-01) accidentally broke nVMX live migration from older version
      by changing the userspace ABI.  Restore it and, while at it, ensure
      that vmx->nested.has_preemption_timer_deadline is always initialized
      according to the KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE flag.
      
      Cc: Makarand Sonare <makarandsonare@google.com>
      Fixes: 850448f3 ("KVM: nVMX: Fix VMX preemption timer migration")
      Reviewed-by: NJim Mattson <jmattson@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      83d31e52
    • V
      riscv: Avoid kgdb.h including gdb_xml.h to solve unused-const-variable warning · 70ee5731
      Vincent Chen 提交于
      The constant arrays in gdb_xml.h are only used in arch/riscv/kernel/kgdb.c,
      but other c files may include the gdb_xml.h indirectly via including the
      kgdb.h. Hence, It will cause many unused-const-variable warnings. This
      patch makes the kgdb.h not to include the gdb_xml.h to solve this problem.
      Signed-off-by: NVincent Chen <vincent.chen@sifive.com>
      Signed-off-by: NPalmer Dabbelt <palmerdabbelt@google.com>
      70ee5731
    • V
      kgdb: Move the extern declaration kgdb_has_hit_break() to generic kgdb.h · def0aa21
      Vincent Chen 提交于
      Currently, only riscv kgdb.c uses the kgdb_has_hit_break() to identify
      the kgdb breakpoint. It causes other architectures will encounter the "no
      previous prototype" warnings if the compile option has W=1. Moving the
      declaration of extern kgdb_has_hit_break() from risc-v kgdb.h to generic
      kgdb.h to avoid generating these warnings.
      Signed-off-by: NVincent Chen <vincent.chen@sifive.com>
      Acked-by: NDaniel Thompson <daniel.thompson@linaro.org>
      Signed-off-by: NPalmer Dabbelt <palmerdabbelt@google.com>
      def0aa21