From patchwork Fri Jan 15 22:46:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 363799 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp275498jap; Fri, 15 Jan 2021 14:59:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJ/aKo/3zNjh8QGqIKil19ZwXDydQmfoj4ZER8pkxmDO6P5mghnK6shKv10OfMBzk7Ouv5 X-Received: by 2002:a5b:eca:: with SMTP id a10mr14546603ybs.91.1610751563558; Fri, 15 Jan 2021 14:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610751563; cv=none; d=google.com; s=arc-20160816; b=SlcxEW+MpSq72AbjPlrXB8uEbbwIHIoEzgxnTTjV+t9UfqnPbU/q+mIVaFKPiCGHUV uu0WN1yVuPfYrbndl+hwnsiRkEjwsQqgmMvQWcEEzKk5pxnAmHaFI9Pa4bDHjHOLfkr2 NLjEzbBeRkqFZjtGLo/zgrEOFUoqtGiHbGhFThICkeyiMxGHbuVYuS0h2xhjXQICIPAB TKsR69fySuVam55aURMKJX+GLgHDOzgWrv+Io0QJ8gJvk0glHuOUecIm5ka1K3Yne+1D kA6sqA/DYmAobTgoFhnMigRmiGONZg8yg8r5sUzy7LaEWECxa6quXkh7/Hw/4v8o0V3h +Mmg== 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=cekQQRp0i5HZWYUW7TcRhFHir1r8zA6FY8NgWmITL0g=; b=rWntz3zBFOwgzDRyud8Fyb3FIed8HSF9G/Mu9n3ObFuh3rJs6WvN6gEMLuCyepxAl3 GPJjFKaauqV+eLR4M5gjl84j9HRyx0GY2mFRAT5g896XBC+HFk+4rrNkAqZxolr9CQdw uC4QM7HYYhslcakHWkbQRFfd1yTD9HUyrc8OtdlosvzztwHqAQZgMstsMvMEN+eufOT6 FTJ07AZR/vvXo4tr2STShZWVAQFecM1tICVTkl3N1tqfQDs+QaUi8baz2C7Z1fTzwDwl RfiFh7yepH711DKycuOXfm8O1MRU9ne5XMRS9kdzCvoHCiCm/xm0ADd8jgsr4Iu5O1cw XWTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jWLwcRYi; 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 e6si5890644ybp.375.2021.01.15.14.59.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jan 2021 14:59:23 -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=jWLwcRYi; 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]:50444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0Y3v-0007Be-0x for patch@linaro.org; Fri, 15 Jan 2021 17:59:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0XsF-0003du-PV for qemu-devel@nongnu.org; Fri, 15 Jan 2021 17:47:19 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:42960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0Xs1-0005FM-6J for qemu-devel@nongnu.org; Fri, 15 Jan 2021 17:47:19 -0500 Received: by mail-pg1-x52a.google.com with SMTP id g15so6927559pgu.9 for ; Fri, 15 Jan 2021 14:47: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=cekQQRp0i5HZWYUW7TcRhFHir1r8zA6FY8NgWmITL0g=; b=jWLwcRYiTngZ/Nzz67lB7NXK3iTuCNdax0+JWEbw4ZbC3U3xoWG/MaR5AOW2OwF0BB wbAETgmrWBV8aZ6tqMm8j8Qjl0gIutGuAvU2+sBOBKrlcakQLADxK+jSwxefH69a4c/t vB7HG3edLYHC4TEXrRmyyME2Kkt/IfiVl1hIXRS/A+up3JLGmngS9I+mSFqrfqn3fYV7 4e7IPFPTegFAa6LcAiFwrONaKLXfNy5JjXM4CxrwYLyzaeFLhuLMv8Fc80XLtLju9U+V uNTczzPWKSv6Tc6jEDOE8LfeuqfZB6DF1xQWt4ZWCw9HNZdI/16zg20pL486EHWK4A0j JoTw== 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=cekQQRp0i5HZWYUW7TcRhFHir1r8zA6FY8NgWmITL0g=; b=phSy/9BWyjKWAIiZ1YFWxP4BNLwrjSOBSAlAaWEt6bXUOUOUgmY1Gr8dXy1gAsorlO Lzbb7/n4zx15VtBTh2jjG9aphsgv9BS4yU6SJI6pNCfGjAk82HCIwAp3FLoa70iltSuA qV2q9H5+9dGKj163Aa1IhWAFHT8cBkmGhxLU4Ss/qa50EApeSVxSsaXptu/vQ4/7TKzM opBqOnSEYDp6YpOhYQ4bzE4DvLxwdqXsHJWBDbGihxhzaydEyb9G6UFdnIhe9I453wX3 UOoxAMnc+YIJAlXWrJLv0/aeZDRipKK1UKIO2fCYyoXl1CyxfnDsNR8AxEohWdGW0Aij /jBA== X-Gm-Message-State: AOAM531O5OAVK4XyHtma2AHY7VHDRJ+RdlgQr/uyvEvzCu7Do5GfiZFD 7VugjfCDCVh1DzlEK4erOHTB1FxJGR2c9ypE X-Received: by 2002:a63:6305:: with SMTP id x5mr14466820pgb.216.1610750821621; Fri, 15 Jan 2021 14:47:01 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 14:47:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/21] bsd-user: Tidy VERIFY_READ/VERIFY_WRITE Date: Fri, 15 Jan 2021 12:46:32 -1000 Message-Id: <20210115224645.1196742-9-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::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=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" These constants are only ever used with access_ok, and friends. Rather than translating them to PAGE_* bits, let them equal the PAGE_* bits to begin. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- bsd-user/qemu.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.25.1 Reviewed-by: Warner Losh Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

This looks OK to me.

Reviewed-by: Warner Losh <imp@bsdimp.com>
 
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index f8bb1e5459..4076adabd0 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -218,13 +218,12 @@ extern unsigned long x86_stack_size; /* user access */ -#define VERIFY_READ 0 -#define VERIFY_WRITE 1 /* implies read access */ +#define VERIFY_READ PAGE_READ +#define VERIFY_WRITE (PAGE_READ | PAGE_WRITE) -static inline int access_ok(int type, abi_ulong addr, abi_ulong size) +static inline bool access_ok(int type, abi_ulong addr, abi_ulong size) { - return page_check_range((target_ulong)addr, size, - (type == VERIFY_READ) ? PAGE_READ : (PAGE_READ | PAGE_WRITE)) == 0; + return page_check_range((target_ulong)addr, size, type) == 0; } /* NOTE __get_user and __put_user use host pointers and don't check access. */