[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH RFC PKS/PMEM 57/58] nvdimm/pmem: Stray access protection for pmem->virt_addr
- To: John Hubbard <jhubbard@xxxxxxxxxx>
- From: Ira Weiny <ira.weiny@xxxxxxxxx>
- Date: Sun, 11 Oct 2020 22:52:19 -0700
- Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Andy Lutomirski <luto@xxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, x86@xxxxxxxxxx, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, Dan Williams <dan.j.williams@xxxxxxxxx>, Fenghua Yu <fenghua.yu@xxxxxxxxx>, linux-doc@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-nvdimm@xxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, linux-mm@xxxxxxxxx, linux-kselftest@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, bpf@xxxxxxxxxxxxxxx, kexec@xxxxxxxxxxxxxxxxxxx, linux-bcache@xxxxxxxxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, devel@xxxxxxxxxxxxxxxxxxxx, linux-efi@xxxxxxxxxxxxxxx, linux-mmc@xxxxxxxxxxxxxxx, linux-scsi@xxxxxxxxxxxxxxx, target-devel@xxxxxxxxxxxxxxx, linux-nfs@xxxxxxxxxxxxxxx, ceph-devel@xxxxxxxxxxxxxxx, linux-ext4@xxxxxxxxxxxxxxx, linux-aio@xxxxxxxxx, io-uring@xxxxxxxxxxxxxxx, linux-erofs@xxxxxxxxxxxxxxxx, linux-um@xxxxxxxxxxxxxxxxxxx, linux-ntfs-dev@xxxxxxxxxxxxxxxxxxxxx, reiserfs-devel@xxxxxxxxxxxxxxx, linux-f2fs-devel@xxxxxxxxxxxxxxxxxxxxx, linux-nilfs@xxxxxxxxxxxxxxx, cluster-devel@xxxxxxxxxx, ecryptfs@xxxxxxxxxxxxxxx, linux-cifs@xxxxxxxxxxxxxxx, linux-btrfs@xxxxxxxxxxxxxxx, linux-afs@xxxxxxxxxxxxxxxxxxx, linux-rdma@xxxxxxxxxxxxxxx, amd-gfx@xxxxxxxxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, intel-gfx@xxxxxxxxxxxxxxxxxxxxx, drbd-dev@xxxxxxxxxxxxxxxx, linux-block@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-cachefs@xxxxxxxxxx, samba-technical@xxxxxxxxxxxxxxx, intel-wired-lan@xxxxxxxxxxxxxxxx
- Delivery-date: Mon, 12 Oct 2020 05:52:32 +0000
- Ironport-sdr: IZoSZ/GPXERgY4pSWfMFevrkmP+3iWYjSO6Y6o1NEk2j35ezRz042p/BH0mZHp3/ACJDi3IEMK Y+FNgg9/JeRg==
- Ironport-sdr: Ya9EDAn3SOMd08SCKVKBtueoni+yyq9EF8H8N9tr+YE/IrdFHweYy6SREcwPgxnde0DbbLRvxa rOKYCbITG9ew==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Fri, Oct 09, 2020 at 07:53:07PM -0700, John Hubbard wrote:
> On 10/9/20 12:50 PM, ira.weiny@xxxxxxxxx wrote:
> > From: Ira Weiny <ira.weiny@xxxxxxxxx>
> >
> > The pmem driver uses a cached virtual address to access its memory
> > directly. Because the nvdimm driver is well aware of the special
> > protections it has mapped memory with, we call dev_access_[en|dis]able()
> > around the direct pmem->virt_addr (pmem_addr) usage instead of the
> > unnecessary overhead of trying to get a page to kmap.
> >
> > Signed-off-by: Ira Weiny <ira.weiny@xxxxxxxxx>
> > ---
> > drivers/nvdimm/pmem.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> > index fab29b514372..e4dc1ae990fc 100644
> > --- a/drivers/nvdimm/pmem.c
> > +++ b/drivers/nvdimm/pmem.c
> > @@ -148,7 +148,9 @@ static blk_status_t pmem_do_read(struct pmem_device
> > *pmem,
> > if (unlikely(is_bad_pmem(&pmem->bb, sector, len)))
> > return BLK_STS_IOERR;
> > + dev_access_enable(false);
> > rc = read_pmem(page, page_off, pmem_addr, len);
> > + dev_access_disable(false);
>
> Hi Ira!
>
> The APIs should be tweaked to use a symbol (GLOBAL, PER_THREAD), instead of
> true/false. Try reading the above and you'll see that it sounds like it's
> doing the opposite of what it is ("enable_this(false)" sounds like a clumsy
> API design to *disable*, right?). And there is no hint about the scope.
Sounds reasonable.
>
> And it *could* be so much more readable like this:
>
> dev_access_enable(DEV_ACCESS_THIS_THREAD);
I'll think about the flag name. I'm not liking 'this thread'.
Maybe DEV_ACCESS_[GLOBAL|THREAD]
Ira
|