From nobody Mon Nov 25 02:59:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1717734453; cv=none; d=zohomail.com; s=zohoarc; b=cS+qRy8s9igairCEHtoJ/kAg/AsgkB0JLKtt61/COXSp5gJkBw9fG9OSA1xIzKIkR1chxYRMDFLv8SV4TksOdQRZd0ydvQDv91qpJbPKZu+HMbWMIVVxHVyK5j58NsNLpWpn7cdNTtG2xxUSy2G2psWLO/wgai8xb0bX5rOHhGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717734453; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e2zQ1H8W44cIwmlfiKccsXCEnWSMDCd/sRf7MeOiKVM=; b=R9PTotASvLR0Cx56YILbvHyBlUgrAc3/e4XEJqweIgh2azjlrWWEJFntdu9DsISEHgLxKtb2KFBDYuh4cWcyttOD7OcpCD61Kyd6hMJsdpzMMPwBV9vL0Bllpvwqisc/S89+rPH1/mtyL3p/A7oUDe5OgYUQC1540ngx5YmQv0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717734453876307.515183394672; Thu, 6 Jun 2024 21:27:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFRB0-0004lq-7W; Fri, 07 Jun 2024 00:26:06 -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 1sFRAt-0004jy-8D for qemu-devel@nongnu.org; Fri, 07 Jun 2024 00:25:59 -0400 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFRAr-000501-DM for qemu-devel@nongnu.org; Fri, 07 Jun 2024 00:25:58 -0400 Received: by mail-il1-x131.google.com with SMTP id e9e14a558f8ab-3737b70a74aso8932365ab.0 for ; Thu, 06 Jun 2024 21:25:56 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-374bc15d9d9sm6162585ab.37.2024.06.06.21.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:25:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1717734356; x=1718339156; 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=e2zQ1H8W44cIwmlfiKccsXCEnWSMDCd/sRf7MeOiKVM=; b=YO+52K5OJCTM6/7CF0EKys/rGGuBFNfAWuxKpj1w1KJR9QAHD0TWbEcx6hP59o4Hwi DxaN0YkZ0a4KgrsHLxB0x+1BMrf62hbo2ECeq0YO5/LNDAey9pgBO6smk20wCa4x/4YL w8AbLkhYpaFleg6wIpxa8kBe7FiLoILVXBwawcmhYRrM0bj6uQsLS2mC8EsxD3qd9Hdf nCBAQ83CF0ZXA3hOSlBi3U6WsQtRD/JdltgX2Q6RQ+kf/SRnMPmgD6Z7+xeggJ0RTckp R3VeQfNbEb2hhL6W6WLRKpVbKaPLTLZ3G+Hy2BE6Otoy7YaIkZ5MAx1ceFkUeLCalS2M m9MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717734356; x=1718339156; 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=e2zQ1H8W44cIwmlfiKccsXCEnWSMDCd/sRf7MeOiKVM=; b=Ke+9tPU9CZrIF5QloTtiCheXAFJDofKxwKpjoPA59k8wR8t7q8T74n7nZ25Ikjuh8U LcvcruHL8A1tlezAEKS6Inj4cz86h9w1hqAH2O6LivPDnf70z/ExKWJBw5XBoutGf2X4 4NCO1S4Al+XtqSCrDuL909HjRYYnAypNylchlsLR7X5OoqGPx27qXKhVaXx4vJnsJNSS SJV7lpRZ/UM5PHnEdqIeXzsfA36d7jxqdDnjkxvWR+9SW5T0QNLJMRK3ownfdEh6ml+X 8KyRbwNgKSRCwOpgqJxhwdiwa+aMjvm+q3KHsy10u7B5WcfdDsy2rQVQljrGkIIpOKDe mcjA== X-Gm-Message-State: AOJu0YwAA/AH1Rfo5hKA67XLl4G6xFRTUROJoq2r6qvnmMfeeVdT7qqa Wm3/PiKkZdGcTXvoYoRMBjGnwIEZ/Vqpuc7mW3j5BaliiqHhQ8pa8SwA++iIt32ak0ijGDHI9VF YBYw= X-Google-Smtp-Source: AGHT+IHth/zYOqbGg3Tp+Fv4sTisBfezBBQP0AOVkg/478ALyZIfaXqIXdQCFSangBLhrOtw5YYDLw== X-Received: by 2002:a05:6e02:1a83:b0:36c:2975:a7f5 with SMTP id e9e14a558f8ab-374b97ca9f0mr25415025ab.9.1717734355706; Thu, 06 Jun 2024 21:25:55 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Kyle Evans , Laurent Vivier , Richard Henderson , Warner Losh Subject: [PATCH 1/3] linux-user: Adjust comment to reflect the code. Date: Thu, 6 Jun 2024 22:25:01 -0600 Message-ID: <20240607042503.25222-2-imp@bsdimp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607042503.25222-1-imp@bsdimp.com> References: <20240607042503.25222-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::131; envelope-from=imp@bsdimp.com; helo=mail-il1-x131.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1717734455874100006 Content-Type: text/plain; charset="utf-8" If the user didn't specify a reserved_va, there's an else for 64-bit host 32-bit (or fewer) target to reserve 32-bits of address space. Update the comments to reflect this, and rejustify comment to 80 columns. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- linux-user/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 94e4c47f052..94c99a1366f 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -814,10 +814,10 @@ int main(int argc, char **argv, char **envp) thread_cpu =3D cpu; =20 /* - * Reserving too much vm space via mmap can run into problems - * with rlimits, oom due to page table creation, etc. We will - * still try it, if directed by the command-line option, but - * not by default. + * Reserving too much vm space via mmap can run into problems with rli= mits, + * oom due to page table creation, etc. We will still try it, if dire= cted + * by the command-line option, but not by default. Unless we're runnin= g a + * target address space of 32 or fewer bits on a host with 64 bits. */ max_reserved_va =3D MAX_RESERVED_VA(cpu); if (reserved_va !=3D 0) { --=20 2.43.0 From nobody Mon Nov 25 02:59:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1717734425; cv=none; d=zohomail.com; s=zohoarc; b=kQzVtGN6NE8tN3B3gq7+IBMRyRmnogcFOOBBLqhDLWkA+gpjs646dBzGntpW1rlCrjQGVw52KfAwQNDkd8xFsIZphAfFGzcjdaYCcXP63VPVbMHYf1hPjdpYVATE352IDN9zTK5Jz1Td9uL/PzJ0qnBpk/1neY/p35C5s8lLo+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717734425; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I/j33GhWtIBI0v34ghg84N3DhwSzzaAp7dsCaoBrlq4=; b=liZ0yNRIEfn/mjR0xQFtaBIO8scOIjgdjQWmGEYdhe36Kn010nlvdqxvJlY3wOQ3N8rC0SvMSb1J3DtslfbmyDdDnvCx37CcBaSpf2gJTtMvDXL03GUaAVnuHKdcyKgfRuy2VCFPtSUNke7xgI2McQhNjgvZp/IFLpjwlandFvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717734425101683.0948530617997; Thu, 6 Jun 2024 21:27:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFRB0-0004l5-1O; Fri, 07 Jun 2024 00:26:06 -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 1sFRAu-0004kF-GM for qemu-devel@nongnu.org; Fri, 07 Jun 2024 00:26:00 -0400 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFRAs-000514-W4 for qemu-devel@nongnu.org; Fri, 07 Jun 2024 00:26:00 -0400 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-7eb2db841f2so65492439f.1 for ; Thu, 06 Jun 2024 21:25:58 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-374bc15d9d9sm6162585ab.37.2024.06.06.21.25.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1717734357; x=1718339157; 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=I/j33GhWtIBI0v34ghg84N3DhwSzzaAp7dsCaoBrlq4=; b=Yyi2gcII815T/pAA+1Wjrbeg+l5UOILhLc91hn1PKgvPXUnceOPff0YblcrUon0yd/ lfPfCxajr4Y7uc45aX8do42fl1tDfg1Nan5i7ESJnceuwfX4l3OF9r/hcyk8A/D3pGyw TB7r3DAduV3RD3cTOLfRulDLDb7sPzKrA3RBH64H8oA0kSCMqZNee1z+k+8O7xBFkmy6 xj6YsfSVy/wRFR2chyMepjGoKNGW/i3cp6/inaR5bKjEEFt7/E/CtJVq9a8p8WyUKaZG wjKxwc5BJDSN5j8Neg7DZ3i0uNie0zD9vhtrJYCbvuWyf0hAl69WbyAwbtYV6Bh73UHY itCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717734357; x=1718339157; 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=I/j33GhWtIBI0v34ghg84N3DhwSzzaAp7dsCaoBrlq4=; b=hpk5jgZZxSXn0lbSYoKRDki2CDGy8P00Zl8D67c2srAOcO72c9I6aBBW+zI9Xwcuyk w3vMNJkSAadMyef6DS5ZGWEdoIWA5x/3utZlzwr2ldSoqRxJtOfGcI/X5AL/proxb9Na GiaIJELz27+Iwj/b9TDu5D/VQcy1uo5gRed+YIT6J50xqO4XbbPU1LsPwSvXAxZl/xr1 5dfgT+C6INFXOme/EQQ6nOObkdsgGWQwLaszavVtnjzOGL2Mex7w16hT6wYgtuJB8S2d gRi2AFtV6EmyVPFzrnqOLOYaZp1aGmmjckal+hWMOUnaR+RMZIa6eVCWRzr1nc5oO5gx HK2w== X-Gm-Message-State: AOJu0YyBo4T4vfPKEtw/CUCwQ3Le6kXVgzhvi7EBO1MGSfIYAXuTljK5 rZjreZkYT3aZLHHdFptQfg8f1PLru0IFCXqI4hyRNMEoKSA8uDwdRwEHY+qlUcUYFkFoNBgHHWU 0CQE= X-Google-Smtp-Source: AGHT+IFJnkYLTSNSLqMkyGCaFlIcBtiiYPjxVRD4xAQ7s7uBR32660iDZgHpZ99lro/Dbohsg8/Q4g== X-Received: by 2002:a05:6e02:b43:b0:375:fa2:5195 with SMTP id e9e14a558f8ab-375803224a3mr19401295ab.8.1717734357266; Thu, 06 Jun 2024 21:25:57 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Kyle Evans , Laurent Vivier , Richard Henderson , Warner Losh Subject: [PATCH 2/3] bsd-user: port linux-user:ff8a8bbc2ad1 for variable page sizes Date: Thu, 6 Jun 2024 22:25:02 -0600 Message-ID: <20240607042503.25222-3-imp@bsdimp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607042503.25222-1-imp@bsdimp.com> References: <20240607042503.25222-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d34; envelope-from=imp@bsdimp.com; helo=mail-io1-xd34.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1717734425739100003 Content-Type: text/plain; charset="utf-8" Bring in Richard Henderson's ff8a8bbc2ad1 to finalize the page size to allow TARGET_PAGE_BITS_VARY. bsd-user's "blitz" fork has aarch64 support, which is now variable page size. Add support for it here, even though it's effectively a nop in upstream qemu. Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bsd-user/main.c b/bsd-user/main.c index 29a629d8779..d685734d087 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -46,6 +46,7 @@ #include "crypto/init.h" #include "qemu/guest-random.h" #include "gdbstub/user.h" +#include "exec/page-vary.h" =20 #include "host-os.h" #include "target_arch_cpu.h" @@ -291,6 +292,7 @@ int main(int argc, char **argv) char **target_environ, **wrk; envlist_t *envlist =3D NULL; char *argv0 =3D NULL; + int host_page_size; =20 adjust_ssize(); =20 @@ -476,6 +478,16 @@ int main(int argc, char **argv) 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 =3D qemu_real_host_page_size(); + set_preferred_target_page_bits(ctz32(host_page_size)); + finalize_target_page_bits(); + cpu =3D cpu_create(cpu_type); env =3D cpu_env(cpu); cpu_reset(cpu); --=20 2.43.0 From nobody Mon Nov 25 02:59:11 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1717734424; cv=none; d=zohomail.com; s=zohoarc; b=cMAzev+R9IQlQ0fZ06EJuwdKFHPBhh2QOWXuP+AnU5YqTThBDktd4wxEF/cAIYdoVbHW5aPrCLwthPsF07+rReflsDuuo5bjYCXZ6Gi5pK4m91Iu+1ClFQDyCWU+NBH5unC4WzPXMWop7LWpUEDopnIulocuDKrxVVCjmBS85+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717734424; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e+E8YdlwBZo6utgAOnWf5bK8eXZtaIP4XDr+Yf1pIjg=; b=UqWMDOKttZPwMZKbCZion9IbgCy0mZayue4WV2z6HJw56j9uxHoxZkxNKHoQy7Gi9L1LnaC98uQd8GnCbwzHKwkEh3Da6THsebG3UzmjbIVAwlZ0g+hXjo+paD7nwVmzD2aIWcJGFJQjD0W+J0a1jVmMJr1DJ6l1VIwenEF1eQs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1717734424803454.6499570614636; Thu, 6 Jun 2024 21:27:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sFRB4-0004mc-3R; Fri, 07 Jun 2024 00:26:10 -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 1sFRAw-0004l0-JT for qemu-devel@nongnu.org; Fri, 07 Jun 2024 00:26:04 -0400 Received: from mail-il1-x12d.google.com ([2607:f8b0:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sFRAu-00051Q-Ts for qemu-devel@nongnu.org; Fri, 07 Jun 2024 00:26:02 -0400 Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-3748d68b713so6912055ab.1 for ; Thu, 06 Jun 2024 21:26:00 -0700 (PDT) Received: from dune.bsdimp.com ([50.253.99.174]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-374bc15d9d9sm6162585ab.37.2024.06.06.21.25.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20230601.gappssmtp.com; s=20230601; t=1717734359; x=1718339159; 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=e+E8YdlwBZo6utgAOnWf5bK8eXZtaIP4XDr+Yf1pIjg=; b=LaVZ/IABIW32bfoBKkT16T29k2jugDXPH2HWoKpJnGjC0v9TNVP4eYpwDf5zc+O1ZE vy3D7ku/deddRslkXOOFo33+1PUrSdWInz5eG+4pqrb6b1XPldanUIepAZiFmf4en7MG 1KPLYX418D5iBdEhDPkpBAf3Q/msdCxGC/t038teNCsUDKexoZzdtsVJaQzhIxbzro66 CVKEeiMSJHvLssYlyMW/lPF+r6ZnQQsPmN93OM2RGuZf44Su9VxH8pRQ2AaKn21B43RP ZKsS8cBn0TKIvtZ7YA4BjQcr2eqzaJJKhBL4IKjqdr5P/SQBskWTuzIi4QMTaWA38wh6 4zcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717734359; x=1718339159; 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=e+E8YdlwBZo6utgAOnWf5bK8eXZtaIP4XDr+Yf1pIjg=; b=PzdYHn53MgbhovkEF5ZiorgTfGf5/04o31QniQbDNk+a9cGHP4w7qEmkK7osoAeuEV uiHv7Bs4RVv7YtZsTCSk/8rcsGZ9fALgvAP7DmvUxappNN/aT8+7EGuXwOC/xU1mYAdW aga1oUOjrfJq7wh77GiyV/V4sgl8xy6ldyJIbaDfbgyh6kuYXPbsny97ObH44ThdTKgi rZqXnSXURya8yANV6yFfsxcfFmCdbmZbVvPpQo2EksGePUtri5WGGPnbOQmnKQv8tO4T eDeoxPkcmkojaGxGYAQjTqfoXZqRpAn339NjoRTLG+bw8ibBKs9vvh5ckl6vdZWz7kIR sm8A== X-Gm-Message-State: AOJu0YxKRtWZ6l3zqZBB/2TWSlFtT4kQaM85OwrstJoHgvZQphFmlw92 5gH1NjMA2u00/5SbdwlMOF5mpT5gMYjURqGEdCImSItjgZOnL/rNEIrd60aCaWY580r0sTY5/1D Yfzg= X-Google-Smtp-Source: AGHT+IGW1966wtxuskI4e/9BuhuG1QlxDl+dGxHBJWO4tqdRYVUvC5/IuumJlyFx3Q/NEuIR/n1Pmw== X-Received: by 2002:a92:c569:0:b0:374:5a2d:178 with SMTP id e9e14a558f8ab-3758030a2fdmr18999515ab.2.1717734358912; Thu, 06 Jun 2024 21:25:58 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Cc: Kyle Evans , Laurent Vivier , Richard Henderson , Warner Losh Subject: [PATCH 3/3] bsd-user: Catch up to run-time reserved_va math Date: Thu, 6 Jun 2024 22:25:03 -0600 Message-ID: <20240607042503.25222-4-imp@bsdimp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607042503.25222-1-imp@bsdimp.com> References: <20240607042503.25222-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::12d; envelope-from=imp@bsdimp.com; helo=mail-il1-x12d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @bsdimp-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1717734425771100005 Content-Type: text/plain; charset="utf-8" Catch up to linux-user's 8f67b9c694d0, 13c13397556a, 2f7828b57293, and 95059f9c313a by Richard Henderson which made reserved_va a run-time calculation, defaulting to nothing except in the case of 64-bit host 32-bit target. Also include the adjustment of the comment heading that work submitted in the same patch stream. Since this is a direct copy, squash it into one patch rather than follow the Linux evolution since breaking this down further at this point doesn't make sense for this "new code". Signed-off-by: Warner Losh Reviewed-by: Richard Henderson --- bsd-user/main.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index d685734d087..dcad266c2c9 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -77,25 +77,16 @@ bool have_guest_base; # if HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS # if TARGET_VIRT_ADDR_SPACE_BITS =3D=3D 32 && \ (TARGET_LONG_BITS =3D=3D 32 || defined(TARGET_ABI32)) -# define MAX_RESERVED_VA 0xfffffffful +# define MAX_RESERVED_VA(CPU) 0xfffffffful # else -# define MAX_RESERVED_VA ((1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1) +# define MAX_RESERVED_VA(CPU) ((1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1) # endif # else -# define MAX_RESERVED_VA 0 +# define MAX_RESERVED_VA(CPU) 0 # endif #endif =20 -/* - * That said, reserving *too* much vm space via mmap can run into problems - * with rlimits, oom due to page table creation, etc. We will still try i= t, - * if directed by the command-line option, but not by default. - */ -#if HOST_LONG_BITS =3D=3D 64 && TARGET_VIRT_ADDR_SPACE_BITS <=3D 32 -unsigned long reserved_va =3D MAX_RESERVED_VA; -#else unsigned long reserved_va; -#endif =20 const char *interp_prefix =3D CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release; @@ -293,6 +284,7 @@ int main(int argc, char **argv) envlist_t *envlist =3D NULL; char *argv0 =3D NULL; int host_page_size; + unsigned long max_reserved_va; =20 adjust_ssize(); =20 @@ -493,6 +485,29 @@ int main(int argc, char **argv) cpu_reset(cpu); thread_cpu =3D cpu; =20 + /* + * Reserving too much vm space via mmap can run into problems with rli= mits, + * oom due to page table creation, etc. We will still try it, if dire= cted + * by the command-line option, but not by default. Unless we're runnin= g a + * target address space of 32 or fewer bits on a host with 64 bits. + */ + max_reserved_va =3D MAX_RESERVED_VA(cpu); + if (reserved_va !=3D 0) { + if ((reserved_va + 1) % host_page_size) { + char *s =3D size_to_str(host_page_size); + fprintf(stderr, "Reserved virtual address not aligned mod %s\n= ", s); + g_free(s); + exit(EXIT_FAILURE); + } + if (max_reserved_va && reserved_va > max_reserved_va) { + fprintf(stderr, "Reserved virtual address too big\n"); + exit(EXIT_FAILURE); + } + } else if (HOST_LONG_BITS =3D=3D 64 && TARGET_VIRT_ADDR_SPACE_BITS <= =3D 32) { + /* MAX_RESERVED_VA + 1 is a large power of 2, so is aligned. */ + reserved_va =3D max_reserved_va; + } + if (getenv("QEMU_STRACE")) { do_strace =3D 1; } --=20 2.43.0