From: Claudio Fontana <cfontana@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>,
Eduardo Habkost <ehabkost@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Dongjiu Geng" <gengdongjiu@huawei.com>
Subject: Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly
Date: Mon, 7 Dec 2020 19:18:23 +0100 [thread overview]
Message-ID: <08bd6211-1ac8-593c-0d95-a8b26a1b3745@suse.de> (raw)
In-Reply-To: <CAFEAcA_UUs6NJ_JYtNEQ3VubHnvsvo1BBx6=9nVT9GO_QrDwoQ@mail.gmail.com>
On 12/7/20 7:07 PM, Peter Maydell wrote:
> On Mon, 7 Dec 2020 at 17:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
>> arm_v7m_class_init() (used by cortex-* CPU models) overrides it.
>> Those CPU models as "TCG CPUs" in the code, but I don't see what
>> makes them TCG-specific.
>
> They're TCG specific because the Arm Virtualization Extension
> is for A-profile only and only supports virtualization of
> A-profile CPUs. You can't accelerate an M-profile CPU with it.
> (Similarly, you can't use the Virtualization Extension to
> accelerate a pre-v7 CPU, which is why CPUs like the arm1176
> are also TCG-only, and you can't use it to accelerate a CPU
> which has TrustZone enabled.)
>
> (M-profile CPUs override cc->do_interrupt() because their
> exception and interrupt handling logic is totally different
> to A-profile.)
>
>> What exactly is the expected behavior
>> if using, e.g., "-cpu cortex-m33 -accel kvm"?
>
> It ought to print a useful error message telling you
> that that CPU type isn't compatible with KVM.
>
> As it happens, you get an assertion failure for cortex-m33:
>
> $ ./build/all/qemu-system-aarch64 -accel kvm -M mps2-an505 -display none
> qemu-system-aarch64: ../../softmmu/physmem.c:745:
> cpu_address_space_init: Assertion `asidx == 0 || !kvm_enabled()'
> failed.
> Aborted
>
> because the M33 has TrustZone enabled (which is not compatible
> with KVM) and we don't check that before we hit the assertion.
> We should fix that :-)
>
> If you try it with a non-TrustZone M-profile core like the M3 then
> you do get a better error message:
>
> $ ./build/all/qemu-system-aarch64 -accel kvm -M mps2-an385 -display none
> qemu-system-aarch64: KVM is not supported for this guest CPU type
> qemu-system-aarch64: kvm_init_vcpu: kvm_arch_init_vcpu failed (0):
> Invalid argument
>
> If you try this with the "virt" board then you'll run into the
> virt board's own sanity checking of CPU types instead:
>
> $ ./build/all/qemu-system-aarch64 -accel kvm -M virt -cpu cortex-m33
> -display none
> qemu-system-aarch64: mach-virt: CPU type cortex-m33-arm-cpu not supported
>
> All of that said, I think I agree with you -- we have this
> indirect mechanism for invoking class methods on the CPU
> object, why is it necessary for this KVM-specific code to
> call the implementation function directly?
>
> thanks
> -- PMM
>
Hi Peter,
the initial attempt there was to mark do_interrupt as a TCG-only operation,
to move to a separate tcg_ops structure in CPUClass like for the others,
but countrary to the other ops I noticed that ARM is the only target that is calling cc->do_interrupt() for KVM too.
I might have to either leave do_interrupt() out of the refactoring, or find a way to avoid accessing cc->do_interrupt on KVM.
Thanks,
Claudio
next prev parent reply other threads:[~2020-12-07 18:29 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-07 8:40 [PATCH] target/arm: do not use cc->do_interrupt for KVM directly Claudio Fontana
2020-12-07 13:09 ` Philippe Mathieu-Daudé
2020-12-07 13:59 ` Alex Bennée
2020-12-07 17:49 ` Eduardo Habkost
2020-12-07 18:07 ` Peter Maydell
2020-12-07 18:18 ` Claudio Fontana [this message]
2020-12-07 18:28 ` Eduardo Habkost
2020-12-07 20:56 ` Peter Maydell
2020-12-07 21:01 ` Peter Maydell
2020-12-07 21:06 ` Claudio Fontana
2020-12-07 21:12 ` Peter Maydell
2020-12-07 21:17 ` Claudio Fontana
2020-12-07 21:28 ` Eduardo Habkost
2020-12-07 21:26 ` Eduardo Habkost
2020-12-07 21:50 ` Peter Maydell
2020-12-08 13:27 ` Philippe Mathieu-Daudé
2020-12-08 13:51 ` Claudio Fontana
2020-12-08 13:55 ` Claudio Fontana
2020-12-08 14:34 ` Philippe Mathieu-Daudé
2020-12-08 16:19 ` Claudio Fontana
2020-12-08 16:28 ` Eduardo Habkost
2020-12-08 17:43 ` Claudio Fontana
2020-12-07 18:08 ` Claudio Fontana
2020-12-07 18:14 ` Peter Maydell
2020-12-07 18:17 ` Claudio Fontana
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=08bd6211-1ac8-593c-0d95-a8b26a1b3745@suse.de \
--to=cfontana@suse.de \
--cc=alex.bennee@linaro.org \
--cc=ehabkost@redhat.com \
--cc=gengdongjiu@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@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).