diff mbox series

[RFC,V2,14/17] dax: Stray write protection for dax_direct_access()

Message ID 20200717072056.73134-15-ira.weiny@intel.com (mailing list archive)
State New, archived
Headers show
Series PKS: Add Protection Keys Supervisor (PKS) support | expand

Commit Message

Ira Weiny July 17, 2020, 7:20 a.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

dax_direct_access() is a special case of accessing pmem via a page
offset and without a struct page.

Because the dax driver is well aware of the special protections it has
mapped memory with, call dev_access_[en|dis]able() directly instead of
the unnecessary overhead of trying to get a page to kmap.

Like kmap though, leverage the existing dax_read[un]lock() functions
because they are already required to surround the use of the memory
returned from dax_direct_access().

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 drivers/dax/super.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Peter Zijlstra July 17, 2020, 9:22 a.m. UTC | #1
On Fri, Jul 17, 2020 at 12:20:53AM -0700, ira.weiny@intel.com wrote:

> --- a/drivers/dax/super.c
> +++ b/drivers/dax/super.c
> @@ -30,12 +30,14 @@ static DEFINE_SPINLOCK(dax_host_lock);
>  
>  int dax_read_lock(void)
>  {
> +	dev_access_enable();
>  	return srcu_read_lock(&dax_srcu);
>  }
>  EXPORT_SYMBOL_GPL(dax_read_lock);
>  
>  void dax_read_unlock(int id)
>  {
> +	dev_access_disable();
>  	srcu_read_unlock(&dax_srcu, id);
>  }
>  EXPORT_SYMBOL_GPL(dax_read_unlock);

This is inconsistently ordered.
Ira Weiny July 19, 2020, 4:41 a.m. UTC | #2
On Fri, Jul 17, 2020 at 11:22:43AM +0200, Peter Zijlstra wrote:
> On Fri, Jul 17, 2020 at 12:20:53AM -0700, ira.weiny@intel.com wrote:
> 
> > --- a/drivers/dax/super.c
> > +++ b/drivers/dax/super.c
> > @@ -30,12 +30,14 @@ static DEFINE_SPINLOCK(dax_host_lock);
> >  
> >  int dax_read_lock(void)
> >  {
> > +	dev_access_enable();
> >  	return srcu_read_lock(&dax_srcu);
> >  }
> >  EXPORT_SYMBOL_GPL(dax_read_lock);
> >  
> >  void dax_read_unlock(int id)
> >  {
> > +	dev_access_disable();
> >  	srcu_read_unlock(&dax_srcu, id);
> >  }
> >  EXPORT_SYMBOL_GPL(dax_read_unlock);
> 
> This is inconsistently ordered.

Thanks, good catch.

Fixed.
Ira
diff mbox series

Patch

diff --git a/drivers/dax/super.c b/drivers/dax/super.c
index 021739768093..e8d0a28e6ed2 100644
--- a/drivers/dax/super.c
+++ b/drivers/dax/super.c
@@ -30,12 +30,14 @@  static DEFINE_SPINLOCK(dax_host_lock);
 
 int dax_read_lock(void)
 {
+	dev_access_enable();
 	return srcu_read_lock(&dax_srcu);
 }
 EXPORT_SYMBOL_GPL(dax_read_lock);
 
 void dax_read_unlock(int id)
 {
+	dev_access_disable();
 	srcu_read_unlock(&dax_srcu, id);
 }
 EXPORT_SYMBOL_GPL(dax_read_unlock);