Re: [PATCH RFC V2 12/17] memremap: Add zone device access protection

2020-07-20 Thread Peter Zijlstra
On Fri, Jul 17, 2020 at 10:06:50PM -0700, Ira Weiny wrote: > On Fri, Jul 17, 2020 at 11:10:53AM +0200, Peter Zijlstra wrote: > > On Fri, Jul 17, 2020 at 12:20:51AM -0700, ira.we...@intel.com wrote: > > > +static pgprot_t dev_protection_enable_get(struct dev_pagemap *pgmap, > > > pgprot_t prot) > >

Re: [PATCH RFC V2 12/17] memremap: Add zone device access protection

2020-07-17 Thread Ira Weiny
On Fri, Jul 17, 2020 at 11:17:18AM +0200, Peter Zijlstra wrote: > On Fri, Jul 17, 2020 at 12:20:51AM -0700, ira.we...@intel.com wrote: > > +void dev_access_disable(void) > > +{ > > + unsigned long flags; > > + > > + if (!static_branch_unlikely(&dev_protection_static_key)) > > + return

Re: [PATCH RFC V2 12/17] memremap: Add zone device access protection

2020-07-17 Thread Ira Weiny
On Fri, Jul 17, 2020 at 11:10:53AM +0200, Peter Zijlstra wrote: > On Fri, Jul 17, 2020 at 12:20:51AM -0700, ira.we...@intel.com wrote: > > +static pgprot_t dev_protection_enable_get(struct dev_pagemap *pgmap, > > pgprot_t prot) > > +{ > > + if (pgmap->flags & PGMAP_PROT_ENABLED && dev_page_pkey

Re: [PATCH RFC V2 12/17] memremap: Add zone device access protection

2020-07-17 Thread Peter Zijlstra
On Fri, Jul 17, 2020 at 12:20:51AM -0700, ira.we...@intel.com wrote: > From: Ira Weiny > > Device managed memory exposes itself to the kernel direct map which > allows stray pointers to access these device memories. > > Stray pointers to normal memory may result in a crash or other > undesirable

Re: [PATCH RFC V2 12/17] memremap: Add zone device access protection

2020-07-17 Thread Peter Zijlstra
On Fri, Jul 17, 2020 at 12:20:51AM -0700, ira.we...@intel.com wrote: > +void dev_access_disable(void) > +{ > + unsigned long flags; > + > + if (!static_branch_unlikely(&dev_protection_static_key)) > + return; > + > + local_irq_save(flags); > + current->dev_page_access_re

Re: [PATCH RFC V2 12/17] memremap: Add zone device access protection

2020-07-17 Thread Peter Zijlstra
On Fri, Jul 17, 2020 at 12:20:51AM -0700, ira.we...@intel.com wrote: > +static pgprot_t dev_protection_enable_get(struct dev_pagemap *pgmap, > pgprot_t prot) > +{ > + if (pgmap->flags & PGMAP_PROT_ENABLED && dev_page_pkey != PKEY_INVALID) > { > + pgprotval_t val = pgprot_val(prot)

[PATCH RFC V2 12/17] memremap: Add zone device access protection

2020-07-17 Thread ira . weiny
From: Ira Weiny Device managed memory exposes itself to the kernel direct map which allows stray pointers to access these device memories. Stray pointers to normal memory may result in a crash or other undesirable behavior which, while unfortunate, are usually recoverable with a reboot. Stray w