Skip to contentSkip to conversation

vl.c: disallow command line fw cfg without opt/

PATCH In review Michael S. Tsirkin 6 participants 36 messages Mar 15, 2016 – Mar 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 vl.c: disallow command line fw cfg without opt/

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

---

changes from v1:
add configure option

 configure | 7 +++++++
 vl.c      | 3 +++
 2 files changed, 10 insertions(+)
configure +7 -0
index 2b32876..e5a692f 100755
@@ -256,6 +256,7 @@ sysconfdir="\${prefix}/etc"
 local_statedir="\${prefix}/var"
 confsuffix="/qemu"
 slirp="yes"
+unsafe_fw_cfg="no"
 oss_lib=""
 bsd="no"
 linux="no"
@@ -875,6 +876,8 @@ for opt do
   ;;
   --enable-vnc-png) vnc_png="yes"
   ;;
+  --enable-unsafe-fw-cfg) unsafe_fw_cfg="yes"
+  ;;
   --disable-slirp) slirp="no"
   ;;
   --disable-uuid) uuid="no"
@@ -1286,6 +1289,7 @@ Advanced options (experts only):
                            Available backends: $($python $source_path/scripts/tracetool.py --list-backends)
   --with-trace-file=NAME   Full PATH,NAME of file to store traces
                            Default:trace-<pid>
