From: Dan Williams <dan.j.williams@intel.com> To: linux-nvdimm@lists.01.org Cc: tony.luck@intel.com, Peter Zijlstra <peterz@infradead.org>, x86@kernel.org, linux-kernel@vger.kernel.org, Andy Lutomirski <luto@amacapital.net>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Al Viro <viro@zeniv.linux.org.uk>, Thomas Gleixner <tglx@linutronix.de>, Linus Torvalds <torvalds@linux-foundation.org>, Andrew Morton <akpm@linux-foundation.org> Subject: [PATCH 3/6] x86, memcpy_mcsafe: add write-protection-fault handling Date: Tue, 01 May 2018 13:45:24 -0700 [thread overview] Message-ID: <152520752472.36522.6229986239583637697.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <152520750404.36522.15462513519590065300.stgit@dwillia2-desk3.amr.corp.intel.com> In preparation for using memcpy_mcsafe() to handle user copies it needs to be to handle write-protection faults while writing user pages. Add MMU-fault handlers alongside the machine-check exception handlers. Note that the machine check fault exception handling makes assumptions about source buffer alignment and poison alignment. In the write fault case, given the destination buffer is arbitrarily aligned, it needs a separate / additional fault handling approach. The mcsafe_handle_tail() helper is reused. The @limit argument is set to @len since there is no safety concern about retriggering an MMU fault, and this simplifies the assembly. Cc: <x86@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Co-developed-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/lib/memcpy_64.S | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S index 97b772fcf62f..fc9c1f594c71 100644 --- a/arch/x86/lib/memcpy_64.S +++ b/arch/x86/lib/memcpy_64.S @@ -345,6 +345,16 @@ EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled) mov %ecx, %eax ret +.E_write_cache_X: + shll $6, %ecx + jmp .E_handle_tail +.E_write_trailing_words: + shll $3, %ecx +.E_handle_tail: + addl %edx, %ecx + movl %ecx, %edx + jmp mcsafe_handle_tail + .previous _ASM_EXTABLE_FAULT(.L_read_leading_bytes, .E_leading_bytes) @@ -358,4 +368,15 @@ EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled) _ASM_EXTABLE_FAULT(.L_cache_r7, .E_cache_7) _ASM_EXTABLE_FAULT(.L_read_trailing_words, .E_trailing_words) _ASM_EXTABLE_FAULT(.L_read_trailing_bytes, .E_trailing_bytes) + _ASM_EXTABLE(.L_write_leading_bytes, .E_leading_bytes) + _ASM_EXTABLE(.L_cache_w0, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w1, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w2, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w3, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w4, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w5, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w6, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w7, .E_write_cache_X) + _ASM_EXTABLE(.L_write_trailing_words, .E_write_trailing_words) + _ASM_EXTABLE(.L_write_trailing_bytes, .E_trailing_bytes) #endif _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm
WARNING: multiple messages have this Message-ID (diff)
From: Dan Williams <dan.j.williams@intel.com> To: linux-nvdimm@lists.01.org Cc: x86@kernel.org, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>, Al Viro <viro@zeniv.linux.org.uk>, Thomas Gleixner <tglx@linutronix.de>, Andy Lutomirski <luto@amacapital.net>, Peter Zijlstra <peterz@infradead.org>, Andrew Morton <akpm@linux-foundation.org>, Linus Torvalds <torvalds@linux-foundation.org>, linux-kernel@vger.kernel.org, tony.luck@intel.com Subject: [PATCH 3/6] x86, memcpy_mcsafe: add write-protection-fault handling Date: Tue, 01 May 2018 13:45:24 -0700 [thread overview] Message-ID: <152520752472.36522.6229986239583637697.stgit@dwillia2-desk3.amr.corp.intel.com> (raw) In-Reply-To: <152520750404.36522.15462513519590065300.stgit@dwillia2-desk3.amr.corp.intel.com> In preparation for using memcpy_mcsafe() to handle user copies it needs to be to handle write-protection faults while writing user pages. Add MMU-fault handlers alongside the machine-check exception handlers. Note that the machine check fault exception handling makes assumptions about source buffer alignment and poison alignment. In the write fault case, given the destination buffer is arbitrarily aligned, it needs a separate / additional fault handling approach. The mcsafe_handle_tail() helper is reused. The @limit argument is set to @len since there is no safety concern about retriggering an MMU fault, and this simplifies the assembly. Cc: <x86@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Co-developed-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- arch/x86/lib/memcpy_64.S | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S index 97b772fcf62f..fc9c1f594c71 100644 --- a/arch/x86/lib/memcpy_64.S +++ b/arch/x86/lib/memcpy_64.S @@ -345,6 +345,16 @@ EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled) mov %ecx, %eax ret +.E_write_cache_X: + shll $6, %ecx + jmp .E_handle_tail +.E_write_trailing_words: + shll $3, %ecx +.E_handle_tail: + addl %edx, %ecx + movl %ecx, %edx + jmp mcsafe_handle_tail + .previous _ASM_EXTABLE_FAULT(.L_read_leading_bytes, .E_leading_bytes) @@ -358,4 +368,15 @@ EXPORT_SYMBOL_GPL(memcpy_mcsafe_unrolled) _ASM_EXTABLE_FAULT(.L_cache_r7, .E_cache_7) _ASM_EXTABLE_FAULT(.L_read_trailing_words, .E_trailing_words) _ASM_EXTABLE_FAULT(.L_read_trailing_bytes, .E_trailing_bytes) + _ASM_EXTABLE(.L_write_leading_bytes, .E_leading_bytes) + _ASM_EXTABLE(.L_cache_w0, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w1, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w2, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w3, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w4, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w5, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w6, .E_write_cache_X) + _ASM_EXTABLE(.L_cache_w7, .E_write_cache_X) + _ASM_EXTABLE(.L_write_trailing_words, .E_write_trailing_words) + _ASM_EXTABLE(.L_write_trailing_bytes, .E_trailing_bytes) #endif
next prev parent reply other threads:[~2018-05-01 20:55 UTC|newest] Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-01 20:45 [PATCH 0/6] use memcpy_mcsafe() for copy_to_iter() Dan Williams 2018-05-01 20:45 ` Dan Williams 2018-05-01 20:45 ` [PATCH 1/6] x86, memcpy_mcsafe: update labels in support of write fault handling Dan Williams 2018-05-01 20:45 ` Dan Williams 2018-05-01 20:45 ` [PATCH 2/6] x86, memcpy_mcsafe: return bytes remaining Dan Williams 2018-05-01 20:45 ` Dan Williams 2018-05-01 20:45 ` Dan Williams [this message] 2018-05-01 20:45 ` [PATCH 3/6] x86, memcpy_mcsafe: add write-protection-fault handling Dan Williams 2018-05-01 20:45 ` [PATCH 4/6] x86, memcpy_mcsafe: define copy_to_iter_mcsafe() Dan Williams 2018-05-01 20:45 ` Dan Williams 2018-05-01 22:17 ` kbuild test robot 2018-05-01 22:17 ` kbuild test robot 2018-05-01 22:49 ` kbuild test robot 2018-05-01 22:49 ` kbuild test robot 2018-05-01 20:45 ` [PATCH 5/6] dax: use copy_to_iter_mcsafe() in dax_iomap_actor() Dan Williams 2018-05-01 20:45 ` Dan Williams 2018-05-01 20:45 ` [PATCH 6/6] x86, nfit_test: unit test for memcpy_mcsafe() Dan Williams 2018-05-01 20:45 ` Dan Williams 2018-05-01 21:05 ` [PATCH 0/6] use memcpy_mcsafe() for copy_to_iter() Linus Torvalds 2018-05-01 21:05 ` Linus Torvalds 2018-05-01 23:02 ` Dan Williams 2018-05-01 23:02 ` Dan Williams 2018-05-01 23:28 ` Andy Lutomirski 2018-05-01 23:28 ` Andy Lutomirski 2018-05-01 23:31 ` Dan Williams 2018-05-01 23:31 ` Dan Williams 2018-05-02 0:09 ` Linus Torvalds 2018-05-02 0:09 ` Linus Torvalds 2018-05-02 2:25 ` Dan Williams 2018-05-02 2:25 ` Dan Williams 2018-05-02 2:53 ` Linus Torvalds 2018-05-02 2:53 ` Linus Torvalds 2018-05-02 3:02 ` Dan Williams 2018-05-02 3:02 ` Dan Williams 2018-05-02 3:13 ` Linus Torvalds 2018-05-02 3:13 ` Linus Torvalds 2018-05-02 3:20 ` Dan Williams 2018-05-02 3:20 ` Dan Williams 2018-05-02 3:22 ` Dan Williams 2018-05-02 3:22 ` Dan Williams 2018-05-02 3:33 ` Linus Torvalds 2018-05-02 3:33 ` Linus Torvalds 2018-05-02 4:00 ` Dan Williams 2018-05-02 4:00 ` Dan Williams 2018-05-02 4:14 ` Linus Torvalds 2018-05-02 4:14 ` Linus Torvalds 2018-05-02 5:37 ` Dan Williams 2018-05-02 5:37 ` Dan Williams 2018-05-02 16:19 ` Andy Lutomirski 2018-05-02 16:19 ` Andy Lutomirski 2018-05-02 17:47 ` Dan Williams 2018-05-02 17:47 ` Dan Williams 2018-05-02 8:30 ` Borislav Petkov 2018-05-02 8:30 ` Borislav Petkov 2018-05-02 13:52 ` Dan Williams 2018-05-02 13:52 ` Dan Williams
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=152520752472.36522.6229986239583637697.stgit@dwillia2-desk3.amr.corp.intel.com \ --to=dan.j.williams@intel.com \ --cc=akpm@linux-foundation.org \ --cc=bp@alien8.de \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-nvdimm@lists.01.org \ --cc=luto@amacapital.net \ --cc=mingo@redhat.com \ --cc=peterz@infradead.org \ --cc=tglx@linutronix.de \ --cc=tony.luck@intel.com \ --cc=torvalds@linux-foundation.org \ --cc=viro@zeniv.linux.org.uk \ --cc=x86@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.