From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Haibo Xu <haibo.xu@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
drjones@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH 3/7] target/arm/cpu: spe: Add an option to turn on/off vSPE support
Date: Mon, 10 Aug 2020 12:14:09 +0200 [thread overview]
Message-ID: <b7f9ee4e-c9f5-8627-09cf-f21c9f7146e4@amsat.org> (raw)
In-Reply-To: <CAJc+Z1ECoqwzexiGABs4oBk_DdZcA3_r6u7fQP-ZnZnuKaK7Rw@mail.gmail.com>
On 8/10/20 5:03 AM, Haibo Xu wrote:
> On Fri, 7 Aug 2020 at 16:28, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>> Hi Haibo,
>>
>> On 8/7/20 10:10 AM, Haibo Xu wrote:
>>> Adds a spe=[on/off] option to enable/disable vSPE support in
>>> guest vCPU. Note this option is only available for "-cpu host"
>>> with KVM mode, and default value is on.
You are right, we don't know whether if the feature is announced
to the guest, the guest will use the SPE registers, so similarly
to PMU have it default ON if available.
>>>
>>> Signed-off-by: Haibo Xu <haibo.xu@linaro.org>
>>> ---
>>> target/arm/cpu.c | 28 ++++++++++++++++++++++++++++
>>> target/arm/cpu.h | 3 +++
>>> 2 files changed, 31 insertions(+)
>>>
>>> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
>>> index 111579554f..40768b4d19 100644
>>> --- a/target/arm/cpu.c
>>> +++ b/target/arm/cpu.c
>>> @@ -1122,6 +1122,29 @@ static void arm_set_pmu(Object *obj, bool value, Error **errp)
>>> cpu->has_pmu = value;
>>> }
>>>
>>> +static bool arm_get_spe(Object *obj, Error **errp)
>>> +{
>>> + ARMCPU *cpu = ARM_CPU(obj);
>>> +
>>> + return cpu->has_spe;
>>> +}
>>> +
>>> +static void arm_set_spe(Object *obj, bool value, Error **errp)
>>> +{
>>> + ARMCPU *cpu = ARM_CPU(obj);
>>> +
>>> + if (value) {
>>> + if (kvm_enabled() && !kvm_arm_spe_supported()) {
>>> + error_setg(errp, "'spe' feature not supported by KVM on this host");
>>> + return;
>>> + }
>>> + set_feature(&cpu->env, ARM_FEATURE_SPE);
>>> + } else {
>>> + unset_feature(&cpu->env, ARM_FEATURE_SPE);
>>> + }
>>> + cpu->has_spe = value;
>>> +}
>>> +
>>> unsigned int gt_cntfrq_period_ns(ARMCPU *cpu)
>>> {
>>> /*
>>> @@ -1195,6 +1218,11 @@ void arm_cpu_post_init(Object *obj)
>>> object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu);
>>> }
>>>
>>> + if (arm_feature(&cpu->env, ARM_FEATURE_SPE)) {
>>> + cpu->has_spe = true;
>>
>> Being a profiling feature, are you sure you want it to be ON by default?
>>
>> I'd expect the opposite, either being turned on via command line at
>> startup or by a management layer at runtime, when someone is ready
>> to record the perf events and analyze them.
>>
>
> I'm not sure whether it's proper to follow the 'pmu' setting here
> which has it on by default.
> To be honest, I also prefer to turn it off by default(Please refer to
> the comments in the cover letter).
>
>>> + object_property_add_bool(obj, "spe", arm_get_spe, arm_set_spe);
>>> + }
>>> +
>>> /*
>>> * Allow user to turn off VFP and Neon support, but only for TCG --
>>> * KVM does not currently allow us to lie to the guest about its
>>> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
>>> index 9e8ed423ea..fe0ac14386 100644
>>> --- a/target/arm/cpu.h
>>> +++ b/target/arm/cpu.h
>>> @@ -822,6 +822,8 @@ struct ARMCPU {
>>> bool has_el3;
>>> /* CPU has PMU (Performance Monitor Unit) */
>>> bool has_pmu;
>>> + /* CPU has SPE (Statistical Profiling Extension) */
>>> + bool has_spe;
>>> /* CPU has VFP */
>>> bool has_vfp;
>>> /* CPU has Neon */
>>> @@ -1959,6 +1961,7 @@ enum arm_features {
>>> ARM_FEATURE_VBAR, /* has cp15 VBAR */
>>> ARM_FEATURE_M_SECURITY, /* M profile Security Extension */
>>> ARM_FEATURE_M_MAIN, /* M profile Main Extension */
>>> + ARM_FEATURE_SPE, /* has SPE support */
>>> };
>>>
>>> static inline int arm_feature(CPUARMState *env, int feature)
>>>
>>
>
next prev parent reply other threads:[~2020-08-10 10:15 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-07 8:10 [PATCH 0/7] target/arm: Add vSPE support to KVM guest Haibo Xu
2020-08-07 8:10 ` [PATCH 1/7] update Linux headers with new vSPE macros Haibo Xu
2020-08-07 8:10 ` [PATCH 2/7] target/arm/kvm: spe: Add helper to detect SPE when using KVM Haibo Xu
2020-08-14 19:16 ` Richard Henderson
2020-08-07 8:10 ` [PATCH 3/7] target/arm/cpu: spe: Add an option to turn on/off vSPE support Haibo Xu
2020-08-07 8:28 ` Philippe Mathieu-Daudé
2020-08-10 3:03 ` Haibo Xu
2020-08-10 10:14 ` Philippe Mathieu-Daudé [this message]
2020-08-10 10:50 ` Andrew Jones
2020-08-14 19:03 ` Richard Henderson
2020-08-14 19:15 ` Richard Henderson
2020-08-07 8:10 ` [PATCH 4/7] target/arm/kvm: spe: Unify device attr operatioin helper Haibo Xu
2020-08-07 8:19 ` Philippe Mathieu-Daudé
2020-08-10 2:48 ` Haibo Xu
2020-08-10 10:29 ` Andrew Jones
2020-08-11 1:13 ` Haibo Xu
2020-08-07 8:10 ` [PATCH 5/7] target/arm/kvm: spe: Add device init and set_irq operations Haibo Xu
2020-08-07 8:10 ` [PATCH 6/7] hw/arm/virt: spe: Add SPE fdt binding for virt machine Haibo Xu
2020-08-10 11:05 ` Andrew Jones
2020-08-11 2:38 ` Haibo Xu
2020-08-11 16:38 ` Andrew Jones
2020-08-12 0:42 ` Haibo Xu
2020-08-29 15:21 ` Auger Eric
2020-08-31 6:27 ` Haibo Xu
2020-08-07 8:10 ` [PATCH 7/7] target/arm/cpu: spe: Enable spe to work with host cpu Haibo Xu
2020-08-10 11:16 ` Andrew Jones
2020-08-11 3:15 ` Haibo Xu
2020-08-11 16:49 ` Andrew Jones
2020-08-12 0:54 ` Haibo Xu
2020-08-14 19:28 ` Richard Henderson
2020-08-15 7:17 ` Andrew Jones
2020-08-10 10:43 ` [PATCH 0/7] target/arm: Add vSPE support to KVM guest Andrew Jones
2020-08-31 7:56 ` Auger Eric
2020-09-01 2:26 ` Haibo Xu
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=b7f9ee4e-c9f5-8627-09cf-f21c9f7146e4@amsat.org \
--to=f4bug@amsat.org \
--cc=drjones@redhat.com \
--cc=haibo.xu@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).