From patchwork Fri Jan 15 22:46:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 363798 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp273788jap; Fri, 15 Jan 2021 14:55:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9ITX80c60w6K1LXXrzx5bIF3kyhcOwarlaZU88v2/HnYL0ojajGv5/VcHAhJfIqHTT/7Q X-Received: by 2002:a25:73c7:: with SMTP id o190mr4634567ybc.482.1610751340231; Fri, 15 Jan 2021 14:55:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610751340; cv=none; d=google.com; s=arc-20160816; b=eJTvLC1U8e6IrYIMdh/3mxQc6r1cvaS4/9cUTQCvv8txliv9WlXTbFoQE7f6AYAG5+ rqPfXbKAuyXYOJowZuVm1ygzqqrei/sD3u2P0SpOdT+lxlHLXb3UXS2fqKN5THDgURKo sssbnSCAljAN8sQPjoQqE5lbGH5THsojP+YycCKJ3+dlcDRZOFv5l4fzzj+ZYHdquGa1 jPqujbWuYpA3Gn1f3DE/ja9Z0eowdJZ4ew/qY4ipJcaHA9PYzXvucKkOiMTBaJa/4dES Oj6BkQf3wqeXodSdd7yRWwu/QYEdlfoBNG7sr3zSAbwdVKWDVIonwGUXER7johigJjxU /HUA== 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=4REF6cfdA8MQv8viPXefMUo/38x0z3uSDZzFVOD3Xwc=; b=ztmvYZRpp+O8xoI4ZB2Rr7bYRyoMzhldYCi/y1nfaKkr3j0f5fDZEiQ6FPelXyP9pQ kmq7LNUkzC1LM4xVLmaQIg1wwxbjo+M8b8wTsAYMqhrv6b0253p6mCtvoKtgZPixYXqm g8ZCOPDWqPLevGxxzHQxwtJv/Ybw8+WBF5am4cIv1epodG8HPQyna+nafRvvrP6gNgCX 8JVkGSc9YC98jL6lRvs2RGF/0doUD4I++hxk4YkDKFDuqlqfRzx9DtsVl4KLqIb1WTJX DpDdIa5q2vQPh7b0DWlD6CHDVJhTzBPHdwo1tXbHsIIUUIDLsbhmfl3lF+/rWSt1pDPR bOIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=yKJEbBv+; 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=fail (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 k4si9021149ybp.93.2021.01.15.14.55.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jan 2021 14:55:40 -0800 (PST) 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=fail header.i=@linaro.org header.s=google header.b=yKJEbBv+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0Y0J-0003vQ-Oc for patch@linaro.org; Fri, 15 Jan 2021 17:55:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0XsE-0003bB-Qz for qemu-devel@nongnu.org; Fri, 15 Jan 2021 17:47:18 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:38703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0Xs2-0005FZ-RS for qemu-devel@nongnu.org; Fri, 15 Jan 2021 17:47:18 -0500 Received: by mail-pf1-x42a.google.com with SMTP id y205so583899pfc.5 for ; Fri, 15 Jan 2021 14:47:04 -0800 (PST) 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=4REF6cfdA8MQv8viPXefMUo/38x0z3uSDZzFVOD3Xwc=; b=yKJEbBv+SrFsgEnltc/TzCtw86pnuM6k14IqbwjELUAeVDqJ3li5/xF7UFZl6/sxkA yoABsgYO0PryhgXiatN2djfCWQaSm36thjzmLwcp0RGiZHjJmI1sawyRwW4QR0lwDFmk Fn+CgVCVbDdYNv6JTPClFC0Au3kM+t3LJvLoymZvDp4Hu2sdPMm8Xt7jp9tgAchii05j jsX9gyhDfZ9EMkzI6PRxvaKtjkanv8f77aw2EXXE12WascTVrohbA95VfyKejvuB4SkD 4t4Fx1bbDFqq8WBSFc0VBBhccVYOxdqeBd+5nyJtENFj6/mnWXp+BQGPWb4ivGkBZr6b hHuA== 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=4REF6cfdA8MQv8viPXefMUo/38x0z3uSDZzFVOD3Xwc=; b=BhN3gB5svPRmqtAxJ9Clk/oligGN9sb4ZTCqCtbDQ/W2Alh2qfCl1gdFV1mnEDyOeS jOeyC0/ddJpVH4OR98F5UscamkzwbhlxG+xBFOMremvBGZg3bPRHztkFNxXjhiQv/Gkj uEm3gp6HMVdn/RYWHcyO6m/3MtD7lDu82qIEjL98piA4xa6nXnKFKPzH1V6whRSwEOIk IFG0O5iOdlkxRRJciIDPE7K8NrZLP8y3NK+oE70IhWFHZs2ztVGVsIDMKifpHY376hlq Ltrc0nYMl9bXMACpU1O2fWpk3sOayi+uwtIhmJ/hSKC3Of9QOcjki1Wo/TOgXKLFuM7a rd7A== X-Gm-Message-State: AOAM533qcteu6I0M78NQmypfxulBykkR0vp0rK3KMUQGio1pzYTyI0Lf tXoIVw5rBbsj4iQvWhAQJwzj52a7Ig5IbDJJ X-Received: by 2002:a63:65c5:: with SMTP id z188mr14580822pgb.332.1610750823237; Fri, 15 Jan 2021 14:47:03 -0800 (PST) Received: from localhost.localdomain (rrcs-173-197-107-21.west.biz.rr.com. [173.197.107.21]) by smtp.gmail.com with ESMTPSA id s13sm9521700pfd.99.2021.01.15.14.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 14:47:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 09/21] linux-user: Do not use guest_addr_valid for h2g_valid Date: Fri, 15 Jan 2021 12:46:33 -1000 Message-Id: <20210115224645.1196742-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210115224645.1196742-1-richard.henderson@linaro.org> References: <20210115224645.1196742-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is the only use of guest_addr_valid that does not begin with a guest address, but a host address being transformed to a guest address. We will shortly adjust guest_addr_valid to handle guest memory tags, and the host address should not be subjected to that. Move h2g_valid adjacent to the other h2g macros. Signed-off-by: Richard Henderson --- v3: Ditch type changes; retain true for HLB <= GAM (pmm). --- include/exec/cpu_ldst.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 5e8878ee9b..4e6ef3d542 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -77,13 +77,16 @@ typedef uint64_t abi_ptr; #else #define guest_addr_valid(x) ((x) <= GUEST_ADDR_MAX) #endif -#define h2g_valid(x) guest_addr_valid((uintptr_t)(x) - guest_base) static inline bool guest_range_valid(abi_ulong start, abi_ulong len) { return len - 1 <= GUEST_ADDR_MAX && start <= GUEST_ADDR_MAX - len + 1; } +#define h2g_valid(x) \ + (HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS || \ + (uintptr_t)(x) - guest_base <= GUEST_ADDR_MAX) + #define h2g_nocheck(x) ({ \ uintptr_t __ret = (uintptr_t)(x) - guest_base; \ (abi_ptr)__ret; \