Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2412717rwj; Mon, 19 Dec 2022 04:21:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXvHmZmjrhD7LaHgQxUdO/hqUJMQ2Ygn1AmKWxIUJhjtiP/sBO2QwWyaVhPZgwg9gr8etpBq X-Received: by 2002:aa7:dbd0:0:b0:478:b87d:94d0 with SMTP id v16-20020aa7dbd0000000b00478b87d94d0mr6398680edt.17.1671452478814; Mon, 19 Dec 2022 04:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671452478; cv=none; d=google.com; s=arc-20160816; b=QTeqJZxaJ1PUPzTpQ0K/l9OuizmUoMrJ2zDrN1yl/HLe0//j7VCJtW0oNYDvsP0VFK H60bQO84OZSkjWVqF1xz2IrzVi2k35CAush/DZ80F4WNdHR8/Nz8lJcSY/AvPqtPul4M mx8f1pDwRammaYxoDHq3w85+Ey2wDAJO4mJX56UYE/HHTUifGzifOGAKuDYFaCPX2V3H D8x3N+ij0T2Nrk7P1NzFYIn+Yqd9/e6OJd1elMiUR/J8KPgrwtWIdeGNN64R4Mr2awjk hEduAtV/HPF+it6guwHYWwnT1BfkU4nJ/jKkNj4IgU9WHQB5esATPGm4vkleQLUVN6O5 eDaw== 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=WNhk9CFgEgukzoHbRsO98T7cEkYKNoKzrzUU/0C7L5o=; b=tm0IaiWLKYcwiPnTsm/n9/SWHLkzltD3MHVfb3GpgkfJ35JXZ7zEhGvmGMpkMbza1x zUu/aHD9NKqLbaPuYi+kyyW8jQHN311Qr3DcFPmaNbk1v0CHoz62+aHGPISzAUQ6Lp+s lJqhlOW+pXieLaD+8UUZC3SCo//t252fF+ROQef9yo8J51+Hvo7l0L2A9xDExcn492MJ RsjO2ZgH7+8kNZ7Pr1Ib/F5ojNMDrTIv2TKvpMJzpgJmtfF2kQ4ORx6hLYeCi+hd10Tb rWJuH0UKZdoFX5FEQoECej3iP8bQvkFL3cY4kAhTZNESeEy65hThK7uexXASWoNLaqoD 7e/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a05640211c800b0046bdaa564bdsi10644976edw.419.2022.12.19.04.21.01; Mon, 19 Dec 2022 04:21:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232006AbiLSMCX (ORCPT + 70 others); Mon, 19 Dec 2022 07:02:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231453AbiLSMBX (ORCPT ); Mon, 19 Dec 2022 07:01:23 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6B84286 for ; Mon, 19 Dec 2022 04:00:40 -0800 (PST) Received: from kwepemm600017.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NbJ8024v8zqT9Q; Mon, 19 Dec 2022 19:56:16 +0800 (CST) Received: from ubuntu.huawei.com (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.2375.34; Mon, 19 Dec 2022 20:00:37 +0800 From: Tong Tiangen To: Mark Rutland , James Morse , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Robin Murphy , Dave Hansen , Catalin Marinas , Will Deacon , Alexander Viro , , "H . Peter Anvin" CC: , , , Kefeng Wang , Guohanjun , Xie XiuQi , Tong Tiangen Subject: [PATCH -next v8 1/4] uaccess: add generic fallback version of copy_mc_to_user() Date: Mon, 19 Dec 2022 12:00:05 +0000 Message-ID: <20221219120008.3818828-2-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221219120008.3818828-1-tongtiangen@huawei.com> References: <20221219120008.3818828-1-tongtiangen@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 3ddc65c63a49..82dc55707c4b 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -357,6 +357,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 1d2c79246681..71a4d7bf9e38 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -559,6 +559,7 @@ copy_mc_to_kernel(void *to, const void *from, unsigned len); unsigned long __must_check copy_mc_to_user(void *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 46680189d761..8726260e5508 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -198,6 +198,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++; -- 2.25.1