meson: Make DEBUG_REMAP a meson option

target/m68k: Support semihosting on non-ColdFire targets
 linux-user: do_setsockopt cleanups
 linux-user: Add FITRIM ioctl
 -----BEGIN PGP SIGNATURE-----
 
 iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmYpjHcdHHJpY2hhcmQu
 aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+a/Af7BHmDB27U61b9i8et
 cObewYH9y9M+iaCrIflNZPAaoguHDRKOuvw+PFT/dIo5FL2D509vYOuxUow1qLsy
 q6b6kdvXROq9WU2NiuB86Abl/4mwwzxRhFah+Eh+OYSA2/pQnkcULkouLqxjFfF0
 xTBzZtHtYdTbCTVRbpd6XrwLo7Qrs85ovl4wVD1r+T2T8FkvrryoNOA/VjUWxyeh
 3b1X1I0wtOTnEA7JSr17JCXWZGENCmTO35r6WSYzJy5U/C59PjjgaaeMi3R3lQTJ
 gg21EH0hlU1nTiPLg2ypj3l9NbIGAincAdDF/jufee+R75YSPdpKoDH8tUlUGsnM
 CRx5Xg==
 =J+5K
 -----END PGP SIGNATURE-----

Merge tag 'pull-tcg-20240424' of https://gitlab.com/rth7680/qemu into staging

meson: Make DEBUG_REMAP a meson option
target/m68k: Support semihosting on non-ColdFire targets
linux-user: do_setsockopt cleanups
linux-user: Add FITRIM ioctl

# -----BEGIN PGP SIGNATURE-----
#
# iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmYpjHcdHHJpY2hhcmQu
# aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+a/Af7BHmDB27U61b9i8et
# cObewYH9y9M+iaCrIflNZPAaoguHDRKOuvw+PFT/dIo5FL2D509vYOuxUow1qLsy
# q6b6kdvXROq9WU2NiuB86Abl/4mwwzxRhFah+Eh+OYSA2/pQnkcULkouLqxjFfF0
# xTBzZtHtYdTbCTVRbpd6XrwLo7Qrs85ovl4wVD1r+T2T8FkvrryoNOA/VjUWxyeh
# 3b1X1I0wtOTnEA7JSr17JCXWZGENCmTO35r6WSYzJy5U/C59PjjgaaeMi3R3lQTJ
# gg21EH0hlU1nTiPLg2ypj3l9NbIGAincAdDF/jufee+R75YSPdpKoDH8tUlUGsnM
# CRx5Xg==
# =J+5K
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 24 Apr 2024 03:49:27 PM PDT
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "richard.henderson@linaro.org"
# gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate]

* tag 'pull-tcg-20240424' of https://gitlab.com/rth7680/qemu:
  target/m68k: Support semihosting on non-ColdFire targets
  target/m68k: Perform the semihosting test during translate
  target/m68k: Pass semihosting arg to exit
  linux-user: Add FITRIM ioctl
  linux-user: do_setsockopt: eliminate goto in switch for SO_SNDTIMEO
  linux-user: do_setsockopt: make ip_mreq_source local to the place where it is used
  linux-user: do_setsockopt: make ip_mreq local to the place it is used and inline target_to_host_ip_mreq()
  linux-user: do_setsockopt: fix SOL_ALG.ALG_SET_KEY
  meson: Make DEBUG_REMAP a meson option

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2024-04-24 15:51:49 -07:00
commit 5da72194df
14 changed files with 107 additions and 68 deletions

View File

