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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A036FC3DA4A for ; Mon, 19 Aug 2024 13:11:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 16DE66B008C; Mon, 19 Aug 2024 09:11:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 120336B0093; Mon, 19 Aug 2024 09:11:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F00DB6B0095; Mon, 19 Aug 2024 09:11:32 -0400 (EDT) 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 D282C6B008C for ; Mon, 19 Aug 2024 09:11:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 5C757160785 for ; Mon, 19 Aug 2024 13:11:32 +0000 (UTC) X-FDA: 82469031624.05.6EC348D Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf22.hostedemail.com (Postfix) with ESMTP id EEAECC000F for ; Mon, 19 Aug 2024 13:11:28 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.187 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=1724073003; 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=j3N5fuhgmE2SP4wzPOW4e9q1CcjJbHPCkFmSoK479H8=; b=jnTLuu2QVnTATJscB61JZx2z7DxII2EIFWpshnNvCWIsh1thGkEXz3/mY8WBQHk6n9ajmg YNE3Jlt/kFhIKdgSPuh/kXpWWXPoKmgH8UrsS/dDLfmlCCr+Gg9DtKdwgnCTzfcIPl5gs7 xjbnkFjYQDznwPunAc8rUKZ1vDJGpUM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724073003; a=rsa-sha256; cv=none; b=PgAnVc+wDmqZfo2Wda6ABTIoxdb+Gd2Rjgu8YEbT0ljNlrfjNt+U1yNlMOFpoKZ4YadtKy iNemBuG21FdzTHbWmNjcv26RQN22OOKwwGqxFYv7YLFKtyNpzUvW+2Z+hioc1SJysfbK9F nAulrHLmaVTecjfyGBC0pj1E2wU/Zvk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf22.hostedemail.com: domain of tongtiangen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=tongtiangen@huawei.com 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EEAECC000F X-Stat-Signature: m3a6kcwr7nwxi4xjtqruses7965zwaoq X-Rspam-User: X-HE-Tag: 1724073088-5118 X-HE-Meta: U2FsdGVkX19BjH79E4sqWmuuwSErmMsoishiuqtbwPoDH9YJPYIbgbdKVNcN8UEwUNvqgsaBB0D2OFUmAfPlfF92a2P6iqQ341boM5g7COBh9XlXzasOi23Ueauhod30KwUekLBs4dCeAqg5Jn+L2oV+gn7S7tP4vId2l4bYA6oCU488ubiwGjSKW4vtLIruY3IYRdGE/ZaVf4LMhieqcM8sp7iCjzkfExzu3LK/UK7yPycnZFpPT5Xu7zRDgwMuho1ez6u0nr9hlX4dwjjNLozk/jIeuP+AsK+HdSWgsAbrmAVIVzUO+8qPjhjs4pIGDWlzUsWbyog1BmilOOOrJDevcWXIF2ixMR7L4US+4O5VV9aYdPJXZHzw4ejR/95G1egG/KHqyUkm8joEgZT22ViTc3dQokukniw5dvp69fTFUsl1LdSQ/ZHJjJR4SHB10Eh6Gl6YVNW6GluNcn+0fDDSHVioXygyiVoJoKwvt8a2UPL6iHaM4dcRCKlwUUWd7ST6SWEdex+NjuLEUv3Q2RTTzVRxg5B6F48Hh0Agm5HGTW93UA4c9eJPTprdeRhBWDtAa6GkZMk5nwU7J5by+63CnqQyXrNKbwHprXbAInA9UMc9XRNbu0wYx+hQ7p8/CyY0hDtDSEXyuflH+CPxN89vxlhJ0TUL8PkmUhlDg7sHCrsUqrsYll8983sH0290qWhGy2OEUu6oul3RneQLYU4mnrfK+iFB6AAfuI/3dfrPP/z+LdEp9j8YwT9RDaiv/ZzRk4PaXYVJezbnqG1za3oTYYLWEIY/O05sPvFgKK6beVtPRb4BmHxUj4HfU3VSfDsZk+P23f9jvL2mrHErT8fJ2pcijdt6xcNMpDzeoZOlGxLzxSpeebFcbrtTQkS1GwqJjqZTUuY1slbKES26O1vLNSkpNdtZ3zjQQR7Ht0umjEM0os1aBfTMojXYkLmt6Q11ToCgxH0cp57XMgN LP59l6w9 E5bHDpd9nkNlVupC/uFRqw7W42gvCMHl5OKqebQxuTGDE9809Z96qh3Ep1rdxWCk/bB08I4hQiquUlmZDnRmA5B9eNRBquxGo5oP9BapCYWEaYGAeELtqGJTS8cr9J4cHonrEiEfaOKyn1gldQEwk5CjEa81BONayd0EMnSCU6CFeWZu4jFhlMi5HCdkn2YbvYQpDXx+SzxRzDEDwRDMSiTVcsImRmzRdgWpeVT9fPz1goE7fyQWHro+A5+I5BgLquyogLzbjO6pUN0S38it31L09JAFejtVpVLk0Zyuay292VuYhsr/APCEw8+4/vwMn3UChmhZpLuCVfQx13pubysgpcQ== 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: 在 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++; > > .