From: Richard Henderson <richard.henderson@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>, qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, qemu-arm@nongnu.org,
"Peter Maydell" <peter.maydell@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH v2 17/30] exec/target_page: runtime defintion for TARGET_PAGE_BITS_MIN
Date: Sat, 22 Mar 2025 13:55:38 -0700 [thread overview]
Message-ID: <392cd6e5-0c73-4702-8733-d3047db76f77@linaro.org> (raw)
In-Reply-To: <c1b7b73e-0a59-46cf-bf33-5712df5d9b75@linaro.org>
On 3/21/25 17:20, Pierrick Bouvier wrote:
> On 3/21/25 17:01, Pierrick Bouvier wrote:
>> On 3/21/25 15:19, Richard Henderson wrote:
>>> On 3/21/25 13:11, Pierrick Bouvier wrote:
>>>> On 3/21/25 12:27, Richard Henderson wrote:
>>>>> On 3/21/25 11:09, Pierrick Bouvier wrote:
>>>>>>> Mmm, ok I guess. Yesterday I would have suggested merging this with page-vary.h, but
>>>>>>> today I'm actively working on making TARGET_PAGE_BITS_MIN a global constant.
>>>>>>>
>>>>>>
>>>>>> When you mention this, do you mean "constant accross all architectures", or a global
>>>>>> (const) variable vs having a function call?
>>>>> The first -- constant across all architectures.
>>>>>
>>>>
>>>> That's great.
>>>> Does choosing the min(set_of(TARGET_PAGE_BITS_MIN)) is what we want there, or is the
>>>> answer more subtle than that?
>>>
>>> It will be, yes.
>>>
>>> This isn't as hard as it seems, because there are exactly two targets with
>>> TARGET_PAGE_BITS < 12: arm and avr.
>>>
>>> Because we still support armv4, TARGET_PAGE_BITS_MIN must be <= 10.
>>>
>>> AVR currently has TARGET_PAGE_BITS == 8, which is a bit of a problem.
>>> My first task is to allow avr to choose TARGET_PAGE_BITS_MIN >= 10.
>>>
>>> Which will leave us with TARGET_PAGE_BITS_MIN == 10.
>>>
>>
>> Ok.
>>
>> From what I understand, we make sure tlb flags are stored in an
>> immutable position, within virtual addresses related to guest, by using
>> lower bits belonging to address range inside a given page, since page
>> addresses are aligned on page size, leaving those bits free.
>>
>> bits [0..2) are bswap, watchpoint and check_aligned.
>> bits [TARGET_PAGE_BITS_MIN - 5..TARGET_PAGE_BITS_MIN) are slow,
>> discard_write, mmio, notdirty, and invalid mask.
>> And the compile time check we have is to make sure we don't overlap
>> those sets (would happen in TARGET_PAGE_BITS_MIN <= 7).
>>
>> I wonder why we can't use bits [3..8) everywhere, like it's done for
>> AVR, even for bigger page sizes. I noticed the comment about "address
>> alignment bits", but I'm confused why bits [0..2) can be used, and not
>> upper ones.
>>
>> Are we storing something else in the middle on other archs, or did I
>> miss some piece of the puzzle?
>>
>
> After looking better, TLB_SLOW_FLAGS are not part of address, so we don't use bits [0..2).
>
> For a given TARGET_PAGE_SIZE, how do we define alignment bits?
Alignment bits are the least significant bits that must be 0 in order to enforce a
particular alignment. The specific alignment is requested via MO_ALIGN et al as part of
the guest memory reference.
I think the piece you're missing is the softmmu fast path test in the generated code.
We begin by indexing the tlb to find an entry. At that index, the entry may or may not
match because (1) we have never looked up the page so the entry is empty, (2) we have
looked up a different page that aliases, or (3) the page is present and (3a) correct, or
(3b) invalidated, or (3c) some other condition that forces the slow path.
The target address and the comparator have several fields:
page address [63 ... TARGET_PAGE_BITS]
page flags [TARGET_PAGE_BITS - 1 ... TARGET_PAGE_BITS - 5]
unused [TARGET_PAGE_BITS - 6 ... align_bits], or empty.
alignment [align_bits - 1 ... 0], or empty
In the comparator, the unused and alignment bits are always zero; the page flags may be
non-zero in order to force the comparison to fail.
In the target address, we mask the page flags and unused bits; if the alignment bits of
the address are set, then the address is of course unaligned and so the comparison fails.
In order for all this work, the alignment field cannot overlap the page flags.
The maximum alignment currently used by any guest is 5 bits, for Arm Neon,
which means the minimum value for TARGET_PAGE_BITS_MIN is 10.
r~
next prev parent reply other threads:[~2025-03-22 20:56 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 22:29 [PATCH v2 00/30] single-binary: start make hw/arm/ common Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 01/30] exec/cpu-all: remove BSWAP_NEEDED Pierrick Bouvier
2025-03-23 19:26 ` Richard Henderson
2025-03-24 20:54 ` Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 02/30] exec/cpu-all: extract tlb flags defines to exec/tlb-flags.h Pierrick Bouvier
2025-03-23 19:28 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 03/30] exec/cpu-all: move cpu_copy to linux-user/qemu.h Pierrick Bouvier
2025-03-21 15:36 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 04/30] include/exec/cpu-all: move compile time check for CPUArchState to cpu-target.c Pierrick Bouvier
2025-03-21 15:42 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 05/30] exec/cpu-all: remove system/memory include Pierrick Bouvier
2025-03-21 16:36 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 06/30] exec/cpu-all: remove exec/page-protection include Pierrick Bouvier
2025-03-21 16:37 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 07/30] exec/cpu-all: remove tswap include Pierrick Bouvier
2025-03-21 16:37 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 08/30] exec/cpu-all: remove exec/cpu-interrupt include Pierrick Bouvier
2025-03-21 16:38 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 09/30] exec/cpu-all: remove exec/cpu-defs include Pierrick Bouvier
2025-03-21 16:38 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 10/30] exec/cpu-all: remove exec/target_page include Pierrick Bouvier
2025-03-23 19:29 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 11/30] exec/cpu-all: remove hw/core/cpu.h include Pierrick Bouvier
2025-03-21 18:00 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 12/30] accel/tcg: fix missing includes for TCG_GUEST_DEFAULT_MO Pierrick Bouvier
2025-03-21 18:01 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 13/30] accel/tcg: fix missing includes for TARGET_HAS_PRECISE_SMC Pierrick Bouvier
2025-03-21 18:02 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 14/30] exec/cpu-all: remove cpu include Pierrick Bouvier
2025-03-21 18:02 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 15/30] exec/cpu-all: transfer exec/cpu-common include to cpu.h headers Pierrick Bouvier
2025-03-21 18:03 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 16/30] exec/cpu-all: remove this header Pierrick Bouvier
2025-03-21 18:04 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 17/30] exec/target_page: runtime defintion for TARGET_PAGE_BITS_MIN Pierrick Bouvier
2025-03-21 18:05 ` Richard Henderson
2025-03-21 18:09 ` Pierrick Bouvier
2025-03-21 19:27 ` Richard Henderson
2025-03-21 20:11 ` Pierrick Bouvier
2025-03-21 22:19 ` Richard Henderson
2025-03-22 0:01 ` Pierrick Bouvier
2025-03-22 0:20 ` Pierrick Bouvier
2025-03-22 20:55 ` Richard Henderson [this message]
2025-03-24 21:39 ` Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 18/30] accel/kvm: move KVM_HAVE_MCE_INJECTION define to kvm-all.c Pierrick Bouvier
2025-03-23 19:35 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 19/30] exec/poison: KVM_HAVE_MCE_INJECTION can now be poisoned Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 20/30] target/arm/cpu: always define kvm related registers Pierrick Bouvier
2025-03-23 19:37 ` Richard Henderson
2025-03-24 21:11 ` Pierrick Bouvier
2025-03-25 1:24 ` Richard Henderson
2025-04-02 13:36 ` Philippe Mathieu-Daudé
2025-04-02 15:06 ` Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 21/30] target/arm/cpu: flags2 is always uint64_t Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 22/30] target/arm/cpu: define same set of registers for aarch32 and aarch64 Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 23/30] target/arm/cpu: remove inline stubs for aarch32 emulation Pierrick Bouvier
2025-03-23 19:41 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 24/30] meson: add common hw files Pierrick Bouvier
2025-03-23 19:58 ` Richard Henderson
2025-03-24 21:21 ` Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 25/30] hw/arm/boot: make compilation unit hw common Pierrick Bouvier
2025-03-23 19:46 ` Richard Henderson
2025-03-20 22:29 ` [PATCH v2 26/30] hw/arm/armv7m: prepare compilation unit to be common Pierrick Bouvier
2025-03-23 19:48 ` Richard Henderson
2025-03-24 21:31 ` Pierrick Bouvier
2025-03-25 1:22 ` Richard Henderson
2025-03-25 1:48 ` Pierrick Bouvier
2025-03-20 22:29 ` [PATCH v2 27/30] hw/arm/digic_boards: " Pierrick Bouvier
2025-03-23 19:49 ` Richard Henderson
2025-03-20 22:30 ` [PATCH v2 28/30] hw/arm/xlnx-zynqmp: " Pierrick Bouvier
2025-03-23 19:50 ` Richard Henderson
2025-03-24 21:23 ` Pierrick Bouvier
2025-03-20 22:30 ` [PATCH v2 29/30] hw/arm/xlnx-versal: " Pierrick Bouvier
2025-03-23 19:50 ` Richard Henderson
2025-03-20 22:30 ` [PATCH v2 30/30] hw/arm: make most of the compilation units common Pierrick Bouvier
2025-03-23 19:51 ` Richard Henderson
2025-03-20 22:49 ` [PATCH v2 00/30] single-binary: start make hw/arm/ common 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=392cd6e5-0c73-4702-8733-d3047db76f77@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-arm@nongnu.org \
--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).