[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 1/2] kvm: add support for guest physical bits
From: |
Gerd Hoffmann |
Subject: |
Re: [PATCH v4 1/2] kvm: add support for guest physical bits |
Date: |
Fri, 22 Mar 2024 13:50:44 +0100 |
> > + if (cpu->host_phys_bits_limit &&
> > + cpu->guest_phys_bits > cpu->host_phys_bits_limit) {
> > + cpu->guest_phys_bits = cpu->host_phys_bits_limit;
>
> host_phys_bits_limit takes effect only when cpu->host_phys_bits is set.
>
> If users pass configuration like "-cpu
> qemu64,phys-bits=52,host-phys-bits-limit=45", the cpu->guest_phys_bits will
> be set to 45. I think this is not what we want, though the usage seems
> insane.
>
> We can guard it as
>
> if (cpu->host_phys_bits && cpu->host_phys_bits_limit &&
> cpu->guest_phys_bits > cpu->host_phys_bits_limt)
> {
> }
Yes, makes sense.
> Simpler, we can guard with cpu->phys_bits like below, because
> cpu->host_phys_bits_limit is used to guard cpu->phys_bits in
> host_cpu_realizefn()
>
> if (cpu->guest_phys_bits > cpu->phys_bits) {
> cpu->guest_phys_bits = cpu->phys_bits;
> }
I think I prefer the first version. The logic is already difficult
enough to follow because it is spread across a bunch of files due to
the different cases we have to handle (tcg, kvm-with-host_phys_bits,
kvm-without-host_phys_bits).
It's not in any way performance-critical, so I happily trade some extra
checks for code which is easier to read.
take care,
Gerd