Skip to contentSkip to conversation

hw/arm/virt-acpi-build: Only expose flash on older machine types

PATCH Applied Andrew Jones 7 participants 25 messages Jun 29, 2020 – Jul 15, 2020

lore
Share & tools
lore
#0 lore raw

cover hw/arm/virt-acpi-build: Only expose flash on older machine types

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

This change was suggested by Ard and Laszlo.

Patch 3/4 is the meat. The other patches deal with updating qtest.

Thanks,
drew

Andrew Jones (4):
tests/acpi: remove stale allowed tables
tests/acpi: virt: allow DSDT acpi table changes hw/arm/virt-acpi-build: Only expose flash on older machine types tests/acpi: virt: update golden masters for DSDT

 hw/arm/virt-acpi-build.c                    |   5 ++++-
 hw/arm/virt.c                               |   3 +++
 include/hw/arm/virt.h                       |   1 +
 tests/data/acpi/virt/DSDT                   | Bin 5307 -> 5205 bytes
 tests/data/acpi/virt/DSDT.memhp             | Bin 6668 -> 6566 bytes
 tests/data/acpi/virt/DSDT.numamem           | Bin 5307 -> 5205 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |  18 ------------------
 7 files changed, 8 insertions(+), 19 deletions(-)
Signature · 1 line
2.25.4
#1 lore raw

PATCH 1/4 tests/acpi: remove stale allowed tables

Fixes 93dd625f8bf7 ("tests/acpi: update expected data files")
---
 tests/qtest/bios-tables-test-allowed-diff.h | 18 ------------------
 1 file changed, 18 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -18
index 8992f1f12b77..dfb8523c8bf4 100644
@@ -1,19 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/q35/DSDT",
-"tests/data/acpi/q35/DSDT.acpihmat",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.cphp",
-"tests/data/acpi/q35/DSDT.dimmpxm",
-"tests/data/acpi/q35/DSDT.ipmibt",
-"tests/data/acpi/q35/DSDT.memhp",
-"tests/data/acpi/q35/DSDT.mmio64",
-"tests/data/acpi/q35/DSDT.numamem",
-"tests/data/acpi/q35/DSDT.tis",
Signature · 1 line
2.25.4
#2 lore raw

Re: [PATCH 1/4] tests/acpi: remove stale allowed tables

Quoted 2 lines · Andrew Jones
Fixes 93dd625f8bf7 ("tests/acpi: update expected data files")

Ah yes. Thanks for fixing this! I will add something to the pull request script to catch this in the future.

Quoted 30 lines
---
 tests/qtest/bios-tables-test-allowed-diff.h | 18 ------------------
 1 file changed, 18 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -18
index 8992f1f12b77..dfb8523c8bf4 100644
@@ -1,19 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/q35/DSDT",
-"tests/data/acpi/q35/DSDT.acpihmat",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.cphp",
-"tests/data/acpi/q35/DSDT.dimmpxm",
-"tests/data/acpi/q35/DSDT.ipmibt",
-"tests/data/acpi/q35/DSDT.memhp",
-"tests/data/acpi/q35/DSDT.mmio64",
-"tests/data/acpi/q35/DSDT.numamem",
-"tests/data/acpi/q35/DSDT.tis",
Signature · 1 line
2.25.4
#3 lore raw

PATCH 2/4 tests/acpi: virt: allow DSDT acpi table changes

In reply to Andrew Jones
---
 tests/qtest/bios-tables-test-allowed-diff.h | 3 +++
 1 file changed, 3 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +3 -0
index dfb8523c8bf4..32a401ae35fa 100644
@@ -1 +1,4 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/virt/DSDT",
+"tests/data/acpi/virt/DSDT.memhp",
+"tests/data/acpi/virt/DSDT.numamem",
Signature · 1 line
2.25.4
#4 lore raw

PATCH 3/4 hw/arm/virt-acpi-build: Only expose flash on older machine types

