Page MenuHomeFreeBSD

bhyve: abort and return FEATURE_NOT_SAVEABLE while set feature with a save flag for NVMe controller.
ClosedPublic

Authored by wanpengqian_gmail.com on Nov 1 2021, 4:23 AM.
Tags
None
Referenced Files
F102721104: D32767.diff
Sat, Nov 16, 8:30 AM
Unknown Object (File)
Mon, Nov 11, 3:03 AM
Unknown Object (File)
Fri, Nov 8, 3:39 AM
Unknown Object (File)
Thu, Nov 7, 3:40 AM
Unknown Object (File)
Wed, Nov 6, 2:35 PM
Unknown Object (File)
Wed, Nov 6, 2:43 AM
Unknown Object (File)
Tue, Nov 5, 9:28 AM
Unknown Object (File)
Mon, Oct 28, 10:19 PM

Details

Summary

Currently bhyve's NVMe controller cannot save feature values cross reboot.
It should return a FEATURE_NOT_SAVEABLE error when the command specifies a save flag.

Quote from NVMe specification, page 205:

https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4-2019.06.10-Ratified.pdf

If the Feature Identifier specified in the Set Features command is not saveable by the controller and the controller receives a Set Features command with the Save bit set to one, then the command shall be aborted with a status of Feature Identifier Not Saveable.

Test Plan

After apply this patch, under linux guest, fire command
nvme set-feature -f 4 -v 0x157 -s /dev/nvme0
it return an error message of
NVMe status: FEATURE_NOT_SAVEABLE: The Feature Identifier specified does not support a saveable value(0x10d)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

wanpengqian_gmail.com retitled this revision from bhyve: abort and return FEATURE_NOT_SAVEABLE while set feature with save flag. to bhyve: abort and return FEATURE_NOT_SAVEABLE while set feature with a save flag for NVMe controller..
wanpengqian_gmail.com edited the summary of this revision. (Show Details)
wanpengqian_gmail.com edited the test plan for this revision. (Show Details)
wanpengqian_gmail.com removed a reviewer: grehan.
wanpengqian_gmail.com edited the test plan for this revision. (Show Details)
corvink added subscribers: manu, corvink.

LGTM @manu

usr.sbin/bhyve/pci_nvme.c
122–132

Not sure if we should add these defines to sys/dev/nvme/nvme.h

This revision is now accepted and ready to land.Nov 9 2022, 12:35 PM
usr.sbin/bhyve/pci_nvme.c
122–132

Yes, it is better move to nvme.h
I will update this patch soon.
also make a macro to make it more simple.

chuck added inline comments.
usr.sbin/bhyve/pci_nvme.c
1863

Nit but I'd drop this debug message as it doesn't add much value

usr.sbin/bhyve/pci_nvme.c
122–132

thanks! I was going to suggest this as well.

This revision now requires review to proceed.Nov 10 2022, 12:47 AM

Address reviewers' feedback.

usr.sbin/bhyve/pci_nvme.c
1854

Inspired by Chuck's NVMEB macro, I create an NVMEV macro that helps extract values.

And we don't need to do the following defines now. save a lot of code work and potential typo

#define NVME_FEAT_SET_FID(x) \
        ((x) >> NVME_FEAT_SET_FID_SHIFT & NVME_FEAT_SET_FID_MASK)
This revision is now accepted and ready to land.Nov 10 2022, 6:56 AM