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
Unknown Object (File)
Tue, May 14, 2:56 AM
Unknown Object (File)
Thu, May 2, 12:46 PM
Unknown Object (File)
Tue, Apr 23, 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
Unknown Object (File)
Dec 19 2023, 11:26 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

usr.sbin/bhyve/pci_nvme.c
1927

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
1927

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
1888

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
1888

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
1888

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
1888

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
1888

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
1888

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.

1888

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
1888

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.