1
0
Fork 0

RISC-V updates for v5.4-rc2

Two RISC-V fixes for v5.4-rc2:
 
 - Ensure that exclusive-load reservations are terminated after system
   call or exception handling.  This primarily affects QEMU, which does
     not expire load reservations.
 
 - Fix an issue primarily affecting RV32 platforms that can cause the
   DT header to be corrupted, causing boot failures.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEElRDoIDdEz9/svf2Kx4+xDQu9KksFAl2Xge8ACgkQx4+xDQu9
 KkuRpQ/+PvRuMmcC2IHL5P1SAq/U3ExVS81d0lPRrSMRnUoIdZeKyVfKM6CyxsmA
 CbTl6GEem60Pb/+35Y6rIaW/mEusBBJpgyzP9Wkkl9uRrlpr3ofmjg9WOg5jLHVh
 2gajke8MvKMVfAtVgdWLH/OtaoXLW2pHx7FY/pj2YALgzDLnykA8BgO30w5T+bzr
 SxoA1L+oqb6FMtwUPVyvUh4pC5I4TPsCZVFyqAGSGSJcFm6A+I333PMnqGmt5d9L
 bExTcFhlPimhEUH2V+j7FPrL3m3jewS5w9VMfQ5QZ+63g7+SvYDzW2NievoaZ3p3
 /ts1c1+folMzENMMQ7IdGgC9+sTwtLTVaO06OAiBOgbrhKCllz+JbuKw5tEqA68x
 JvvQPGm+OX3W6NWjTbbmfiL+7S3i8j5ZBrURFHqfBmYzvfSP9jkG/IZeD9FvX49D
 Fkx7A5YB8BwfNFoGrFS+iW9dHCrDM8qefYqDF7pmgIE6rooWxKNRamHAwNYvJ1jG
 8uvYP6RHZdSlHxf4hbrD6C379j7awDXa4t0fTpNywZtXan3i56DhFImEFUuYcPV7
 ARahcaiBl2eCFI/HssPS5bn+xwVGPzbC3/5A+hGpCBOQf1DU5GkKHp8FQjcAl/9U
 RRu6v+2N77oBIZGwnt7yh8cfM40+4y4hZ1bn8Vz4tNh5j2ycNao=
 =yka9
 -----END PGP SIGNATURE-----

Merge tag 'riscv/for-v5.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull RISC-V fixes from Paul Walmsley:

 - Ensure that exclusive-load reservations are terminated after system
   call or exception handling. This primarily affects QEMU, which does
   not expire load reservations.

 - Fix an issue primarily affecting RV32 platforms that can cause the DT
   header to be corrupted, causing boot failures.

* tag 'riscv/for-v5.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: Fix memblock reservation for device tree blob
  RISC-V: Clear load reservations while restoring hart contexts
alistair/sunxi64-5.4-dsi
Linus Torvalds 2019-10-04 13:02:47 -07:00
commit 812ad49d88
3 changed files with 32 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#define REG_L __REG_SEL(ld, lw)
#define REG_S __REG_SEL(sd, sw)
#define REG_SC __REG_SEL(sc.d, sc.w)
#define SZREG __REG_SEL(8, 4)
#define LGREG __REG_SEL(3, 2)

View File

@ -98,7 +98,26 @@ _save_context:
*/
.macro RESTORE_ALL
REG_L a0, PT_SSTATUS(sp)
REG_L a2, PT_SEPC(sp)
/*
* The current load reservation is effectively part of the processor's
* state, in the sense that load reservations cannot be shared between
* different hart contexts. We can't actually save and restore a load
* reservation, so instead here we clear any existing reservation --
* it's always legal for implementations to clear load reservations at
* any point (as long as the forward progress guarantee is kept, but
* we'll ignore that here).
*
* Dangling load reservations can be the result of taking a trap in the
* middle of an LR/SC sequence, but can also be the result of a taken
* forward branch around an SC -- which is how we implement CAS. As a
* result we need to clear reservations between the last CAS and the
* jump back to the new context. While it is unlikely the store
* completes, implementations are allowed to expand reservations to be
* arbitrarily large.
*/
REG_L a2, PT_SEPC(sp)
REG_SC x0, a2, PT_SEPC(sp)
csrw CSR_SSTATUS, a0
csrw CSR_SEPC, a2

View File

@ -11,6 +11,7 @@
#include <linux/swap.h>
#include <linux/sizes.h>
#include <linux/of_fdt.h>
#include <linux/libfdt.h>
#include <asm/fixmap.h>
#include <asm/tlbflush.h>
@ -82,6 +83,8 @@ disable:
}
#endif /* CONFIG_BLK_DEV_INITRD */
static phys_addr_t dtb_early_pa __initdata;
void __init setup_bootmem(void)
{
struct memblock_region *reg;
@ -117,7 +120,12 @@ void __init setup_bootmem(void)
setup_initrd();
#endif /* CONFIG_BLK_DEV_INITRD */
early_init_fdt_reserve_self();
/*
* Avoid using early_init_fdt_reserve_self() since __pa() does
* not work for DTB pointers that are fixmap addresses
*/
memblock_reserve(dtb_early_pa, fdt_totalsize(dtb_early_va));
early_init_fdt_scan_reserved_mem();
memblock_allow_resize();
memblock_dump_all();
@ -393,6 +401,8 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
/* Save pointer to DTB for early FDT parsing */
dtb_early_va = (void *)fix_to_virt(FIX_FDT) + (dtb_pa & ~PAGE_MASK);
/* Save physical address for memblock reservation */
dtb_early_pa = dtb_pa;
}
static void __init setup_vm_final(void)