[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v6 29/42] nvme: refactor request bounds checking
From: |
Klaus Birkelund Jensen |
Subject: |
Re: [PATCH v6 29/42] nvme: refactor request bounds checking |
Date: |
Tue, 31 Mar 2020 07:44:56 +0200 |
On Mar 25 12:56, Maxim Levitsky wrote:
> On Mon, 2020-03-16 at 07:29 -0700, Klaus Jensen wrote:
> > From: Klaus Jensen <address@hidden>
> >
> > Signed-off-by: Klaus Jensen <address@hidden>
> > ---
> > hw/block/nvme.c | 28 ++++++++++++++++++++++------
> > 1 file changed, 22 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> > index eecfad694bf8..ba520c76bae5 100644
> > --- a/hw/block/nvme.c
> > +++ b/hw/block/nvme.c
> > @@ -562,13 +577,14 @@ static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace
> > *ns, NvmeCmd *cmd,
> > uint64_t data_offset = slba << data_shift;
> > int is_write = rw->opcode == NVME_CMD_WRITE ? 1 : 0;
> > enum BlockAcctType acct = is_write ? BLOCK_ACCT_WRITE :
> > BLOCK_ACCT_READ;
> > + uint16_t status;
> >
> > trace_nvme_dev_rw(is_write ? "write" : "read", nlb, data_size, slba);
> >
> > - if (unlikely((slba + nlb) > ns->id_ns.nsze)) {
> > + status = nvme_check_bounds(n, ns, slba, nlb, req);
> > + if (status) {
> > block_acct_invalid(blk_get_stats(n->conf.blk), acct);
> > - trace_nvme_dev_err_invalid_lba_range(slba, nlb, ns->id_ns.nsze);
> > - return NVME_LBA_RANGE | NVME_DNR;
> > + return status;
> > }
> >
> > if (nvme_map(n, cmd, &req->qsg, &req->iov, data_size, req)) {
> Looks good as well, once we get support for discard, it will
> use this as well, but for now indeed only write zeros and read/write
> need bounds checking on the IO path.
>
I have that patch in the submission queue and the check is factored out
there ;)
> Reviewed-by: Maxim Levitsky <address@hidden>
>
[PATCH v6 29/42] nvme: refactor request bounds checking, Klaus Jensen, 2020/03/16
[PATCH v6 27/42] nvme: add request mapping helper, Klaus Jensen, 2020/03/16
[PATCH v6 28/42] nvme: verify validity of prp lists in the cmb, Klaus Jensen, 2020/03/16
[PATCH v6 34/42] pci: pass along the return value of dma_memory_rw, Klaus Jensen, 2020/03/16
[PATCH v6 30/42] nvme: add check for mdts, Klaus Jensen, 2020/03/16
[PATCH v6 26/42] nvme: pass request along for tracing, Klaus Jensen, 2020/03/16