diff mbox series

hw/nvme: fix mo field in io mgnt send

Message ID 20240506-fix-ioms-mo-v1-1-65c315531850@samsung.com
State New
Headers show
Series hw/nvme: fix mo field in io mgnt send | expand

Commit Message

Klaus Jensen May 6, 2024, 8:06 a.m. UTC
From: Klaus Jensen <k.jensen@samsung.com>

The Management Operation field of I/O Management Send is only 8 bits,
not 16.

Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
---
 hw/nvme/ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 84b0eb1826f690aa8d51984644318ee6c810f5bf
change-id: 20240506-fix-ioms-mo-97098c6c5396

Best regards,

Comments

Vincent Fu May 7, 2024, 2:05 p.m. UTC | #1
On 5/6/24 04:06, Klaus Jensen wrote:
> The Management Operation field of I/O Management Send is only 8 bits,
> not 16.
> 
> Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> ---
>   hw/nvme/ctrl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> index 9e7bbebc8bb0..ede5f281dd7c 100644
> --- a/hw/nvme/ctrl.c
> +++ b/hw/nvme/ctrl.c
> @@ -4387,7 +4387,7 @@ static uint16_t nvme_io_mgmt_send(NvmeCtrl *n, NvmeRequest *req)
>   {
>       NvmeCmd *cmd = &req->cmd;
>       uint32_t cdw10 = le32_to_cpu(cmd->cdw10);
> -    uint8_t mo = (cdw10 & 0xff);
> +    uint8_t mo = cdw10 & 0xf;
>   
>       switch (mo) {
>       case NVME_IOMS_MO_NOP:
> 
> ---
> base-commit: 84b0eb1826f690aa8d51984644318ee6c810f5bf
> change-id: 20240506-fix-ioms-mo-97098c6c5396
> 
> Best regards,

Reviewed-by: Vincent Fu <vincent.fu@samsung.com>
Vincent Fu May 8, 2024, 1:36 p.m. UTC | #2
On 5/7/24 10:05, Vincent Fu wrote:
> On 5/6/24 04:06, Klaus Jensen wrote:
>> The Management Operation field of I/O Management Send is only 8 bits,
>> not 16.
>>
>> Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
>> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
>> ---
>>   hw/nvme/ctrl.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
>> index 9e7bbebc8bb0..ede5f281dd7c 100644
>> --- a/hw/nvme/ctrl.c
>> +++ b/hw/nvme/ctrl.c
>> @@ -4387,7 +4387,7 @@ static uint16_t nvme_io_mgmt_send(NvmeCtrl *n, 
>> NvmeRequest *req)
>>   {
>>       NvmeCmd *cmd = &req->cmd;
>>       uint32_t cdw10 = le32_to_cpu(cmd->cdw10);
>> -    uint8_t mo = (cdw10 & 0xff);
>> +    uint8_t mo = cdw10 & 0xf;
>>       switch (mo) {
>>       case NVME_IOMS_MO_NOP:
>>
>> ---
>> base-commit: 84b0eb1826f690aa8d51984644318ee6c810f5bf
>> change-id: 20240506-fix-ioms-mo-97098c6c5396
>>
>> Best regards,
> 
> Reviewed-by: Vincent Fu <vincent.fu@samsung.com>

Klaus, upon taking a second look, the original code is correct. The 
proposed change would only keep the least significant 4 bits of the MO 
field. The original code gives you the 8 bits needed.

Let me withdraw my Reviewed-by.

Vincent
Klaus Jensen May 24, 2024, 8:03 a.m. UTC | #3
On May  8 09:36, Vincent Fu wrote:
> On 5/7/24 10:05, Vincent Fu wrote:
> > On 5/6/24 04:06, Klaus Jensen wrote:
> > > The Management Operation field of I/O Management Send is only 8 bits,
> > > not 16.
> > > 
> > > Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation")
> > > Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
> > > ---
> > >   hw/nvme/ctrl.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
> > > index 9e7bbebc8bb0..ede5f281dd7c 100644
> > > --- a/hw/nvme/ctrl.c
> > > +++ b/hw/nvme/ctrl.c
> > > @@ -4387,7 +4387,7 @@ static uint16_t nvme_io_mgmt_send(NvmeCtrl *n,
> > > NvmeRequest *req)
> > >   {
> > >       NvmeCmd *cmd = &req->cmd;
> > >       uint32_t cdw10 = le32_to_cpu(cmd->cdw10);
> > > -    uint8_t mo = (cdw10 & 0xff);
> > > +    uint8_t mo = cdw10 & 0xf;
> > >       switch (mo) {
> > >       case NVME_IOMS_MO_NOP:
> > > 
> > > ---
> > > base-commit: 84b0eb1826f690aa8d51984644318ee6c810f5bf
> > > change-id: 20240506-fix-ioms-mo-97098c6c5396
> > > 
> > > Best regards,
> > 
> > Reviewed-by: Vincent Fu <vincent.fu@samsung.com>
> 
> Klaus, upon taking a second look, the original code is correct. The proposed
> change would only keep the least significant 4 bits of the MO field. The
> original code gives you the 8 bits needed.
> 
> Let me withdraw my Reviewed-by.
> 
> Vincent

That was embarrasing. Thanks for catching that Vincent :)
diff mbox series

Patch

diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index 9e7bbebc8bb0..ede5f281dd7c 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -4387,7 +4387,7 @@  static uint16_t nvme_io_mgmt_send(NvmeCtrl *n, NvmeRequest *req)
 {
     NvmeCmd *cmd = &req->cmd;
     uint32_t cdw10 = le32_to_cpu(cmd->cdw10);
-    uint8_t mo = (cdw10 & 0xff);
+    uint8_t mo = cdw10 & 0xf;
 
     switch (mo) {
     case NVME_IOMS_MO_NOP: