From: Paolo Bonzini <pbonzini@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Igor Mammedov" <imammedo@redhat.com>,
"Jiri Denemark" <jdenemar@redhat.com>,
qemu-devel@nongnu.org, "Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 1/7] target-i386: Eliminate CONFIG_KVM #ifdefs
Date: Mon, 09 Dec 2013 19:17:49 +0100 [thread overview]
Message-ID: <52A6094D.1080605@redhat.com> (raw)
In-Reply-To: <1385580849-10777-2-git-send-email-ehabkost@redhat.com>
Il 27/11/2013 20:34, Eduardo Habkost ha scritto:
> The compiler is capable of eliminating the KVM-specific function calls
> as long as the calling function has an assert(kvm_enabled()) line, so we
> don't need to wrap all KVM-specific inside #ifdefs.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> target-i386/cpu.c | 13 ++-----------
> 1 file changed, 2 insertions(+), 11 deletions(-)
>
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index d747e04..b525592 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -373,7 +373,6 @@ void disable_kvm_pv_eoi(void)
> void host_cpuid(uint32_t function, uint32_t count,
> uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
> {
> -#if defined(CONFIG_KVM)
> uint32_t vec[4];
>
> #ifdef __x86_64__
> @@ -401,7 +400,6 @@ void host_cpuid(uint32_t function, uint32_t count,
> *ecx = vec[2];
> if (edx)
> *edx = vec[3];
> -#endif
> }
NACK for this one. It includes an "asm", it is plausible that it fails
to parse before dead-code elimination. Rather, change the #else to an
#elif, and add a new #else with an abort inside.
Otherwise looks good.
Paolo
> #define iswhite(c) ((c) && ((c) <= ' ' || '~' < (c)))
> @@ -1118,7 +1116,6 @@ void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w,
> }
> }
>
> -#ifdef CONFIG_KVM
> static int cpu_x86_fill_model_id(char *str)
> {
> uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
> @@ -1133,7 +1130,6 @@ static int cpu_x86_fill_model_id(char *str)
> }
> return 0;
> }
> -#endif
>
> /* Fill a x86_def_t struct with information about the host CPU, and
> * the CPU features supported by the host hardware + host kernel
> @@ -1142,7 +1138,6 @@ static int cpu_x86_fill_model_id(char *str)
> */
> static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
> {
> -#ifdef CONFIG_KVM
> KVMState *s = kvm_state;
> uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
>
> @@ -1172,8 +1167,6 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
> kvm_arch_get_supported_cpuid(s, wi->cpuid_eax, wi->cpuid_ecx,
> wi->cpuid_reg);
> }
> -
> -#endif /* CONFIG_KVM */
> }
>
> static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask)
> @@ -1798,13 +1791,14 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
> return cpu_list;
> }
>
> -#ifdef CONFIG_KVM
> static void filter_features_for_kvm(X86CPU *cpu)
> {
> CPUX86State *env = &cpu->env;
> KVMState *s = kvm_state;
> FeatureWord w;
>
> + assert(kvm_enabled());
> +
> for (w = 0; w < FEATURE_WORDS; w++) {
> FeatureWordInfo *wi = &feature_word_info[w];
> uint32_t host_feat = kvm_arch_get_supported_cpuid(s, wi->cpuid_eax,
> @@ -1815,7 +1809,6 @@ static void filter_features_for_kvm(X86CPU *cpu)
> cpu->filtered_features[w] = requested_features & ~env->features[w];
> }
> }
> -#endif
>
> static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)
> {
> @@ -2525,9 +2518,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
> "Host's CPU doesn't support requested features");
> goto out;
> }
> -#ifdef CONFIG_KVM
> filter_features_for_kvm(cpu);
> -#endif
> }
>
> #ifndef CONFIG_USER_ONLY
>
next prev parent reply other threads:[~2013-12-09 18:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-27 19:34 [Qemu-devel] [PATCH 0/7] x86 CPU subclasses, take 6 Eduardo Habkost
2013-11-27 19:34 ` [Qemu-devel] [PATCH 1/7] target-i386: Eliminate CONFIG_KVM #ifdefs Eduardo Habkost
2013-12-09 18:17 ` Paolo Bonzini [this message]
2013-12-10 18:55 ` [Qemu-devel] [PATCH 1/7 v2] " Eduardo Habkost
2013-12-11 1:36 ` Richard Henderson
2013-12-11 16:11 ` Eduardo Habkost
2013-12-11 16:31 ` [Qemu-devel] [PATCH 1/7 v3] " Eduardo Habkost
2013-11-27 19:34 ` [Qemu-devel] [PATCH 2/7] target-i386: Don't change x86_def_t struct on cpu_x86_register() Eduardo Habkost
2013-11-27 19:34 ` [Qemu-devel] [PATCH 3/7] target-i386: Move KVM default-vendor hack to instance_init Eduardo Habkost
2013-11-27 19:34 ` [Qemu-devel] [PATCH 4/7] target-i386: Rename cpu_x86_register() to x86_cpu_load_def() Eduardo Habkost
2013-11-27 19:34 ` [Qemu-devel] [PATCH 5/7] target-i386: Call x86_cpu_load_def() earlier Eduardo Habkost
2013-11-27 19:34 ` [Qemu-devel] [PATCH 6/7] target-i386: Rename x86_def_t to X86CPUDefinition Eduardo Habkost
2013-11-27 19:34 ` [Qemu-devel] [RFC 7/7] target-i386: CPU model subclasses Eduardo Habkost
2013-12-09 18:07 ` [Qemu-devel] [PATCH 0/7] x86 CPU subclasses, take 6 Eduardo Habkost
2013-12-09 18:21 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52A6094D.1080605@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=jdenemar@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).