qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Andrew Jones <drjones@redhat.com>,
	qemu-devel@nongnu.org, qemu-arm@nongnu.org
Cc: peter.maydell@linaro.org
Subject: Re: [PATCH v2 2/5] target/arm/kvm: Make uncalled stubs explicitly unreachable
Date: Wed, 12 Aug 2020 12:16:43 +0200	[thread overview]
Message-ID: <b26a7bf5-ad7c-9376-78ab-600b7ea9fed8@redhat.com> (raw)
In-Reply-To: <20200805091640.11134-3-drjones@redhat.com>

Hi Drew,

On 8/5/20 11:16 AM, Andrew Jones wrote:
> When we compile without KVM support !defined(CONFIG_KVM) we generate
> stubs for functions that the linker will still encounter. Sometimes
> these stubs can be executed safely and are placed in paths where they
> get executed with or without KVM. Other functions should never be
> called without KVM. Those functions should be guarded by kvm_enabled(),
> but should also be robust to refactoring mistakes. Putting a
> g_assert_not_reached() in the function should help. Additionally,
> the g_assert_not_reached() calls may actually help the linker remove
> some code.
> 
> We remove the stubs for kvm_arm_get/put_virtual_time(), as they aren't
> necessary at all - the only caller is in kvm.c
> 
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
>  target/arm/kvm_arm.h | 44 +++++++++++++++++++++++++++-----------------
>  1 file changed, 27 insertions(+), 17 deletions(-)
> 
> diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
> index adb38514bf20..0da00eb6b20c 100644
> --- a/target/arm/kvm_arm.h
> +++ b/target/arm/kvm_arm.h
> @@ -344,16 +344,10 @@ int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level);
>  
>  #else
>  
> -static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
> -{
> -    /*
> -     * This should never actually be called in the "not KVM" case,
> -     * but set up the fields to indicate an error anyway.
> -     */
> -    cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE;
> -    cpu->host_cpu_probe_failed = true;
> -}
> -
> +/*
> + * It's safe to call these functions without KVM support.
> + * They should either do nothing or return "not supported".
> + */
>  static inline void kvm_arm_add_vcpu_properties(Object *obj) {}
this one also is guarded by kvm_enabled() in target/arm/cpu.c
don't you want to add g_assert_not_reached()?
>  
>  static inline bool kvm_arm_aarch32_supported(void)
> @@ -371,23 +365,39 @@ static inline bool kvm_arm_sve_supported(void)
>      return false;
>  }
>  
> +/*
> + * These functions should never actually be called without KVM support.
> + */
> +static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu)
> +{
> +    g_assert_not_reached();
> +}
> +
>  static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
>  {
> -    return -ENOENT;
> +    g_assert_not_reached();
>  }
>  
>  static inline int kvm_arm_vgic_probe(void)
>  {
> -    return 0;
> +    g_assert_not_reached();
>  }
>  
> -static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq) {}
> -static inline void kvm_arm_pmu_init(CPUState *cs) {}
> +static inline void kvm_arm_pmu_set_irq(CPUState *cs, int irq)
> +{
> +    g_assert_not_reached();
> +}
>  
> -static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map) {}
> +static inline void kvm_arm_pmu_init(CPUState *cs)
> +{
> +    g_assert_not_reached();
> +}
> +
> +static inline void kvm_arm_sve_get_vls(CPUState *cs, unsigned long *map)
> +{
> +    g_assert_not_reached();
> +}
>  
> -static inline void kvm_arm_get_virtual_time(CPUState *cs) {}
> -static inline void kvm_arm_put_virtual_time(CPUState *cs) {}
>  #endif
>  
>  static inline const char *gic_class_name(void)
> 

Besides,
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric



  reply	other threads:[~2020-08-12 10:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05  9:16 [PATCH v2 0/5] hw/arm/virt: Introduce kvm-steal-time Andrew Jones
2020-08-05  9:16 ` [PATCH v2 1/5] hw: add compat machines for 5.2 Andrew Jones
2020-08-05  9:16 ` [PATCH v2 2/5] target/arm/kvm: Make uncalled stubs explicitly unreachable Andrew Jones
2020-08-12 10:16   ` Auger Eric [this message]
2020-08-12 10:26     ` Andrew Jones
2020-08-05  9:16 ` [PATCH v2 3/5] hw/arm/virt: Move post cpu realize check into its own function Andrew Jones
2020-08-12 10:16   ` Auger Eric
2020-08-05  9:16 ` [PATCH v2 4/5] hw/arm/virt: Move kvm pmu setup to virt_cpu_post_init Andrew Jones
2020-08-12 10:16   ` Auger Eric
2020-08-12 10:35     ` Andrew Jones
2020-08-25 14:27   ` Peter Maydell
2020-08-05  9:16 ` [PATCH v2 5/5] hw/arm/virt: Implement kvm-steal-time Andrew Jones
2020-08-12 12:41   ` Auger Eric
2020-09-07  7:04 ` [PATCH v2 0/5] hw/arm/virt: Introduce kvm-steal-time Andrew Jones

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=b26a7bf5-ad7c-9376-78ab-600b7ea9fed8@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=drjones@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --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).