From: Klaus Jensen <its@irrelevant.dk>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: fam@euphon.net, kwolf@redhat.com, qemu-block@nongnu.org,
Gollu Appalanaidu <anaidu.gollu@samsung.com>,
qemu-devel@nongnu.org, mreitz@redhat.com, kbusch@kernel.org
Subject: Re: [PATCH v2 1/2] hw/nvme: add support for boot partiotions
Date: Thu, 3 Jun 2021 12:04:06 +0200 [thread overview]
Message-ID: <YLipFmd3ePdqgyXU@apples.localdomain> (raw)
In-Reply-To: <YLilZqgEZyQjnRwX@stefanha-x1.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2826 bytes --]
On Jun 3 10:48, Stefan Hajnoczi wrote:
>On Tue, Jun 01, 2021 at 08:07:48PM +0530, Gollu Appalanaidu wrote:
>> @@ -5546,6 +5665,47 @@ static void nvme_write_bar(NvmeCtrl *n, hwaddr offset, uint64_t data,
>> NVME_GUEST_ERR(pci_nvme_ub_mmiowr_cmbsz_readonly,
>> "invalid write to read only CMBSZ, ignored");
>> return;
>> + case 0x44: /* BPRSEL */
>> + n->bar.bprsel = data & 0xffffffff;
>> + size_t bp_len = NVME_BPRSEL_BPRSZ(n->bar.bprsel) * 4 * KiB;
>> + int64_t bp_offset = NVME_BPRSEL_BPROF(n->bar.bprsel) * 4 * KiB;
>> + int64_t off = 0;
>> + struct nvme_bp_read_ctx *ctx;
>> +
>> + trace_pci_nvme_mmio_bprsel(data, n->bar.bprsel,
>> + NVME_BPRSEL_BPID(n->bar.bpinfo),
>> + bp_offset, bp_len);
>> +
>> + if (bp_len + bp_offset > n->bp_size) {
>> + NVME_BPINFO_CLEAR_BRS(n->bar.bpinfo);
>> + NVME_BPINFO_SET_BRS(n->bar.bpinfo, NVME_BPINFO_BRS_ERROR);
>> + return;
>> + }
>> +
>> + off = NVME_BPRSEL_BPID(n->bar.bpinfo) * n->bp_size + bp_offset;
>> +
>> + NVME_BPINFO_CLEAR_BRS(n->bar.bpinfo);
>> + NVME_BPINFO_SET_BRS(n->bar.bpinfo, NVME_BPINFO_BRS_READING);
>> +
>> + ctx = g_new(struct nvme_bp_read_ctx, 1);
>> +
>> + ctx->n = n;
>> +
>> + pci_dma_sglist_init(&ctx->qsg, &n->parent_obj, 1);
>> +
>> + qemu_sglist_add(&ctx->qsg, n->bar.bpmbl, bp_len);
>> +
>> + dma_blk_read(n->blk_bp, &ctx->qsg, off , BDRV_SECTOR_SIZE,
>> + nvme_bp_read_cb, ctx);
>
>The returned BlockAIOCB is not stored. Two questions:
>
Thanks for these comments Stefan, I've commented below how I think they
can be resolved.
>1. Can the guest allocate unbounded amounts of QEMU memory (struct
> nvme_bp_read_ctx) by repeatedly writing to this register?
>
Yeah, the QSQ should just be a member of the controller struct and then
have that as the cb_arg to dma_blk_read. Then, the QSG can be
initialized and the host address added when BPMBL is written instead of
here.
We don't want the QSG to change while the read is in progress, so the
write to BPMBL should check BPINFO.BRS and not do anything if the QSG is
"in use". The spec says that the host *shall* not modify the registers
when a read is in progress, so we can safely just ignore the write.
>2. What happens if the NVMe device is hot unplugged or reset while a
> boot partition read request is in flight?
The spec also says that the host *shall* not reset or shutdown the
controller while a read is in progress, but again, we need to protect
QEMU so the aiocb must be saved on the controller struct and cancelled
appropriately.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-06-03 10:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20210601144231epcas5p3b931fe9421737d104dc3c5be50c928f3@epcas5p3.samsung.com>
2021-06-01 14:37 ` [PATCH v2 0/2] add boot partitions support and read test case Gollu Appalanaidu
[not found] ` <CGME20210601144234epcas5p153e855ad673876cf67e57d4b539dc274@epcas5p1.samsung.com>
2021-06-01 14:37 ` [PATCH v2 1/2] hw/nvme: add support for boot partiotions Gollu Appalanaidu
2021-06-01 17:19 ` Keith Busch
2021-06-01 17:41 ` Klaus Jensen
2021-06-01 17:46 ` Klaus Jensen
2021-06-01 18:07 ` Keith Busch
2021-06-01 19:07 ` Klaus Jensen
2021-06-01 20:23 ` Keith Busch
2021-06-03 9:48 ` Stefan Hajnoczi
2021-06-03 10:04 ` Klaus Jensen [this message]
2021-06-03 11:51 ` Stefan Hajnoczi
[not found] ` <CGME20210601144242epcas5p1292f656f45aebd1b9c75fe54797d6b46@epcas5p1.samsung.com>
2021-06-01 14:37 ` [PATCH v2 2/2] tests/qtest/nvme-test: add boot partition read test Gollu Appalanaidu
2021-06-01 17:43 ` Klaus Jensen
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=YLipFmd3ePdqgyXU@apples.localdomain \
--to=its@irrelevant.dk \
--cc=anaidu.gollu@samsung.com \
--cc=fam@euphon.net \
--cc=kbusch@kernel.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).