From nobody Sat Jan 29 23:15:39 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 63C0D197AB53; Sat, 29 Jan 2022 23:15:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JmVYT0gTNz3sTc; Sat, 29 Jan 2022 23:15:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643498141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pO0v3dREFwwgiWPdfEZpz3KzkeqJgMStVOcT7AEZ1m8=; b=DVvxH3f1NpwVWFgT1Mhqxz7DyJ4U+A1shcSFF1RRvSlkHSDwQyvIV/9BaQsNXwzjyI68m3 +VNssqNXd2RWoRdPSdoY4A3frXpDzYx99ULehcr5KWwQioYjMUavhyP/LgaRQpX7XEeh1E ze2sw07Vb1Vgp7cJ8yF5lf+rhDeSJxBMjWUEGOR3TopL8629Je2DG8PkPIeZnZyDGh4A3C e3G7Y1c0wO8mxttJ7o1xHonO0rqHLXp9o4V5pIQyWtLxjYmv/nMJhhFyuaizrLh8ODMLwq 63Nebp6+eGEpUjtoUXGdufZMarfh2Pg+wGukNmcVKK/qSJXjH1YVOrMQGhWMTA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CECF31DF63; Sat, 29 Jan 2022 23:15:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20TNFdAw008182; Sat, 29 Jan 2022 23:15:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20TNFd2D008181; Sat, 29 Jan 2022 23:15:39 GMT (envelope-from git) Date: Sat, 29 Jan 2022 23:15:39 GMT Message-Id: <202201292315.20TNFd2D008181@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Chuck Tuffli Subject: git: b1b2a4d9e87e - main - bhyve nvme: Implement Log Page Offset List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: chuck X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b1b2a4d9e87e0eec413781e4580cd14edf74af7f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643498141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pO0v3dREFwwgiWPdfEZpz3KzkeqJgMStVOcT7AEZ1m8=; b=W9pWklVLcvwlosCExpz8skszN4QLPo1bl69edHMss6kW6g5FUsBSdq5/kBTfLXNEzo5SgC gmd5Aa2ZUQQOWef33pxKFyYmcRVPEsxLMBRJB+hItukbq9PnVT5+VGqPVOMljXo2Tmz18I V/1QTXL6MK9flVgc4AyBJf9gjugZMjgwOLJhjBMWRJH1w8BJ10x2jz3szNVduppNHIhOZ7 briFLLSSjTxlt0sWRI//q2OrI4n1ST1Hj6u1ehYoM4N6Hu/cpXdQ9MfN3/HancEsB/cWup 3pxsuON8QHkqaH9RSQ7LvNxtII9cLH0dZL9616j11mI9KCJaQZE+2hSlEVbYpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643498141; a=rsa-sha256; cv=none; b=EPzij+To85i8jKAhb47x4BSDMERJ3w+JLCVa6YFeAkSgDafjXV7TsXvHbqZ12mI4QGciOG xsmbj8oo7mAmydClD7/ThrRp7xfgxF/IJrjZke3J4tkxPtyCdbuyOal6nwvNviohCkLcid toTNW/GhBVpJBc/D6SFDkeWt3V9wolobPFYHSAW+/fRYlpgAnP8sshczmf6Ziwq7zG/JP+ DRbyt3kC3t3fOW6zfNyj0MfS70vJY+ehvErmmK7DTLHUEf9lTuLwimvsP5vMf2ccOLfNup 1hT71A5cGsjw550JmF1hwsFSmpBwg2yUt38ray7iNGb53H0m3ZF/xRxFjmGSNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by chuck: URL: https://cgit.FreeBSD.org/src/commit/?id=b1b2a4d9e87e0eec413781e4580cd14edf74af7f commit b1b2a4d9e87e0eec413781e4580cd14edf74af7f Author: Chuck Tuffli AuthorDate: 2022-01-30 07:06:46 +0000 Commit: Chuck Tuffli CommitDate: 2022-01-30 07:06:46 +0000 bhyve nvme: Implement Log Page Offset Modify the Get Log Page command to parse the Log Page Offset fields to support more recent versions of the NVMe specification. Fixes various tests for UNH Test 1.3.* Reviewed by: imp, allanjude Tested by: jason@tubnor.net MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D33568 --- usr.sbin/bhyve/pci_nvme.c | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/usr.sbin/bhyve/pci_nvme.c b/usr.sbin/bhyve/pci_nvme.c index e5def8ef8165..43426f5f1f59 100644 --- a/usr.sbin/bhyve/pci_nvme.c +++ b/usr.sbin/bhyve/pci_nvme.c @@ -1329,6 +1329,7 @@ static int nvme_opc_get_log_page(struct pci_nvme_softc* sc, struct nvme_command* command, struct nvme_completion* compl) { + uint64_t logoff; uint32_t logsize; uint8_t logpage = command->cdw10 & 0xFF; @@ -1342,15 +1343,28 @@ nvme_opc_get_log_page(struct pci_nvme_softc* sc, struct nvme_command* command, */ logsize = ((command->cdw11 << 16) | (command->cdw10 >> 16)) + 1; logsize *= sizeof(uint32_t); + logoff = ((uint64_t)(command->cdw13) << 32) | command->cdw12; switch (logpage) { case NVME_LOG_ERROR: + if (logoff >= sizeof(sc->err_log)) { + pci_nvme_status_genc(&compl->status, + NVME_SC_INVALID_FIELD); + break; + } + nvme_prp_memcpy(sc->nsc_pi->pi_vmctx, command->prp1, - command->prp2, (uint8_t *)&sc->err_log, - MIN(logsize, sizeof(sc->err_log)), + command->prp2, (uint8_t *)&sc->err_log + logoff, + MIN(logsize - logoff, sizeof(sc->err_log)), NVME_COPY_TO_PRP); break; case NVME_LOG_HEALTH_INFORMATION: + if (logoff >= sizeof(sc->health_log)) { + pci_nvme_status_genc(&compl->status, + NVME_SC_INVALID_FIELD); + break; + } + pthread_mutex_lock(&sc->mtx); memcpy(&sc->health_log.data_units_read, &sc->read_data_units, sizeof(sc->health_log.data_units_read)); @@ -1363,20 +1377,32 @@ nvme_opc_get_log_page(struct pci_nvme_softc* sc, struct nvme_command* command, pthread_mutex_unlock(&sc->mtx); nvme_prp_memcpy(sc->nsc_pi->pi_vmctx, command->prp1, - command->prp2, (uint8_t *)&sc->health_log, - MIN(logsize, sizeof(sc->health_log)), + command->prp2, (uint8_t *)&sc->health_log + logoff, + MIN(logsize - logoff, sizeof(sc->health_log)), NVME_COPY_TO_PRP); break; case NVME_LOG_FIRMWARE_SLOT: + if (logoff >= sizeof(sc->fw_log)) { + pci_nvme_status_genc(&compl->status, + NVME_SC_INVALID_FIELD); + break; + } + nvme_prp_memcpy(sc->nsc_pi->pi_vmctx, command->prp1, - command->prp2, (uint8_t *)&sc->fw_log, - MIN(logsize, sizeof(sc->fw_log)), + command->prp2, (uint8_t *)&sc->fw_log + logoff, + MIN(logsize - logoff, sizeof(sc->fw_log)), NVME_COPY_TO_PRP); break; case NVME_LOG_CHANGED_NAMESPACE: + if (logoff >= sizeof(sc->ns_log)) { + pci_nvme_status_genc(&compl->status, + NVME_SC_INVALID_FIELD); + break; + } + nvme_prp_memcpy(sc->nsc_pi->pi_vmctx, command->prp1, - command->prp2, (uint8_t *)&sc->ns_log, - MIN(logsize, sizeof(sc->ns_log)), + command->prp2, (uint8_t *)&sc->ns_log + logoff, + MIN(logsize - logoff, sizeof(sc->ns_log)), NVME_COPY_TO_PRP); memset(&sc->ns_log, 0, sizeof(sc->ns_log)); break;