In reply to Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +3 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
include/hw/arm/virt.h +1 -0
index 31878ddc7223..c65be5fe0bb6 100644
@@ -119,6 +119,7 @@ typedef struct {
     bool no_highmem_ecam;
     bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
     bool kvm_no_adjvtime;
+    bool acpi_expose_flash;
 } VirtMachineClass;
 
 typedef struct {
Signature · 1 line
2.25.4
Reviewed-by on v1 3/4
#5 lore raw
Quoted 14 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

Quoted 3 lines
Quoted 59 lines
---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +3 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
include/hw/arm/virt.h +1 -0
index 31878ddc7223..c65be5fe0bb6 100644
@@ -119,6 +119,7 @@ typedef struct {
     bool no_highmem_ecam;
     bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
     bool kvm_no_adjvtime;
+    bool acpi_expose_flash;
 } VirtMachineClass;
 
 typedef struct {
Reviewed-by on v1 3/4
#6 lore raw
In reply to Andrew Jones
Quoted 69 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +3 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
include/hw/arm/virt.h +0 -0
index 31878ddc7223..c65be5fe0bb6 100644

include/hw/arm/virt.h typedef struct { · line 125

Quoted 7 lines
include/hw/arm/virt.h +1 -0
@@ -119,6 +119,7 @@ typedef struct {
     bool no_highmem_ecam;
     bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
     bool kvm_no_adjvtime;
+    bool acpi_expose_flash;
 } VirtMachineClass;
 
 typedef struct {

Thank you!
Laszlo

#7 lore raw
In reply to Andrew Jones
Quoted 14 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

Quoted 3 lines

So who's merging this? Mostly ACPI things so I guess my tree? If so can I get acks from ARM maintainers pls?

Thanks!

Quoted 60 lines
---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +3 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
include/hw/arm/virt.h +1 -0
index 31878ddc7223..c65be5fe0bb6 100644
@@ -119,6 +119,7 @@ typedef struct {
     bool no_highmem_ecam;
     bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
     bool kvm_no_adjvtime;
+    bool acpi_expose_flash;
 } VirtMachineClass;
 
 typedef struct {
Signature · 1 line
2.25.4
#8 lore raw
Quoted 16 lines · Michael S. Tsirkin
Quoted 14 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

Quoted 6 lines
Quoted 3 lines

So who's merging this? Mostly ACPI things so I guess my tree? If so can I get acks from ARM maintainers pls?

This is on my to-look-at queue but in theory I'm on holiday this week :-)

-- PMM

#9 lore raw
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Michael S. Tsirkin
Quoted 17 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

Quoted 6 lines
Quoted 2 lines

So who's merging this? Mostly ACPI things so I guess my tree? If so can I get acks from ARM maintainers pls?

This is on my to-look-at queue but in theory I'm on holiday this week :-)

-- PMM

I picked up patch 1 for now :)

Signature · 1 line
MST
#10 lore raw
In reply to Andrew Jones
Quoted 51 lines · On Mon, 29 Jun 2020 16:09:37 +0200 Andrew Jones <[email protected]> wrote:

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +0 -0
index cd0834ce7faf..5adc9ff799ef 100644

hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) · line 2490

Quoted 9 lines
hw/arm/virt.c +3 -0
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;

we usually do not version ACPI tables changes
(unless we have a good reason to do so)

Quoted 15 lines
hw/arm/virt.c +0 -0
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
include/hw/arm/virt.h +1 -0
index 31878ddc7223..c65be5fe0bb6 100644
@@ -119,6 +119,7 @@ typedef struct {
     bool no_highmem_ecam;
     bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
     bool kvm_no_adjvtime;
+    bool acpi_expose_flash;
 } VirtMachineClass;
 
 typedef struct {
#11 lore raw
Quoted 55 lines · Igor Mammedov
Quoted 52 lines · On Mon, 29 Jun 2020 16:09:37 +0200 Andrew Jones <[email protected]> wrote:

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +0 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
Quoted 11 lines

hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) · line 2490

Quoted 8 lines
hw/arm/virt.c +3 -0
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;

we usually do not version ACPI tables changes
(unless we have a good reason to do so)

Even when the change is to remove the exposure of hardware from the guest? Before this change, if a guest looked, it had a flash, after this change, if a guest looks, it doesn't. I'd feel much better versioning a change like that, than not.

Thanks,
drew

Quoted 18 lines
Quoted 16 lines
hw/arm/virt.c +0 -0
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
include/hw/arm/virt.h +1 -0
index 31878ddc7223..c65be5fe0bb6 100644
@@ -119,6 +119,7 @@ typedef struct {
     bool no_highmem_ecam;
     bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
     bool kvm_no_adjvtime;
+    bool acpi_expose_flash;
 } VirtMachineClass;
 
 typedef struct {
#12 lore raw
Quoted 68 lines · Andrew Jones
Quoted 55 lines · Igor Mammedov
Quoted 52 lines · On Mon, 29 Jun 2020 16:09:37 +0200 Andrew Jones <[email protected]> wrote:

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +0 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
Quoted 11 lines

hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) · line 2490

Quoted 8 lines
hw/arm/virt.c +3 -0
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;

we usually do not version ACPI tables changes
(unless we have a good reason to do so)

Quoted 3 lines

Even when the change is to remove the exposure of hardware from the guest? Before this change, if a guest looked, it had a flash, after this change, if a guest looks, it doesn't.

It's up to the relevant maintainers who know what the semantics are. FYI ACPI tables only change across a reset though.
So it's a question of whether guests get confused even if this changes after a reboot.
Versioning is generally safer, but it's a good idea to document the motivation for it.

Quoted 24 lines

I'd feel much better versioning a change
like that, than not.

Thanks,
drew

Quoted 18 lines
Quoted 16 lines
hw/arm/virt.c +0 -0
 }
 DEFINE_VIRT_MACHINE(5, 0)
 
include/hw/arm/virt.h +1 -0
index 31878ddc7223..c65be5fe0bb6 100644
@@ -119,6 +119,7 @@ typedef struct {
     bool no_highmem_ecam;
     bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
     bool kvm_no_adjvtime;
+    bool acpi_expose_flash;
 } VirtMachineClass;
 
 typedef struct {
#13 lore raw
Quoted 69 lines · Michael S. Tsirkin
Quoted 68 lines · Andrew Jones
Quoted 66 lines · Igor Mammedov
Quoted 51 lines · On Mon, 29 Jun 2020 16:09:37 +0200 Andrew Jones <[email protected]> wrote:

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +0 -0
index cd0834ce7faf..5adc9ff799ef 100644

hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) · line 2490

Quoted 9 lines
hw/arm/virt.c +3 -0
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;

we usually do not version ACPI tables changes
(unless we have a good reason to do so)

Quoted 8 lines
Quoted 3 lines

Even when the change is to remove the exposure of hardware from the guest? Before this change, if a guest looked, it had a flash, after this change, if a guest looks, it doesn't.

It's up to the relevant maintainers who know what the semantics are. FYI ACPI tables only change across a reset though.
So it's a question of whether guests get confused even if this changes after a reboot.

Yup, but it's still the same "machine", so a user may wonder why it changed.

Quoted 3 lines

Versioning is generally safer, but it's a good idea to document the motivation for it.

Well, in this case, we could probably push this change to old machine types and nobody would notice. If a guest is using ACPI, then it must be using firmware, and if they're using firmware, then they can't be using the flash. So the user shouldn't care if it's there or not. The only justification for the versioning is because "it's safer". If people feel strongly about avoiding versioning when it's not obviously necessary, then I can respin without it.

Thanks,
drew

#14 lore raw
Quoted 94 lines · Andrew Jones
Quoted 69 lines · Michael S. Tsirkin
Quoted 68 lines · Andrew Jones
Quoted 66 lines · Igor Mammedov
Quoted 51 lines · On Mon, 29 Jun 2020 16:09:37 +0200 Andrew Jones <[email protected]> wrote:

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +0 -0
index cd0834ce7faf..5adc9ff799ef 100644

hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) · line 2490

Quoted 9 lines
hw/arm/virt.c +3 -0
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;

we usually do not version ACPI tables changes
(unless we have a good reason to do so)

Quoted 8 lines
Quoted 3 lines

Even when the change is to remove the exposure of hardware from the guest? Before this change, if a guest looked, it had a flash, after this change, if a guest looks, it doesn't.

It's up to the relevant maintainers who know what the semantics are. FYI ACPI tables only change across a reset though.
So it's a question of whether guests get confused even if this changes after a reboot.

Yup, but it's still the same "machine", so a user may wonder why it changed.

Quoted 3 lines

Versioning is generally safer, but it's a good idea to document the motivation for it.

Well, in this case, we could probably push this change to old machine types and nobody would notice. If a guest is using ACPI, then it must be using firmware, and if they're using firmware, then they can't be using the flash. So the user shouldn't care if it's there or not. The only justification for the versioning is because "it's safer". If people feel strongly about avoiding versioning when it's not obviously necessary, then I can respin without it.

Quoted 2 lines

Thanks,
drew

It's up to maintainers either way, but please do tweak the motivation in the commit log to include the above.

Signature · 1 line
MST
#15 lore raw
In reply to Andrew Jones
Quoted 74 lines · On Tue, 14 Jul 2020 11:23:25 +0200 Andrew Jones <[email protected]> wrote:
Quoted 73 lines · Michael S. Tsirkin
Quoted 71 lines · Andrew Jones
Quoted 55 lines · Igor Mammedov
Quoted 52 lines · On Mon, 29 Jun 2020 16:09:37 +0200 Andrew Jones <[email protected]> wrote:

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +0 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
Quoted 11 lines

hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) · line 2490

