aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-08-29target/loongarch: Add enum type TLBRet definitionBibo Mao4-36/+40
There is mixed usage between enum variable TLBRET_xxx and int type, here add enum type TLBRet definition and replace int type variable with enum type TLBRet in some functions. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-29target/loongarch: Add header file cpu-mmu.hBibo Mao6-20/+34
New header file cpu-mmu.h is added and move mmu relative function declaration to this file. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-29target/loongarch: Set page size in TLB entry with STLBBibo Mao1-31/+10
With VTLB different TLB entry may have different page size, and page size is set in PS field of TLB entry. However with STLB, all the TLB entries have the same page size, page size comes from register CSR_STLBPS, PS field of TLB entry is not used. Here PS field of TLB entry is used with all TLB entries, even with STLB. It is convenient with TLB maintainance operation. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn>
2025-08-29target/loongarch: Define function loongarch_cpu_post_init as staticBibo Mao2-92/+90
Function loongarch_cpu_post_init() is implemented and used in the same file target/loongarch/cpu.c, it can be defined as static function. This patch moves implementation about function loongarch_cpu_post_init() before it is referenced. And it is only code movement, no function change. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-29target/loongarch: Move some function definition to kvm directoryBibo Mao3-11/+3
Move function definition specified with kvm to the corresponding directory. Also remove header file "cpu.h" including outside of macro QEMU_KVM_LOONGARCH_H. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-29Merge tag 'pull-loongarch-20250828' of https://github.com/gaosong715/qemu ↵Richard Henderson9-45/+54
into staging pull-loongarch-20250828 # -----BEGIN PGP SIGNATURE----- # # iLMEAAEIAB0WIQTKRzxE1qCcGJoZP81FK5aFKyaCFgUCaLBJawAKCRBFK5aFKyaC # FhiGBACdQ1hkGp79sFrwi0h6GaP4NdbG8jx0vNGwPOqvbIc6Frn4bSyATNZI76k+ # /B2KTGLe4fU95QeXCJ937N1mNqcbagxFVeCaqSS71wuSfVKZBWLvGi8CckCqWU57 # GeUCQTOgA+E94C93G0pdgtyi2r7ambPnqTNifghkdoSN52Ta1Q== # =pUq/ # -----END PGP SIGNATURE----- # gpg: Signature made Thu 28 Aug 2025 10:19:55 PM AEST # gpg: using RSA key CA473C44D6A09C189A193FCD452B96852B268216 # gpg: Good signature from "Song Gao <gaosong@loongson.cn>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: CA47 3C44 D6A0 9C18 9A19 3FCD 452B 9685 2B26 8216 * tag 'pull-loongarch-20250828' of https://github.com/gaosong715/qemu: hw/intc/loongarch_pch_pic: Fix ubsan warning and endianness issue target/loongarch: Guard 64-bit-only insn translation with TRANS64 macro Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28hw/intc/loongarch_pch_pic: Fix ubsan warning and endianness issueThomas Huth1-7/+8
When booting the Linux kernel from tests/functional/test_loongarch64_virt.py with a QEMU that has been compiled with --enable-ubsan, there is a warning like this: .../hw/intc/loongarch_pch_pic.c:171:46: runtime error: index 512 out of bounds for type 'uint8_t[64]' (aka 'unsigned char[64]') SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior .../hw/intc/loongarch_pch_pic.c:171:46 .../hw/intc/loongarch_pch_pic.c:175:45: runtime error: index 256 out of bounds for type 'uint8_t[64]' (aka 'unsigned char[64]') SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior .../hw/intc/loongarch_pch_pic.c:175:45 It happens because "addr" is added first before substracting the base (PCH_PIC_HTMSI_VEC or PCH_PIC_ROUTE_ENTRY). Additionally, this code looks like it is not endianness safe, since it uses a 64-bit pointer to write values into an array of 8-bit values. Thus rework the code to use the stq_le_p / ldq_le_p helpers here and make sure that we do not create pointers with undefined behavior by accident. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
2025-08-28target/loongarch: Guard 64-bit-only insn translation with TRANS64 macroWANG Rui8-38/+46
This patch replaces uses of the generic TRANS macro with TRANS64 for instructions that are only valid when 64-bit support is available. This improves correctness and avoids potential assertion failures or undefined behavior during translation on 32-bit-only configurations. Signed-off-by: WANG Rui <wangrui@loongson.cn> Reviewed-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>
2025-08-28Merge tag 'pull-lu-20250828' of https://gitlab.com/rth7680/qemu into stagingRichard Henderson69-1629/+1528
linux-user: do not print IP socket options by default linux-user: Add strace for rseq linux-user: Move get_elf_cpu_model to target/elfload.c linux-user: Move get_elf_hwcap to target/elfload.c linux-user: Move get_elf_hwcap2 to target/elfload.c linux-user: Move get_elf_platform to target/elfload.c linux-user: Move get_elf_base_platform to target/elfload.c linux-user: Create init_main_thread in target/cpu_loop.c semihosting: Retrieve stack top from image_info semihosting: Initialize heap once per process # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmive68dHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV+LwwgAsjSjc5Bjal0mc+UI # Qmb7qbNM7YDhJ4o9eJoT7AfEo3AlR8vhA01/ayfBEKMxYStl4tkZU1jthb7LLTyS # TfPBsZEBF/ZuTYLV56dfQ/6AJZ2g5OhqJbeVeD8Ef93JK60qgBerCK/D5SfphSfh # TQtOG0LU2BXzGt8K3WghFxsFQeYcTrNeT5JdtIXYrmGQmDnPh3dOnQrFcO1leFLa # khUfj7l7bE1Rgqo5h5pveaee4AD3VndYe10zvSVKHKjBL4Zd3hxf3MypNRpDFC0v # ua9xt4qXtWgEYSkKPj/mipcd9fsb+RKs6kPA3oojwb8DCkFAZ0UogIwmd9/7lz8u # FMp+iQ== # =Nu63 # -----END PGP SIGNATURE----- # gpg: Signature made Thu 28 Aug 2025 07:42:07 AM AEST # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-lu-20250828' of https://gitlab.com/rth7680/qemu: (46 commits) linux-user: do not print IP socket options by default linux-user: Add strace for rseq linux-user: Remove do_init_main_thread linux-user/hexagon: Create init_main_thread linux-user/xtensa: Create init_main_thread linux-user/hppa: Create init_main_thread linux-user/riscv: Create init_main_thread linux-user/s390x: Create init_main_thread linux-user/alpha: Create init_main_thread linux-user/m68k: Create init_main_thread linux-user/sh4: Create init_main_thread linux-user/openrisc: Create init_main_thread linux-user/microblaze: Create init_main_thread linux-user/mips: Create init_main_thread linux-user/loongarch64: Create init_main_thread linux-user/ppc: Create init_main_thread linux-user/sparc: Create init_main_thread linux-user/aarch64: Create init_main_thread linux-user/arm: Remove a.out startup remenents linux-user/arm: Create init_main_thread ... Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: do not print IP socket options by defaultŁukasz Stelmach1-16/+20
IP protocols should not be printed unless the socket is an IPv4 or IPv6 one. Current arrangement erroneously prints IPPROTO_IP for Unix domain sockets. Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20250827095412.2348821-1-l.stelmach@samsung.com>
2025-08-28linux-user: Add strace for rseqJoel Stanley1-0/+3
build/qemu-riscv64 -cpu rv64,v=on -d strace build/tests/tcg/riscv64-linux-user/test-vstart-overflow 1118081 riscv_hwprobe(0xffffbc038200,1,0,0,0,0) = 0 1118081 brk(NULL) = 0x0000000000085000 1118081 brk(0x0000000000085b00) = 0x0000000000085b00 1118081 set_tid_address(0x850f0) = 1118081 1118081 set_robust_list(0x85100,24) = -1 errno=38 (Function not implemented) 1118081 rseq(0x857c0,32,0,0xf1401073) = -1 errno=38 (Function not implemented) Signed-off-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20250826060341.1118670-1-joel@jms.id.au>
2025-08-28linux-user: Remove do_init_main_threadRichard Henderson4-50/+1
All targets have been converted, so we can call init_main_thread directly. Remove do_init_main_thread and HAVE_INIT_MAIN_THREAD. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/hexagon: Create init_main_threadRichard Henderson2-9/+6
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/xtensa: Create init_main_threadRichard Henderson2-23/+17
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/hppa: Create init_main_threadRichard Henderson2-19/+12
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/riscv: Create init_main_threadRichard Henderson2-12/+5
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/s390x: Create init_main_threadRichard Henderson2-15/+9
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/alpha: Create init_main_threadRichard Henderson2-14/+5
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Note that init_thread had set ps in target_pt_regs, but target_cpu_copy_regs did not copy to env. This turns out to be ok because alpha_cpu_initfn initializes flags properly. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/m68k: Create init_main_threadRichard Henderson2-29/+7
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/sh4: Create init_main_threadRichard Henderson2-13/+5
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/openrisc: Create init_main_threadRichard Henderson2-13/+5
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/microblaze: Create init_main_threadRichard Henderson2-41/+6
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/mips: Create init_main_threadRichard Henderson2-17/+7
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Note that init_thread had set cp0_status in target_pt_regs, but target_cpu_copy_regs did not copy to env. This turns out to be ok because mips_cpu_reset_hold initializes CP0_Status properly. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/loongarch64: Create init_main_threadRichard Henderson2-15/+5
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Note that init_thread had set crmd in target_pt_regs, but target_cpu_copy_regs did not copy to env. This turns out to be ok because loongarch_cpu_reset_hold initializes CRMD properly. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/ppc: Create init_main_threadRichard Henderson2-24/+19
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/sparc: Create init_main_threadRichard Henderson2-19/+9
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/aarch64: Create init_main_threadRichard Henderson2-17/+7
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/arm: Remove a.out startup remenentsRichard Henderson1-4/+0
The setting of r1/r2 was removed in kernel commit acfdd4b1f7590d0 ("ARM: 7791/1: a.out: remove partial a.out support"), and the kernel commit message explains the history. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/arm: Create init_main_threadRichard Henderson2-50/+44
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/i386: Create init_main_threadRichard Henderson3-49/+29
Merge init_thread and target_cpu_copy_regs. There's no point going through a target_pt_regs intermediate. Temporarily introduce HAVE_INIT_MAIN_THREAD during conversion. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Create do_init_main_threadRichard Henderson4-16/+12
Provide a unified function to initialize the main thread. Keep target_pt_regs isolated to this function. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move target_cpu_copy_regs decl to qemu.hRichard Henderson2-4/+3
The function is not used by bsd-user, so placement within include/user/cpu_loop.h is not ideal. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_base_platform to mips/elfload.cRichard Henderson5-36/+37
Pass in CPUState; define HAVE_ELF_BASE_PLATFORM. Since this was the only instance of ELF_BASE_PLATFORM, go ahead and provide the stub definition for other platforms. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Remove ELF_PLATFORMRichard Henderson1-14/+4
All real definitions of ELF_PLATFORM are now identical, and the stub definitions are NULL. Use HAVE_ELF_PLATFORM and provide a stub as a fallback definition of get_elf_platform. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/hppa: Create get_elf_platformRichard Henderson3-1/+8
Move the string literal to a new function. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/loongarch64: Create get_elf_platformRichard Henderson3-1/+7
Move the string literal to a new function. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_platform to arm/elfload.cRichard Henderson6-38/+38
Move the aarch32 get_elf_platform to arm/elfload.c; pass in CPUState. Create a simple version in aarch64/elfload.c, which we must do at the same time because of the ifdef dependency between TARGET_AARCH64 and TARGET_ARM. Since all versions of get_elf_platform now have the same signature, remove the ifdef from the declaration in loader.h. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user/i386: Return const data from get_elf_platformRichard Henderson1-8/+4
Rather than modify a static buffer, index into an array of const data. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_platform to {i386,x86_64}/elfload.cRichard Henderson6-16/+25
Move get_elf_platform to i386/elfload.c; pass in CPUState. Create a simple get_elf_platform for x86_64. Introduce HAVE_ELF_PLATFORM. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Remove ELF_HWCAP2Richard Henderson1-13/+10
All definitions of ELF_HWCAP2 are now identical. Provide a not-reached stub as a fallback definition of get_elf_hwcap2. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Remove ELF_HWCAPRichard Henderson1-23/+12
All real definitions of ELF_HWCAP are now identical, and the stub definitions are 0. Provide zero stub as a fallback definition. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_hwcap to riscv/elfload.cRichard Henderson4-18/+15
Change the return type to abi_ulong, and pass in the cpu. As this is the last instance of get_elf_hwcap to be converted, remove the ifdef around the declaration in loader.h. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move hwcap functions to s390x/elfload.cRichard Henderson5-64/+62
For get_elf_hwcap, change the return type to abi_ulong and pass in the cpu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_hwcap to sh4/elfload.cRichard Henderson4-29/+32
Change the return type to abi_ulong, and pass in the cpu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_hwcap to mips/elfload.cRichard Henderson5-52/+56
Change the return type to abi_ulong, and pass in the cpu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_hwcap to loongarch64/elfload.cRichard Henderson4-49/+52
Change the return type to abi_ulong, and pass in the cpu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move hwcap functions to ppc/elfload.cRichard Henderson4-115/+122
Change the return type to abi_ulong, and pass in the cpu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_hwcap to sparc/elfload.cRichard Henderson4-30/+32
Change the return type to abi_ulong, and pass in the cpu. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move hwcap functions to {arm,aarch64}/elfload.cRichard Henderson7-509/+510
For get_elf_hwcap and get_elf_hwcap2, change the return type to abi_ulong, and pass in the cpu. We must do these targets at the same time because of the ifdef dependency between TARGET_AARCH64 and TARGET_ARM. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2025-08-28linux-user: Move get_elf_hwcap to {i386,x86_64}/elfload.cRichard Henderson6-8/+18
Change the return type to abi_ulong, and pass in the cpu. Duplicate the one line function between i386 and x86_64, as most other additions to elfload.c won't be common. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>