From patchwork Wed Apr 17 18:27:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 789316 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp172640wrm; Wed, 17 Apr 2024 11:29:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWevHMkU238cBncko8ZLdJY0uXz9ObHVB0MF7QH+MxEfWOgKlurmrLN/tvJKUvQxnyhAS1VdSrVMu87Ity5P1tV X-Google-Smtp-Source: AGHT+IHcCUSkUGI7BXk12Nesojf13y8UUEzUDseBDsw9OoXQuZm+8LENcde/T/XaAA6gl5wIbExs X-Received: by 2002:a05:620a:109a:b0:78e:c724:c813 with SMTP id g26-20020a05620a109a00b0078ec724c813mr212543qkk.5.1713378563045; Wed, 17 Apr 2024 11:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713378563; cv=none; d=google.com; s=arc-20160816; b=Qd5hM/Os/0RzD4p/Vo6YWfdOLsk1SMfsEFzki5qhwlOx9aLuvACu2waMa9Z6kUZc2C ZKAJB2AD4hbEmUHaev4kT/XxA9b4P4oL6jnevJc8l62awKRVTWl1b+QE/BqNk5C5xk3r rgk0918VkHXM0yaOw5fPEMv5kRBzshF9/M9pQsO9Y+tinIcK85RkXo2rMhgeZGRhPsCI 3ThkCHbL0QXpr9MlhtdphvpLSRAWqtQk5qHIyQzMDhSgftNdUJXKUazQ5joKrRRntdHm Wl82Zlx8MUMxmecm3S1/KbefKRBQXb2mZDysEnAkUY7z3IxqaM1aHeGTv2usqVxLIFOn 8GPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rI+phs//gjZco0fvuUEX1KPF7mTDgm4gz1xheV8LKk0=; fh=AGplSnt+WUiov1DMvmsoICTNBRvGlJbdW0SrX8Rpgr8=; b=FvRCLlLBFL5W7e/xtWLEkwMHZGxrb5UTII/jnE9/mOYM/6MnJedWdbJk89lucQwlc6 /b1AWTpRSiTWTrmGhhbFEtK+fxEZ+gIvmxe4+IawDOcw7/hkL+4ExXUgjjUVmyp8CFEj e/6fGiqqAHVebI/mPi0RSRmBN2pCli5vHjjVnh38O0JswqbOGzFRg3Bu2drWqnOaUNxl 168SP+QqIVNsKut1c0Uo9JYSyhQl+X7hH30iPLVJs5JC8wA/FyrFFN/kfzdFjVmGIAM+ AwSDd1ZJj4tK+Tvpa4v+I5K5bghwCRguuSkZDOS8AbeolS8TL0o76QZ97W/Zj1Wgq2q5 YHrw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zwg14XFa; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 11-20020a05620a040b00b0078d4de3f8a7si15111310qkp.149.2024.04.17.11.29.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Apr 2024 11:29:23 -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=Zwg14XFa; 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 Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxA1U-0007fG-AM; Wed, 17 Apr 2024 14:28:44 -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 1rxA1S-0007eD-KZ for qemu-devel@nongnu.org; Wed, 17 Apr 2024 14:28:42 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxA1Q-0003Jw-Na for qemu-devel@nongnu.org; Wed, 17 Apr 2024 14:28:42 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-418db9aa891so312215e9.0 for ; Wed, 17 Apr 2024 11:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713378518; x=1713983318; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rI+phs//gjZco0fvuUEX1KPF7mTDgm4gz1xheV8LKk0=; b=Zwg14XFahuzecCyN8f6uSyWtRSbf+Ugd4qs0L+9Uxhg5m5TQfzL9D/LjLzLr6u804Y ArVu+UAEgtBafdh9Qgrz3uVhYpZDNfgQBLruTCZuCWtvh5uUhHSr0Cl2OxMMuVWEpbDG Bn9zdk9c49QG8sGaDoQJ3YulF2SRXLkFp9DUDmfznGSSKDsH9I/dkC7j9s9IfOWqm+RD tVUbbgNjNKowP+obgAxUIETOK8qupGuZ0mEj4iEbEJU7mkfPP5tsigFo/KArO0A9mAHO AASGMJSIKdn0VP185RJRQ601rO4FIiBLUf69TQp8zmg7wuTDVVhiuUSbKsFthfS9di7F oHzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713378518; x=1713983318; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rI+phs//gjZco0fvuUEX1KPF7mTDgm4gz1xheV8LKk0=; b=B0sV72HWmDvYrDrwM0vb1aKthSFrSQ3ZjvMPtSyxmtuGluhYG9vm+/kB5T45xOIbFO ZfJ0ueQqy8TtbETL8s4Qt/BjnK/iVFE0s4hrxDdOJg4Pdl8iNt7QzjedB4QiGqL1q591 TFZ8PkDIOI66JfdXu25kCJIDIuGZf+PlVJtOCJxEfKaCzBZ0E49zYWkd+xI960HUQ/Og pzgImtP/TqPPDm4eoJSTJ0DDW89BRUWP9P4uYnmoLandyUH629f9XGJ6Si+EC5l2Nh/2 +BcX83tcXx1+C+Sxy/dOnM5MhOCsGGQbircw8DKxi8Qqm9u6CNKSa8o3lkX9INTEdHy4 6rVg== X-Gm-Message-State: AOJu0Yw/VWSUga1Vu5z8VEmUg9OUzxIMM5QDvH+9Kn723C8hf8QIsGin vRW5Hw6TTbLmkxAYE1Cv1L3eVy9I7rZl5GzT8Avg1PD1iWabM8d0OhDd7xvfz3Nr0lQcIuh35ex k X-Received: by 2002:a05:600c:4591:b0:416:8efd:1645 with SMTP id r17-20020a05600c459100b004168efd1645mr406430wmo.7.1713378518617; Wed, 17 Apr 2024 11:28:38 -0700 (PDT) Received: from m1x-phil.lan ([176.187.201.23]) by smtp.gmail.com with ESMTPSA id u12-20020a05600c19cc00b004182cd07133sm3716196wmq.3.2024.04.17.11.28.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Apr 2024 11:28:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?utf-8?q?Philippe_Mat?= =?utf-8?q?hieu-Daud=C3=A9?= , Warner Losh Subject: [PATCH 05/21] exec: Expose 'target_page.h' API to user emulation Date: Wed, 17 Apr 2024 20:27:50 +0200 Message-ID: <20240417182806.69446-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240417182806.69446-1-philmd@linaro.org> References: <20240417182806.69446-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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=ham 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 User-only objects might benefit from the "exec/target_page.h" API, which allows to build some objects once for all targets. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Warner Losh Reviewed-by: Richard Henderson Message-Id: <20231211212003.21686-3-philmd@linaro.org> --- meson.build | 2 +- page-target.c | 44 ++++++++++++++++++++++++++++++++++++++++++ system/physmem.c | 30 ---------------------------- target/target-common.c | 10 ---------- target/meson.build | 2 -- 5 files changed, 45 insertions(+), 43 deletions(-) create mode 100644 page-target.c delete mode 100644 target/target-common.c diff --git a/meson.build b/meson.build index da8295b405..44d337f67b 100644 --- a/meson.build +++ b/meson.build @@ -3554,7 +3554,7 @@ if get_option('b_lto') pagevary = declare_dependency(link_with: pagevary) endif common_ss.add(pagevary) -specific_ss.add(files('page-vary-target.c')) +specific_ss.add(files('page-target.c', 'page-vary-target.c')) subdir('backends') subdir('disas') diff --git a/page-target.c b/page-target.c new file mode 100644 index 0000000000..82211c8593 --- /dev/null +++ b/page-target.c @@ -0,0 +1,44 @@ +/* + * QEMU page values getters (target independent) + * + * Copyright (c) 2003 Fabrice Bellard + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "qemu/osdep.h" +#include "exec/target_page.h" +#include "exec/cpu-defs.h" +#include "cpu.h" +#include "exec/cpu-all.h" + +size_t qemu_target_page_size(void) +{ + return TARGET_PAGE_SIZE; +} + +int qemu_target_page_mask(void) +{ + return TARGET_PAGE_MASK; +} + +int qemu_target_page_bits(void) +{ + return TARGET_PAGE_BITS; +} + +int qemu_target_page_bits_min(void) +{ + return TARGET_PAGE_BITS_MIN; +} + +/* Convert target pages to MiB (2**20). */ +size_t qemu_target_pages_to_MiB(size_t pages) +{ + int page_bits = TARGET_PAGE_BITS; + + /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */ + g_assert(page_bits < 20); + + return pages >> (20 - page_bits); +} diff --git a/system/physmem.c b/system/physmem.c index a4fe3d2bf8..dd7b222942 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3504,36 +3504,6 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr, return 0; } -/* - * Allows code that needs to deal with migration bitmaps etc to still be built - * target independent. - */ -size_t qemu_target_page_size(void) -{ - return TARGET_PAGE_SIZE; -} - -int qemu_target_page_bits(void) -{ - return TARGET_PAGE_BITS; -} - -int qemu_target_page_bits_min(void) -{ - return TARGET_PAGE_BITS_MIN; -} - -/* Convert target pages to MiB (2**20). */ -size_t qemu_target_pages_to_MiB(size_t pages) -{ - int page_bits = TARGET_PAGE_BITS; - - /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */ - g_assert(page_bits < 20); - - return pages >> (20 - page_bits); -} - bool cpu_physical_memory_is_io(hwaddr phys_addr) { MemoryRegion*mr; diff --git a/target/target-common.c b/target/target-common.c deleted file mode 100644 index 903b10cfe4..0000000000 --- a/target/target-common.c +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -#include "qemu/osdep.h" - -#include "cpu.h" -#include "exec/target_page.h" - -int qemu_target_page_mask(void) -{ - return TARGET_PAGE_MASK; -} diff --git a/target/meson.build b/target/meson.build index dee2ac47e0..a53a60486f 100644 --- a/target/meson.build +++ b/target/meson.build @@ -19,5 +19,3 @@ subdir('sh4') subdir('sparc') subdir('tricore') subdir('xtensa') - -specific_ss.add(files('target-common.c'))