Quoted 8 lines
hw/arm/virt.c +3 -0
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;  

we usually do not version ACPI tables changes
(unless we have a good reason to do so)

Even when the change is to remove the exposure of hardware from the guest? Before this change, if a guest looked, it had a flash, after this change, if a guest looks, it doesn't.

Quoted 7 lines
Quoted 4 lines

It's up to the relevant maintainers who know what the semantics are. FYI ACPI tables only change across a reset though.
So it's a question of whether guests get confused even if this changes after a reboot.

Yup, but it's still the same "machine", so a user may wonder why it changed.

you can have a different firmware with the same machine type either and it might look differently to guest OS but don't bother versioning FW. APCI tables are also part of FW (but generated by QEMU), so the same usually rule applies.

Quoted 11 lines
Quoted 3 lines

Versioning is generally safer, but it's a good idea to document the motivation for it.

Well, in this case, we could probably push this change to old machine types and nobody would notice. If a guest is using ACPI, then it must be using firmware, and if they're using firmware, then they can't be using the flash. So the user shouldn't care if it's there or not. The only justification for the versioning is because "it's safer". If people feel strongly about avoiding versioning when it's not obviously necessary, then I can respin without it.

From my pov if it doesn't break anything don't version it, since versioning adds complexity which cost time during review, so it would be nicer to reviewers and to future yourself if you can help to keep it as simple as possible.

