diff mbox

[3/3] target-i386: Enable x2apic by default on KVM

Message ID 1392821892-26682-4-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost Feb. 19, 2014, 2:58 p.m. UTC
When on KVM mode, enable x2apic by default on all CPU models.

Normally we try to keep the CPU model definitions as close as the real
CPUs as possible, but x2apic can be emulated by KVM without host CPU
support for x2apic, and it improves performance by reducing APIC access
overhead. x2apic emulation is available on KVM since 2009 (Linux
2.6.32-rc1), there's no reason for not enabling x2apic by default when
running KVM.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/i386/pc_piix.c | 1 +
 hw/i386/pc_q35.c  | 2 ++
 target-i386/cpu.c | 1 +
 3 files changed, 4 insertions(+)

Comments

Andreas Färber March 12, 2014, 2:36 p.m. UTC | #1
Am 19.02.2014 15:58, schrieb Eduardo Habkost:
> When on KVM mode, enable x2apic by default on all CPU models.
> 
> Normally we try to keep the CPU model definitions as close as the real
> CPUs as possible, but x2apic can be emulated by KVM without host CPU
> support for x2apic, and it improves performance by reducing APIC access
> overhead. x2apic emulation is available on KVM since 2009 (Linux
> 2.6.32-rc1), there's no reason for not enabling x2apic by default when
> running KVM.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  hw/i386/pc_piix.c | 1 +
>  hw/i386/pc_q35.c  | 2 ++
>  target-i386/cpu.c | 1 +
>  3 files changed, 4 insertions(+)
> 
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index dab0c78..cf12873 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -260,6 +260,7 @@ static void pc_compat_1_7(QEMUMachineInitArgs *args)
>  {
>      smbios_type1_defaults = false;
>      gigabyte_align = false;
> +    x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
>  }
>  
>  static void pc_compat_1_6(QEMUMachineInitArgs *args)
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index a7f6260..71b05f1 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -244,6 +244,8 @@ static void pc_compat_1_7(QEMUMachineInitArgs *args)
>  {
>      smbios_type1_defaults = false;
>      gigabyte_align = false;
> +    x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
> +
>  }
>  
>  static void pc_compat_1_6(QEMUMachineInitArgs *args)
[snip]

Needed rebase:

diff --cc hw/i386/pc_piix.c
index 5011c3a,ebd442e..0000000
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@@ -266,7 -266,7 +266,8 @@@ static void pc_compat_1_7(QEMUMachineIn
  {
      smbios_type1_defaults = false;
      gigabyte_align = false;
 +    option_rom_has_mr = true;
+     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
  }

  static void pc_compat_1_6(QEMUMachineInitArgs *args)
diff --cc hw/i386/pc_q35.c
index 4b0456a,71b05f1..0000000
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@@ -244,7 -244,8 +244,8 @@@ static void pc_compat_1_7(QEMUMachineIn
  {
      smbios_type1_defaults = false;
      gigabyte_align = false;
 +    option_rom_has_mr = true;
+     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
 -
  }

  static void pc_compat_1_6(QEMUMachineInitArgs *args)

Andreas
Eduardo Habkost March 12, 2014, 3:42 p.m. UTC | #2
On Wed, Mar 12, 2014 at 03:36:02PM +0100, Andreas Färber wrote:
[...]
> [snip]
> 
> Needed rebase:
> 
> diff --cc hw/i386/pc_piix.c
> index 5011c3a,ebd442e..0000000
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@@ -266,7 -266,7 +266,8 @@@ static void pc_compat_1_7(QEMUMachineIn
>   {
>       smbios_type1_defaults = false;
>       gigabyte_align = false;
>  +    option_rom_has_mr = true;
> +     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
>   }
> 
>   static void pc_compat_1_6(QEMUMachineInitArgs *args)
> diff --cc hw/i386/pc_q35.c
> index 4b0456a,71b05f1..0000000
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@@ -244,7 -244,8 +244,8 @@@ static void pc_compat_1_7(QEMUMachineIn
>   {
>       smbios_type1_defaults = false;
>       gigabyte_align = false;
>  +    option_rom_has_mr = true;
> +     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
>  -
>   }
> 
>   static void pc_compat_1_6(QEMUMachineInitArgs *args)

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

(I am guessing there's no need to resubmit. That's right?)
Andreas Färber March 12, 2014, 4:49 p.m. UTC | #3
Am 12.03.2014 16:42, schrieb Eduardo Habkost:
> On Wed, Mar 12, 2014 at 03:36:02PM +0100, Andreas Färber wrote:
> [...]
>> [snip]
>>
>> Needed rebase:
>>
>> diff --cc hw/i386/pc_piix.c
>> index 5011c3a,ebd442e..0000000
>> --- a/hw/i386/pc_piix.c
>> +++ b/hw/i386/pc_piix.c
>> @@@ -266,7 -266,7 +266,8 @@@ static void pc_compat_1_7(QEMUMachineIn
>>   {
>>       smbios_type1_defaults = false;
>>       gigabyte_align = false;
>>  +    option_rom_has_mr = true;
>> +     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
>>   }
>>
>>   static void pc_compat_1_6(QEMUMachineInitArgs *args)
>> diff --cc hw/i386/pc_q35.c
>> index 4b0456a,71b05f1..0000000
>> --- a/hw/i386/pc_q35.c
>> +++ b/hw/i386/pc_q35.c
>> @@@ -244,7 -244,8 +244,8 @@@ static void pc_compat_1_7(QEMUMachineIn
>>   {
>>       smbios_type1_defaults = false;
>>       gigabyte_align = false;
>>  +    option_rom_has_mr = true;
>> +     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
>>  -
>>   }
>>
>>   static void pc_compat_1_6(QEMUMachineInitArgs *args)
> 
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> 
> (I am guessing there's no need to resubmit. That's right?)

Right, just FYI that there's changes happening on my branch and that
things are still being prepared and retested for submission.

Andreas
diff mbox

Patch

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index dab0c78..cf12873 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -260,6 +260,7 @@  static void pc_compat_1_7(QEMUMachineInitArgs *args)
 {
     smbios_type1_defaults = false;
     gigabyte_align = false;
+    x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
 }
 
 static void pc_compat_1_6(QEMUMachineInitArgs *args)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a7f6260..71b05f1 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -244,6 +244,8 @@  static void pc_compat_1_7(QEMUMachineInitArgs *args)
 {
     smbios_type1_defaults = false;
     gigabyte_align = false;
+    x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
+
 }
 
 static void pc_compat_1_6(QEMUMachineInitArgs *args)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index d65ca26..089328e 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -369,6 +369,7 @@  static uint32_t kvm_default_features[FEATURE_WORDS] = {
         (1 << KVM_FEATURE_STEAL_TIME) |
         (1 << KVM_FEATURE_PV_EOI) |
         (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT),
+    [FEAT_1_ECX] = CPUID_EXT_X2APIC,
 };
 
 void x86_cpu_compat_disable_kvm_features(FeatureWord w, uint32_t features)