From: Andrew Jones <drjones@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>,
Beata Michalska <beata.michalska@linaro.org>
Subject: Re: [PATCH 3/3] hw/arm/virt: Implement kvm-steal-time
Date: Mon, 3 Aug 2020 17:18:18 +0200 [thread overview]
Message-ID: <20200803151818.3ejilt5crefdyw6h@kamzik.brq.redhat.com> (raw)
In-Reply-To: <20200729144050.pzl4t3pnpt2zg36u@kamzik.brq.redhat.com>
On Wed, Jul 29, 2020 at 04:40:54PM +0200, Andrew Jones wrote:
> > > +static inline void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) {}
> >
> > Does this stub need to report an error to the caller via errp,
> > or is it a "never called but needs to exist to avoid linker errors" ?
>
> The second one, as we can't have kvm_enabled() and !defined(CONFIG_KVM).
> Hmm, these types of stubs would be more robust to refactoring if we put
> build bugs in them. I can try to analyze all the stubs in this #else to
> see which ones should be returning false/error/nothing vs. build bugging.
>
I couldn't come up with a way to die at compile-time, but I think we
should be able to use g_assert_not_reached() in these functions. How
about something like the diff below?
Thanks,
drew
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) {}
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)
next prev parent reply other threads:[~2020-08-03 15:19 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-11 10:10 [PATCH 0/3] hw/arm/virt: Introduce kvm-steal-time Andrew Jones
2020-07-11 10:10 ` [PATCH 1/3] hw/arm/virt: Move post cpu realize check into its own function Andrew Jones
2020-07-21 10:03 ` Peter Maydell
2020-07-11 10:10 ` [PATCH 2/3] hw/arm/virt: Move kvm pmu setup to virt_cpu_post_init Andrew Jones
2020-07-21 10:02 ` Peter Maydell
2020-07-29 13:51 ` Andrew Jones
2020-07-11 10:10 ` [PATCH 3/3] hw/arm/virt: Implement kvm-steal-time Andrew Jones
2020-07-21 10:46 ` Peter Maydell
2020-07-29 14:40 ` Andrew Jones
2020-08-03 15:18 ` Andrew Jones [this message]
2020-07-31 14:54 ` Peter Maydell
2020-08-01 12:00 ` Andrew Jones
2020-08-03 15:16 ` Andrew Jones
2020-07-20 10:16 ` [PATCH 0/3] hw/arm/virt: Introduce kvm-steal-time Peter Maydell
2020-07-27 8:33 ` 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=20200803151818.3ejilt5crefdyw6h@kamzik.brq.redhat.com \
--to=drjones@redhat.com \
--cc=beata.michalska@linaro.org \
--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).