+  --enable-unsafe-fw-cfg   Enable loading fw cfg entries at unsafe paths (broken! don't use in production!)
   --disable-slirp          disable SLIRP userspace network connectivity
   --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
   --oss-lib                path to OSS library
@@ -4911,6 +4915,9 @@ fi
 if test "$profiler" = "yes" ; then
   echo "CONFIG_PROFILER=y" >> $config_host_mak
 fi
+if test "$unsafe_fw_cfg" = "yes" ; then
+  echo "CONFIG_UNSAFE_FW_CFG=y" >> $config_host_mak
+fi
 if test "$slirp" = "yes" ; then
   echo "CONFIG_SLIRP=y" >> $config_host_mak
   echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
vl.c +3 -0
index 7a28982..5adf217 100644
@@ -2321,6 +2321,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)
     if (strncmp(name, "opt/", 4) != 0) {
         error_report("warning: externally provided fw_cfg item names "
                      "should be prefixed with \"opt/\"");
+#ifndef CONFIG_UNSAFE_FW_CFG
+        return -1;
+#endif
     }
     if (nonempty_str(str)) {
         size = strlen(str); /* NUL terminator NOT included in fw_cfg blob */
Signature · 1 line
MST
#1 lore raw
Quoted 7 lines · Michael S. Tsirkin

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Quoted 6 lines

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

I'm having a hard time to see the point. There are *countless* ways users can mess up their guests from the command line or the monitor. Yet we get so hung up on this rather obscure one to attempt to catch some (but far from all) misuses that may trigger it, and then, because that interferes with debugging, add a *configure* option to suppress it again.

Misuse of -fw_cfg isn't even a molehill, but adding a configure option *is* making a mountain out of it.

If you know what "fw cfg" is (few users do), and know how to put the user-specified fw cfg files feature to use (even fewer), you're damn well expected to know to stick to /opt or else. We already print a reminder. That's as far as I'd want us to go.

#2 lore raw
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Michael S. Tsirkin

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Quoted 8 lines
Quoted 6 lines

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

I'm having a hard time to see the point.

Frankly, I am having a hard time to see the point of exposing fw cfg to users at all. It was designed as an internal interface between QEMU PC hardware and firmware. As a PC maintainer, I do not like it that users get to poke at PC internals.

So it is yet another way to pass binaries to Linux guests. Don't we have enough of these? But Gerd likes it for some reason, and merged it. OK.

But please find a way to make sure it does not conflict with its current usage in PC. Asking that all files have an "opt/" prefix is one way but only if it is enforced.

This is polluting global namespace.

Quoted 6 lines

There are *countless* ways
users can mess up their guests from the command line or the monitor. Yet we get so hung up on this rather obscure one to attempt to catch some (but far from all) misuses that may trigger it, and then, because that interferes with debugging, add a *configure* option to suppress it again.

In fact, how does it interfere with debugging? debugging what? by whom? I think we should figure that out instead of carrying more opaque binaries around.

E.g. if people want to replace built-in ACPI tables, say so, and we'll look at sane ways to do this that do not involve poking at acpi internals.

Quoted 3 lines

Misuse of -fw_cfg isn't even a molehill, but adding a configure option *is* making a mountain out of it.

Yea. That configure hack is an attempt at a compromise.

But maybe the real fix is to rip fw cfg tweaking from command line out completely, at least for 2.6.

Quoted 4 lines

If you know what "fw cfg" is (few users do), and know how to put the user-specified fw cfg files feature to use (even fewer), you're damn well expected to know to stick to /opt or else. We already print a reminder. That's as far as I'd want us to go.

What happens is that inevitable someone finds a bug, and then finds a work around, and blog posts spring up advertising the fix, and you can never go back again.

Or a tool uses this, no one notices for years, and after an update someone gets to debug it until finally the warning is noticed.
Or more likely it all ends up in the launchpad/bugzilla, with yet another useful tool broken for no good reason.

Signature · 1 line
MST
#3 lore raw
Quoted 19 lines · Michael S. Tsirkin
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Michael S. Tsirkin

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Quoted 8 lines
Quoted 6 lines

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

I'm having a hard time to see the point.

Quoted 8 lines

Frankly, I am having a hard time to see the point of exposing fw cfg to users at all. It was designed as an internal interface between QEMU PC hardware and firmware. As a PC maintainer, I do not like it that users get to poke at PC internals.

So it is yet another way to pass binaries to Linux guests. Don't we have enough of these? But Gerd likes it for some reason, and merged it. OK.

As the author of the feature, I feel I should jump back in and clarify:

It's a way to pass arbitrary blobs to any type of guest, with two important properties: 1. asynchronous, and 2. out-of-band. When I started looking, all existing methods involved either having the host start polling for the guest to bring up qga and be ready to accept an out-of-band connection (i.e., *not* asynchronous), or have the guest mount some special cdrom or floppy image prepared by the host (i.e., *not* out of band).

fw_cfg is both asynchronous and out-of-band, so it appeared to be the perfect choice.

Quoted 3 lines

But please find a way to make sure it does not conflict with its current usage in PC. Asking that all files have an "opt/" prefix is one way but only if it is enforced.

Enforcing the "opt/" prefix was clearly on the table when I submitted the feature (and totally acceptable for my own needs). At the time, however, most of the advice I received on the list was to leave it as a warning only (i.e., "mechanism, not policy"), especially since other respondents expressed interest in passing in non-"/opt" blobs for easier development and debugging of alternative firmware (such as OVMF, iirc).

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

Thanks much,
--Gabriel

#4 lore raw
Quoted 53 lines · Gabriel L. Somlo
Quoted 19 lines · Michael S. Tsirkin
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Michael S. Tsirkin

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Quoted 8 lines
Quoted 6 lines

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

I'm having a hard time to see the point.

Quoted 8 lines

Frankly, I am having a hard time to see the point of exposing fw cfg to users at all. It was designed as an internal interface between QEMU PC hardware and firmware. As a PC maintainer, I do not like it that users get to poke at PC internals.

So it is yet another way to pass binaries to Linux guests. Don't we have enough of these? But Gerd likes it for some reason, and merged it. OK.

As the author of the feature, I feel I should jump back in and clarify:

It's a way to pass arbitrary blobs to any type of guest, with two important properties: 1. asynchronous, and 2. out-of-band. When I started looking, all existing methods involved either having the host start polling for the guest to bring up qga and be ready to accept an out-of-band connection (i.e., *not* asynchronous), or have the guest mount some special cdrom or floppy image prepared by the host (i.e., *not* out of band).

fw_cfg is both asynchronous and out-of-band, so it appeared to be the perfect choice.

Quoted 3 lines

But please find a way to make sure it does not conflict with its current usage in PC. Asking that all files have an "opt/" prefix is one way but only if it is enforced.

Enforcing the "opt/" prefix was clearly on the table when I submitted the feature (and totally acceptable for my own needs). At the time, however, most of the advice I received on the list was to leave it as a warning only (i.e., "mechanism, not policy"), especially since other respondents expressed interest in passing in non-"/opt" blobs for easier development and debugging of alternative firmware (such as OVMF, iirc).

Quoted 3 lines

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Quoted 8 lines

NOTE: Users *SHOULD* choose item names beginning with the prefix "opt/" when using the "-fw_cfg" command line option, to avoid conflicting with item names used internally by QEMU. For instance:

-fw_cfg name=opt/my_item_name,file=./my_blob.bin

Similarly, QEMU developers *SHOULD NOT* use item names prefixed with "opt/" when inserting items programmatically, e.g. via fw_cfg_add_file().

It says "should", not "must". I liked (and like) the "mechanism, not policy" thing. Letting developers pass in whatever they want, for development / debugging / testing purposes, is a plus to me.

Thanks
Laszlo

#5 lore raw
Quoted 67 lines · Laszlo Ersek
Quoted 53 lines · Gabriel L. Somlo
Quoted 19 lines · Michael S. Tsirkin
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Michael S. Tsirkin

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Quoted 8 lines
Quoted 6 lines

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

I'm having a hard time to see the point.

Quoted 8 lines

Frankly, I am having a hard time to see the point of exposing fw cfg to users at all. It was designed as an internal interface between QEMU PC hardware and firmware. As a PC maintainer, I do not like it that users get to poke at PC internals.

So it is yet another way to pass binaries to Linux guests. Don't we have enough of these? But Gerd likes it for some reason, and merged it. OK.

As the author of the feature, I feel I should jump back in and clarify:

It's a way to pass arbitrary blobs to any type of guest, with two important properties: 1. asynchronous, and 2. out-of-band. When I started looking, all existing methods involved either having the host start polling for the guest to bring up qga and be ready to accept an out-of-band connection (i.e., *not* asynchronous), or have the guest mount some special cdrom or floppy image prepared by the host (i.e., *not* out of band).

fw_cfg is both asynchronous and out-of-band, so it appeared to be the perfect choice.

Quoted 3 lines

But please find a way to make sure it does not conflict with its current usage in PC. Asking that all files have an "opt/" prefix is one way but only if it is enforced.

Enforcing the "opt/" prefix was clearly on the table when I submitted the feature (and totally acceptable for my own needs). At the time, however, most of the advice I received on the list was to leave it as a warning only (i.e., "mechanism, not policy"), especially since other respondents expressed interest in passing in non-"/opt" blobs for easier development and debugging of alternative firmware (such as OVMF, iirc).

Quoted 3 lines

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Quoted 4 lines

NOTE: Users *SHOULD* choose item names beginning with the prefix "opt/" when using the "-fw_cfg" command line option, to avoid conflicting with item names used internally by QEMU. For instance:

Quoted 6 lines
Quoted 4 lines

-fw_cfg name=opt/my_item_name,file=./my_blob.bin

Similarly, QEMU developers *SHOULD NOT* use item names prefixed with "opt/" when inserting items programmatically, e.g. via fw_cfg_add_file().

It says "should", not "must".

should means "might be ok". So change it to must then?

Quoted 6 lines

I liked (and like) the "mechanism, not
policy" thing. Letting developers pass in whatever they want, for development / debugging / testing purposes, is a plus to me.

Thanks
Laszlo

Could you flesh out the development / debugging / testing and how is inserting files in PC namespace useful for that?

Signature · 1 line
MST
#6 lore raw
Quoted 68 lines · Michael S. Tsirkin
Quoted 67 lines · Laszlo Ersek
Quoted 53 lines · Gabriel L. Somlo
Quoted 19 lines · Michael S. Tsirkin
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Michael S. Tsirkin

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Quoted 8 lines
Quoted 6 lines

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

I'm having a hard time to see the point.

Quoted 8 lines

Frankly, I am having a hard time to see the point of exposing fw cfg to users at all. It was designed as an internal interface between QEMU PC hardware and firmware. As a PC maintainer, I do not like it that users get to poke at PC internals.

So it is yet another way to pass binaries to Linux guests. Don't we have enough of these? But Gerd likes it for some reason, and merged it. OK.

As the author of the feature, I feel I should jump back in and clarify:

It's a way to pass arbitrary blobs to any type of guest, with two important properties: 1. asynchronous, and 2. out-of-band. When I started looking, all existing methods involved either having the host start polling for the guest to bring up qga and be ready to accept an out-of-band connection (i.e., *not* asynchronous), or have the guest mount some special cdrom or floppy image prepared by the host (i.e., *not* out of band).

fw_cfg is both asynchronous and out-of-band, so it appeared to be the perfect choice.

Quoted 3 lines

But please find a way to make sure it does not conflict with its current usage in PC. Asking that all files have an "opt/" prefix is one way but only if it is enforced.

Enforcing the "opt/" prefix was clearly on the table when I submitted the feature (and totally acceptable for my own needs). At the time, however, most of the advice I received on the list was to leave it as a warning only (i.e., "mechanism, not policy"), especially since other respondents expressed interest in passing in non-"/opt" blobs for easier development and debugging of alternative firmware (such as OVMF, iirc).

Quoted 3 lines

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Quoted 4 lines

NOTE: Users *SHOULD* choose item names beginning with the prefix "opt/" when using the "-fw_cfg" command line option, to avoid conflicting with item names used internally by QEMU. For instance:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

-fw_cfg name=opt/my_item_name,file=./my_blob.bin

Similarly, QEMU developers *SHOULD NOT* use item names prefixed with "opt/" when inserting items programmatically, e.g. via fw_cfg_add_file().

It says "should", not "must".

should means "might be ok".

Yes, if there is a pressing reason. And even then, "you have been warned".

Quoted 1 line

So change it to must then?

I didn't suggest that.

(For consistency, your patch should be attempting to modify the code and the docs together -- but this doesn't mean that I agree with the patch.)

Quoted 9 lines
Quoted 6 lines

I liked (and like) the "mechanism, not
policy" thing. Letting developers pass in whatever they want, for development / debugging / testing purposes, is a plus to me.

Thanks
Laszlo

Could you flesh out the development / debugging / testing and how is inserting files in PC namespace useful for that?

I don't know -- which is part of the argument. Lack of a ready example doesn't imply (to me) that the possibility should be excluded.

As Paolo said, I believe we've been through this discussion. I have no new arguments; the old ones are valid to me still. I won't try to influence this discussion any further; I only chimed in because OVMF was mentioned (and because I noticed that the docs would get out of sync with the code).

Thanks
Laszlo

#7 lore raw
Quoted 100 lines · Laszlo Ersek
Quoted 68 lines · Michael S. Tsirkin
Quoted 67 lines · Laszlo Ersek
Quoted 53 lines · Gabriel L. Somlo
Quoted 19 lines · Michael S. Tsirkin
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Michael S. Tsirkin

Allowing arbitary file names on command line is setting us up for
failure: future guests will look for a specific QEMU-specified name and will get confused finding a user file there.

We do warn but people are conditioned to ignore warnings by now, so at best that will help users debug problem, not avoid it.

Quoted 8 lines
Quoted 6 lines

Disable this by default, so distros don't get to deal with it, but leave an option for developers to configure this in, with scary warnings so people only do it if they know what they are doing.

I'm having a hard time to see the point.

Quoted 8 lines

Frankly, I am having a hard time to see the point of exposing fw cfg to users at all. It was designed as an internal interface between QEMU PC hardware and firmware. As a PC maintainer, I do not like it that users get to poke at PC internals.

So it is yet another way to pass binaries to Linux guests. Don't we have enough of these? But Gerd likes it for some reason, and merged it. OK.

As the author of the feature, I feel I should jump back in and clarify:

It's a way to pass arbitrary blobs to any type of guest, with two important properties: 1. asynchronous, and 2. out-of-band. When I started looking, all existing methods involved either having the host start polling for the guest to bring up qga and be ready to accept an out-of-band connection (i.e., *not* asynchronous), or have the guest mount some special cdrom or floppy image prepared by the host (i.e., *not* out of band).

fw_cfg is both asynchronous and out-of-band, so it appeared to be the perfect choice.

Quoted 3 lines

But please find a way to make sure it does not conflict with its current usage in PC. Asking that all files have an "opt/" prefix is one way but only if it is enforced.

Enforcing the "opt/" prefix was clearly on the table when I submitted the feature (and totally acceptable for my own needs). At the time, however, most of the advice I received on the list was to leave it as a warning only (i.e., "mechanism, not policy"), especially since other respondents expressed interest in passing in non-"/opt" blobs for easier development and debugging of alternative firmware (such as OVMF, iirc).

Quoted 3 lines

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Quoted 4 lines

NOTE: Users *SHOULD* choose item names beginning with the prefix "opt/" when using the "-fw_cfg" command line option, to avoid conflicting with item names used internally by QEMU. For instance:

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

-fw_cfg name=opt/my_item_name,file=./my_blob.bin

Similarly, QEMU developers *SHOULD NOT* use item names prefixed with "opt/" when inserting items programmatically, e.g. via fw_cfg_add_file().

It says "should", not "must".

should means "might be ok".

Yes, if there is a pressing reason. And even then, "you have been warned".

Quoted 1 line

So change it to must then?

I didn't suggest that.

(For consistency, your patch should be attempting to modify the code and the docs together -- but this doesn't mean that I agree with the patch.)

Quoted 9 lines
Quoted 6 lines

I liked (and like) the "mechanism, not
policy" thing. Letting developers pass in whatever they want, for development / debugging / testing purposes, is a plus to me.

Thanks
Laszlo

Could you flesh out the development / debugging / testing and how is inserting files in PC namespace useful for that?

I don't know -- which is part of the argument. Lack of a ready example doesn't imply (to me) that the possibility should be excluded.

Quoted 8 lines

As Paolo said, I believe we've been through this discussion. I have no new arguments; the old ones are valid to me still. I won't try to influence this discussion any further; I only chimed in because OVMF was mentioned (and because I noticed that the docs would get out of sync with the code).

Thanks
Laszlo

By the way, these are developer docs. User docs do not say anything:

-fw_cfg [name=]name,file=file
Add named fw_cfg entry from file. name determines the name of the entry in the fw_cfg file directory exposed to the guest.

-fw_cfg [name=]name,string=str
Add named fw_cfg entry from string.

Signature · 1 line
MST
#8 lore raw
In reply to Laszlo Ersek
Quoted 4 lines · Laszlo Ersek
Quoted 4 lines
Quoted 4 lines

I liked (and like) the "mechanism, not
policy" thing. Letting developers pass in whatever they want, for development / debugging / testing purposes, is a plus to me.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Thanks
Laszlo

Could you flesh out the development / debugging / testing and how is inserting files in PC namespace useful for that?

I don't know -- which is part of the argument. Lack of a ready example doesn't imply (to me) that the possibility should be excluded.

When it comes to an interface that has to be maintained indefinitely, only allowing what you absolutely need seems like exactly the correct design.

Signature · 1 line
MST
#9 lore raw
In reply to Laszlo Ersek
Quoted 4 lines · Laszlo Ersek

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Wait a second. You are saying upsteam OVMF puts files there. If users add their own flags that happen to be in opt/ovmf/ then what happens? And how do they *know* they should avoid that? There's no warning, guest just breaks in various ways.

This is exactly the kind of mess I was worried about. We have a global namespace with no way to control what goes where.

opt/ was for end users not firmware.

The right thing to do would be for ovmf to reserve itself a directory under root.

This really needs more thought. For now I'd suggest we drop the whole interface from 2.6 and come back to it after 2.6.

Signature · 1 line
MST
#10 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Laszlo Ersek

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Wait a second. You are saying upsteam OVMF puts files there.

Sorry, I wasn't clear enough. OVMF consumes files that are put there by the user.

Quoted 7 lines

If users add their own flags that happen to be in opt/ovmf/ then what happens? And how do they *know* they should avoid that? There's no warning, guest just breaks in various ways.

This is exactly the kind of mess I was worried about. We have a global namespace with no way to control what goes where.

Quoted 7 lines

opt/ was for end users not firmware.

The right thing to do would be for ovmf to reserve itself a directory under root.

This really needs more thought. For now I'd suggest we drop the whole interface from 2.6 and come back to it after 2.6.

I very strongly disagree. -fw_cfg was invented exactly for the purpose that guest code (mostly, but not exclusively, guest firmware code) can take settings from the user without QEMU's knowledge. We were conscious of the namespace question, which is why the opt/ prefix was strongly recommended for such knobs. Trying to control it all from QEMU (beyond setting aside the opt/ subdirectory, regardless if it's worded "should" or "must"), introducing a central registry for prefixes, would defeat the entire purpose.

Subdividing the namespace under opt/ was purposely left open. Then I went with opt/ovmf/ for files that OVMF should take from users because that's the obvious choice.

If we want to be extremely paranoid about the namespace, we can modify the recommendation to say "use opt/UUID/...", where UUID is generated with "uuidgen". That's just an example I know from UEFI; it is how the entire namespace question is side-stepped without a central registry. Nonetheless, OVMF is the second of two guest firmwares in total, so "opt/ovmf/" is the obvious choice.

Removing the interface would break existing code in OVMF that (a) consumes opt/ovmf/... files and (b) doesn't disturb anything at all otherwise.

Plus, the -fw_cfg option was released in 2.4 (added around commit 81b2b81062).

Laszlo

#11 lore raw
Quoted 11 lines · Laszlo Ersek
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Laszlo Ersek

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Wait a second. You are saying upsteam OVMF puts files there.

Sorry, I wasn't clear enough. OVMF consumes files that are put there by the user.

I think what Michael is saying is that OVMF now has to worry about users calling their own files "opt/ovmf/foo" and causing a conflict.

I actually agree with his worry, but probably not with how to resolve it. For me, the way to resolve it would be:

1) files should actually be named etc/ovmf/foo. OVMF could optionally accept both the old and the new names for a while, you would decide whether this is useful.

2) in turn, because of (1) even the warning on opt/ should be removed.

