From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:52156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOqxj-000877-6A for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:20:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOqxY-0006WP-TP for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:20:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOqxY-0006WH-Kn for qemu-devel@nongnu.org; Thu, 18 Oct 2012 10:20:28 -0400 Date: Thu, 18 Oct 2012 16:22:13 +0200 From: "Michael S. Tsirkin" Message-ID: <20121018142213.GB24971@redhat.com> References: <20121017221548.GA14428@redhat.com> <50800E92.9060209@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <50800E92.9060209@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv2] qemu: enable PV EOI for qemu 1.3 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: Anthony Liguori , Eduardo Habkost , Jan Kiszka , Don Slutz , qemu-devel@nongnu.org, Blue Swirl , Igor Mammedov On Thu, Oct 18, 2012 at 04:13:38PM +0200, Andreas F=E4rber wrote: > Am 18.10.2012 00:15, schrieb Michael S. Tsirkin: > > Enable KVM PV EOI by default. You can still disable it with > > -kvm_pv_eoi cpu flag. To avoid breaking cross-version migration, > > enable only for qemu 1.3 (or in the future, newer) machine type. > >=20 > > Signed-off-by: Michael S. Tsirkin > > --- > >=20 > > Changes from v1: > > Address comments by Eduardo: > > use include instead of duplicate definition > > reduce ifdef spagetti in code using features mask > > rename init from _pv_eoi to _1_3 to enable adding > > more stuff in this version > >=20 > > hw/pc_piix.c | 15 ++++++++++++++- > > target-i386/cpu.c | 33 ++++++++++++++++++++------------- > > target-i386/cpu.h | 2 ++ > > 3 files changed, 36 insertions(+), 14 deletions(-) > >=20 > > diff --git a/hw/pc_piix.c b/hw/pc_piix.c > > index 82364ab..607de77 100644 > > --- a/hw/pc_piix.c > > +++ b/hw/pc_piix.c > > @@ -43,6 +43,7 @@ > > #include "xen.h" > > #include "memory.h" > > #include "exec-memory.h" > > +#include "cpu.h" > > #ifdef CONFIG_XEN > > # include > > #endif > > @@ -301,6 +302,18 @@ static void pc_init_pci(ram_addr_t ram_size, > > initrd_filename, cpu_model, 1, 1); > > } > > =20 > > +static void pc_init_pci_1_3(ram_addr_t ram_size, > > + const char *boot_device, > > + const char *kernel_filename, > > + const char *kernel_cmdline, > > + const char *initrd_filename, > > + const char *cpu_model) >=20 > Indentation was not adapted to name change? >=20 > > +{ > > + enable_kvm_pv_eoi(); > > + pc_init_pci(ram_size, boot_device, kernel_filename, > > + kernel_cmdline, initrd_filename, cpu_model); >=20 > There's two tabs here. >=20 > Thought you wanted to s/pc_init_pci/pc_init_pci_1_2/g and name this > pc_init_pci()? I decided it's not worth it - better keep the patch small. > Are you expecting there to be a pc_init_pci_1_4()? I don't know. Maybe we will be able to stick to .. _1_3 for the next 10 revisions. > > +} > > + > > static void pc_init_pci_no_kvmclock(ram_addr_t ram_size, > > const char *boot_device, > > const char *kernel_filename, > > @@ -353,7 +366,7 @@ static QEMUMachine pc_machine_v1_3 =3D { > > .name =3D "pc-1.3", > > .alias =3D "pc", > > .desc =3D "Standard PC", > > - .init =3D pc_init_pci, > > + .init =3D pc_init_pci_1_3, > > .max_cpus =3D 255, > > .is_default =3D 1, > > }; > > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > > index f3708e6..5f316b3 100644 > > --- a/target-i386/cpu.c > > +++ b/target-i386/cpu.c > > @@ -124,6 +124,20 @@ typedef struct model_features_t { > > int check_cpuid =3D 0; > > int enforce_cpuid =3D 0; > > =20 > > +#if defined(CONFIG_KVM) > > +static uint32_t kvm_default_features =3D (1 << KVM_FEATURE_CLOCKSOUR= CE) | > > + (1 << KVM_FEATURE_NOP_IO_DELAY) |=20 > > + (1 << KVM_FEATURE_MMU_OP) | > > + (1 << KVM_FEATURE_CLOCKSOURCE2) | > > + (1 << KVM_FEATURE_ASYNC_PF) |=20 > > + (1 << KVM_FEATURE_STEAL_TIME) | > > + (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); > > +static const uint32_t kvm_pv_eoi_features =3D (0x1 << KVM_FEATURE_PV= _EOI); > > +#else > > +static uint32_t kvm_default_features =3D 0; > > +static const uint32_t kvm_pv_eoi_features =3D 0; > > +#endif > > + > > void host_cpuid(uint32_t function, uint32_t count, > > uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_= t *edx) > > { > > @@ -1107,7 +1121,7 @@ static int cpu_x86_find_by_name(x86_def_t *x86_= cpu_def, const char *cpu_model) > > /* Features to be added*/ > > uint32_t plus_features =3D 0, plus_ext_features =3D 0; > > uint32_t plus_ext2_features =3D 0, plus_ext3_features =3D 0; > > - uint32_t plus_kvm_features =3D 0, plus_svm_features =3D 0; > > + uint32_t plus_kvm_features =3D kvm_default_features, plus_svm_fe= atures =3D 0; > > uint32_t plus_7_0_ebx_features =3D 0; > > /* Features to be removed */ > > uint32_t minus_features =3D 0, minus_ext_features =3D 0; > > @@ -1127,18 +1141,6 @@ static int cpu_x86_find_by_name(x86_def_t *x86= _cpu_def, const char *cpu_model) > > memcpy(x86_cpu_def, def, sizeof(*def)); > > } > > =20 > > -#if defined(CONFIG_KVM) > > - plus_kvm_features =3D (1 << KVM_FEATURE_CLOCKSOURCE) | > > - (1 << KVM_FEATURE_NOP_IO_DELAY) |=20 > > - (1 << KVM_FEATURE_MMU_OP) | > > - (1 << KVM_FEATURE_CLOCKSOURCE2) | > > - (1 << KVM_FEATURE_ASYNC_PF) |=20 > > - (1 << KVM_FEATURE_STEAL_TIME) | > > - (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); > > -#else > > - plus_kvm_features =3D 0; > > -#endif > > - > > add_flagname_to_bitmaps("hypervisor", &plus_features, > > &plus_ext_features, &plus_ext2_features, &plus_ext3_feat= ures, > > &plus_kvm_features, &plus_svm_features, &plus_7_0_ebx_f= eatures); > > @@ -1953,3 +1955,8 @@ static void x86_cpu_register_types(void) > > } > > =20 > > type_init(x86_cpu_register_types) > > + > > +void enable_kvm_pv_eoi(void) > > +{ > > + kvm_default_features |=3D kvm_pv_eoi_features; > > +} >=20 > Indentation is off (7 spaces). >=20 > I'd prefer to place this function below the variable definitions, so > that type_init() remains at the bottom of the file. >=20 > Otherwise I'm happy with the modified cpu.h-based interaction. > So far there's no conflicts here, so it could go through either PC > maintainer, kvm/uq or qom-cpu. >=20 > Andreas >=20 > > diff --git a/target-i386/cpu.h b/target-i386/cpu.h > > index 871c270..de33303 100644 > > --- a/target-i386/cpu.h > > +++ b/target-i386/cpu.h > > @@ -1188,4 +1188,6 @@ void do_smm_enter(CPUX86State *env1); > > =20 > > void cpu_report_tpr_access(CPUX86State *env, TPRAccess access); > > =20 > > +void enable_kvm_pv_eoi(void); > > + > > #endif /* CPU_I386_H */ I'll fix the whitespace and repost. Thanks for the review. >=20 > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrn= berg