Skip to contentSkip to conversation

x86: Check for machine state object class before typecasting it

PATCH In review Michal Privoznik 4 participants 8 messages Dec 30, 2019 – Jan 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Check for machine state object class before typecasting it

In v4.2.0-246-ged9e923c3c the SMM property was moved from PC machine class to x86 machine class. Makes sense, but the change was too aggressive: in target/i386/kvm.c:kvm_arch_init() it altered check which sets SMRAM if given machine has SMM enabled. The line that detects whether given machine object is class of PC_MACHINE was removed from the check. This makes qemu try to enable SMRAM for all machine types, which is not what we want.

---
 target/i386/kvm.c | 1 +
 1 file changed, 1 insertion(+)
target/i386/kvm.c +1 -0
index 0b511906e3..7ee3202634 100644
@@ -2173,6 +2173,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
     }
 
     if (kvm_check_extension(s, KVM_CAP_X86_SMM) &&
+        object_dynamic_cast(OBJECT(ms), TYPE_X86_MACHINE) &&
         x86_machine_is_smm_enabled(X86_MACHINE(ms))) {
         smram_machine_done.notify = register_smram_listener;
         qemu_add_machine_init_done_notifier(&smram_machine_done);
Signature · 1 line
2.24.1
#1 lore raw
Patchew URL: https://patchew.org/QEMU/7cc91bab3191bfd7e071bdd3fdf7fe2a2991deb0.1577692822.git.mprivozn@redhat.com/

Patchew URL: https://patchew.org/QEMU/7cc91bab3191bfd7e071bdd3fdf7fe2a2991deb0.1577692822.git.mprivozn@redhat.com/

Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===

The full log is available at
http://patchew.org/logs/7cc91bab3191bfd7e071bdd3fdf7fe2a2991deb0.1577692822.git.mprivozn@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

Reviewed-by on v1 1/1
#2 lore raw
In reply to Michal Privoznik
Quoted 1 line · Michal Privoznik

In v4.2.0-246-ged9e923c3c the SMM property was moved from PC

Typo v4.2.0-246-ged9e923c3c -> ed9e923c3c.

Quoted 7 lines

machine class to x86 machine class. Makes sense, but the change was too aggressive: in target/i386/kvm.c:kvm_arch_init() it altered check which sets SMRAM if given machine has SMM enabled. The line that detects whether given machine object is class of PC_MACHINE was removed from the check. This makes qemu try to enable SMRAM for all machine types, which is not what we want.

Quoted 18 lines
---
  target/i386/kvm.c | 1 +
  1 file changed, 1 insertion(+)
target/i386/kvm.c +1 -0
index 0b511906e3..7ee3202634 100644
@@ -2173,6 +2173,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
      }
 
      if (kvm_check_extension(s, KVM_CAP_X86_SMM) &&
+        object_dynamic_cast(OBJECT(ms), TYPE_X86_MACHINE) &&
          x86_machine_is_smm_enabled(X86_MACHINE(ms))) {
          smram_machine_done.notify = register_smram_listener;
          qemu_add_machine_init_done_notifier(&smram_machine_done);
#3 lore raw
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line · Michal Privoznik

In v4.2.0-246-ged9e923c3c the SMM property was moved from PC

Typo v4.2.0-246-ged9e923c3c -> ed9e923c3c.

This depends on how you format the hash :-)
I've used 'git describe ed9e923c3c' because I find it more readable for us humans (at least we see what version the commit was introduced in). But I don't know what the praxis is in qemu.

Quoted 11 lines
Quoted 8 lines

machine class to x86 machine class. Makes sense, but the change was too aggressive: in target/i386/kvm.c:kvm_arch_init() it altered check which sets SMRAM if given machine has SMM enabled. The line that detects whether given machine object is class of PC_MACHINE was removed from the check. This makes qemu try to enable SMRAM for all machine types, which is not what we want.

Thanks,
Michal

#4 lore raw
Quoted 10 lines · Michal Prívozník
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line · Michal Privoznik

In v4.2.0-246-ged9e923c3c the SMM property was moved from PC

Typo v4.2.0-246-ged9e923c3c -> ed9e923c3c.

This depends on how you format the hash :-)
I've used 'git describe ed9e923c3c' because I find it more readable for us humans (at least we see what version the commit was introduced in). But I don't know what the praxis is in qemu.

Hmm I never used it. Your explanation makes sense, but the tag confused me because I don't have it locally. However git (and gitk) seems clever enough to only use the useful part:

$ git show randomcrap-ged9e923c3c
commit ed9e923c3c9a2c50c4e82ba178b3fb1feba56867
Author: Paolo Bonzini <[email protected]>
Date:   Thu Dec 12 17:28:01 2019 +0100

x86: move SMM property to X86MachineState

FYI My output is different:

