From patchwork Tue Jul 23 03:34:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 813932 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2141520wro; Mon, 22 Jul 2024 20:36:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVR5KmmvzgkRiXMZK7EnEZGrXY2Mt4CL3NqbaUoKk9Bu62zhYTb4Z8hCGN72dhpSIaz858UBQX5WwY651s6FYTL X-Google-Smtp-Source: AGHT+IG5yvfugEO6agw10Fag/115+oj8IYSIUzsR1N9LdivNxfIbmtsRdMWjbmmQh8E9Y4Uy7PuM X-Received: by 2002:a05:6102:8086:b0:493:b9ae:3208 with SMTP id ada2fe7eead31-493b9ae35demr274756137.24.1721705798452; Mon, 22 Jul 2024 20:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721705798; cv=none; d=google.com; s=arc-20160816; b=S3jg8WmFu59gJFKG8ybVIdI7ubxCTjYbBCqRhpRzPWGp3F2V0MGxszmAtTjU/3o0VM wzuvHGzeRt2UUSpTrH1ajwAcxh+vgYnNNLCaiW0JXywNQBGRaXZDjxTUr8NfRGV7XMG9 mq0mgkiWx+1SbotH9c0Gvvars216C3PSc2WB4f+XgcFGfj2u/UK3SINccG/8Qkac88Zi SaZnx9V9dNU/eEi6ZnbVK1Owra9ibBktbEay3X8GFR3HnUIZ8h8QRA8ciRj/9tRjwpNr K1iGp4Su1B6SFDZL1r821WbTkJbHnFtx9n/Tkhj+9AK21Aq3IH8PXIbpw3EOgzosXXS+ G//A== 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:cc:to :from:dkim-signature; bh=LQzguNqg29abBGKUeSrC6IOQ1lzCyJlmW94ab8MjDZo=; fh=LdyjhHvC5fiJE3DrTb1lyh4cVnLYo1KiZKDMDI3pf8o=; b=lzyFQiruSQop94LzBM6RWnZZCe1iiaPQSGAdsTyLnvm1hTRz/rwO/7kxmy4U9RdtHp 9BdRwGbgay5BHVbiiRCUB2SMXIxQH3qJV+uOG+mp4nW4MICfXo++Llf9gajfB0ExNa2p GWuce/F7cVnCICbCJyM6Op6YmioLxphDZ+oNnHnqXsOrI9Y0u74CVgDnof6UXKhMRLFf jIu5QoyDN60rc+0D5OxlTv3+dNw0/ayBMAG94S1ZNKrC65TOWpw2U5AFpfUK6DGEEvI/ Ygp4YojV7xCsMZsFg7VltTKWth2zgzTLBblAjuJz2Z5lc2o4xwVVxkbqVnwrwD/QHtJb cV2Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcnUPsoE; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a198f986d0si966035785a.22.2024.07.22.20.36.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 20:36:38 -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=wcnUPsoE; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sW6JI-0003Vs-NM; Mon, 22 Jul 2024 23:35:32 -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 1sW6JH-0003Pm-4a for qemu-devel@nongnu.org; Mon, 22 Jul 2024 23:35:31 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sW6JF-0001za-8p for qemu-devel@nongnu.org; Mon, 22 Jul 2024 23:35:30 -0400 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3d9bcb47182so2979608b6e.3 for ; Mon, 22 Jul 2024 20:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721705728; x=1722310528; 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=LQzguNqg29abBGKUeSrC6IOQ1lzCyJlmW94ab8MjDZo=; b=wcnUPsoExxpvoiIYJY583a5bwQzgtXSE54eU8ndkmv/5H+vhHYyDqckAiWYUk6zaVQ 5rYGFoNNZX16oMyMwu625Ydb6RGSLnNJR4VoP1KOD5vrD0eI0aLb9cfh2Y4o8ZS6d6Et OOylX99ERSJ9RjEMzKYh0tKqIM/vSSVwnfAFG9tJ6hKNlFcsDpVOopIyxH+LMhvWSK+l CE3RfQp2WTyhDLwOGN4uT0LOJkLMPDtAYc4tvwTkmqDlmwEdbdEiz0hvqW2mQ/uSavTz OC4Vvb9/ZzbECRP/SANU3XMn2obUp1qh3YIKvNlfEFJ7JHyZ41sD6KL/vGrWK3u75Lmr 06Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721705728; x=1722310528; 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=LQzguNqg29abBGKUeSrC6IOQ1lzCyJlmW94ab8MjDZo=; b=fSc8bu7hEY+mctBNt9Pj+XOmJUberTr6EqMfb8s5s5En6dsNDmRFsvalR+y/OLEZsN m7ej/jNYpv5l7gzhsRgT23VEJukclTsiMD/Vxt6rhiBkZ09ji1eSuZjinq9FQb3DNGIJ b9ivgNdy+DE9uN34n7Kc3ytBESx+2/r+aP34SVal5oz6oUPVfOQTu2LoqkWdj5TQtclu dLA8Ztcw6NqURmej2tRtvOlVdZ9rc4Bl/s0qLxMrvqKzSbozkWbeHUlg8MqUkwS4o/Ra 6Lzg3u8ITCUFvyb9NmLW/upRQPfQe7TSh5FZ373GHJkRqOx+wKsOZjPPg9Oc9mK3Amfl 5xvQ== X-Gm-Message-State: AOJu0Yy1/DmQlTkLRRM1WI2TnMGs+3aIbk1s4rP3empv+ne9mK+pZfq7 EtRtzdM+Ymp0v/gjKlv8iLKYClyTWRm0d87RLaaIfU5SNZ6U/dAG/HsofOsWf0XnuZkkIBWHurO shKGLQg== X-Received: by 2002:a05:6808:189e:b0:3d6:3000:9ab3 with SMTP id 5614622812f47-3dae97dfbfdmr12513773b6e.40.1721705727691; Mon, 22 Jul 2024 20:35:27 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70d2b96bfcasm2171380b3a.87.2024.07.22.20.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 20:35:27 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Max Chou , Alistair Francis Subject: [PATCH 12/12] target/riscv: Simplify probing in vext_ldff Date: Tue, 23 Jul 2024 13:34:51 +1000 Message-ID: <20240723033451.546151-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240723033451.546151-1-richard.henderson@linaro.org> References: <20240723033451.546151-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x235.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.29 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-bounces+patch=linaro.org@nongnu.org The current pairing of tlb_vaddr_to_host with extra is either inefficient (user-only, with page_check_range) or incorrect (system, with probe_pages). For proper non-fault behaviour, use probe_access_flags with its nonfault parameter set to true. Reviewed-by: Max Chou Acked-by: Alistair Francis Signed-off-by: Richard Henderson --- target/riscv/vector_helper.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 1b4d5a8e37..10a52ceb5b 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -474,7 +474,6 @@ vext_ldff(void *vd, void *v0, target_ulong base, vext_ldst_elem_fn *ldst_elem, uint32_t log2_esz, uintptr_t ra) { - void *host; uint32_t i, k, vl = 0; uint32_t nf = vext_nf(desc); uint32_t vm = vext_vm(desc); @@ -493,27 +492,31 @@ vext_ldff(void *vd, void *v0, target_ulong base, } addr = adjust_addr(env, base + i * (nf << log2_esz)); if (i == 0) { + /* Allow fault on first element. */ probe_pages(env, addr, nf << log2_esz, ra, MMU_DATA_LOAD); } else { - /* if it triggers an exception, no need to check watchpoint */ remain = nf << log2_esz; while (remain > 0) { + void *host; + int flags; + offset = -(addr | TARGET_PAGE_MASK); - host = tlb_vaddr_to_host(env, addr, MMU_DATA_LOAD, mmu_index); - if (host) { -#ifdef CONFIG_USER_ONLY - if (!page_check_range(addr, offset, PAGE_READ)) { - vl = i; - goto ProbeSuccess; - } -#else - probe_pages(env, addr, offset, ra, MMU_DATA_LOAD); -#endif - } else { + + /* Probe nonfault on subsequent elements. */ + flags = probe_access_flags(env, addr, offset, MMU_DATA_LOAD, + mmu_index, true, &host, 0); + + /* + * Stop if invalid (unmapped) or mmio (transaction may fail). + * Do not stop if watchpoint, as the spec says that + * first-fault should continue to access the same + * elements regardless of any watchpoint. + */ + if (flags & ~TLB_WATCHPOINT) { vl = i; goto ProbeSuccess; } - if (remain <= offset) { + if (remain <= offset) { break; } remain -= offset;