From patchwork Fri Aug 18 17:12:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 714672 Delivered-To: patch@linaro.org Received: by 2002:a5d:484e:0:b0:317:ecd7:513f with SMTP id n14csp630314wrs; Fri, 18 Aug 2023 10:17:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzN1YZ8IICPXAHcgAVGdfvch2LTQcv0s0KovmSFh1pEWPQ4Afl3ea6oku+f1ERmoppF3AU X-Received: by 2002:a05:6358:440a:b0:135:43da:b16d with SMTP id z10-20020a056358440a00b0013543dab16dmr4030140rwc.11.1692379029504; Fri, 18 Aug 2023 10:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692379029; cv=none; d=google.com; s=arc-20160816; b=hO1SnF6CnQ4QN15fIV5shA+zBCpsHWMWKoqybdJJgpW7kGwKgq7Utb8CMGhRVLNnxU yY12sccFZEDZ9qg8/Gu9Q9hzwk8T9vaqcy8GGUyW4s4hOcPA3GeGRRB33bQ4fRgMRgsg 3stCMoxqVGS4tOhD20KMIvTSPMMomlFkjFObDTmhZ46KPr7nNn1LpWSW/+tjuIfLReSn RBFoUkHeqwuh/z9SJgi9QCbFob2A3hJ/IUfTenSIj4U0aSawk3JzBkRCfOLjSjOrGuIw GLiIb/cRHfn1IWOvDHEw00wH94n0wLrj47ltRtyRGdkgKbyk7upVqBcsejZawOU/DT6Q Z4iQ== 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:to:from :dkim-signature; bh=Gjb3/VxZ1+V+7wtutprokQqvAFJJgSE2zXjUQaXpThk=; fh=oYAd+8Lj9FKlReeF9hgENQXa3P4LhBP5C4njRBbobDA=; b=pcf47xfBdtHrDheGeHOHFfLblc0Ci56lJqQn4MR3g5bt797JHlbyhrzR2Uws5BuOP/ ZEHES/pV/A15iWae6DmMgB55jzvCEpmfWoBeiUFvTLZXGcqGvA1OI7JwaDedW24iPa8s fviGQrOxLyeQPo3S5Z/KrPhp4zjRVwJMTEC2h3OFDrE9UrbKo7gxYt6ecWqDSX+Uk/Ms OHUkUnobysN1AY6mHPwKO8jwnzIbhFE1rMyFN7tiG2nP/FUN1eQjfK/Zwm5q6cwdaIct pm/7kYMdxZWtZA9qhHRjBZZBE1u7j8ugXCjRZwMcBJXL0kzN65FSLogWifBQ0DnMlPHO n8vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kuEh4+Jp; 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 qq4-20020a05620a38c400b0076cbce19efasi1275855qkn.726.2023.08.18.10.17.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Aug 2023 10:17:09 -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=kuEh4+Jp; 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 1qX324-0008OR-IU; Fri, 18 Aug 2023 13:13:08 -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 1qX322-0008Ls-BT for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:06 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX320-00087V-7v for qemu-devel@nongnu.org; Fri, 18 Aug 2023 13:13:06 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bdcb800594so9297315ad.1 for ; Fri, 18 Aug 2023 10:13:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692378783; x=1692983583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Gjb3/VxZ1+V+7wtutprokQqvAFJJgSE2zXjUQaXpThk=; b=kuEh4+JpYpTD2nX3jTcmYmIBK4Ol079fEd+Rg8VYjlUXmu0EjcLNEADNKcQuiXW+OS Q4d5LE4HafACHHc+AjLcjRewUjw5/WZVrHvPBcwRWuWIwsazVJ9ZVpGjK48eZjQ8tQ0n ovx3a7bdRRaApix4Mrs6c3TcfbnWqa6m8LhLxzjvJlIU3XCCrLQEAzvZ9X1VS3lE1bpk oR0iBB1tbw8RmigtLebGjYPNG4LhcEiPsjv1HDmnArmia3bR3dsTJdTP8Po9xiBTU0Ji rZW9dpxjm8fFrmRJca1TBtTXz860EkWLTyuYZEg7OOTET8pQ6O1sKZZrnz08fA31lCxe bK/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692378783; x=1692983583; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gjb3/VxZ1+V+7wtutprokQqvAFJJgSE2zXjUQaXpThk=; b=GK5eAdMR9A0LGSO/jsZBIsHhkrnvlN2BY5/CUzeua/zwkujHIHbyNhh2jwLLyAELna 6X35QgyAKfl0G0T+tby3A5PergAur4jTKQtjW4WIwxhw7X/DihxfmXM0Lc1R4e8m5JuG 5naYtXGANx/pJgYajOPKKZFx4Ppn6t8KB47LXKpdrRJ2t2h8J1aHmEeMeVFXxwGRYORP yJR+6Vhb6f8KgIkd9OdJ9h/TZ36GzI3HYfz6IrVT9u+AQsqVlisBC16vY31iXWtCAHkd a19fRsudGUFtAq24d7sqgExOpb5wJebMpGe6eOuY/bI0Uw2HPI8be1tCTavH2C3ocCKO hzCQ== X-Gm-Message-State: AOJu0Yx9gQu7DsVbS6UJ27w2m1Pef9jmKlG1AzRbPmythMa7xBdG3fXs tVVnCYX5HzpkVayU7Ys9rfjNsWWRhRKKwD32J5E= X-Received: by 2002:a17:902:7005:b0:1bc:9c70:b955 with SMTP id y5-20020a170902700500b001bc9c70b955mr3086081plk.28.1692378783022; Fri, 18 Aug 2023 10:13:03 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:cf24:6daf:2b9e:7972]) by smtp.gmail.com with ESMTPSA id jw24-20020a170903279800b001adf6b21c77sm2020025plb.107.2023.08.18.10.13.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 10:13:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Fri, 18 Aug 2023 10:12:23 -0700 Message-Id: <20230818171227.141728-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818171227.141728-1-richard.henderson@linaro.org> References: <20230818171227.141728-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.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 If set, match the host and guest page sizes. 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 3dd3310331..2334d7cc67 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_ptr; 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);