* [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
@ 2019-01-18 22:31 Laszlo Ersek
2019-01-21 7:21 ` Gerd Hoffmann
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Laszlo Ersek @ 2019-01-18 22:31 UTC (permalink / raw)
To: qemu devel list
Cc: Gerd Hoffmann, Markus Armbruster, Philippe Mathieu-Daudé
Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
array from static to automatic. This broke the interface contract on the
fw_cfg_add_file() function, which is documented as follows, in
"include/hw/nvram/fw_cfg.h":
> [...] The data referenced by the starting pointer is only linked, NOT
> copied, into the data structure of the fw_cfg device. [...]
As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
file, it now sees garbage. Fix the regression by changing the storage
duration to allocated. (The call is reached at most once, on the realize
path of the board-specific fw_cfg sysbus device.)
While at it, clean up the name and the assignment of the object as well.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
hw/nvram/fw_cfg.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 53e8e010a8b7..7fdf04adc97f 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
{
const char *boot_splash_filename = NULL;
const char *boot_splash_time = NULL;
- uint8_t qemu_extra_params_fw[2];
char *filename, *file_data;
gsize file_size;
int file_type;
@@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
/* insert splash time if user configurated */
if (boot_splash_time) {
int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
+ uint16_t bst_le16;
+
/* validate the input */
if (bst_val < 0 || bst_val > 0xffff) {
error_report("splash-time is invalid,"
@@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
exit(1);
}
/* use little endian format */
- qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
- qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
- fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
+ bst_le16 = cpu_to_le16(bst_val);
+ fw_cfg_add_file(s, "etc/boot-menu-wait",
+ g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16);
}
/* insert splash file if user configurated */
--
2.19.1.3.g30247aa5d201
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
2019-01-18 22:31 [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw" Laszlo Ersek
@ 2019-01-21 7:21 ` Gerd Hoffmann
2019-01-21 7:40 ` Li Qiang
2019-01-21 15:14 ` Stefano Garzarella
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2019-01-21 7:21 UTC (permalink / raw)
To: Laszlo Ersek
Cc: qemu devel list, Markus Armbruster, Philippe Mathieu-Daudé
On Fri, Jan 18, 2019 at 11:31:52PM +0100, Laszlo Ersek wrote:
> Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
> 2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
> array from static to automatic. This broke the interface contract on the
> fw_cfg_add_file() function, which is documented as follows, in
> "include/hw/nvram/fw_cfg.h":
>
> > [...] The data referenced by the starting pointer is only linked, NOT
> > copied, into the data structure of the fw_cfg device. [...]
>
> As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
> file, it now sees garbage. Fix the regression by changing the storage
> duration to allocated. (The call is reached at most once, on the realize
> path of the board-specific fw_cfg sysbus device.)
>
> While at it, clean up the name and the assignment of the object as well.
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> hw/nvram/fw_cfg.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 53e8e010a8b7..7fdf04adc97f 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> {
> const char *boot_splash_filename = NULL;
> const char *boot_splash_time = NULL;
> - uint8_t qemu_extra_params_fw[2];
> char *filename, *file_data;
> gsize file_size;
> int file_type;
> @@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> /* insert splash time if user configurated */
> if (boot_splash_time) {
> int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
> + uint16_t bst_le16;
> +
> /* validate the input */
> if (bst_val < 0 || bst_val > 0xffff) {
> error_report("splash-time is invalid,"
> @@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> exit(1);
> }
> /* use little endian format */
> - qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
> - qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
> - fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
> + bst_le16 = cpu_to_le16(bst_val);
> + fw_cfg_add_file(s, "etc/boot-menu-wait",
> + g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16);
> }
>
> /* insert splash file if user configurated */
> --
> 2.19.1.3.g30247aa5d201
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
2019-01-21 7:21 ` Gerd Hoffmann
@ 2019-01-21 7:40 ` Li Qiang
0 siblings, 0 replies; 8+ messages in thread
From: Li Qiang @ 2019-01-21 7:40 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: Laszlo Ersek, Philippe Mathieu-Daudé,
qemu devel list, Markus Armbruster
Gerd Hoffmann <kraxel@redhat.com> 于2019年1月21日周一 下午3:22写道:
> On Fri, Jan 18, 2019 at 11:31:52PM +0100, Laszlo Ersek wrote:
> > Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
> > 2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
> > array from static to automatic. This broke the interface contract on the
> > fw_cfg_add_file() function, which is documented as follows, in
> > "include/hw/nvram/fw_cfg.h":
> >
> > > [...] The data referenced by the starting pointer is only linked, NOT
> > > copied, into the data structure of the fw_cfg device. [...]
> >
> > As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
> > file, it now sees garbage. Fix the regression by changing the storage
> > duration to allocated. (The call is reached at most once, on the realize
> > path of the board-specific fw_cfg sysbus device.)
> >
> > While at it, clean up the name and the assignment of the object as well.
>
> Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
>
> >
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Markus Armbruster <armbru@redhat.com>
> > Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> > Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
> > Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>
Oh my fault.
Reviewed-by: Li Qiang <liq3ea@gmail.com>
So I think my patch:
-->http://lists.nongnu.org/archive/html/qemu-devel/2019-01/msg04896.html
is useful to write this file entry test cases
Thanks,
Li Qiang
> > ---
> > hw/nvram/fw_cfg.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> > index 53e8e010a8b7..7fdf04adc97f 100644
> > --- a/hw/nvram/fw_cfg.c
> > +++ b/hw/nvram/fw_cfg.c
> > @@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> > {
> > const char *boot_splash_filename = NULL;
> > const char *boot_splash_time = NULL;
> > - uint8_t qemu_extra_params_fw[2];
> > char *filename, *file_data;
> > gsize file_size;
> > int file_type;
> > @@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> > /* insert splash time if user configurated */
> > if (boot_splash_time) {
> > int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
> > + uint16_t bst_le16;
> > +
> > /* validate the input */
> > if (bst_val < 0 || bst_val > 0xffff) {
> > error_report("splash-time is invalid,"
> > @@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> > exit(1);
> > }
> > /* use little endian format */
> > - qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
> > - qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
> > - fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw,
> 2);
> > + bst_le16 = cpu_to_le16(bst_val);
> > + fw_cfg_add_file(s, "etc/boot-menu-wait",
> > + g_memdup(&bst_le16, sizeof bst_le16), sizeof
> bst_le16);
> > }
> >
> > /* insert splash file if user configurated */
> > --
> > 2.19.1.3.g30247aa5d201
> >
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
2019-01-18 22:31 [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw" Laszlo Ersek
2019-01-21 7:21 ` Gerd Hoffmann
@ 2019-01-21 15:14 ` Stefano Garzarella
2019-01-22 12:00 ` Philippe Mathieu-Daudé
2019-01-31 14:27 ` Laszlo Ersek
3 siblings, 0 replies; 8+ messages in thread
From: Stefano Garzarella @ 2019-01-21 15:14 UTC (permalink / raw)
To: Laszlo Ersek
Cc: qemu devel list, Philippe Mathieu-Daudé,
Gerd Hoffmann, Markus Armbruster
On Fri, Jan 18, 2019 at 11:31:52PM +0100, Laszlo Ersek wrote:
> Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
> 2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
> array from static to automatic. This broke the interface contract on the
> fw_cfg_add_file() function, which is documented as follows, in
> "include/hw/nvram/fw_cfg.h":
>
> > [...] The data referenced by the starting pointer is only linked, NOT
> > copied, into the data structure of the fw_cfg device. [...]
>
> As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
> file, it now sees garbage. Fix the regression by changing the storage
> duration to allocated. (The call is reached at most once, on the realize
> path of the board-specific fw_cfg sysbus device.)
>
> While at it, clean up the name and the assignment of the object as well.
>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> hw/nvram/fw_cfg.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
2019-01-18 22:31 [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw" Laszlo Ersek
2019-01-21 7:21 ` Gerd Hoffmann
2019-01-21 15:14 ` Stefano Garzarella
@ 2019-01-22 12:00 ` Philippe Mathieu-Daudé
2019-01-31 14:27 ` Laszlo Ersek
3 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-01-22 12:00 UTC (permalink / raw)
To: Laszlo Ersek, qemu devel list; +Cc: Gerd Hoffmann, Markus Armbruster, Li Qiang
On 1/18/19 11:31 PM, Laszlo Ersek wrote:
> Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
> 2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
> array from static to automatic. This broke the interface contract on the
> fw_cfg_add_file() function, which is documented as follows, in
> "include/hw/nvram/fw_cfg.h":
>
>> [...] The data referenced by the starting pointer is only linked, NOT
>> copied, into the data structure of the fw_cfg device. [...]
>
> As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
> file, it now sees garbage. Fix the regression by changing the storage
> duration to allocated. (The call is reached at most once, on the realize
> path of the board-specific fw_cfg sysbus device.)
Hopefully you catched this in time. This also demonstrate my testing is
poor. This will be improved.
>
> While at it, clean up the name and the assignment of the object as well.
>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> hw/nvram/fw_cfg.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 53e8e010a8b7..7fdf04adc97f 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> {
> const char *boot_splash_filename = NULL;
> const char *boot_splash_time = NULL;
> - uint8_t qemu_extra_params_fw[2];
> char *filename, *file_data;
> gsize file_size;
> int file_type;
> @@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> /* insert splash time if user configurated */
> if (boot_splash_time) {
> int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
> + uint16_t bst_le16;
> +
> /* validate the input */
> if (bst_val < 0 || bst_val > 0xffff) {
> error_report("splash-time is invalid,"
> @@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> exit(1);
> }
> /* use little endian format */
> - qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
> - qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
> - fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
> + bst_le16 = cpu_to_le16(bst_val);
I had a similar patch staged using the ldst API, however using the
cpu_to API is more consistent with the rest of this file.
> + fw_cfg_add_file(s, "etc/boot-menu-wait",
> + g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16);
Using the heap and not worrying about releasing it is also consistent
with the rest of this file, so:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Sorry for having you going throught this bug, and thanks for fixing it!
Phil.
> }
>
> /* insert splash file if user configurated */
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
2019-01-18 22:31 [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw" Laszlo Ersek
` (2 preceding siblings ...)
2019-01-22 12:00 ` Philippe Mathieu-Daudé
@ 2019-01-31 14:27 ` Laszlo Ersek
2019-01-31 15:06 ` Michael S. Tsirkin
3 siblings, 1 reply; 8+ messages in thread
From: Laszlo Ersek @ 2019-01-31 14:27 UTC (permalink / raw)
To: qemu devel list, Michael S. Tsirkin
Cc: Philippe Mathieu-Daudé, Gerd Hoffmann, Markus Armbruster
On 01/18/19 23:31, Laszlo Ersek wrote:
> Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
> 2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
> array from static to automatic. This broke the interface contract on the
> fw_cfg_add_file() function, which is documented as follows, in
> "include/hw/nvram/fw_cfg.h":
>
>> [...] The data referenced by the starting pointer is only linked, NOT
>> copied, into the data structure of the fw_cfg device. [...]
>
> As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
> file, it now sees garbage. Fix the regression by changing the storage
> duration to allocated. (The call is reached at most once, on the realize
> path of the board-specific fw_cfg sysbus device.)
>
> While at it, clean up the name and the assignment of the object as well.
>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> hw/nvram/fw_cfg.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 53e8e010a8b7..7fdf04adc97f 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> {
> const char *boot_splash_filename = NULL;
> const char *boot_splash_time = NULL;
> - uint8_t qemu_extra_params_fw[2];
> char *filename, *file_data;
> gsize file_size;
> int file_type;
> @@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> /* insert splash time if user configurated */
> if (boot_splash_time) {
> int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
> + uint16_t bst_le16;
> +
> /* validate the input */
> if (bst_val < 0 || bst_val > 0xffff) {
> error_report("splash-time is invalid,"
> @@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> exit(1);
> }
> /* use little endian format */
> - qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
> - qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
> - fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
> + bst_le16 = cpu_to_le16(bst_val);
> + fw_cfg_add_file(s, "etc/boot-menu-wait",
> + g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16);
> }
>
> /* insert splash file if user configurated */
>
I hope a polite ping can't hurt; can we get this merged please?
Thanks
LAszlo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
2019-01-31 14:27 ` Laszlo Ersek
@ 2019-01-31 15:06 ` Michael S. Tsirkin
2019-01-31 18:14 ` Laszlo Ersek
0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2019-01-31 15:06 UTC (permalink / raw)
To: Laszlo Ersek
Cc: qemu devel list, Philippe Mathieu-Daudé,
Gerd Hoffmann, Markus Armbruster
On Thu, Jan 31, 2019 at 03:27:01PM +0100, Laszlo Ersek wrote:
> On 01/18/19 23:31, Laszlo Ersek wrote:
> > Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
> > 2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
> > array from static to automatic. This broke the interface contract on the
> > fw_cfg_add_file() function, which is documented as follows, in
> > "include/hw/nvram/fw_cfg.h":
> >
> >> [...] The data referenced by the starting pointer is only linked, NOT
> >> copied, into the data structure of the fw_cfg device. [...]
> >
> > As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
> > file, it now sees garbage. Fix the regression by changing the storage
> > duration to allocated. (The call is reached at most once, on the realize
> > path of the board-specific fw_cfg sysbus device.)
> >
> > While at it, clean up the name and the assignment of the object as well.
> >
> > Cc: Gerd Hoffmann <kraxel@redhat.com>
> > Cc: Markus Armbruster <armbru@redhat.com>
> > Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
> > Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
> > Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> > ---
> > hw/nvram/fw_cfg.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> > index 53e8e010a8b7..7fdf04adc97f 100644
> > --- a/hw/nvram/fw_cfg.c
> > +++ b/hw/nvram/fw_cfg.c
> > @@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> > {
> > const char *boot_splash_filename = NULL;
> > const char *boot_splash_time = NULL;
> > - uint8_t qemu_extra_params_fw[2];
> > char *filename, *file_data;
> > gsize file_size;
> > int file_type;
> > @@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> > /* insert splash time if user configurated */
> > if (boot_splash_time) {
> > int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
> > + uint16_t bst_le16;
> > +
> > /* validate the input */
> > if (bst_val < 0 || bst_val > 0xffff) {
> > error_report("splash-time is invalid,"
> > @@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> > exit(1);
> > }
> > /* use little endian format */
> > - qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
> > - qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
> > - fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
> > + bst_le16 = cpu_to_le16(bst_val);
> > + fw_cfg_add_file(s, "etc/boot-menu-wait",
> > + g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16);
> > }
> >
> > /* insert splash file if user configurated */
> >
>
> I hope a polite ping can't hurt; can we get this merged please?
>
> Thanks
> LAszlo
Sure it does not hurt. I have it tagged for the next pull.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw"
2019-01-31 15:06 ` Michael S. Tsirkin
@ 2019-01-31 18:14 ` Laszlo Ersek
0 siblings, 0 replies; 8+ messages in thread
From: Laszlo Ersek @ 2019-01-31 18:14 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: qemu devel list, Philippe Mathieu-Daudé,
Gerd Hoffmann, Markus Armbruster
On 01/31/19 16:06, Michael S. Tsirkin wrote:
> On Thu, Jan 31, 2019 at 03:27:01PM +0100, Laszlo Ersek wrote:
>> On 01/18/19 23:31, Laszlo Ersek wrote:
>>> Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
>>> 2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
>>> array from static to automatic. This broke the interface contract on the
>>> fw_cfg_add_file() function, which is documented as follows, in
>>> "include/hw/nvram/fw_cfg.h":
>>>
>>>> [...] The data referenced by the starting pointer is only linked, NOT
>>>> copied, into the data structure of the fw_cfg device. [...]
>>>
>>> As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
>>> file, it now sees garbage. Fix the regression by changing the storage
>>> duration to allocated. (The call is reached at most once, on the realize
>>> path of the board-specific fw_cfg sysbus device.)
>>>
>>> While at it, clean up the name and the assignment of the object as well.
>>>
>>> Cc: Gerd Hoffmann <kraxel@redhat.com>
>>> Cc: Markus Armbruster <armbru@redhat.com>
>>> Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
>>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>>> ---
>>> hw/nvram/fw_cfg.c | 9 +++++----
>>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
>>> index 53e8e010a8b7..7fdf04adc97f 100644
>>> --- a/hw/nvram/fw_cfg.c
>>> +++ b/hw/nvram/fw_cfg.c
>>> @@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
>>> {
>>> const char *boot_splash_filename = NULL;
>>> const char *boot_splash_time = NULL;
>>> - uint8_t qemu_extra_params_fw[2];
>>> char *filename, *file_data;
>>> gsize file_size;
>>> int file_type;
>>> @@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
>>> /* insert splash time if user configurated */
>>> if (boot_splash_time) {
>>> int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
>>> + uint16_t bst_le16;
>>> +
>>> /* validate the input */
>>> if (bst_val < 0 || bst_val > 0xffff) {
>>> error_report("splash-time is invalid,"
>>> @@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
>>> exit(1);
>>> }
>>> /* use little endian format */
>>> - qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
>>> - qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
>>> - fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
>>> + bst_le16 = cpu_to_le16(bst_val);
>>> + fw_cfg_add_file(s, "etc/boot-menu-wait",
>>> + g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16);
>>> }
>>>
>>> /* insert splash file if user configurated */
>>>
>>
>> I hope a polite ping can't hurt; can we get this merged please?
>>
>> Thanks
>> LAszlo
>
> Sure it does not hurt. I have it tagged for the next pull.
>
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-01-31 18:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18 22:31 [Qemu-devel] [PATCH] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw" Laszlo Ersek
2019-01-21 7:21 ` Gerd Hoffmann
2019-01-21 7:40 ` Li Qiang
2019-01-21 15:14 ` Stefano Garzarella
2019-01-22 12:00 ` Philippe Mathieu-Daudé
2019-01-31 14:27 ` Laszlo Ersek
2019-01-31 15:06 ` Michael S. Tsirkin
2019-01-31 18:14 ` Laszlo Ersek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.