From patchwork Mon Dec 11 21:19:39 2023 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: 752531 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c83:0:b0:333:3a04:f257 with SMTP id z3csp1547409wrs; Mon, 11 Dec 2023 13:23:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGUl5QcaDSrjVFSSI706nsUopps+f7VeqbpsmDhKfBkDRg6wHPMW34yLkCb2lmjkd1+9FcT X-Received: by 2002:ac8:5942:0:b0:419:8f42:8c45 with SMTP id 2-20020ac85942000000b004198f428c45mr6850955qtz.8.1702329826209; Mon, 11 Dec 2023 13:23:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702329826; cv=none; d=google.com; s=arc-20160816; b=GjUH+prI6IJWgnoGpL91fdFc8HN4twqQVgCn1k0HFL+K27r3beZHmuX6fUvdOVRM0Z Mhp4O9wREcL+G5M4xgVXnVA7lV7/u2F7W0lxaHefeKQdK6E3uzqHbzJMLRIAqnHRmaia lv2vcEdQ9m2UdkM2bR7tWAhTrLOiISznmaoHzodCjEjiXqU9nbUPo2ZJSkmLWwOFtnWf GRDGC7/dzPmnxECuGNAoyhw3mGYNskGRk4tv4X35pnk/5exx14c/UuaXUBlNizLQXXeA aT3hm+wNvYvOAsiRGpeJkX7/hc2tyc8SFD8aoX4se9m9WczxIaiFFEs1U6RcIjd5J4+S oNxg== 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=wgiAOK8BuLaD0cXDs62KfIAvV8sc/YA5HaZCqiUDiy0=; fh=jr6BeAjRBF2hKKiijQk6ZwQLKxSmFaSzke8XrKLKGCU=; b=Zch2icSN9DxeeRUAr+y7sX0a1xFK1Xap8guUCKVUPHde1+TUAFRDKrx7gVULVYlKKG Pj9r/BYL8qJbank40wrdaR473Egqo3z2aAAJV3wD/Ep4wtUgZaqkYAayfVL2E5so2MtI Uccm5L+dpPhaY4Wgc5j8r1QGrMQeV93JVc+AuydXQGd2JqiiDBAh37+BxGSfDo2FGg4V 4MCERG/2QW3RFsWrboBca2AzKaHIV15HVPT2waudEMxcaBZyOUAI2netB13tmAqhEM5H n5OliwElcwPDwNXyDTuO8lJYI6sRHLiERl9UMv2WWU96HMD6zJCxHO79naa3XolFq6RL cbfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MmvNvQ1d; 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 h14-20020ac8584e000000b0042547c95362si9356040qth.531.2023.12.11.13.23.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Dec 2023 13:23:46 -0800 (PST) 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=MmvNvQ1d; 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 1rCnhj-0000jJ-CY; Mon, 11 Dec 2023 16:20:43 -0500 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 1rCnhg-0000gl-9d for qemu-devel@nongnu.org; Mon, 11 Dec 2023 16:20:40 -0500 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCnhX-0005DH-KX for qemu-devel@nongnu.org; Mon, 11 Dec 2023 16:20:39 -0500 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-50bf898c43cso4736148e87.1 for ; Mon, 11 Dec 2023 13:20:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702329627; x=1702934427; 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=wgiAOK8BuLaD0cXDs62KfIAvV8sc/YA5HaZCqiUDiy0=; b=MmvNvQ1d0inCOhQtAJ811ZIi5Opzju8kLcjZhJVpe4JO+f3ZUc5x3GMbIJdswNnMXN swKnBAhEM/VtwqKNJPXY+ECORzLXENvXiYzkogTa81qDcxfuLSLciAPf0ODwCnklvd0Q 0r5+5cZ37FYwrIx7khk+diDg1oECS4MmqL7ZEw5lsTBXiKTuwDKt7kd6ydi/ElpGnjrj 1G25/9y0Gxwtsu2xDDUdqGUPdcLiYewKeCi8uDWZU+t8gZvPoQCy1md+jyiAWMwaJmjC 0AzhJioYpooMRn8AO9FUXpHQxovgsVnYQevPuMzhpAg2KBp0Lp78SgAc5nhTZNa4Kdep i9pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702329627; x=1702934427; 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=wgiAOK8BuLaD0cXDs62KfIAvV8sc/YA5HaZCqiUDiy0=; b=j7hKkwdlr8S2nVmm62jQ8zkgCqZZ6PgZo/9sojFtlMpR2GEg4vJm4t/sc9TGK+v/jO t5DjtnvGYXDBJzBaCyY02tZJPkojJ+zwHFLyVJZuqLvFMkqz6T7dGDwjzv5Bgwgi/3KD kbsCiPnTDeqqyh4RjAWqtiRLeRxVBkUM+fW8c4255y01X8KcfYM+VwwFTWl9ODMdcQYk 0yDbkoKamvyn2DRl1/LEqJauq9avGDVfJDSxPap+/fKKD4bNIRHwH7EEGfEWlBqxncUt YK6YYM44NEEMlDfoz0lFyNOBLWahqY0oL0DWe8FA2lqYbDP5/HhiaFWfoARFiEdK/1NT ae0g== X-Gm-Message-State: AOJu0Yx8iBC7kpDyr2b23IdSfGlsZ5XUAu3E2o2qLq8uW8Baz3jlpsFv ePtlWXKiMAnOK3/oMZL0fzRI2kIGlUsgVNiQsGi8iw== X-Received: by 2002:ac2:5f59:0:b0:50b:f300:204 with SMTP id 25-20020ac25f59000000b0050bf3000204mr1399873lfz.70.1702329626915; Mon, 11 Dec 2023 13:20:26 -0800 (PST) Received: from m1x-phil.lan ([176.176.175.193]) by smtp.gmail.com with ESMTPSA id cf8-20020a0564020b8800b0054cfef2fe21sm4026966edb.41.2023.12.11.13.20.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 11 Dec 2023 13:20:26 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Peter Xu , Liu Zhiwei , Peter Maydell , Mark Cave-Ayland , Eduardo Habkost , qemu-arm@nongnu.org, Paolo Bonzini , qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-riscv@nongnu.org, David Hildenbrand , Warner Losh , Claudio Fontana , Brian Cain , Daniel Henrique Barboza , Richard Henderson , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Marc?= =?utf-8?q?-Andr=C3=A9_Lureau?= Subject: [PATCH 02/24] exec: Expose 'target_page.h' API to user emulation Date: Mon, 11 Dec 2023 22:19:39 +0100 Message-ID: <20231211212003.21686-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231211212003.21686-1-philmd@linaro.org> References: <20231211212003.21686-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=philmd@linaro.org; helo=mail-lf1-x135.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, T_SCC_BODY_TEXT_LINE=-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 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 --- meson.build | 2 +- page-target.c | 43 +++++++++++++++++++++++++++++++++++++++++++ system/physmem.c | 35 ----------------------------------- 3 files changed, 44 insertions(+), 36 deletions(-) create mode 100644 page-target.c diff --git a/meson.build b/meson.build index d2c4c2adb3..5fdc4ef8db 100644 --- a/meson.build +++ b/meson.build @@ -3488,7 +3488,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..d286e2d58b --- /dev/null +++ b/page-target.c @@ -0,0 +1,43 @@ +/* + * 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 "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 a63853a7bc..4bdb3d0592 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3422,41 +3422,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_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); -} - bool cpu_physical_memory_is_io(hwaddr phys_addr) { MemoryRegion*mr;