Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp930134pxa; Sat, 1 Aug 2020 10:39:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/qOmYTPxb+JRZZ/V1EsQOd+USm/+SM32KCmiZg+YxiYXMkJsEDUmaikRrZ7TkpFv8nuz5 X-Received: by 2002:a17:907:204e:: with SMTP id pg14mr9790546ejb.324.1596303569382; Sat, 01 Aug 2020 10:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596303569; cv=none; d=google.com; s=arc-20160816; b=bBaDiZBb4oDC13sgXp8VECiLlhgsUTzPX7Bw71PbPhBX+/wJm212+lU7pXyguvaAST ABrZNqwlMRK5MS/8jedsCvZ0MjOtnUzRlSdVCd6tn1jg0hbbUMdbkY2i/yVVj9LeuDcw 8uU/m1GnQqop6EgpxNaWYmrNmIqXJexwbahxjsKOOkKl2QBiZmrcdjd+VwWPNcfreURx 1geJx879d4KIp2aZE6/hK1dSPviP3J4CiF/mF10Tk2XdJiEtx6N14txrITKuqYXa05Rr Ajoocesinj996GT4FyPiw2w5bI70hG9asAlHXbYplNo+SpexqUIrzJaMeb98r+avcb6/ BzZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:date:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=8l2Y3qqa0cFNKmttj9nEBipctiW1LYpcUhMgGPdMxpA=; b=nDLdA8PLawTQvaCn7XdeEmfADJKmA2s1kfRX63IXuIDC4fsZFMI1Mxz/ZhykHGyomh Rg2+j9d1IeTGj9reWfl5B2qEAyeVic5Mb8Qorx4HlUzfsJcNFH2iqzn/Rnihb0F9iY0V LtNLlgIOBlvCm11TpxnP9WkSB8RtRL/a5/6CZ3Vp4lI/FJHs7Q5txDJPPUxwuWoIkOwj 5Utq6PB4MWG/m3hyKKDb3YDJUt1R8UDJcSNnKIKFB58pUuB10Z150/38HtERPZvWNyul mQQ+Pfh3Qb/GYupzpSvBu/yFxnfXcXkjtrV/Gnd5BXsJRrA39dnXqL1cg3Bn5jv0Wbb7 RBYg== ARC-Authentication-Results: i=1; mx.google.com; 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 k17si6164325ejv.169.2020.08.01.10.39.05; Sat, 01 Aug 2020 10:39:29 -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; 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 S1726571AbgHARi4 (ORCPT + 99 others); Sat, 1 Aug 2020 13:38:56 -0400 Received: from mga04.intel.com ([192.55.52.120]:10253 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbgHARiz (ORCPT ); Sat, 1 Aug 2020 13:38:55 -0400 IronPort-SDR: t5dyDFe/5NI3Mg2MbfsLG4qAI6UTcvSGyhuWUvQwl2DR1PfthWLEKLp2rp65WG2+zNAHWHO0yX Sn6z4U32XNrA== X-IronPort-AV: E=McAfee;i="6000,8403,9699"; a="149394069" X-IronPort-AV: E=Sophos;i="5.75,423,1589266800"; d="scan'208";a="149394069" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2020 10:38:54 -0700 IronPort-SDR: KRjjdqdzFj6+0PzdZWkJsUEcbjVt3ZTshu8heTogL8MViDiBwCfEOXZz4d+BLX+oJd/bX90qKU M+b1xREghqEg== X-IronPort-AV: E=Sophos;i="5.75,423,1589266800"; d="scan'208";a="395632580" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Aug 2020 10:38:54 -0700 Subject: [PATCH v8 0/2] Renovate memcpy_mcsafe with copy_mc_to_{user, kernel} From: Dan Williams To: tglx@linutronix.de, mingo@redhat.com, vishal.l.verma@intel.com Cc: Tony Luck , Vivek Goyal , Peter Zijlstra , Linus Torvalds , Alexander Viro , Borislav Petkov , stable@vger.kernel.org, x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Paul Mackerras , Benjamin Herrenschmidt , Erwin Tsaur , Michael Ellerman , Mikulas Patocka , Arnaldo Carvalho de Melo , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Date: Sat, 01 Aug 2020 10:22:36 -0700 Message-ID: <159630255616.3143511.18110575960499749012.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes since v7 [1]: - Rebased on v5.8-rc5 to resolve a conflict with commit eb25de276505 ("tools arch: Update arch/x86/lib/memcpy_64.S copy used in 'perf bench mem memcpy'") [1]: http://lore.kernel.org/r/159408043801.2272533.17485467640602344900.stgit@dwillia2-desk3.amr.corp.intel.com --- Vishal, since this patch set has experienced unprecedented silence from x86 folks I expect you will need to send it to Linus directly during the merge window. It merges cleanly with recent -next. Thomas, Ingo, Boris, please chime in to save Vishal from that awkwardness. I am only going to be sporadically online for the next few weeks. --- The primary motivation to go touch memcpy_mcsafe() is that the existing benefit of doing slow and careful copies is obviated on newer CPUs. That fact solves the problem of needing to detect machine-check recovery capability. Now the old "mcsafe_key" opt-in to careful copying can be made an opt-out from the default fast copy implementation. The discussion with Linus further made clear that this facility had already lost its x86-machine-check specificity starting with commit 2c89130a56a ("x86/asm/memcpy_mcsafe: Add write-protection-fault handling"). The new changes to not require a "careful copy" further de-emphasizes the role that x86-MCA plays in the implementation to just one more source of recoverable trap during the operation. With the above realizations the name "mcsafe" is no longer accurate and copy_safe() is proposed as its replacement. x86 grows a copy_safe_fast() implementation as a default implementation that is independent of detecting the presence of x86-MCA. --- Dan Williams (2): x86, powerpc: Rename memcpy_mcsafe() to copy_mc_to_{user,kernel}() x86/copy_mc: Introduce copy_mc_generic() arch/powerpc/Kconfig | 2 arch/powerpc/include/asm/string.h | 2 arch/powerpc/include/asm/uaccess.h | 40 +++-- arch/powerpc/lib/Makefile | 2 arch/powerpc/lib/copy_mc_64.S | 4 arch/x86/Kconfig | 2 arch/x86/Kconfig.debug | 2 arch/x86/include/asm/copy_mc_test.h | 75 +++++++++ arch/x86/include/asm/mcsafe_test.h | 75 --------- arch/x86/include/asm/string_64.h | 32 ---- arch/x86/include/asm/uaccess.h | 21 +++ arch/x86/include/asm/uaccess_64.h | 20 -- arch/x86/kernel/cpu/mce/core.c | 8 - arch/x86/kernel/quirks.c | 9 - arch/x86/lib/Makefile | 1 arch/x86/lib/copy_mc.c | 64 ++++++++ arch/x86/lib/copy_mc_64.S | 165 ++++++++++++++++++++ arch/x86/lib/memcpy_64.S | 115 -------------- arch/x86/lib/usercopy_64.c | 21 --- drivers/md/dm-writecache.c | 15 +- drivers/nvdimm/claim.c | 2 drivers/nvdimm/pmem.c | 6 - include/linux/string.h | 9 - include/linux/uaccess.h | 9 + include/linux/uio.h | 10 + lib/Kconfig | 7 + lib/iov_iter.c | 43 +++-- tools/arch/x86/include/asm/mcsafe_test.h | 13 -- tools/arch/x86/lib/memcpy_64.S | 115 -------------- tools/objtool/check.c | 5 - tools/perf/bench/Build | 1 tools/perf/bench/mem-memcpy-x86-64-lib.c | 24 --- tools/testing/nvdimm/test/nfit.c | 48 +++--- .../testing/selftests/powerpc/copyloops/.gitignore | 2 tools/testing/selftests/powerpc/copyloops/Makefile | 6 - .../selftests/powerpc/copyloops/copy_mc_64.S | 1 .../selftests/powerpc/copyloops/memcpy_mcsafe_64.S | 1 37 files changed, 451 insertions(+), 526 deletions(-) rename arch/powerpc/lib/{memcpy_mcsafe_64.S => copy_mc_64.S} (98%) create mode 100644 arch/x86/include/asm/copy_mc_test.h delete mode 100644 arch/x86/include/asm/mcsafe_test.h create mode 100644 arch/x86/lib/copy_mc.c create mode 100644 arch/x86/lib/copy_mc_64.S delete mode 100644 tools/arch/x86/include/asm/mcsafe_test.h delete mode 100644 tools/perf/bench/mem-memcpy-x86-64-lib.c create mode 120000 tools/testing/selftests/powerpc/copyloops/copy_mc_64.S delete mode 120000 tools/testing/selftests/powerpc/copyloops/memcpy_mcsafe_64.S base-commit: 11ba468877bb23f28956a35e896356252d63c983