Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp342386pxf; Wed, 31 Mar 2021 04:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL0Ajr7yg7ml2iSYMx9AKhKlCiANalH8pfjm29wYnkwfoT3U7vlu5gqG89UQg0WJOF5nkX X-Received: by 2002:a05:6402:3593:: with SMTP id y19mr3179475edc.317.1617191875118; Wed, 31 Mar 2021 04:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617191875; cv=none; d=google.com; s=arc-20160816; b=K3ObC5IxwP8xUxXyTOsCwH2uImdBK4Vf3XexLsD1r7YOY+tQ+Sos665Trcfw3YjDU7 26R1NrkNp72BaI6wdRvz+P8aCy0/MYVIlgn3uoMY3zGTXVphg4EPpzDhfl94RbNH+eUD QXrFNrtndhxlNeJFjTk21JU8Ho2yGoJbw/7GYNVLU/ysdfdaTKEOD6eFyCVG0zIzhq77 1KxHhjRWyjAPDITGt6DYdgiiX+1mg672aKdMQI0NSD/GL4xGc/iaFUaUw2qTglHC3Cpc PVv4dsjGaGd1zadCFHVNNVdz94M0TI4b5udkjhglvBsM7OF4KtRyMZ7Nyv6qpis2J0xw vPrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=jRxFkYEjCApGdVpgMl+WmWFQ0R+cNbBEB80QkfiwB5w=; b=fc2xOwos8kn0KnOEuZCJPy9N9pm4n+VvBr3QiPxP6YXLppij3ivAJ4ruzmlKBexqQi 0aeIX8NqeUzg/xvd7Y3YTM2ZMmRbHEHm516FMbxHne/+gqD8mBu7erKu4vvBspgNG/3l ODO7LaJfyljXtrpvujU8YaQJUCc07GfPv8I6UXYbAI7estJxomfkaDfl0LHLNPAh4RA9 iq928sSSjaxm/S8GeK7zwNeFa7tF9ob25P2t1WvaTV2KDmg4E3lYiz9qXFbaYA96VCvY sKUx66YBDvnK4v9zm3PnWQYjBOjT6J0tLYcTrX/VIvE4VvBK4QE/J6cEGL5t2eKRiu9I ry7g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s6si1487054ejq.79.2021.03.31.04.57.32; Wed, 31 Mar 2021 04:57:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235375AbhCaL4j (ORCPT + 99 others); Wed, 31 Mar 2021 07:56:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:51748 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235019AbhCaL4G (ORCPT ); Wed, 31 Mar 2021 07:56:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A2D03B1E6; Wed, 31 Mar 2021 11:56:05 +0000 (UTC) From: Thomas Bogendoerfer To: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: hch@lst.de Subject: [PATCH v2 2/4] MIPS: uaccess: Added __get/__put_kernel_nofault Date: Wed, 31 Mar 2021 13:55:59 +0200 Message-Id: <20210331115603.146159-3-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210331115603.146159-1-tsbogend@alpha.franken.de> References: <20210331115603.146159-1-tsbogend@alpha.franken.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Added __get/__put_kernel_nofault as preparation for removing get/set_fs. Signed-off-by: Thomas Bogendoerfer --- arch/mips/include/asm/uaccess.h | 24 ++++++++++++++++++++++++ arch/mips/mm/Makefile | 4 ++++ arch/mips/mm/maccess.c | 10 ++++++++++ 3 files changed, 38 insertions(+) create mode 100644 arch/mips/mm/maccess.c diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h index d273a3857809..c5cab0b8f902 100644 --- a/arch/mips/include/asm/uaccess.h +++ b/arch/mips/include/asm/uaccess.h @@ -355,6 +355,18 @@ do { \ (val) = __gu_tmp.t; \ } +#define HAVE_GET_KERNEL_NOFAULT + +#define __get_kernel_nofault(dst, src, type, err_label) \ +do { \ + int __gu_err; \ + \ + __get_kernel_common(*((type *)(dst)), sizeof(type), \ + (__force type *)(src)); \ + if (unlikely(__gu_err)) \ + goto err_label; \ +} while (0) + #ifndef CONFIG_EVA #define __put_kernel_common(ptr, size) __put_user_common(ptr, size) #else @@ -483,6 +495,18 @@ do { \ extern void __put_user_unknown(void); +#define __put_kernel_nofault(dst, src, type, err_label) \ +do { \ + type __pu_val; \ + int __pu_err = 0; \ + \ + __pu_val = *(__force type *)(src); \ + __put_kernel_common(((type *)(dst)), sizeof(type)); \ + if (unlikely(__pu_err)) \ + goto err_label; \ +} while (0) + + /* * We're generating jump to subroutines which will be outside the range of * jump instructions diff --git a/arch/mips/mm/Makefile b/arch/mips/mm/Makefile index 865926a37775..76e3ee8882fa 100644 --- a/arch/mips/mm/Makefile +++ b/arch/mips/mm/Makefile @@ -22,6 +22,10 @@ else obj-y += uasm-mips.o endif +ifndef CONFIG_EVA +obj-y += maccess.o +endif + obj-$(CONFIG_32BIT) += ioremap.o pgtable-32.o obj-$(CONFIG_64BIT) += ioremap64.o pgtable-64.o obj-$(CONFIG_HIGHMEM) += highmem.o diff --git a/arch/mips/mm/maccess.c b/arch/mips/mm/maccess.c new file mode 100644 index 000000000000..58173842c6be --- /dev/null +++ b/arch/mips/mm/maccess.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include + +bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) +{ + /* highest bit set means kernel space */ + return (unsigned long)unsafe_src >> (BITS_PER_LONG - 1); +} -- 2.29.2