From nobody Mon Jun 29 16:45:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FA56C4332F for ; Mon, 7 Feb 2022 07:53:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237034AbiBGHwo (ORCPT ); Mon, 7 Feb 2022 02:52:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243299AbiBGHvC (ORCPT ); Mon, 7 Feb 2022 02:51:02 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58DE5C043181 for ; Sun, 6 Feb 2022 23:51:01 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id g8so1723359pfq.9 for ; Sun, 06 Feb 2022 23:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3bIYzWqmKF4OUiLArYTAXIwmNIkF1zAp2Bo8KhvDjuI=; b=mfPEoaUoTNW4cZcUnhtyn0r4mMu9F+6a9vIIHAKnZduKijW6Dh8TOxtB4MdRXrf0Zc HNOp7UcYZ1sjqM1rJLtFss7HewON8j2NSkYuf8xhCoTyFzEtkhX23nOyDxybW0R6jLcT uzS6JntswqmLoMKx5UGFHTDfq7HJV7tK9tbzK+wFknaHJIG/QbuFqeWyetbJ+yEBd0df vbvDxEqpko/urGmhVsfxjK5Qf7DWwZr9NxRP/28AmJjpSP0vjBdpQ1ZuoH8F0B32SFBB C8o96YE5CQQ+w/vBIb3ZrjIYNCuvaJEKz/AwDdDC1zbzhesQU1lPPpRAhFJSk3oY2jbS ZWBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3bIYzWqmKF4OUiLArYTAXIwmNIkF1zAp2Bo8KhvDjuI=; b=kl4TwBeaRkrtuNwYtADJqan1+DJZAxbN4d7fNAfVwLOG4BWvF6RS+MfvgRZCjy5Tov 8vCQQ3Y1AsqxMJd5ovkVjhqqUlSMneEwMH3wVjIkhwv3lu8WQ1HRzovDPWmI9wDZDnDb Aq+DnmJIxnfm2jICIpBb2xBOAEp/D0OiDWPVcYS5jlyAjYy9AwD1nftW7ueDjVXQ83VM hCfKoTnKtoE0aT3Cu7MSuhv44syerHK6jTFNfQwA1cBlo5Z0TbRbkQbvmp0I8v8LZEO1 EmSxX8furzxlWA4/K/AplF/9A9XbxsYT/89PijbKCVqJTN7tX7lMvV39tqCT0VrDpqsH hSDQ== X-Gm-Message-State: AOAM532VXhsIJRI7YiPGuYPK2zkXeSauXNBgCc/GOJ7ABfElSU0pXq0+ SYaK5ogn9fD6HMCd6W7MI945T3rpnhk5lA== X-Google-Smtp-Source: ABdhPJwTL/+cIZ3C18clOHCWfWcmnq939swO65hH5D76BW4zzZBiUUz9TobGzV4hvCovLT3KuCzZpQ== X-Received: by 2002:a63:ad44:: with SMTP id y4mr8491023pgo.160.1644220260405; Sun, 06 Feb 2022 23:51:00 -0800 (PST) Received: from localhost ([2409:10:24a0:4700:e8ad:216a:2a9d:6d0c]) by smtp.gmail.com with ESMTPSA id 8sm20150775pjs.39.2022.02.06.23.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Feb 2022 23:50:59 -0800 (PST) From: Stafford Horne To: LKML Cc: Geert Uytterhoeven , Christoph Hellwig , Arnd Bergmann , Stafford Horne , Jonas Bonn , Stefan Kristiansson , Randy Dunlap , openrisc@lists.librecores.org Subject: [PATCH v2] openrisc: remove CONFIG_SET_FS Date: Mon, 7 Feb 2022 16:50:36 +0900 Message-Id: <20220207075038.3811999-1-shorne@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the address space override API set_fs(). The OpenRISC user address space is now limited to TASK_SIZE. To support this we implement and wire in __get_kernel_nofault and __set_kernel_nofault. The function user_addr_max is removed as there is a default definition provided when CONFIG_SET_FS is not used. Signed-off-by: Stafford Horne --- since v1: - Fix commit message with misleading comment about User Mode Linux. arch/openrisc/Kconfig | 1 - arch/openrisc/include/asm/thread_info.h | 7 ---- arch/openrisc/include/asm/uaccess.h | 48 +++++++++++-------------- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index bf047dca7ec6..ceda77fb8bc8 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -36,7 +36,6 @@ config OPENRISC select ARCH_WANT_FRAME_POINTERS select GENERIC_IRQ_MULTI_HANDLER select MMU_GATHER_NO_RANGE if MMU - select SET_FS select TRACE_IRQFLAGS_SUPPORT =20 config CPU_BIG_ENDIAN diff --git a/arch/openrisc/include/asm/thread_info.h b/arch/openrisc/includ= e/asm/thread_info.h index 659834ab87fa..4af3049c34c2 100644 --- a/arch/openrisc/include/asm/thread_info.h +++ b/arch/openrisc/include/asm/thread_info.h @@ -40,18 +40,12 @@ */ #ifndef __ASSEMBLY__ =20 -typedef unsigned long mm_segment_t; - struct thread_info { struct task_struct *task; /* main task structure */ unsigned long flags; /* low level flags */ __u32 cpu; /* current CPU */ __s32 preempt_count; /* 0 =3D> preemptable, <0 =3D> BUG */ =20 - mm_segment_t addr_limit; /* thread address space: - 0-0x7FFFFFFF for user-thead - 0-0xFFFFFFFF for kernel-thread - */ __u8 supervisor_stack[0]; =20 /* saved context data */ @@ -71,7 +65,6 @@ struct thread_info { .flags =3D 0, \ .cpu =3D 0, \ .preempt_count =3D INIT_PREEMPT_COUNT, \ - .addr_limit =3D KERNEL_DS, \ .ksp =3D 0, \ } =20 diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/as= m/uaccess.h index 120f5005461b..cc9c5d8fd183 100644 --- a/arch/openrisc/include/asm/uaccess.h +++ b/arch/openrisc/include/asm/uaccess.h @@ -23,36 +23,12 @@ #include #include =20 -/* - * The fs value determines whether argument validity checking should be - * performed or not. If get_fs() =3D=3D USER_DS, checking is performed, w= ith - * get_fs() =3D=3D KERNEL_DS, checking is bypassed. - * - * For historical reasons, these macros are grossly misnamed. - */ - -/* addr_limit is the maximum accessible address for the task. we misuse - * the KERNEL_DS and USER_DS values to both assign and compare the - * addr_limit values through the equally misnamed get/set_fs macros. - * (see above) - */ - -#define KERNEL_DS (~0UL) - -#define USER_DS (TASK_SIZE) -#define get_fs() (current_thread_info()->addr_limit) -#define set_fs(x) (current_thread_info()->addr_limit =3D (x)) - -#define uaccess_kernel() (get_fs() =3D=3D KERNEL_DS) - /* Ensure that the range from addr to addr+size is all within the process' * address space */ static inline int __range_ok(unsigned long addr, unsigned long size) { - const mm_segment_t fs =3D get_fs(); - - return size <=3D fs && addr <=3D (fs - size); + return size <=3D TASK_SIZE && addr <=3D (TASK_SIZE - size); } =20 #define access_ok(addr, size) \ @@ -241,6 +217,25 @@ do { \ (__typeof__((x)-(x)))__gu_tmp); \ } =20 +#define __get_kernel_nofault(dst, src, type, label) \ +{ \ + type __user *p =3D (type __force __user *)(src); \ + type data; \ + if (__get_user(data, p)) \ + goto label; \ + *(type *)dst =3D data; \ +} + +#define __put_kernel_nofault(dst, src, type, label) \ +{ \ + type __user *p =3D (type __force __user *)(dst); \ + type data =3D *(type *)src; \ + if (__put_user(data, p)) \ + goto label; \ +} + +#define HAVE_GET_KERNEL_NOFAULT + /* more complex routines */ =20 extern unsigned long __must_check @@ -268,9 +263,6 @@ clear_user(void __user *addr, unsigned long size) return size; } =20 -#define user_addr_max() \ - (uaccess_kernel() ? ~0UL : TASK_SIZE) - extern long strncpy_from_user(char *dest, const char __user *src, long cou= nt); =20 extern __must_check long strnlen_user(const char __user *str, long n); --=20 2.31.1