In this particular case I'd drop versioning.

Quoted 4 lines

Thanks,
drew

#16 lore raw
Quoted 82 lines · Igor Mammedov
Quoted 79 lines · On Tue, 14 Jul 2020 11:23:25 +0200 Andrew Jones <[email protected]> wrote:
Quoted 77 lines · Michael S. Tsirkin
Quoted 68 lines · Andrew Jones
Quoted 55 lines · Igor Mammedov
Quoted 52 lines · On Mon, 29 Jun 2020 16:09:37 +0200 Andrew Jones <[email protected]> wrote:

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

As firmware needs the device and uses DT, we leave the device exposed there. It's up to firmware to remove the nodes from DT before sending it on to the OS. However, there's no need to force firmware to remove tables from ACPI (which it doesn't know how to do anyway), so we simply don't add the tables in the first place. But, as we've been adding the tables for quite some time and don't want to change the default hardware exposed to versioned machines, then we only stop exposing the flash device tables for 5.1 and later machine types.

---
 hw/arm/virt-acpi-build.c | 5 ++++-
 hw/arm/virt.c            | 3 +++
 include/hw/arm/virt.h    | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +4 -1
index 1384a2cf2ab4..91f0df7b13a3 100644
@@ -749,6 +749,7 @@ static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker,
 static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
     Aml *scope, *dsdt;
     MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
@@ -767,7 +768,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     acpi_dsdt_add_cpus(scope, vms->smp_cpus);
     acpi_dsdt_add_uart(scope, &memmap[VIRT_UART],
                        (irqmap[VIRT_UART] + ARM_SPI_BASE));
-    acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    if (vmc->acpi_expose_flash) {
+        acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]);
+    }
     acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]);
     acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO],
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
hw/arm/virt.c +0 -0
index cd0834ce7faf..5adc9ff799ef 100644
@@ -2482,9 +2482,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(5, 1)
 
