From patchwork Thu Jan 28 22:41:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 372629 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1666105jam; Thu, 28 Jan 2021 14:49:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6Pzwgk9RUlseksoMKZua7LHGeAZYxO5wae6bdedn+PAbpgD9FQVW7HCBJCCm3UHsnSS8p X-Received: by 2002:a25:7c43:: with SMTP id x64mr2260970ybc.267.1611874189225; Thu, 28 Jan 2021 14:49:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611874189; cv=none; d=google.com; s=arc-20160816; b=QB9V31vCNL6GQlYNy4ZhTJIBBvqviO4ul5JNRVjUn4Wl10pSwmiYJ4wXZWTdbBm+iK /Ze3RZcWe8j0pgCykBiTmRcXDPojwMv8Xj1mWep364iy9C62RpTIMTI4Qba75r/uSjx3 H8lJiRK3DvbBQvbF9t3PK8nfhLr+yNCgJerzWuJpqs96NqyQU7sMdmy2TIKqp+rzlZcn LeHeWmUtmo6Ga5YOfRo2FJl5j5xnGrH8NkCUAfS0f7wYV2UWQXFsWBjuf/fPtlfmhNtu I8NfgiTeQH2KfFNXlioK5Lo44r0CU3OosLtHLyUYm0X8oUtBzwTGemcEqRN4IgeeTpdc KAPg== 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=HKiptbZBSo71ojLgw3PxYCETYtXrfhVTaAIj8cs2COKyTZt9Wf/Gk6tWe0yrp33wr3 m4gZ7Ll1QnozcS6TeMuTCrSBccnmx20TzSP2t74IOBByXaJKCVQtHkJxd5hRs2VWwEIi T04+b/aFVS5faRpekE3qc07rOxEwnJF8sEPPENE5JVxqZJT0gAqisu5X1Lq4rFStbQWQ n8P2myvKht1iV32sXerwljeymF3XFKsXm6f1SdK8JT/CUgD4YSsUQBo+75k9ZdWERJX4 aiX2q6zlN3MDOpPyRThkaiim+34YyWRsIGrD335F/APSEUK7qfes/e8hMpW7Yid5hQvv EZvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Aw9NDjqY; 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 z184si7106347ybc.57.2021.01.28.14.49.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jan 2021 14:49:49 -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=Aw9NDjqY; 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]:34684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5G6m-0005EX-ME for patch@linaro.org; Thu, 28 Jan 2021 17:49:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5FzM-0005X9-1J for qemu-devel@nongnu.org; Thu, 28 Jan 2021 17:42:12 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:54925) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5FzF-00088P-Rr for qemu-devel@nongnu.org; Thu, 28 Jan 2021 17:42:07 -0500 Received: by mail-pj1-x102e.google.com with SMTP id cq1so4717749pjb.4 for ; Thu, 28 Jan 2021 14:42:00 -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=Aw9NDjqY6PN9drRr+/r4nElPi2eAAbZVnJ+fn1Z7s0D8FWNFXW47STthtTal25DXQh qHZyeD3xL78B8D3btXbY1ByLAWKpBUpr04H14BerHxArgo+E3gOlh5TVD80m3vulh3Fx rsfKisD58WD2thmQWv5xTsBApsH7uGru0HCwDm9blDgeRKHzVfriJ1jIYwQ/bKt10SEV LMH/eXAAu8xEyMfGbXov7Mjiy5geDpDSr+uATldXchscO8ofjtHoB3Q9kX4i0FhqyaDL u6+1u9IblN9g1WIEQYmwHzLuA46QdYBQUGjfm98yo6ryPP/AFG0iYa41XIDo3d6pxoA1 ez2A== 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=NNVGDtcBsky4yShLyGAwcdV5V6CxSjujL3xgHoY/dkkJj7KhT0Ysy8BLGAz7/OwvfX YP058mbD+d4LDE1ATsiIWuRSxT8Nf84mliERjeP+E6YFYreEG5EniKhNyV4ThywclC77 CKqD5OkfFrazXBgOxQlDTmm11lmQk/y6Xs6oJpnz6yxwFNpFBnM/zdxVXmhFlWiSrMyh mnweB0Ov+FONny+t5wNNl7SgVO3GIQcaU3cuvH2YTDLwetI4IV2eeHYlFRM7GE04u6T2 iIdqs9rcFstiVYB3DByK0kGuWiRutWEve6gabBxZUJtMJF3JYiD8hZogcXcKE83Ecszv ohgA== X-Gm-Message-State: AOAM530uSaBN2y8QkwtdgzLyVgnu7d0YT1gSDThFoL4FuUGQRzlpX01f NnzoD40/z+1eN7SqLB5y5SxUadeynB7LdPBW X-Received: by 2002:a17:90b:949:: with SMTP id dw9mr1585322pjb.20.1611873719633; Thu, 28 Jan 2021 14:41:59 -0800 (PST) Received: from localhost.localdomain (cpe-66-27-222-29.hawaii.res.rr.com. [66.27.222.29]) by smtp.gmail.com with ESMTPSA id m10sm6042358pjs.25.2021.01.28.14.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 14:41:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 09/23] linux-user: Do not use guest_addr_valid for h2g_valid Date: Thu, 28 Jan 2021 12:41:27 -1000 Message-Id: <20210128224141.638790-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210128224141.638790-1-richard.henderson@linaro.org> References: <20210128224141.638790-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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=unavailable 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; \