@@ -371,6 +371,39 @@ static void hyp_dump_backtrace(unsigned long hyp_offset)
371
371
kvm_nvhe_dump_backtrace_end ();
372
372
}
373
373
374
+ #ifdef CONFIG_PROTECTED_NVHE_STACKTRACE
375
+ DECLARE_KVM_NVHE_PER_CPU (unsigned long [NVHE_STACKTRACE_SIZE /sizeof (long )],
376
+ pkvm_stacktrace );
377
+
378
+ /*
379
+ * pkvm_dump_backtrace - Dump the protected nVHE HYP backtrace.
380
+ *
381
+ * @hyp_offset: hypervisor offset, used for address translation.
382
+ *
383
+ * Dumping of the pKVM HYP backtrace is done by reading the
384
+ * stack addresses from the shared stacktrace buffer, since the
385
+ * host cannot directly access hypervisor memory in protected
386
+ * mode.
387
+ */
388
+ static void pkvm_dump_backtrace (unsigned long hyp_offset )
389
+ {
390
+ unsigned long * stacktrace
391
+ = (unsigned long * ) this_cpu_ptr_nvhe_sym (pkvm_stacktrace );
392
+ int i , size = NVHE_STACKTRACE_SIZE / sizeof (long );
393
+
394
+ kvm_nvhe_dump_backtrace_start ();
395
+ /* The saved stacktrace is terminated by a null entry */
396
+ for (i = 0 ; i < size && stacktrace [i ]; i ++ )
397
+ kvm_nvhe_dump_backtrace_entry ((void * )hyp_offset , stacktrace [i ]);
398
+ kvm_nvhe_dump_backtrace_end ();
399
+ }
400
+ #else /* !CONFIG_PROTECTED_NVHE_STACKTRACE */
401
+ static void pkvm_dump_backtrace (unsigned long hyp_offset )
402
+ {
403
+ kvm_err ("Cannot dump pKVM nVHE stacktrace: !CONFIG_PROTECTED_NVHE_STACKTRACE\n" );
404
+ }
405
+ #endif /* CONFIG_PROTECTED_NVHE_STACKTRACE */
406
+
374
407
/*
375
408
* kvm_nvhe_dump_backtrace - Dump KVM nVHE hypervisor backtrace.
376
409
*
@@ -379,7 +412,7 @@ static void hyp_dump_backtrace(unsigned long hyp_offset)
379
412
static void kvm_nvhe_dump_backtrace (unsigned long hyp_offset )
380
413
{
381
414
if (is_protected_kvm_enabled ())
382
- return ;
415
+ pkvm_dump_backtrace ( hyp_offset ) ;
383
416
else
384
417
hyp_dump_backtrace (hyp_offset );
385
418
}
0 commit comments