Quoted 11 lines

hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(5, 1) · line 2490

Quoted 8 lines
hw/arm/virt.c +3 -0
 static void virt_machine_5_0_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_5_1_options(mc);
     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
     mc->numa_mem_supported = true;
+    vmc->acpi_expose_flash = true;  

we usually do not version ACPI tables changes
(unless we have a good reason to do so)

Quoted 3 lines

Even when the change is to remove the exposure of hardware from the guest? Before this change, if a guest looked, it had a flash, after this change, if a guest looks, it doesn't.

It's up to the relevant maintainers who know what the semantics are. FYI ACPI tables only change across a reset though.
So it's a question of whether guests get confused even if this changes after a reboot.

Quoted 7 lines
Quoted 2 lines

Yup, but it's still the same "machine", so a user may wonder why it changed.

you can have a different firmware with the same machine type either and it might look differently to guest OS but don't bother versioning FW. APCI tables are also part of FW (but generated by QEMU), so the same usually rule applies.

That makes sense. However, while users of real machines agree to update their firmware after determining what will change, or at least expect there could be a change that they'll need to adapt to, users of virtual machines simply reboot, getting new firmware and ACPI tables, and then possibly new surprises. Indeed, they may have opted to use a virtual machine precisely so they could keep the environment stable across updates of the real machine. IOW, since we can maintain a versioned machine, then maybe we should?

Quoted 13 lines
Quoted 5 lines
Quoted 4 lines

Versioning is generally safer, but it's a good idea to document the motivation for it.

Quoted 7 lines

Well, in this case, we could probably push this change to old machine types and nobody would notice. If a guest is using ACPI, then it must be using firmware, and if they're using firmware, then they can't be using the flash. So the user shouldn't care if it's there or not. The only justification for the versioning is because "it's safer". If people feel strongly about avoiding versioning when it's not obviously necessary, then I can respin without it.

Quoted 1 line

From my pov if it doesn't break anything don't version it,

I don't see how we can be sure that we won't break anything. Although, in this case, we *probably* won't.

Quoted 3 lines

since versioning
adds complexity which cost time during review, so it would be nicer to reviewers and to future yourself if you can help to keep it as simple as possible.

I agree with all of that.

Quoted 3 lines

In this particular case I'd drop versioning.

So it sounds to me like we have some flexibility in our versioned machine maintenance. We can choose to forgo the usual compat code when the risk is deemed low enough. And, if somebody screams, we can always fix it later. I can live with that. I'll go ahead and respin without the versioning.

