From patchwork Tue Mar 11 19:57:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 872494 Delivered-To: patch@linaro.org Received: by 2002:a5d:64ce:0:b0:38f:210b:807b with SMTP id f14csp1660854wri; Tue, 11 Mar 2025 12:58:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVs6ul9VkiX2kxWd/KEwyox+z25QjRJg6SiMjfwr/5dPNV8LLHizs0qNTIsCydW21j+8GJ8rg==@linaro.org X-Google-Smtp-Source: AGHT+IE3d4q+N8D+J5pDiX3HOow8uV7lAQrF6A50p5H8it1UahMMs+zhAmwtlPasaIB5KbebHYLh X-Received: by 2002:a05:620a:488c:b0:7c5:3c69:2bc7 with SMTP id af79cd13be357-7c53c692f56mr2367699285a.5.1741723124755; Tue, 11 Mar 2025 12:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741723124; cv=none; d=google.com; s=arc-20240605; b=ZLvfJDtn354gI76UmBwmksVhhM+S6WfDEBDBJgk8RglkLz3/e+mFcv9GSxYBBcoPAm jwb3+KeLm+MoNSMOBcBgf1R8FHKhMtl/WhnieAYGwHZ0ku4j5QU44KL7Ein1rLjj1zkL w9QzZ64gob+0jYul1Fri4QdllAkJXARSLaOXeaSyKmaPiELaJHByIjN/SblnaFyvXNnL HZZ4qdDgNE0D8x0LIjmkteIFN8sidan7NcubUsxoPKVv5YExGrSyXvrc34ol2cy0++mO cU1giSDdlDi1mS1hdOAz1sQOonuJr082YyfHwbuJAdeqo+Jw/8cEiSMqXpQQMyEAjDo6 dJEw== 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=BJxldrM9ls/rNwHOkfKDTsLlkFzxI4z634GC5RzciYk=; fh=kEoQpoDeYKqqTWMOc0Iq2e1LPI+fIsbUMg+I80Y/mck=; b=CJNZPkU6d6VjTH/IpALSMkd3BQYLP7h72E7iML9A2/0GOjFYkK5VxEHZM4ZJ8l2+pq sjw+tcfC3iNMsMX7KBlICHx8pqgi2/gOr90Fo9j+fgOmDhXEoqEH6T4WId7gX9TIiiNE rXidpJATvzJyj/fGHCrDvamlgFl5N3aI7fSDdh/ZkjU4I3HzP2RAgL+k6IqlI3/AQXs8 aaoVbCgGUDPGp+sM1qweQMRAD54OTcxeJKx2755C9ig4GWq1F4KiHkZr1RGk/UeEbzYI CdLhZAMonqq1qJL3nrpi1plySid/gnvy+k/dlBWnvcmydPVZSEVGzARbtHdFZsHOTUzH CqjA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gNt1cvGJ; 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 af79cd13be357-7c556b02c5bsi413656385a.593.2025.03.11.12.58.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Mar 2025 12:58:44 -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=gNt1cvGJ; 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 1ts5kC-0000yP-St; Tue, 11 Mar 2025 15:58:29 -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 1ts5jz-0000qJ-NW for qemu-devel@nongnu.org; Tue, 11 Mar 2025 15:58:17 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ts5jw-0008UD-S0 for qemu-devel@nongnu.org; Tue, 11 Mar 2025 15:58:15 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-224100e9a5cso113421495ad.2 for ; Tue, 11 Mar 2025 12:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741723091; x=1742327891; 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=BJxldrM9ls/rNwHOkfKDTsLlkFzxI4z634GC5RzciYk=; b=gNt1cvGJuhGpTH3MYysn9HKadCoGMja9x1abNSp/XzBJwNwd4hgRums1DgvkGAmNMW D94nau/wtuDmsrlzEppEQI+mMT+83yrHVNIopwH6TuUw1EZWn3bmEqXSEfJ6VPKahHYi ylwRWd/Hhpilyvr106HiBZkVG71l1R6JFMrEVDUlOHmKVj/TPm0MoGtc/ZqkcE7Ltvzo lHwQZ8Vvg3M/wL69BKvTFEfMPADY6wJ6HNQE5aiT19nDKgLJhI7VegLpzoogvGSvHF2J KWilWvKQpW3qk8rvYUeALWz3vAzvo0rFsIy6+v1bYpZBy7QPa1HZz1IGEAYftsz0jDXX ZBbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741723091; x=1742327891; 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=BJxldrM9ls/rNwHOkfKDTsLlkFzxI4z634GC5RzciYk=; b=TfKtrQ3nMTEvlHnUn5iGAgG/oKf12lWd4MJaUK7opC+O8QzHQAD+IhSXETBQl1IoB0 4u/G3bNu1cavH1VFvxtCJUf8XiZC8EBU0Pbrzu80fNhQXv6OqnYQTNDOm6lssdxp+KAJ 56V9dzr0c7tryPiIKXFi6XmsOqWCblCB4o0rGtd6xePT6pefCmsNrG0AQsHme69DCARZ /Yz7xTG1Bv57iQC4Fc5fXn4QMgNIEdGJ1SFEIi6ssogLwpPausc+nvULG7aWfahI4eHT M2Q+VV8776tIL+Plz3UD1dPxlgHwadxx0Dav6q1+HGaPMUtXijO+ruAsad7dmNVXEGre GrTA== X-Gm-Message-State: AOJu0YwRgYmtkJDzofOae+BhSrCAvAegDZbhipNYAXTVMuD+JHo8uKAR 4ifQfyIaXi+RUqV1PSSIVJcRUHN32IkSXaAgRkeKA/I94M7oJ52jte2Ik+bCo733AKBnaAkpSSI uOpk= X-Gm-Gg: ASbGncv6l4KX2OCueKV5hvLAWB7HBpUYolSdDSitIcz0DOZO4PX/WylelqfsUkJVq4s iPfTIgftIL3TA8NpH6ObhoZPLIOzzTUK3riJLB/oaBR1jPihhbEjXt7XEn2w8DCZ2F9PKHoE9Ih vD7m//xand3BLT2sL0VySWADh/Vf+anALT0UnmJLBqhH3i0NG3f5vyq4ID6f4sHgXzBH7a2rzI0 +BXOIczV+gsDbANg7QfmedVOED44mUzDgGTuPQ/UQX8RYmmyRk4hoKbhzIRKkcdFkBNl5Lc1L9Q nH5EaKn8U0XrYXji8HSt7JOPN2uHnDoUCCo/LoViVvrF X-Received: by 2002:a17:903:32ce:b0:223:39ae:a98 with SMTP id d9443c01a7336-22428a98102mr318619255ad.22.1741723090697; Tue, 11 Mar 2025 12:58:10 -0700 (PDT) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-736a6e5c13asm9646981b3a.157.2025.03.11.12.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Mar 2025 12:58:10 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: David Hildenbrand , Stefano Stabellini , "Edgar E. Iglesias" , Anthony PERARD , xen-devel@lists.xenproject.org, Nicholas Piggin , Richard Henderson , Weiwei Li , kvm@vger.kernel.org, Palmer Dabbelt , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paul Durrant , Liu Zhiwei , Daniel Henrique Barboza , manos.pitsidianakis@linaro.org, Peter Xu , Harsh Prateek Bora , Alistair Francis , alex.bennee@linaro.org, Yoshinori Sato , qemu-riscv@nongnu.org, qemu-ppc@nongnu.org, Pierrick Bouvier Subject: [PATCH v3 00/17] make system memory API available for common code Date: Tue, 11 Mar 2025 12:57:46 -0700 Message-Id: <20250311195803.4115788-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::635; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x635.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, SPF_PASS=-0.001 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 The main goal of this series is to be able to call any memory ld/st function from code that is *not* target dependent. As a positive side effect, we can turn related system compilation units into common code. The first 5 patches remove dependency of memory API to cpu headers and remove dependency to target specific code. This could be a series on its own, but it's great to be able to turn system memory compilation units into common code to make sure it can't regress, and prove it achieves the desired result. The next patches remove more dependencies on cpu headers (exec-all, memory-internal, ram_addr). Then, we add access to a needed function from kvm, some xen stubs, and we finally can turn our compilation units into common code. Every commit was tested to build correctly for all targets (on windows, linux, macos), and the series was fully tested by running all tests we have (linux, x86_64 host). v2: - reorder first commits (tswap change first, so memory cached functions can use it) - move st/ld*_p functions to tswap instead of bswap - add define for target_words_bigendian when COMPILING_PER_TARGET, equals to TARGET_BIG_ENDIAN (avoid overhead in target code) - rewrite devend_memop - remove useless exec-all.h in concerned patch - extract devend_big_endian function to reuse in system/memory.c - rewrite changes to system/memory.c v3: - move devend functions to memory_internal.h - completed description for commits removing cpu.h dependency Pierrick Bouvier (17): exec/tswap: target code can use TARGET_BIG_ENDIAN instead of target_words_bigendian() exec/tswap: implement {ld,st}.*_p as functions instead of macros exec/memory_ldst: extract memory_ldst declarations from cpu-all.h exec/memory_ldst_phys: extract memory_ldst_phys declarations from cpu-all.h exec/memory.h: make devend_memop "target defines" agnostic codebase: prepare to remove cpu.h from exec/exec-all.h exec/exec-all: remove dependency on cpu.h exec/memory-internal: remove dependency on cpu.h exec/ram_addr: remove dependency on cpu.h system/kvm: make kvm_flush_coalesced_mmio_buffer() accessible for common code exec/ram_addr: call xen_hvm_modified_memory only if xen is enabled hw/xen: add stubs for various functions system/physmem: compilation unit is now common to all targets include/exec/memory: extract devend_big_endian from devend_memop include/exec/memory: move devend functions to memory-internal.h system/memory: make compilation unit common system/ioport: make compilation unit common include/exec/cpu-all.h | 66 ----------------------- include/exec/exec-all.h | 1 - include/exec/memory-internal.h | 21 +++++++- include/exec/memory.h | 30 ++++------- include/exec/ram_addr.h | 11 ++-- include/exec/tswap.h | 81 +++++++++++++++++++++++++++-- include/system/kvm.h | 6 +-- include/tcg/tcg-op.h | 1 + target/ppc/helper_regs.h | 2 + include/exec/memory_ldst.h.inc | 4 -- include/exec/memory_ldst_phys.h.inc | 5 +- cpu-target.c | 1 + hw/ppc/spapr_nested.c | 1 + hw/sh4/sh7750.c | 1 + hw/xen/xen_stubs.c | 56 ++++++++++++++++++++ page-vary-target.c | 2 +- system/ioport.c | 1 - system/memory.c | 17 ++---- target/riscv/bitmanip_helper.c | 2 +- hw/xen/meson.build | 3 ++ system/meson.build | 6 +-- 21 files changed, 192 insertions(+), 126 deletions(-) create mode 100644 hw/xen/xen_stubs.c