Paolo

#12 lore raw
Quoted 18 lines · Paolo Bonzini
Quoted 11 lines · Laszlo Ersek
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines · Laszlo Ersek

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Wait a second. You are saying upsteam OVMF puts files there.

Sorry, I wasn't clear enough. OVMF consumes files that are put there by the user.

I think what Michael is saying is that OVMF now has to worry about users calling their own files "opt/ovmf/foo" and causing a conflict.

Quoted 6 lines

I actually agree with his worry, but probably not with how to resolve it. For me, the way to resolve it would be:

1) files should actually be named etc/ovmf/foo. OVMF could optionally accept both the old and the new names for a while, you would decide whether this is useful.

IOW if etc/ovmf exists, then ignore opt/ovmf? OK.

Quoted 3 lines

2) in turn, because of (1) even the warning on opt/ should be removed.

Paolo

If we do 2) then users might put files in etc/ovmf/foo.

Signature · 1 line
MST
#13 lore raw
Quoted 9 lines · Michael S. Tsirkin
Quoted 3 lines

1) files should actually be named etc/ovmf/foo. OVMF could optionally accept both the old and the new names for a while, you would decide whether this is useful.

IOW if etc/ovmf exists, then ignore opt/ovmf? OK.

Quoted 1 line

2) in turn, because of (1) even the warning on opt/ should be removed.