@ -22,8 +22,6 @@
#include "exec/cpu_ldst.h" #include "exec/cpu_ldst.h"
#include "exec/exec-all.h" #include "exec/exec-all.h"
#undef DEBUG_REMAP
#include "exec/user/abitypes.h" #include "exec/user/abitypes.h"
extern char **environ; extern char **environ;
@ -437,7 +435,7 @@ static inline void *lock_user(int type, abi_ulong guest_addr, long len,
if (!access_ok(type, guest_addr, len)) { if (!access_ok(type, guest_addr, len)) {
return NULL; return NULL;
} }
#ifdef DEBUG_REMAP #ifdef CONFIG_DEBUG_REMAP
{ {
void *addr; void *addr;
addr = g_malloc(len); addr = g_malloc(len);
@ -461,7 +459,7 @@ static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,
long len) long len)
{ {
#ifdef DEBUG_REMAP #ifdef CONFIG_DEBUG_REMAP
if (!host_ptr) { if (!host_ptr) {
return; return;
} }

View File

@ -140,6 +140,9 @@
#ifdef FITHAW #ifdef FITHAW
IOCTL(FITHAW, IOC_W | IOC_R, TYPE_INT) IOCTL(FITHAW, IOC_W | IOC_R, TYPE_INT)
#endif #endif
#ifdef FITRIM
IOCTL(FITRIM, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_fstrim_range)))
#endif
IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG)) IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG))
#ifdef CONFIG_FIEMAP #ifdef CONFIG_FIEMAP

View File

