From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
qemu-arm@nongnu.org, anjo@rev.ng, richard.henderson@linaro.org
Subject: Re: [PATCH 05/13] target/arm/kvm_arm: copy definitions from kvm headers
Date: Wed, 30 Apr 2025 08:08:09 +0200 [thread overview]
Message-ID: <e88f9bfe-1d8e-4571-81d0-55d750a2da9e@linaro.org> (raw)
In-Reply-To: <b044596b-46a0-47ca-a1f0-61160c59efc9@linaro.org>
On 30/4/25 00:02, Pierrick Bouvier wrote:
> On 4/29/25 2:14 PM, Pierrick Bouvier wrote:
>> On 4/29/25 3:28 AM, Alex Bennée wrote:
>>> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>>>
>>>> "linux/kvm.h" is not included for code compiled without
>>>> COMPILING_PER_TARGET, and headers are different depending architecture
>>>> (arm, arm64).
>>>> Thus we need to manually expose some definitions that will
>>>> be used by target/arm, ensuring they are the same for arm amd aarch64.
>>>>
>>>> As well, we must but prudent to not redefine things if code is already
>>>> including linux/kvm.h, thus the #ifndef COMPILING_PER_TARGET guard.
>>>>
>>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
>>>> ---
>>>> target/arm/kvm_arm.h | 15 +++++++++++++++
>>>> 1 file changed, 15 insertions(+)
>>>>
>>>> diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
>>>> index c8ddf8beb2e..eedd081064c 100644
>>>> --- a/target/arm/kvm_arm.h
>>>> +++ b/target/arm/kvm_arm.h
>>>> @@ -16,6 +16,21 @@
>>>> #define KVM_ARM_VGIC_V2 (1 << 0)
>>>> #define KVM_ARM_VGIC_V3 (1 << 1)
>>>> +#ifndef COMPILING_PER_TARGET
>>>> +
>>>> +/* we copy those definitions from asm-arm and asm-aarch64, as they
>>>> are the same
>>>> + * for both architectures */
>>>> +#define KVM_ARM_IRQ_CPU_IRQ 0
>>>> +#define KVM_ARM_IRQ_CPU_FIQ 1
>>>> +#define KVM_ARM_IRQ_TYPE_CPU 0
>>>> +typedef unsigned int __u32;
>>>> +struct kvm_vcpu_init {
>>>> + __u32 target;
>>>> + __u32 features[7];
>>>> +};
>>>> +
>>>> +#endif /* COMPILING_PER_TARGET */
>>>> +
>>>
>>> I'm not keen on the duplication. It seems to be the only reason we have
>>> struct kvm_vcpu_init is for kvm_arm_create_scratch_host_vcpu() where the
>>> only *external* user passes in a NULL.
>>>
>>
>> I'm not keen about it either, so thanks for pointing it.
>>
>>> If kvm_arm_create_scratch_host_vcpu() is made internal static to
>>> target/arm/kvm.c which will should always include the real linux headers
>>> you just need a QMP helper.
>>>
>>
>> Yes, sounds like the good approach! Thanks.
>>
>
> Alas this function is used in target/arm/arm-qmp-cmds.c, and if we move
> the code using it, it pulls QAPI, which is target dependent at this time.
>
> Since struct kvm_vcpu_init is only used by pointer, I could workaround
> this by doing a simple forward declaration in kvm_arm.h.
Correct, great!
next prev parent reply other threads:[~2025-04-30 6:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 4:59 [PATCH 00/13] single-binary: compile target/arm twice Pierrick Bouvier
2025-04-29 4:59 ` [PATCH 01/13] target/arm: Replace target_ulong -> uint64_t for HWBreakpoint Pierrick Bouvier
2025-04-29 9:15 ` Alex Bennée
2025-04-29 4:59 ` [PATCH 02/13] include/system/hvf: missing vaddr include Pierrick Bouvier
2025-04-29 5:36 ` Philippe Mathieu-Daudé
2025-04-29 7:13 ` Philippe Mathieu-Daudé
2025-04-29 21:09 ` Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 03/13] meson: add common libs for target and target_system Pierrick Bouvier
2025-04-29 18:01 ` Philippe Mathieu-Daudé
2025-04-29 21:11 ` Pierrick Bouvier
2025-04-30 6:06 ` Philippe Mathieu-Daudé
2025-04-30 6:12 ` Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 04/13] target/arm: move kvm stubs and remove CONFIG_KVM from kvm_arm.h Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 05/13] target/arm/kvm_arm: copy definitions from kvm headers Pierrick Bouvier
2025-04-29 10:28 ` Alex Bennée
2025-04-29 21:14 ` Pierrick Bouvier
2025-04-29 22:02 ` Pierrick Bouvier
2025-04-30 6:08 ` Philippe Mathieu-Daudé [this message]
2025-04-29 5:00 ` [PATCH 06/13] target/arm/kvm-stub: add missing stubs Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 07/13] target/arm/cpu: remove CONFIG_KVM from arm_cpu_kvm_set_irq Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 08/13] accel/hvf: add hvf_enabled() for common code Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 09/13] target/arm/cpu: get endianness from cpu state Pierrick Bouvier
2025-04-29 12:26 ` Anton Johansson via
2025-04-29 21:07 ` Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 10/13] target/arm/cpu: remove TARGET_AARCH64 around aarch64_cpu_dump_state common Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 11/13] target/arm/cpu: remove TARGET_AARCH64 in arm_cpu_finalize_features Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 12/13] target/arm/cpu: compile file twice (user, system) only Pierrick Bouvier
2025-04-30 8:32 ` Philippe Mathieu-Daudé
2025-04-30 14:39 ` Pierrick Bouvier
2025-04-29 5:00 ` [PATCH 13/13] target/arm/cpu32-stubs.c: compile file twice (user, system) Pierrick Bouvier
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=e88f9bfe-1d8e-4571-81d0-55d750a2da9e@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=anjo@rev.ng \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).