diff mbox

[2/2] Make kvm_enabled unavailable to non-target devices

Message ID v2xf43fc5581004020846y1c0558b5m6d948a9ed59c7a82@mail.gmail.com
State New
Headers show

Commit Message

Blue Swirl April 2, 2010, 3:46 p.m. UTC
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 hw/acpi.c   |   10 +++++-----
 hw/pc.h     |    2 +-
 hw/poison.h |    3 +++
 3 files changed, 9 insertions(+), 6 deletions(-)

Comments

Anthony Liguori April 2, 2010, 4:25 p.m. UTC | #1
On 04/02/2010 10:46 AM, Blue Swirl wrote:
> Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
> ---
>   hw/acpi.c   |   10 +++++-----
>   hw/pc.h     |    2 +-
>   hw/poison.h |    3 +++
>   3 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/hw/acpi.c b/hw/acpi.c
> index 5c01c2e..7c2b109 100644
> --- a/hw/acpi.c
> +++ b/hw/acpi.c
> @@ -51,7 +51,7 @@ typedef struct PIIX4PMState {
>       qemu_irq irq;
>       qemu_irq cmos_s3;
>       qemu_irq smi_irq;
> -    int kvm_enabled;
> +    int kvm_is_enabled;
>   } PIIX4PMState;
>
>   #define RSM_STS (1<<  15)
> @@ -482,7 +482,7 @@ static void piix4_reset(void *opaque)
>       pci_conf[0x5a] = 0;
>       pci_conf[0x5b] = 0;
>
> -    if (s->kvm_enabled) {
> +    if (s->kvm_is_enabled) {
>           /* Mark SMM as already inited (until KVM supports SMM). */
>           pci_conf[0x5B] = 0x02;
>       }
> @@ -502,7 +502,7 @@ static void piix4_powerdown(void *opaque, int irq,
> int power_failing)
>
>   i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
>                          qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
> -                       int kvm_enabled)
> +                       int kvm_is_enabled)
>   {
>       PIIX4PMState *s;
>       uint8_t *pci_conf;
> @@ -529,8 +529,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn,
> uint32_t smb_io_base,
>
>       register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s);
>
> -    s->kvm_enabled = kvm_enabled;
> -    if (s->kvm_enabled) {
> +    s->kvm_is_enabled = kvm_is_enabled;
> +    if (s->kvm_is_enabled) {
>           /* Mark SMM as already inited to prevent SMM from running.
> KVM does not
>            * support SMM mode. */
>           pci_conf[0x5B] = 0x02;
> diff --git a/hw/pc.h b/hw/pc.h
> index 5f86b37..08a541d 100644
> --- a/hw/pc.h
> +++ b/hw/pc.h
> @@ -92,7 +92,7 @@ int acpi_table_add(const char *table_desc);
>
>   i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
>                          qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
> -                       int kvm_enabled);
> +                       int kvm_is_enabled);
>   void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
>   void piix4_acpi_system_hot_add_init(PCIBus *bus);
>
> diff --git a/hw/poison.h b/hw/poison.h
> index d7db7f4..18b9657 100644
> --- a/hw/poison.h
> +++ b/hw/poison.h
> @@ -46,5 +46,8 @@
>   #pragma GCC poison CPU_INTERRUPT_VIRQ
>   #pragma GCC poison CPU_INTERRUPT_NMI
>
> +#pragma GCC poison kvm_allowed
> +#pragma GCC poison kvm_enabled
>
>    

kvm_enabled() is a macro.  I dont' think this poison pragma is actually 
meaningful.

Regards,

Anthony Liguori

>   #endif
>   #endif
>
Blue Swirl April 2, 2010, 4:33 p.m. UTC | #2
On 4/2/10, Anthony Liguori <anthony@codemonkey.ws> wrote:
> On 04/02/2010 10:46 AM, Blue Swirl wrote:
>
> > Signed-off-by: Blue Swirl<blauwirbel@gmail.com>
> > ---
> >  hw/acpi.c   |   10 +++++-----
> >  hw/pc.h     |    2 +-
> >  hw/poison.h |    3 +++
> >  3 files changed, 9 insertions(+), 6 deletions(-)
> >
> > diff --git a/hw/acpi.c b/hw/acpi.c
> > index 5c01c2e..7c2b109 100644
> > --- a/hw/acpi.c
> > +++ b/hw/acpi.c
> > @@ -51,7 +51,7 @@ typedef struct PIIX4PMState {
> >      qemu_irq irq;
> >      qemu_irq cmos_s3;
> >      qemu_irq smi_irq;
> > -    int kvm_enabled;
> > +    int kvm_is_enabled;
> >  } PIIX4PMState;
> >
> >  #define RSM_STS (1<<  15)
> > @@ -482,7 +482,7 @@ static void piix4_reset(void *opaque)
> >      pci_conf[0x5a] = 0;
> >      pci_conf[0x5b] = 0;
> >
> > -    if (s->kvm_enabled) {
> > +    if (s->kvm_is_enabled) {
> >          /* Mark SMM as already inited (until KVM supports SMM). */
> >          pci_conf[0x5B] = 0x02;
> >      }
> > @@ -502,7 +502,7 @@ static void piix4_powerdown(void *opaque, int irq,
> > int power_failing)
> >
> >  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> >                         qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq
> smi_irq,
> > -                       int kvm_enabled)
> > +                       int kvm_is_enabled)
> >  {
> >      PIIX4PMState *s;
> >      uint8_t *pci_conf;
> > @@ -529,8 +529,8 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn,
> > uint32_t smb_io_base,
> >
> >      register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4,
> acpi_dbg_writel, s);
> >
> > -    s->kvm_enabled = kvm_enabled;
> > -    if (s->kvm_enabled) {
> > +    s->kvm_is_enabled = kvm_is_enabled;
> > +    if (s->kvm_is_enabled) {
> >          /* Mark SMM as already inited to prevent SMM from running.
> > KVM does not
> >           * support SMM mode. */
> >          pci_conf[0x5B] = 0x02;
> > diff --git a/hw/pc.h b/hw/pc.h
> > index 5f86b37..08a541d 100644
> > --- a/hw/pc.h
> > +++ b/hw/pc.h
> > @@ -92,7 +92,7 @@ int acpi_table_add(const char *table_desc);
> >
> >  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
> >                         qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq
> smi_irq,
> > -                       int kvm_enabled);
> > +                       int kvm_is_enabled);
> >  void piix4_smbus_register_device(SMBusDevice *dev,
> uint8_t addr);
> >  void piix4_acpi_system_hot_add_init(PCIBus *bus);
> >
> > diff --git a/hw/poison.h b/hw/poison.h
> > index d7db7f4..18b9657 100644
> > --- a/hw/poison.h
> > +++ b/hw/poison.h
> > @@ -46,5 +46,8 @@
> >  #pragma GCC poison CPU_INTERRUPT_VIRQ
> >  #pragma GCC poison CPU_INTERRUPT_NMI
> >
> > +#pragma GCC poison kvm_allowed
> > +#pragma GCC poison kvm_enabled
> >
> >
> >
>
>  kvm_enabled() is a macro.  I dont' think this poison pragma is actually
> meaningful.