@ -4,8 +4,6 @@
#include "cpu.h" #include "cpu.h"
#include "exec/cpu_ldst.h" #include "exec/cpu_ldst.h"
#undef DEBUG_REMAP
#include "exec/user/abitypes.h" #include "exec/user/abitypes.h"
#include "syscall_defs.h" #include "syscall_defs.h"
@ -332,7 +330,7 @@ void *lock_user(int type, abi_ulong guest_addr, ssize_t len, bool copy);
/* Unlock an area of guest memory. The first LEN bytes must be /* Unlock an area of guest memory. The first LEN bytes must be
flushed back to guest memory. host_ptr = NULL is explicitly flushed back to guest memory. host_ptr = NULL is explicitly
allowed and does nothing. */ allowed and does nothing. */
#ifndef DEBUG_REMAP #ifndef CONFIG_DEBUG_REMAP
static inline void unlock_user(void *host_ptr, abi_ulong guest_addr, static inline void unlock_user(void *host_ptr, abi_ulong guest_addr,
ssize_t len) ssize_t len)
{ {

View File

@ -1615,24 +1615,6 @@ static abi_long do_pipe(CPUArchState *cpu_env, abi_ulong pipedes,
return get_errno(ret); return get_errno(ret);
} }
static inline abi_long target_to_host_ip_mreq(struct ip_mreqn *mreqn,
abi_ulong target_addr,
socklen_t len)
{
struct target_ip_mreqn *target_smreqn;
target_smreqn = lock_user(VERIFY_READ, target_addr, len, 1);
if (!target_smreqn)
return -TARGET_EFAULT;
mreqn->imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr;
mreqn->imr_address.s_addr = target_smreqn->imr_address.s_addr;
if (len == sizeof(struct target_ip_mreqn))
mreqn->imr_ifindex = tswapal(target_smreqn->imr_ifindex);
unlock_user(target_smreqn, target_addr, 0);
return 0;
}
static inline abi_long target_to_host_sockaddr(int fd, struct sockaddr *addr, static inline abi_long target_to_host_sockaddr(int fd, struct sockaddr *addr,
abi_ulong target_addr, abi_ulong target_addr,
socklen_t len) socklen_t len)
@ -2067,8 +2049,6 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
{ {
abi_long ret; abi_long ret;
int val; int val;
struct ip_mreqn *ip_mreq;
struct ip_mreq_source *ip_mreq_source;
switch(level) { switch(level) {
case SOL_TCP: case SOL_TCP:
@ -2111,19 +2091,40 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
break; break;
case IP_ADD_MEMBERSHIP: case IP_ADD_MEMBERSHIP:
case IP_DROP_MEMBERSHIP: case IP_DROP_MEMBERSHIP:
{
struct ip_mreqn ip_mreq;
struct target_ip_mreqn *target_smreqn;
QEMU_BUILD_BUG_ON(sizeof(struct ip_mreq) !=
sizeof(struct target_ip_mreq));
if (optlen < sizeof (struct target_ip_mreq) || if (optlen < sizeof (struct target_ip_mreq) ||
optlen > sizeof (struct target_ip_mreqn)) optlen > sizeof (struct target_ip_mreqn)) {
return -TARGET_EINVAL; return -TARGET_EINVAL;
}
ip_mreq = (struct ip_mreqn *) alloca(optlen); target_smreqn = lock_user(VERIFY_READ, optval_addr, optlen, 1);
target_to_host_ip_mreq(ip_mreq, optval_addr, optlen); if (!target_smreqn) {
ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq, optlen)); return -TARGET_EFAULT;
}
ip_mreq.imr_multiaddr.s_addr = target_smreqn->imr_multiaddr.s_addr;
ip_mreq.imr_address.s_addr = target_smreqn->imr_address.s_addr;
if (optlen == sizeof(struct target_ip_mreqn)) {
ip_mreq.imr_ifindex = tswapal(target_smreqn->imr_ifindex);
optlen = sizeof(struct ip_mreqn);
}
unlock_user(target_smreqn, optval_addr, 0);
ret = get_errno(setsockopt(sockfd, level, optname, &ip_mreq, optlen));
break; break;
}
case IP_BLOCK_SOURCE: case IP_BLOCK_SOURCE:
case IP_UNBLOCK_SOURCE: case IP_UNBLOCK_SOURCE:
case IP_ADD_SOURCE_MEMBERSHIP: case IP_ADD_SOURCE_MEMBERSHIP:
case IP_DROP_SOURCE_MEMBERSHIP: case IP_DROP_SOURCE_MEMBERSHIP:
{
struct ip_mreq_source *ip_mreq_source;
if (optlen != sizeof (struct target_ip_mreq_source)) if (optlen != sizeof (struct target_ip_mreq_source))
return -TARGET_EINVAL; return -TARGET_EINVAL;
@ -2134,7 +2135,7 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq_source, optlen)); ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq_source, optlen));
unlock_user (ip_mreq_source, optval_addr, 0); unlock_user (ip_mreq_source, optval_addr, 0);
break; break;
}
default: default:
goto unimplemented; goto unimplemented;
} }
@ -2277,18 +2278,13 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
switch (optname) { switch (optname) {
case ALG_SET_KEY: case ALG_SET_KEY:
{ {
char *alg_key = g_malloc(optlen); char *alg_key = lock_user(VERIFY_READ, optval_addr, optlen, 1);
if (!alg_key) { if (!alg_key) {
return -TARGET_ENOMEM;
}
if (copy_from_user(alg_key, optval_addr, optlen)) {
g_free(alg_key);
return -TARGET_EFAULT; return -TARGET_EFAULT;
} }
ret = get_errno(setsockopt(sockfd, level, optname, ret = get_errno(setsockopt(sockfd, level, optname,
alg_key, optlen)); alg_key, optlen));
g_free(alg_key); unlock_user(alg_key, optval_addr, optlen);
break; break;
} }
case ALG_SET_AEAD_AUTHSIZE: case ALG_SET_AEAD_AUTHSIZE:
@ -2305,12 +2301,10 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
case TARGET_SOL_SOCKET: case TARGET_SOL_SOCKET:
switch (optname) { switch (optname) {
case TARGET_SO_RCVTIMEO: case TARGET_SO_RCVTIMEO:
case TARGET_SO_SNDTIMEO:
{ {
struct timeval tv; struct timeval tv;
optname = SO_RCVTIMEO;
set_timeout:
if (optlen != sizeof(struct target_timeval)) { if (optlen != sizeof(struct target_timeval)) {
return -TARGET_EINVAL; return -TARGET_EINVAL;
} }
@ -2319,13 +2313,12 @@ set_timeout:
return -TARGET_EFAULT; return -TARGET_EFAULT;
} }
ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname, ret = get_errno(setsockopt(sockfd, SOL_SOCKET,
optname == TARGET_SO_RCVTIMEO ?
SO_RCVTIMEO : SO_SNDTIMEO,
&tv, sizeof(tv))); &tv, sizeof(tv)));
return ret; return ret;
} }
case TARGET_SO_SNDTIMEO:
optname = SO_SNDTIMEO;
goto set_timeout;
case TARGET_SO_ATTACH_FILTER: case TARGET_SO_ATTACH_FILTER:
{ {
struct target_sock_fprog *tfprog; struct target_sock_fprog *tfprog;

View File

@ -945,6 +945,7 @@ struct target_rtc_pll_info {
#define TARGET_FIFREEZE TARGET_IOWR('X', 119, abi_int) #define TARGET_FIFREEZE TARGET_IOWR('X', 119, abi_int)
#define TARGET_FITHAW TARGET_IOWR('X', 120, abi_int) #define TARGET_FITHAW TARGET_IOWR('X', 120, abi_int)
#define TARGET_FITRIM TARGET_IOWR('X', 121, struct fstrim_range)
/* /*
* Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION> * Note that the ioctl numbers for FS_IOC_<GET|SET><FLAGS|VERSION>

View File

@ -341,6 +341,11 @@ STRUCT(file_clone_range,
TYPE_ULONGLONG, /* src_length */ TYPE_ULONGLONG, /* src_length */
TYPE_ULONGLONG) /* dest_offset */ TYPE_ULONGLONG) /* dest_offset */
STRUCT(fstrim_range,
TYPE_ULONGLONG, /* start */
TYPE_ULONGLONG, /* len */
TYPE_ULONGLONG) /* minlen */
STRUCT(fiemap_extent, STRUCT(fiemap_extent,
TYPE_ULONGLONG, /* fe_logical */ TYPE_ULONGLONG, /* fe_logical */
TYPE_ULONGLONG, /* fe_physical */ TYPE_ULONGLONG, /* fe_physical */

View File

@ -14,7 +14,7 @@ void *lock_user(int type, abi_ulong guest_addr, ssize_t len, bool copy)
return NULL; return NULL;
} }
host_addr = g2h_untagged(guest_addr); host_addr = g2h_untagged(guest_addr);
#ifdef DEBUG_REMAP #ifdef CONFIG_DEBUG_REMAP
if (copy) { if (copy) {
host_addr = g_memdup(host_addr, len); host_addr = g_memdup(host_addr, len);
} else { } else {
@ -24,7 +24,7 @@ void *lock_user(int type, abi_ulong guest_addr, ssize_t len, bool copy)
return host_addr; return host_addr;
} }
#ifdef DEBUG_REMAP #ifdef CONFIG_DEBUG_REMAP
void unlock_user(void *host_ptr, abi_ulong guest_addr, ssize_t len) void unlock_user(void *host_ptr, abi_ulong guest_addr, ssize_t len)
{ {
void *host_ptr_conv; void *host_ptr_conv;

View File

@ -2350,6 +2350,7 @@ config_host_data.set('CONFIG_DEBUG_GRAPH_LOCK', get_option('debug_graph_lock'))
config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex')) config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex'))
config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage')) config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_usage'))
config_host_data.set('CONFIG_DEBUG_TCG', get_option('debug_tcg')) config_host_data.set('CONFIG_DEBUG_TCG', get_option('debug_tcg'))
config_host_data.set('CONFIG_DEBUG_REMAP', get_option('debug_remap'))
config_host_data.set('CONFIG_LIVE_BLOCK_MIGRATION', get_option('live_block_migration').allowed()) config_host_data.set('CONFIG_LIVE_BLOCK_MIGRATION', get_option('live_block_migration').allowed())
config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug')) config_host_data.set('CONFIG_QOM_CAST_DEBUG', get_option('qom_cast_debug'))
config_host_data.set('CONFIG_REPLICATION', get_option('replication').allowed()) config_host_data.set('CONFIG_REPLICATION', get_option('replication').allowed())
@ -4277,6 +4278,9 @@ if config_all_accel.has_key('CONFIG_TCG')
endif endif
summary_info += {'TCG plugins': get_option('plugins')} summary_info += {'TCG plugins': get_option('plugins')}
summary_info += {'TCG debug enabled': get_option('debug_tcg')} summary_info += {'TCG debug enabled': get_option('debug_tcg')}
if have_linux_user or have_bsd_user
summary_info += {'syscall buffer debugging support': get_option('debug_remap')}
endif
endif endif
summary_info += {'target list': ' '.join(target_dirs)} summary_info += {'target list': ' '.join(target_dirs)}
if have_system if have_system

