From patchwork Thu Mar 20 22:29:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 874983 Delivered-To: patch@linaro.org Received: by 2002:a5d:5f4c:0:b0:38f:210b:807b with SMTP id cm12csp573618wrb; Thu, 20 Mar 2025 15:32:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXHltolnj0oufH3upEMpKs3lG1fP1s/qHrJS6OE2b3gjsp2aVeuec3eKx6jLYPNHX1+pHn0Yw==@linaro.org X-Google-Smtp-Source: AGHT+IH1A5pFjTFs5OIfMyFmhm8nK0S68ph4FwP+nJwJz4Fnf4TLRXD4XeRzgfzGwCqfxLEzpEim X-Received: by 2002:ac8:7d4d:0:b0:477:1e1f:43d7 with SMTP id d75a77b69052e-4771e1f43e6mr13888571cf.0.1742509922586; Thu, 20 Mar 2025 15:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1742509922; cv=none; d=google.com; s=arc-20240605; b=gIT5ODDiVtf1rgt858YAYciPZ+yMZ+NNSo1I5C8/9frBhyIwiLKinxppH2AlrC/xpi sHuhaN2DhKC2O3QDnGF1qo5qTIoY7ElxfSvUcwN99nnJ0uEq68/jMcQwOdUtfYmbRP2O +VIB1IdoRaLTjDLBvhlSOvPRDvLW9RZCTGkyGXYNjVHqjoOj/S7xYfnjy4f4ef78XMld 5ZJoa52sZik/EbM3ImvkV0w94cJW2keyeo4AzHdA1t5V4G6ZH0sm5bJwTpzYxVA0vJPn MspX/rPzxNGtWvrcqJwRjJ/bwKE9MqvrwRmBMgaz6xBQOV+ru7DVdyc8nG9SQbn9+mWK Sj8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=iqhwlkf8vVBUTfdErW46dXre9tdQWHJk62D7NGKBzrU=; fh=nOkKbActdBXNisDSrdwXLE2FHRvxbNZxRZo5bVBICcQ=; b=VVoVYpRiTRkK/85Suoo584NCDgFV8lM/O4DXJaGZ8TNUzt/5wTOzrAMJ3LJbXsji1Z GDhjNSoPZURzbP4Y+YD90Wi9weYicQURq13i7Hw0AXG9hchFLuFjjdmCNA2/Tg4+IXY3 dAvIXaECf+r8Ww1IVlqtTZa0QpEqqfpludou4Ak+klz6GqQZowvrj2CzNjcxOoShl4fC ahBUPqHUZgmQRIg8mQMzZpIy0PS8xplQwRkaRBjSIT/3BWe+z5grR/ZoA/jfCba4OJwq 3xbzTLxHSay9l99/sY1VapeurikBZ63YeQWY0ld0xLa2TnqkYiqWg7r/+OnXadGcbqiT A4Yg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HMXX2Y63; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4771d15cebfsi7199511cf.135.2025.03.20.15.32.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Mar 2025 15:32:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HMXX2Y63; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tvOPE-0002Nc-AD; Thu, 20 Mar 2025 18:30:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tvOPA-0002H2-Ck for qemu-devel@nongnu.org; Thu, 20 Mar 2025 18:30:24 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tvOP3-000764-Ct for qemu-devel@nongnu.org; Thu, 20 Mar 2025 18:30:24 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-223594b3c6dso30658815ad.2 for ; Thu, 20 Mar 2025 15:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1742509811; x=1743114611; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iqhwlkf8vVBUTfdErW46dXre9tdQWHJk62D7NGKBzrU=; b=HMXX2Y63oXl7RMdr3O4ZkuqwW6ZxgnDlGxtMlrpAH9NJNGhLS+ouOg1+sqEWNkfIHe c5TWmriqFzJK/o18EBgC3iU6Dxt+NV7B7syFC0QvCacaiYPuuylWeQiW5b7m2+aiRO0b OF90zgK5O3Ta2E6TIs8Ya0WX2gUDv5Mfgy+ZjnCCg4MV1Jta6Kvuv7jtmhhCEo+5glGM sNqbbnCrG2OylRZakQs+9sj6/L4JEFudDUo5MKvRQPUUpFQFHp5zFyD+4SaXq3ehpAcT xSh2OWbFoyYlwouSKtn/tU7uo28+6G2U+/NqGzsjtzIr5wWN+AOI5rGGTJtQLGHwuDSF ZZHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742509811; x=1743114611; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iqhwlkf8vVBUTfdErW46dXre9tdQWHJk62D7NGKBzrU=; b=INazp/1S3vFJwrz4W9pqL9LFXOeUuFSHQAzMOWSYUsxCt0XNykAua13wZS3jsN9UEt rpmJS9SsoUeFjB5+kE5Hdptz7X1v2MALxb61goBenwPL9Oll7JyNBtXMg9BWm9+jcx1v h9kw4aSqbHkoUKoT6B8Ivdl29eXMeifj7R3wLXSni+RiM9QoLn3HejCEQktRqKPesr6o krgbzBncR2XGM3Jgx43dUJonLytnDtPTkGOqMWUHVnupq8JMM+xynEyKt1a/hSmzvoiA DuE83QGzdEnwWfCIGBc9RtMGmA2XqLNWpvqn0CMd1pCZMn60s/UOIJA910FpxG/NIMW8 sAmA== X-Gm-Message-State: AOJu0YxbZrHy2J6n83YrZaUc7wPM54/Qpy4piS9RBgrslOO9unN1cbb1 /h7Dkm1cBMqAjLqhvCiW7ICIsXCqGOsq6EL1wORlMMY/GfxuM93iNzn/SMAFQ1Zi0AdIftUAMih k X-Gm-Gg: ASbGncteOAfDJ9mwbipis+GAlytnv0bAnQc2TBifAmXPjXUUJWNsM+3KMWhk93nwFDS ETRuDGje5B/5F1/YpE5ruxQyL9p/agfaJXOOpyrJ6YnjNYlJJuL7sxv5xqyFkDhm+xJpREF7Ko5 KSo32/rQPRbQNoxAsU6cFg2LX9OXbZozqCqo2xldmh9s9wGIqAZwVppNDBjTxUSjL10S0pqBQ+v bA0kp56eQnhkJ3Zyt0TCHG2ntsvX7qraPNSlBycm9haxXIkWQjNeGknre5b81xumjMhyrxEOOnJ r9j+fMynDZ2B7kbqlI1DKeJmdtqX0Ys2l8GR0W00QY+0ATSxZnCC1H0= X-Received: by 2002:a17:903:1110:b0:21f:ba77:c45e with SMTP id d9443c01a7336-22780e20562mr11953595ad.45.1742509810917; Thu, 20 Mar 2025 15:30:10 -0700 (PDT) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22780f4581csm3370145ad.59.2025.03.20.15.30.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Mar 2025 15:30:10 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, qemu-arm@nongnu.org, Peter Maydell , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Pierrick Bouvier Subject: [PATCH v2 00/30] single-binary: start make hw/arm/ common Date: Thu, 20 Mar 2025 15:29:32 -0700 Message-Id: <20250320223002.2915728-1-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org This series focuses on removing compilation units duplication in hw/arm. We start with this architecture because it should not be too hard to transform it, and should give us some good hints on the difficulties we'll meet later. We first start by making changes in global headers to be able to not rely on specific target defines. In particular, we completely remove cpu-all.h. We then focus on removing those defines from target/arm/cpu.h. >From there, we modify build system to create a new hw common library (per base architecture, "arm" in this case), instead of compiling the same files for every target. Finally, we can declare hw/arm/boot.c, and most of the boards as common as a first step for this part. - Based-on: 20250317183417.285700-1-pierrick.bouvier@linaro.org ("[PATCH v6 00/18] make system memory API available for common code") https://lore.kernel.org/qemu-devel/20250317183417.285700-1-pierrick.bouvier@linaro.org/ - Based-on: 20250318213209.2579218-1-richard.henderson@linaro.org ("[PATCH v2 00/42] accel/tcg, codebase: Build once patches") https://lore.kernel.org/qemu-devel/20250318213209.2579218-1-richard.henderson@linaro.org v2: - rebase on top of Richard series - add target include in hw_common lib - hw_common_lib uses -DCOMPILE_SYSTEM_VS_USER introduced by Richard series - remove cpu-all header - remove BSWAP_NEEDED define - new tlb-flags header - Cleanup i386 KVM_HAVE_MCE_INJECTION definition + move KVM_HAVE_MCE_INJECTION - remove comment about cs_base in target/arm/cpu.h - updated commit message about registers visibility between aarch32/aarch64 - tried remove ifdefs in target/arm/helper.c but this resulted in more a ugly result. So just comment calls for now, as we'll clean this file later. - make most of the boards in hw/arm common Pierrick Bouvier (30): exec/cpu-all: remove BSWAP_NEEDED exec/cpu-all: extract tlb flags defines to exec/tlb-flags.h exec/cpu-all: move cpu_copy to linux-user/qemu.h include/exec/cpu-all: move compile time check for CPUArchState to cpu-target.c exec/cpu-all: remove system/memory include exec/cpu-all: remove exec/page-protection include exec/cpu-all: remove tswap include exec/cpu-all: remove exec/cpu-interrupt include exec/cpu-all: remove exec/cpu-defs include exec/cpu-all: remove exec/target_page include exec/cpu-all: remove hw/core/cpu.h include accel/tcg: fix missing includes for TCG_GUEST_DEFAULT_MO accel/tcg: fix missing includes for TARGET_HAS_PRECISE_SMC exec/cpu-all: remove cpu include exec/cpu-all: transfer exec/cpu-common include to cpu.h headers exec/cpu-all: remove this header exec/target_page: runtime defintion for TARGET_PAGE_BITS_MIN accel/kvm: move KVM_HAVE_MCE_INJECTION define to kvm-all.c exec/poison: KVM_HAVE_MCE_INJECTION can now be poisoned target/arm/cpu: always define kvm related registers target/arm/cpu: flags2 is always uint64_t target/arm/cpu: define same set of registers for aarch32 and aarch64 target/arm/cpu: remove inline stubs for aarch32 emulation meson: add common hw files hw/arm/boot: make compilation unit hw common hw/arm/armv7m: prepare compilation unit to be common hw/arm/digic_boards: prepare compilation unit to be common hw/arm/xlnx-zynqmp: prepare compilation unit to be common hw/arm/xlnx-versal: prepare compilation unit to be common hw/arm: make most of the compilation units common meson.build | 37 +++++++- accel/tcg/internal-target.h | 1 + accel/tcg/tb-internal.h | 1 - hw/s390x/ipl.h | 2 + include/exec/cpu_ldst.h | 1 + include/exec/exec-all.h | 1 + include/exec/poison.h | 4 + include/exec/target_page.h | 3 + include/exec/{cpu-all.h => tlb-flags.h} | 38 +------- include/hw/core/cpu.h | 2 +- include/qemu/bswap.h | 2 +- include/system/kvm.h | 2 - linux-user/qemu.h | 3 + linux-user/sparc/target_syscall.h | 2 + linux-user/syscall_defs.h | 2 +- target/alpha/cpu.h | 4 +- target/arm/cpu.h | 40 ++------ target/arm/internals.h | 1 + target/avr/cpu.h | 4 +- target/hexagon/cpu.h | 3 +- target/hppa/cpu.h | 5 +- target/i386/cpu.h | 5 +- target/i386/hvf/vmx.h | 1 + target/loongarch/cpu.h | 4 +- target/m68k/cpu.h | 4 +- target/microblaze/cpu.h | 4 +- target/mips/cpu.h | 4 +- target/openrisc/cpu.h | 4 +- target/ppc/cpu.h | 4 +- target/ppc/mmu-hash32.h | 2 + target/ppc/mmu-hash64.h | 2 + target/riscv/cpu.h | 4 +- target/rx/cpu.h | 4 +- target/s390x/cpu.h | 4 +- target/sh4/cpu.h | 4 +- target/sparc/cpu.h | 4 +- target/tricore/cpu.h | 3 +- target/xtensa/cpu.h | 4 +- accel/kvm/kvm-all.c | 5 + accel/tcg/cpu-exec.c | 3 +- accel/tcg/cputlb.c | 1 + accel/tcg/tb-maint.c | 1 + accel/tcg/translate-all.c | 1 + accel/tcg/user-exec.c | 2 + bsd-user/elfload.c | 6 +- cpu-target.c | 5 + hw/alpha/dp264.c | 1 + hw/alpha/typhoon.c | 1 + hw/arm/armv7m.c | 12 ++- hw/arm/boot.c | 2 + hw/arm/digic_boards.c | 2 +- hw/arm/smmuv3.c | 1 + hw/arm/xlnx-versal.c | 2 - hw/arm/xlnx-zynqmp.c | 2 - hw/hppa/machine.c | 1 + hw/i386/multiboot.c | 1 + hw/i386/pc.c | 1 + hw/i386/pc_sysfw_ovmf.c | 1 + hw/i386/vapic.c | 1 + hw/loongarch/virt.c | 1 + hw/m68k/next-cube.c | 1 + hw/m68k/q800.c | 1 + hw/m68k/virt.c | 1 + hw/openrisc/boot.c | 1 + hw/pci-host/astro.c | 1 + hw/ppc/e500.c | 1 + hw/ppc/mac_newworld.c | 5 +- hw/ppc/mac_oldworld.c | 5 +- hw/ppc/ppc.c | 1 + hw/ppc/ppc_booke.c | 1 + hw/ppc/prep.c | 1 + hw/ppc/spapr_hcall.c | 1 + hw/ppc/spapr_ovec.c | 1 + hw/riscv/riscv-iommu-pci.c | 1 + hw/riscv/riscv-iommu.c | 1 + hw/s390x/s390-pci-bus.c | 1 + hw/s390x/s390-pci-inst.c | 1 + hw/s390x/s390-skeys.c | 1 + hw/sparc/sun4m.c | 7 +- hw/sparc64/sun4u.c | 7 +- hw/xtensa/pic_cpu.c | 1 + linux-user/elfload.c | 8 +- monitor/hmp-cmds-target.c | 1 + semihosting/uaccess.c | 2 +- target/alpha/helper.c | 2 + target/arm/gdbstub64.c | 1 + target/arm/helper.c | 6 ++ target/arm/hvf/hvf.c | 1 + target/arm/ptw.c | 1 + target/arm/tcg/helper-a64.c | 1 + target/arm/tcg/hflags.c | 4 +- target/arm/tcg/mte_helper.c | 1 + target/arm/tcg/sve_helper.c | 1 + target/arm/tcg/tlb-insns.c | 1 + target/avr/helper.c | 2 + target/hexagon/translate.c | 1 + target/i386/arch_memory_mapping.c | 1 + target/i386/helper.c | 2 + target/i386/hvf/hvf.c | 1 + target/i386/kvm/hyperv.c | 1 + target/i386/kvm/kvm.c | 1 + target/i386/kvm/xen-emu.c | 1 + target/i386/sev.c | 1 + target/i386/tcg/system/excp_helper.c | 2 + target/i386/tcg/system/misc_helper.c | 1 + target/i386/tcg/system/tcg-cpu.c | 1 + target/i386/xsave_helper.c | 1 + target/loongarch/cpu_helper.c | 1 + target/loongarch/tcg/translate.c | 1 + target/m68k/helper.c | 1 + target/microblaze/helper.c | 1 + target/microblaze/mmu.c | 1 + target/mips/tcg/system/cp0_helper.c | 1 + target/mips/tcg/translate.c | 1 + target/openrisc/mmu.c | 1 + target/ppc/excp_helper.c | 1 + target/ppc/mmu-book3s-v3.c | 1 + target/ppc/mmu-hash64.c | 1 + target/ppc/mmu-radix64.c | 1 + target/riscv/cpu_helper.c | 1 + target/riscv/op_helper.c | 1 + target/riscv/pmp.c | 1 + target/riscv/vector_helper.c | 2 + target/rx/cpu.c | 1 + target/s390x/helper.c | 1 + target/s390x/ioinst.c | 1 + target/s390x/tcg/mem_helper.c | 1 + target/sparc/ldst_helper.c | 1 + target/sparc/mmu_helper.c | 2 + target/tricore/helper.c | 1 + target/xtensa/helper.c | 1 + target/xtensa/mmu_helper.c | 1 + target/xtensa/op_helper.c | 1 + target/xtensa/xtensa-semi.c | 1 + tcg/tcg-op-ldst.c | 2 +- hw/arm/meson.build | 117 ++++++++++++------------ 136 files changed, 302 insertions(+), 205 deletions(-) rename include/exec/{cpu-all.h => tlb-flags.h} (78%)