From patchwork Wed Feb 7 13:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tong Tiangen X-Patchwork-Id: 13548487 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B9BFC4828D for ; Wed, 7 Feb 2024 13:22:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C6816B0075; Wed, 7 Feb 2024 08:22:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 44C586B0078; Wed, 7 Feb 2024 08:22:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 279796B007D; Wed, 7 Feb 2024 08:22:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 131BA6B0075 for ; Wed, 7 Feb 2024 08:22:25 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8FE231609FB for ; Wed, 7 Feb 2024 13:22:24 +0000 (UTC) X-FDA: 81765071808.09.126B8F6 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf17.hostedemail.com (Postfix) with ESMTP id BF69A40007 for ; Wed, 7 Feb 2024 13:22:21 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707312142; a=rsa-sha256; cv=none; b=d58cq67MGJfEaOyCB3Sbi4dIM9Mmft/pB8lXgS664mYHv4FVGL1J8SZso9nydL/a5m8kE7 ZJhtfDVvb417PPO5sTGXPLIr+cwBJab+f6mNOarewXxd0oa/gQ/WjBYXdW5fFp3c2Llpg2 QuoWrc2dL0caHcMC7YcxqpeVJ5+1VhQ= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf17.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707312142; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W+V3hpnEnaWvLyVJnlAq6fqrYusvwPYT3iTx/9ZgIVQ=; b=iL9I7+P/XC4hbhG6gEuSJVrf4pDTOtC5E55bCKbi9YIB1PNDpgmKqQyOnR02NZdDMUcm6M CvALBd6v3/79U7qeriaGihqw4ygVXDB9F3vF0PPNyAc/wzGnFNHQwTasq541JahHWljO1q T8vLvsjN4Fx2FCTeRoC6AYoagaT7C8o= Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TVLJN6TZfz1FKNk; Wed, 7 Feb 2024 21:17:40 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id A0E0B1400CF; Wed, 7 Feb 2024 21:22:17 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 7 Feb 2024 21:22:15 +0800 From: Tong Tiangen To: Mark Rutland , Catalin Marinas , Will Deacon , Andrew Morton , James Morse , Robin Murphy , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Michael Ellerman , Nicholas Piggin , Andrey Ryabinin , Alexander Potapenko , Christophe Leroy , Aneesh Kumar K.V , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H. Peter Anvin" CC: , , , , Tong Tiangen , , Guohanjun Subject: [PATCH v11 1/5] uaccess: add generic fallback version of copy_mc_to_user() Date: Wed, 7 Feb 2024 21:22:00 +0800 Message-ID: <20240207132204.1720444-2-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240207132204.1720444-1-tongtiangen@huawei.com> References: <20240207132204.1720444-1-tongtiangen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600017.china.huawei.com (7.193.23.234) X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: BF69A40007 X-Stat-Signature: a8zxuutidm1mu1sap6aesb8uwjde8acs X-Rspam-User: X-HE-Tag: 1707312141-675928 X-HE-Meta: U2FsdGVkX1+i9KEMkZBfrWihw3cS8jOKFd4F3vA2VoacQjZgbB9FvrmNQlAJK2QkPpp3Xjc/LjMoGvaiCttztE/kIFXl8UaTk910uDmtPRU4wZbwaSW2puSrq2suk8CC/OVLtKIjMt3OBLGw9fO8VnVgQC57FnyCz4BG+NJ+6N9uBvJpKPyrsHE424wTTQ5l7Y2tKXGkOPakThMTFkYz6JScWT/wBbdfD2KZB8m1INa6e8ew8KSgBoMTW4zceHWDeyXw+QJ0A1xe8is0Oytx3ZDWPvGz7iTZdb8HxQr3Q18KUL1zuSWllHpj2zdXlMDEsCWjvu3w2jqsM8R5W3SLhbEQHiDwFKu7OWinn9JVn1agTVe2U2LvfkC50HxXL1ZuviDkBbprF7Os/UUtNsl1t+zyYJodn/POyCqW3ZbLsAEkuqaIm53b4B+h5mzeeRfx9Du9/X6o+cDWRL7E4+xt6zDvIkrVl5PIg3lxFI9i+xRfw0uh3qPLKc75AutJnIg3r2hHg+wFdUdTUVslq2tRyQk9ihWEqoqsK3g/o5QDyTsiYKjYUnDsKDqiindy/VviowXpsBx7GRZneKZ35FizSfpaleJFfq6jaUeHqRAka/73lvANtTuFIdstZ+38c+3TNHPZME2ZbfcIJ9MsCxFgpNsM7jhzFpSdHE1yrK7joCbxptj71KwQwZRqV75BX4Gzg+x2z17W7CyxibY6MFW5biwFD+/F5gDX0hSYPTS/lBJ/YzfSZYtaIHFm6IXUws2tgiuLWeCo9lIAdN8FWv1JMgdmujTdCkIfVCDCyO5kFBYjqfAu13HbHKDosM7DqU62yGkuFiMoR0VCnZINzSL/4ftyzdoP2vrjtu5d2orr4rDqkv75Mn/DmDZc37/r1uz6N9Jy5RAZybQoU/kdRJZuzeU9vA9QtH0yozLUIqZIouft/yvs7NXG5Wun2Xti7sWVWaKDkPXAeRyHO+r59L9 FjseF8lQ VOQwerB5TD3kVX3z81JTZP+/J/TIibnOWJZ6qGeRXDk9EsToweRkoJgZv1LKKnCxsdbnqn55qYPiTREx9o27A2TNcq/uF2EI4jHvgS8eqogELfYg7Gm6dtZe7H7Gv4gZ7Vc6ymW0pifXu8Hd18jO2HDUL36VSdD2rdUFAVx5gjvkkRYbILYgudJQLXbB8e04j93lPFiS4dj1k8WCeuz0iTTLOO+lL3K0xdXU2MAZxpERYljS+AJ2eANI+3+ArjhQZ1nJP5OcQ/JmEJGM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: x86/powerpc has it's implementation of copy_mc_to_user(), we add generic fallback in include/linux/uaccess.h prepare for other architechures to enable CONFIG_ARCH_HAS_COPY_MC. Signed-off-by: Tong Tiangen Acked-by: Michael Ellerman --- arch/powerpc/include/asm/uaccess.h | 1 + arch/x86/include/asm/uaccess.h | 1 + include/linux/uaccess.h | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index f1f9890f50d3..4bfd1e6f0702 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -381,6 +381,7 @@ copy_mc_to_user(void __user *to, const void *from, unsigned long n) return n; } +#define copy_mc_to_user copy_mc_to_user #endif extern long __copy_from_user_flushcache(void *dst, const void __user *src, diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 5c367c1290c3..fd56282ee9a8 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -497,6 +497,7 @@ copy_mc_to_kernel(void *to, const void *from, unsigned len); unsigned long __must_check copy_mc_to_user(void __user *to, const void *from, unsigned len); +#define copy_mc_to_user copy_mc_to_user #endif /* diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 3064314f4832..550287c92990 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -205,6 +205,15 @@ copy_mc_to_kernel(void *dst, const void *src, size_t cnt) } #endif +#ifndef copy_mc_to_user +static inline unsigned long __must_check +copy_mc_to_user(void *dst, const void *src, size_t cnt) +{ + check_object_size(src, cnt, true); + return raw_copy_to_user(dst, src, cnt); +} +#endif + static __always_inline void pagefault_disabled_inc(void) { current->pagefault_disabled++;