View File

@ -85,6 +85,8 @@ option('plugins', type: 'boolean', value: false,
description: 'TCG plugins via shared library loading') description: 'TCG plugins via shared library loading')
option('debug_tcg', type: 'boolean', value: false, option('debug_tcg', type: 'boolean', value: false,
description: 'TCG debugging') description: 'TCG debugging')
option('debug_remap', type: 'boolean', value: false,
description: 'syscall buffer debugging support')
option('tcg_interpreter', type: 'boolean', value: false, option('tcg_interpreter', type: 'boolean', value: false,
description: 'TCG with bytecode interpreter (slow)') description: 'TCG with bytecode interpreter (slow)')
option('safe_stack', type: 'boolean', value: false, option('safe_stack', type: 'boolean', value: false,

View File

@ -29,6 +29,7 @@ meson_options_help() {
printf "%s\n" ' --enable-debug-graph-lock' printf "%s\n" ' --enable-debug-graph-lock'
printf "%s\n" ' graph lock debugging support' printf "%s\n" ' graph lock debugging support'
printf "%s\n" ' --enable-debug-mutex mutex debugging support' printf "%s\n" ' --enable-debug-mutex mutex debugging support'
printf "%s\n" ' --enable-debug-remap syscall buffer debugging support'
printf "%s\n" ' --enable-debug-stack-usage' printf "%s\n" ' --enable-debug-stack-usage'
printf "%s\n" ' measure coroutine stack usage' printf "%s\n" ' measure coroutine stack usage'
printf "%s\n" ' --enable-debug-tcg TCG debugging' printf "%s\n" ' --enable-debug-tcg TCG debugging'
@ -294,6 +295,8 @@ _meson_option_parse() {
--disable-debug-graph-lock) printf "%s" -Ddebug_graph_lock=false ;; --disable-debug-graph-lock) printf "%s" -Ddebug_graph_lock=false ;;
--enable-debug-mutex) printf "%s" -Ddebug_mutex=true ;; --enable-debug-mutex) printf "%s" -Ddebug_mutex=true ;;
--disable-debug-mutex) printf "%s" -Ddebug_mutex=false ;; --disable-debug-mutex) printf "%s" -Ddebug_mutex=false ;;
--enable-debug-remap) printf "%s" -Ddebug_remap=true ;;
--disable-debug-remap) printf "%s" -Ddebug_remap=false ;;
--enable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=true ;; --enable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=true ;;
--disable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=false ;; --disable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=false ;;
--enable-debug-tcg) printf "%s" -Ddebug_tcg=true ;; --enable-debug-tcg) printf "%s" -Ddebug_tcg=true ;;

