Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4692058pxk; Wed, 30 Sep 2020 09:14:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRp7t/vBVMDzmu6TWUyECCsidPP6URSB0IMAvWhBUkxW+SxEFlxFWt440e8y3Ys2ZIdRBe X-Received: by 2002:a50:d61e:: with SMTP id x30mr3494546edi.70.1601482483529; Wed, 30 Sep 2020 09:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601482483; cv=none; d=google.com; s=arc-20160816; b=bRJum1UiS5GSBExFlshV+QIQGWOAm75JlDLvA20BvIPS+bTVKZWbwkTEExm6v0SQqx V56zJ8XEzX37QKPddSIQ3acqk059qZhzUpXsOQhfOWo5kbySn1giryof0s5XclENCiCS 2IxEdFc40rZP1k0D75DjMwzyhQdt2T59Tz2ORDE/88MoYscTUUuM/sc74b5bec6xAJTZ x+f+/Rgo55Etb6jyCik2re3BOZ39bbrVOsBXUdBGS686Ht+4K33FFIOQpZCkcWxsJDex rqX2OsJoUfHJWGeSQqfl/TbWru9mHhfEv6lSAQDwvsY3xtaP+3o+lS2X44ghb6enzg3C D6og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=B68i/03gO6ZR0stPp/XuIiWcgy0nxB559p48BCd6ARw=; b=Q3tNF0eFf8wH8TfYl9DiD7gUwN71a8k04jb8Spmz3BrIdPkB9F2mwp5HLoXgNRnWpl /PO6OWT1kW/RwYsmajsgTOiyzXuWBd0kM9Jg4HxzrmevMXT9SqraWyvcQtrM6FweJ4S0 QDxqjSptmeIinRYAhgIrTBZh00jWVpC/DdkUu1m7f6vZp1y6onqFRA0QZrzV1dpIl0sS /H8eHMbJPWYsLiLXEsKFacSLTOWM2l+Ni6Ia5RCiU6dD1v2XnMN2piDYD75/sdKqomlA TyNM9e1Xuc9lg5akuQ4fsVh/iLiYxAeTqaWtO2Ye4H891XtdkgIn3Wz2r1N0aDRKFqgl 3InQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="PX1/Et52"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si1407631edo.12.2020.09.30.09.14.16; Wed, 30 Sep 2020 09:14:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="PX1/Et52"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727749AbgI3QNV (ORCPT + 99 others); Wed, 30 Sep 2020 12:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725800AbgI3QNV (ORCPT ); Wed, 30 Sep 2020 12:13:21 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1D55C061755 for ; Wed, 30 Sep 2020 09:13:20 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id p15so3637892ejm.7 for ; Wed, 30 Sep 2020 09:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B68i/03gO6ZR0stPp/XuIiWcgy0nxB559p48BCd6ARw=; b=PX1/Et52kin9Rxfq1UxAKtvLAZw8XEYjLfAunQK4XuD4V0feOzB3QEYw7v7ThbU3Mt mAiv2K0rHxn933lpLwwCB0wtsyk/Vkj9iawLQ63G7s/YSV5r1kqfzoqoJBOpyjemnwbR jPkFIZ+aCNen9BaOql/Q6UkMrcE1yeclcDXqo4pRtnReCRRV2KjdXlMJ2qcMYBn88j4a hn54Pujx2xVaIZJ/7UDT4TJHflGOZyAVNefQWpY1GlZxlpT9OsE4bf8lH2/2XnHpOhIz +oIvhB3mmC5yUm2M66+DuI52zIT9WH0bnVRAKm3+NziWfY9j9ACgASesmoLq29qnztc+ DZBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B68i/03gO6ZR0stPp/XuIiWcgy0nxB559p48BCd6ARw=; b=BfKJSLGd7OKRjFMaN2ojV7k+I8bTzp/ecLerZldsN7weTyn/13yza0kmo/vgwlN3C7 uH5kIUmOHDa+t7xpQJhfbCFBIwL71iPAusQ1Al5zWaSV8O+0L+8SxA8quXtuAUaHdglX QkdROrybk6bXLDSngWji4zxc6bqSLYsW4/p26skaiD3b/qNdsyxLKPkID+0E3H31UHSz a+YT8qcpLwOLKUw/t3XSbeO79NxsPbWBXQ2xnMZ8FaA0Rrg0AbI0eSamguk4vZO/Ta9R rxqrir/RhKuRf6zbJQSV2nV8o8DMNsKoRCruselasWB3DfgKnV3ClUYDbsYnKvM5v4IK rvhA== X-Gm-Message-State: AOAM531fNEgU9AkrDVhiJtyORwrvqsicFVlG4kBk/tm2G5zJRdt6nBPP PW7j5okPuGYK6LA9BtGgsxbbobY/rfhyLLyJDN77oQ== X-Received: by 2002:a17:906:8143:: with SMTP id z3mr3481181ejw.323.1601482399413; Wed, 30 Sep 2020 09:13:19 -0700 (PDT) MIME-Version: 1.0 References: <160087928642.3520.17063139768910633998.stgit@dwillia2-desk3.amr.corp.intel.com> <160087929294.3520.12013578778066801369.stgit@dwillia2-desk3.amr.corp.intel.com> <20200929102512.GB21110@zn.tnic> In-Reply-To: <20200929102512.GB21110@zn.tnic> From: Dan Williams Date: Wed, 30 Sep 2020 09:13:07 -0700 Message-ID: Subject: Re: [PATCH v9 1/2] x86, powerpc: Rename memcpy_mcsafe() to copy_mc_to_{user, kernel}() To: Borislav Petkov Cc: Ingo Molnar , X86 ML , stable , "H. Peter Anvin" , Paul Mackerras , Thomas Gleixner , Peter Zijlstra , Mikulas Patocka , Alexander Viro , Arnaldo Carvalho de Melo , Linus Torvalds , Benjamin Herrenschmidt , Tony Luck , Michael Ellerman , linux-nvdimm , Linux Kernel Mailing List , Jan Kara Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2020 at 3:25 AM Borislav Petkov 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 > > +#include > > +#include > > +#include > > +#include > > + > > +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.