From patchwork Mon Mar 10 04:58:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 872187 Delivered-To: patch@linaro.org Received: by 2002:a5d:64ce:0:b0:38f:210b:807b with SMTP id f14csp813103wri; Sun, 9 Mar 2025 22:03:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVJoWmOIJ4VVFCM0TPztdNXEvNlHqhfNUlKPQ2X/FNecPq8Iad4S9rVjiljo+ByRoSkM/Hq4w==@linaro.org X-Google-Smtp-Source: AGHT+IFP37KRCBlcxxEutBCQ8tk8A6JImcpeeuV5M4D/S1eF5iMTAyZwulAj3pgCjB+igoRjW8mO X-Received: by 2002:a05:620a:6088:b0:7c3:d752:f24c with SMTP id af79cd13be357-7c4e61ca099mr1896251585a.45.1741582983574; Sun, 09 Mar 2025 22:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1741582983; cv=none; d=google.com; s=arc-20240605; b=JgAa63kXZ5KKc7/e+hN3QyVADiRmRU6bEXzi0/BR8WLXi4hDFpm262js278l63i1Em jzo55Xobm+QK4mL5zYnP4t4l4dv8f0OxKNfrhv2mqDtpxIECqCFk387A20300yiinNNW 5x3QkvcBKZt5Il2ND3hFBqjI/4398sbkpRwMnSsbLI9scRfbbsskQILSg//02MURmko+ VQnb9eT7MBtfNM/aOTCHOPSOqvkHdRF8ALS8YFiesFXFyleB+Foa7yXSWSOmpsv5GDNG 33aNHmsFmtLvJ6bpD8kdENU4Z8v7dzpNb6KiAsc6i/SoD52+eAGj9WTbEdJrlXoTaewo 0btA== 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=CyMnY8DCOyhH4sll8UBWjGQBOdpS4N2V2sRcD5CyECM=; fh=AOAaWavohGY9wY0gHpJ2Sua/5WG2LnOAbadvwNNYWfE=; b=KEdvna0r0Eee4IHcCZXvx3zmnSq4GAytcZeQBhPH+8jYBnX57fvvMuTCyRgzptyNdB gt3nAYl2TFDGkx2V6f54pC15M3DbGqlOeNr7mgxKalrSzVNsxIpBJRB2BBot8o6tDdze NuNcECeU0ToZqgoYTnCpKf2YQWVK/mRYSfrIVRFv3vO32cI+N+LsrHv1Q4yD98kjvfLs vJpC8Koat/40xTEaM9RNWi0JAmK9HGQ4AerlKdqyRAtG4UgQSo+7Sd8tk3vU5vwCqnB7 CJ+Pj1UpgFh0NyF4o5oCe61MOVI/kMV9IJlejXn99v4MHTEnuqUlgheQXgRJu/KJJ7Nl vrDg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hfLiPxvy; 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-47672e87427si35194571cf.383.2025.03.09.22.03.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Mar 2025 22:03:03 -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=hfLiPxvy; 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 1trVE7-0002dt-Q3; Mon, 10 Mar 2025 00:58:55 -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 1trVE5-0002ce-OA for qemu-devel@nongnu.org; Mon, 10 Mar 2025 00:58:53 -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 1trVE3-000894-Ta for qemu-devel@nongnu.org; Mon, 10 Mar 2025 00:58:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-223594b3c6dso65469375ad.2 for ; Sun, 09 Mar 2025 21:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1741582730; x=1742187530; 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=CyMnY8DCOyhH4sll8UBWjGQBOdpS4N2V2sRcD5CyECM=; b=hfLiPxvyqxmTjLmZ3nHbM5hovdVZpMl8UjjeM9FOXEt19EmPihv0lDDEUNXHbaz+A2 grqQ439HrcAOhn+hbFe8/8kAgY6IEegpzXEqbP+qowOj7j92KbsgpqeNp80JrzHrWNt6 agXIGxUsEmhL+VhlqgWKC/JjNNo7Q3g0KcH+K9zBCqTdsE+2iFQBi4UPJFsPI8tFVN7W UQVPyAFxA+dxkYjlRwW99bsNZant7KFzGDvkxkQN4CrMJwZzazXCfz9M2Hw9zy/vJwX8 TxCYLJr3iRvzcrioUCmNv0pUuWlUth5YkejF2bofZPs4SBBaug3zm/HJnwHapxPuo/v+ 1OeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741582730; x=1742187530; 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=CyMnY8DCOyhH4sll8UBWjGQBOdpS4N2V2sRcD5CyECM=; b=TePJt39Tknia7slZkZsyCmMY6J0ZLv8NSxOB9zOZUQa7BM3+ZOzLYuIqnRAy0wMpSO QkypdM0W3PCqOMqxZRpB2QpBsSVTNY2tPvvJe9RDa+kB18/6uIn2nia1W6CIo6OLfMVn CwH5m0tL53zUtIvI+AqWnnE1fu2hXz1MYxO0/NWw+ZwlkmbNR6bpBCIhjXsfBly9k50R x/0kyOoq5t9GJoINJttOY0bmsvNAOoLLHDkwGdlEG6R6OfukzgMP5wKHxcMK2QUyIlwO GRx5j4Eh3OUf0LOQHAqSzTJrjncFDl+TTCaUEP5ia0jErRqkCaow+s6BeiTUOuiPj4iW Om8A== X-Gm-Message-State: AOJu0YwszJeg/pbzHBGytBPJblAI4V1YeK3TZvD1+N2Zdh/DHEMMImBf l0p9ZQxscAEYVsDnkfM5boHQNdiXKgWD9OEOrlacaHZzOaXQQMSgr9TAYhuxNl2Xed6MQnP4ood Rpcc= X-Gm-Gg: ASbGncuA1telyNQzRbxNlaQNCXX/zTGOAmgeJWANfGbW5O3dh2/cW2ss5CzhSoy/Zsp Kw3PjjhIc3bsFzMaKscDgcndUflGXX20+4cWCBR+1lF1Y15V437TkdL+Ravjv4wE3tKUI071Lkm 09c2VtgwtiufqlF3hcoMEi8EdLJL0oupaNmsbYTgEArRPi3wzh2sDSmqRzL4EHCkSlASjaZJrel sEGl3g95dUsN1bRdwj7kFHQ3NVUwUg5alaa59XaaC7LMMyodJMm9BddKTp+OgCUAdGSs+kZfhlR n0dszxHhj9YlLst76by0r88LObESqRpGMYImaIAfMYul30K+t2nKcJk= X-Received: by 2002:a05:6a00:b4e:b0:736:57cb:f2b6 with SMTP id d2e1a72fcca58-736aaa1acf0mr17943212b3a.12.1741582729877; Sun, 09 Mar 2025 21:58:49 -0700 (PDT) Received: from pc.. ([38.39.164.180]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-736d2ae318csm1708308b3a.53.2025.03.09.21.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Mar 2025 21:58:49 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, Alistair Francis , Richard Henderson , Harsh Prateek Bora , alex.bennee@linaro.org, Palmer Dabbelt , Daniel Henrique Barboza , kvm@vger.kernel.org, Peter Xu , Nicholas Piggin , Liu Zhiwei , David Hildenbrand , Weiwei Li , Paul Durrant , "Edgar E. Iglesias" , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Anthony PERARD , Yoshinori Sato , manos.pitsidianakis@linaro.org, qemu-riscv@nongnu.org, Paolo Bonzini , xen-devel@lists.xenproject.org, Stefano Stabellini , Pierrick Bouvier Subject: [PATCH 00/16] make system memory API available for common code Date: Sun, 9 Mar 2025 21:58:26 -0700 Message-Id: <20250310045842.2650784-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 6 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). Pierrick Bouvier (16): exec/memory_ldst: extract memory_ldst declarations from cpu-all.h exec/memory_ldst_phys: extract memory_ldst_phys declarations from cpu-all.h include: move target_words_bigendian() from tswap to bswap exec/memory.h: make devend_memop target agnostic qemu/bswap: implement {ld,st}.*_p as functions exec/cpu-all.h: we can now remove ld/st macros 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 system/memory: make compilation unit common system/ioport: make compilation unit common include/exec/cpu-all.h | 52 ------------------ include/exec/exec-all.h | 1 - include/exec/memory-internal.h | 2 - include/exec/memory.h | 48 ++++++++++++++--- include/exec/ram_addr.h | 11 ++-- include/exec/tswap.h | 11 ---- include/qemu/bswap.h | 82 +++++++++++++++++++++++++++++ include/system/kvm.h | 6 +-- include/tcg/tcg-op.h | 1 + target/ppc/helper_regs.h | 2 + include/exec/memory_ldst.h.inc | 13 ++--- include/exec/memory_ldst_phys.h.inc | 5 +- hw/ppc/spapr_nested.c | 1 + hw/sh4/sh7750.c | 1 + hw/xen/xen_stubs.c | 56 ++++++++++++++++++++ page-vary-target.c | 3 +- system/ioport.c | 1 - system/memory.c | 22 +++++--- target/riscv/bitmanip_helper.c | 1 + hw/xen/meson.build | 3 ++ system/meson.build | 6 +-- 21 files changed, 225 insertions(+), 103 deletions(-) create mode 100644 hw/xen/xen_stubs.c