From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDFD3C5320E for ; Mon, 19 Aug 2024 13:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:CC:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=j3N5fuhgmE2SP4wzPOW4e9q1CcjJbHPCkFmSoK479H8=; b=BV5Y5mGRyPXiO+diUIonfctemI 5Y7gtmT9A5Xg2VyaF2s3X1IjEmuP3VjfRHEppBBLiI/2tuplS8/1fRm+I4WCV7VDEaKWfbOpfJf4Z uK2CJ54aTxmDofvVF2a2ATA28zUgyEYzMpUS99DN6TcfAEdG2/8x4lYePYxbpmTvGx9c0FzQynLUW 5X1ZDFFiOzMNmUT1ka7+TFhHcHq0ZMBM8XH+uWiy4Wi0/sK90anmhtzv9u2w2Mo77eyEnKewqEJX9 4u//4J+9iFTQh13F56lDmngutGzbSjZr3iTfk3andDj7p8S7DYPrHewFnTQy8CJAbH9hrB3SB9hSp X+UjovNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg2BJ-00000001Xhe-2RDi; Mon, 19 Aug 2024 13:12:21 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg2Ab-00000001XZT-2nM7 for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 13:11:40 +0000 Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WnXyw0xzszyQDd; Mon, 19 Aug 2024 21:10:48 +0800 (CST) Received: from kwepemm600017.china.huawei.com (unknown [7.193.23.234]) by mail.maildlp.com (Postfix) with ESMTPS id D292C140159; Mon, 19 Aug 2024 21:11:24 +0800 (CST) Received: from [10.174.179.234] (10.174.179.234) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 19 Aug 2024 21:11:22 +0800 Message-ID: Date: Mon, 19 Aug 2024 21:11:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v12 1/6] uaccess: add generic fallback version of copy_mc_to_user() To: Jonathan Cameron CC: 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" , , , , , , Guohanjun References: <20240528085915.1955987-1-tongtiangen@huawei.com> <20240528085915.1955987-2-tongtiangen@huawei.com> <20240819105750.00001269@Huawei.com> From: Tong Tiangen In-Reply-To: <20240819105750.00001269@Huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.234] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600017.china.huawei.com (7.193.23.234) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240819_061138_306603_1168D31A X-CRM114-Status: GOOD ( 17.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 在 2024/8/19 17:57, Jonathan Cameron 写道: > On Tue, 28 May 2024 16:59:10 +0800 > Tong Tiangen wrote: > >> 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 > Seems like a sensible approach to me given existing fallbacks in x86 > if the relevant features are disabled. > > It may be worth exploring at some point if some of the special casing > in the callers of this function can also be remove now there > is a default version. There are some small differences but I've > not analyzed if they matter or not. > > Reviewed-by: Jonathan Cameron copy_mc_to_user() and copy_to_user() have the same logic of copying the memory. The main difference is that the MC version can handle the hardware error. The implementation of MC version is related to the architecture. Therefore, when the architecture does not implement the MC version, it is logically correct to roll back to the no MC version. Thanks :) > >> --- >> arch/powerpc/include/asm/uaccess.h | 1 + >> arch/x86/include/asm/uaccess.h | 1 + >> include/linux/uaccess.h | 8 ++++++++ >> 3 files changed, 10 insertions(+) >> >> diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h >> index de10437fd206..df42e6ad647f 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 0f9bab92a43d..309f2439327e 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..0dfa9241b6ee 100644 >> --- a/include/linux/uaccess.h >> +++ b/include/linux/uaccess.h >> @@ -205,6 +205,14 @@ 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) >> +{ >> + return copy_to_user(dst, src, cnt); >> +} >> +#endif >> + >> static __always_inline void pagefault_disabled_inc(void) >> { >> current->pagefault_disabled++; > > .