Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1433584rwb; Fri, 12 Aug 2022 00:21:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR5sAhRhW4EAmA8Pi5WrVERk2zfMobfkGoLjPdoM0PnvNVjEgwCL/zsGLEHonjSSn6SlqKCq X-Received: by 2002:a17:907:2be3:b0:730:6866:a9b1 with SMTP id gv35-20020a1709072be300b007306866a9b1mr1761430ejc.693.1660288876671; Fri, 12 Aug 2022 00:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660288876; cv=none; d=google.com; s=arc-20160816; b=SvEAKgxNgagAn38HbaMRFHDlV6U3AFFi8rg8/AojuIsGjEDzQmaZw3MO7iociNRiuO No/pp56WN0xmAfNbqTDpiwuh86ufJtulfMinDk/zxbG0S2cvSu2ej9/7HhEoFqeVqupO 2gjPAPfQxgyUibwywN/QPQJDkuD43R5y3Aru4eHM3k9yOK43vbxvA2l2sRPO72YV1xjC sFpVQKLOKyvfEGGSDlGDKE0SqfdSYhgtE/GCX1TqUhfglXQcMLr1GqCN1EfsqiRYcd+Y F+uAa961oRiFe8iPB1owJrk70izsu2xU6V9q9g+Gq4c/OdHbhHxqaXl+tmY3ShDQm6PF evFw== 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=rmrvhio2YZLA+OoFpK4GbMQAILWLTAFAKTmFxAzMXxs=; b=Iegco0g3vkrMP9x4L3wbQ26ouF7fJbc8PV0dbMEp3ffKVt2XhW2cOEfzClBS0QMQiL FOpZQmSFh780u3U1I/OlVXuoymCYclo0qPoyuKM2JNh5Oy4SvAY6YOMcVeb2qPT/AguK d2NxQD4kpF2XPUZLfZq95EBpOwztpyGpk8/0yf03RnC36XTzh8iIe0nwkH1IYyz197UB EuuEGansgYs3/Ab4m+J5v0T6LcyzCFKd5SE0iXARCMqO/lc9Wp7IDksekYfp7ypo6eIR XjBST9XTLVVGWOG8rcFWmk2/iAFzrc/mD3MICNDZSOYKx0zwnt46L8JRh7hL8ePrOO+n oaSA== 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 ez22-20020a056402451600b0044347b22b2bsi296728edb.354.2022.08.12.00.20.50; Fri, 12 Aug 2022 00:21:16 -0700 (PDT) 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 S237269AbiHLHGe (ORCPT + 99 others); Fri, 12 Aug 2022 03:06:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237130AbiHLHG2 (ORCPT ); Fri, 12 Aug 2022 03:06:28 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2A574E18 for ; Fri, 12 Aug 2022 00:06:26 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4M3vlL2VgXz1M8lr; Fri, 12 Aug 2022 15:03:10 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 12 Aug 2022 15:06:24 +0800 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.2375.24; Fri, 12 Aug 2022 15:06:22 +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 , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , , "H . Peter Anvin" CC: , , , , Kefeng Wang , Xie XiuQi , Guohanjun , Tong Tiangen Subject: [PATCH -next v7 1/4] uaccess: add generic fallback version of copy_mc_to_user() Date: Fri, 12 Aug 2022 07:05:54 +0000 Message-ID: <20220812070557.1028499-2-tongtiangen@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220812070557.1028499-1-tongtiangen@huawei.com> References: <20220812070557.1028499-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: dggems704-chm.china.huawei.com (10.3.19.181) 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,T_SCC_BODY_TEXT_LINE 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 913e593a3b45..64ba7f723ddf 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -512,6 +512,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 47e5d374c7eb..6f48ad43a82e 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -174,6 +174,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