Received: by 10.192.165.148 with SMTP id m20csp1428841imm; Wed, 2 May 2018 22:12:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq+HuHkaskGM/I1nqNs+IbuivhkdSBXfjBvqMkey8A09D7pEnR8smEb2Vd+q+RX8t/xtc7n X-Received: by 2002:a17:902:7488:: with SMTP id h8-v6mr22859676pll.124.1525324329243; Wed, 02 May 2018 22:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525324329; cv=none; d=google.com; s=arc-20160816; b=ibMz2/f0b39cbqydyOOOWcAxYSvzZfoWrQ8nwfjdsDlMoCWn67zymCJ2GhGXrMIAWV wYGM9VS4paDdvRQlbLtMIEkN2xC3/59pdVfe6OyK84OejhefsPzW4LEqJaF2EO9R5j6e 5YQgYXV5SSKZGjOxSt/ZDmPxroIQ7tq7eYXLW0qkkSxygSrZnMaw8Jb2MuyHZemUp4Ie YqqcFToD1OHAxKOLr9MkPEILo5iieNaIqGLkHnRoZNwccrSIij8qbrGkKvXVU1Jw9Y4O BiqBD69H4FhiETtXaZYJlDyo22KaLwhBbVC1TbWAESZBxe7YCuINYlUFHeKljKWXOCOz xV1Q== 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:references:in-reply-to:message-id:date:cc:to:from :subject:arc-authentication-results; bh=UoJ+WSfhMii5h5JoVZAhpi7lBanyQ32cEH5p8327jqk=; b=N/sX9da+yZqKr55CK9VMvrpFWmeniVLgOYteNlBXoQexm/Oa+M/1Fxd5nJ+Iqzdgi3 XJYcMGcjZWduvTL6z+uKi2LurjjZ+opuglTU46gwgCRIUQuZ2LhSdLCUMHNrgrKeFWMn JlA62/l31CiiPDSyI8LueM++geGg5semBxa/ap9I4NCJfwmBlk6P/YT9o8bpvDf1N0nt b48TMs+YldYc5KM8Suq5ABWhaa4XsL+Q4xwluEwhKus5Jk3dBxI8YmQrnN1VcGIi2mcb l2IEITPTxzEPqw4hT7233VVbvrS260+ugpR6iQ6ksI0SYNc+xJsbx/OdsDIocGHnL1l+ XPiA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y1-v6si11011923pgq.532.2018.05.02.22.11.55; Wed, 02 May 2018 22:12:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752132AbeECFIz (ORCPT + 99 others); Thu, 3 May 2018 01:08:55 -0400 Received: from mga02.intel.com ([134.134.136.20]:28184 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbeECFIt (ORCPT ); Thu, 3 May 2018 01:08:49 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 May 2018 22:08:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,356,1520924400"; d="scan'208";a="225375199" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by fmsmga005.fm.intel.com with ESMTP; 02 May 2018 22:08:48 -0700 Subject: [PATCH v2 2/9] x86, memcpy_mcsafe: add labels for write fault handling From: Dan Williams To: linux-nvdimm@lists.01.org Cc: x86@kernel.org, Ingo Molnar , Borislav Petkov , Al Viro , Thomas Gleixner , Andy Lutomirski , Peter Zijlstra , Andrew Morton , Linus Torvalds , Tony Luck , hch@lst.de, linux-kernel@vger.kernel.org, tony.luck@intel.com, linux-fsdevel@vger.kernel.org Date: Wed, 02 May 2018 21:58:51 -0700 Message-ID: <152532353186.17218.12613043253505288889.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <152532351517.17218.3583455156840230837.stgit@dwillia2-desk3.amr.corp.intel.com> References: <152532351517.17218.3583455156840230837.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-2-gc94f 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 The memcpy_mcsafe() implementation handles CPU exceptions when reading from the source address. Before it can be used for user copies it needs to grow support for handling write faults. In preparation for adding that exception handling update the labels for the read cache word X case (.L_cache_rX) and write cache word X case (.L_cache_wX). Cc: Cc: Ingo Molnar Cc: Borislav Petkov Cc: Al Viro Cc: Thomas Gleixner Cc: Andy Lutomirski Cc: Peter Zijlstra Cc: Andrew Morton Cc: Linus Torvalds Reported-by: Tony Luck Signed-off-by: Dan Williams --- arch/x86/lib/memcpy_64.S | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S index 54c971892db5..5709f3ec22a4 100644 --- a/arch/x86/lib/memcpy_64.S +++ b/arch/x86/lib/memcpy_64.S @@ -204,13 +204,14 @@ ENTRY(__memcpy_mcsafe) subl $8, %ecx negl %ecx subl %ecx, %edx -.L_copy_leading_bytes: +.L_read_leading_bytes: movb (%rsi), %al +.L_write_leading_bytes: movb %al, (%rdi) incq %rsi incq %rdi decl %ecx - jnz .L_copy_leading_bytes + jnz .L_read_leading_bytes .L_8byte_aligned: movl %edx, %ecx @@ -218,13 +219,14 @@ ENTRY(__memcpy_mcsafe) shrl $3, %ecx jz .L_no_whole_words -.L_copy_words: +.L_read_words: movq (%rsi), %r8 +.L_write_words: movq %r8, (%rdi) addq $8, %rsi addq $8, %rdi decl %ecx - jnz .L_copy_words + jnz .L_read_words /* Any trailing bytes? */ .L_no_whole_words: @@ -233,13 +235,14 @@ ENTRY(__memcpy_mcsafe) /* Copy trailing bytes */ movl %edx, %ecx -.L_copy_trailing_bytes: +.L_read_trailing_bytes: movb (%rsi), %al +.L_write_trailing_bytes: movb %al, (%rdi) incq %rsi incq %rdi decl %ecx - jnz .L_copy_trailing_bytes + jnz .L_read_trailing_bytes /* Copy successful. Return zero */ .L_done_memcpy_trap: @@ -256,7 +259,7 @@ EXPORT_SYMBOL_GPL(__memcpy_mcsafe) .previous - _ASM_EXTABLE_FAULT(.L_copy_leading_bytes, .L_memcpy_mcsafe_fail) - _ASM_EXTABLE_FAULT(.L_copy_words, .L_memcpy_mcsafe_fail) - _ASM_EXTABLE_FAULT(.L_copy_trailing_bytes, .L_memcpy_mcsafe_fail) + _ASM_EXTABLE_FAULT(.L_read_leading_bytes, .L_memcpy_mcsafe_fail) + _ASM_EXTABLE_FAULT(.L_read_words, .L_memcpy_mcsafe_fail) + _ASM_EXTABLE_FAULT(.L_read_trailing_bytes, .L_memcpy_mcsafe_fail) #endif