I'm not familiar with poison pragmas, but actually poisoning only
kvm_allowed didn't work.
Paolo Bonzini April 2, 2010, 4:47 p.m. UTC | #3
>>> +#pragma GCC poison kvm_allowed
>>> +#pragma GCC poison kvm_enabled
>>
>>   kvm_enabled() is a macro.  I dont' think this poison pragma is actually
>> meaningful.
>
> I'm not familiar with poison pragmas, but actually poisoning only
> kvm_allowed didn't work.

Indeed, macro expansions are explicitly allowed to use poisoned 
identifiers (and on the contrary macro names count towards poisoning 
errors).

IMO kvm_allowed should be left unpoisoned.

Paolo
Anthony Liguori April 2, 2010, 4:57 p.m. UTC | #4
On 04/02/2010 11:47 AM, Paolo Bonzini wrote:
>
>>>> +#pragma GCC poison kvm_allowed
>>>> +#pragma GCC poison kvm_enabled
>>>
>>>   kvm_enabled() is a macro.  I dont' think this poison pragma is 
>>> actually
>>> meaningful.
>>
>> I'm not familiar with poison pragmas, but actually poisoning only
>> kvm_allowed didn't work.
>
> Indeed, macro expansions are explicitly allowed to use poisoned 
> identifiers (and on the contrary macro names count towards poisoning 
> errors).
>
> IMO kvm_allowed should be left unpoisoned.

Interesting, thanks.

Regards,

Anthony Liguori

> Paolo
diff mbox

Patch

diff --git a/hw/acpi.c b/hw/acpi.c
index 5c01c2e..7c2b109 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -51,7 +51,7 @@  typedef struct PIIX4PMState {
     qemu_irq irq;
     qemu_irq cmos_s3;
     qemu_irq smi_irq;
-    int kvm_enabled;
+    int kvm_is_enabled;
 } PIIX4PMState;

 #define RSM_STS (1 << 15)
@@ -482,7 +482,7 @@  static void piix4_reset(void *opaque)
     pci_conf[0x5a] = 0;
     pci_conf[0x5b] = 0;

-    if (s->kvm_enabled) {
+    if (s->kvm_is_enabled) {
         /* Mark SMM as already inited (until KVM supports SMM). */
         pci_conf[0x5B] = 0x02;
     }
@@ -502,7 +502,7 @@  static void piix4_powerdown(void *opaque, int irq,
int power_failing)

 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
-                       int kvm_enabled)
+                       int kvm_is_enabled)
 {
     PIIX4PMState *s;
     uint8_t *pci_conf;
@@ -529,8 +529,8 @@  i2c_bus *piix4_pm_init(PCIBus *bus, int devfn,
uint32_t smb_io_base,

     register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s);

-    s->kvm_enabled = kvm_enabled;
-    if (s->kvm_enabled) {
+    s->kvm_is_enabled = kvm_is_enabled;
+    if (s->kvm_is_enabled) {
         /* Mark SMM as already inited to prevent SMM from running.
KVM does not
          * support SMM mode. */
         pci_conf[0x5B] = 0x02;
diff --git a/hw/pc.h b/hw/pc.h
index 5f86b37..08a541d 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -92,7 +92,7 @@  int acpi_table_add(const char *table_desc);

 i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
                        qemu_irq sci_irq, qemu_irq cmos_s3, qemu_irq smi_irq,
-                       int kvm_enabled);
+                       int kvm_is_enabled);
 void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
 void piix4_acpi_system_hot_add_init(PCIBus *bus);

diff --git a/hw/poison.h b/hw/poison.h
index d7db7f4..18b9657 100644
--- a/hw/poison.h
+++ b/hw/poison.h
@@ -46,5 +46,8 @@ 
 #pragma GCC poison CPU_INTERRUPT_VIRQ
 #pragma GCC poison CPU_INTERRUPT_NMI

+#pragma GCC poison kvm_allowed
+#pragma GCC poison kvm_enabled
+
 #endif
 #endif