Thanks,
drew

#17 lore raw
Quoted 10 lines · Andrew Jones
Quoted 3 lines · Igor Mammedov

In this particular case I'd drop versioning.

So it sounds to me like we have some flexibility in our versioned machine maintenance. We can choose to forgo the usual compat code when the risk is deemed low enough. And, if somebody screams, we can always fix it later. I can live with that. I'll go ahead and respin without the versioning.

Actually this patch was already merged

2c1fb4d5c011 hw/arm/virt-acpi-build: Only expose flash on older machine types

and I don't see much value in posting a patch to remove the compat code.

Regarding the result of this discussion, my take is that unless the policy is to always or to never use versioning, then I think we should have guidelines documented which we can follow. Would one of the ACPI maintainers like to submit a document with the reasoning for when and when not to use versioning? And also for what's expected of the commit message justification when versioning is necessary?

Thanks,
drew

#18 lore raw
In reply to Andrew Jones

Hi Drew,

Quoted 4 lines · Andrew Jones

So it sounds to me like we have some flexibility in our versioned machine maintenance. We can choose to forgo the usual compat code when the risk is deemed low enough. And, if somebody screams, we can always fix it later. I can live with that. I'll go ahead and respin without the versioning.

In that case, please don't simply remove the acpi_dsdt_add_flash() call from build_dsdt(), because then "git blame" won't be able to help later. Can you please replace the call with a comment instead, similar to the RTC comment from commit 67736a25f865 ("ARM: virt: Don't generate RTC ACPI device when using UEFI", 2016-01-15)?

Thanks!
Laszlo

#19 lore raw
Quoted 9 lines · Laszlo Ersek

Hi Drew,

Quoted 4 lines · Andrew Jones

So it sounds to me like we have some flexibility in our versioned machine maintenance. We can choose to forgo the usual compat code when the risk is deemed low enough. And, if somebody screams, we can always fix it later. I can live with that. I'll go ahead and respin without the versioning.

Quoted 6 lines

In that case, please don't simply remove the acpi_dsdt_add_flash() call from build_dsdt(), because then "git blame" won't be able to help later. Can you please replace the call with a comment instead, similar to the RTC comment from commit 67736a25f865 ("ARM: virt: Don't generate RTC ACPI device when using UEFI", 2016-01-15)?

In the end I won't be respinning, as this patch is already merged. And, unless Igor twists my arm, then I don't plan to write another patch that removes the compat code. If I did remove it, I'd put a comment in there for git-blame to find. And, in the comment I'd write "Igor said to remove this", because git-blame would otherwise blame me :-)

Thanks,
drew

#20 lore raw

PATCH 4/4 tests/acpi: virt: update golden masters for DSDT

In reply to Andrew Jones

Differences between disassembled ASL files for DSDT:

@@ -5,13 +5,13 @@
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of a, Mon Jun 29 09:50:01 2020
+ * Disassembly of b, Mon Jun 29 09:50:03 2020
*
* Original Table Header:

  *     Signature        "DSDT"
- *     Length           0x000014BB (5307)
+ *     Length           0x00001455 (5205)
  *     Revision         0x02
- *     Checksum         0xD1
+ *     Checksum         0xE1
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPCDSDT"
  *     OEM Revision     0x00000001 (1)
@@ -45,32 +45,6 @@
             })
         }

