Created attachment 266785 [details] fix jump to correct label Hello, I'm using qemu-system-aarch64 with kernel build from current 'main', based on VIRT kernconf - and it does not boot. The fix is in attachment. The kernel code has size 8M (etext), ergo perfectly aligned to 2M leaves. The 'build_l3_page_pagetable' function - which populates 4K leaves - is called with argument entries = 0 in register x10. The first instruction (cbz x10, 2f) compares x10 against 0 and in case of match it jumps to '2f' - which is a *first forward* label named '2' - which stores the entry (not-yet-configured x13) into the page table (str x13, [x6, x11, lsl #3]). In the function, there is a second '2' label, right before 'ret' instruction, which is where the conditional 'cbz x10, 2f' should aim.
As this is a patch can you post it either via https://reviews.freebsd.org/ or as a GitHub pull request.
(In reply to Andrew Turner from comment #1) Ok, I will use pull request, thanks.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=a9f2f92322f211921b955b13b088624efe7f901a commit a9f2f92322f211921b955b13b088624efe7f901a Author: Marian Cingel <cingel.marian@gmail.com> AuthorDate: 2026-01-03 14:45:27 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2026-01-06 10:36:37 +0000 arm64: Fix jump to wrong label in case of 0 entries Broke qemu-system-aarch6 boot with VIRT kernconf PR: 292156 Fixes: ea8dc498aa8e ("arm64: Create an L3 table to limit permissions") Signed-off-by: Marian Cingel <cingel.marian@gmail.com> Pull Request: https://github.com/freebsd/freebsd-src/pull/1943 sys/arm64/arm64/locore.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
I'm not an expert on compiler. From my perspective, having the same labels within same ASM code block is bad smell. Can the compiler emit warnings about such kind of style ?
(In reply to Zhenlei Huang from comment #4) Hi, I'm not compiler expert, this is just my opinion: It is a "local label" and it is common practice f.i to implement loops this way, so you don't have to make a and maintain unique labels across the file. Assembler (GNU gas) is only aware of scope per file/translation_unit - it does not recognize blocks.
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5ca05e51c861387003f0ef0ee6862bc39583dab0 commit 5ca05e51c861387003f0ef0ee6862bc39583dab0 Author: Marian Cingel <cingel.marian@gmail.com> AuthorDate: 2026-01-03 14:45:27 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2026-02-09 14:47:51 +0000 arm64: Fix jump to wrong label in case of 0 entries Broke qemu-system-aarch6 boot with VIRT kernconf PR: 292156 Fixes: ea8dc498aa8e ("arm64: Create an L3 table to limit permissions") Signed-off-by: Marian Cingel <cingel.marian@gmail.com> Pull Request: https://github.com/freebsd/freebsd-src/pull/1943 (cherry picked from commit a9f2f92322f211921b955b13b088624efe7f901a) sys/arm64/arm64/locore.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)