@@ -17,11 +17,14 @@ static void insert_slb_entry(unsigned long p, int ssize, int page_size)
1717 : "r" (mk_vsid_data (p , ssize , flags )),
1818 "r" (mk_esid_data (p , ssize , SLB_NUM_BOLTED ))
1919 : "memory" );
20+ isync ();
2021
2122 asm volatile ("slbmte %0,%1" :
2223 : "r" (mk_vsid_data (p , ssize , flags )),
2324 "r" (mk_esid_data (p , ssize , SLB_NUM_BOLTED + 1 ))
2425 : "memory" );
26+ isync ();
27+
2528 preempt_enable ();
2629}
2730
@@ -84,6 +87,7 @@ static void insert_dup_slb_entry_0(void)
8487 : "r" (vsid ),
8588 "r" (esid | SLB_NUM_BOLTED )
8689 : "memory" );
90+ isync ();
8791
8892 asm volatile ("slbmfee %0,%1" : "=r" (esid ) : "r" (i ));
8993 asm volatile ("slbmfev %0,%1" : "=r" (vsid ) : "r" (i ));
@@ -93,13 +97,39 @@ static void insert_dup_slb_entry_0(void)
9397 : "r" (vsid ),
9498 "r" (esid | (SLB_NUM_BOLTED + 1 ))
9599 : "memory" );
100+ isync ();
96101
97102 pr_info ("%s accessing test address 0x%lx: 0x%lx\n" ,
98103 __func__ , test_address , * test_ptr );
99104
100105 preempt_enable ();
101106}
102107
108+ static void tlbiel_va (unsigned long va ,
109+ unsigned long pid ,
110+ unsigned long ap ,
111+ unsigned long ric )
112+ {
113+ unsigned long rb , rs , prs , r ;
114+
115+ rb = va & ~(PPC_BITMASK (52 , 63 ));
116+ rb |= ap << PPC_BITLSHIFT (58 );
117+ rs = pid << PPC_BITLSHIFT (31 );
118+
119+ prs = 1 ; /* process scoped */
120+ r = 1 ; /* radix format */
121+
122+ /*
123+ * Trigger an MCE by issuing radix tlbiel with an invalid operand combination.
124+ * Using PRS=1 (process-scoped) with kernel address does not correspond to
125+ * any valid process-scoped translation.
126+ * This results in an invalid tlbiel operation, causing hardware to
127+ * raise a machine check.
128+ */
129+ asm volatile (PPC_TLBIEL (%0 , %4 , %3 , %2 , %1 )
130+ : : "r" (rb ), "i" (r ), "i" (prs ), "i" (ric ), "r" (rs ) : "memory ");
131+ }
132+
103133static void lkdtm_PPC_SLB_MULTIHIT (void )
104134{
105135 if (!radix_enabled ()) {
@@ -119,8 +149,22 @@ static void lkdtm_PPC_SLB_MULTIHIT(void)
119149 }
120150}
121151
152+ static void lkdtm_PPC_RADIX_TLBIEL (void )
153+ {
154+ unsigned long addr = PAGE_OFFSET ;
155+
156+ if (radix_enabled ()) {
157+ pr_info ("Injecting Radix TLB invalidation MCE\n" );
158+ tlbiel_va (addr , 0 , 0 , RIC_FLUSH_ALL );
159+ pr_info ("Recovered from radix tlbiel attempt\n" );
160+ } else {
161+ pr_err ("XFAIL: This test is for ppc64 and with radix mode MMU only\n" );
162+ }
163+ }
164+
122165static struct crashtype crashtypes [] = {
123166 CRASHTYPE (PPC_SLB_MULTIHIT ),
167+ CRASHTYPE (PPC_RADIX_TLBIEL ),
124168};
125169
126170struct crashtype_category powerpc_crashtypes = {
0 commit comments