On 4/2/25 20:05, Huacai Chen wrote:
On Thu, Apr 3, 2025 at 2:11 AM Richard Henderson
<richard.hender...@linaro.org> wrote:
On 4/1/25 20:04, Huacai Chen wrote:
Hi, Richard,
On Tue, Apr 1, 2025 at 9:39 PM Richard Henderson
<richard.hender...@linaro.org> wrote:
On 3/31/25 20:15, Huacai Chen wrote:
# define TARGET_VIRT_ADDR_SPACE_BITS 32
#endif
#endif
-#ifdef CONFIG_USER_ONLY
#define TARGET_PAGE_BITS 12
-#else
-#define TARGET_PAGE_BITS_VARY
-#define TARGET_PAGE_BITS_MIN 12
-#endif
I'm a bit confused about TARGET_PAGE_BITS and other macros.
In my opinion, if we define TARGET_PAGE_BITS as 12, that means we only
support 4K pages. And if we define TARGET_PAGE_BITS_VARY and
TARGET_PAGE_BITS_MIN as 12, that means we support the minimum page as
4K, but we also support larger pages.
Am I wrong?
Yes.
TARGET_PAGE_BITS is a minimum value that is used by the memory subsystem for
managing ram
and i/o. If variable, via TARGET_PAGE_BITS_VARY, this is set very early in
qemu startup
and cannot be changed.
The page size for the mips cpu, like many others, may be changed at runtime.
The page
size used at that point is reported to softmmu during tlb_fill.
The value of TARGET_PAGE_BITS must be the minimum supported by the cpu.
For Arm, the minimum for armv6 was 1k, then armv7 dropped support for tiny
pages so the
minimum is 4k. At runtime, armv8 supports page sizes of 4k, 16k, and 64k.
For MIPS, ignoring those cpus which support 1k pages, the minimum is 4k.
If all types of cpus of the target arch has the same minimum supported
page size, we only need to define TARGET_PAGE_BITS; otherwise we need
to define TARGET_PAGE_BITS_VARY, and TARGET_PAGE_BITS_MIN means the
minimum supported page size of the smallest supported page's cpu type.
Here we remove TARGET_PAGE_BITS_VARY because we just ignore the 1K
pages.
Am I right now?
Yes.
OK, then it is fine to remove the TARGET_PAGE_BITS_VARY and
TARGET_PAGE_BITS_MIN definition. But Loongson still prefers 16K pages
(4K pages cause cache alias on Loongson), so I want to keep
mc->minimum_page_bits = 14.
You can't set minimum_page_size = 14, because TARGET_PAGE_BITS_VARY is unset.
However, the Loongson kernel will continue to correctly program 16k pages at runtime, and
we will continue to correctly provide 16k pages to softmmu during tlb_fill. All is well.
r~