From: Gavin Shan <gshan@redhat.com>
To: qemu-arm@nongnu.org
Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org,
pbonzini@redhat.com, philmd@linaro.org,
richard.henderson@linaro.org, shan.gavin@gmail.com
Subject: Re: [PATCH 3/4] hw/arm/virt: Use kvm_arch_get_default_type()
Date: Fri, 9 Aug 2024 20:01:32 +1000 [thread overview]
Message-ID: <d75a3435-6ab4-47c2-aee5-71dc4f877639@redhat.com> (raw)
In-Reply-To: <20240809035134.699830-4-gshan@redhat.com>
On 8/9/24 1:51 PM, Gavin Shan wrote:
> kvm_arch_get_default_type() and kvm_arm_get_max_vm_ipa_size() are
> interchangeable since the type is equivalent to IPA size (bits)
> with one exception that IPA size (bits) is 40 when the type is zero.
>
> Replace kvm_arm_get_max_vm_ipa_size() with kvm_arch_get_default_type().
> After this, kvm_arm_get_max_vm_ipa_size() needn't to be a public API
> any more.
>
> Signed-off-by: Gavin Shan <gshan@redhat.com>
> ---
> hw/arm/virt.c | 14 ++++++--------
> target/arm/kvm.c | 2 +-
> target/arm/kvm_arm.h | 15 ---------------
> 3 files changed, 7 insertions(+), 24 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 09b7a158a9..f35857aa95 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -2995,10 +2995,12 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
> static int virt_kvm_type(MachineState *ms, const char *type_str)
> {
> VirtMachineState *vms = VIRT_MACHINE(ms);
> - int max_vm_pa_size, requested_pa_size;
> + int type, max_vm_pa_size, requested_pa_size;
> bool fixed_ipa;
>
> - max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa);
> + /* The IPA size is 40 bits when the type is zero */
> + type = kvm_arch_get_default_type(ms);
> + max_vm_pa_size = (type == 0) ? 40 : type;
>
> /* we freeze the memory map to compute the highest gpa */
> virt_set_memmap(vms, max_vm_pa_size);
> @@ -3017,12 +3019,8 @@ static int virt_kvm_type(MachineState *ms, const char *type_str)
> requested_pa_size, max_vm_pa_size);
> return -1;
> }
> - /*
> - * We return the requested PA log size, unless KVM only supports
> - * the implicit legacy 40b IPA setting, in which case the kvm_type
> - * must be 0.
> - */
> - return fixed_ipa ? 0 : requested_pa_size;
> +
> + return type;
> }
> #endif /* CONFIG_KVM */
>
This actually needs to be something like below. It's incorrect to ignore
@requested_pa_size here.
return (type == 0) ? 0 : requested_pa_size;
> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
> index 849e2e21b3..65893c9c12 100644
> --- a/target/arm/kvm.c
> +++ b/target/arm/kvm.c
> @@ -526,7 +526,7 @@ bool kvm_arm_pmu_supported(void)
> return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3);
> }
>
> -int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
> +static int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
> {
> KVMState *s = KVM_STATE(ms->accelerator);
> int ret;
> diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
> index cfaa0d9bc7..fd919d4738 100644
> --- a/target/arm/kvm_arm.h
> +++ b/target/arm/kvm_arm.h
> @@ -188,16 +188,6 @@ bool kvm_arm_pmu_supported(void);
> */
> bool kvm_arm_sve_supported(void);
>
> -/**
> - * kvm_arm_get_max_vm_ipa_size:
> - * @ms: Machine state handle
> - * @fixed_ipa: True when the IPA limit is fixed at 40. This is the case
> - * for legacy KVM.
> - *
> - * Returns the number of bits in the IPA address space supported by KVM
> - */
> -int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa);
> -
> int kvm_arm_vgic_probe(void);
>
> void kvm_arm_pmu_init(ARMCPU *cpu);
> @@ -248,11 +238,6 @@ static inline void kvm_arm_add_vcpu_properties(ARMCPU *cpu)
> g_assert_not_reached();
> }
>
> -static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
> -{
> - g_assert_not_reached();
> -}
> -
> static inline int kvm_arm_vgic_probe(void)
> {
> g_assert_not_reached();
Thanks,
Gavin
next prev parent reply other threads:[~2024-08-09 10:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 3:51 [PATCH 0/4] hw/arm/virt: Improve virt_kvm_type() Gavin Shan
2024-08-09 3:51 ` [PATCH 1/4] hw/arm/virt: hide virt_kvm_type() on !CONFIG_KVM Gavin Shan
2024-08-09 9:00 ` Peter Maydell
2024-08-09 9:39 ` Gavin Shan
2024-08-09 3:51 ` [PATCH 2/4] hw/arm/virt: Avoid multiple lines of comments in virt_kvm_type() Gavin Shan
2024-08-09 3:51 ` [PATCH 3/4] hw/arm/virt: Use kvm_arch_get_default_type() Gavin Shan
2024-08-09 8:59 ` Peter Maydell
2024-08-09 9:58 ` Gavin Shan
2024-08-09 10:01 ` Gavin Shan [this message]
2024-08-09 3:51 ` [PATCH 4/4] target/arm/kvm: Remove kvm_arm_get_max_vm_ipa_size() Gavin Shan
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=d75a3435-6ab4-47c2-aee5-71dc4f877639@redhat.com \
--to=gshan@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shan.gavin@gmail.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).