From patchwork Wed Feb 21 02:22:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 1901790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=Qa1qozLV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfg7s4CM9z23cl for ; Wed, 21 Feb 2024 13:24:09 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rccGJ-00033p-9J; Tue, 20 Feb 2024 21:23:07 -0500 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 1rccGH-000339-SE for qemu-devel@nongnu.org; Tue, 20 Feb 2024 21:23:05 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rccGG-0001Fk-8L for qemu-devel@nongnu.org; Tue, 20 Feb 2024 21:23:05 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6e459b39e2cso1936899b3a.1 for ; Tue, 20 Feb 2024 18:23:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1708482182; x=1709086982; 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=c06cdweMSPa1lLgHj48cX17VsakRjktLirNDmTiTsUo=; b=Qa1qozLVrPpNvT9f8NckECsWDFT7LgUB95vLlw1hg/XbCaxoWXdBJspd5dSAqP3ZlC 6N+4p8OAr4mZJBh3eMM+H8ARkcT2Npfw2s0rsZgL+0uXWxq20Hizck332MDFSkxqvlDW TNM/msvapnHmTB8G9izIgvtfYXdqTqrI0Rw39DlzZyE9QSRVxzzbOPsSEKFc/E0BXyXM RQMCTdPOXbzTEZ8rYuKJ+IbALX4mjyTT62GHofBWxRt9sZ77heghJ0JPreWyaeNybJZF 4Ev05YYdBYEilsYQcct/xi81VnEO5M52Kzfmk5iGeg+MXBMT3f5p/EgKRhJZtOny0B5A Fxlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708482182; x=1709086982; 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=c06cdweMSPa1lLgHj48cX17VsakRjktLirNDmTiTsUo=; b=NLqlAE347VincdqYdpSzKk/wstiX47Yp8b40fd+DnOune+EYEkdvJkyDLhLKq0+Vss 6TtYVuIRH/h3QDvzgjXIAIMIHSA1ZPVPuATS/LlIMpqDv03JM377O7m4v4oL6jYKNZs5 WhJQrizM2Ay4hPx6BNXDIB8k8oTfsecPHbHtMUfnPlEeFvagtlkl/Dkuy/kaEw9U4D+8 qGXv/LHt3QBkL0MF03QbYIVppqNHauIeoT3ACygbFQcmwI4kolCkc/wyAZvUqPudAvdh XoXTxufiY+2JEuPOQxhM0yt0mjtBVF70PSb81FTY5CV2SeINZtawqVNaPsRPh7BlPbdO As/g== X-Gm-Message-State: AOJu0Yy+61SvwQl5A9100OIZKFdqueB42WiFayIkSGh63rqOzRRWQd3A SW5z/7JE5QNzb1oFK76gKYzOAl2u68mpqhy3X7jubBoyJkOnwM+rXwaZ1d2fPNK5BSYs2ML65ZZ h X-Google-Smtp-Source: AGHT+IHqRKW6XfvwHdq8pSClVFfirIz/R/cz/fUiCSRSxqWgT+mC2Lo9YY+/0KmeXjpgVvVUmA6D5g== X-Received: by 2002:a05:6a21:3409:b0:19e:92cf:77f4 with SMTP id yn9-20020a056a21340900b0019e92cf77f4mr25651850pzb.0.1708482182587; Tue, 20 Feb 2024 18:23:02 -0800 (PST) Received: from grind.dc1.ventanamicro.com ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id y5-20020a634945000000b005dc48e56191sm7183355pgk.11.2024.02.20.18.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 18:23:02 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, richard.henderson@linaro.org, max.chou@sifive.com, Daniel Henrique Barboza Subject: [PATCH v5 1/7] trans_rvv.c.inc: mark_vs_dirty() before loads and stores Date: Tue, 20 Feb 2024 23:22:46 -0300 Message-ID: <20240221022252.252872-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221022252.252872-1-dbarboza@ventanamicro.com> References: <20240221022252.252872-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=dbarboza@ventanamicro.com; helo=mail-pf1-x431.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org While discussing a problem with how we're (not) setting vstart_eq_zero Richard had the following to say w.r.t the conditional mark_vs_dirty() calls on load/store functions [1]: "I think it's required to have stores set dirty unconditionally, before the operation. Consider a store that traps on the 2nd element, leaving vstart = 2, and exiting to the main loop via exception. The exception enters the kernel page fault handler. The kernel may need to fault in the page for the process, and in the meantime task switch. If vs dirty is not already set, the kernel won't know to save vector state on task switch." Do a mark_vs_dirty() before both loads and stores. [1] https://lore.kernel.org/qemu-riscv/72c7503b-0f43-44b8-aa82-fbafed2aac0c@linaro.org/ Suggested-by: Richard Henderson Signed-off-by: Daniel Henrique Barboza --- target/riscv/insn_trans/trans_rvv.c.inc | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index 9e101ab434..7a98f1caa6 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -636,11 +636,9 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, uint32_t data, tcg_gen_addi_ptr(dest, tcg_env, vreg_ofs(s, vd)); tcg_gen_addi_ptr(mask, tcg_env, vreg_ofs(s, 0)); - fn(dest, mask, base, tcg_env, desc); + mark_vs_dirty(s); - if (!is_store) { - mark_vs_dirty(s); - } + fn(dest, mask, base, tcg_env, desc); gen_set_label(over); return true; @@ -797,11 +795,9 @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs1, uint32_t rs2, tcg_gen_addi_ptr(dest, tcg_env, vreg_ofs(s, vd)); tcg_gen_addi_ptr(mask, tcg_env, vreg_ofs(s, 0)); - fn(dest, mask, base, stride, tcg_env, desc); + mark_vs_dirty(s); - if (!is_store) { - mark_vs_dirty(s); - } + fn(dest, mask, base, stride, tcg_env, desc); gen_set_label(over); return true; @@ -904,11 +900,9 @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1, uint32_t vs2, tcg_gen_addi_ptr(index, tcg_env, vreg_ofs(s, vs2)); tcg_gen_addi_ptr(mask, tcg_env, vreg_ofs(s, 0)); - fn(dest, mask, base, index, tcg_env, desc); + mark_vs_dirty(s); - if (!is_store) { - mark_vs_dirty(s); - } + fn(dest, mask, base, index, tcg_env, desc); gen_set_label(over); return true; @@ -1102,11 +1096,10 @@ static bool ldst_whole_trans(uint32_t vd, uint32_t rs1, uint32_t nf, base = get_gpr(s, rs1, EXT_NONE); tcg_gen_addi_ptr(dest, tcg_env, vreg_ofs(s, vd)); + mark_vs_dirty(s); + fn(dest, base, tcg_env, desc); - if (!is_store) { - mark_vs_dirty(s); - } gen_set_label(over); return true;