View File

@ -66,7 +66,7 @@
#define EXCP_MMU_ACCESS 58 /* MMU Access Level Violation Error */ #define EXCP_MMU_ACCESS 58 /* MMU Access Level Violation Error */
#define EXCP_RTE 0x100 #define EXCP_RTE 0x100
#define EXCP_HALT_INSN 0x101 #define EXCP_SEMIHOSTING 0x101
#define M68K_DTTR0 0 #define M68K_DTTR0 0
#define M68K_DTTR1 1 #define M68K_DTTR1 1

View File

@ -132,8 +132,8 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
args = env->dregs[1]; args = env->dregs[1];
switch (nr) { switch (nr) {
case HOSTED_EXIT: case HOSTED_EXIT:
gdb_exit(env->dregs[0]); gdb_exit(env->dregs[1]);
exit(env->dregs[0]); exit(env->dregs[1]);
case HOSTED_OPEN: case HOSTED_OPEN:
GET_ARG(0); GET_ARG(0);

View File

@ -202,18 +202,8 @@ static void cf_interrupt_all(CPUM68KState *env, int is_hw)
/* Return from an exception. */ /* Return from an exception. */
cf_rte(env); cf_rte(env);
return; return;
case EXCP_HALT_INSN: case EXCP_SEMIHOSTING:
if (semihosting_enabled((env->sr & SR_S) == 0) do_m68k_semihosting(env, env->dregs[0]);
&& (env->pc & 3) == 0
&& cpu_lduw_code(env, env->pc - 4) == 0x4e71
&& cpu_ldl_code(env, env->pc) == 0x4e7bf000) {
env->pc += 4;
do_m68k_semihosting(env, env->dregs[0]);
return;
}
cs->halted = 1;
cs->exception_index = EXCP_HLT;
cpu_loop_exit(cs);
return; return;
} }
} }

