On Wed, 10 Feb 2021 22:46:39 -0800 Isaku Yamahata <isaku.yamah...@intel.com> wrote:
> The following patch will introduce incompatible behavior of SMM. > Introduce a property to keep the old behavior for compatibility. > To enable smm compat, use "-machine x-smm-compat-5=on" just curious, why it has "-5" suffix also I'd drop x- prefix. > Signed-off-by: Isaku Yamahata <isaku.yamah...@intel.com> > --- > hw/i386/pc_piix.c | 10 ++++++---- > hw/i386/pc_q35.c | 1 + > hw/i386/x86.c | 18 ++++++++++++++++++ > include/hw/i386/x86.h | 2 ++ > 4 files changed, 27 insertions(+), 4 deletions(-) > > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c > index 6188c3e97e..87269e170e 100644 > --- a/hw/i386/pc_piix.c > +++ b/hw/i386/pc_piix.c > @@ -441,6 +441,7 @@ DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL, > static void pc_i440fx_5_2_machine_options(MachineClass *m) > { > pc_i440fx_6_0_machine_options(m); > + m->default_machine_opts = "firmware=bios-256k.bin,x-smm-compat-5=on"; did I point to a wrong example :/ smm machinery is part of ich9/piix4 devices, so it would be simpler by adding 'smm-compat' property to them diff --git a/hw/core/machine.c b/hw/core/machine.c index 970046f438..bcb0333ddf 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -36,7 +36,9 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-pci.h" -GlobalProperty hw_compat_5_2[] = {}; +GlobalProperty hw_compat_5_2[] = { it turns on compat mode on 5.2 and older machines types + { "ICH9-LPC", "smm-compat", "on"}, +}; const size_t hw_compat_5_2_len = G_N_ELEMENTS(hw_compat_5_2); GlobalProperty hw_compat_5_1[] = { diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index d3145bf014..13003b2ac2 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -774,6 +774,7 @@ static const VMStateDescription vmstate_ich9_lpc = { }; static Property ich9_lpc_properties[] = { default would be used on new and later machine types + DEFINE_PROP_BOOL("smm-compat", ICH9LPCState, pm.smm_compat , false), DEFINE_PROP_BOOL("noreboot", ICH9LPCState, pin_strap.spkr_hi, true), DEFINE_PROP_BIT64("x-smi-broadcast", ICH9LPCState, smi_host_features, ICH9_LPC_SMI_F_BROADCAST_BIT, true), then do the same for piix4 pm device > m->alias = NULL; > m->is_default = false; > compat_props_add(m->compat_props, hw_compat_5_2, hw_compat_5_2_len); > @@ -664,7 +665,8 @@ static void pc_i440fx_2_2_machine_options(MachineClass *m) > > pc_i440fx_2_3_machine_options(m); > m->hw_version = "2.2.0"; > - m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on"; > + m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on" > + ",x-smm-compat-5=on"; > compat_props_add(m->compat_props, hw_compat_2_2, hw_compat_2_2_len); > compat_props_add(m->compat_props, pc_compat_2_2, pc_compat_2_2_len); > pcmc->rsdp_in_ram = false; > @@ -727,7 +729,7 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m) > > pc_i440fx_2_0_machine_options(m); > m->hw_version = "1.7.0"; > - m->default_machine_opts = NULL; > + m->default_machine_opts = "x-smm-compat-5=on"; > m->option_rom_has_mr = true; > compat_props_add(m->compat_props, pc_compat_1_7, pc_compat_1_7_len); > pcmc->smbios_defaults = false; > @@ -999,7 +1001,7 @@ static void xenfv_4_2_machine_options(MachineClass *m) > pc_i440fx_4_2_machine_options(m); > m->desc = "Xen Fully-virtualized PC"; > m->max_cpus = HVM_MAX_VCPUS; > - m->default_machine_opts = "accel=xen,suppress-vmdesc=on"; > + m->default_machine_opts = > "accel=xen,suppress-vmdesc=on,x-smm-compat-5=on"; > } > > DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init, > @@ -1011,7 +1013,7 @@ static void xenfv_3_1_machine_options(MachineClass *m) > m->desc = "Xen Fully-virtualized PC"; > m->alias = "xenfv"; > m->max_cpus = HVM_MAX_VCPUS; > - m->default_machine_opts = "accel=xen,suppress-vmdesc=on"; > + m->default_machine_opts = > "accel=xen,suppress-vmdesc=on,x-smm-compat-5=on"; > } > > DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init, > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c > index 0a212443aa..14974b7255 100644 > --- a/hw/i386/pc_q35.c > +++ b/hw/i386/pc_q35.c > @@ -358,6 +358,7 @@ DEFINE_Q35_MACHINE(v6_0, "pc-q35-6.0", NULL, > static void pc_q35_5_2_machine_options(MachineClass *m) > { > pc_q35_6_0_machine_options(m); > + m->default_machine_opts = "firmware=bios-256k.bin,x-smm-compat-5=on"; > m->alias = NULL; > compat_props_add(m->compat_props, hw_compat_5_2, hw_compat_5_2_len); > compat_props_add(m->compat_props, pc_compat_5_2, pc_compat_5_2_len); > diff --git a/hw/i386/x86.c b/hw/i386/x86.c > index 6329f90ef9..00eb2253d3 100644 > --- a/hw/i386/x86.c > +++ b/hw/i386/x86.c > @@ -1174,6 +1174,18 @@ static void x86_machine_set_smm(Object *obj, Visitor > *v, const char *name, > visit_type_OnOffAuto(v, name, &x86ms->smm, errp); > } > > +static bool x86_machine_get_smm_compat_5(Object *obj, Error **errp) > +{ > + X86MachineState *x86ms = X86_MACHINE(obj); > + return x86ms->smm_compat_5; > +} > + > +static void x86_machine_set_smm_compat_5(Object *obj, bool value, Error > **errp) > +{ > + X86MachineState *x86ms = X86_MACHINE(obj); > + x86ms->smm_compat_5 = value; > +} > + > bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms) > { > if (x86ms->acpi == ON_OFF_AUTO_OFF) { > @@ -1204,6 +1216,7 @@ static void x86_machine_initfn(Object *obj) > X86MachineState *x86ms = X86_MACHINE(obj); > > x86ms->smm = ON_OFF_AUTO_AUTO; > + x86ms->smm_compat_5 = false; > x86ms->acpi = ON_OFF_AUTO_AUTO; > x86ms->smp_dies = 1; > x86ms->pci_irq_mask = ACPI_BUILD_PCI_IRQS; > @@ -1228,6 +1241,11 @@ static void x86_machine_class_init(ObjectClass *oc, > void *data) > object_class_property_set_description(oc, X86_MACHINE_SMM, > "Enable SMM"); > > + object_class_property_add_bool(oc, X86_MACHINE_SMM_COMPAT_5, > + x86_machine_get_smm_compat_5, x86_machine_set_smm_compat_5); > + object_class_property_set_description(oc, X86_MACHINE_SMM_COMPAT_5, > + "Enable SMM compatible behavior"); > + > object_class_property_add(oc, X86_MACHINE_ACPI, "OnOffAuto", > x86_machine_get_acpi, x86_machine_set_acpi, > NULL, NULL); > diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h > index 56080bd1fb..3dbe19a335 100644 > --- a/include/hw/i386/x86.h > +++ b/include/hw/i386/x86.h > @@ -65,6 +65,7 @@ struct X86MachineState { > unsigned smp_dies; > > OnOffAuto smm; > + bool smm_compat_5; > OnOffAuto acpi; > > /* > @@ -75,6 +76,7 @@ struct X86MachineState { > }; > > #define X86_MACHINE_SMM "smm" > +#define X86_MACHINE_SMM_COMPAT_5 "x-smm-compat-5" > #define X86_MACHINE_ACPI "acpi" > > #define TYPE_X86_MACHINE MACHINE_TYPE_NAME("x86")