From nobody Fri Dec 19 06:16:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151452960271497.46680393823351; Thu, 28 Dec 2017 22:40:02 -0800 (PST) Received: from localhost ([::1]:56969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUoKj-0000bc-HI for importer@patchew.org; Fri, 29 Dec 2017 01:39:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUoCy-0002nH-K1 for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:31:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUoCw-0004Wl-Um for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:31:56 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:47010) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eUoCw-0004WS-NL for qemu-devel@nongnu.org; Fri, 29 Dec 2017 01:31:54 -0500 Received: by mail-pf0-x243.google.com with SMTP id c204so21819539pfc.13 for ; Thu, 28 Dec 2017 22:31:54 -0800 (PST) Received: from cloudburst.twiddle.net (97-113-183-164.tukw.qwest.net. [97.113.183.164]) by smtp.gmail.com with ESMTPSA id c28sm76539063pfe.69.2017.12.28.22.31.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Dec 2017 22:31:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+S9P/21+H05pEuPl2Lh72O2+jZKmmJb/siIKkD4zSIE=; b=V+U20SAdnFLHpV5haNUL/qPRGGfXkw2rpi5oKP8pj/J/sagf0Wl9BnymUK3+9/za5h zlmAicYN/kFXjKBEqkxcLq+eRr9Xj0iVIWuLkS+gznNDF94/3ieNJJgRz80eRdmQnZvx knLS45uyAHQG98HdB0zC2PG3XyKwLW6a3NG+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+S9P/21+H05pEuPl2Lh72O2+jZKmmJb/siIKkD4zSIE=; b=TFSVvM/vE8gVY7QCzBvjLaFQEs+3jxXg8u3ohgv8/pJ0WfXzIlLNWrELVuw90O2uUT iUpK5RPJ91olgn6MqN+KDSNnYs0RcelYmmBAwFigaEnt0JVeYvEB/FlYqes3XBt8zZo4 wOj5myRnTou/lg2Pvq4fbVLjhnsbSMDFxeN/AKLO6JiMX1BMErkWvR3ML9ny6aWaxX3H rkiFfPbkWDma4/bvayGSjE9sxVYoRrDvnT/Eh0gKux76JN1adN/ctD8j2Sfcysq2W/ST DpD2Sek4QOSEbcRtLpZz12oGJFCGD9D6qgmsUXSJCjHrI9p8R1nb+TboZWnqwoNep3Zf hgHQ== X-Gm-Message-State: AKGB3mKQkdoYo06LXYVbYzvSlfCbSQjOK+SQeKjntfGSg9dLye0Il5XG vKvASq8i2SaKuZ19k/pQYoFYTE2nMJ0= X-Google-Smtp-Source: ACJfBotVbJWAOGvPD/BxHpj2xF5t/2Cj1NW7wBLpi5o1Bk5ml06Z+okxw5mf6oE0HzbloeSRnO5rYw== X-Received: by 10.99.172.10 with SMTP id v10mr30765818pge.35.1514529113464; Thu, 28 Dec 2017 22:31:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Dec 2017 22:31:11 -0800 Message-Id: <20171229063145.29167-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171229063145.29167-1-richard.henderson@linaro.org> References: <20171229063145.29167-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH 04/38] target/hppa: Define hardware exception types X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: deller@gmx.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/hppa/cpu.h | 39 +++++++++++++++++++++++++++---- linux-user/main.c | 26 ++++++++++++++++++--- target/hppa/helper.c | 61 ++++++++++++++++++++++++++++++++++----------= ---- target/hppa/mem_helper.c | 4 +++- target/hppa/op_helper.c | 6 ++--- target/hppa/translate.c | 8 +++---- 6 files changed, 111 insertions(+), 33 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index ea7e495408..d84af91860 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -40,11 +40,40 @@ #define MMU_USER_IDX 0 #define TARGET_INSN_START_EXTRA_WORDS 1 =20 -#define EXCP_SYSCALL 1 -#define EXCP_SYSCALL_LWS 2 -#define EXCP_SIGSEGV 3 -#define EXCP_SIGILL 4 -#define EXCP_SIGFPE 5 +/* Hardware exceptions, interupts, faults, and traps. */ +#define EXCP_HPMC 1 /* high priority machine check */ +#define EXCP_POWER_FAIL 2 +#define EXCP_RC 3 /* recovery counter */ +#define EXCP_EXT_INTERRUPT 4 /* external interrupt */ +#define EXCP_LPMC 5 /* low priority machine check */ +#define EXCP_ITLB_MISS 6 /* itlb miss / instruction page fault = */ +#define EXCP_IMP 7 /* instruction memory protection trap = */ +#define EXCP_ILL 8 /* illegal instruction trap */ +#define EXCP_BREAK 9 /* break instruction */ +#define EXCP_PRIV_OPR 10 /* privileged operation trap */ +#define EXCP_PRIV_REG 11 /* privileged register trap */ +#define EXCP_OVERFLOW 12 /* signed overflow trap */ +#define EXCP_COND 13 /* trap-on-condition */ +#define EXCP_ASSIST 14 /* assist exception trap */ +#define EXCP_DTLB_MISS 15 /* dtlb miss / data page fault */ +#define EXCP_NA_ITLB_MISS 16 /* non-access itlb miss */ +#define EXCP_NA_DTLB_MISS 17 /* non-access dtlb miss */ +#define EXCP_DMP 18 /* data memory protection trap */ +#define EXCP_DMB 19 /* data memory break trap */ +#define EXCP_TLB_DIRTY 20 /* tlb dirty bit trap */ +#define EXCP_PAGE_REF 21 /* page reference trap */ +#define EXCP_ASSIST_EMU 22 /* assist emulation trap */ +#define EXCP_HPT 23 /* high-privilege transfer trap */ +#define EXCP_LPT 24 /* low-privilege transfer trap */ +#define EXCP_TB 25 /* taken branch trap */ +#define EXCP_DMAR 26 /* data memory access rights trap */ +#define EXCP_DMPI 27 /* data memory protection id trap */ +#define EXCP_UNALIGN 28 /* unaligned data reference trap */ +#define EXCP_PER_INTERRUPT 29 /* performance monitor interrupt */ + +/* Exceptions for linux-user emulation. */ +#define EXCP_SYSCALL 30 +#define EXCP_SYSCALL_LWS 31 =20 /* Taken from Linux kernel: arch/parisc/include/asm/psw.h */ #define PSW_I 0x00000001 diff --git a/linux-user/main.c b/linux-user/main.c index 71696ed33d..93073e1997 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3761,21 +3761,41 @@ void cpu_loop(CPUHPPAState *env) env->iaoq_f =3D env->gr[31]; env->iaoq_b =3D env->gr[31] + 4; break; - case EXCP_SIGSEGV: + case EXCP_ITLB_MISS: + case EXCP_DTLB_MISS: + case EXCP_NA_ITLB_MISS: + case EXCP_NA_DTLB_MISS: + case EXCP_IMP: + case EXCP_DMP: + case EXCP_DMB: + case EXCP_PAGE_REF: + case EXCP_DMAR: + case EXCP_DMPI: info.si_signo =3D TARGET_SIGSEGV; info.si_errno =3D 0; info.si_code =3D TARGET_SEGV_ACCERR; info._sifields._sigfault._addr =3D env->ior; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; - case EXCP_SIGILL: + case EXCP_UNALIGN: + info.si_signo =3D TARGET_SIGBUS; + info.si_errno =3D 0; + info.si_code =3D 0; + info._sifields._sigfault._addr =3D env->ior; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + break; + case EXCP_ILL: + case EXCP_PRIV_OPR: + case EXCP_PRIV_REG: info.si_signo =3D TARGET_SIGILL; info.si_errno =3D 0; info.si_code =3D TARGET_ILL_ILLOPN; info._sifields._sigfault._addr =3D env->iaoq_f; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; - case EXCP_SIGFPE: + case EXCP_OVERFLOW: + case EXCP_COND: + case EXCP_ASSIST: info.si_signo =3D TARGET_SIGFPE; info.si_errno =3D 0; info.si_code =3D 0; diff --git a/target/hppa/helper.c b/target/hppa/helper.c index 4231ef3bff..6439179a0e 100644 --- a/target/hppa/helper.c +++ b/target/hppa/helper.c @@ -74,25 +74,52 @@ void hppa_cpu_do_interrupt(CPUState *cs) int i =3D cs->exception_index; =20 if (qemu_loglevel_mask(CPU_LOG_INT)) { + static const char * const names[] =3D { + [EXCP_HPMC] =3D "high priority machine check", + [EXCP_POWER_FAIL] =3D "power fail interrupt", + [EXCP_RC] =3D "recovery counter trap", + [EXCP_EXT_INTERRUPT] =3D "external interrupt", + [EXCP_LPMC] =3D "low priority machine check", + [EXCP_ITLB_MISS] =3D "instruction tlb miss fault", + [EXCP_IMP] =3D "instruction memory protection trap", + [EXCP_ILL] =3D "illegal instruction trap", + [EXCP_BREAK] =3D "break instruction trap", + [EXCP_PRIV_OPR] =3D "privileged operation trap", + [EXCP_PRIV_REG] =3D "privileged register trap", + [EXCP_OVERFLOW] =3D "overflow trap", + [EXCP_COND] =3D "conditional trap", + [EXCP_ASSIST] =3D "assist exception trap", + [EXCP_DTLB_MISS] =3D "data tlb miss fault", + [EXCP_NA_ITLB_MISS] =3D "non-access instruction tlb miss", + [EXCP_NA_DTLB_MISS] =3D "non-access data tlb miss", + [EXCP_DMP] =3D "data memory protection trap", + [EXCP_DMB] =3D "data memory break trap", + [EXCP_TLB_DIRTY] =3D "tlb dirty bit trap", + [EXCP_PAGE_REF] =3D "page reference trap", + [EXCP_ASSIST_EMU] =3D "assist emulation trap", + [EXCP_HPT] =3D "high-privilege transfer trap", + [EXCP_LPT] =3D "low-privilege transfer trap", + [EXCP_TB] =3D "taken branch trap", + [EXCP_DMAR] =3D "data memory access rights trap", + [EXCP_DMPI] =3D "data memory protection id trap", + [EXCP_UNALIGN] =3D "unaligned data reference trap", + [EXCP_PER_INTERRUPT] =3D "performance monitor interrupt", + [EXCP_SYSCALL] =3D "syscall", + [EXCP_SYSCALL_LWS] =3D "syscall-lws", + }; static int count; - const char *name =3D ""; - - switch (i) { - case EXCP_SYSCALL: - name =3D "syscall"; - break; - case EXCP_SIGSEGV: - name =3D "sigsegv"; - break; - case EXCP_SIGILL: - name =3D "sigill"; - break; - case EXCP_SIGFPE: - name =3D "sigfpe"; - break; + const char *name =3D NULL; + + if (i >=3D 0 && i < ARRAY_SIZE(names)) { + name =3D names[i]; + } + if (name) { + qemu_log("INT %6d: %s ia_f=3D" TARGET_FMT_lx "\n", + ++count, name, env->iaoq_f); + } else { + qemu_log("INT %6d: unknown %d ia_f=3D" TARGET_FMT_lx "\n", + ++count, i, env->iaoq_f); } - qemu_log("INT %6d: %s ia_f=3D" TARGET_FMT_lx "\n", - ++count, name, env->iaoq_f); } cs->exception_index =3D -1; } diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c index e0802bc935..2901f3e29c 100644 --- a/target/hppa/mem_helper.c +++ b/target/hppa/mem_helper.c @@ -29,7 +29,9 @@ int hppa_cpu_handle_mmu_fault(CPUState *cs, vaddr address, { HPPACPU *cpu =3D HPPA_CPU(cs); =20 - cs->exception_index =3D EXCP_SIGSEGV; + /* ??? Test between data page fault and data memory protection trap, + which would affect si_code. */ + cs->exception_index =3D EXCP_DMP; cpu->env.ior =3D address; return 1; } diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c index 9c7603588f..d6b86834c1 100644 --- a/target/hppa/op_helper.c +++ b/target/hppa/op_helper.c @@ -44,14 +44,14 @@ static void QEMU_NORETURN dynexcp(CPUHPPAState *env, in= t excp, uintptr_t ra) void HELPER(tsv)(CPUHPPAState *env, target_ulong cond) { if (unlikely((target_long)cond < 0)) { - dynexcp(env, EXCP_SIGFPE, GETPC()); + dynexcp(env, EXCP_OVERFLOW, GETPC()); } } =20 void HELPER(tcond)(CPUHPPAState *env, target_ulong cond) { if (unlikely(cond)) { - dynexcp(env, EXCP_SIGFPE, GETPC()); + dynexcp(env, EXCP_COND, GETPC()); } } =20 @@ -235,7 +235,7 @@ static void update_fr0_op(CPUHPPAState *env, uintptr_t = ra) env->fr[0] =3D (uint64_t)shadow << 32; =20 if (hard_exp & shadow) { - dynexcp(env, EXCP_SIGFPE, ra); + dynexcp(env, EXCP_ASSIST, ra); } } =20 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 8e357cc60c..8d85ed9df3 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -462,7 +462,7 @@ static DisasJumpType gen_excp(DisasContext *ctx, int ex= ception) static DisasJumpType gen_illegal(DisasContext *ctx) { nullify_over(ctx); - return nullify_end(ctx, gen_excp(ctx, EXCP_SIGILL)); + return nullify_end(ctx, gen_excp(ctx, EXCP_ILL)); } =20 static bool use_goto_tb(DisasContext *ctx, target_ulong dest) @@ -1578,7 +1578,7 @@ static DisasJumpType do_page_zero(DisasContext *ctx) =20 switch (ctx->iaoq_f) { case 0x00: /* Null pointer call */ - gen_excp_1(EXCP_SIGSEGV); + gen_excp_1(EXCP_IMP); return DISAS_NORETURN; =20 case 0xb0: /* LWS */ @@ -1597,7 +1597,7 @@ static DisasJumpType do_page_zero(DisasContext *ctx) =20 default: do_sigill: - gen_excp_1(EXCP_SIGILL); + gen_excp_1(EXCP_ILL); return DISAS_NORETURN; } } @@ -1614,7 +1614,7 @@ static DisasJumpType trans_break(DisasContext *ctx, u= int32_t insn, const DisasInsn *di) { nullify_over(ctx); - return nullify_end(ctx, gen_excp(ctx, EXCP_DEBUG)); + return nullify_end(ctx, gen_excp(ctx, EXCP_BREAK)); } =20 static DisasJumpType trans_sync(DisasContext *ctx, uint32_t insn, --=20 2.14.3