[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly
From: |
Peter Maydell |
Subject: |
Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly |
Date: |
Mon, 7 Dec 2020 21:50:07 +0000 |
On Mon, 7 Dec 2020 at 21:26, Eduardo Habkost <ehabkost@redhat.com> wrote:
> My understanding is that there's no reason for ARM KVM to use
> another approach, and that CPUClass.do_interrupt is not really
> TCG-specific.
>
> Do we have any case where the CPUClass.do_interrupt
> implementation is really TCG-specific, or it is just a
> coincidence that most other accelerators simply don't to call the
> method? It looks like the only cases where the
> CPUClass.do_interrupt assignment is conditional on CONFIG_TCG are
> i386 and s390x.
Looking at PPC, its kvm_handle_debug() function does a
direct call to ppc_cpu_do_interrupt(). So the code of
its do_interrupt method must be ok-for-KVM, it's just that
it doesn't use the method pointer. (It's doing the same thing
Arm is -- if a debug event turns out not to be for QEMU itself,
inject a suitable exception into the guest.)
So of our 5 KVM-supporting architectures:
* i386 and s390x have kernel APIs for "inject suitable
exception", don't need to call do_interrupt, and make
the cc->do_interrupt assignment only ifdef CONFIG_TCG,
so that the code for do_interrupt need not be compiled
into a KVM-only binary. (In both cases the code for the
function is in a source file that the meson.build puts
into the source list only if CONFIG_TCG)
* ppc and arm both need to use this code even in a KVM
only binary. Neither of them #ifdef the cc->do_interrupt
assignment, because there's not much point at the moment
if you're not going to try to compile out the code.
ppc happens to do a direct function call, and arm happens
to go via the cc->do_interrupt pointer, but I don't
think there's much significance in the choice either way.
In both cases, the only places making the call are within
architecture-specific KVM code.
* mips KVM does neither of these things, probably because it is
not sufficiently featureful to have run into the cases
where you might want to re-inject an exception and it's
not being sufficiently used in production for anybody to
have looked at minimising the amount of code in a
KVM-only QEMU binary for it.
So in conclusion we have a basically 50:50 split between
"use the same do_interrupt code as TCG" and "have a kernel
API to make the kernel do the work", plus one arch that
probably hasn't had to make the choice yet. ¯\_(ツ)_/¯
> Oh, I thought you were arguing that CPUClass.do_interrupt is
> not TCG_specific.
Well, I don't think it really is TCG-specific. But as
a pragmatic thing, if these two lines in the Arm code
are getting in the way of stopping us from having a
useful compile-time check that code that's not supposed
to call this method isn't calling it, I think the balance
maybe leans towards just making the direct function call.
I guess it depends whether you think people are likely to
accidentally make cc->do_interrupt calls in non-target-specific
code that gets used by KVM (which currently would crash if that
code path is exercised on x86 or s390x, but under the
proposed change would become a compile error).
thanks
-- PMM
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, (continued)
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Peter Maydell, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Eduardo Habkost, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Peter Maydell, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Peter Maydell, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Peter Maydell, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Eduardo Habkost, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Eduardo Habkost, 2020/12/07
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly,
Peter Maydell <=
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Philippe Mathieu-Daudé, 2020/12/08
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/08
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/08
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Philippe Mathieu-Daudé, 2020/12/08
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/08
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Eduardo Habkost, 2020/12/08
- Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/08
Re: [PATCH] target/arm: do not use cc->do_interrupt for KVM directly, Claudio Fontana, 2020/12/07