From patchwork Thu Feb 22 20:43:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 774917 Delivered-To: patch@linaro.org Received: by 2002:adf:a356:0:b0:33b:4db1:f5b3 with SMTP id d22csp45303wrb; Thu, 22 Feb 2024 12:52:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWugQtLxfZcxuRNIlgp/QQYlKPjmMpb8I+cnilSgOYeZcfU3VCuiss5Qnh1Xp2V/R0ZUxAjiALRyBnlTpuaqT7Z X-Google-Smtp-Source: AGHT+IFESj66B7qy3wyNJjm06QA5s8+EWiQJ71/e2S0MopdiPIXi4wGxkFmSOJ2L81u6gzwZuXO2 X-Received: by 2002:a05:6830:114e:b0:6e1:d90:c429 with SMTP id x14-20020a056830114e00b006e10d90c429mr188787otq.7.1708635140573; Thu, 22 Feb 2024 12:52:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708635140; cv=none; d=google.com; s=arc-20160816; b=g0QJGB6HDOjLr4DTtbOtunkKPA+dMqiapb2ii3Es/Jrb7xz98/EJS2DgZLB9zrxIS0 eaNs340m4FhZyx/zQfQgDlrG3OqwkojER4D1dAm85g7XcdhV02XvgqHP5YwUCxofV600 LTZxfCTmY5+q3Zw11rT+Fvu1SzdvEzHzcm4+rp3oDfqeV/D7wtYHdZCvHkkFGg6S12y/ nGH9CwMJQrbnLoNyocnwvbuOzldx7LWI4C3VdE4wi07kYVhFx3+iXwfTRk1y85w9HlZg 4HiL4M3WW0yW7vuJOIwNKAcalJY/c7/youq3heog7TAYPKOzKedCZMe+TxZ0/3bOakU1 rKcQ== 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=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; fh=G0NodtoLUMhKR6pPncKXd0kw6+54AeSvXTR8kR6ypiY=; b=yc8bpCivUmuBSQizpWKXbOwJZsUj4ki8MpKswGAaPxJrCuWuQOqFVefva84ZmJ8e/A KWjF4ugslIwtB3DIZgKk7gPHi3lwvRUpU9m2uRSaGkWx8ldGnm4/kKQ3R1R4HCnpOMfO H4L3KfBPBBeOl5Tt4lOEaj18wvJWcKDQV3Bs3R5X98JJUZCGmhAgn2pouQ8hWOjnvC0x tWmPmLW3wY+EfRn5B4UUUXNMb0l1qS6pU8mDsjXIAIY/OmqgtHN6tCHQeV22qiMOMsio VRUvzkd0d2k7pFPI+juKaOOF7+6Cwi4FnExtll+9bWPGrgXUe0tdrXJp48t2efc5wXMI fVSw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VurPbK1A; 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 e5-20020ac84905000000b0042c50465c78si13024824qtq.664.2024.02.22.12.52.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Feb 2024 12:52:20 -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=VurPbK1A; 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 1rdFva-0008Ay-IT; Thu, 22 Feb 2024 15:44:22 -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 1rdFvZ-00088o-6J for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:21 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvX-0002nk-Ln for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:20 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d51ba18e1bso2648285ad.0 for ; Thu, 22 Feb 2024 12:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634658; x=1709239458; 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=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=VurPbK1AbyR8HxdE5lor0PPsWgTMf+77WjbJQAKxVmnsOZ8tsDK0c2riN0yar3NTVa /tIBpakzQwPJjgEkHQwEnWh+4NCReswMRlK3I8A2wuobUheLcnF+8a6V/20jB41uv3mJ msf1i9kzBmlI5OlcbPsEYjla3GQTH9TCE012LUkkEOyfPgHdGX6nNknwYB3BkzqSlSrE 1Iqy6M37sUMKdgcS5DUBFoezem7bBRYNNwYjqiRq/0ZwEIZ+jgR0QRSYx+xoGWdxVZDg jUn0t0giIMhq8WuyzjKHnca8V9GRgZGItheEQ4dfbKGK2gjdUPiyzHy1FZ2rYkrP/FNY dj9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634658; x=1709239458; 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=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=LBELrP/K9qDB+3VxUp8rQYQ45uRwrUbidXvTRwNUblHSxWTjcE7qAavED/OgY3D0O8 SGK2s/oh2Cz3b8Kul5l+LsOB6jLA8HEiwmQTJVnLxGDweR6L0yLZ9XqQ/ge1gkXfdDYs 0JCiZtTxPp2yt8XRE+b61KZmuQohTD2sUB9z87tpy9AXCH7dJmqJFw4p2P8mUBVGq/DZ 3WppPh7cWa1cCujxl3I79C2s18YqZ0F4Icun/g8V9C0bpVvizb8G3wo4Dnrh76G/H5+l Ayd13sLYOkhEClfJG9IJY27Zn4aO/H/uwtvgq+n5zQ4J9xaAMqHiRcO/KmtrkfNK93RT FKWw== X-Gm-Message-State: AOJu0Yw0FBZLGzEq03NTPwWGnk+QPyNZ6a3r0Z2jUn3ZJLgl3WcVd5vC /p8SS7rhW5A60bPWTce3C6BjNNza81TE98h1RnQIs6bUW7YZwowBl8iK99/ZUvBGfKDtbVa24TZ o X-Received: by 2002:a17:902:6b04:b0:1dc:5d2e:c18c with SMTP id o4-20020a1709026b0400b001dc5d2ec18cmr1608170plk.67.1708634658496; Thu, 22 Feb 2024 12:44:18 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id l12-20020a170902d34c00b001d8f81ecebesm10275500plk.192.2024.02.22.12.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Helge Deller Subject: [PULL 34/39] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Thu, 22 Feb 2024 10:43:18 -1000 Message-Id: <20240222204323.268539-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240222204323.268539-1-richard.henderson@linaro.org> References: <20240222204323.268539-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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=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 If set, match the host and guest page sizes. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Acked-by: Helge Deller Message-Id: <20240102015808.132373-30-richard.henderson@linaro.org> --- linux-user/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index bad03f06d3..12bb839982 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "tcg/perf.h" +#include "exec/page-vary.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -680,6 +681,7 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; + int host_page_size; unsigned long max_reserved_va; bool preserve_argv0; @@ -791,6 +793,16 @@ int main(int argc, char **argv, char **envp) opt_one_insn_per_tb, &error_abort); ac->init_machine(NULL); } + + /* + * Finalize page size before creating CPUs. + * This will do nothing if !TARGET_PAGE_BITS_VARY. + * The most efficient setting is to match the host. + */ + host_page_size = qemu_real_host_page_size(); + set_preferred_target_page_bits(ctz32(host_page_size)); + finalize_target_page_bits(); + cpu = cpu_create(cpu_type); env = cpu_env(cpu); cpu_reset(cpu); @@ -804,8 +816,6 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va = MAX_RESERVED_VA(cpu); if (reserved_va != 0) { - int host_page_size = qemu_real_host_page_size(); - if ((reserved_va + 1) % host_page_size) { char *s = size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n", s); @@ -904,7 +914,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr == 0) { - mmap_min_addr = qemu_real_host_page_size(); + mmap_min_addr = host_page_size; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=0x%lx (fallback)\n", mmap_min_addr);