Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp23719pxa; Mon, 3 Aug 2020 21:25:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEkQgPvoTu9ooXaMlWxQ93eyiBuEkajqQjkDkX26Rd9ssrWWO/6R4OFmS0RMqRxWAE0v7i X-Received: by 2002:a17:906:6558:: with SMTP id u24mr18896408ejn.364.1596515131917; Mon, 03 Aug 2020 21:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596515131; cv=none; d=google.com; s=arc-20160816; b=GEG3twYwx4w7zWT/GZWwxx1/Q1eS5yUgI0JVQrgqJUGCUbqqNbYeLAI3Z39W6/jwGj 46Ev6SmvC5hwFPtSlyxg2W2M1smbtaDnMEijowh/ydgNCQsOWTA4Sgm6428c+83EDeQX 6ZFujhEEQmcmyIO9PkGop0Jw68UptlQOKt0saSOwYiqKejZ2ofKfpyDtX4yN7kZSJ9Fp p4p7hJXx8tKjDAfLRL/gqM/lZzd2JW3iAkMWs9FhAm1YdmyaZ46d5DLGYUHPVqr2YPJ/ pqNhVmQOR4jsoOxARYC1ASv+C5+R0eqxdZXCcZFqumMTahM5UVT/pErYX0w7iy/rQgYP +HDw== 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=6FQQh9grVE9WmqeYXdehIdQwW9U/dAMb893sRAt75ZM=; b=WnD4PeBFN7ygWaU7JRonIzUrh+V4tk754RahPFYHp5rgZUHUFsfUDoHdLk35Q5Sr31 /fJQmpDIy9K/8bzk4YxAIKs6yx+Fwk98iih0g0Np7toZ3gfbxrewwbzDhMchurTC2nHy zre+Mm9gCYf2qaG4jEn0pSoXZYcsPinX8fOD+9VGlLF7Bzx/ra1qabYxf+t4eLi98Ref fTzZzy/1D2Y/KmjD7pmqueU2ENj8698XtON41OAfq7Yt2/Ti6v8DMpuFUTkLe8FopcqV TzaKqdsaHknukCRomVvkMddl6Imy9S/ei5Ui4rnLuKBXol+nr9xQdP5MSyRV/VmHOgU5 CfGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uBZEqpyk; 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 x60si12359774ede.582.2020.08.03.21.25.09; Mon, 03 Aug 2020 21:25:31 -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=uBZEqpyk; 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 S1729684AbgHDEYU (ORCPT + 99 others); Tue, 4 Aug 2020 00:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725999AbgHDEYU (ORCPT ); Tue, 4 Aug 2020 00:24:20 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4022AC06174A for ; Mon, 3 Aug 2020 21:24:20 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id t10so16823449plz.10 for ; Mon, 03 Aug 2020 21:24:20 -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=6FQQh9grVE9WmqeYXdehIdQwW9U/dAMb893sRAt75ZM=; b=uBZEqpykqt1c/NtoFtFkiYRPjXq/DjkOC0dqEIKQYgA2z0nQlsMOqtZvNnnfjhBavS yxgafmW7t7eLvEI95aD4U3Q++5esqlDcoAha32yxun7dmQcnCodO7Q26e6yB+zvXjHBR Ptg2VdD7gcpq05vmN5IaF6kFxdeSiV2kgF40qS2kmBwEBqyL6K9GGSl+TqoKva7HX8YS EhM27dQ1eauN2I4rZh7uozUGDyngS1OqWLpLzpTqNugz+hLtY//Oz3TST/Zh+K/fnNwx WVygcl1Sxfi7L++kT6MTKKOgHiHPQ2YIxyNddZR+FC+URSgoATOvCJiiQ+bNWWdcYyjA dpjg== 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=6FQQh9grVE9WmqeYXdehIdQwW9U/dAMb893sRAt75ZM=; b=awWettHnOfAVp3JjmYq94VGN02BXxezcAT+WcjBc0MgmtHFTS5eUJIbUCuz/e4z+i2 Z6XaPz8Pie9lPdALxsPxd8GzhCEHiBq4zG5FioUmir9seMsscvDGz71xiKQcUBKdNJhA daNHFHAZQYyciYG+f/1uG+qhFh2mJlDZBkhPFVkkTEsWEzE57sbdZPjXFxLmuXgbnSfd WhoBUDhyygXiFFcDrU64X3ZEANg+xhPfxwj2wFe2CWhhrSYaDTYKz8TbqvotMsAIbWe1 250vdlGf8KiZaRazHl8VctJSq3LrbzkxV4Ap/IIHIo9Q7+BNoBdGxff76tyc6aHgfK0s IIYw== X-Gm-Message-State: AOAM531rSFbVSd8hJtbHv5CJKzhOjPhbDr2TxNtueGKt7ZVnEAgsW1r/ r0u6KMFpKjrVX4BQofa4q5I6d66x X-Received: by 2002:a17:902:9349:: with SMTP id g9mr17504812plp.313.1596515059299; Mon, 03 Aug 2020 21:24:19 -0700 (PDT) Received: from localhost (g223.115-65-55.ppp.wakwak.ne.jp. [115.65.55.223]) by smtp.gmail.com with ESMTPSA id r15sm12279933pfq.189.2020.08.03.21.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 21:24:18 -0700 (PDT) From: Stafford Horne To: LKML Cc: Stafford Horne , Linus Torvalds , Jonas Bonn , Stefan Kristiansson , Luc Van Oostenryck , openrisc@lists.librecores.org Subject: [PATCH 3/6] openrisc: uaccess: Use static inline function in access_ok Date: Tue, 4 Aug 2020 13:23:51 +0900 Message-Id: <20200804042354.3930694-4-shorne@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804042354.3930694-1-shorne@gmail.com> References: <20200804042354.3930694-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 --- 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