$ git describe ed9e923c3c
pull-target-arm-20191216-1-199-ged9e923c3c
Quoted 14 lines
Quoted 10 lines
Quoted 7 lines

machine class to x86 machine class. Makes sense, but the change was too aggressive: in target/i386/kvm.c:kvm_arch_init() it altered check which sets SMRAM if given machine has SMM enabled. The line that detects whether given machine object is class of PC_MACHINE was removed from the check. This makes qemu try to enable SMRAM for all machine types, which is not what we want.

Thanks,
Michal

#5 lore raw
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Michal Prívozník
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line · Michal Privoznik

In v4.2.0-246-ged9e923c3c the SMM property was moved from PC

Typo v4.2.0-246-ged9e923c3c -> ed9e923c3c.

Quoted 8 lines
Quoted 4 lines

This depends on how you format the hash :-)
I've used 'git describe ed9e923c3c' because I find it more readable for us humans (at least we see what version the commit was introduced in). But I don't know what the praxis is in qemu.

Hmm I never used it. Your explanation makes sense, but the tag confused me because I don't have it locally. However git (and gitk) seems clever enough to only use the useful part:

The v4.2.0 tag is in origin. I wonder how come you do not have it.

Quoted 6 lines
$ git show randomcrap-ged9e923c3c
commit ed9e923c3c9a2c50c4e82ba178b3fb1feba56867
Author: Paolo Bonzini <[email protected]>
Date:   Thu Dec 12 17:28:01 2019 +0100
Quoted 6 lines

    x86: move SMM property to X86MachineState

FYI My output is different:

$ git describe ed9e923c3c
pull-target-arm-20191216-1-199-ged9e923c3c

You may want to use 'git describe --tags --match "v*" $commit'

But again, feel free to change it to whatever you/committer wants.

Michal

#6 lore raw
Quoted 25 lines · Michal Prívozník
Quoted 7 lines · Philippe Mathieu-Daudé
Quoted 6 lines · Michal Prívozník
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line · Michal Privoznik

In v4.2.0-246-ged9e923c3c the SMM property was moved from PC

Typo v4.2.0-246-ged9e923c3c -> ed9e923c3c.

Quoted 8 lines
Quoted 4 lines

This depends on how you format the hash :-)
I've used 'git describe ed9e923c3c' because I find it more readable for us humans (at least we see what version the commit was introduced in). But I don't know what the praxis is in qemu.

Hmm I never used it. Your explanation makes sense, but the tag confused me because I don't have it locally. However git (and gitk) seems clever enough to only use the useful part:

The v4.2.0 tag is in origin. I wonder how come you do not have it.

Quoted 6 lines
$ git show randomcrap-ged9e923c3c
commit ed9e923c3c9a2c50c4e82ba178b3fb1feba56867
Author: Paolo Bonzini <[email protected]>
Date:   Thu Dec 12 17:28:01 2019 +0100
Quoted 8 lines
Quoted 6 lines

    x86: move SMM property to X86MachineState

FYI My output is different:

$ git describe ed9e923c3c
pull-target-arm-20191216-1-199-ged9e923c3c

You may want to use 'git describe --tags --match "v*" $commit'

Oh yes I have it :>

$ git describe --tags --match "v*" ed9e923c3c
v4.2.0-246-ged9e923c3c

The difference seems to be I have other tags between v4.2.0 and ed9e923c3c, and git-describe choose the closest (newer?).

Quoted 2 lines

But again, feel free to change it to whatever you/committer wants.

This is fine, no problem, today I learned something new :)

#7 lore raw
In reply to Michal Prívozník
Quoted 13 lines · Michal Prívozník
Quoted 12 lines · Philippe Mathieu-Daudé
Quoted 10 lines · Michal Prívozník
Quoted 4 lines · Philippe Mathieu-Daudé
Quoted 1 line · Michal Privoznik

In v4.2.0-246-ged9e923c3c the SMM property was moved from PC

Typo v4.2.0-246-ged9e923c3c -> ed9e923c3c.

This depends on how you format the hash :-)
I've used 'git describe ed9e923c3c' because I find it more readable for us humans (at least we see what version the commit was introduced in). But I don't know what the praxis is in qemu.

Quoted 8 lines
Quoted 3 lines

Hmm I never used it. Your explanation makes sense, but the tag confused me because I don't have it locally. However git (and gitk) seems clever enough to only use the useful part:

The v4.2.0 tag is in origin. I wonder how come you do not have it.

Quoted 2 lines
$ git show randomcrap-ged9e923c3c

Cool, I didn't know this. I usually format it like

ed9e923c3c ("x86: move SMM property to X86MachineState", 2019-12-17)

I can see why most developers don't use "git describe", because at least those that also are maintainers will often have intermediate tags after a release.

Anyway I've queued this patch, thanks.

Paolo