View File

@ -26,12 +26,11 @@
#include "qemu/log.h" #include "qemu/log.h"
#include "qemu/qemu-print.h" #include "qemu/qemu-print.h"
#include "exec/translator.h" #include "exec/translator.h"
#include "exec/helper-proto.h" #include "exec/helper-proto.h"
#include "exec/helper-gen.h" #include "exec/helper-gen.h"
#include "exec/log.h" #include "exec/log.h"
#include "fpu/softfloat.h" #include "fpu/softfloat.h"
#include "semihosting/semihost.h"
#define HELPER_H "helper.h" #define HELPER_H "helper.h"
#include "exec/helper-info.c.inc" #include "exec/helper-info.c.inc"
@ -1401,6 +1400,40 @@ static void gen_jmp_tb(DisasContext *s, int n, target_ulong dest,
s->base.is_jmp = DISAS_NORETURN; s->base.is_jmp = DISAS_NORETURN;
} }
#ifndef CONFIG_USER_ONLY
static bool semihosting_test(DisasContext *s)
{
uint32_t test;
if (!semihosting_enabled(IS_USER(s))) {
return false;
}
/*
* "The semihosting instruction is immediately preceded by a
* nop aligned to a 4-byte boundary..."
* The preceding 2-byte (aligned) nop plus the 2-byte halt/bkpt
* means that we have advanced 4 bytes from the required nop.
*/
if (s->pc % 4 != 0) {
return false;
}
test = translator_lduw(s->env, &s->base, s->pc - 4);
if (test != 0x4e71) {
return false;
}
/* "... and followed by an invalid sentinel instruction movec %sp,0." */
test = translator_ldl(s->env, &s->base, s->pc);
if (test != 0x4e7bf000) {
return false;
}
/* Consume the sentinel. */
s->pc += 4;
return true;
}
#endif /* !CONFIG_USER_ONLY */
DISAS_INSN(scc) DISAS_INSN(scc)
{ {
DisasCompare c; DisasCompare c;
@ -2613,6 +2646,11 @@ DISAS_INSN(bkpt)
#if defined(CONFIG_USER_ONLY) #if defined(CONFIG_USER_ONLY)
gen_exception(s, s->base.pc_next, EXCP_DEBUG); gen_exception(s, s->base.pc_next, EXCP_DEBUG);
#else #else
/* BKPT #0 is the alternate semihosting instruction. */
if ((insn & 7) == 0 && semihosting_test(s)) {
gen_exception(s, s->pc, EXCP_SEMIHOSTING);
return;
}
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL); gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
#endif #endif
} }
@ -4465,8 +4503,12 @@ DISAS_INSN(halt)
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE); gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
return; return;
} }
if (semihosting_test(s)) {
gen_exception(s, s->pc, EXCP_HALT_INSN); gen_exception(s, s->pc, EXCP_SEMIHOSTING);
return;
}
tcg_gen_movi_i32(cpu_halted, 1);
gen_exception(s, s->pc, EXCP_HLT);
} }
DISAS_INSN(stop) DISAS_INSN(stop)