qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/block/fdc: floppy command FIFO memory initialization
@ 2019-05-29 12:22 Andrey Shinkevich
  2019-05-29 13:40 ` John Snow
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Shinkevich @ 2019-05-29 12:22 UTC (permalink / raw)
  To: qemu-devel, qemu-block
  Cc: kwolf, vsementsov, mreitz, andrey.shinkevich, den, jsnow

The uninitialized memory allocated for the command FIFO of the
floppy controller during the VM hardware initialization incurs
many unwanted reports by Valgrind when VM state is being saved.
That verbosity hardens a search for the real memory issues when
the iotests run. Particularly, the patch eliminates 20 unnecessary
reports of the Valgrind tool in the iotest #169.

Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
---
 hw/block/fdc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 6f19f12..54e470c 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -2647,6 +2647,10 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
 
     FLOPPY_DPRINTF("init controller\n");
     fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
+    if (fdctrl->fifo) {
+        /* To avoid using the uninitialized memory while saving VM state */
+        memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
+    }
     fdctrl->fifo_size = 512;
     fdctrl->result_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
                                              fdctrl_result_timer, fdctrl);
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/block/fdc: floppy command FIFO memory initialization
  2019-05-29 12:22 [Qemu-devel] [PATCH] hw/block/fdc: floppy command FIFO memory initialization Andrey Shinkevich
@ 2019-05-29 13:40 ` John Snow
  2019-05-29 13:56   ` Andrey Shinkevich
  0 siblings, 1 reply; 4+ messages in thread
From: John Snow @ 2019-05-29 13:40 UTC (permalink / raw)
  To: Andrey Shinkevich, qemu-devel, qemu-block; +Cc: kwolf, den, vsementsov, mreitz



On 5/29/19 8:22 AM, Andrey Shinkevich wrote:
> The uninitialized memory allocated for the command FIFO of the
> floppy controller during the VM hardware initialization incurs
> many unwanted reports by Valgrind when VM state is being saved.
> That verbosity hardens a search for the real memory issues when
> the iotests run. Particularly, the patch eliminates 20 unnecessary
> reports of the Valgrind tool in the iotest #169.
> 
> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
> ---
>  hw/block/fdc.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
> index 6f19f12..54e470c 100644
> --- a/hw/block/fdc.c
> +++ b/hw/block/fdc.c
> @@ -2647,6 +2647,10 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>  
>      FLOPPY_DPRINTF("init controller\n");
>      fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
> +    if (fdctrl->fifo) {
> +        /* To avoid using the uninitialized memory while saving VM state */
> +        memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
> +    }

qemu_memalign doesn't look like it can fail (looking at
util/oslib-posix); is this conditional necessary?

I think you could just:

fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
memset(fdctrl->fifo, 0, FD_SECTOR_LEN);

>      fdctrl->fifo_size = 512;
>      fdctrl->result_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
>                                               fdctrl_result_timer, fdctrl);
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/block/fdc: floppy command FIFO memory initialization
  2019-05-29 13:40 ` John Snow
@ 2019-05-29 13:56   ` Andrey Shinkevich
  2019-05-29 14:01     ` John Snow
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Shinkevich @ 2019-05-29 13:56 UTC (permalink / raw)
  To: John Snow, qemu-devel@nongnu.org, qemu-block@nongnu.org
  Cc: kwolf@redhat.com, Vladimir Sementsov-Ogievskiy, Denis Lunev,
	mreitz@redhat.com



On 29/05/2019 16:40, John Snow wrote:
> 
> 
> On 5/29/19 8:22 AM, Andrey Shinkevich wrote:
>> The uninitialized memory allocated for the command FIFO of the
>> floppy controller during the VM hardware initialization incurs
>> many unwanted reports by Valgrind when VM state is being saved.
>> That verbosity hardens a search for the real memory issues when
>> the iotests run. Particularly, the patch eliminates 20 unnecessary
>> reports of the Valgrind tool in the iotest #169.
>>
>> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
>> ---
>>   hw/block/fdc.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
>> index 6f19f12..54e470c 100644
>> --- a/hw/block/fdc.c
>> +++ b/hw/block/fdc.c
>> @@ -2647,6 +2647,10 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>>   
>>       FLOPPY_DPRINTF("init controller\n");
>>       fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
>> +    if (fdctrl->fifo) {
>> +        /* To avoid using the uninitialized memory while saving VM state */
>> +        memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
>> +    }
> 
> qemu_memalign doesn't look like it can fail (looking at
> util/oslib-posix); is this conditional necessary?
> 
> I think you could just:
> 
> fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
> memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
> 
>>       fdctrl->fifo_size = 512;
>>       fdctrl->result_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
>>                                                fdctrl_result_timer, fdctrl);
>>

Yes, that's right.
Thank you, John.

Andrey


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/block/fdc: floppy command FIFO memory initialization
  2019-05-29 13:56   ` Andrey Shinkevich
@ 2019-05-29 14:01     ` John Snow
  0 siblings, 0 replies; 4+ messages in thread
From: John Snow @ 2019-05-29 14:01 UTC (permalink / raw)
  To: Andrey Shinkevich, qemu-devel@nongnu.org, qemu-block@nongnu.org
  Cc: kwolf@redhat.com, Vladimir Sementsov-Ogievskiy, Denis Lunev,
	mreitz@redhat.com



On 5/29/19 9:56 AM, Andrey Shinkevich wrote:
> 
> 
> On 29/05/2019 16:40, John Snow wrote:
>>
>>
>> On 5/29/19 8:22 AM, Andrey Shinkevich wrote:
>>> The uninitialized memory allocated for the command FIFO of the
>>> floppy controller during the VM hardware initialization incurs
>>> many unwanted reports by Valgrind when VM state is being saved.
>>> That verbosity hardens a search for the real memory issues when
>>> the iotests run. Particularly, the patch eliminates 20 unnecessary
>>> reports of the Valgrind tool in the iotest #169.
>>>
>>> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
>>> ---
>>>   hw/block/fdc.c | 4 ++++
>>>   1 file changed, 4 insertions(+)
>>>
>>> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
>>> index 6f19f12..54e470c 100644
>>> --- a/hw/block/fdc.c
>>> +++ b/hw/block/fdc.c
>>> @@ -2647,6 +2647,10 @@ static void fdctrl_realize_common(DeviceState *dev, FDCtrl *fdctrl,
>>>   
>>>       FLOPPY_DPRINTF("init controller\n");
>>>       fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
>>> +    if (fdctrl->fifo) {
>>> +        /* To avoid using the uninitialized memory while saving VM state */
>>> +        memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
>>> +    }
>>
>> qemu_memalign doesn't look like it can fail (looking at
>> util/oslib-posix); is this conditional necessary?
>>
>> I think you could just:
>>
>> fdctrl->fifo = qemu_memalign(512, FD_SECTOR_LEN);
>> memset(fdctrl->fifo, 0, FD_SECTOR_LEN);
>>
>>>       fdctrl->fifo_size = 512;
>>>       fdctrl->result_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
>>>                                                fdctrl_result_timer, fdctrl);
>>>
> 
> Yes, that's right.
> Thank you, John.
> 
> Andrey
> 

Thanks for valgrinding QEMU :)

--js


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-29 14:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-29 12:22 [Qemu-devel] [PATCH] hw/block/fdc: floppy command FIFO memory initialization Andrey Shinkevich
2019-05-29 13:40 ` John Snow
2019-05-29 13:56   ` Andrey Shinkevich
2019-05-29 14:01     ` John Snow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).