From patchwork Wed Oct 13 02:45:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515682 Delivered-To: patch@linaro.org Received: by 2002:ac0:b5cc:0:0:0:0:0 with SMTP id x12csp6082955ime; Tue, 12 Oct 2021 19:54:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztDbayLI+AdMbnku/hyBclfMJRolTLE2N4uxiSE2qRTq4ZTYcqIxVaO82KUPCE+eXthYwA X-Received: by 2002:a37:44ca:: with SMTP id r193mr23013157qka.190.1634093656804; Tue, 12 Oct 2021 19:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634093656; cv=none; d=google.com; s=arc-20160816; b=wLCugvOz8y8jJ303rVF/zFe5pSkqXqnsKCxjPfbs3Gfb+iP7v4WZ3a0JkXbSgVwIG0 4hRrkaB9Eslf9hyFnhYwdOIHlRXInnFZIKeo58VQVQcFenVYhq0d2W7l3xSeK8Vfbnom ngKU4J1BokRDWebxhJ6v6Ftz4p+8PCWvhtMHFdkmPdnncVyZkvzo+ZjyuTQGPF7r0673 lNHcepGZ2QxemovbI3E/JTp86a07AQnu8ZnYdbihaP4U9ywnhJAyPovzY3O+UhyytSwt QaRz6KWzVHfLM/6r6gVYS2fIb+T/3aV5nzGehYBzhXXdpH8bibwrmc/T4xwsVyPnCIf4 eOUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=54O7y5F6cil48JbVjJeuP4tBSWG4MHFPBxntrZflWpI=; b=dmY8oZ50MdEBCmBCux7u/Nm+2tHSAZj/XVskCo8KO+/WBb73D6zmWbxJJWjBDnHbpj 8OB2I8CFb5ae2MWyoIyLS9Pi7ngMZLivYFC2I1ApreXi07S2uKf90m58oBSujV0INZ98 4D5vyrz6syKkHL6iMTpRAtmBgaudQcCP1vWHI2OhHTC205nT7aBfQ83u/f42PgAV4V0S BmNAedd5ymdT0brLcK9m6lSfyRoEWif+I+Vb6ib8KvxUNOlB+qpUnZA6jclRaqyw4Ebl VZEz9FF7WNDWZ4Q+PQyAjh8yWPI/UHenbw1XSyJuo1GFiq4K1zGKGKXBD2YOsYE7IMJe wF/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lv3YyLQx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u14si7718319qvv.87.2021.10.12.19.54.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Oct 2021 19:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lv3YyLQx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maUPI-0004jK-8d for patch@linaro.org; Tue, 12 Oct 2021 22:54:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maUHb-0004DA-Mu for qemu-devel@nongnu.org; Tue, 12 Oct 2021 22:46:20 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:38436) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maUHa-0004nM-0k for qemu-devel@nongnu.org; Tue, 12 Oct 2021 22:46:19 -0400 Received: by mail-pf1-x42e.google.com with SMTP id k26so1157625pfi.5 for ; Tue, 12 Oct 2021 19:46:17 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=54O7y5F6cil48JbVjJeuP4tBSWG4MHFPBxntrZflWpI=; b=lv3YyLQxLme3vKyGGKEiCQFJ+bMDhfxALse0U4TYuoIdTxOE7xWwUmWiT5Z+HSaY0M QFd5NHl0HAE/rNR8Jt/pMVujOVJHixUA3qejy87L6KuQQaqt0Uh8+yJ2r4eaO7ELTZSq ziZpgzp5AaBoNoNvqbFI3Gsb87f0p8NmMADbfKdJkMzY45hGITkRAXqXJPaa2BUnbxD+ pzN2f3S+yJ5k39XOpOIZhfjF4XJOwx/sFa8QpaAS0Gugh9lHM3vIMgwL/iHYjS25qhXg P9KQDJelKmExullvomy8eff9qWj9Zz0q/rrSxB/ll3etagUK5IdwlJ34ydot2SJNPCuf hY7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=54O7y5F6cil48JbVjJeuP4tBSWG4MHFPBxntrZflWpI=; b=v1jO3XJaJKnYYmVL3sp3BqVn/+fKZHfq6I9qafx2qNbiELIqaLoczOXaDTzX5vfQm6 ekpJi+weDv88FgNuEiH5zxMFHLPQtY08D8zziuUD4ZJcyWPUKtEtjeShMgd9w65xmZcU cm1WoyOxMTpkpAIRMfjA7AS5hR8qhuQvaRXAhTgslmGPMe2topFz0OIgqMpjv280hsxf 6kdtpbazvxhyoEIw3JCtj+FxPI3e2b/4Km2GY7E6C/ArAdFm4wfahLGtwYs8Lz1zdGqd proPR011abo1BdrawM20jDSTDUQnuxrXUaVvtXpQOKdT2PicJ8r4pVhng5K0MN7qxYZI QydA== X-Gm-Message-State: AOAM532FhDcY+BOnSZ4t/f6Fq6MvHrEnjWZM11rQ/mKcvyYk2OTeEdMS u0SkcdFfCdt7UcUjv4QV37dk45FTzes7gg== X-Received: by 2002:a63:f145:: with SMTP id o5mr25793340pgk.273.1634093176605; Tue, 12 Oct 2021 19:46:16 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id qe17sm4855014pjb.39.2021.10.12.19.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 19:46:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 07/48] target/ppc: Move SPR_DSISR setting to powerpc_excp Date: Tue, 12 Oct 2021 19:45:26 -0700 Message-Id: <20211013024607.731881-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211013024607.731881-1-richard.henderson@linaro.org> References: <20211013024607.731881-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" By doing this while sending the exception, we will have already done the unwinding, which makes the ppc_cpu_do_unaligned_access code a bit cleaner. Update the comment about the expected instruction format. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/ppc/excp_helper.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) -- 2.25.1 diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index b7d1767920..88a8de4b80 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -454,13 +454,15 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp) break; } case POWERPC_EXCP_ALIGN: /* Alignment exception */ - /* Get rS/rD and rA from faulting opcode */ /* - * Note: the opcode fields will not be set properly for a - * direct store load/store, but nobody cares as nobody - * actually uses direct store segments. + * Get rS/rD and rA from faulting opcode. + * Note: We will only invoke ALIGN for atomic operations, + * so all instructions are X-form. */ - env->spr[SPR_DSISR] |= (env->error_code & 0x03FF0000) >> 16; + { + uint32_t insn = cpu_ldl_code(env, env->nip); + env->spr[SPR_DSISR] |= (insn & 0x03FF0000) >> 16; + } break; case POWERPC_EXCP_PROGRAM: /* Program exception */ switch (env->error_code & ~0xF) { @@ -1462,14 +1464,9 @@ void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, int mmu_idx, uintptr_t retaddr) { CPUPPCState *env = cs->env_ptr; - uint32_t insn; - - /* Restore state and reload the insn we executed, for filling in DSISR. */ - cpu_restore_state(cs, retaddr, true); - insn = cpu_ldl_code(env, env->nip); cs->exception_index = POWERPC_EXCP_ALIGN; - env->error_code = insn & 0x03FF0000; - cpu_loop_exit(cs); + env->error_code = 0; + cpu_loop_exit_restore(cs, retaddr); } #endif