From patchwork Wed Oct 13 02:45:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 515706 Delivered-To: patch@linaro.org Received: by 2002:ac0:b5cc:0:0:0:0:0 with SMTP id x12csp6094476ime; Tue, 12 Oct 2021 20:13:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS2Ll06cnJ69bLgjLvpG/l2r7nCO6bdoCbBvFml0Qgx4DcjkcwlFUNcWy6fjLxAGMHNN+M X-Received: by 2002:a25:4607:: with SMTP id t7mr30466186yba.173.1634094809224; Tue, 12 Oct 2021 20:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634094809; cv=none; d=google.com; s=arc-20160816; b=mITf037b6rx/wSemsHUxWcjC1AXjDgjeNWyLDIsTmcDL2Z6FWSVU2SH/O4GJBjed74 qyvvl1uzQlLyb2pcKThrqJRTFD/0RIOI35r1nFlmwRPyHDryjQGwLDMeJI6fMgw10MFU X8H4XvowFKo/sbhVu0gEkqT3YDcgjik7PPDzS4oABzNvAXLO7UE4dJbQndXkHtflAH/f XbekRcp3XSXQbQyfP1ekGLxDmjJg/8hESLoag0SAPCU/d+oc8IgtvKdFSc87jnMbDe2m O7USNkHlcvL7JZZV7IvN26ofPPp9lqtwgGt+t8ZUmVvDw73eTZYj/56HqrnE7u9q9GE3 66xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=FDh0xRrxNKle4pRoEftfiIirEtPOD6rcCJZUiwu3wG8=; b=pcOeWHQnxpQjscD8xDljsnHEWb3lOEbBSIB3qCwEC4C/SuryJ58qaHIQ+TuGfZRv1Q 08WwfdYJrysguootI+zirWcjOvlCv3bbnMH0KE7p+qNr/67JFG0qksjOMT/34y3Iz5TD znPTR1OSA4FemL6ZP9AF8FmhAZgEQSauYl279lkWbKIZcR3t2mch8Ea5hsmZonbWWlgb k6oNgQp2QymqI+blcr4wcARbJxKc3Xj72PSzC3hVzQSAVTK92WVrWdq8r4wSPQm/uggo LScppQQE8GpbgVzAfJVxgrgVTV2DC4kSLAqAVzF8c2Vot4Y6kAHDegOizkBC2eY+F6Pd mtvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FZvQI+F+; 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 s4si14479456ybm.143.2021.10.12.20.13.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Oct 2021 20:13:29 -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=FZvQI+F+; 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]:33380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1maUhs-00073a-L9 for patch@linaro.org; Tue, 12 Oct 2021 23:13:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1maUI6-00052N-CT for qemu-devel@nongnu.org; Tue, 12 Oct 2021 22:46:50 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:39650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1maUI4-0005Er-OX for qemu-devel@nongnu.org; Tue, 12 Oct 2021 22:46:50 -0400 Received: by mail-pl1-x630.google.com with SMTP id c4so809552pls.6 for ; Tue, 12 Oct 2021 19:46:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FDh0xRrxNKle4pRoEftfiIirEtPOD6rcCJZUiwu3wG8=; b=FZvQI+F+Ljxp+PFFWKh+4ok6rngYX5aygLyoo2uRJHB4ByTZoEipvFmLEiJrTYjVU2 LkcVKAEM5GuSyfVjidpli1PJPCH/Te1jESpdov4WYEVvoM5ErtREitGuu67YmAQRYfCs w2yokpSBQNOYRUOMzVPSDvy/Z39modyxASZLgevEjB1aBVXYdA+1P0+csClRC7r8RQbk 3sjgvB+b5/wA3Dq4UpVb4tBjjSSqjJO5AsJSzzxVtgKxFPZWQtwhBp4tsZFjqNVXwCt+ SzcJM6dIbka3P6LzVKL6icRaC+MJNIyo0G5Jtigogf1sjmlDdkJ2nuDaRTGymnpI9m0d 2HXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FDh0xRrxNKle4pRoEftfiIirEtPOD6rcCJZUiwu3wG8=; b=dGn3ETQEb+4GU5b6slpc1BUjHRYvij2ND+/EUznxTBfgwFTLdmZns6t9xZZNV1Su0S kDT8FitzuxSNhQwxjfmDkeK6iOyv4RrCkR7iWszg7I/H6BNGF6QjTcqHOjjs+2OhbQS7 Ni4Akx1jdu9vRAbw77CLErdBR5IE2Xdh2GdOCWG8t2UebtsEflYX/TzBdJE6E/aEmEe5 NQjR63/O0nYPm/dvUm+f17/bka7kKhGn0eLfAvdXGcbkm3vjuUAMI6mK0JH5gMlI/5LR sImq1yO13s1iAnbScodXq8OFzpboXJDv5pdyqCHvx81MZgi4+wAYqPFveOwajZ05wdLz pYWg== X-Gm-Message-State: AOAM532zZu5ElLoN+HuHHognb8elwJ42PWFo1nhO3qTrTxONDrO68Fh3 KHS9ewXrHnLcl7B72tTvgj4TJuOuKVkQcw== X-Received: by 2002:a17:90b:3687:: with SMTP id mj7mr10599879pjb.196.1634093207309; Tue, 12 Oct 2021 19:46:47 -0700 (PDT) Received: from localhost.localdomain ([71.212.134.125]) by smtp.gmail.com with ESMTPSA id qe17sm4855014pjb.39.2021.10.12.19.46.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 19:46:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 38/48] target/hppa: Implement prctl_unalign_sigbus Date: Tue, 12 Oct 2021 19:45:57 -0700 Message-Id: <20211013024607.731881-39-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::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Leave TARGET_ALIGNED_ONLY set, but use the new CPUState flag to set MO_UNALN for the instructions that the kernel handles in the unaligned trap. Signed-off-by: Richard Henderson --- linux-user/hppa/target_prctl.h | 2 +- target/hppa/cpu.h | 5 ++++- target/hppa/translate.c | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/linux-user/hppa/target_prctl.h b/linux-user/hppa/target_prctl.h index eb53b31ad5..5629ddbf39 100644 --- a/linux-user/hppa/target_prctl.h +++ b/linux-user/hppa/target_prctl.h @@ -1 +1 @@ -/* No special prctl support required. */ +#include "../generic/target_prctl_unalign.h" diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 294fd7297f..45fd338b02 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -259,12 +259,14 @@ static inline target_ulong hppa_form_gva(CPUHPPAState *env, uint64_t spc, return hppa_form_gva_psw(env->psw, spc, off); } -/* Since PSW_{I,CB} will never need to be in tb->flags, reuse them. +/* + * Since PSW_{I,CB} will never need to be in tb->flags, reuse them. * TB_FLAG_SR_SAME indicates that SR4 through SR7 all contain the * same value. */ #define TB_FLAG_SR_SAME PSW_I #define TB_FLAG_PRIV_SHIFT 8 +#define TB_FLAG_UNALIGN 0x400 static inline void cpu_get_tb_cpu_state(CPUHPPAState *env, target_ulong *pc, target_ulong *cs_base, @@ -279,6 +281,7 @@ static inline void cpu_get_tb_cpu_state(CPUHPPAState *env, target_ulong *pc, #ifdef CONFIG_USER_ONLY *pc = env->iaoq_f & -4; *cs_base = env->iaoq_b & -4; + flags |= TB_FLAG_UNALIGN * !env_cpu(env)->prctl_unalign_sigbus; #else /* ??? E, T, H, L, B, P bits need to be here, when implemented. */ flags |= env->psw & (PSW_W | PSW_C | PSW_D); diff --git a/target/hppa/translate.c b/target/hppa/translate.c index c3698cf067..fdaa2b12b8 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -272,8 +272,18 @@ typedef struct DisasContext { int mmu_idx; int privilege; bool psw_n_nonzero; + +#ifdef CONFIG_USER_ONLY + MemOp unalign; +#endif } DisasContext; +#ifdef CONFIG_USER_ONLY +#define UNALIGN(C) (C)->unalign +#else +#define UNALIGN(C) 0 +#endif + /* Note that ssm/rsm instructions number PSW_W and PSW_E differently. */ static int expand_sm_imm(DisasContext *ctx, int val) { @@ -1477,7 +1487,7 @@ static void do_load_32(DisasContext *ctx, TCGv_i32 dest, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_ld_reg(dest, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_ld_reg(dest, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -1495,7 +1505,7 @@ static void do_load_64(DisasContext *ctx, TCGv_i64 dest, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_ld_i64(dest, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_ld_i64(dest, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -1513,7 +1523,7 @@ static void do_store_32(DisasContext *ctx, TCGv_i32 src, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_st_i32(src, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_st_i32(src, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -1531,7 +1541,7 @@ static void do_store_64(DisasContext *ctx, TCGv_i64 src, unsigned rb, form_gva(ctx, &addr, &ofs, rb, rx, scale, disp, sp, modify, ctx->mmu_idx == MMU_PHYS_IDX); - tcg_gen_qemu_st_i64(src, addr, ctx->mmu_idx, mop); + tcg_gen_qemu_st_i64(src, addr, ctx->mmu_idx, mop | UNALIGN(ctx)); if (modify) { save_gpr(ctx, rb, ofs); } @@ -4110,6 +4120,7 @@ static void hppa_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->mmu_idx = MMU_USER_IDX; ctx->iaoq_f = ctx->base.pc_first | MMU_USER_IDX; ctx->iaoq_b = ctx->base.tb->cs_base | MMU_USER_IDX; + ctx->unalign = (ctx->tb_flags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN); #else ctx->privilege = (ctx->tb_flags >> TB_FLAG_PRIV_SHIFT) & 3; ctx->mmu_idx = (ctx->tb_flags & PSW_D ? ctx->privilege : MMU_PHYS_IDX);