From patchwork Fri Jan 15 21:28:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artyom Tarasenko X-Patchwork-Id: 42997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D6F721007D2 for ; Sat, 16 Jan 2010 08:32:33 +1100 (EST) Received: from localhost ([127.0.0.1]:53085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVtkN-0001vu-UX for incoming@patchwork.ozlabs.org; Fri, 15 Jan 2010 16:30:23 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NVtj6-0001s9-HW for qemu-devel@nongnu.org; Fri, 15 Jan 2010 16:29:04 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NVtj3-0001qm-13 for qemu-devel@nongnu.org; Fri, 15 Jan 2010 16:29:04 -0500 Received: from [199.232.76.173] (port=60230 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NVtj2-0001qg-OQ for qemu-devel@nongnu.org; Fri, 15 Jan 2010 16:29:00 -0500 Received: from mail-fx0-f222.google.com ([209.85.220.222]:53814) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NVtj2-0000uh-DU for qemu-devel@nongnu.org; Fri, 15 Jan 2010 16:29:00 -0500 Received: by fxm22 with SMTP id 22so720124fxm.2 for ; Fri, 15 Jan 2010 13:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=eVXWN2mS/bAijfd+y+3DycKEhNY5UUpAwsywU2AU62Y=; b=xSbdmcTDfyRSMgZKl99lK7usCuZ41gsgYBP7AisTfZGNs64YFOK9z0r8KF9rB93/PU gwrSMY06Y2EyPgiLudvisgrvFeUeg4CJG754hWG48jdMkpxoCgYTwZ+xmBZw44RoBgfB mxgbqPj02AjzcRtr+ViTnF97jmPksM0X66KWU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Wtgfn+VAgng3lB+kgPCIjQR3wFRLu6L8KxLOsZsGpqi8xUPjt/93rCnaL216U2l574 REpdN/r8U8FUHGt9wrVkP4/pD7itEKt12TPhAkvbqELUOxMCcJpRe5uZ/jn8gsT+7hdJ ohnLKsDx/nPzSyHOFE2obLt2eHgiH+0GWXJ+Y= Received: by 10.223.145.133 with SMTP id d5mr3245297fav.57.1263590939132; Fri, 15 Jan 2010 13:28:59 -0800 (PST) Received: from localhost (e181210186.adsl.alicedsl.de [85.181.210.186]) by mx.google.com with ESMTPS id z10sm3054649fka.0.2010.01.15.13.28.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 15 Jan 2010 13:28:58 -0800 (PST) From: Artyom Tarasenko To: qemu-devel@nongnu.org Date: Fri, 15 Jan 2010 22:28:56 +0100 Message-Id: <1263590936-17505-1-git-send-email-atar4qemu@google.com> X-Mailer: git-send-email 1.6.2.5 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Blue Swirl , Artyom Tarasenko Subject: [Qemu-devel] sparc32 do_unassigned_access overhaul v2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org According to pages 9-31 - 9-34 of "SuperSPARC & MultiCache Controller User's Manual": 1. "A lower priority fault may not overwrite the MFSR status of a higher priority fault." 2. The MFAR is overwritten according to the policy defined for the MFSR 3. The overwrite bit is asserted if the fault status register (MFSR) has been written more than once by faults of the same class 4. SuperSPARC will never place instruction fault addresses in the MFAR. Implementation of points 1-3 allows booting Solaris 2.6 and 2.5.1. v2: CODING_STYLE fixes Signed-off-by: Artyom Tarasenko diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c index 381e6c4..3ff35d3 100644 --- a/target-sparc/op_helper.c +++ b/target-sparc/op_helper.c @@ -3714,6 +3714,7 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, int is_asi, int size) { CPUState *saved_env; + int fault_type; /* XXX: hack to restore env in all cases, even if not called from generated code */ @@ -3731,18 +3732,29 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, is_exec ? "exec" : is_write ? "write" : "read", size, size == 1 ? "" : "s", addr, env->pc); #endif - if (env->mmuregs[3]) /* Fault status register */ - env->mmuregs[3] = 1; /* overflow (not read before another fault) */ - if (is_asi) - env->mmuregs[3] |= 1 << 16; - if (env->psrs) - env->mmuregs[3] |= 1 << 5; - if (is_exec) - env->mmuregs[3] |= 1 << 6; - if (is_write) - env->mmuregs[3] |= 1 << 7; - env->mmuregs[3] |= (5 << 2) | 2; - env->mmuregs[4] = addr; /* Fault address register */ + /* Don't overwrite translation and access faults */ + fault_type = (env->mmuregs[3] & 0x1c) >> 2; + if ((fault_type > 4) || (fault_type == 0)) { + env->mmuregs[3] = 0; /* Fault status register */ + if (is_asi) + env->mmuregs[3] |= 1 << 16; + if (env->psrs) + env->mmuregs[3] |= 1 << 5; + if (is_exec) + env->mmuregs[3] |= 1 << 6; + if (is_write) + env->mmuregs[3] |= 1 << 7; + env->mmuregs[3] |= (5 << 2) | 2; + /* SuperSPARC will never place instruction fault addresses in the FAR */ + if (!is_exec) { + env->mmuregs[4] = addr; /* Fault address register */ + } + } + /* overflow (same type fault was not read before another fault) */ + if (fault_type == ((env->mmuregs[3] & 0x1c)) >> 2) { + env->mmuregs[3] |= 1; + } + if ((env->mmuregs[0] & MMU_E) && !(env->mmuregs[0] & MMU_NF)) { if (is_exec) raise_exception(TT_CODE_ACCESS); @@ -3750,6 +3762,12 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, raise_exception(TT_DATA_ACCESS); } env = saved_env; + + /* flush neverland mappings created during no-fault mode, + so the sequential MMU faults report proper fault types */ + if (env->mmuregs[0] & MMU_NF) { + tlb_flush(env, 1); + } } #else void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,