forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/powerpc/include/asm/plpar_wrappers.h
....@@ -312,7 +312,12 @@
312312
313313 static inline long plpar_set_watchpoint0(unsigned long dawr0, unsigned long dawrx0)
314314 {
315
- return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR, dawr0, dawrx0);
315
+ return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR0, dawr0, dawrx0);
316
+}
317
+
318
+static inline long plpar_set_watchpoint1(unsigned long dawr1, unsigned long dawrx1)
319
+{
320
+ return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR1, dawr1, dawrx1);
316321 }
317322
318323 static inline long plpar_signal_sys_reset(long cpu)
....@@ -334,12 +339,70 @@
334339 return rc;
335340 }
336341
342
+/*
343
+ * Wrapper to H_RPT_INVALIDATE hcall that handles return values appropriately
344
+ *
345
+ * - Returns H_SUCCESS on success
346
+ * - For H_BUSY return value, we retry the hcall.
347
+ * - For any other hcall failures, attempt a full flush once before
348
+ * resorting to BUG().
349
+ *
350
+ * Note: This hcall is expected to fail only very rarely. The correct
351
+ * error recovery of killing the process/guest will be eventually
352
+ * needed.
353
+ */
354
+static inline long pseries_rpt_invalidate(u32 pid, u64 target, u64 type,
355
+ u64 page_sizes, u64 start, u64 end)
356
+{
357
+ long rc;
358
+ unsigned long all;
359
+
360
+ while (true) {
361
+ rc = plpar_hcall_norets(H_RPT_INVALIDATE, pid, target, type,
362
+ page_sizes, start, end);
363
+ if (rc == H_BUSY) {
364
+ cpu_relax();
365
+ continue;
366
+ } else if (rc == H_SUCCESS)
367
+ return rc;
368
+
369
+ /* Flush request failed, try with a full flush once */
370
+ if (type & H_RPTI_TYPE_NESTED)
371
+ all = H_RPTI_TYPE_NESTED | H_RPTI_TYPE_NESTED_ALL;
372
+ else
373
+ all = H_RPTI_TYPE_ALL;
374
+retry:
375
+ rc = plpar_hcall_norets(H_RPT_INVALIDATE, pid, target,
376
+ all, page_sizes, 0, -1UL);
377
+ if (rc == H_BUSY) {
378
+ cpu_relax();
379
+ goto retry;
380
+ } else if (rc == H_SUCCESS)
381
+ return rc;
382
+
383
+ BUG();
384
+ }
385
+}
386
+
337387 #else /* !CONFIG_PPC_PSERIES */
338388
339389 static inline long plpar_set_ciabr(unsigned long ciabr)
340390 {
341391 return 0;
342392 }
393
+
394
+static inline long plpar_pte_read_4(unsigned long flags, unsigned long ptex,
395
+ unsigned long *ptes)
396
+{
397
+ return 0;
398
+}
399
+
400
+static inline long pseries_rpt_invalidate(u32 pid, u64 target, u64 type,
401
+ u64 page_sizes, u64 start, u64 end)
402
+{
403
+ return 0;
404
+}
405
+
343406 #endif /* CONFIG_PPC_PSERIES */
344407
345408 #endif /* _ASM_POWERPC_PLPAR_WRAPPERS_H */