Page MenuHomeFreeBSD

bhyve: return FEATURE_NOT_CHANGEABLE for unimplemented feature of NVMe controller
ClosedPublic

Authored by wanpengqian_gmail.com on Nov 2 2021, 1:33 PM.
Tags
None
Referenced Files
F85212343: D32802.diff
Mon, Jun 3, 4:02 AM
Unknown Object (File)
Tue, May 14, 2:56 AM
Unknown Object (File)
May 2 2024, 12:46 PM
Unknown Object (File)
Apr 23 2024, 1:33 AM
Unknown Object (File)
Apr 7 2024, 12:43 PM
Unknown Object (File)
Apr 6 2024, 8:26 PM
Unknown Object (File)
Mar 4 2024, 7:03 AM
Unknown Object (File)
Dec 23 2023, 1:19 AM

Details

Summary

Set Feature is a feature specified function.
Currently only some features have the set procedure.
for features that are not handled by the controller, we should return a FEATURE_NOT_CHANGEABLE error message.

Test Plan

Fire a un-handle set feature command to check the response.
it should return a
NVMe status: FEATURE_NOT_CHANGEABLE: The Feature Identifier is not able to be changed(0x10e)
error message within Linux guest.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 42522
Build 39410: arc lint + arc unit

Event Timeline

usr.sbin/bhyve/pci_nvme.c
1438

Doesn't the removal of this break the NVMe requirement that values given in Set Features should be returned in CDW0 of Get Features?

usr.sbin/bhyve/pci_nvme.c
1438

You are right. I will keep the change to as small as needed.

wanpengqian_gmail.com edited the test plan for this revision. (Show Details)
This revision is now accepted and ready to land.Nov 9 2022, 12:23 PM
chuck requested changes to this revision.Nov 9 2022, 4:15 PM
chuck added inline comments.
usr.sbin/bhyve/pci_nvme.c
1406

This behavior is not spec compliant. Please review section 5.27.1

This revision now requires changes to proceed.Nov 9 2022, 4:15 PM
wanpengqian_gmail.com added inline comments.
usr.sbin/bhyve/pci_nvme.c
1406

Yes, you are correct.
I read section 5.21.1 (not 5.27.1, right?)

https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4c-2021.06.28-Ratified.pdf

If the controller does not support a changeable value for a Feature (e.g., the Feature is not changeable),
and a Set Features command for that Feature is processed, then if that command specifies a Feature value
that:
• is not the same as the existing value for that Feature, then the controller shall abort that command
with a status code of Feature Not Changeable; and
• is the same as the existing value for that Feature, then the controller may:
o complete that command successfully; or
o abort that command with a status code of Feature Not Changeable

I am abandoning this patch.

usr.sbin/bhyve/pci_nvme.c
1406

Hmm, sry don't get it. How I understand the spec: If we there's no feat->set, we do not support a changable value for the feature. So, we should abort the command and return Feature Not Changable.

usr.sbin/bhyve/pci_nvme.c
1406

At first, I understood what you just said. after reading the spec again. I found it means: If the user provides a value that is different to the existing value, and the controller does not support change , it should return Feature Not Changeable.
If a feature does not implement feat->set, I think we should return another error message instead of Feature Not Changeable.

usr.sbin/bhyve/pci_nvme.c
1406

If the user isn't permitted to change the value, you can always return Feature Not Changable. There's a special case: If the value is the same as the existing one, the controller is allowed to succeed but it doesn't have to.
Maybe @chuck could specify in more details why this isn't spec compliant.

Btw: I've checked qemu. It has the same behaviour. If qemu has no feat->set it returns Feature Not Changable:
https://github.com/qemu/qemu/blob/f21f1cfeb94b94ce044726856c291bed9391e3a4/hw/nvme/ctrl.c#L5595-L5596

usr.sbin/bhyve/pci_nvme.c
1406

Yes, you are correct.
I read section 5.21.1 (not 5.27.1, right?)

https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4c-2021.06.28-Ratified.pdf

Apologies, it is section 5.27.1 in the 2.0 spec, but yes, you found the correct section for the 1.4 spec.

1406

The specification has a "shall" that makes this non-compliant (emphasis mine):

If the controller does not support a changeable value for a Feature (e.g., the Feature is not changeable),
and a Set Features command for that Feature is processed, then if that command specifies a Feature value
that:

  • is not the same as the existing value for that Feature, then the controller shall abort that command with a status code of Feature Not Changeable; and

The code would also need to check the supplied vs. existing value to be correct.

usr.sbin/bhyve/pci_nvme.c
1406

Read the next statement:

  • is the same as the existing value for that Feature, then the controller may:
    • complete that command successfully; or
    • abort that command with a status code of Feature Not Changeable

So, always returning Feature Not Changable should be compliant.

I see what you are saying. Unfortunately, I can't figure out how to remove the "revisions requested" status.

All right, I think for unimplemented features, always return FEATURE NOT CHANGEABLE is compliant to the spec. and for implemented features, it is up to the implementation.so I am reclaiming this patch. thanks.

This revision now requires changes to proceed.Nov 10 2022, 9:53 PM
This revision was not accepted when it landed; it landed in state Needs Review.Nov 15 2022, 7:26 AM
This revision was automatically updated to reflect the committed changes.