From patchwork Fri Feb 12 18:48:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 381866 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp3190993jah; Fri, 12 Feb 2021 11:12:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJysqhGVzwVS909jBm5noSZIQZZ3doP89cxRPBGTYUNbXX0x2rZZgG3ZehyKZRT0tyx8Jk0y X-Received: by 2002:a25:8742:: with SMTP id e2mr5675822ybn.66.1613157149005; Fri, 12 Feb 2021 11:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613157149; cv=none; d=google.com; s=arc-20160816; b=IieihQ00Hmuxz4UTXoL3m/lKwW0rHU4ALGhrtdaCxifxi3fiOuWnsMcIaB86wVrbqQ /k6+luuGcgup1vT1Gir5bNjoPBDg7MNwhzlb9lXxCiXZyl3ayNxGe4812Bk1XVNXfkrB TVA9YmzJFj5Kk/Ko8a3JT0IDR6jrTU18caBJL29ii5GlfHel7nIR4LfVePkShOG6f+rA 2nkH2Ue1uB6FztXNUdyhcoe8HjCE/vxT028/kLCb1amrextcIvQGFSPmxQ9Y5ABZSPZF mJBPWXvB4i8DFU2/5mo86BSrfwYZY5V3UMev5vIDhKEkLxg3RC0euEAPUpogjg0c9MQw ddMg== 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=ACfOE8SVSBgg4JpZZoxjcwYfYXJzG1xX3fS2kxeRIKY=; b=Ls03q9BZZfAekIeT/e3FSBR+v6jv4Ju7bm0Qx9QAFCSfHMw9vHB61/Es85Q8hS1627 dH3i4tEbou98qQp09mgGYCw3YJiyZR8UXrpccK3Dextj3qk0wEzk9cWNdJdUJvKH/CN/ tYEDypWChpwVzpA2ZQJnKZwtjrLMKhrnuP6P9a5Hfd4ArZ3M6aCuhvHdsF+dkNA4XOVD EMZFqO/gop1qL9L5fKsaMgwk1ZM2QozQ7b9OTzbflvoYlAvJqDf7eOTdMUK+/41zZIe4 Mw6WBbc4m1qr2tAK5FRQXL5eHKVhCPet4QnPvo73kC84JIG+Uvyk8ooAuFrw9A1PLSaq Gxuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mqpzC3VX; 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 206si7919339ybq.133.2021.02.12.11.12.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Feb 2021 11:12:28 -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=pass header.i=@linaro.org header.s=google header.b=mqpzC3VX; 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]:56976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAdrg-0003Sd-GW for patch@linaro.org; Fri, 12 Feb 2021 14:12:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAdVX-0001my-O7 for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:35 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:45489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAdVM-0007os-W9 for qemu-devel@nongnu.org; Fri, 12 Feb 2021 13:49:35 -0500 Received: by mail-pg1-x52a.google.com with SMTP id o21so220206pgn.12 for ; Fri, 12 Feb 2021 10:49:24 -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=ACfOE8SVSBgg4JpZZoxjcwYfYXJzG1xX3fS2kxeRIKY=; b=mqpzC3VXtPsyNvOu96d9QAxow7rc8cCVYVdFUm7f8PC5uK+feQM8oOMxIt+kCgQmpi FqLVdNHGmsQAQM4cpndsvQTzyXL3+9dyXkNzysandX9P3TSmNuQMlpgTE5PZXIo1Wuuc oydzT5r8Zh902SE4GFgK0ph42F/qP0xNVZOl5F5FQOVw+UDb3wKkqJWILy+WwsrEVBb+ bLzy1OinMLvpQaZHBvPufDYT5Kdpvu5z0Y0yFlEUZHVgxHDdko/v2EaqKVU7woLig8Pk vQKi0VMaePrFMp9ZCMpg0Ct2dNsnEUCr4DF9q8TpVZA4osjAVjcLzI6XjzteUhbLi1OU cWIA== 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=ACfOE8SVSBgg4JpZZoxjcwYfYXJzG1xX3fS2kxeRIKY=; b=N4WCJFSgCg/+lvhw0hizyDrxMxPd3LKtLD+9JsIp9j2Z8omMeprZaNJ68V1PWhbvMy EOxkv/Do9qz4hEzAnaLK84H83xntSBjF472900hXXnuowBHDZppwN0jWZoghlsCnQq8m bSKpl3Tj6nUQvD2R3dJJHZ7VgoGo6UhTi8yRT6u2BzzAiP47iJfsS5w0qUkDkSMsliDo V4q7sgPAQOpbjOnBewLuSWq+XW2P99FCe7URWJnkH4jFL2FAQ3Oy01wPZSMeP4qCkYRp OO7PJTBsWrFVGlOWkDVkavncrcHk0KjlTvuI7EYIKqCWEQakFf/Zu3UUCU5uAwommMU8 +SSg== X-Gm-Message-State: AOAM530TW757Y/foecdf5O+2zt1EsRBrYso3sp0OEn57m2CF9GEDjn7A GH3nns4Ul2zsL3oEuBUZ1Bv2OnSSoRw7Ng== X-Received: by 2002:a62:8c85:0:b029:1bd:5441:6cb8 with SMTP id m127-20020a628c850000b02901bd54416cb8mr4238386pfd.29.1613155762557; Fri, 12 Feb 2021 10:49:22 -0800 (PST) Received: from localhost.localdomain (174-21-150-71.tukw.qwest.net. [174.21.150.71]) by smtp.gmail.com with ESMTPSA id k5sm9427618pfi.31.2021.02.12.10.49.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 10:49:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 14/31] linux-user: Use guest_range_valid in access_ok Date: Fri, 12 Feb 2021 10:48:45 -0800 Message-Id: <20210212184902.1251044-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210212184902.1251044-1-richard.henderson@linaro.org> References: <20210212184902.1251044-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We're currently open-coding the range check in access_ok; use guest_range_valid when size != 0. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- linux-user/qemu.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) -- 2.25.1 diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 9fbc5edc4b..ba122a7903 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -493,12 +493,9 @@ extern unsigned long guest_stack_size; static inline bool access_ok(int type, abi_ulong addr, abi_ulong size) { - if (!guest_addr_valid(addr)) { - return false; - } - if (size != 0 && - (addr + size - 1 < addr || - !guest_addr_valid(addr + size - 1))) { + if (size == 0 + ? !guest_addr_valid(addr) + : !guest_range_valid(addr, size)) { return false; } return page_check_range((target_ulong)addr, size, type) == 0;