From patchwork Thu Jan 28 22:41:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 372625 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp1662574jam; Thu, 28 Jan 2021 14:42:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMvXg5TQ235tDD692RWpU+yN/qAiddZmv02sFJHFRSNtehOa8g52fQpRioWangLp66arRF X-Received: by 2002:a25:1e42:: with SMTP id e63mr2157478ybe.270.1611873775676; Thu, 28 Jan 2021 14:42:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611873775; cv=none; d=google.com; s=arc-20160816; b=bKCnv9UGYjiR66Ht9M4AyjWTasRN0z6YnziMXo3xWhl7Nyf/LE3l05Nz5KV1eFYsjh cMEfNisKYWDtQQTZwTLYt9A6AugEuAl5qI7eXThn0janb1iYJeeNk1t7bUeRx4W+2TML 9zheIR7IuB6xlvi4wU5zLOlslSD2rsKzlJjGBbIKBvB99LUPsy/Q+S93oOgjW1xrU4Jj TObbemU0bPIMKDX4IjDpOocIjIcNeqB4AVoaRUB9mPE+dJNg/HWmLYdTMS3B4HKhS2eL Khx99M8mpfGTOwnVo5N4cEw26MpYGsNItqVudf7Mwf365rdJdxQ5JVrqDBTki9XAAoOV XNNA== 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=XRNC7TN62/mhJ44h4TxsBn3p8qzX1+L1EKv8lKpxGuM=; b=ZcJTtUU8Ii0jhSsFtehvK9r45vfTx3rradjDu00bSNuDhS7BAOPP02jvOB+FgVbrc9 M6RsqnWvjlq+56t9OFCAvUsvwIt7Zz4ng7rdyYNEFvewufC/18XuEL4WYVRD7Y09bn8G BbAIu+QAVJJRLDUykxRW7/MgAvZpQOe5w02BkxyC+hMS+kQwmUpx9sHgLQ+MManfEUST iQIRZhu8SRFum9P24rMDbvZL6nKZNT0YOs4y8vkV0ofK2osjIF9Iu/aJIfP/GzVA9ZU+ cKmCI2WT5wnfl6g4yCWM/t2bi6FZVYofbFPI0/dSVWyuciOhDLZvUP6zWyb3VMfS1F7x 8/Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vblZAsOE; 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 r11si6751411ybb.116.2021.01.28.14.42.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jan 2021 14:42:55 -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=vblZAsOE; 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]:45160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5G07-00067i-2s for patch@linaro.org; Thu, 28 Jan 2021 17:42:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5FzQ-0005XU-2S 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]:52907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5FzH-000897-Lq for qemu-devel@nongnu.org; Thu, 28 Jan 2021 17:42:11 -0500 Received: by mail-pj1-x102e.google.com with SMTP id kx7so4731488pjb.2 for ; Thu, 28 Jan 2021 14:42:02 -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=XRNC7TN62/mhJ44h4TxsBn3p8qzX1+L1EKv8lKpxGuM=; b=vblZAsOEFd82DGYDOVgYbHn0mioP2LeWtRtyFGs/MRXk8Nth5Y3ZGqgUJ92pJkjLgS vER9jA1vigrP+IkeDmO7lndLQc5oVMQbOj7w2OSJkckTrK3PV6Rb7Dg+ARBzrgU3LMld de7FT484SRvm4vGGUCTFjAamPeHgsXoaf72TOE481v/kAJIRv8S7dXskl10kJmuafyeq Cqv+iPTHYb6WPE1W0UOBp+aLj3leOnJ4owhvpoiodhO5r6ruAzDgDsC8hU7rnHWNXQ1/ Q+57NHLDo1GIZjSMiErfJwGpxRuuMvwEvfoV4GgFRu87P0oXsAj6XRZpW5HVDYKzCwc/ Hthg== 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=XRNC7TN62/mhJ44h4TxsBn3p8qzX1+L1EKv8lKpxGuM=; b=gyQKHrWChLbdiq+ZN8VIQU89nG4iMNG8uiWiqO4ci1T/3ONg5kAv/F3LXXujTzGqpp vXsrjowfZIE3xq+7Kx+YvV4jb/vCPTjhCZ6Tv6uCAMLXt0EkpDOwpBEdSOKJkkEcFInM i4H3BHEFTX3SlhAntlMLKCSInR9HGfpqYvAMebEIqebTlXWXKYr9bU70xk0xpsIjkR6W uZp37DYAP0O9PQndTBIs7na2hL7O/Iu+Db5Eo0eiM9IEZZ5BLsXoiiKi4QWO2vm6htIS w7geDCJX3Frb/BgMLnuzwg7p9ILL/XqeXC1MT5NEpxxKHSgBZU0kfwcFk6x2AYZ7hvq6 FCbg== X-Gm-Message-State: AOAM531sFtXtOHppJHkMVKqpHeLbZYiTsy2KWvS2Pyn4xdmNAtsE8DPp WalYZmktTj8LE8LY+QQWSYG7BWLZwb5sdOP2 X-Received: by 2002:a17:90a:7e2:: with SMTP id m89mr1522901pjm.2.1611873721204; Thu, 28 Jan 2021 14:42:01 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 14:42:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 10/23] linux-user: Fix guest_addr_valid vs reserved_va Date: Thu, 28 Jan 2021 12:41:28 -1000 Message-Id: <20210128224141.638790-11-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=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" We must always use GUEST_ADDR_MAX, because even 32-bit hosts can use -R to restrict the memory address of the guest. Signed-off-by: Richard Henderson --- include/exec/cpu_ldst.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.25.1 Reviewed-by: Peter Maydell diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index 4e6ef3d542..e62f4fba00 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -72,11 +72,10 @@ typedef uint64_t abi_ptr; /* All direct uses of g2h and h2g need to go away for usermode softmmu. */ #define g2h(x) ((void *)((uintptr_t)(abi_ptr)(x) + guest_base)) -#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS -#define guest_addr_valid(x) (1) -#else -#define guest_addr_valid(x) ((x) <= GUEST_ADDR_MAX) -#endif +static inline bool guest_addr_valid(abi_ulong x) +{ + return x <= GUEST_ADDR_MAX; +} static inline bool guest_range_valid(abi_ulong start, abi_ulong len) {