From nobody Sun Nov 24 14:48:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1722925645; cv=none; d=zohomail.com; s=zohoarc; b=BA428XuVmaM5TEKr/SI+qWbpXrBuSaT7BXwxcKrA0ttPlfNodk+rb1aP9ShTk5I6YnOWxELRXKORui9iOhvErVjAoZToHSK125+CCUnz9fSXdOSHQaIKbO918Fsn7pxj6aZ/I28GwyFcpgPvD+putZ9tFPt7t/ndeKAVN47d4mk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722925645; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OTX/GHXUmXFh0D4AEM8ZY3l4zU6LP3K0z3O3UyAfsjo=; b=iLZJqtLqQO7SxpbipfI0qrx+VtzODJ5bOd6PRWa+jlMwqORdA/hcbPE4FQEj9UPWkjVw6Gxf0KmN3KYyUF1uNLU1cuHGFYarf2WdJDqnJQBp9CqJf5j5VVncwT4gqtW2c7+T40aUzwSB7A/l7P9M/0SPUMd2t2ni6KJRutsZ8so= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722925645877639.470470577184; Mon, 5 Aug 2024 23:27:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sbDe6-0003Lg-Kb; Tue, 06 Aug 2024 02:26:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sbDe4-0003H3-UU for qemu-devel@nongnu.org; Tue, 06 Aug 2024 02:26:08 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sbDe3-0003xF-3t for qemu-devel@nongnu.org; Tue, 06 Aug 2024 02:26:08 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1fd640a6454so1766075ad.3 for ; Mon, 05 Aug 2024 23:26:06 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ff5927f161sm79464975ad.232.2024.08.05.23.26.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 23:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722925565; x=1723530365; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OTX/GHXUmXFh0D4AEM8ZY3l4zU6LP3K0z3O3UyAfsjo=; b=DXUJkiskpBzfwoGnMlRgOFv1sX+Vy0aVpyJtXbC25dqyE7ibhI1icf2b5Ga+cjt0Cr yllI1lyUzbtA6Y+2NQLnrPRkE450+k9IhYeRLnIHqkznPEXCaucEAbxKVyc4FJ1FI+ji sVC6TUk8qy7UUzq1POUjRB9rqyE8D4ZAn/rXt7U207/9eHinAWzDboHaWtKuoeXqRry4 Om80/DrYpufEZC53tP5fPKEf+oVdiX+e3Q+1PlEHpTgxcVZNAiAQEhfwmVH4euuO24Lx ydwSdianQXmN/JRkfM3HfzWkU+OT5mq1jejPROWiOLmTm+UJB0N+43GwD4E4Bn2SC/Bw /RIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722925565; x=1723530365; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OTX/GHXUmXFh0D4AEM8ZY3l4zU6LP3K0z3O3UyAfsjo=; b=wZRIe/UlQKlqmg+g5JjfM8qeZV5FSQ9IgNBmIQPyJa7DPjvn+DNINDxSvHLLCx/xQr 0qOb0HmEv55lkHG3mO8H/tAQZFFIArp9uJNIqE2z5FfopEbZ091XgE+ySY1AghTZQGuL OENSE+NzLTvTEFCelzC3BzMEijF12UZuFVieWRODMJSgG5sa8bkTaP/XXVEs2HhMqrEf PzcZHyy4EIrGN67l7/7vZONpEF6dygGkoCZEUC+M670tSNGqlXcPKjsTPFyWyLUCMOad jC4H+4pUylxI7TJB5NhKQkg8hZUmPcwWH4hMgbD7GeqeX5grNy6EBQJG+3xynG6vM1k4 DEaA== X-Gm-Message-State: AOJu0Yyy5uU+Oui31TAIu7BEWaShpJz5ORp/gjKWiH1/qZLDlwrHdePO Ieov2fK//148gfIDLL03lBPfYMYzukFzV9JNYop9r3avFVIlPM/4q4+eNIup X-Google-Smtp-Source: AGHT+IF5Pl8s81U4n/WjooUF8w3HVO5+U4CDYPQsgS7HIJmcv4isCuQj5MMesKX9GIfrsx177CDIqw== X-Received: by 2002:a17:903:110f:b0:1fb:8e00:e5e8 with SMTP id d9443c01a7336-1ff5727cff6mr152124725ad.10.1722925564932; Mon, 05 Aug 2024 23:26:04 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Alistair Francis , Richard Henderson Subject: [PULL 3/5] target/riscv: Relax fld alignment requirement Date: Tue, 6 Aug 2024 16:25:43 +1000 Message-ID: <20240806062545.1250910-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806062545.1250910-1-alistair.francis@wdc.com> References: <20240806062545.1250910-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=alistair23@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1722925647819116600 From: LIU Zhiwei According to the risc-v specification: "FLD and FSD are only guaranteed to execute atomically if the effective address is naturally aligned and XLEN=E2=89=A564." We currently implement fld as MO_ATOM_IFALIGN when XLEN < 64, which does not violate the rules. But it will hide some problems. So relax it to MO_ATOM_NONE. Signed-off-by: LIU Zhiwei Reviewed-by: Alistair Francis Reviewed-by: Richard Henderson Message-ID: <20240802072417.659-4-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvd.c.inc | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvd.c.inc b/target/riscv/insn_tr= ans/trans_rvd.c.inc index 49682292b8..8a46124f98 100644 --- a/target/riscv/insn_trans/trans_rvd.c.inc +++ b/target/riscv/insn_trans/trans_rvd.c.inc @@ -48,11 +48,17 @@ static bool trans_fld(DisasContext *ctx, arg_fld *a) REQUIRE_EXT(ctx, RVD); =20 /* - * Zama16b applies to loads and stores of no more than MXLEN bits defi= ned - * in the F, D, and Q extensions. + * FLD and FSD are only guaranteed to execute atomically if the effect= ive + * address is naturally aligned and XLEN=E2=89=A564. Also, zama16b app= lies to + * loads and stores of no more than MXLEN bits defined in the F, D, and + * Q extensions. */ - if ((get_xl_max(ctx) >=3D MXL_RV64) && ctx->cfg_ptr->ext_zama16b) { + if (get_xl_max(ctx) =3D=3D MXL_RV32) { + memop |=3D MO_ATOM_NONE; + } else if (ctx->cfg_ptr->ext_zama16b) { memop |=3D MO_ATOM_WITHIN16; + } else { + memop |=3D MO_ATOM_IFALIGN; } =20 decode_save_opc(ctx); @@ -71,8 +77,12 @@ static bool trans_fsd(DisasContext *ctx, arg_fsd *a) REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); =20 - if ((get_xl_max(ctx) >=3D MXL_RV64) && ctx->cfg_ptr->ext_zama16b) { + if (get_xl_max(ctx) =3D=3D MXL_RV32) { + memop |=3D MO_ATOM_NONE; + } else if (ctx->cfg_ptr->ext_zama16b) { memop |=3D MO_ATOM_WITHIN16; + } else { + memop |=3D MO_ATOM_IFALIGN; } =20 decode_save_opc(ctx); --=20 2.45.2