On Tue, Sep 29, 2020 at 3:25 AM Borislav Petkov <bp@xxxxxxxxx> wrote: > > On Wed, Sep 23, 2020 at 09:41:33AM -0700, Dan Williams wrote: > > The rename replaces a single top-level memcpy_mcsafe() with either > > copy_mc_to_user(), or copy_mc_to_kernel(). > > What is "copy_mc" supposed to mean? Especially if it is called that on > two arches... > > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > > index 7101ac64bb20..e876b3a087f9 100644 > > --- a/arch/x86/Kconfig > > +++ b/arch/x86/Kconfig > > @@ -75,7 +75,7 @@ config X86 > > select ARCH_HAS_PTE_DEVMAP if X86_64 > > select ARCH_HAS_PTE_SPECIAL > > select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 > > - select ARCH_HAS_UACCESS_MCSAFE if X86_64 && X86_MCE > > + select ARCH_HAS_COPY_MC if X86_64 > > X86_MCE is dropped here. So if I have a build which has > > # CONFIG_X86_MCE is not set > > One of those quirks like: > > /* > * CAPID0{7:6} indicate whether this is an advanced RAS SKU > * CAPID5{8:5} indicate that various NVDIMM usage modes are > * enabled, so memory machine check recovery is also enabled. > */ > if ((capid0 & 0xc0) == 0xc0 || (capid5 & 0x1e0)) > enable_copy_mc_fragile(); > > will still call enable_copy_mc_fragile() and none of those platforms > need MCE functionality? > > But there's a hunk in here which sets it in the MCE code: > > if (mca_cfg.recovery) > enable_copy_mc_fragile(); > > So which is it? They need it or they don't? > > The comment over copy_mc_to_kernel() says: > > * Call into the 'fragile' version on systems that have trouble > * actually do machine check recovery > > If CONFIG_X86_MCE is not set, I'll say. :) True, without CONFIG_X86_MCE there's no point in attempting the fragile copy because the #MC will go unhandled. At the same time the point of the new copy_mc_generic() is that it is suitable to use without CONFIG_X86_MCE as it's just a typical fast string copy instrumented for exception handling. So, I still think CONFIG_ARCH_HAS_COPY_MC is independent of CONFIG_X86_MCE, but enable_copy_mc_fragile() should be stubbed out by CONFIG_X86_MCE=n, will re-spin. > > > +++ b/arch/x86/lib/copy_mc.c > > @@ -0,0 +1,66 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* Copyright(c) 2016-2020 Intel Corporation. All rights reserved. */ > > + > > +#include <linux/jump_label.h> > > +#include <linux/uaccess.h> > > +#include <linux/export.h> > > +#include <linux/string.h> > > +#include <linux/types.h> > > + > > +static DEFINE_STATIC_KEY_FALSE(copy_mc_fragile_key); > > + > > +void enable_copy_mc_fragile(void) > > +{ > > + static_branch_inc(©_mc_fragile_key); > > +} > > + > > +/** > > + * copy_mc_to_kernel - memory copy that that handles source exceptions > > One "that" is enough. Yup.