target/riscv: Honour -semihosting-config userspace=on and enable=on
The riscv target incorrectly enabled semihosting always, whether the user asked for it or not. Call semihosting_enabled() passing the correct value to the is_userspace argument, which fixes this and also handles the userspace=on argument. Because we do this at translate time, we no longer need to check the privilege level in riscv_cpu_do_interrupt(). Note that this is a behaviour change: we used to default to semihosting being enabled, and now the user must pass "-semihosting-config enable=on" if they want it. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220822141230.3658237-8-peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
870ab98bee
commit
7d7fb11615
|
@ -1589,13 +1589,10 @@ void riscv_cpu_do_interrupt(CPUState *cs)
|
||||||
target_ulong mtval2 = 0;
|
target_ulong mtval2 = 0;
|
||||||
|
|
||||||
if (cause == RISCV_EXCP_SEMIHOST) {
|
if (cause == RISCV_EXCP_SEMIHOST) {
|
||||||
if (env->priv >= PRV_S) {
|
|
||||||
do_common_semihosting(cs);
|
do_common_semihosting(cs);
|
||||||
env->pc += 4;
|
env->pc += 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cause = RISCV_EXCP_BREAKPOINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!async) {
|
if (!async) {
|
||||||
/* set tval to badaddr for traps with address information */
|
/* set tval to badaddr for traps with address information */
|
||||||
|
|
|
@ -52,7 +52,8 @@ static bool trans_ebreak(DisasContext *ctx, arg_ebreak *a)
|
||||||
* that no exception will be raised when fetching them.
|
* that no exception will be raised when fetching them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((pre_addr & TARGET_PAGE_MASK) == (post_addr & TARGET_PAGE_MASK)) {
|
if (semihosting_enabled(ctx->mem_idx < PRV_S) &&
|
||||||
|
(pre_addr & TARGET_PAGE_MASK) == (post_addr & TARGET_PAGE_MASK)) {
|
||||||
pre = opcode_at(&ctx->base, pre_addr);
|
pre = opcode_at(&ctx->base, pre_addr);
|
||||||
ebreak = opcode_at(&ctx->base, ebreak_addr);
|
ebreak = opcode_at(&ctx->base, ebreak_addr);
|
||||||
post = opcode_at(&ctx->base, post_addr);
|
post = opcode_at(&ctx->base, post_addr);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "exec/translator.h"
|
#include "exec/translator.h"
|
||||||
#include "exec/log.h"
|
#include "exec/log.h"
|
||||||
|
#include "semihosting/semihost.h"
|
||||||
|
|
||||||
#include "instmap.h"
|
#include "instmap.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
|
|
Loading…
Reference in New Issue