From: Cornelia Huck <cohuck@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>,
Peter Maydell <peter.maydell@linaro.org>,
Thomas Huth <thuth@redhat.com>,
Laurent Vivier <lvivier@redhat.com>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kvm@vger.kernel.org,
Eric Auger <eauger@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Gavin Shan <gshan@redhat.com>
Subject: Re: [PATCH v4 1/2] arm/kvm: add support for MTE
Date: Wed, 18 Jan 2023 18:37:24 +0100 [thread overview]
Message-ID: <87fsc7oiaz.fsf@redhat.com> (raw)
In-Reply-To: <b92e6786-acc6-50ef-8804-e4e3ef4eb2d6@linaro.org>
On Tue, Jan 17 2023, Richard Henderson <richard.henderson@linaro.org> wrote:
> On 1/11/23 06:13, Cornelia Huck wrote:
>> @@ -2136,7 +2136,7 @@ static void machvirt_init(MachineState *machine)
>>
>> if (vms->mte && (kvm_enabled() || hvf_enabled())) {
>> error_report("mach-virt: %s does not support providing "
>> - "MTE to the guest CPU",
>> + "emulated MTE to the guest CPU",
>> kvm_enabled() ? "KVM" : "HVF");
>
> Not your bug, but noticing this should use current_accel_name().
I can fix it as I'm touching the code anyway.
(Hm... two more of these right above. Maybe better in a separate patch.)
>
>> +static inline bool arm_machine_has_tag_memory(void)
>> +{
>> +#ifndef CONFIG_USER_ONLY
>> + Object *obj = object_dynamic_cast(qdev_get_machine(), TYPE_VIRT_MACHINE);
>> +
>> + /* so far, only the virt machine has support for tag memory */
>> + if (obj) {
>> + VirtMachineState *vms = VIRT_MACHINE(obj);
>> +
>> + return vms->mte;
>> + }
>> +#endif
>> + return false;
>> +}
>
> True for CONFIG_USER_ONLY, via page_get_target_data().
> You should have seen check-tcg test failures...
Weird, let me check my setup...
>
>> +void arm_cpu_mte_finalize(ARMCPU *cpu, Error **errp)
>> +{
>> + bool enable_mte;
>> +
>> + switch (cpu->prop_mte) {
>> + case ON_OFF_AUTO_OFF:
>> + enable_mte = false;
>> + break;
>> + case ON_OFF_AUTO_ON:
>> + if (!kvm_enabled()) {
>
> tcg_enabled(), here and everywhere else you test for !kvm.
>
>> +#ifdef CONFIG_KVM
>> + if (kvm_enabled() && !kvm_arm_mte_supported()) {
>
> kvm_arm.h should get a stub inline returning false, so that the ifdef is removed.
> See e.g. kvm_arm_sve_supported().
Oh, I actually did add it already...
>
>> + default: /* AUTO */
>> + if (!kvm_enabled()) {
>
> tcg_enabled.
>
>> + /* accelerator-specific enablement */
>> + if (kvm_enabled()) {
>> +#ifdef CONFIG_KVM
>> + if (kvm_vm_enable_cap(kvm_state, KVM_CAP_ARM_MTE, 0)) {
>> + error_setg(errp, "Failed to enable KVM_CAP_ARM_MTE");
>
> Ideally this ifdef could go away as well.
>
>> + } else {
>> + /* TODO: add proper migration support with MTE enabled */
>> + if (!mte_migration_blocker) {
>
> Move the global variable here, as a local static?
>
> I guess this check is to avoid adding one blocker per cpu?
> I would guess the cap doesn't need enabling more than once either?
Indeed, it's a VM cap. (I only tested this on a single-cpu FVP setup.)
>
>
>> + error_setg(&mte_migration_blocker,
>> + "Live migration disabled due to MTE enabled");
>> + if (migrate_add_blocker(mte_migration_blocker, NULL)) {
>
> You pass NULL to the migrate_add_blocker errp argument...
>
>> + error_setg(errp, "Failed to add MTE migration blocker");
>
> ... then make up your own generic reason for why it failed.
> In this case it seems only related to another command-line option: --only-migratable.
>
>
> Anyway, I wonder about hiding all of this in target/arm/kvm.c:
>
> bool kvm_arm_enable_mte(Error *errp)
> {
> static bool once = false;
> Error *blocker;
>
> if (once) {
> return;
> }
> once = true;
>
> if (kvm_vm_enable_cap(kvm_state, KVM_CAP_ARM_MTE, 0)) {
> error_setg_errno(errp, "Failed to enable KVM_CAP_ARM_MTE");
> return false;
> }
>
> blocker = g_new0(Error);
> error_setg(blocker, "Live migration disabled....");
> return !migrate_add_blocker(blocker, errp);
> }
>
> with
>
> static inline bool kvm_arm_enable_mte(Error *errp)
> {
> g_assert_not_reached();
> }
>
> in the !CONFIG_KVM block in kvm_arm.h.
Good suggestion, I'll give that one a try.
Thanks for the feedback!
next prev parent reply other threads:[~2023-01-18 17:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-11 16:13 [PATCH v4 0/2] arm: enable MTE for QEMU + kvm Cornelia Huck
2023-01-11 16:13 ` [PATCH v4 1/2] arm/kvm: add support for MTE Cornelia Huck
2023-01-17 16:16 ` Peter Maydell
2023-01-17 16:50 ` Dr. David Alan Gilbert
2023-01-17 16:59 ` Cornelia Huck
2023-01-17 17:11 ` Dr. David Alan Gilbert
2023-01-17 17:01 ` Peter Maydell
2023-01-17 17:53 ` Dr. David Alan Gilbert
2023-01-17 16:52 ` Cornelia Huck
2023-01-17 19:37 ` Richard Henderson
2023-01-18 17:37 ` Cornelia Huck [this message]
2023-01-23 13:50 ` Eric Auger
2023-01-26 11:47 ` Cornelia Huck
2023-01-26 12:15 ` Cornelia Huck
2023-01-11 16:13 ` [PATCH v4 2/2] qtests/arm: add some mte tests Cornelia Huck
2023-01-17 7:21 ` Philippe Mathieu-Daudé
2023-01-23 14:29 ` Eric Auger
2023-01-26 10:57 ` Cornelia Huck
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=87fsc7oiaz.fsf@redhat.com \
--to=cohuck@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eauger@redhat.com \
--cc=gshan@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/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).