From patchwork Thu Mar 12 19:41:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 184508 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp954021ile; Thu, 12 Mar 2020 12:46:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtjWA9wB7PmOoJ0X6FROzSGo/+/UxZZDcs1/HIEGVwwE7u03jB0dQACZTgq72/4AXYg2YE7 X-Received: by 2002:a37:aec2:: with SMTP id x185mr9743810qke.45.1584042374695; Thu, 12 Mar 2020 12:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584042374; cv=none; d=google.com; s=arc-20160816; b=JVDbYoj7sxKriA+6iS14FZNf1vIsKMKXGn24OI2daOftXaTIQmKflKtJijahKmMUBx sTHI86ul2oN37w+zM4p0h5X+heJHrpmgdR05HRIwrQ1fcNUt7snOBSUkwgRctMkLw46G aRY9HNiV3Nfqs+Bq7kT+j1jvt1i/V9OEXlTjIIz24uPNeIbQfQUqucbcIdRrPKxeJ1zn IUvVJiMMZHQlJND2+kDijrVS255bcr3qrQD4YlFYe5lYqEQbIMK8sgpRH/Gnu6OWUsTc QF31DOYv2Wuo7q/4GOusgtwd+zkCC6bnNRmg7rrloEiHJaCn0Yz9mfukjzM/0rchD9Mi rAhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=wN0TfHqfZivaapeBhs6fRX0f635NiC55vaX3XaH653M=; b=WF3OdPhy5dR9brs11+dotmMKhPGgHWDtltelzVICmySZYXDJ2Vr05Tr29gQldBCy6X oCG4vjIR2QWs5VKQZBn6cqqiXLubTWva24Ine+KRAwyjc19vD8mzG7LI2Gb8acu9nz/P 7ghdJGADM6rTitGbbgjKTuUpklUacgDeMbCwvf0S/FgvITn94MYMUO+6jQ6zdMnMfLG4 SrtTGNgVz9s7YKTEZ2JFnn0XrQ0Sh+1c7MX7iHNFV2Hxc7UVBuQTZ9vhqcLlnbJmf2lV X2OY0ibq7iJdxPW8rJr+YmTr9TXKUfyc+i4p8ks9OHhLsA+1PIlBvj7ieSEGuP5yRMlj de/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ViHYVa2I; 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 o8si3439623qvu.87.2020.03.12.12.46.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Mar 2020 12:46:14 -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=ViHYVa2I; 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]:49240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCTmY-00081d-6F for patch@linaro.org; Thu, 12 Mar 2020 15:46:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45366) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCTj8-0005Lh-4T for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:42:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCTj6-0001zS-Vj for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:42:42 -0400 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]:54809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jCTj6-0001xu-Pm for qemu-devel@nongnu.org; Thu, 12 Mar 2020 15:42:40 -0400 Received: by mail-pj1-x1042.google.com with SMTP id np16so2964216pjb.4 for ; Thu, 12 Mar 2020 12:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wN0TfHqfZivaapeBhs6fRX0f635NiC55vaX3XaH653M=; b=ViHYVa2IeF2adL4f3D4ETRqrlHVsziMQ7lV68vafRzNA2+lyX+m/bhOYsTKGAeVAHA bsxm7M/poAJu1lqEqXuChqSrsqeLqpX7PMcgcMNjg0RdiK9uJIqWT7ZyE13bb2B900v6 TAurQKqQicROPyOkVxxQAn9wP6mnR1qV8zXhwhWBti1kdDfBLb3r3rRJj7xZLcVXHfed 9KLyAWFXcbwMsOKYXWMPfh8XdbK9t+WOFZwcIK8mkBsEydJoXn3eQHg9uHVbwzxAkelr a+DeCQF4BDR4G0SgFjTfW19BdUeNJwzdlM80R2JDmaIfK1UbETWpuaNVcjJEtv2RdGYa i04w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wN0TfHqfZivaapeBhs6fRX0f635NiC55vaX3XaH653M=; b=IYIs9Ytrq8cJMIxVFGsgnqaMJG9XifsosIFDYNXxkRvfsJqhTAAw3Q4n1VGmeSWoYB p/ZVgS5du+dnnwWhZdb7ysxRCStBL9QA9yPWU0iTvRG97XpRmxibiOnoIZOCXc1JDBnD MD2IcMs0CPgpgr/iJ5Bq5BVv03sTA0jNKQnc4y4F7lGarBh385W3shAfX2ZQ0cYNJlVM OmN6J5eWhzKPK8JcUmp29/Dvvcqhi0GSTd5EeLB6nXWiuYGtmeTAnJMNGZtgKfR0e/VF n+U+AjjCiD3gA7npkollk1gFheSjnoopcZ9GZOKsHXQnElF57rjec9WuqUoN7j4dq1rK VKZA== X-Gm-Message-State: ANhLgQ3vSsHuDz3LNLg33xkjglKyH+153sv3ikQQ8kXgw5jPoq3vGVLJ bufZCaLKaQdJdpBcvkyHcFzynKErTXU= X-Received: by 2002:a17:90a:9306:: with SMTP id p6mr5806526pjo.0.1584042159488; Thu, 12 Mar 2020 12:42:39 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id g69sm6824842pje.34.2020.03.12.12.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 12:42:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 14/42] target/arm: Add helper_probe_access Date: Thu, 12 Mar 2020 12:41:51 -0700 Message-Id: <20200312194219.24406-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200312194219.24406-1-richard.henderson@linaro.org> References: <20200312194219.24406-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1042 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: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Raise an exception if the given virtual memory is not accessible. Signed-off-by: Richard Henderson --- target/arm/helper.h | 2 ++ target/arm/op_helper.c | 16 ++++++++++++++++ target/arm/translate-a64.c | 13 +++++++++++++ 3 files changed, 31 insertions(+) -- 2.20.1 diff --git a/target/arm/helper.h b/target/arm/helper.h index 72eb9e6a1a..8a616ed6d8 100644 --- a/target/arm/helper.h +++ b/target/arm/helper.h @@ -95,6 +95,8 @@ DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int) +DEF_HELPER_FLAGS_5(probe_access, TCG_CALL_NO_WG, void, env, tl, i32, i32, i32) + DEF_HELPER_1(vfp_get_fpscr, i32, env) DEF_HELPER_2(vfp_set_fpscr, void, env, i32) diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index eb0de080f1..b1065216b2 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -935,3 +935,19 @@ uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i) return ((uint32_t)x >> shift) | (x << (32 - shift)); } } + +void HELPER(probe_access)(CPUARMState *env, target_ulong ptr, + uint32_t access_type, uint32_t mmu_idx, + uint32_t size) +{ + uint32_t in_page = -((uint32_t)ptr | TARGET_PAGE_SIZE); + uintptr_t ra = GETPC(); + + if (likely(size <= in_page)) { + probe_access(env, ptr, size, access_type, mmu_idx, ra); + } else { + probe_access(env, ptr, in_page, access_type, mmu_idx, ra); + probe_access(env, ptr + in_page, size - in_page, + access_type, mmu_idx, ra); + } +} diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 49c94bc565..45a95d8ea0 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -249,6 +249,19 @@ static void gen_address_with_allocation_tag0(TCGv_i64 dst, TCGv_i64 src) tcg_gen_andi_i64(dst, src, ~MAKE_64BIT_MASK(56, 4)); } +static void gen_probe_access(DisasContext *s, TCGv_i64 ptr, + MMUAccessType acc, int log2_size) +{ + TCGv_i32 t_acc = tcg_const_i32(acc); + TCGv_i32 t_idx = tcg_const_i32(get_mem_index(s)); + TCGv_i32 t_size = tcg_const_i32(1 << log2_size); + + gen_helper_probe_access(cpu_env, ptr, t_acc, t_idx, t_size); + tcg_temp_free_i32(t_acc); + tcg_temp_free_i32(t_idx); + tcg_temp_free_i32(t_size); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value;