From patchwork Tue Aug 16 20:33:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 597509 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp2696887maz; Tue, 16 Aug 2022 13:41:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR4tqm7Vck716qcA5EwZU5h32/LTALWATlI7Oryi3BrZFuFEqaFu6TGPENabwH/faP8Pat4r X-Received: by 2002:ac8:5e49:0:b0:31f:1bfe:b906 with SMTP id i9-20020ac85e49000000b0031f1bfeb906mr19785321qtx.18.1660682488696; Tue, 16 Aug 2022 13:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660682488; cv=none; d=google.com; s=arc-20160816; b=LCJ923nGHAomg0642Ylmj0IfQIxWZzOTRWimSpl7uNKC7RpVXxMEauhtUsBGQZqpGF KQN+36ZXU9rD2/RLnoacqhkmSm+GJuvFQ2gylsHRSjcPdyrH/BY7Ur9HUWAShe350ZrI yNtFf2eknnkCmphEuMrFBRWd0aQ3Sa7kwo6WhL2Xg2IryfoQD5CPUUjYfa0CQQ2WRpuO Pf3SP2jqUFmqw1hSlzqEN58Uril5W4yZVWkw/kNHHg3Omk/rt2iJhNnsasjCGcTQhg0y TpAo0Tr2N2QrxHdfQBkRBWbrNVHtlNYJC80hBQlkC/ZT1UCqj7PrxndSWDL0fz6qXmZt c2cQ== 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=3ksd7LzYDwg4KZFpTxKEvut5zUiua6xn62cdmeCd4NI=; b=0eMhGqfEYwvJIMAvDAdMLqdMAz0JReRkO2c+Bcy0W1UkDnNWhAd8TO6BD3ZphZoaQd kTmHyrMzD5VDY5yNZr2LvF9qmvoaCsgh18GdqC4EWD2FusxUFhAfQEH8olv2yWCR8xMx +29+gpHfNlIHdPW2jh5JkR/He2H41HxsjCYHE2S/9Q0C2YZeSSzK2IJxUA4eObS/96Sr 6VnPGxsdJZnQhaiaV/c9uwzrDwjpHfEvXKgIfShooZS90D4QTysSXubV1nlHDZLrDXR/ YHQpsIwjgzkKxR4PM0i5vmwhBG+rCmP3Tbg8V/ROMU7Xfz5K/zeCSGRjVxarjU8Qt682 YpDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Xe9/AQOJ"; 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 ga6-20020a05622a590600b0031ecb75f59asi7302440qtb.664.2022.08.16.13.41.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 16 Aug 2022 13:41:28 -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="Xe9/AQOJ"; 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]:49546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oO3NQ-0005Nm-8A for patch@linaro.org; Tue, 16 Aug 2022 16:41:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oO3Go-0004pC-NP for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:38 -0400 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]:47094) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oO3Gl-0004U1-0A for qemu-devel@nongnu.org; Tue, 16 Aug 2022 16:34:37 -0400 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-1168e046c85so12927625fac.13 for ; Tue, 16 Aug 2022 13:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=3ksd7LzYDwg4KZFpTxKEvut5zUiua6xn62cdmeCd4NI=; b=Xe9/AQOJQcDrIkOLYznYz6OyhBfMxzNRT/L7VHVGO0UzygcWPY8sF5Os3EjhNnUu7K MjD9NjImtaa37lMEPyYzruSlTBcyA6SkjjHUsmD32+1o6MwGEFV6C/T1WKUeK6yf1RWk E5q4Kq4QF7az/AGSoXjSa46Km051+7Xl00Zeh9df+Hc/bnRycLliEB2E4E2/O0MdTokw wD9JWyEGpTr3XR+UwJxCcS0siIxn9Amplc4zMdxbT96+L9cnaZEcwZzU9CHk8vpBMqKE G2IZbT/5rkX5I8IexV4koPv89fpQ/JC66eYqvZ0swik2R52Itd05EGbwd2SXiScqVD2k bX3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=3ksd7LzYDwg4KZFpTxKEvut5zUiua6xn62cdmeCd4NI=; b=uONE3sJetm6XoW6kPrbRe692wRAAttfEX3gh7TiBtmWPaxFvXI8hN07anglhsn2XQo Z6gUbMXj27pcHz65W9FrGwbAVTu8EAJjzQUYF850WnbJjlrIMevPl3pQvnk7wgdu7b6Y ZqYR3t+9BJjP0wgdWkZMjoSEj+TpNWGcA+NYDZS0LYJaFvH/VUv7EcH1zNHjDSDfLD71 v2Z7bzvLnEq+GrYG9wHE8vmEExzw4LtZxCftHt2+9sOJYSjGg36S6fMZW5UDk5AjTNjw 2P2zr44ThTmE2zfuTEaCjpR/XYy4hh3LETJRKQ56M0eGU1QQCjy31vQCq75s0fZAt7Cd m6JQ== X-Gm-Message-State: ACgBeo0AafjDeyCYWI3hnNFrWltoD1pglfaehCT8LSWQ35UBnPAzSj+b +o8tD2F6SX+BTrCiqBGCng7TkU+f+lzrDg== X-Received: by 2002:a05:6870:1485:b0:11c:46b6:7b81 with SMTP id k5-20020a056870148500b0011c46b67b81mr126823oab.233.1660682074216; Tue, 16 Aug 2022 13:34:34 -0700 (PDT) Received: from stoup.. ([2605:ef80:80f6:61fa:9bc2:5095:d612:5e22]) by smtp.gmail.com with ESMTPSA id y23-20020a056870b01700b0010ef8ccde67sm2285220oae.13.2022.08.16.13.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 13:34:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, alex.bennee@linaro.org, iii@linux.ibm.com Subject: [PATCH v2 12/33] accel/tcg: Add nofault parameter to get_page_addr_code_hostp Date: Tue, 16 Aug 2022 15:33:39 -0500 Message-Id: <20220816203400.161187-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220816203400.161187-1-richard.henderson@linaro.org> References: <20220816203400.161187-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2e; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2e.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=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" Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 10 +++++----- accel/tcg/cputlb.c | 8 ++++---- accel/tcg/plugin-gen.c | 4 ++-- accel/tcg/user-exec.c | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 9f35e3b7a9..7a6dc44d86 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -599,6 +599,8 @@ struct MemoryRegionSection *iotlb_to_section(CPUState *cpu, * get_page_addr_code_hostp() * @env: CPUArchState * @addr: guest virtual address of guest code + * @nofault: do not raise an exception + * @hostp: output for host pointer * * See get_page_addr_code() (full-system version) for documentation on the * return value. @@ -607,10 +609,10 @@ struct MemoryRegionSection *iotlb_to_section(CPUState *cpu, * If the return value is -1, sets *@hostp to NULL. Otherwise, sets *@hostp * to the host address where @addr's content is kept. * - * Note: this function can trigger an exception. + * Note: Unless @nofault, this function can trigger an exception. */ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, - void **hostp); + bool nofault, void **hostp); /** * get_page_addr_code() @@ -620,13 +622,11 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, * If we cannot translate and execute from the entire RAM page, or if * the region is not backed by RAM, returns -1. Otherwise, returns the * ram_addr_t corresponding to the guest code at @addr. - * - * Note: this function can trigger an exception. */ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr) { - return get_page_addr_code_hostp(env, addr, NULL); + return get_page_addr_code_hostp(env, addr, true, NULL); } #if defined(CONFIG_USER_ONLY) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 2dc2affa12..ae7b40dd51 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -1644,16 +1644,16 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr, * of RAM. This will force us to execute by loading and translating * one insn at a time, without caching. * - * NOTE: This function will trigger an exception if the page is - * not executable. + * NOTE: Unless @nofault, this function will trigger an exception + * if the page is not executable. */ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, - void **hostp) + bool nofault, void **hostp) { void *p; (void)probe_access_internal(env, addr, 1, MMU_INST_FETCH, - cpu_mmu_index(env, true), true, &p, 0); + cpu_mmu_index(env, true), nofault, &p, 0); if (p == NULL) { return -1; } diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 3d0b101e34..8377c15383 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -872,7 +872,7 @@ bool plugin_gen_tb_start(CPUState *cpu, const TranslationBlock *tb, bool mem_onl ptb->vaddr = tb->pc; ptb->vaddr2 = -1; - get_page_addr_code_hostp(cpu->env_ptr, tb->pc, &ptb->haddr1); + get_page_addr_code_hostp(cpu->env_ptr, tb->pc, true, &ptb->haddr1); ptb->haddr2 = NULL; ptb->mem_only = mem_only; @@ -902,7 +902,7 @@ void plugin_gen_insn_start(CPUState *cpu, const DisasContextBase *db) unlikely((db->pc_next & TARGET_PAGE_MASK) != (db->pc_first & TARGET_PAGE_MASK))) { get_page_addr_code_hostp(cpu->env_ptr, db->pc_next, - &ptb->haddr2); + true, &ptb->haddr2); ptb->vaddr2 = db->pc_next; } if (likely(ptb->vaddr2 == -1)) { diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index a20234fb02..1b3403a064 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -200,11 +200,11 @@ void *probe_access(CPUArchState *env, target_ulong addr, int size, } tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr, - void **hostp) + bool nofault, void **hostp) { int flags; - flags = probe_access_internal(env, addr, 1, MMU_INST_FETCH, true, 0); + flags = probe_access_internal(env, addr, 1, MMU_INST_FETCH, nofault, 0); if (unlikely(flags)) { return -1; }