From patchwork Tue Jan 2 01:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 759341 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp5856168wrw; Mon, 1 Jan 2024 17:59:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEj4f3uLewgPzXHlsm0EDWEPOaD8nTO7pyniaAt93lKErYAlyvkIrDBY6LTZjtG2vXQroHy X-Received: by 2002:ad4:4eef:0:b0:680:b7a0:a53 with SMTP id dv15-20020ad44eef000000b00680b7a00a53mr3137179qvb.80.1704160781155; Mon, 01 Jan 2024 17:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704160781; cv=none; d=google.com; s=arc-20160816; b=dLEHE4EytvpRnKE5qsOYRiag5WYhQ298ahwhu0J4iYbw1+EtjNnGIfIUxNxL6/5Jdu xd19+ltARfwzeEpEj9aL5RlhTnjp8PXDSEBp4r+C7q8UterG+cybbDvtDfI3hm6ARuje 0kDSff41ol/qGljOlEcEuOU7PmkMTluYk5jPr54oLWfhVsDVlbLlQSyMm4kQcxb2At9B gcJNs2iRDsuH6q9zJuFB2djp/NkaX5+eiy1bt6ncgaZMx5xI2qWihDMEtCkc/UsKFG+w iaMfsjS02s3KEXewrr2LsvsEOD9TUElp/pPVX90N+tMprLLRFCmVSz7XBef8hwIMrdaS NJsw== 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=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; fh=kQadAhxV42GJ3cd2VUw1RyURv/zJQGvmUdF7iLEVTtc=; b=nLNW2vMbIO1a30raSdSshRyPpl6YUq+JKaZknUP4a7k71wGm80ZuOrBPxkqTaNIYDV FJDJS3EeblwKpxzfLy0qvNWkmwYwCfRNpENoOeaGDwLk3GTuEvM1NXM8AnrRNgLWTXvf IxQfnJs+GJBZhY0+DeKZ0UCH2Op+ZIVOj4MvTB3Pxlkzr8BhYmKLmQdQl59sVFqncGxY oDJuiK6C5YceBeEInDt2Ssvia/3uRx90+1x+Oy+BrunM29hDOQCg2etNasd/cGKq5kmn +yc8lNDRGhT4qu++9On6Qn0KGsCqh8qQrNJB13q7ru0ZBo/3hEQtFT+5Kc4WFz3VljtL 2pbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Z0nnq+/b"; 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 gy13-20020a056214242d00b0068059cc9998si14090459qvb.481.2024.01.01.17.59.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jan 2024 17:59:41 -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="Z0nnq+/b"; 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 1rKU3q-0003wz-TC; Mon, 01 Jan 2024 20:59:18 -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 1rKU3o-0003nJ-Rw for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3n-00076e-Az for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3bb53e20a43so7596606b6e.1 for ; Mon, 01 Jan 2024 17:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160754; x=1704765554; 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=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; b=Z0nnq+/b1pW4yKSicEQF9GaDRiXWh+0hlcENiwZ/kShnZpxvRe0wt/b5DN6RS/McI3 vVhImIxmWesfn/+k1CVCiXQZtsMnAaavU/+DaUbGCeplS7gHngGTCk5BDcen+g7yY+YE 3f79uChMAitwr/OlAxKvA178ds1cb6uxsskKvDn8ZufNObxnEjQ5c7eMozcbI1BgJerA 7U4hbEfMGV9maDzE9kUVdbqmEf4epQHiDWy8+toctbxJG7S43yNcRDqEkhM9pgHifchR JSTYknfuxS9ImascdbN83vp0AC+UafEXtHmPBVTM4gm3yAKCLM+kcxu8X3YJFvjngy2j w95g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160754; x=1704765554; 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=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; b=q5GHnplpMxD4d+LBTH8TVoFAsUe4l45N98lTVMrkKZp7sRTZAEFW14j2r5QFUWfljD n2/uHIUdLq8Zb/Xj/FGiA899tPm6SONyXpv/aCLA1c4bEWk/NYmMoqrraZLM5eFS6TQg +Fr8CUvJ3Y+Si6NoDNzW0PUgK6W6PMk7zpMJbke9SU/sT7zLSoRezsbHSKu5fznrBNZJ jdH60BNo0eX+eROAOynSXird13zFVbfa/6FxORuHt6u6OkibcK46FZoOO0zrE9EQZY/d mw52rD5TVvnnLiVaqG7IJuFO5LnLkqNwjcSRs+kuKeROCqw1zN09+25lW7lmDSEOyzXF TIyQ== X-Gm-Message-State: AOJu0Yxca5SbZaqSph+MgV4BQwuQUfp4IDJJs7Y3/N6i7q10znkB4wQ5 NSLsYt+Wac+mSU85+tjhwCex9eDFUmaK67RAUPXxXOw0YVQ= X-Received: by 2002:a05:6808:130e:b0:3b9:dcf0:63b9 with SMTP id y14-20020a056808130e00b003b9dcf063b9mr20258295oiv.23.1704160753974; Mon, 01 Jan 2024 17:59:13 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Tue, 2 Jan 2024 12:58:04 +1100 Message-Id: <20240102015808.132373-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.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 --- 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 9ba4dc5872..d00a0d7d1f 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "accel/tcg/perf.h" +#include "exec/page-vary.h" #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -683,6 +684,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; @@ -794,6 +796,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); @@ -807,8 +819,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); @@ -907,7 +917,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);