Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3271064pxa; Sat, 8 Aug 2020 16:08:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWvfhXzLus8bA73q4QJgOA/Iem2JaW8spgmph62jgKa2GCyecJLBw0rITLD6c/Xx01FZk3 X-Received: by 2002:a05:6402:37b:: with SMTP id s27mr15107491edw.239.1596928096336; Sat, 08 Aug 2020 16:08:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596928096; cv=none; d=google.com; s=arc-20160816; b=vkuDsDaea+s6ooDq18/YSmzD8jkXixVODupadsZJvBtEuoia2Du06nZPuqi912HzLe v07OxAaS/RvJsypq3BnIk6zU0A6pa9DLw/tq7r5qyJW2A/dKt43RQ06SHaeAWO1tHWRG sD+TsKphTM8N59lfChjfZHOHhE5evuOyr+WHW2KhBQIMZh62cB5uPi0e/B95tA5wuYxD 0NeE2+WUE747g0ea6Jt6v9IKnRi9+HkCjSmy3nSJsQn1VKK17SEFHYPMPMDnUWXpubtP ZWx5AGTcI6cA3uot7FYNa9Wt7aZZjdAbTjYChmlj0lHEuNcH472QPUQ2qy6TXYC2Mo1V cPuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S+PYM2LWPubAwsecp2cm9Eg9qZYacd1EtMsG3lIYCHo=; b=yqfPIUDLcZ3X+8/j1SY6dgaa/UiyoRW0b24mdT3vW6OE+0m6gRP9aj7//IpKgVJNln 0UCN0GhssM56KfxMndGLahkocS7tSLgdxizOXOtRbhkY7h36autclubfu2puEIfh6egK Q2MfYudxSH+15YsFwF/5hjYQiw6aerVGkQuPZWD25ld2medmTMRFpL6jMd3erHOZV+Rx iZhMs0COrlAnXhVGruQaelac+pHCQ05gnsqZq4mnKqdNA9IuRi00NvhF0G6wU8y01nda GOZU4WllbEaKpZdz7t0Yp7H2hIfSQ/Gioos3lup5UNhbVuqGs55CIMS3AZfC08AqUwyB qFZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tTIufmJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t28si8193211edt.38.2020.08.08.16.07.54; Sat, 08 Aug 2020 16:08:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tTIufmJ0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726393AbgHHXHL (ORCPT + 99 others); Sat, 8 Aug 2020 19:07:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725950AbgHHXHJ (ORCPT ); Sat, 8 Aug 2020 19:07:09 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BECDC061756 for ; Sat, 8 Aug 2020 16:07:09 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id m34so2860878pgl.11 for ; Sat, 08 Aug 2020 16:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=S+PYM2LWPubAwsecp2cm9Eg9qZYacd1EtMsG3lIYCHo=; b=tTIufmJ0TWMbd03xb8vnegxRX7bK+EaEleQwIcF1OSAOhCGoEhjxnNl3NeMEAatVKV AT14Tfkj9Sh8mHs9WSq4oKZF/urVFxOZKsNulnD3p8EKzyy4Lh/AkWTnCw9PBdLYhlMj rOgKwq6r9M1v9DM7fViMn4+QC/DpWWxQdxQosa2CCopnZYKw/Mwnp5cqnQ0uJUvmg72Z ZTK2vzs2THaJOFBdR38/KNjZfeI4QQaUsARbCsfOjN+S767We5MAWaIQKb5hWjA83v5O /apmaclkvqE5DpoAQpNLOodEZmbw0TmqPay5E3vMZFwNjJmERcAEDdks4mi7xuoiVgeL Pg6A== 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=S+PYM2LWPubAwsecp2cm9Eg9qZYacd1EtMsG3lIYCHo=; b=iuL0NKBeyIiwE5/VZu+Fo1ZLkPWAqtKISd9aHPcm4a+nuZ4HBFgbkir37CPKiLun3i DSR4Tz+g0x187+UNa4YDr2gC61kIrK/h1cqIH31l0pVtGPjuBoOIy5hueXSMCc9HxqGI NQvtGekTIlU4SQpTQF018yNhGZ9A/UmmGjftPe/L0dVRvt1vPymm84WMzZjr0/ifemzG Exc9n7mDUfCfOm9gWdq7/s1CWXn9ZbEy4Hqh7opknFWaE6xM4bKXfxkUEVFMdG4frqaX s2/yA7rCIk/yDL6kQ2QlQz3yoyDAhIIiQUhWae2D19CZGOCYKEIIciGUH4V2HRAl/ulC BalQ== X-Gm-Message-State: AOAM531AaY5PPPdmSgwVGEOwRtzZDyIVyR28We/iePS9wTntdyvawMjy UrDd79jOycNPDOsgAJQiEirqrCBb X-Received: by 2002:a62:b417:: with SMTP id h23mr18259041pfn.118.1596928028346; Sat, 08 Aug 2020 16:07:08 -0700 (PDT) Received: from localhost (g223.115-65-55.ppp.wakwak.ne.jp. [115.65.55.223]) by smtp.gmail.com with ESMTPSA id x7sm17623887pfc.209.2020.08.08.16.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2020 16:07:07 -0700 (PDT) From: Stafford Horne To: LKML Cc: Luc Van Oostenryck , Stafford Horne , Linus Torvalds , Jonas Bonn , Stefan Kristiansson , openrisc@lists.librecores.org Subject: [PATCH v3 3/6] openrisc: uaccess: Use static inline function in access_ok Date: Sun, 9 Aug 2020 08:06:44 +0900 Message-Id: <20200808230647.833047-4-shorne@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200808230647.833047-1-shorne@gmail.com> References: <20200808230647.833047-1-shorne@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As suggested by Linus when reviewing commit 9cb2feb4d21d ("arch/openrisc: Fix issues with access_ok()") last year; making __range_ok an inline function also fixes the used twice issue that the commit was fixing. I agree it's a good cleanup. This patch addresses that as I am currently working on the access_ok macro to fixup sparse annotations in OpenRISC. Suggested-by: Linus Torvalds Signed-off-by: Stafford Horne Reviewed-by: Luc Van Oostenryck --- arch/openrisc/include/asm/uaccess.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h index f2fc5c4b88c3..4b59dc9ad300 100644 --- a/arch/openrisc/include/asm/uaccess.h +++ b/arch/openrisc/include/asm/uaccess.h @@ -48,16 +48,19 @@ /* Ensure that the range from addr to addr+size is all within the process' * address space */ -#define __range_ok(addr, size) (size <= get_fs() && addr <= (get_fs()-size)) +static inline int __range_ok(unsigned long addr, unsigned long size) +{ + const mm_segment_t fs = get_fs(); + + return size <= fs && addr <= (fs - size); +} /* Ensure that addr is below task's addr_limit */ #define __addr_ok(addr) ((unsigned long) addr < get_fs()) #define access_ok(addr, size) \ ({ \ - unsigned long __ao_addr = (unsigned long)(addr); \ - unsigned long __ao_size = (unsigned long)(size); \ - __range_ok(__ao_addr, __ao_size); \ + __range_ok((unsigned long)(addr), (size)); \ }) /* -- 2.26.2