- Device (FLS0)
- {

-            Name (_HID, "LNRO0015")  // _HID: Hardware ID
-            Name (_UID, Zero)  // _UID: Unique ID
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                Memory32Fixed (ReadWrite,
-                    0x00000000,         // Address Base
-                    0x04000000,         // Address Length
-                    )

- })
- }
-
- Device (FLS1)
- {

-            Name (_HID, "LNRO0015")  // _HID: Hardware ID
-            Name (_UID, One)  // _UID: Unique ID
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                Memory32Fixed (ReadWrite,
-                    0x04000000,         // Address Base
-                    0x04000000,         // Address Length
-                    )
-            })
-        }
-
         Device (FWCF)
         {
             Name (_HID, "QEMU0002")  // _HID: Hardware ID

The other two binaries have the same changes (the removal of the flash devices).

---
 tests/data/acpi/virt/DSDT                   | Bin 5307 -> 5205 bytes
 tests/data/acpi/virt/DSDT.memhp             | Bin 6668 -> 6566 bytes
 tests/data/acpi/virt/DSDT.numamem           | Bin 5307 -> 5205 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   3 ---
 4 files changed, 3 deletions(-)
tests/data/acpi/virt/DSDT binary +0 -0
index d6f5c617881c4247f55d4dcd06581f9693916b2f..e669508d175f1e3ddf355f8a9b0d419266cac8aa 100644
GIT binary patch
tests/data/acpi/virt/DSDT.memhp binary +0 -0
index 730e95a46d2cce0af011ffc051d7342beb8f1328..4cb81f692d73526542493a0c4da9c9793cc8366e 100644
GIT binary patch
tests/data/acpi/virt/DSDT.numamem binary +0 -0
index d6f5c617881c4247f55d4dcd06581f9693916b2f..e669508d175f1e3ddf355f8a9b0d419266cac8aa 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -3
index 32a401ae35fa..dfb8523c8bf4 100644
@@ -1,4 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/virt/DSDT",
-"tests/data/acpi/virt/DSDT.memhp",
-"tests/data/acpi/virt/DSDT.numamem",
Signature · 1 line
2.25.4
Reviewed-by on v1 4/4
#21 lore raw

Re: [PATCH 4/4] tests/acpi: virt: update golden masters for DSDT

Quoted 103 lines · Andrew Jones

Differences between disassembled ASL files for DSDT:

(quoted diff) +3 -29
@@ -5,13 +5,13 @@
  *
  * Disassembling to symbolic ASL+ operators
  *
- * Disassembly of a, Mon Jun 29 09:50:01 2020
+ * Disassembly of b, Mon Jun 29 09:50:03 2020
  *
  * Original Table Header:
  *     Signature        "DSDT"
- *     Length           0x000014BB (5307)
+ *     Length           0x00001455 (5205)
  *     Revision         0x02
- *     Checksum         0xD1
+ *     Checksum         0xE1
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPCDSDT"
  *     OEM Revision     0x00000001 (1)
@@ -45,32 +45,6 @@
             })
         }
 