If we do 2) then users might put files in etc/ovmf/foo.

Right, that's exactly the point. These are user-configurable knobs for the firmware (user-configurable meaning they can't be expected to recompile QEMU).

Paolo

#14 lore raw
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Michael S. Tsirkin
Quoted 3 lines

1) files should actually be named etc/ovmf/foo. OVMF could optionally accept both the old and the new names for a while, you would decide whether this is useful.

IOW if etc/ovmf exists, then ignore opt/ovmf? OK.

Quoted 1 line

2) in turn, because of (1) even the warning on opt/ should be removed.

Quoted 7 lines
Quoted 1 line

If we do 2) then users might put files in etc/ovmf/foo.

Right, that's exactly the point. These are user-configurable knobs for the firmware (user-configurable meaning they can't be expected to recompile QEMU).

Paolo

Right.

See Markus' answer and my proposal that attempts to be a superset of this.

Signature · 1 line
MST
#15 lore raw
In reply to Laszlo Ersek

Hi,

Quoted 8 lines
Quoted 3 lines

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

seabios has a few flags too, in etc/. Some of them are supported directly by qemu (such as setting the boot menu delay). Others are not, and I'd like to be able to use -fw_cfg for them for testing/debugging (any use cases beyond that should be supported by adding a less obscure way to set them to qemu, similar to the boot delay).

Oh, and that'll most likely be more seabios testing than qemu testing, so why require me build a special qemu version for that?

On the ovmf flags: What kind of flags are there? Anything a normal user might want to set?

cheers,
Gerd

#16 lore raw
Quoted 11 lines · Gerd Hoffmann

Hi,

Quoted 8 lines
Quoted 3 lines

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

Quoted 8 lines

seabios has a few flags too, in etc/. Some of them are supported directly by qemu (such as setting the boot menu delay). Others are not, and I'd like to be able to use -fw_cfg for them for testing/debugging (any use cases beyond that should be supported by adding a less obscure way to set them to qemu, similar to the boot delay).

Oh, and that'll most likely be more seabios testing than qemu testing, so why require me build a special qemu version for that?

+1

Quoted 2 lines

On the ovmf flags: What kind of flags are there? Anything a normal user might want to set?

Occasionally, yes.

- "opt/ovmf/PcdPropertiesTableEnable" controls whether the "properties table" UEFI feature is enabled. Some guest OSes support it, some others are broken by it. It defaults to false.

- "opt/ovmf/PcdSetNxForStack" controls whether the stack is made non-executable at the start of the DXE phase. This is meant as a security feature in edk2 generally, it is not specific to OVMF; only the way it is exposed to users is specific to OVMF. It used to default to TRUE, but then people reported that a non-executable stack was breaking grub2-efi binaries that had been shipped on Debian installer ISOs sometime during the middle ages. So I was forced to change the default to FALSE (and I hate that compromise to this day).

