From patchwork Thu Apr 28 20:50:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 93300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A4697B6F5F for ; Fri, 29 Apr 2011 06:52:13 +1000 (EST) Received: from localhost ([::1]:44738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFYC2-0005Ad-T3 for incoming@patchwork.ozlabs.org; Thu, 28 Apr 2011 16:52:10 -0400 Received: from eggs.gnu.org ([140.186.70.92]:47751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFYBT-00054r-8U for qemu-devel@nongnu.org; Thu, 28 Apr 2011 16:51:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFYBS-0005aE-3z for qemu-devel@nongnu.org; Thu, 28 Apr 2011 16:51:35 -0400 Received: from mail-px0-f179.google.com ([209.85.212.179]:58851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFYBR-0005Xi-SJ for qemu-devel@nongnu.org; Thu, 28 Apr 2011 16:51:34 -0400 Received: by mail-px0-f179.google.com with SMTP id 2so298049pxi.10 for ; Thu, 28 Apr 2011 13:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:to:subject:date:message-id:x-mailer :in-reply-to:references; bh=d51qxRyQ+wy6Sgx73eKfTnms9R75ziCfwaWiyZBGT1M=; b=nh81HgmCJDYUysrKx8ikrCBrJfHfnuMF8hfIbMl4LI/d/N1Wj9NaCsJmP8JJ3sEudR vn5zdNxSS3RALO2zUAddKo8hx453U44CnkOmHXqbOZr007xmQEKwdUkPoWrBYHDB8YoC Q1IGhlv/FL/BbccR/sbtzftYEWpL42iyTEols= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; b=V5Y/wMY5mTYPXE6HWY1O1FOH2YPPMM9qIdwL9vtUS5f9GW/ZbIFj0wp0N5h1JgCCUD gAv5T1Gl9WKKIdO2QEc5RgT+BZzIgX7+G5D0CUKo+owbDHrnM/68s26o5O1VCJ9nJ2IG iC4lVVeTiW875Am18a0OW6y7NHg60FPmBGiBw= Received: by 10.143.177.5 with SMTP id e5mr1325045wfp.50.1304023893421; Thu, 28 Apr 2011 13:51:33 -0700 (PDT) Received: from localhost.localdomain (are.twiddle.net [75.101.38.216]) by mx.google.com with ESMTPS id z10sm2266797wfj.12.2011.04.28.13.51.32 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Apr 2011 13:51:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Apr 2011 13:50:50 -0700 Message-Id: <1304023875-25040-9-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1304023875-25040-1-git-send-email-rth@twiddle.net> References: <1304023875-25040-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.212.179 Subject: [Qemu-devel] [PATCH 08/33] target-alpha: Tidy exception constants. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There's no need to attempt to match EXCP_* values with PALcode entry point offsets. Instead, compress all the values to make for more efficient switch statements within QEMU. We will be doing TLB fill within QEMU proper, not within the PALcode, so all of the ITB/DTB miss, double fault, and access exceptions can be compressed to EXCP_MMFAULT. Compress all of the EXCP_CALL_PAL exceptions into one. Use env->error_code to store the specific entry point. --- linux-user/main.c | 44 ++++++++++++++------------------------------ target-alpha/cpu.h | 34 ++++++++++++++-------------------- target-alpha/helper.c | 6 +----- target-alpha/translate.c | 4 ++-- 4 files changed, 31 insertions(+), 57 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index a1e37e4..2a29088 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2526,19 +2526,13 @@ void cpu_loop (CPUState *env) fprintf(stderr, "Machine check exception. Exit\n"); exit(1); break; - case EXCP_ARITH: - env->lock_addr = -1; - info.si_signo = TARGET_SIGFPE; - info.si_errno = 0; - info.si_code = TARGET_FPE_FLTINV; - info._sifields._sigfault._addr = env->pc; - queue_signal(env, info.si_signo, &info); - break; - case EXCP_HW_INTERRUPT: + case EXCP_SMP_INTERRUPT: + case EXCP_CLK_INTERRUPT: + case EXCP_DEV_INTERRUPT: fprintf(stderr, "External interrupt. Exit\n"); exit(1); break; - case EXCP_DFAULT: + case EXCP_MMFAULT: env->lock_addr = -1; info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; @@ -2547,22 +2541,6 @@ void cpu_loop (CPUState *env) info._sifields._sigfault._addr = env->ipr[IPR_EXC_ADDR]; queue_signal(env, info.si_signo, &info); break; - case EXCP_DTB_MISS_PAL: - fprintf(stderr, "MMU data TLB miss in PALcode\n"); - exit(1); - break; - case EXCP_ITB_MISS: - fprintf(stderr, "MMU instruction TLB miss\n"); - exit(1); - break; - case EXCP_ITB_ACV: - fprintf(stderr, "MMU instruction access violation\n"); - exit(1); - break; - case EXCP_DTB_MISS_NATIVE: - fprintf(stderr, "MMU data TLB miss\n"); - exit(1); - break; case EXCP_UNALIGN: env->lock_addr = -1; info.si_signo = TARGET_SIGBUS; @@ -2580,12 +2558,20 @@ void cpu_loop (CPUState *env) info._sifields._sigfault._addr = env->pc; queue_signal(env, info.si_signo, &info); break; + case EXCP_ARITH: + env->lock_addr = -1; + info.si_signo = TARGET_SIGFPE; + info.si_errno = 0; + info.si_code = TARGET_FPE_FLTINV; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, &info); + break; case EXCP_FEN: /* No-op. Linux simply re-enables the FPU. */ break; - case EXCP_CALL_PAL ... (EXCP_CALL_PALP - 1): + case EXCP_CALL_PAL: env->lock_addr = -1; - switch ((trapnr >> 6) | 0x80) { + switch (env->error_code) { case 0x80: /* BPT */ info.si_signo = TARGET_SIGTRAP; @@ -2676,8 +2662,6 @@ void cpu_loop (CPUState *env) goto do_sigill; } break; - case EXCP_CALL_PALP ... (EXCP_CALL_PALE - 1): - goto do_sigill; case EXCP_DEBUG: info.si_signo = gdb_handlesig (env, TARGET_SIGTRAP); if (info.si_signo) { diff --git a/target-alpha/cpu.h b/target-alpha/cpu.h index 0daa556..8c73d5d 100644 --- a/target-alpha/cpu.h +++ b/target-alpha/cpu.h @@ -391,26 +391,20 @@ enum { }; enum { - EXCP_RESET = 0x0000, - EXCP_MCHK = 0x0020, - EXCP_ARITH = 0x0060, - EXCP_HW_INTERRUPT = 0x00E0, - EXCP_DFAULT = 0x01E0, - EXCP_DTB_MISS_PAL = 0x09E0, - EXCP_ITB_MISS = 0x03E0, - EXCP_ITB_ACV = 0x07E0, - EXCP_DTB_MISS_NATIVE = 0x08E0, - EXCP_UNALIGN = 0x11E0, - EXCP_OPCDEC = 0x13E0, - EXCP_FEN = 0x17E0, - EXCP_CALL_PAL = 0x2000, - EXCP_CALL_PALP = 0x3000, - EXCP_CALL_PALE = 0x4000, - /* Pseudo exception for console */ - EXCP_CONSOLE_DISPATCH = 0x4001, - EXCP_CONSOLE_FIXUP = 0x4002, - EXCP_STL_C = 0x4003, - EXCP_STQ_C = 0x4004, + EXCP_RESET, + EXCP_MCHK, + EXCP_SMP_INTERRUPT, + EXCP_CLK_INTERRUPT, + EXCP_DEV_INTERRUPT, + EXCP_MMFAULT, + EXCP_UNALIGN, + EXCP_OPCDEC, + EXCP_ARITH, + EXCP_FEN, + EXCP_CALL_PAL, + /* For Usermode emulation. */ + EXCP_STL_C, + EXCP_STQ_C, }; /* Arithmetic exception */ diff --git a/target-alpha/helper.c b/target-alpha/helper.c index f7cf4ee..676c870 100644 --- a/target-alpha/helper.c +++ b/target-alpha/helper.c @@ -164,12 +164,8 @@ void cpu_alpha_store_fpcr (CPUState *env, uint64_t val) int cpu_alpha_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) { - if (rw == 2) - env->exception_index = EXCP_ITB_MISS; - else - env->exception_index = EXCP_DFAULT; + env->exception_index = EXCP_MMFAULT; env->ipr[IPR_EXC_ADDR] = address; - return 1; } diff --git a/target-alpha/translate.c b/target-alpha/translate.c index c9fd16f..63a0321 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -1516,7 +1516,7 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) #endif if (palcode >= 0x80 && palcode < 0xC0) { /* Unprivileged PAL call */ - ret = gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x3F) << 6), 0); + ret = gen_excp(ctx, EXCP_CALL_PAL, palcode & 0xBF); break; } #ifndef CONFIG_USER_ONLY @@ -1524,7 +1524,7 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) /* Privileged PAL code */ if (ctx->mem_idx & 1) goto invalid_opc; - ret = gen_excp(ctx, EXCP_CALL_PALP + ((palcode & 0x3F) << 6), 0); + ret = gen_excp(ctx, EXCP_CALL_PAL, palcode & 0x3F); } #endif /* Invalid PAL call */