All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mika Penttilä" <mika.penttila@nextfour.com>
To: Dan Williams <dan.j.williams@intel.com>, linux-nvdimm@lists.01.org
Cc: Tony Luck <tony.luck@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, x86@kernel.org, hch@lst.de,
	Andy Lutomirski <luto@amacapital.net>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2 4/9] x86, memcpy_mcsafe: add write-protection-fault handling
Date: Thu, 3 May 2018 08:29:46 +0300	[thread overview]
Message-ID: <69d19601-df56-687d-730e-d043b2cf7161@nextfour.com> (raw)
In-Reply-To: <152532354268.17218.11923624861859552990.stgit@dwillia2-desk3.amr.corp.intel.com>

On 05/03/2018 07:59 AM, Dan Williams wrote:
> 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.
> 

> diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
> index 75d3776123cc..9787f5ee0cf9 100644
> --- a/arch/x86/lib/usercopy_64.c
> +++ b/arch/x86/lib/usercopy_64.c
> @@ -75,6 +75,23 @@ copy_user_handle_tail(char *to, char *from, unsigned len)
>  	return len;
>  }
>  
> +/*
> + * Similar to copy_user_handle_tail, probe for the write fault point,
> + * but reuse __memcpy_mcsafe in case a new read error is encountered.
> + * clac() is handled in _copy_to_iter_mcsafe().
> + */
> +__visible unsigned long
> +mcsafe_handle_tail(char *to, char *from, unsigned len)
> +{
> +	for (; len; --len, to++) {
> +		unsigned long rem = memcpy_mcsafe(to, from, 1);
> +


Hmm why not 
	for (; len; --len, from++, to++)



> +		if (rem)
> +			break;
> +	}
> +	return len;
> +}


--Mika

_______________________________________________
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: "Mika Penttilä" <mika.penttila@nextfour.com>
To: Dan Williams <dan.j.williams@intel.com>, 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>,
	hch@lst.de, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 4/9] x86, memcpy_mcsafe: add write-protection-fault handling
Date: Thu, 3 May 2018 08:29:46 +0300	[thread overview]
Message-ID: <69d19601-df56-687d-730e-d043b2cf7161@nextfour.com> (raw)
In-Reply-To: <152532354268.17218.11923624861859552990.stgit@dwillia2-desk3.amr.corp.intel.com>

On 05/03/2018 07:59 AM, Dan Williams wrote:
> 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.
> 

> diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
> index 75d3776123cc..9787f5ee0cf9 100644
> --- a/arch/x86/lib/usercopy_64.c
> +++ b/arch/x86/lib/usercopy_64.c
> @@ -75,6 +75,23 @@ copy_user_handle_tail(char *to, char *from, unsigned len)
>  	return len;
>  }
>  
> +/*
> + * Similar to copy_user_handle_tail, probe for the write fault point,
> + * but reuse __memcpy_mcsafe in case a new read error is encountered.
> + * clac() is handled in _copy_to_iter_mcsafe().
> + */
> +__visible unsigned long
> +mcsafe_handle_tail(char *to, char *from, unsigned len)
> +{
> +	for (; len; --len, to++) {
> +		unsigned long rem = memcpy_mcsafe(to, from, 1);
> +


Hmm why not 
	for (; len; --len, from++, to++)



> +		if (rem)
> +			break;
> +	}
> +	return len;
> +}


--Mika

WARNING: multiple messages have this Message-ID (diff)
From: "Mika Penttilä" <mika.penttila-MRsr7dthA9VWk0Htik3J/w@public.gmane.org>
To: Dan Williams
	<dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org
Cc: Tony Luck <tony.luck-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	Peter Zijlstra <peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	hch-jcswGhMUV9g@public.gmane.org,
	Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>,
	Ingo Molnar <mingo-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Borislav Petkov <bp-Gina5bIWoIWzQB+pC5nmwQ@public.gmane.org>,
	Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
	Linus Torvalds
	<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH v2 4/9] x86, memcpy_mcsafe: add write-protection-fault handling
Date: Thu, 3 May 2018 08:29:46 +0300	[thread overview]
Message-ID: <69d19601-df56-687d-730e-d043b2cf7161@nextfour.com> (raw)
In-Reply-To: <152532354268.17218.11923624861859552990.stgit-p8uTFz9XbKj2zm6wflaqv1nYeNYlB/vhral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

On 05/03/2018 07:59 AM, Dan Williams wrote:
> 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.
> 

> diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
> index 75d3776123cc..9787f5ee0cf9 100644
> --- a/arch/x86/lib/usercopy_64.c
> +++ b/arch/x86/lib/usercopy_64.c
> @@ -75,6 +75,23 @@ copy_user_handle_tail(char *to, char *from, unsigned len)
>  	return len;
>  }
>  
> +/*
> + * Similar to copy_user_handle_tail, probe for the write fault point,
> + * but reuse __memcpy_mcsafe in case a new read error is encountered.
> + * clac() is handled in _copy_to_iter_mcsafe().
> + */
> +__visible unsigned long
> +mcsafe_handle_tail(char *to, char *from, unsigned len)
> +{
> +	for (; len; --len, to++) {
> +		unsigned long rem = memcpy_mcsafe(to, from, 1);
> +


Hmm why not 
	for (; len; --len, from++, to++)



> +		if (rem)
> +			break;
> +	}
> +	return len;
> +}


--Mika

  reply	other threads:[~2018-05-03  5:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-03  4:58 [PATCH v2 0/9] use memcpy_mcsafe() for copy_to_iter() Dan Williams
2018-05-03  4:58 ` Dan Williams
2018-05-03  4:58 ` [PATCH v2 1/9] x86, memcpy_mcsafe: remove loop unrolling Dan Williams
2018-05-03  4:58   ` Dan Williams
2018-05-03  4:58 ` [PATCH v2 2/9] x86, memcpy_mcsafe: add labels for write fault handling Dan Williams
2018-05-03  4:58   ` Dan Williams
2018-05-03  4:58 ` [PATCH v2 3/9] x86, memcpy_mcsafe: return bytes remaining Dan Williams
2018-05-03  4:58   ` Dan Williams
2018-05-03  4:59 ` [PATCH v2 4/9] x86, memcpy_mcsafe: add write-protection-fault handling Dan Williams
2018-05-03  4:59   ` Dan Williams
2018-05-03  5:29   ` Mika Penttilä [this message]
2018-05-03  5:29     ` Mika Penttilä
2018-05-03  5:29     ` Mika Penttilä
2018-05-03 14:19     ` Dan Williams
2018-05-03 14:19       ` Dan Williams
2018-05-03  4:59 ` [PATCH v2 5/9] x86, memcpy_mcsafe: define copy_to_iter_mcsafe() Dan Williams
2018-05-03  4:59   ` Dan Williams
2018-05-03  4:59 ` [PATCH v2 6/9] dax: introduce a ->copy_to_iter dax operation Dan Williams
2018-05-03  4:59   ` Dan Williams
2018-05-03  4:59 ` [PATCH v2 7/9] dax: report bytes remaining in dax_iomap_actor() Dan Williams
2018-05-03  4:59   ` Dan Williams
2018-05-03  4:59 ` [PATCH v2 8/9] pmem: switch to copy_to_iter_mcsafe() Dan Williams
2018-05-03  4:59   ` Dan Williams
2018-05-03  4:59 ` [PATCH v2 9/9] x86, nfit_test: unit test for memcpy_mcsafe() Dan Williams
2018-05-03  4:59   ` 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=69d19601-df56-687d-730e-d043b2cf7161@nextfour.com \
    --to=mika.penttila@nextfour.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --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: link
Be 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.