- "opt/ovmf/X-PciMmio64Mb" controls the size of the range from which the 64-bit MMIO BARs are allocated. It defaults to 32GB (and as you suggested, a natural alignment is also ensured, both for the default 32GB, and for the user's choice, if any). The "X-" prefix signals that this is an experimental knob without any promise of stability. There are two imporant use cases for this knob at the moment: (a) if a user has a bunch of MMIO-hungry assignable devices, allow him/her to experiment with this flag, and report his/her data to us, so we can come up with smart heuristics, (b) allow a user to disable the high allocation of 64-bit MMIO BARs entirely, by setting the value to 0.

The edk2 BAR allocation code prefers to allocate 64-bit BARs actually high -- unlike SeaBIOS --, and this has already exposed problems. For example, such devices don't work -- at the moment -- behind PXBs, if you use OVMF. Marcel is going to enhance PXB to support this (thank you!), but even until then (and for yet unknown similar issues), this flag allows a user to force the edk2 allocator to keep those 64-bit BARs under 4GB, at least if there is enough room for them there.)

In downstream, we have two more (same purpose but separately for ARM and x86):
- opt/aavmf/PcdResizeXterm
- opt/ovmf/PcdResizeXterm

(These settings are downstream only because the underlying feature that they control was rejected by upstream.)

The feature they control is the following: assume you are at the UEFI shell prompt, and you have at least two console devices (e.g., one serial console you are looking at in xterm, and one video display you are looking at with spice), with the text output being mirrored to both. The MODE command allows you to select various text resolutions that are supported by all of your console devices simultaneously. Let's say you change from the default 80x25 to 100x31. This will correctly resize your video display, and also change the textual resolution used on the serial console, but it will *not* resize your xterm. Which means the serial console output will be garbled when you scroll, when you use commands that print wide tables, and so on. If the user sets the above knob to Y, then the xterm will also be resized (via control sequences). Sometimes this feature is invaluable, sometimes it's very annoying. It defaults to N.

- Another flag I might expose later is "PcdHiiOsRuntimeSupport". This would control whether various bits of UEFI configuration that are normally accessible through TUI forms in the UEFI setup are also exposed as a large binary blob to the runtime OS. As I understand it, this feature is meant to allow OS-level vendor applications to mess with various firmware settings. For now OVMF inherits the central default Y. It is somewhat costly, so I think I'll flip the default for OVMF to N, but expose the knob under "opt/ovmf/PcdHiiOsRuntimeSupport" to support people who want to experiment with this.

-*-

The X-... knob might go away at any time, the others are likely to stay.

And, obviously, exposing this kind of knob with dedicated QEMU options is out of question.

Thanks
Laszlo

#17 lore raw

Hi,

Quoted 6 lines

Occasionally, yes.

- "opt/ovmf/PcdPropertiesTableEnable" controls whether the "properties

- "opt/ovmf/PcdSetNxForStack" controls whether the stack is made

Quoted 8 lines

- "opt/ovmf/X-PciMmio64Mb" controls the size of the range from which the

In downstream, we have two more (same purpose but separately for ARM and x86):
- opt/aavmf/PcdResizeXterm
- opt/ovmf/PcdResizeXterm

- Another flag I might expose later is "PcdHiiOsRuntimeSupport". This

I think we should probably move those out of the opt/ namespace space, as this is reserved for user-defined files.

I think either "etc/efi/" or "efi/" is useful (so we don't have different names on ovmf and aavmf). Possibly add "pcd/". Maybe even support setting *any* pcd via "efi/pcd/$name" (just an idea, not sure whenever that is useful and is possible without being too invasive).

Quoted 1 line

- "opt/ovmf/X-PciMmio64Mb" controls the size of the range from which

Hmm. Leave as-is for now I'd say. If we decide to keep it we should probably rename it and place it below etc/, next to reserved-memory-end. Export the size in bytes, like reserved-memory-end does. Add an option to qemu to set it, so you can specify the size as "32G" using the standard qemu size parser.

cheers,
Gerd

#18 lore raw
Quoted 15 lines · Gerd Hoffmann

Hi,

Quoted 13 lines

Occasionally, yes.

- "opt/ovmf/PcdPropertiesTableEnable" controls whether the "properties

- "opt/ovmf/PcdSetNxForStack" controls whether the stack is made

- "opt/ovmf/X-PciMmio64Mb" controls the size of the range from which the

In downstream, we have two more (same purpose but separately for ARM and x86):
- opt/aavmf/PcdResizeXterm
- opt/ovmf/PcdResizeXterm

Quoted 6 lines
Quoted 1 line

- Another flag I might expose later is "PcdHiiOsRuntimeSupport". This

I think we should probably move those out of the opt/ namespace space, as this is reserved for user-defined files.

I think either "etc/efi/"

This is more or less what Paolo suggests.

It confuses me.

I have now re-read the last section of "docs/specs/fw_cfg.txt" to make sure my current mental image of the original idea has not diverged from the actual original idea. I don't think so.

So, "user defined files" exist so that users can control "stuff" with them, without QEMU's knowledge. OVMF is "stuff". Just because it's firmware, it remains "stuff". Whatever Gabriel wants to control with such fw_cfg files in the guest, is also "stuff". I don't see any difference between a user controlling an ad-hoc application of his with "opt/blah1", and controlling OVMF behavior under "opt/ovmf/xizzy". If the user tries to control his own app by choosing the name "opt/ovmf/xizzy", that's *his* fault. "opt/ovmf/" is not a prefix someone comes up with by chance.

We meant just two partitions of the namespace. "opt/" and non-"opt/". The latter belongs to QEMU, the former belongs to everything else, and the subdivision of everything else doesn't belong into QEMU. OVMF is part of everything else.

If we're paranoid about it, we can make a recommendation that each user pick "opt/UUID/..." for himself, running "uuidgen" and then sticking with the output for his own stuff. That will guarantee that no conflicts will be seen. OVMF could be adapted to that as well. (The only snag with uuidgen is that it would leave only 56 - 4 - 36 - 1 == 15 characters for the actual knob name.)

Choosing "etc/" for such files of OVMF that are passed in with the -fw_cfg switch would be the textbook example of violating the original idea, because etc/ is heavily populated by QEMU itself.

Quoted 2 lines

or "efi/" is useful (so we don't have
different names on ovmf and aavmf).

I dislike efi/. It suggests that it controls some features that all UEFI implementations offer.

Quoted 3 lines

Possibly add "pcd/". Maybe even
support setting *any* pcd via "efi/pcd/$name" (just an idea, not sure whenever that is useful and is possible without being too invasive).

It's all of: too invasive, not always useful, and not flexible enough. Knobs should be exposed (with their different value domains) on a case-by-case basis.

Quoted 3 lines
Quoted 1 line

- "opt/ovmf/X-PciMmio64Mb" controls the size of the range from which

Hmm. Leave as-is for now I'd say.

Will do.

Quoted 5 lines

If we decide to keep it we should
probably rename it and place it below etc/, next to reserved-memory-end. Export the size in bytes, like reserved-memory-end does. Add an option to qemu to set it, so you can specify the size as "32G" using the standard qemu size parser.

I certainly don't disagree with this, but if it goes under etc/, and -- hence necessarily -- also gets its own command line option, then SeaBIOS should probably adhere to it as well (or the QEMU manual should state that this option is also firmware specific).

Thanks
Laszlo

#19 lore raw
Quoted 41 lines · Laszlo Ersek
Quoted 15 lines · Gerd Hoffmann

Hi,

Quoted 13 lines

Occasionally, yes.

- "opt/ovmf/PcdPropertiesTableEnable" controls whether the "properties

- "opt/ovmf/PcdSetNxForStack" controls whether the stack is made

- "opt/ovmf/X-PciMmio64Mb" controls the size of the range from which the

In downstream, we have two more (same purpose but separately for ARM and x86):
- opt/aavmf/PcdResizeXterm
- opt/ovmf/PcdResizeXterm

Quoted 6 lines
Quoted 1 line

- Another flag I might expose later is "PcdHiiOsRuntimeSupport". This

I think we should probably move those out of the opt/ namespace space, as this is reserved for user-defined files.

I think either "etc/efi/"

This is more or less what Paolo suggests.

It confuses me.

I have now re-read the last section of "docs/specs/fw_cfg.txt" to make sure my current mental image of the original idea has not diverged from the actual original idea. I don't think so.

So, "user defined files" exist so that users can control "stuff" with them, without QEMU's knowledge. OVMF is "stuff". Just because it's firmware, it remains "stuff". Whatever Gabriel wants to control with such fw_cfg files in the guest, is also "stuff". I don't see any difference between a user controlling an ad-hoc application of his with "opt/blah1", and controlling OVMF behavior under "opt/ovmf/xizzy". If the user tries to control his own app by choosing the name "opt/ovmf/xizzy", that's *his* fault. "opt/ovmf/" is not a prefix someone comes up with by chance.

Quoted 4 lines

We meant just two partitions of the namespace. "opt/" and non-"opt/". The latter belongs to QEMU, the former belongs to everything else, and the subdivision of everything else doesn't belong into QEMU. OVMF is part of everything else.

This is where we made a design mistake. There are 3 kinds of users adding entries: QEMU, QEMU firmware developers and QEMU users.

And QEMU users could be further subdivided.

Quoted 44 lines

If we're paranoid about it, we can make a recommendation that each user pick "opt/UUID/..." for himself, running "uuidgen" and then sticking with the output for his own stuff. That will guarantee that no conflicts will be seen. OVMF could be adapted to that as well. (The only snag with uuidgen is that it would leave only 56 - 4 - 36 - 1 == 15 characters for the actual knob name.)

Choosing "etc/" for such files of OVMF that are passed in with the -fw_cfg switch would be the textbook example of violating the original idea, because etc/ is heavily populated by QEMU itself.

Quoted 2 lines

or "efi/" is useful (so we don't have
different names on ovmf and aavmf).

I dislike efi/. It suggests that it controls some features that all UEFI implementations offer.

Quoted 3 lines

Possibly add "pcd/". Maybe even
support setting *any* pcd via "efi/pcd/$name" (just an idea, not sure whenever that is useful and is possible without being too invasive).

It's all of: too invasive, not always useful, and not flexible enough. Knobs should be exposed (with their different value domains) on a case-by-case basis.

Quoted 3 lines
Quoted 1 line

- "opt/ovmf/X-PciMmio64Mb" controls the size of the range from which

Hmm. Leave as-is for now I'd say.

Will do.

Quoted 5 lines

If we decide to keep it we should
probably rename it and place it below etc/, next to reserved-memory-end. Export the size in bytes, like reserved-memory-end does. Add an option to qemu to set it, so you can specify the size as "32G" using the standard qemu size parser.

I certainly don't disagree with this, but if it goes under etc/, and -- hence necessarily -- also gets its own command line option, then SeaBIOS should probably adhere to it as well (or the QEMU manual should state that this option is also firmware specific).

Thanks
Laszlo

#20 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines

We meant just two partitions of the namespace. "opt/" and non-"opt/". The latter belongs to QEMU, the former belongs to everything else, and the subdivision of everything else doesn't belong into QEMU. OVMF is part of everything else.

This is where we made a design mistake. There are 3 kinds of users adding entries: QEMU, QEMU firmware developers and QEMU users.

I can definitely agree with this.

Paolo

Quoted 1 line

And QEMU users could be further subdivided.

#21 lore raw
In reply to Laszlo Ersek

Hi,

Quoted 4 lines

So, "user defined files" exist so that users can control "stuff" with them, without QEMU's knowledge. OVMF is "stuff". Just because it's firmware, it remains "stuff". Whatever Gabriel wants to control with such fw_cfg files in the guest, is also "stuff".

Well, non-firmware stuff was my interpretation, i.e. user-specific stuff in both guest and host.

cheers,
Gerd

#22 lore raw
In reply to Laszlo Ersek
Quoted 2 lines · Laszlo Ersek

And, obviously, exposing this kind of knob with dedicated QEMU options is out of question.

We are moving away from dedicated options anyway.

But these could easily be machine properties, with the benefit that there is actual validation of values, some help and documentation for users, nice shortcuts like G/M/K for numbers, introspection, unit tests and more.

Signature · 1 line
MST
#23 lore raw
In reply to Gerd Hoffmann
Quoted 6 lines · Gerd Hoffmann

Hi,

Quoted 4 lines
Quoted 3 lines

Having a mis-use of this feature become "institutionalized" over time was seen as a low/negligible risk at the time. Do we have any new reasons to worry about it ?

Quoted 7 lines
Quoted 4 lines

OVMF uses this feature for a few flags. They are all called "opt/ovmf/...". I followed the advice in "docs/specs/fw_cfg.txt" (which shouldn't be surprising since I seem to have reviewed every patch for that file):

seabios has a few flags too, in etc/. Some of them are supported directly by qemu (such as setting the boot menu delay).

I forgot to confirm: clearly, when some flag already exists on which we can foist, kicking and screaming, a somewhat similar interpretation in OVMF, we do that without inventing a new flag. The boot menu delay is like this. Namely, if you set "-boot menu=on,splash-time=5000", you will get a progress bar for five seconds before auto-booting the otherwise relevant boot option.

The QEMU manual documents the -boot option as guest firmware-specific, and OVMF operates with that in mind -- support what it can, as closely it can.

Thanks
Laszlo

Quoted 14 lines

Others are not,
and I'd like to be able to use -fw_cfg for them for testing/debugging (any use cases beyond that should be supported by adding a less obscure way to set them to qemu, similar to the boot delay).

Oh, and that'll most likely be more seabios testing than qemu testing, so why require me build a special qemu version for that?

On the ovmf flags: What kind of flags are there? Anything a normal user might want to set?

cheers,
Gerd

#24 lore raw
In reply to Michael S. Tsirkin

Top level reply, because this isn't in reply to any specific message in the thread, more like in reply to all of them.

FW CFG's primary user is QEMU, which uses it to expose configuration information (in the widest sense) to Firmware. Thus the name FW CFG.

FW CFG can also be used by others for their own purposes. QEMU is merely acting as transport then.

I think there are actually three separate questions that should not be mixed up.

1. Is it a good idea to offer FW CFG as a transport to others?

I have no opinion on this myself, but I trust Gerd's and Laszlo's judgement. Their answer seems to be a clear yes.

2. Is it a good idea to let users mess with QEMU's use of FW CFG?

I think this is a special case of a more general question: should we try to protect the user from himself?

We should definitely try not to trap the user. Obvious usage should be as safe as we can make it. Risky usage should be marked in the docs and/or warn on use.

However, we should not try to stop our users from doing stupid things, as that would also stop them from doing clever things.

3. How should the FW CFG name space be shared among its users?

Bad things can happen if others use the namespace in ways that conflict with QEMU's use, or conflict with another "other".

This isn't an issue specific to FW CFG. For instance, upstream QEMU and the various downstream QEMUs all use the QMP command name space, and bad things can happen if they conflict. The difference is they'd conflict at compile time. Conflicts are easier to detect, but just as hard to resolve.

QMP's solution is to reserve part of the name space for "others" (downstreams), and subdivide the reserved part further via RFQDN:
owning a DNS domain name makes you own that RFQDN subdivision.

For FW CFG, we did only the first half, namely reserving part of the name space for others: /opt/. We neglected to spell out rules for its safe sharing, i.e. the second part.

I don't think it's too late to fix that: amend the specification to stipulate that owning a DNS domain name makes you own /opt/RFQDN/. Throw in known existing uses like /opt/ovmf/ as special cases.

#25 lore raw
Quoted 44 lines · Markus Armbruster

Top level reply, because this isn't in reply to any specific message in the thread, more like in reply to all of them.

FW CFG's primary user is QEMU, which uses it to expose configuration information (in the widest sense) to Firmware. Thus the name FW CFG.

FW CFG can also be used by others for their own purposes. QEMU is merely acting as transport then.

I think there are actually three separate questions that should not be mixed up.

1. Is it a good idea to offer FW CFG as a transport to others?

I have no opinion on this myself, but I trust Gerd's and Laszlo's judgement. Their answer seems to be a clear yes.

2. Is it a good idea to let users mess with QEMU's use of FW CFG?

I think this is a special case of a more general question: should we try to protect the user from himself?

We should definitely try not to trap the user. Obvious usage should be as safe as we can make it. Risky usage should be marked in the docs and/or warn on use.

However, we should not try to stop our users from doing stupid things, as that would also stop them from doing clever things.

3. How should the FW CFG name space be shared among its users?

Bad things can happen if others use the namespace in ways that conflict with QEMU's use, or conflict with another "other".

This isn't an issue specific to FW CFG. For instance, upstream QEMU and the various downstream QEMUs all use the QMP command name space, and bad things can happen if they conflict. The difference is they'd conflict at compile time. Conflicts are easier to detect, but just as hard to resolve.

QMP's solution is to reserve part of the name space for "others" (downstreams), and subdivide the reserved part further via RFQDN:
owning a DNS domain name makes you own that RFQDN subdivision.

Quoted 7 lines

For FW CFG, we did only the first half, namely reserving part of the name space for others: /opt/. We neglected to spell out rules for its safe sharing, i.e. the second part.

I don't think it's too late to fix that: amend the specification to stipulate that owning a DNS domain name makes you own /opt/RFQDN/. Throw in known existing uses like /opt/ovmf/ as special cases.

As usual, very well put.

This makes complete sense to me. I would rate the current interface rather as attempting to trap users. The only way to figure it out is to read the source, and the source includes ovmf and maybe other firmware. Here is a proposal trying to address the above, including a way to do stupid things:

QEMU command line:
A. -fw-cfg RFQDN/PATH prepends usr/. So users will not get conflicts
with QEMU hardware

B. -fw-cfg org.qemu/unsupported/XXX as a hack, removes
org.qemu/unsupported/ and leaves just XXX, for people who want to break^?^?^?^?^?debug QEMU hardware

C. -fw-cfg opt/FOO accepts any path, for backwards compatibility

D. any other use fails

QEMU Documentation
Document the above in the man page

OVMF:
Can use the compatible opt/ovmf/ for now.

Long term: take one of two paths:

A. Move part of values passed to OVMF into QEMU codebase

If it's commonly needed for guests to boot, we should provide sane defaults and a friendly interface, with
range checking etc.

or

B. Gradually transition OVMF to look up paths in usr/org.uefi/: if nothing is found there, look up in opt/ovmf/ for backwards compatibility.

This makes sense if the feature is esoteric and very rarely used.

Signature · 1 line
MST
#26 lore raw

I frankly think it's overengineered, but it's already much better and if it helps converging to a compromise why not.

Alternatives to your proposals follow:

Quoted 4 lines · Michael S. Tsirkin

QEMU command line:
A. -fw-cfg RFQDN/PATH prepends usr/. So users will not get conflicts
with QEMU hardware

Alternative: no need to prepend usr/, I think.

Quoted 3 lines

B. -fw-cfg org.qemu/unsupported/XXX as a hack, removes
org.qemu/unsupported/ and leaves just XXX, for people who want to break^?^?^?^?^?debug QEMU hardware

Alternative: fail on:

- a blacklist of etc/* files including etc/system-states, etc/smbios/smbios-tables, etc/smbios/smbios-anchor, etc/reserved-memory-end, etc/pvpanic-port, etc/e820, and possibly etc/boot-menu-wait

- on all org.qemu/* files

- iff etc/boot-menu-wait is blacklisted, fail on
org.seabios/boot-menu-wait too.

Everything else is passed through. No hacks required.

Quoted 1 line

C. -fw-cfg opt/FOO accepts any path, for backwards compatibility

Implicit in my proposed alternative to A.

Quoted 1 line

D. any other use fails

Replaced by my alternative to B. RFQDN is just a best practice, and it is not enforced except as proposed in B. For the same reason, no changes are required in the Linux driver.

Quoted 5 lines

OVMF:
Can use the compatible opt/ovmf/ for now. [snip]
Long term: Gradually transition OVMF to look up paths in usr/org.uefi/:
if nothing is found there, look up in opt/ovmf/ for backwards compatibility.

Agreed except it would be org.tianocore.edk2.ovmf/ rather than usr/org.uefi.

Likewise SeaBIOS would switch from etc/ to an org.seabios/ prefix (for stuff usable from both Coreboot and QEMU, e.g. org.seabios/bootsplash.bmp) or org.qemu/ (for stuff that is specific to QEMU).

Files that could be moved from etc/ to org.qemu/ correspond to the ones that are blacklisted in (B), e.g. etc/system-states -> org.qemu/system-states.

Paolo

#27 lore raw
Quoted 8 lines · Paolo Bonzini
Quoted 5 lines · Michael S. Tsirkin

OVMF:
Can use the compatible opt/ovmf/ for now. [snip]
Long term: Gradually transition OVMF to look up paths in usr/org.uefi/:
if nothing is found there, look up in opt/ovmf/ for backwards compatibility.

Quoted 6 lines

Agreed except it would be org.tianocore.edk2.ovmf/ rather than usr/org.uefi.

Likewise SeaBIOS would switch from etc/ to an org.seabios/ prefix (for stuff usable from both Coreboot and QEMU, e.g. org.seabios/bootsplash.bmp) or org.qemu/ (for stuff that is specific to QEMU).

I think it's feasible (in the long term) to make OVMF look for "standard" fw_cfg files under "org.qemu/", and for the OVMF-specific knobs under "org.tianocore.edk2.ovmf/". (The longest knob name OVMF uses at the moment is 24 chars; it would fit.)

It's just that I don't see how a user is any more likely to randomly pick "opt/ovmf/" for his own ad-hoc purposes than to pick "org.tianocore.edk2.ovmf/".

Anyway, I agree that RFQDNs leave a few characters for the actual knob names, and they are mostly unique.

Thanks
Laszlo

#28 lore raw
In reply to Paolo Bonzini
Quoted 2 lines · Paolo Bonzini

I frankly think it's overengineered, but it's already much better and if it helps converging to a compromise why not.

Thanks, I'll think of your suggestions over the weekend. We might be able to simplify things a bit.

Quoted 1 line

Alternatives to your proposals follow:

I wonder what are the advantages of the alternative though? It is certainly more code, the rules for users are more complex to figure out and need more effort for user to follow.

Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines

QEMU command line:
A. -fw-cfg RFQDN/PATH prepends usr/. So users will not get conflicts
with QEMU hardware

Alternative: no need to prepend usr/, I think.

I personally dislike telling user "do X". I don't see a reason not to be friendly and do X. The rare case where users do not want X can be easily enabled.

Quoted 10 lines
Quoted 3 lines

B. -fw-cfg org.qemu/unsupported/XXX as a hack, removes
org.qemu/unsupported/ and leaves just XXX, for people who want to break^?^?^?^?^?debug QEMU hardware

Alternative: fail on:

- a blacklist of etc/* files including etc/system-states, etc/smbios/smbios-tables, etc/smbios/smbios-anchor, etc/reserved-memory-end, etc/pvpanic-port, etc/e820, and possibly etc/boot-menu-wait

We can not predict the future. Future firmware will look for files under etc/mst. Users using this firmware with current QEMU will get a nasty surprise where it previously worked.

Besides, it is way easier to maintain and understand a simple rule than a blacklist.

Quoted 30 lines

- on all org.qemu/* files

- iff etc/boot-menu-wait is blacklisted, fail on
org.seabios/boot-menu-wait too.

Everything else is passed through. No hacks required.

Quoted 1 line

C. -fw-cfg opt/FOO accepts any path, for backwards compatibility

Implicit in my proposed alternative to A.

Quoted 1 line

D. any other use fails

Replaced by my alternative to B. RFQDN is just a best practice, and it is not enforced except as proposed in B. For the same reason, no changes are required in the Linux driver.

Quoted 5 lines

OVMF:
Can use the compatible opt/ovmf/ for now. [snip]
Long term: Gradually transition OVMF to look up paths in usr/org.uefi/:
if nothing is found there, look up in opt/ovmf/ for backwards compatibility.

Agreed except it would be org.tianocore.edk2.ovmf/ rather than usr/org.uefi.

Likewise SeaBIOS would switch from etc/ to an org.seabios/ prefix (for stuff usable from both Coreboot and QEMU, e.g. org.seabios/bootsplash.bmp) or org.qemu/ (for stuff that is specific to QEMU).

Quoted 5 lines

Files that could be moved from etc/ to org.qemu/ correspond to the ones that are blacklisted in (B), e.g. etc/system-states -> org.qemu/system-states.

Paolo

I am not sure about moving things into usr/org.qemu. These are system files, not user-provided ones. But we can argue about future plans down the road.

Signature · 1 line
MST
#29 lore raw
Quoted 11 lines · Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines

QEMU command line:
A. -fw-cfg RFQDN/PATH prepends usr/. So users will not get conflicts
with QEMU hardware

Alternative: no need to prepend usr/, I think.

I personally dislike telling user "do X". I don't see a reason not to be friendly and do X. The rare case where users do not want X can be easily enabled.

I wouldn't include usr/ at all in the paths. The RFQDN recommendation is enough to avoid clashes with etc/ and opt/.

Quoted 11 lines
Quoted 10 lines
Quoted 3 lines

B. -fw-cfg org.qemu/unsupported/XXX as a hack, removes
org.qemu/unsupported/ and leaves just XXX, for people who want to break^?^?^?^?^?debug QEMU hardware

Alternative: fail on:

- a blacklist of etc/* files including etc/system-states, etc/smbios/smbios-tables, etc/smbios/smbios-anchor, etc/reserved-memory-end, etc/pvpanic-port, etc/e820, and possibly etc/boot-menu-wait

Quoted 7 lines

We can not predict the future. Future firmware will look for files under etc/mst. Users using this firmware with current QEMU will get a nasty surprise where it previously worked.

Besides, it is way easier to maintain and understand a simple rule than a blacklist.

The reason for the blacklist is that these are files owned by QEMU but traditionally under etc/. The error can be simply "fw_cfg file %s is provided by QEMU". If a file is added in the future that is owned by QEMU, it will be under org.qemu/* so the blacklist will not grow.

Quoted 5 lines
Quoted 5 lines

Likewise SeaBIOS would switch from etc/ to an org.seabios/ prefix (for stuff usable from both Coreboot and QEMU, e.g. org.seabios/bootsplash.bmp) or org.qemu/ (for stuff that is specific to QEMU).

Quoted 7 lines
Quoted 3 lines

Files that could be moved from etc/ to org.qemu/ correspond to the ones that are blacklisted in (B), e.g. etc/system-states -> org.qemu/system-states.

I am not sure about moving things into usr/org.qemu. These are system files, not user-provided ones. But we can argue about future plans down the road.

Does it make more sense if it's just org.qemu, not usr/org.qemu?

Thanks,

Paolo

#30 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines · Michael S. Tsirkin
Quoted 6 lines · Michael S. Tsirkin
Quoted 4 lines

QEMU command line:
A. -fw-cfg RFQDN/PATH prepends usr/. So users will not get conflicts
with QEMU hardware

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Alternative: no need to prepend usr/, I think.

I personally dislike telling user "do X". I don't see a reason not to be friendly and do X. The rare case where users do not want X can be easily enabled.

I wouldn't include usr/ at all in the paths. The RFQDN recommendation is enough to avoid clashes with etc/ and opt/.

Yes but then we need a blacklist. And usr/ is not visible to users so I do not see a problem with it.

Quoted 16 lines
Quoted 16 lines
Quoted 10 lines
Quoted 3 lines

B. -fw-cfg org.qemu/unsupported/XXX as a hack, removes
org.qemu/unsupported/ and leaves just XXX, for people who want to break^?^?^?^?^?debug QEMU hardware

Alternative: fail on:

- a blacklist of etc/* files including etc/system-states, etc/smbios/smbios-tables, etc/smbios/smbios-anchor, etc/reserved-memory-end, etc/pvpanic-port, etc/e820, and possibly etc/boot-menu-wait

We can not predict the future. Future firmware will look for files under etc/mst. Users using this firmware with current QEMU will get a nasty surprise where it previously worked.

Quoted 7 lines
Quoted 2 lines

Besides, it is way easier to maintain and understand a simple rule than a blacklist.

The reason for the blacklist is that these are files owned by QEMU but traditionally under etc/. The error can be simply "fw_cfg file %s is provided by QEMU". If a file is added in the future that is owned by QEMU, it will be under org.qemu/* so the blacklist will not grow.

Yes, but a new prefix seems like a cleaner way.

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines

Likewise SeaBIOS would switch from etc/ to an org.seabios/ prefix (for stuff usable from both Coreboot and QEMU, e.g. org.seabios/bootsplash.bmp) or org.qemu/ (for stuff that is specific to QEMU).

Quoted 7 lines
Quoted 3 lines

Files that could be moved from etc/ to org.qemu/ correspond to the ones that are blacklisted in (B), e.g. etc/system-states -> org.qemu/system-states.

I am not sure about moving things into usr/org.qemu. These are system files, not user-provided ones. But we can argue about future plans down the road.

Quoted 5 lines

Does it make more sense if it's just org.qemu, not usr/org.qemu?

Thanks,

Paolo

I am not sure, let's discuss after 2.6.

Signature · 1 line
MST
#31 lore raw
Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines

QEMU command line:
A. -fw-cfg RFQDN/PATH prepends usr/. So users will not get conflicts
with QEMU hardware

Alternative: no need to prepend usr/, I think.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I personally dislike telling user "do X". I don't see a reason not to be friendly and do X. The rare case where users do not want X can be easily enabled.

I wouldn't include usr/ at all in the paths. The RFQDN recommendation is enough to avoid clashes with etc/ and opt/.

Yes but then we need a blacklist.

Can't the blacklist be as simple as "org.qemu/*", plus some handling of legacy "etc/*"?

We'd need special handling of "etc/*" anyway because SeaBIOS is using it (Gerd's usecase) and you certainly don't want to use org.qemu/unsupported/etc/XYZ hacks for that.

Paolo

#32 lore raw
Quoted 24 lines · Paolo Bonzini
Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Michael S. Tsirkin
Quoted 7 lines · Michael S. Tsirkin
Quoted 4 lines

QEMU command line:
A. -fw-cfg RFQDN/PATH prepends usr/. So users will not get conflicts
with QEMU hardware

Alternative: no need to prepend usr/, I think.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I personally dislike telling user "do X". I don't see a reason not to be friendly and do X. The rare case where users do not want X can be easily enabled.

I wouldn't include usr/ at all in the paths. The RFQDN recommendation is enough to avoid clashes with etc/ and opt/.

Yes but then we need a blacklist.

Quoted 8 lines

Can't the blacklist be as simple as "org.qemu/*", plus some handling of legacy "etc/*"?

We'd need special handling of "etc/*" anyway because SeaBIOS is using it (Gerd's usecase) and you certainly don't want to use org.qemu/unsupported/etc/XYZ hacks for that.

Paolo

I would prefer a white-list, but I have an idea: look for "." in the name. If not there, it's not an RFQDN.

Signature · 1 line
MST
#33 lore raw
In reply to Paolo Bonzini

Hi,

Quoted 6 lines

Alternative: fail on:

- a blacklist of etc/* files including etc/system-states, etc/smbios/smbios-tables, etc/smbios/smbios-anchor, etc/reserved-memory-end, etc/pvpanic-port, etc/e820, and possibly etc/boot-menu-wait

I think that fails already because qemu throws an error on duplicate firmware entries.

Quoted 4 lines

Likewise SeaBIOS would switch from etc/ to an org.seabios/ prefix (for stuff usable from both Coreboot and QEMU, e.g. org.seabios/bootsplash.bmp) or org.qemu/ (for stuff that is specific to QEMU).

Do we really want shuffle around stuff like this? It means we have to support both paths in both firmware and qemu for a quite a while for compatibility reasons.

(moving around opt/ovmf/ has this issue too, even though to a lesser
extend as there isn't stuff as critical as acpi tables or boot order).

Also note that most stuff in etc/ is used by all firmwares, so moving this to org.seabios looks pointless to me, especially as things might change over time (i.e. ovmf starting to use cfg options it used to ignore first, which is the case for etc/boot-menu-wait IIRC, so it started as seabios only but isn't any more).

Also note that the fw_cfg layout is modeled a bit after cbfs (coreboot filesystem) which is provided by coreboot and used by seabios. That'll cause trouble too if we try to redefine the paths.

cheers,
Gerd

#34 lore raw
Quoted 11 lines · Gerd Hoffmann

Hi,

Quoted 6 lines

Alternative: fail on:

- a blacklist of etc/* files including etc/system-states, etc/smbios/smbios-tables, etc/smbios/smbios-anchor, etc/reserved-memory-end, etc/pvpanic-port, etc/e820, and possibly etc/boot-menu-wait

I think that fails already because qemu throws an error on duplicate firmware entries.

The problem is that some files are only added conditionally (e.g. etc/boot-menu-wait).

Quoted 9 lines

Do we really want shuffle around stuff like this? It means we have to support both paths in both firmware and qemu for a quite a while for compatibility reasons.

Also note that most stuff in etc/ is used by all firmwares, so moving this to org.seabios looks pointless to me, especially as things might change over time (i.e. ovmf starting to use cfg options it used to ignore first, which is the case for etc/boot-menu-wait IIRC, so it started as seabios only but isn't any more).

Stuff that is used by all firmwares could move to org.coreboot/ or org.qemu/, but keeping etc/ as a special case is certainly fine by me.

Paolo

#35 lore raw
Quoted 12 lines · Paolo Bonzini
Quoted 9 lines · Gerd Hoffmann

Hi,

Quoted 6 lines

Alternative: fail on:

- a blacklist of etc/* files including etc/system-states, etc/smbios/smbios-tables, etc/smbios/smbios-anchor, etc/reserved-memory-end, etc/pvpanic-port, etc/e820, and possibly etc/boot-menu-wait

Quoted 5 lines
Quoted 2 lines

I think that fails already because qemu throws an error on duplicate firmware entries.

The problem is that some files are only added conditionally (e.g. etc/boot-menu-wait).

Another problem is that future firmware can run on an older QEMU. Any blacklist-only strategy fails because of that, we need a schema.

Quoted 14 lines
Quoted 9 lines

Do we really want shuffle around stuff like this? It means we have to support both paths in both firmware and qemu for a quite a while for compatibility reasons.

Also note that most stuff in etc/ is used by all firmwares, so moving this to org.seabios looks pointless to me, especially as things might change over time (i.e. ovmf starting to use cfg options it used to ignore first, which is the case for etc/boot-menu-wait IIRC, so it started as seabios only but isn't any more).

Stuff that is used by all firmwares could move to org.coreboot/ or org.qemu/, but keeping etc/ as a special case is certainly fine by me.

Paolo