-        Device (FLS0)
-        {
-            Name (_HID, "LNRO0015")  // _HID: Hardware ID
-            Name (_UID, Zero)  // _UID: Unique ID
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                Memory32Fixed (ReadWrite,
-                    0x00000000,         // Address Base
-                    0x04000000,         // Address Length
-                    )
-            })
-        }
-
-        Device (FLS1)
-        {
-            Name (_HID, "LNRO0015")  // _HID: Hardware ID
-            Name (_UID, One)  // _UID: Unique ID
-            Name (_CRS, ResourceTemplate ()  // _CRS: Current Resource Settings
-            {
-                Memory32Fixed (ReadWrite,
-                    0x04000000,         // Address Base
-                    0x04000000,         // Address Length
-                    )
-            })
-        }
-
         Device (FWCF)
         {
             Name (_HID, "QEMU0002")  // _HID: Hardware ID

The other two binaries have the same changes (the removal of the flash devices).

---
 tests/data/acpi/virt/DSDT                   | Bin 5307 -> 5205 bytes
 tests/data/acpi/virt/DSDT.memhp             | Bin 6668 -> 6566 bytes
 tests/data/acpi/virt/DSDT.numamem           | Bin 5307 -> 5205 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |   3 ---
 4 files changed, 3 deletions(-)
tests/data/acpi/virt/DSDT binary +0 -0
index d6f5c617881c4247f55d4dcd06581f9693916b2f..e669508d175f1e3ddf355f8a9b0d419266cac8aa 100644
GIT binary patch
tests/data/acpi/virt/DSDT.memhp binary +0 -0
index 730e95a46d2cce0af011ffc051d7342beb8f1328..4cb81f692d73526542493a0c4da9c9793cc8366e 100644
GIT binary patch
tests/data/acpi/virt/DSDT.numamem binary +0 -0
index d6f5c617881c4247f55d4dcd06581f9693916b2f..e669508d175f1e3ddf355f8a9b0d419266cac8aa 100644
GIT binary patch
tests/qtest/bios-tables-test-allowed-diff.h +0 -0
index 32a401ae35fa..dfb8523c8bf4 100644

tests/qtest/bios-tables-test-allowed-diff.h line 4

Quoted 4 lines
tests/qtest/bios-tables-test-allowed-diff.h +0 -3
@@ -1,4 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/virt/DSDT",
-"tests/data/acpi/virt/DSDT.memhp",
-"tests/data/acpi/virt/DSDT.numamem",
Reviewed-by on the v1 series
#22 lore raw
In reply to Andrew Jones
Quoted 8 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

This change was suggested by Ard and Laszlo.

Patch 3/4 is the meat. The other patches deal with updating qtest.

acpi things:

Quoted 20 lines

Thanks,
drew

Andrew Jones (4):
tests/acpi: remove stale allowed tables
tests/acpi: virt: allow DSDT acpi table changes hw/arm/virt-acpi-build: Only expose flash on older machine types tests/acpi: virt: update golden masters for DSDT

 hw/arm/virt-acpi-build.c                    |   5 ++++-
 hw/arm/virt.c                               |   3 +++
 include/hw/arm/virt.h                       |   1 +
 tests/data/acpi/virt/DSDT                   | Bin 5307 -> 5205 bytes
 tests/data/acpi/virt/DSDT.memhp             | Bin 6668 -> 6566 bytes
 tests/data/acpi/virt/DSDT.numamem           | Bin 5307 -> 5205 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |  18 ------------------
 7 files changed, 8 insertions(+), 19 deletions(-)
Signature · 1 line
2.25.4
Reviewed-by on the v1 series
#23 lore raw
In reply to Andrew Jones

Hi Drew,

Quoted 9 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

This change was suggested by Ard and Laszlo.

Patch 3/4 is the meat. The other patches deal with updating qtest.

Quoted 8 lines

Thanks,
drew

Andrew Jones (4):
tests/acpi: remove stale allowed tables
tests/acpi: virt: allow DSDT acpi table changes hw/arm/virt-acpi-build: Only expose flash on older machine types tests/acpi: virt: update golden masters for DSDT

SERIES:

Thanks

Eric

Quoted 10 lines
 hw/arm/virt-acpi-build.c                    |   5 ++++-
 hw/arm/virt.c                               |   3 +++
 include/hw/arm/virt.h                       |   1 +
 tests/data/acpi/virt/DSDT                   | Bin 5307 -> 5205 bytes
 tests/data/acpi/virt/DSDT.memhp             | Bin 6668 -> 6566 bytes
 tests/data/acpi/virt/DSDT.numamem           | Bin 5307 -> 5205 bytes
 tests/qtest/bios-tables-test-allowed-diff.h |  18 ------------------
 7 files changed, 8 insertions(+), 19 deletions(-)
#24 lore raw
In reply to Andrew Jones
Quoted 7 lines · Andrew Jones

The flash device is exclusively for the host-controlled firmware, so we should not expose it to the OS. Exposing it risks the OS messing with it, which could break firmware runtime services and surprise the OS when all its changes disappear after reboot.

This change was suggested by Ard and Laszlo.

Applied to target-arm.next, thanks.

-- PMM