Skip to content

Commit

Permalink
morello: Ensure that trapframe_set_elr sets SPRS when using the bench…
Browse files Browse the repository at this point in the history
…mark ABI.

In a benchmark ABI kernel, the elr argument will not have the LSB set.
Assume that all kernel addresses ever passed to trapframe_set_elr
use the C64 encoding and artificially set it.
In practice, this is only used by the pcb_onfault and generic_bs_fault.
  • Loading branch information
qwattash committed May 3, 2024
1 parent 10c03e6 commit ce1989c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sys/arm64/include/cheric.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#ifndef _MACHINE_CHERIC_H_
#define _MACHINE_CHERIC_H_

#include <machine/vmparam.h>

#if __has_feature(capabilities) && defined(_KERNEL)
/*
* ERET in Morello does not use the LSB of the saved elr to set
Expand All @@ -44,6 +46,13 @@ trapframe_set_elr(struct trapframe *tf, uintcap_t elr)
if (cheri_getsealed(elr))
elr = cheri_unseal(elr, sentry_unsealcap);

#ifdef __ARM_MORELLO_PURECAP_BENCHMARK_ABI
/* Assume that kernel ELR addresses are C64 */
if (elr > VM_MAXUSER_ADDRESS) {
elr |= 1;
}
#endif

if (elr & 0x1) {
tf->tf_spsr |= PSR_C64;
--elr;
Expand Down

0 comments on commit ce1989c

Please sign in to comment.