Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:SRIZkP4w2m
qemu
hw-nvme-add-protection-information-pass-.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File hw-nvme-add-protection-information-pass-.patch of Package qemu
From: Dmitry Tihov <d.tihov@yadro.com> Date: Wed, 11 May 2022 17:15:35 +0000 Subject: hw/nvme: add protection information pass parameter Allow namespace to enable pass-through of protection information between guest and integrity capable BlockBackend. Signed-off-by: Dmitry Tihov <d.tihov@yadro.com> --- hw/nvme/ns.c | 57 ++++++++++++++++++++++++++++++++++++++++++++------ hw/nvme/nvme.h | 2 ++ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 8b5f98c76180d66a1ce999e7e06b..71d3e4979997b456f23b6d70928a 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -29,12 +29,17 @@ void nvme_ns_init_format(NvmeNamespace *ns) { NvmeIdNs *id_ns = &ns->id_ns; BlockDriverInfo bdi; - int npdg, nlbas, ret; + int npdg, ret; + int64_t nlbas; ns->lbaf = id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(id_ns->flbas)]; ns->lbasz = 1 << ns->lbaf.ds; - nlbas = ns->size / (ns->lbasz + ns->lbaf.ms); + if (ns->pip) { + nlbas = ns->size / (ns->lbasz); + } else { + nlbas = ns->size / (ns->lbasz + ns->lbaf.ms); + } id_ns->nsze = cpu_to_le64(nlbas); @@ -42,7 +47,7 @@ void nvme_ns_init_format(NvmeNamespace *ns) id_ns->ncap = id_ns->nsze; id_ns->nuse = id_ns->ncap; - ns->moff = (int64_t)nlbas << ns->lbaf.ds; + ns->moff = nlbas << ns->lbaf.ds; npdg = ns->blkconf.discard_granularity / ns->lbasz; @@ -52,6 +57,9 @@ void nvme_ns_init_format(NvmeNamespace *ns) } id_ns->npda = id_ns->npdg = npdg - 1; + if (ns->pip) { + id_ns->dps = bdi.protection_type; + } } static int nvme_ns_init(NvmeNamespace *ns, Error **errp) @@ -62,13 +70,17 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) uint16_t ms; int i; + ns->pip = ns->params.pip; + ns->csi = NVME_CSI_NVM; ns->status = 0x0; ns->id_ns.dlfeat = 0x1; - /* support DULBE and I/O optimization fields */ - id_ns->nsfeat |= (0x4 | 0x10); + if (!ns->pip) { + /* support DULBE and I/O optimization fields */ + id_ns->nsfeat |= (0x4 | 0x10); + } if (ns->params.shared) { id_ns->nmic |= NVME_NMIC_NS_SHARED; @@ -87,7 +99,11 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) id_ns->eui64 = cpu_to_be64(ns->params.eui64); ds = 31 - clz32(ns->blkconf.logical_block_size); - ms = ns->params.ms; + if (ns->pip) { + ms = 8; + } else { + ms = ns->params.ms; + } id_ns->mc = NVME_ID_NS_MC_EXTENDED | NVME_ID_NS_MC_SEPARATE; @@ -348,6 +364,9 @@ static void nvme_zoned_ns_shutdown(NvmeNamespace *ns) static int nvme_ns_check_constraints(NvmeNamespace *ns, Error **errp) { + BlockDriverInfo bdi; + int ret; + if (!ns->blkconf.blk) { error_setg(errp, "block backend not configured"); return -1; @@ -359,6 +378,31 @@ static int nvme_ns_check_constraints(NvmeNamespace *ns, Error **errp) return -1; } + if (ns->params.pip) { + if (ns->params.mset) { + error_setg(errp, "invalid mset parameter, metadata must be " + "stored in a separate buffer to use integrity passthrough"); + return -1; + } + ret = bdrv_get_info(blk_bs(ns->blkconf.blk), &bdi); + if (ret < 0) { + error_setg(errp, "could not determine host block device" + " integrity information"); + return -1; + } + if (!bdi.protection_type) { + error_setg(errp, "nvme-ns backend block device does not" + " support integrity passthrough"); + return -1; + } + if (bdi.protection_interval != ns->blkconf.logical_block_size) { + error_setg(errp, "logical block size parameter (%u bytes) must be" + " equal to protection information interval (%u bytes)", + ns->blkconf.logical_block_size, bdi.protection_interval); + return -1; + } + } + if (ns->params.nsid > NVME_MAX_NAMESPACES) { error_setg(errp, "invalid namespace id (must be between 0 and %d)", NVME_MAX_NAMESPACES); @@ -534,6 +578,7 @@ static Property nvme_ns_props[] = { DEFINE_PROP_UINT8("mset", NvmeNamespace, params.mset, 0), DEFINE_PROP_UINT8("pi", NvmeNamespace, params.pi, 0), DEFINE_PROP_UINT8("pil", NvmeNamespace, params.pil, 0), + DEFINE_PROP_BOOL("pip", NvmeNamespace, params.pip, false), DEFINE_PROP_UINT16("mssrl", NvmeNamespace, params.mssrl, 128), DEFINE_PROP_UINT32("mcl", NvmeNamespace, params.mcl, 128), DEFINE_PROP_UINT8("msrc", NvmeNamespace, params.msrc, 127), diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 83ffabade4cf452bb7380bb4ee63..cf5bc874451dc5d4c8159fafd99f 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -102,6 +102,7 @@ typedef struct NvmeNamespaceParams { uint8_t mset; uint8_t pi; uint8_t pil; + bool pip; uint16_t mssrl; uint32_t mcl; @@ -129,6 +130,7 @@ typedef struct NvmeNamespace { uint8_t csi; uint16_t status; int attached; + bool pip; QTAILQ_ENTRY(NvmeNamespace) entry;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor