revert RNG seed mess
cover revert RNG seed mess
All attempts to fix up passing RNG seed via setup_data entry failed. Let's just rip out all of it. We'll start over.
Warning: all I did was git revert the relevant patches and resolve the (trivial) conflicts. Not even compiled - it's almost midnight here.
Jason this is the kind of approach I'd like to see, not yet another pointer math rich patch I need to spend time reviewing. Just get us back to where we started. We can redo "x86: use typedef for SetupData struct" later if we want, it's benign.
Could you do something like this pls?
Or test and ack if this patchset happens to work by luck.
Michael S. Tsirkin (7):
Revert "x86: don't let decompressed kernel image clobber setup_data" Revert "x86: do not re-randomize RNG seed on snapshot load" Revert "x86: re-initialize RNG seed when selecting kernel" Revert "x86: reinitialize RNG seed on system reboot" Revert "x86: use typedef for SetupData struct"
Revert "x86: return modified setup_data only if read as memory, not as
file"
Revert "hw/i386: pass RNG seed via setup_data entry"
include/hw/i386/microvm.h | 5 +- include/hw/i386/pc.h | 3 - include/hw/i386/x86.h | 3 +- include/hw/nvram/fw_cfg.h | 31 ---------- hw/i386/microvm.c | 17 ++---- hw/i386/pc.c | 4 +- hw/i386/pc_piix.c | 2 - hw/i386/pc_q35.c | 2 - hw/i386/x86.c | 122 ++++++++++---------------------------- hw/nvram/fw_cfg.c | 21 ++----- 10 files changed, 49 insertions(+), 161 deletions(-)
Signature · 1 line
MST
RFC PATCH 1/7 Revert "x86: don't let decompressed kernel image clobber setup_data"
This reverts commit eac7a7791bb6d719233deed750034042318ffd56.
--- include/hw/i386/microvm.h | 5 ++-- include/hw/nvram/fw_cfg.h | 9 ------- hw/i386/microvm.c | 15 ++++------- hw/i386/x86.c | 52 ++++++++++++++++++--------------------- hw/nvram/fw_cfg.c | 9 ------- 5 files changed, 31 insertions(+), 59 deletions(-)
include/hw/i386/microvm.h +2 -3
@@ -50,9 +50,8 @@*/ /* Platform virtio definitions */ -#define VIRTIO_MMIO_BASE 0xfeb00000 -#define VIRTIO_CMDLINE_MAXLEN 64 -#define VIRTIO_CMDLINE_TOTAL_MAX_LEN ((VIRTIO_CMDLINE_MAXLEN + 1) * 16) +#define VIRTIO_MMIO_BASE 0xfeb00000 +#define VIRTIO_CMDLINE_MAXLEN 64#define GED_MMIO_BASE 0xfea00000#define GED_MMIO_BASE_MEMHP (GED_MMIO_BASE + 0x100)
include/hw/nvram/fw_cfg.h +0 -9
@@ -139,15 +139,6 @@ void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key, void *data, size_t len, bool read_only); -/** -* fw_cfg_read_bytes_ptr: -* @s: fw_cfg device being modified -* @key: selector key value for new fw_cfg item -* -* Reads an existing fw_cfg data pointer. -*/ -void *fw_cfg_read_bytes_ptr (FWCfgState *s,uint16_t key); -/** * fw_cfg_add_string: * @s: fw_cfg device being modified
hw/i386/microvm.c +5 -10
@@ -378,8 +378,7 @@ static void microvm_fix_kernel_cmdline(MachineState *machine)MicrovmMachineState *mms =MICROVM_MACHINE (machine);BusState *bus;BusChild *kid; -char *cmdline, *existing_cmdline; -size_t len; +char *cmdline;/* * Find MMIO transports with attached devices, and add them to the kernel
@@ -388,8 +387,7 @@ static void microvm_fix_kernel_cmdline(MachineState *machine)* Yes, this is a hack, but one that heavily improves the UX without * introducing any significant issues. */ - existing_cmdline =fw_cfg_read_bytes_ptr (x86ms->fw_cfg,FW_CFG_CMDLINE_DATA ); - cmdline =g_strdup (existing_cmdline); + cmdline =g_strdup (machine->kernel_cmdline); bus =sysbus_get_default (); QTAILQ_FOREACH(kid, &bus->children, sibling) {DeviceState *dev = kid->child;
@@ -413,12 +411,9 @@ static void microvm_fix_kernel_cmdline(MachineState *machine) } } - len =strlen (cmdline); -if (len >VIRTIO_CMDLINE_TOTAL_MAX_LEN +strlen (existing_cmdline)) { -fprintf (stderr,"qemu: virtio mmio cmdline too large, skipping\n" ); - }else { -memcpy (existing_cmdline, cmdline, len +1 ); - } +fw_cfg_modify_i32 (x86ms->fw_cfg,FW_CFG_CMDLINE_SIZE ,strlen (cmdline) +1 ); +fw_cfg_modify_string (x86ms->fw_cfg,FW_CFG_CMDLINE_DATA , cmdline); +g_free (cmdline); }
hw/i386/x86.c +24 -28
98 lines not on this page · raw message
hw/nvram/fw_cfg.c +0 -9
@@ -741,15 +741,6 @@ void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len)fw_cfg_add_bytes_callback (s, key,NULL ,NULL ,NULL , data, len, true); } -void *fw_cfg_read_bytes_ptr (FWCfgState *s,uint16_t key) -{ -int arch = !!(key &FW_CFG_ARCH_LOCAL ); - - key &=FW_CFG_ENTRY_MASK ; -assert (key <fw_cfg_max_entry (s)); -return s->entries[arch][key].data; -} -void fw_cfg_add_string (FWCfgState *s,uint16_t key,const char *value) {size_t sz =strlen (value) +1 ;
Signature · 1 line
MST
Re: [PATCH RFC 1/7] Revert "x86: don't let decompressed kernel image clobber setup_data"
Quoted 11 lines · Michael S. Tsirkin
This reverts commit
eac7a7791bb6d719233deed750034042318ffd56.Fixes eac7a7791b ("x86: don't let decompressed kernel image clobber setup_data")Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/i386/microvm.h | 5 ++-- include/hw/nvram/fw_cfg.h | 9 ------- hw/i386/microvm.c | 15 ++++------- hw/i386/x86.c | 52 ++++++++++++++++++--------------------- hw/nvram/fw_cfg.c | 9 ------- 5 files changed, 31 insertions(+), 59 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
RFC PATCH 2/7 Revert "x86: do not re-randomize RNG seed on snapshot load"
In reply to Michael S. TsirkinThis reverts commit 14b29fea742034186403914b4d013d0e83f19e78.
--- hw/i386/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/x86.c +1 -1
@@ -1115,7 +1115,7 @@ void x86_load_linux(X86MachineState *x86ms, setup_data->type =cpu_to_le32 (SETUP_RNG_SEED ); setup_data->len =cpu_to_le32 (RNG_SEED_LENGTH );qemu_guest_getrandom_nofail (setup_data->data,RNG_SEED_LENGTH ); -qemu_register_reset_nosnapshotload (reset_rng_seed, setup_data); +qemu_register_reset (reset_rng_seed, setup_data);fw_cfg_add_bytes_callback (fw_cfg,FW_CFG_KERNEL_DATA , reset_rng_seed,NULL , setup_data, kernel, kernel_size, true); }else {
Signature · 1 line
MST
Re: [PATCH RFC 2/7] Revert "x86: do not re-randomize RNG seed on snapshot load"
Quoted 7 lines · Michael S. Tsirkin
This reverts commit
14b29fea742034186403914b4d013d0e83f19e78.Signed-off-by Michael S. Tsirkin <[email protected]>Fixes 14b29fea74 ("x86: do not re-randomize RNG seed on snapshot load")--- hw/i386/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
RFC PATCH 3/7 Revert "x86: re-initialize RNG seed when selecting kernel"
In reply to Michael S. TsirkinThis reverts commit cc63374a5a7c240b7d3be734ef589dabbefc7527.
--- hw/i386/x86.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
hw/i386/x86.c +1 -4
@@ -1116,14 +1116,11 @@ void x86_load_linux(X86MachineState *x86ms, setup_data->len =cpu_to_le32 (RNG_SEED_LENGTH );qemu_guest_getrandom_nofail (setup_data->data,RNG_SEED_LENGTH );qemu_register_reset (reset_rng_seed, setup_data); -fw_cfg_add_bytes_callback (fw_cfg,FW_CFG_KERNEL_DATA , reset_rng_seed,NULL , - setup_data, kernel, kernel_size, true); - }else { -fw_cfg_add_bytes (fw_cfg,FW_CFG_KERNEL_DATA , kernel, kernel_size); }fw_cfg_add_i32 (fw_cfg,FW_CFG_KERNEL_ADDR , prot_addr);fw_cfg_add_i32 (fw_cfg,FW_CFG_KERNEL_SIZE , kernel_size); +fw_cfg_add_bytes (fw_cfg,FW_CFG_KERNEL_DATA , kernel, kernel_size); sev_load_ctx.kernel_data = (char *)kernel; sev_load_ctx.kernel_size = kernel_size;
Signature · 1 line
MST
Re: [PATCH RFC 3/7] Revert "x86: re-initialize RNG seed when selecting kernel"
Quoted 7 lines · Michael S. Tsirkin
This reverts commit
cc63374a5a7c240b7d3be734ef589dabbefc7527.Fixes cc63374a5a ("x86: re-initialize RNG seed when selecting kernel")Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/i386/x86.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
RFC PATCH 4/7 Revert "x86: reinitialize RNG seed on system reboot"
In reply to Michael S. TsirkinThis reverts commit 763a2828bf313ed55878b09759dc435355035f2e.
--- hw/i386/x86.c | 7 ------- 1 file changed, 7 deletions(-)
hw/i386/x86.c +0 -7
@@ -787,12 +787,6 @@ static void reset_setup_data(void *opaque)stq_p (fixup->pos, fixup->orig_val); } -static void reset_rng_seed (void *opaque) -{ -SetupData *setup_data = opaque; -qemu_guest_getrandom_nofail (setup_data->data,le32_to_cpu (setup_data->len)); -} - void x86_load_linux(X86MachineState *x86ms, FWCfgState *fw_cfg, int acpi_data_size,
@@ -1115,7 +1109,6 @@ void x86_load_linux(X86MachineState *x86ms, setup_data->type =cpu_to_le32 (SETUP_RNG_SEED ); setup_data->len =cpu_to_le32 (RNG_SEED_LENGTH );qemu_guest_getrandom_nofail (setup_data->data,RNG_SEED_LENGTH ); -qemu_register_reset (reset_rng_seed, setup_data); }fw_cfg_add_i32 (fw_cfg,FW_CFG_KERNEL_ADDR , prot_addr);
Signature · 1 line
MST
Re: [PATCH RFC 4/7] Revert "x86: reinitialize RNG seed on system reboot"
Quoted 7 lines · Michael S. Tsirkin
This reverts commit
763a2828bf313ed55878b09759dc435355035f2e.Fixes 763a2828bf ("x86: reinitialize RNG seed on system reboot")Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/i386/x86.c | 7 ------- 1 file changed, 7 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
RFC PATCH 5/7 Revert "x86: use typedef for SetupData struct"
In reply to Michael S. TsirkinThis reverts commit eebb38a5633a77f5fa79d6486d5b2fcf8fbe3c07.
--- hw/i386/x86.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
hw/i386/x86.c +7 -7
@@ -657,12 +657,12 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)return dev; } -typedef struct SetupData { +struct setup_data {uint64_t next;uint32_t type;uint32_t len;uint8_t data[]; -} __attribute__((packed))SetupData ; +} __attribute__((packed));/*
@@ -803,7 +803,7 @@ void x86_load_linux(X86MachineState *x86ms,FILE *f;char *vmode;MachineState *machine =MACHINE (x86ms); -SetupData *setup_data; +struct setup_data *setup_data;const char *kernel_filename = machine->kernel_filename;const char *initrd_filename = machine->initrd_filename;const char *dtb_filename = machine->dtb;
@@ -1086,11 +1086,11 @@ void x86_load_linux(X86MachineState *x86ms, } setup_data_offset =QEMU_ALIGN_UP (kernel_size,16 ); - kernel_size = setup_data_offset +sizeof (SetupData) + dtb_size; + kernel_size = setup_data_offset +sizeof (struct setup_data ) + dtb_size; kernel =g_realloc (kernel, kernel_size); - setup_data = (SetupData *)(kernel + setup_data_offset); + setup_data = (struct setup_data *)(kernel + setup_data_offset); setup_data->next =cpu_to_le64 (first_setup_data); first_setup_data = prot_addr + setup_data_offset; setup_data->type =cpu_to_le32 (SETUP_DTB );
@@ -1101,9 +1101,9 @@ void x86_load_linux(X86MachineState *x86ms,if (!legacy_no_rng_seed) { setup_data_offset =QEMU_ALIGN_UP (kernel_size,16 ); - kernel_size = setup_data_offset +sizeof (SetupData) +RNG_SEED_LENGTH ; + kernel_size = setup_data_offset +sizeof (struct setup_data ) +RNG_SEED_LENGTH ; kernel =g_realloc (kernel, kernel_size); - setup_data = (SetupData *)(kernel + setup_data_offset); + setup_data = (struct setup_data *)(kernel + setup_data_offset); setup_data->next =cpu_to_le64 (first_setup_data); first_setup_data = prot_addr + setup_data_offset; setup_data->type =cpu_to_le32 (SETUP_RNG_SEED );
Signature · 1 line
MST
Re: [PATCH RFC 5/7] Revert "x86: use typedef for SetupData struct"
Quoted 4 lines · Michael S. Tsirkin
This reverts commit
eebb38a5633a77f5fa79d6486d5b2fcf8fbe3c07.Fixes eebb38a563 ("x86: use typedef for SetupData struct")Signed-off-by Michael S. Tsirkin <[email protected]>
This one was actually good, I reverted so other reverts are clean. Jason I would appreciate it if you can rebase this on top of the revert.
Quoted 61 lines
--- hw/i386/x86.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)hw/i386/x86.c +7
-7@@ -657,12 +657,12 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)return dev; } -typedef struct SetupData { +struct setup_data {uint64_t next;uint32_t type;uint32_t len;uint8_t data[]; -} __attribute__((packed))SetupData ; +} __attribute__((packed));/* @@ -803,7 +803,7 @@ void x86_load_linux(X86MachineState *x86ms,FILE *f;char *vmode;MachineState *machine =MACHINE (x86ms); -SetupData *setup_data; +struct setup_data *setup_data;const char *kernel_filename = machine->kernel_filename;const char *initrd_filename = machine->initrd_filename;const char *dtb_filename = machine->dtb;@@ -1086,11 +1086,11 @@ void x86_load_linux(X86MachineState *x86ms, } setup_data_offset =QEMU_ALIGN_UP (kernel_size,16 ); - kernel_size = setup_data_offset +sizeof (SetupData) + dtb_size; + kernel_size = setup_data_offset +sizeof (struct setup_data ) + dtb_size; kernel =g_realloc (kernel, kernel_size); - setup_data = (SetupData *)(kernel + setup_data_offset); + setup_data = (struct setup_data *)(kernel + setup_data_offset); setup_data->next =cpu_to_le64 (first_setup_data); first_setup_data = prot_addr + setup_data_offset; setup_data->type =cpu_to_le32 (SETUP_DTB );@@ -1101,9 +1101,9 @@ void x86_load_linux(X86MachineState *x86ms,if (!legacy_no_rng_seed) { setup_data_offset =QEMU_ALIGN_UP (kernel_size,16 ); - kernel_size = setup_data_offset +sizeof (SetupData) +RNG_SEED_LENGTH ; + kernel_size = setup_data_offset +sizeof (struct setup_data ) +RNG_SEED_LENGTH ; kernel =g_realloc (kernel, kernel_size); - setup_data = (SetupData *)(kernel + setup_data_offset); + setup_data = (struct setup_data *)(kernel + setup_data_offset); setup_data->next =cpu_to_le64 (first_setup_data); first_setup_data = prot_addr + setup_data_offset; setup_data->type =cpu_to_le32 (SETUP_RNG_SEED );Signature · 1 line
MST
Re: [PATCH RFC 5/7] Revert "x86: use typedef for SetupData struct"
In reply to Michael S. TsirkinQuoted 7 lines · Michael S. Tsirkin
This reverts commit
eebb38a5633a77f5fa79d6486d5b2fcf8fbe3c07.Fixes eebb38a563 ("x86: use typedef for SetupData struct")Signed-off-by Michael S. Tsirkin <[email protected]>--- hw/i386/x86.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
RFC PATCH 6/7 Revert "x86: return modified setup_data only if read as memory, not as file"
In reply to Michael S. TsirkinThis reverts commit e935b735085dfa61d8e6d276b6f9e7687796a3c7.
--- include/hw/nvram/fw_cfg.h | 22 ------------------- hw/i386/x86.c | 46 +++++++++------------------------------ hw/nvram/fw_cfg.c | 12 +++++----- 3 files changed, 16 insertions(+), 64 deletions(-)
include/hw/nvram/fw_cfg.h +0 -22
@@ -117,28 +117,6 @@ struct FWCfgMemState {*/ void fw_cfg_add_bytes (FWCfgState *s,uint16_t key,void *data,size_t len); -/** -* fw_cfg_add_bytes_callback: -* @s: fw_cfg device being modified -* @key: selector key value for new fw_cfg item -* @select_cb: callback function when selecting -* @write_cb: callback function after a write -* @callback_opaque: argument to be passed into callback function -* @data: pointer to start of item data -* @len: size of item data -* @read_only: is file read only -* -* Add a new fw_cfg item, available by selecting the given key, as a raw -* "blob" of the given size. The data referenced by the starting pointer -* is only linked, NOT copied, into the data structure of the fw_cfg device. -*/ -void fw_cfg_add_bytes_callback (FWCfgState *s,uint16_t key, -FWCfgCallback select_cb, -FWCfgWriteCallback write_cb, -void *callback_opaque, -void *data,size_t len, -bool read_only); -/** * fw_cfg_add_string: * @s: fw_cfg device being modified
hw/i386/x86.c +10 -36
72 lines not on this page · raw message
hw/nvram/fw_cfg.c +6 -6
@@ -693,12 +693,12 @@ static const VMStateDescription vmstate_fw_cfg = { } }; -void fw_cfg_add_bytes_callback (FWCfgState *s,uint16_t key, -FWCfgCallback select_cb, -FWCfgWriteCallback write_cb, -void *callback_opaque, -void *data,size_t len, -bool read_only) +static void fw_cfg_add_bytes_callback (FWCfgState *s,uint16_t key, +FWCfgCallback select_cb, +FWCfgWriteCallback write_cb, +void *callback_opaque, +void *data,size_t len, +bool read_only) {int arch = !!(key &FW_CFG_ARCH_LOCAL );
Signature · 1 line
MST
Re: [PATCH RFC 6/7] Revert "x86: return modified setup_data only if read as memory, not as file"
Quoted 55 lines · Michael S. Tsirkin
This reverts commit
e935b735085dfa61d8e6d276b6f9e7687796a3c7.Fixes e935b73508 ("x86: return modified setup_data only if read as memory, not as file")Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/nvram/fw_cfg.h | 22 ------------------- hw/i386/x86.c | 46 +++++++++------------------------------ hw/nvram/fw_cfg.c | 12 +++++----- 3 files changed, 16 insertions(+), 64 deletions(-)include/hw/nvram/fw_cfg.h +0
-22@@ -117,28 +117,6 @@ struct FWCfgMemState {*/ void fw_cfg_add_bytes (FWCfgState *s,uint16_t key,void *data,size_t len); -/** -* fw_cfg_add_bytes_callback: -* @s: fw_cfg device being modified -* @key: selector key value for new fw_cfg item -* @select_cb: callback function when selecting -* @write_cb: callback function after a write -* @callback_opaque: argument to be passed into callback function -* @data: pointer to start of item data -* @len: size of item data -* @read_only: is file read only -* -* Add a new fw_cfg item, available by selecting the given key, as a raw -* "blob" of the given size. The data referenced by the starting pointer -* is only linked, NOT copied, into the data structure of the fw_cfg device. -*/ -void fw_cfg_add_bytes_callback (FWCfgState *s,uint16_t key, -FWCfgCallback select_cb, -FWCfgWriteCallback write_cb, -void *callback_opaque, -void *data,size_t len, -bool read_only); -/** * fw_cfg_add_string: * @s: fw_cfg device being modified hw/nvram/fw_cfg.c +0
-4@@ -693,12 +693,12 @@ static const VMStateDescription vmstate_fw_cfg = { } }; -void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key, - FWCfgCallback select_cb, - FWCfgWriteCallback write_cb, - void *callback_opaque,
hw/nvram/fw_cfg.c static const VMStateDescription vmstate_fw_cfg = { · line 703
Quoted 10 lines
hw/nvram/fw_cfg.c +6
-2- void *data, size_t len, - bool read_only) +static void fw_cfg_add_bytes_callback (FWCfgState *s,uint16_t key, +FWCfgCallback select_cb, +FWCfgWriteCallback write_cb, +void *callback_opaque, +void *data,size_t len, +bool read_only) {int arch = !!(key &FW_CFG_ARCH_LOCAL );
Could you leave these snippets in? This function is useful and will be needed in the reprise.
Jason
Re: [PATCH RFC 6/7] Revert "x86: return modified setup_data only if read as memory, not as file"
Quoted 61 lines · Jason A. Donenfeld
Quoted 60 lines · Michael S. Tsirkin
This reverts commit
e935b735085dfa61d8e6d276b6f9e7687796a3c7.Fixes e935b73508 ("x86: return modified setup_data only if read as memory, not as file")Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/nvram/fw_cfg.h | 22 ------------------- hw/i386/x86.c | 46 +++++++++------------------------------ hw/nvram/fw_cfg.c | 12 +++++----- 3 files changed, 16 insertions(+), 64 deletions(-)include/hw/nvram/fw_cfg.h +0
-22@@ -117,28 +117,6 @@ struct FWCfgMemState {*/ void fw_cfg_add_bytes (FWCfgState *s,uint16_t key,void *data,size_t len); -/** -* fw_cfg_add_bytes_callback: -* @s: fw_cfg device being modified -* @key: selector key value for new fw_cfg item -* @select_cb: callback function when selecting -* @write_cb: callback function after a write -* @callback_opaque: argument to be passed into callback function -* @data: pointer to start of item data -* @len: size of item data -* @read_only: is file read only -* -* Add a new fw_cfg item, available by selecting the given key, as a raw -* "blob" of the given size. The data referenced by the starting pointer -* is only linked, NOT copied, into the data structure of the fw_cfg device. -*/ -void fw_cfg_add_bytes_callback (FWCfgState *s,uint16_t key, -FWCfgCallback select_cb, -FWCfgWriteCallback write_cb, -void *callback_opaque, -void *data,size_t len, -bool read_only); -/** * fw_cfg_add_string: * @s: fw_cfg device being modified hw/nvram/fw_cfg.c +3
-6@@ -693,12 +693,12 @@ static const VMStateDescription vmstate_fw_cfg = { } }; -void fw_cfg_add_bytes_callback (FWCfgState *s,uint16_t key, -FWCfgCallback select_cb, -FWCfgWriteCallback write_cb, -void *callback_opaque, -void *data,size_t len, -bool read_only) +static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key, + FWCfgCallback select_cb, + FWCfgWriteCallback write_cb,
Quoted 8 lines
hw/nvram/fw_cfg.c static const VMStateDescription vmstate_fw_cfg = { · line 703
Quoted 5 lines
hw/nvram/fw_cfg.c +3
-0+void *callback_opaque, + void *data, size_t len, + bool read_only) { int arch = !!(key & FW_CFG_ARCH_LOCAL);Could you leave these snippets in? This function is useful and will be needed in the reprise.
IMHO it is better to do a full clean revert of the patches.
Switching this one function from static to public is trivial enough that it is not burden to do in a new impl of the RNG seed work.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH RFC 6/7] Revert "x86: return modified setup_data only if read as memory, not as file"
In reply to Michael S. TsirkinQuoted 9 lines · Michael S. Tsirkin
This reverts commit
e935b735085dfa61d8e6d276b6f9e7687796a3c7.Fixes e935b73508 ("x86: return modified setup_data only if read as memory, not as file")Signed-off-by Michael S. Tsirkin <[email protected]>--- include/hw/nvram/fw_cfg.h | 22 ------------------- hw/i386/x86.c | 46 +++++++++------------------------------ hw/nvram/fw_cfg.c | 12 +++++----- 3 files changed, 16 insertions(+), 64 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
RFC PATCH 7/7 Revert "hw/i386: pass RNG seed via setup_data entry"
In reply to Michael S. TsirkinThis reverts commit 67f7e426e53833a5db75b0d813e8d537b8a75bd2.
--- include/hw/i386/pc.h | 3 --- include/hw/i386/x86.h | 3 +-- hw/i386/microvm.c | 2 +- hw/i386/pc.c | 4 ++-- hw/i386/pc_piix.c | 2 -- hw/i386/pc_q35.c | 2 -- hw/i386/x86.c | 26 ++++---------------------- 7 files changed, 8 insertions(+), 34 deletions(-)
include/hw/i386/pc.h +0 -3
@@ -127,9 +127,6 @@ struct PCMachineClass {/* create kvmclock device even when KVM PV features are not exposed */ bool kvmclock_create_always; - -/* skip passing an rng seed for legacy machines */ -bool legacy_no_rng_seed; };#define TYPE_PC_MACHINE "generic-pc-machine"
include/hw/i386/x86.h +1 -2
@@ -126,8 +126,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,void x86_load_linux (X86MachineState *x86ms,FWCfgState *fw_cfg,int acpi_data_size, -bool pvh_enabled, -bool legacy_no_rng_seed); +bool pvh_enabled);bool x86_machine_is_smm_enabled (const X86MachineState *x86ms);bool x86_machine_is_acpi_enabled (const X86MachineState *x86ms);
hw/i386/microvm.c +1 -1
@@ -330,7 +330,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)rom_set_fw (fw_cfg);if (machine->kernel_filename !=NULL ) { -x86_load_linux (x86ms, fw_cfg,0 , true, false); +x86_load_linux (x86ms, fw_cfg,0 , true); }if (mms->option_roms) {
hw/i386/pc.c +2 -2
@@ -804,7 +804,7 @@ void xen_load_linux(PCMachineState *pcms)rom_set_fw (fw_cfg);x86_load_linux (x86ms, fw_cfg, pcmc->acpi_data_size, - pcmc->pvh_enabled, pcmc->legacy_no_rng_seed); + pcmc->pvh_enabled);for (i =0 ; i < nb_option_roms; i++) { assert(!strcmp(option_rom[i].name, "linuxboot.bin") || !strcmp(option_rom[i].name, "linuxboot_dma.bin") ||
@@ -1124,7 +1124,7 @@ void pc_memory_init(PCMachineState *pcms,if (linux_boot) {x86_load_linux (x86ms, fw_cfg, pcmc->acpi_data_size, - pcmc->pvh_enabled, pcmc->legacy_no_rng_seed); + pcmc->pvh_enabled); }for (i =0 ; i < nb_option_roms; i++) {
hw/i386/pc_piix.c +0 -2
@@ -476,9 +476,7 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,static void pc_i440fx_7_1_machine_options (MachineClass *m) { -PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_i440fx_7_2_machine_options (m); - pcmc->legacy_no_rng_seed = true;compat_props_add (m->compat_props, hw_compat_7_1, hw_compat_7_1_len);compat_props_add (m->compat_props, pc_compat_7_1, pc_compat_7_1_len); }
hw/i386/pc_q35.c +0 -2
@@ -395,9 +395,7 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,static void pc_q35_7_1_machine_options (MachineClass *m) { -PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_q35_7_2_machine_options (m); - pcmc->legacy_no_rng_seed = true;compat_props_add (m->compat_props, hw_compat_7_1, hw_compat_7_1_len);compat_props_add (m->compat_props, pc_compat_7_1, pc_compat_7_1_len); }
hw/i386/x86.c +4 -22
@@ -26,7 +26,6 @@#include "qemu/cutils.h" #include "qemu/units.h" #include "qemu/datadir.h" -#include "qemu/guest-random.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qapi/qapi-visit-common.h"
@@ -771,8 +770,7 @@ static bool load_elfboot(const char *kernel_filename,void x86_load_linux (X86MachineState *x86ms,FWCfgState *fw_cfg,int acpi_data_size, -bool pvh_enabled, -bool legacy_no_rng_seed) +bool pvh_enabled) {bool linuxboot_dma_enabled =X86_MACHINE_GET_CLASS (x86ms)->fwcfg_dma_enabled;uint16_t protocol;
@@ -780,7 +778,7 @@ void x86_load_linux(X86MachineState *x86ms,int dtb_size, setup_data_offset;uint32_t initrd_max;uint8_t header[8192 ], *setup, *kernel; -hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 , first_setup_data =0 ; +hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 ;FILE *f;char *vmode;MachineState *machine =MACHINE (x86ms);
@@ -790,7 +788,6 @@ void x86_load_linux(X86MachineState *x86ms,const char *dtb_filename = machine->dtb;const char *kernel_cmdline = machine->kernel_cmdline;SevKernelLoaderContext sev_load_ctx = {}; -enum {RNG_SEED_LENGTH =32 };/* Align to 16 bytes as a paranoia measure */ cmdline_size = (strlen (kernel_cmdline) +16 ) & ~15 ;
@@ -1070,31 +1067,16 @@ void x86_load_linux(X86MachineState *x86ms, kernel_size = setup_data_offset +sizeof (struct setup_data ) + dtb_size; kernel =g_realloc (kernel, kernel_size); +stq_p (header +0x250 , prot_addr + setup_data_offset); setup_data = (struct setup_data *)(kernel + setup_data_offset); - setup_data->next =cpu_to_le64 (first_setup_data); - first_setup_data = prot_addr + setup_data_offset; + setup_data->next =0 ; setup_data->type =cpu_to_le32 (SETUP_DTB ); setup_data->len =cpu_to_le32 (dtb_size);load_image_size (dtb_filename, setup_data->data, dtb_size); } -if (!legacy_no_rng_seed) { - setup_data_offset =QEMU_ALIGN_UP (kernel_size,16 ); - kernel_size = setup_data_offset +sizeof (struct setup_data ) +RNG_SEED_LENGTH ; - kernel =g_realloc (kernel, kernel_size); - setup_data = (struct setup_data *)(kernel + setup_data_offset); - setup_data->next =cpu_to_le64 (first_setup_data); - first_setup_data = prot_addr + setup_data_offset; - setup_data->type =cpu_to_le32 (SETUP_RNG_SEED ); - setup_data->len =cpu_to_le32 (RNG_SEED_LENGTH ); -qemu_guest_getrandom_nofail (setup_data->data,RNG_SEED_LENGTH ); - } - -/* Offset 0x250 is a pointer to the first setup_data link. */ -stq_p (header +0x250 , first_setup_data); -/* * If we're starting an encrypted VM, it will be OVMF based, which uses the * efi stub for booting and doesn't require any values to be placed in the
Signature · 1 line
MST
Re: [PATCH RFC 7/7] Revert "hw/i386: pass RNG seed via setup_data entry"
Quoted 4 lines · Michael S. Tsirkin
This reverts commit
67f7e426e53833a5db75b0d813e8d537b8a75bd2.Fixes 67f7e426e5 ("hw/i386: pass RNG seed via setup_data entry")Signed-off-by Michael S. Tsirkin <[email protected]>
Quoted 9 lines
--- include/hw/i386/pc.h | 3 --- include/hw/i386/x86.h | 3 +-- hw/i386/microvm.c | 2 +- hw/i386/pc.c | 4 ++-- hw/i386/pc_piix.c | 2 -- hw/i386/pc_q35.c | 2 -- hw/i386/x86.c | 26 ++++---------------------- 7 files changed, 8 insertions(+), 34 deletions(-)
All the patches prior to this were clean reverts. This one though does not look clean, rather it looks like reverting a combination of 3 commits
commit ffe2d2382e5f1aae1abc4081af407905ef380311
Author: Jason A. Donenfeld <[email protected]> Date: Wed Sep 21 11:31:34 2022 +0200
x86: re-enable rng seeding via SetupData
commit 3824e25db1a84fadc50b88dfbe27047aa2f7f85d
Author: Gerd Hoffmann <[email protected]> Date: Wed Aug 17 10:39:40 2022 +0200
x86: disable rng seeding via setup_data
commit 67f7e426e53833a5db75b0d813e8d537b8a75bd2
Author: Jason A. Donenfeld <[email protected]> Date: Thu Jul 21 14:56:36 2022 +0200
hw/i386: pass RNG seed via setup_data entry
though, even taking the individual commits isn't a perfectly clean revert due to other unrelated changes in machine type versioning.
I'm not too fussed if this last one isn't a clean revert, but lets just call out in the commit message that we're just manually resolving conflicts and skipping those two intermediate commits for simplicity.
Assuming an improve commit message:
Quoted 168 lines
include/hw/i386/pc.h +0
-3@@ -127,9 +127,6 @@ struct PCMachineClass {/* create kvmclock device even when KVM PV features are not exposed */ bool kvmclock_create_always; - -/* skip passing an rng seed for legacy machines */ -bool legacy_no_rng_seed; };#define TYPE_PC_MACHINE "generic-pc-machine"include/hw/i386/x86.h +1
-2@@ -126,8 +126,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,void x86_load_linux (X86MachineState *x86ms,FWCfgState *fw_cfg,int acpi_data_size, -bool pvh_enabled, -bool legacy_no_rng_seed); +bool pvh_enabled);bool x86_machine_is_smm_enabled (const X86MachineState *x86ms);bool x86_machine_is_acpi_enabled (const X86MachineState *x86ms);hw/i386/microvm.c +1
-1@@ -330,7 +330,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)rom_set_fw (fw_cfg);if (machine->kernel_filename !=NULL ) { -x86_load_linux (x86ms, fw_cfg,0 , true, false); +x86_load_linux (x86ms, fw_cfg,0 , true); }if (mms->option_roms) {hw/i386/pc.c +2
-2@@ -804,7 +804,7 @@ void xen_load_linux(PCMachineState *pcms)rom_set_fw (fw_cfg);x86_load_linux (x86ms, fw_cfg, pcmc->acpi_data_size, - pcmc->pvh_enabled, pcmc->legacy_no_rng_seed); + pcmc->pvh_enabled);for (i =0 ; i < nb_option_roms; i++) { assert(!strcmp(option_rom[i].name, "linuxboot.bin") || !strcmp(option_rom[i].name, "linuxboot_dma.bin") ||@@ -1124,7 +1124,7 @@ void pc_memory_init(PCMachineState *pcms,if (linux_boot) {x86_load_linux (x86ms, fw_cfg, pcmc->acpi_data_size, - pcmc->pvh_enabled, pcmc->legacy_no_rng_seed); + pcmc->pvh_enabled); }for (i =0 ; i < nb_option_roms; i++) {hw/i386/pc_piix.c +0
-2@@ -476,9 +476,7 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,static void pc_i440fx_7_1_machine_options (MachineClass *m) { -PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_i440fx_7_2_machine_options (m); - pcmc->legacy_no_rng_seed = true;compat_props_add (m->compat_props, hw_compat_7_1, hw_compat_7_1_len);compat_props_add (m->compat_props, pc_compat_7_1, pc_compat_7_1_len); }hw/i386/pc_q35.c +0
-2@@ -395,9 +395,7 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,static void pc_q35_7_1_machine_options (MachineClass *m) { -PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_q35_7_2_machine_options (m); - pcmc->legacy_no_rng_seed = true;compat_props_add (m->compat_props, hw_compat_7_1, hw_compat_7_1_len);compat_props_add (m->compat_props, pc_compat_7_1, pc_compat_7_1_len); }hw/i386/x86.c +4
-22@@ -26,7 +26,6 @@#include "qemu/cutils.h" #include "qemu/units.h" #include "qemu/datadir.h" -#include "qemu/guest-random.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qapi/qapi-visit-common.h" @@ -771,8 +770,7 @@ static bool load_elfboot(const char *kernel_filename,void x86_load_linux (X86MachineState *x86ms,FWCfgState *fw_cfg,int acpi_data_size, -bool pvh_enabled, -bool legacy_no_rng_seed) +bool pvh_enabled) {bool linuxboot_dma_enabled =X86_MACHINE_GET_CLASS (x86ms)->fwcfg_dma_enabled;uint16_t protocol;@@ -780,7 +778,7 @@ void x86_load_linux(X86MachineState *x86ms,int dtb_size, setup_data_offset;uint32_t initrd_max;uint8_t header[8192 ], *setup, *kernel; -hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 , first_setup_data =0 ; +hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 ;FILE *f;char *vmode;MachineState *machine =MACHINE (x86ms);@@ -790,7 +788,6 @@ void x86_load_linux(X86MachineState *x86ms,const char *dtb_filename = machine->dtb;const char *kernel_cmdline = machine->kernel_cmdline;SevKernelLoaderContext sev_load_ctx = {}; -enum {RNG_SEED_LENGTH =32 };/* Align to 16 bytes as a paranoia measure */ cmdline_size = (strlen (kernel_cmdline) +16 ) & ~15 ;@@ -1070,31 +1067,16 @@ void x86_load_linux(X86MachineState *x86ms, kernel_size = setup_data_offset +sizeof (struct setup_data ) + dtb_size; kernel =g_realloc (kernel, kernel_size); +stq_p (header +0x250 , prot_addr + setup_data_offset); setup_data = (struct setup_data *)(kernel + setup_data_offset); - setup_data->next =cpu_to_le64 (first_setup_data); - first_setup_data = prot_addr + setup_data_offset; + setup_data->next =0 ; setup_data->type =cpu_to_le32 (SETUP_DTB ); setup_data->len =cpu_to_le32 (dtb_size);load_image_size (dtb_filename, setup_data->data, dtb_size); } -if (!legacy_no_rng_seed) { - setup_data_offset =QEMU_ALIGN_UP (kernel_size,16 ); - kernel_size = setup_data_offset +sizeof (struct setup_data ) +RNG_SEED_LENGTH ; - kernel =g_realloc (kernel, kernel_size); - setup_data = (struct setup_data *)(kernel + setup_data_offset); - setup_data->next =cpu_to_le64 (first_setup_data); - first_setup_data = prot_addr + setup_data_offset; - setup_data->type =cpu_to_le32 (SETUP_RNG_SEED ); - setup_data->len =cpu_to_le32 (RNG_SEED_LENGTH ); -qemu_guest_getrandom_nofail (setup_data->data,RNG_SEED_LENGTH ); - } - -/* Offset 0x250 is a pointer to the first setup_data link. */ -stq_p (header +0x250 , first_setup_data); -/* * If we're starting an encrypted VM, it will be OVMF based, which uses the * efi stub for booting and doesn't require any values to be placed in the Signature · 1 line
MST
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH RFC 7/7] Revert "hw/i386: pass RNG seed via setup_data entry"
Quoted 43 lines · Daniel P. Berrangé
Quoted 4 lines · Michael S. Tsirkin
This reverts commit
67f7e426e53833a5db75b0d813e8d537b8a75bd2.Fixes 67f7e426e5 ("hw/i386: pass RNG seed via setup_data entry")Signed-off-by Michael S. Tsirkin <[email protected]>Quoted 9 lines
--- include/hw/i386/pc.h | 3 --- include/hw/i386/x86.h | 3 +-- hw/i386/microvm.c | 2 +- hw/i386/pc.c | 4 ++-- hw/i386/pc_piix.c | 2 -- hw/i386/pc_q35.c | 2 -- hw/i386/x86.c | 26 ++++---------------------- 7 files changed, 8 insertions(+), 34 deletions(-)All the patches prior to this were clean reverts. This one though does not look clean, rather it looks like reverting a combination of 3 commits
commit
ffe2d2382e5f1aae1abc4081af407905ef380311Author: Jason A. Donenfeld <[email protected]> Date: Wed Sep 21 11:31:34 2022 +0200x86: re-enable rng seeding via SetupData
commit
3824e25db1a84fadc50b88dfbe27047aa2f7f85dAuthor: Gerd Hoffmann <[email protected]> Date: Wed Aug 17 10:39:40 2022 +0200x86: disable rng seeding via
setup_datacommit
67f7e426e53833a5db75b0d813e8d537b8a75bd2Author: Jason A. Donenfeld <[email protected]> Date: Thu Jul 21 14:56:36 2022 +0200hw/i386: pass RNG seed via
setup_dataentrythough, even taking the individual commits isn't a perfectly clean revert due to other unrelated changes in machine type versioning.
Quoted 8 lines
I'm not too fussed if this last one isn't a clean revert, but lets just call out in the commit message that we're just manually resolving conflicts and skipping those two intermediate commits for simplicity.
Assuming an improve commit message:
Reviewed-by Daniel P. Berrangé <[email protected]>
Yes - what I did as part of revert is drop all mentions of legacy_no_rng_seed manually.
I will clarify that, thanks!
Quoted 177 lines
Quoted 170 lines
include/hw/i386/pc.h +0
-3@@ -127,9 +127,6 @@ struct PCMachineClass {/* create kvmclock device even when KVM PV features are not exposed */ bool kvmclock_create_always; - -/* skip passing an rng seed for legacy machines */ -bool legacy_no_rng_seed; };#define TYPE_PC_MACHINE "generic-pc-machine"include/hw/i386/x86.h +1
-2@@ -126,8 +126,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,void x86_load_linux (X86MachineState *x86ms,FWCfgState *fw_cfg,int acpi_data_size, -bool pvh_enabled, -bool legacy_no_rng_seed); +bool pvh_enabled);bool x86_machine_is_smm_enabled (const X86MachineState *x86ms);bool x86_machine_is_acpi_enabled (const X86MachineState *x86ms);hw/i386/microvm.c +1
-1@@ -330,7 +330,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)rom_set_fw (fw_cfg);if (machine->kernel_filename !=NULL ) { -x86_load_linux (x86ms, fw_cfg,0 , true, false); +x86_load_linux (x86ms, fw_cfg,0 , true); }if (mms->option_roms) {hw/i386/pc.c +2
-2@@ -804,7 +804,7 @@ void xen_load_linux(PCMachineState *pcms)rom_set_fw (fw_cfg);x86_load_linux (x86ms, fw_cfg, pcmc->acpi_data_size, - pcmc->pvh_enabled, pcmc->legacy_no_rng_seed); + pcmc->pvh_enabled);for (i =0 ; i < nb_option_roms; i++) { assert(!strcmp(option_rom[i].name, "linuxboot.bin") || !strcmp(option_rom[i].name, "linuxboot_dma.bin") ||@@ -1124,7 +1124,7 @@ void pc_memory_init(PCMachineState *pcms,if (linux_boot) {x86_load_linux (x86ms, fw_cfg, pcmc->acpi_data_size, - pcmc->pvh_enabled, pcmc->legacy_no_rng_seed); + pcmc->pvh_enabled); }for (i =0 ; i < nb_option_roms; i++) {hw/i386/pc_piix.c +0
-2@@ -476,9 +476,7 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,static void pc_i440fx_7_1_machine_options (MachineClass *m) { -PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_i440fx_7_2_machine_options (m); - pcmc->legacy_no_rng_seed = true;compat_props_add (m->compat_props, hw_compat_7_1, hw_compat_7_1_len);compat_props_add (m->compat_props, pc_compat_7_1, pc_compat_7_1_len); }hw/i386/pc_q35.c +0
-2@@ -395,9 +395,7 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,static void pc_q35_7_1_machine_options (MachineClass *m) { -PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_q35_7_2_machine_options (m); - pcmc->legacy_no_rng_seed = true;compat_props_add (m->compat_props, hw_compat_7_1, hw_compat_7_1_len);compat_props_add (m->compat_props, pc_compat_7_1, pc_compat_7_1_len); }hw/i386/x86.c +4
-22@@ -26,7 +26,6 @@#include "qemu/cutils.h" #include "qemu/units.h" #include "qemu/datadir.h" -#include "qemu/guest-random.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qapi/qapi-visit-common.h" @@ -771,8 +770,7 @@ static bool load_elfboot(const char *kernel_filename,void x86_load_linux (X86MachineState *x86ms,FWCfgState *fw_cfg,int acpi_data_size, -bool pvh_enabled, -bool legacy_no_rng_seed) +bool pvh_enabled) {bool linuxboot_dma_enabled =X86_MACHINE_GET_CLASS (x86ms)->fwcfg_dma_enabled;uint16_t protocol;@@ -780,7 +778,7 @@ void x86_load_linux(X86MachineState *x86ms,int dtb_size, setup_data_offset;uint32_t initrd_max;uint8_t header[8192 ], *setup, *kernel; -hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 , first_setup_data =0 ; +hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr =0 ;FILE *f;char *vmode;MachineState *machine =MACHINE (x86ms);@@ -790,7 +788,6 @@ void x86_load_linux(X86MachineState *x86ms,const char *dtb_filename = machine->dtb;const char *kernel_cmdline = machine->kernel_cmdline;SevKernelLoaderContext sev_load_ctx = {}; -enum {RNG_SEED_LENGTH =32 };/* Align to 16 bytes as a paranoia measure */ cmdline_size = (strlen (kernel_cmdline) +16 ) & ~15 ;@@ -1070,31 +1067,16 @@ void x86_load_linux(X86MachineState *x86ms, kernel_size = setup_data_offset +sizeof (struct setup_data ) + dtb_size; kernel =g_realloc (kernel, kernel_size); +stq_p (header +0x250 , prot_addr + setup_data_offset); setup_data = (struct setup_data *)(kernel + setup_data_offset); - setup_data->next =cpu_to_le64 (first_setup_data); - first_setup_data = prot_addr + setup_data_offset; + setup_data->next =0 ; setup_data->type =cpu_to_le32 (SETUP_DTB ); setup_data->len =cpu_to_le32 (dtb_size);load_image_size (dtb_filename, setup_data->data, dtb_size); } -if (!legacy_no_rng_seed) { - setup_data_offset =QEMU_ALIGN_UP (kernel_size,16 ); - kernel_size = setup_data_offset +sizeof (struct setup_data ) +RNG_SEED_LENGTH ; - kernel =g_realloc (kernel, kernel_size); - setup_data = (struct setup_data *)(kernel + setup_data_offset); - setup_data->next =cpu_to_le64 (first_setup_data); - first_setup_data = prot_addr + setup_data_offset; - setup_data->type =cpu_to_le32 (SETUP_RNG_SEED ); - setup_data->len =cpu_to_le32 (RNG_SEED_LENGTH ); -qemu_guest_getrandom_nofail (setup_data->data,RNG_SEED_LENGTH ); - } - -/* Offset 0x250 is a pointer to the first setup_data link. */ -stq_p (header +0x250 , first_setup_data); -/* * If we're starting an encrypted VM, it will be OVMF based, which uses the * efi stub for booting and doesn't require any values to be placed in the Signature · 1 line
MSTWith regards,
DanielSignature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Hi Michael,
Quoted 25 lines · Michael S. Tsirkin
All attempts to fix up passing RNG seed via
setup_dataentry failed. Let's just rip out all of it. We'll start over.Warning: all I did was git revert the relevant patches and resolve the (trivial) conflicts. Not even compiled - it's almost midnight here.
Jason this is the kind of approach I'd like to see, not yet another pointer math rich patch I need to spend time reviewing. Just get us back to where we started. We can redo "x86: use typedef for SetupData struct" later if we want, it's benign.
Could you do something like this pls?
Or test and ack if this patchset happens to work by luck.Michael S. Tsirkin (7):
Revert "x86: don't let decompressed kernel image clobbersetup_data" Revert "x86: do not re-randomize RNG seed on snapshot load" Revert "x86: re-initialize RNG seed when selecting kernel" Revert "x86: reinitialize RNG seed on system reboot" Revert "x86: use typedef for SetupData struct"
Revert "x86: return modifiedsetup_dataonly if read as memory, not as
file"
Revert "hw/i386: pass RNG seed viasetup_dataentry"
Quoted 12 lines
include/hw/i386/microvm.h | 5 +- include/hw/i386/pc.h | 3 - include/hw/i386/x86.h | 3 +- include/hw/nvram/fw_cfg.h | 31 ---------- hw/i386/microvm.c | 17 ++---- hw/i386/pc.c | 4 +- hw/i386/pc_piix.c | 2 - hw/i386/pc_q35.c | 2 - hw/i386/x86.c | 122 ++++++++++---------------------------- hw/nvram/fw_cfg.c | 21 ++----- 10 files changed, 49 insertions(+), 161 deletions(-)
I tested this series with SEV measured boot using AmdSev OVMF. The boot succeeds, and the hashes computed for kernel/initrd/cmdline are identical to the ones computed by qemu 7.1.0, which are the hashes that the guest owner would expect.
As for non-EFI (non-SEV) guests, I did a very simple test of starting a non-EFI guest and it looks OK, but more testing is needed.
So:
Thank you!
-Dov
Quoted 42 lines · Dov Murik
Hi Michael,
Quoted 25 lines · Michael S. Tsirkin
All attempts to fix up passing RNG seed via
setup_dataentry failed. Let's just rip out all of it. We'll start over.Warning: all I did was git revert the relevant patches and resolve the (trivial) conflicts. Not even compiled - it's almost midnight here.
Jason this is the kind of approach I'd like to see, not yet another pointer math rich patch I need to spend time reviewing. Just get us back to where we started. We can redo "x86: use typedef for SetupData struct" later if we want, it's benign.
Could you do something like this pls?
Or test and ack if this patchset happens to work by luck.Michael S. Tsirkin (7):
Revert "x86: don't let decompressed kernel image clobbersetup_data" Revert "x86: do not re-randomize RNG seed on snapshot load" Revert "x86: re-initialize RNG seed when selecting kernel" Revert "x86: reinitialize RNG seed on system reboot" Revert "x86: use typedef for SetupData struct"
Revert "x86: return modifiedsetup_dataonly if read as memory, not as
file"
Revert "hw/i386: pass RNG seed viasetup_dataentry"Quoted 12 lines
include/hw/i386/microvm.h | 5 +- include/hw/i386/pc.h | 3 - include/hw/i386/x86.h | 3 +- include/hw/nvram/fw_cfg.h | 31 ---------- hw/i386/microvm.c | 17 ++---- hw/i386/pc.c | 4 +- hw/i386/pc_piix.c | 2 - hw/i386/pc_q35.c | 2 - hw/i386/x86.c | 122 ++++++++++---------------------------- hw/nvram/fw_cfg.c | 21 ++----- 10 files changed, 49 insertions(+), 161 deletions(-)
Quoted 5 lines
I tested this series with SEV measured boot using AmdSev OVMF. The boot succeeds, and the hashes computed for
kernel/initrd/cmdlineare identical to the ones computed by qemu 7.1.0, which are the hashes that the guest owner would expect.
I also tested that backporting this series to 7.2.0 (skipping PATCH 1/7 because it was added after the 7.2.0 release) works OK for booting SEV guest with AmdSev measured boot (and retains the same kernel/initrd/cmdline hashes as qemu 7.1.0).
-Dov
Quoted 11 lines
As for non-EFI (non-SEV) guests, I did a very simple test of starting a non-EFI guest and it looks OK, but more testing is needed.
So:
Tested-by Dov Murik <[email protected]>Thank you!
-Dov
Quoted 25 lines · Michael S. Tsirkin
All attempts to fix up passing RNG seed via
setup_dataentry failed. Let's just rip out all of it. We'll start over.Warning: all I did was git revert the relevant patches and resolve the (trivial) conflicts. Not even compiled - it's almost midnight here.
Jason this is the kind of approach I'd like to see, not yet another pointer math rich patch I need to spend time reviewing. Just get us back to where we started. We can redo "x86: use typedef for SetupData struct" later if we want, it's benign.
Could you do something like this pls?
Or test and ack if this patchset happens to work by luck.Michael S. Tsirkin (7):
Revert "x86: don't let decompressed kernel image clobbersetup_data" Revert "x86: do not re-randomize RNG seed on snapshot load" Revert "x86: re-initialize RNG seed when selecting kernel" Revert "x86: reinitialize RNG seed on system reboot" Revert "x86: use typedef for SetupData struct"
Revert "x86: return modifiedsetup_dataonly if read as memory, not as
file"
Revert "hw/i386: pass RNG seed viasetup_dataentry"
Quoted 15 lines
include/hw/i386/microvm.h | 5 +- include/hw/i386/pc.h | 3 - include/hw/i386/x86.h | 3 +- include/hw/nvram/fw_cfg.h | 31 ---------- hw/i386/microvm.c | 17 ++---- hw/i386/pc.c | 4 +- hw/i386/pc_piix.c | 2 - hw/i386/pc_q35.c | 2 - hw/i386/x86.c | 122 ++++++++++---------------------------- hw/nvram/fw_cfg.c | 21 ++----- 10 files changed, 49 insertions(+), 161 deletions(-)Signature · 1 line
MST
For the record, all three of the cases that I tested (i386 no EFI, x86_64 with and without EFI) worked fine with this series. In case it is useful:
Cheers,
Nathan
Quoted 11 lines · Michael S. Tsirkin
All attempts to fix up passing RNG seed via
setup_dataentry failed. Let's just rip out all of it. We'll start over.Warning: all I did was git revert the relevant patches and resolve the (trivial) conflicts. Not even compiled - it's almost midnight here.
Jason this is the kind of approach I'd like to see, not yet another pointer math rich patch I need to spend time reviewing. Just get us back to where we started. We can redo "x86: use typedef for SetupData struct" later if we want, it's benign.
This approach looks suitable for applying to the 7.2 tree too, which will be good for fixing the regressions in stable.
Quoted 14 lines
Could you do something like this pls?
Or test and ack if this patchset happens to work by luck.Michael S. Tsirkin (7):
Revert "x86: don't let decompressed kernel image clobbersetup_data" Revert "x86: do not re-randomize RNG seed on snapshot load" Revert "x86: re-initialize RNG seed when selecting kernel" Revert "x86: reinitialize RNG seed on system reboot" Revert "x86: use typedef for SetupData struct"
Revert "x86: return modifiedsetup_dataonly if read as memory, not as
file"
Revert "hw/i386: pass RNG seed viasetup_dataentry"
Quoted 15 lines
include/hw/i386/microvm.h | 5 +- include/hw/i386/pc.h | 3 - include/hw/i386/x86.h | 3 +- include/hw/nvram/fw_cfg.h | 31 ---------- hw/i386/microvm.c | 17 ++---- hw/i386/pc.c | 4 +- hw/i386/pc_piix.c | 2 - hw/i386/pc_q35.c | 2 - hw/i386/x86.c | 122 ++++++++++---------------------------- hw/nvram/fw_cfg.c | 21 ++----- 10 files changed, 49 insertions(+), 161 deletions(-)Signature · 1 line
MST
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 8 lines · Daniel P. Berrangé
Quoted 7 lines · Michael S. Tsirkin
All attempts to fix up passing RNG seed via
setup_dataentry failed. Let's just rip out all of it. We'll start over.Warning: all I did was git revert the relevant patches and resolve the (trivial) conflicts. Not even compiled - it's almost midnight here.
Quoted 7 lines
Quoted 4 lines
Jason this is the kind of approach I'd like to see, not yet another pointer math rich patch I need to spend time reviewing. Just get us back to where we started. We can redo "x86: use typedef for SetupData struct" later if we want, it's benign.
This approach looks suitable for applying to the 7.2 tree too, which will be good for fixing the regressions in stable.
Since no further alternative has been proposed, can you consider sending a pull request for this series. This has been broken for too long and many users & vendors are looking for an official fix to be applied to master before they backport to 7.2
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 17 lines · Daniel P. Berrangé
Quoted 8 lines · Daniel P. Berrangé
Quoted 7 lines · Michael S. Tsirkin
All attempts to fix up passing RNG seed via
setup_dataentry failed. Let's just rip out all of it. We'll start over.Warning: all I did was git revert the relevant patches and resolve the (trivial) conflicts. Not even compiled - it's almost midnight here.
Quoted 7 lines
Quoted 4 lines
Jason this is the kind of approach I'd like to see, not yet another pointer math rich patch I need to spend time reviewing. Just get us back to where we started. We can redo "x86: use typedef for SetupData struct" later if we want, it's benign.
This approach looks suitable for applying to the 7.2 tree too, which will be good for fixing the regressions in stable.
Quoted 11 lines
Since no further alternative has been proposed, can you consider sending a pull request for this series. This has been broken for too long and many users & vendors are looking for an official fix to be applied to master before they backport to 7.2
With regards,
DanielSignature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Will do. Thanks!