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

microblaze: Unprivileged stream instruction awareness

Add cpuinfo support for the new MicroBlaze option permitting userspace
(unprivileged) access to the streaming instructions (FSL / AXI-stream).

Emit a noisy warning at bootup if this is enabled, because bad user code
can potentially lockup the CPU.

Signed-off-by: John A. Williams <john.williams@petalogix.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>

authored by

John A. Williams and committed by
Michal Simek
8904976e 5db34eb9

+13 -1
+1
arch/microblaze/include/asm/cpuinfo.h
··· 38 38 u32 use_exc; 39 39 u32 ver_code; 40 40 u32 mmu; 41 + u32 mmu_privins; 41 42 u32 endian; 42 43 43 44 /* CPU caches */
+2 -1
arch/microblaze/include/asm/pvr.h
··· 117 117 #define PVR11_MMU_DTLB_SIZE 0x07000000 118 118 #define PVR11_MMU_TLB_ACCESS 0x00C00000 119 119 #define PVR11_MMU_ZONES 0x003C0000 120 + #define PVR11_MMU_PRIVINS 0x00010000 120 121 /* MSR Reset value PVR mask */ 121 122 #define PVR11_MSR_RESET_VALUE_MASK 0x000007FF 122 - 123 123 124 124 /* PVR access macros */ 125 125 #define PVR_IS_FULL(_pvr) (_pvr.pvr[0] & PVR0_PVR_FULL_MASK) ··· 216 216 #define PVR_MMU_DTLB_SIZE(_pvr) (_pvr.pvr[11] & PVR11_MMU_DTLB_SIZE) 217 217 #define PVR_MMU_TLB_ACCESS(_pvr) (_pvr.pvr[11] & PVR11_MMU_TLB_ACCESS) 218 218 #define PVR_MMU_ZONES(_pvr) (_pvr.pvr[11] & PVR11_MMU_ZONES) 219 + #define PVR_MMU_PRIVINS(pvr) (pvr.pvr[11] & PVR11_MMU_PRIVINS) 219 220 220 221 /* endian */ 221 222 #define PVR_ENDIAN(_pvr) (_pvr.pvr[0] & PVR0_ENDI)
+1
arch/microblaze/kernel/cpu/cpuinfo-pvr-full.c
··· 72 72 CI(pvr_user2, USER2); 73 73 74 74 CI(mmu, USE_MMU); 75 + CI(mmu_privins, MMU_PRIVINS); 75 76 CI(endian, ENDIAN); 76 77 77 78 CI(use_icache, USE_ICACHE);
+1
arch/microblaze/kernel/cpu/cpuinfo-static.c
··· 119 119 ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2"); 120 120 121 121 ci->mmu = fcpu(cpu, "xlnx,use-mmu"); 122 + ci->mmu_privins = fcpu(cpu, "xlnx,mmu-privileged-instr"); 122 123 ci->endian = fcpu(cpu, "xlnx,endianness"); 123 124 124 125 ci->ver_code = 0;
+4
arch/microblaze/kernel/cpu/cpuinfo.c
··· 88 88 printk(KERN_WARNING "%s: Unsupported PVR setting\n", __func__); 89 89 set_cpuinfo_static(&cpuinfo, cpu); 90 90 } 91 + 92 + if (cpuinfo.mmu_privins) 93 + printk(KERN_WARNING "%s: Stream instructions enabled" 94 + " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); 91 95 }
+4
arch/microblaze/kernel/cpu/mb.c
··· 97 97 (cpuinfo.use_exc & PVR2_FPU_EXC_MASK) ? "fpu " : "", 98 98 (cpuinfo.use_exc & PVR2_USE_FSL_EXC) ? "fsl " : ""); 99 99 100 + count += seq_printf(m, 101 + "Stream-insns:\t%sprivileged\n", 102 + cpuinfo.mmu_privins ? "un" : ""); 103 + 100 104 if (cpuinfo.use_icache) 101 105 count += seq_printf(m, 102 106 "Icache:\t\t%ukB\tline length:\t%dB\n",