From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634932; cv=none; d=zohomail.com; s=zohoarc; b=JL1VNVwM1VwKWV+upze3Eh3xXs1hP9YzIq2+vSN/zaVnmllqbhNFyxX53a1ixoi8BYEsECDibrDjQzY85O8Ubzzy+cpel1RhWQEz8z6Lj8gCDjHmMFL/pyVRLSHQSAOaLy8atfp+X84JqqDGyjObe8F0w417w+ZarZF9w6SNauI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634932; h=Content-Type: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=6bGhiDlU0H1FunNKKdUnN7eps2A5T8/N/TZO0RrbQvI=; b=GCApo3HB+sQBroyYUC/jUEBCxvI1bW0vcpVpJKLOHb21AccAdNA+SO/wkL3/dkpjjQANxoDkKBK2JCanneVHcRFE9vfKEnBlgZybPmL9eU1+oeiWdYQWbew8CbdcgYSUO9sPsQbJasVik6aa08ANIR2VN5JEQHYEarCXiBF30uA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634932767700.598057603497; Thu, 22 Feb 2024 12:48:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFum-0006vU-0v; Thu, 22 Feb 2024 15:43:32 -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 1rdFul-0006td-8R for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:31 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFuj-0002Zb-0j for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:30 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d731314e67so460395ad.1 for ; Thu, 22 Feb 2024 12:43:28 -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.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634607; x=1709239407; 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=6bGhiDlU0H1FunNKKdUnN7eps2A5T8/N/TZO0RrbQvI=; b=KXUG7fKqV+wD9Bd0gYjuGGkHLnN1Vb8hqhqy8PAQmrb0+SFXsWXecWt7RlHeSipmzq x+s+3etnKwc0po28IcZRiDZTsfTDvP4t1LRQfdRHUCzM7h1ePCSF/nXpuJGhW+BLoPfj fFe/9Zp6BrpTXRSdCdDecaJFZ0Y8CsPFioYXyRDmL/Y/km39C/isDpuPVa+bGxZcF/MY ZVjKojlOD5AXjbD5muSnvxjhdncUlyZl3++E3sQe9FHal39NxY4mZmqeVMIl5Vzk0VCg +oEOgxHIOPhZMfUnvfEJxkaV8uTG5LxKchxgCVJdnZdYaQ6WSIO5TLK36fEE/oFB3HvP DQRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634607; x=1709239407; 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=6bGhiDlU0H1FunNKKdUnN7eps2A5T8/N/TZO0RrbQvI=; b=JJ2MBV1nRrk79Te2YwIXvEiq8+wZdrdzmgkcOtQvuTUJkFZXNe+3ximSiopSVKED07 4/zJV0B68gTqboi8MWSPNvKVJwu4zr3xwZKx27iG3NOuatSdaFFCUbpApGEOC6RDVNQp WQCqexEwGU8jguX1tf86inEbArBTeeLZWxVwmAM8G8qdXdK1q5pZXYzSeHSAG9WYNjRK sy/nmTROzHcSBL0kV2IqCETshFWr23tBKX5fxwbJDH4RD18J4/xQOo/3Zb8IIgI5FFsc rPGNbcO1mXlciCRyvzTr13PW5A3ORYX15eyHPKZmfOZvf6yxBZxG1vCDQJVLvlQlG/aW Akpw== X-Gm-Message-State: AOJu0Yx76OogZTL1qkYO5szJbla2DdFQJPv/JczO05TLs/U9WOFoV/eG cuFNZscODTxjTP0NN5+4mYDPrL0ys04guJwgx1Tt1hfCn0lsRnuOArCV6xXYl8tYEKcc6sW9w+5 B X-Google-Smtp-Source: AGHT+IGV+DNcAIjYL2CRgDuAA3BrvJQe/tICE//QVX2rWx+a5IY5VlKzgBOyq+5AYqKF3vlIskqamA== X-Received: by 2002:a17:902:da8f:b0:1db:e7a4:9d4d with SMTP id j15-20020a170902da8f00b001dbe7a49d4dmr17151169plx.46.1708634607498; Thu, 22 Feb 2024 12:43:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 01/39] tcg/aarch64: Apple does not align __int128_t in even registers Date: Thu, 22 Feb 2024 10:42:45 -1000 Message-Id: <20240222204323.268539-2-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634934394100001 From https://developer.apple.com/documentation/xcode/writing-arm64-code-for= -apple-platforms When passing an argument with 16-byte alignment in integer registers, Apple platforms allow the argument to start in an odd-numbered xN register. The standard ABI requires it to begin in an even-numbered xN register. Cc: qemu-stable@nongnu.org Fixes: 5427a9a7604 ("tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2169 Signed-off-by: Richard Henderson Message-Id: <9fc0c2c7-dd57-459e-aecb-528edb74b4a7@linaro.org> Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- tcg/aarch64/tcg-target.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index ef5ebe91bd..85d5746e47 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -55,7 +55,11 @@ typedef enum { #define TCG_TARGET_CALL_STACK_OFFSET 0 #define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL #define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL -#define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN +#ifdef CONFIG_DARWIN +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_NORMAL +#else +# define TCG_TARGET_CALL_ARG_I128 TCG_CALL_ARG_EVEN +#endif #define TCG_TARGET_CALL_RET_I128 TCG_CALL_RET_NORMAL =20 #define have_lse (cpuinfo & CPUINFO_LSE) --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634625; cv=none; d=zohomail.com; s=zohoarc; b=ehwoiG/AimACJSXsZc3f/4rQ8o5LGthJVY1Fd97LSSmTUPtE2pt+ycAIvZrCu5AAPlCkHCK0aYexNVRWBWG2pA5pOVKptu2RS4dWksXKLX7b4KcoASQimFdD0IhEgK3MphwFo+TxtGbuYM2RUZA2nGbKBSwAG2S5cCfxoZoiS54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634625; 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=riDxx/Iexj1qjgzxqR/EG3iYXorkzbFxBXBzbTLKvNo=; b=YUtQYFtEeNGHLKPFa0McJlDI4PL0CSg8l5/xjKcOLJ4l57xp1IgADToRVTWrcs8o+4hmKiBN9+cQPbAFUPbenhcp7+v0s+AO+BLHoAMZsogZ+RbFCoQRqKY3Xfs3P/3mbt/tzxLY2h2kZUe5ZoZspda5vpQ+Be5LVfj8j+92Gzw= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634625130328.52797579706703; Thu, 22 Feb 2024 12:43:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFun-0006xS-L0; Thu, 22 Feb 2024 15:43:33 -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 1rdFum-0006vW-1R for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:32 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFuk-0002Zm-89 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:31 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1dbb47852cdso580245ad.1 for ; Thu, 22 Feb 2024 12:43:29 -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.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634609; x=1709239409; 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=riDxx/Iexj1qjgzxqR/EG3iYXorkzbFxBXBzbTLKvNo=; b=yNhIpPPe2TUFEU4hQVPE79G4RZfzCeGPK6Im71PSFrGvJ2NiQ0cKmxAvosIPrsWCKt eGTenUqYkfNHfS1Mh+6AUauwtaSbI/iwxHDW2EhOdCsGFifyKBhigGZKtReN1jEBB/3d KSUj/uVe5zi1zMJVTZl/4CvC/lVvD+wjQMgzGOTG1G3+G/zJm6zsJG/WFkwuaukX0Nhe iX2uC2XIfXilRMe8Y32EVM8h26qNs2P2hTUCCK5rpqVrTOi9h/XBShuU11XvQSJpeY1K xxehCEX6xYnqF/T7KbGu8OcjrT4em4r/qUShxPDZWFn0AfJja4MdXeN8n/EXJ2tWDb0l zL2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634609; x=1709239409; 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=riDxx/Iexj1qjgzxqR/EG3iYXorkzbFxBXBzbTLKvNo=; b=YBx3eaa+uP7bQ+jtPaNcA1aFxwPN02MhMJGyAy9MBQNrfSkdQho7KyCL9kBvFxWzqe 8StFFDVcZw7/VXW4nTVA59SIw7QPPjItHGDXRGUrYAT0gEDD2/nuAGZs1Aecak6toi/5 Nttx9/TpX0T0tPH9Ef+ht1Ba3kCOWcheh2lx5oyJy0dWZb3kkFOnU8yvPFZgk8Dde3FO tZ+TTAen4jFpkX34nMdTY5ZveWXBtr0B1HeAodO+clYXIcoogQdQWrcC5PP5UZwqEhJo 13EpvQqKn6/r+ftaCfjjQ6/67IoSkXcDBAI2ZEp+XR8cklJTwpaZ2gK4L67ojCG3vPiP SzWQ== X-Gm-Message-State: AOJu0YxnztMCOOh/IahrTE/5mLfmWdJESeXnphdpN9Rpv8cr60rqlWTo BTcbmO6uA4XMtQyqBzayPmvBuq1qezM+Qxhgc5jOVamMeOUnBsS9IJgH5xeww8didwpHS4gx4PL + X-Google-Smtp-Source: AGHT+IFTayTEfEFMciAD+6EPaRRK5cfQpJ10W5TGmNtU6UiQyNrqCn5Czg/EGKkqUMDMUg5eI2DMpg== X-Received: by 2002:a17:902:ec8b:b0:1dc:11f:d954 with SMTP id x11-20020a170902ec8b00b001dc011fd954mr13067965plg.54.1708634608825; Thu, 22 Feb 2024 12:43:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron Subject: [PULL 02/39] accel/tcg: Set can_do_io at at start of lookup_tb_ptr helper Date: Thu, 22 Feb 2024 10:42:46 -1000 Message-Id: <20240222204323.268539-3-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 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: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634625402100001 Content-Type: text/plain; charset="utf-8" From: Peter Maydell If a page table is in IO memory and lookup_tb_ptr probes the TLB it can result in a page table walk for the instruction fetch. If this hits IO memory and io_prepare falsely assumes it needs to do a TLB recompile. Avoid that by setting can_do_io at the start of lookup_tb_ptr. Link: https://lore.kernel.org/qemu-devel/CAFEAcA_a_AyQ=3DEpz3_+CheAT8Crsk9m= Ou894wbNW_FywamkZiw@mail.gmail.com/#t Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Signed-off-by: Jonathan Cameron Message-Id: <20240219173153.12114-2-Jonathan.Cameron@huawei.com> Signed-off-by: Richard Henderson --- accel/tcg/cpu-exec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 977576ca14..52239a441f 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -396,6 +396,14 @@ const void *HELPER(lookup_tb_ptr)(CPUArchState *env) uint64_t cs_base; uint32_t flags, cflags; =20 + /* + * By definition we've just finished a TB, so I/O is OK. + * Avoid the possibility of calling cpu_io_recompile() if + * a page table walk triggered by tb_lookup() calling + * probe_access_internal() happens to touch an MMIO device. + * The next TB, if we chain to it, will clear the flag again. + */ + cpu->neg.can_do_io =3D true; cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); =20 cflags =3D curr_cflags(cpu); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634714; cv=none; d=zohomail.com; s=zohoarc; b=mTm4m2vCstC4VLjdUibZKgictknYJQFEtfkbHMeqO0o71zHkYB91ZmXhf6entSip8lhv44WUDHHsvT23FuRk8JNVn6Ave+D45oKtRjCvpx9uuM/F7r3k+zRSAYh/mqOBwlcDYcW24dD26GrkFqpAwqxA/2vyUhu4J2oiVUC37MM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634714; 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=GXv7UEq6yLB4cFzFbGG2vFz3ZhmdoWnqKW8J54cTadc=; b=axFqdYUZ+s1l0eOlDW17AsFyLX8sjB/ZwaKNH0ZWS/3Mw4dvv2tKNbpmNFOfMsZA7M5SO2FlxBoUZ6kiXVgX18ABtBf2Kro9KVADtvGc4AB6d0cNGJXLo471ionFsk/nvEZKuJNBvzVIO4E3myF2SgBI8ZULb92Bgq95kRX3oPc= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634714404809.9390719485343; Thu, 22 Feb 2024 12:45:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFuo-0006xr-QI; Thu, 22 Feb 2024 15:43:34 -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 1rdFun-0006wq-GJ for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:33 -0500 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 1rdFul-0002bP-Ic for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:33 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d746ce7d13so727785ad.0 for ; Thu, 22 Feb 2024 12:43:31 -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.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634610; x=1709239410; 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=GXv7UEq6yLB4cFzFbGG2vFz3ZhmdoWnqKW8J54cTadc=; b=Yh86zrQpkmYJsVH3YCQZl8Q2C40Xu8Lkbcr314yyzffaeLi2+CVjMemDE/CEUiFbj2 ZZclXdAJJU/vKjrgWdDrl+JJkmNrHHVZdRMa0n6JjTYgB7BXXZETK8b/01uTl+vj3OPm 4MamIxLkpxGdvVnFJNcMvcL1Ifv7cl8AFsl+TOdPJD9F6eG8dw7hUqi22mq+ynSdrUbF 9HiLtg78v8yYq0b/mw7K5k44tvYRhPyXbfIeczEa2rsjEkcW4TD7ij0R/TqY6o7/2BgX 76h1gDT7O49xuTZ7N3eSRlMio7vrCe2jirdLlAZC3JPLhJnuIJHox3KPI5Q3fk15rTiu FxJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634610; x=1709239410; 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=GXv7UEq6yLB4cFzFbGG2vFz3ZhmdoWnqKW8J54cTadc=; b=uVqVfq815DB6Nok0CmMt7B3i70aCOTnvtDrmwDSacAuDoPlE1QVG2qZsxFsvbdiE/N C9qOMEdk11TQXLnLlaUohHCDsP9MaafAyL/sbL1UbHwGIIgcz42/ZfXEUzgS73TYZlqS facbTMAkTOzp4hG014f+am1wEJ/qYsfA/dZBFEC+KSlXEa6mNIKqG+wYTLrj/ooqpR9L ZSG/woA2ASMVz3JCH5b8l8vLodXho+MiUiQi2IXzrcOH9+/fHTSwr2Yf5knvMroSumwg c2brguX3eGizfju3QuVcZjzsxQ0yGE8vmlbOVDzoxftDDm+D7p9OePvIXPn5P8FumkXQ HnYw== X-Gm-Message-State: AOJu0YzHvUrrYKapWUSBVB1Xg04kaFyadZkGq+veO8GNYHPiDDowytN9 h2lYMWytlCmvICenx3i6P+n2lRrcpXkz1BRnkwNyQxj+bFD0VY34vnQD2glK2v7ZI3FXodI2KVJ O X-Google-Smtp-Source: AGHT+IFtKHsfHsx52VPzd8sZOp3GZYtHSklvfPeR1BaHUwpnwVmmvLyeN1YId6aTeoleBa87s6lHiw== X-Received: by 2002:a17:902:c084:b0:1dc:7bc:3527 with SMTP id j4-20020a170902c08400b001dc07bc3527mr10953735pld.19.1708634610185; Thu, 22 Feb 2024 12:43:30 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Jonathan Cameron , Peter Maydell Subject: [PULL 03/39] tcg: Avoid double lock if page tables happen to be in mmio memory. Date: Thu, 22 Feb 2024 10:42:47 -1000 Message-Id: <20240222204323.268539-4-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 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: 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, T_SCC_BODY_TEXT_LINE=-0.01, WEIRD_PORT=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634715706100001 Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron On i386, after fixing the page walking code to work with pages in MMIO memory (specifically CXL emulated interleaved memory), a crash was seen in an interrupt handling path. Useful part of backtrace 7 0x0000555555ab1929 in bql_lock_impl (file=3D0x555556049122 "../../accel/= tcg/cputlb.c", line=3D2033) at ../../system/cpus.c:524 8 bql_lock_impl (file=3Dfile@entry=3D0x555556049122 "../../accel/tcg/cputl= b.c", line=3Dline@entry=3D2033) at ../../system/cpus.c:520 9 0x0000555555c9f7d6 in do_ld_mmio_beN (cpu=3D0x5555578e0cb0, full=3D0x7ff= e88012950, ret_be=3Dret_be@entry=3D0, addr=3D19595792376, size=3Dsize@entry= =3D8, mmu_idx=3D4, type=3DMMU_DATA_LOAD, ra=3D0) at ../../accel/tcg/cputlb.= c:2033 10 0x0000555555ca0fbd in do_ld_8 (cpu=3Dcpu@entry=3D0x5555578e0cb0, p=3Dp@e= ntry=3D0x7ffff4efd1d0, mmu_idx=3D, type=3Dtype@entry=3DMMU_D= ATA_LOAD, memop=3D, ra=3Dra@entry=3D0) at ../../accel/tcg/cp= utlb.c:2356 11 0x0000555555ca341f in do_ld8_mmu (cpu=3Dcpu@entry=3D0x5555578e0cb0, addr= =3Daddr@entry=3D19595792376, oi=3Doi@entry=3D52, ra=3D0, ra@entry=3D52, acc= ess_type=3Daccess_type@entry=3DMMU_DATA_LOAD) at ../../accel/tcg/cputlb.c:2= 439 12 0x0000555555ca5f59 in cpu_ldq_mmu (ra=3D52, oi=3D52, addr=3D19595792376,= env=3D0x5555578e3470) at ../../accel/tcg/ldst_common.c.inc:169 13 cpu_ldq_le_mmuidx_ra (env=3D0x5555578e3470, addr=3D19595792376, mmu_idx= =3D, ra=3Dra@entry=3D0) at ../../accel/tcg/ldst_common.c.inc= :301 14 0x0000555555b4b5fc in ptw_ldq (ra=3D0, in=3D0x7ffff4efd320) at ../../tar= get/i386/tcg/sysemu/excp_helper.c:98 15 ptw_ldq (ra=3D0, in=3D0x7ffff4efd320) at ../../target/i386/tcg/sysemu/ex= cp_helper.c:93 16 mmu_translate (env=3Denv@entry=3D0x5555578e3470, in=3D0x7ffff4efd3e0, ou= t=3D0x7ffff4efd3b0, err=3Derr@entry=3D0x7ffff4efd3c0, ra=3Dra@entry=3D0) at= ../../target/i386/tcg/sysemu/excp_helper.c:174 17 0x0000555555b4c4b3 in get_physical_address (ra=3D0, err=3D0x7ffff4efd3c0= , out=3D0x7ffff4efd3b0, mmu_idx=3D0, access_type=3DMMU_DATA_LOAD, addr=3D18= 446741874686299840, env=3D0x5555578e3470) at ../../target/i386/tcg/sysemu/e= xcp_helper.c:580 18 x86_cpu_tlb_fill (cs=3D0x5555578e0cb0, addr=3D18446741874686299840, size= =3D, access_type=3DMMU_DATA_LOAD, mmu_idx=3D0, probe=3D, retaddr=3D0) at ../../target/i386/tcg/sysemu/excp_helper.c:606 19 0x0000555555ca0ee9 in tlb_fill (retaddr=3D0, mmu_idx=3D0, access_type=3D= MMU_DATA_LOAD, size=3D, addr=3D18446741874686299840, cpu=3D0= x7ffff4efd540) at ../../accel/tcg/cputlb.c:1315 20 mmu_lookup1 (cpu=3Dcpu@entry=3D0x5555578e0cb0, data=3Ddata@entry=3D0x7ff= ff4efd540, mmu_idx=3D0, access_type=3Daccess_type@entry=3DMMU_DATA_LOAD, ra= =3Dra@entry=3D0) at ../../accel/tcg/cputlb.c:1713 21 0x0000555555ca2c61 in mmu_lookup (cpu=3Dcpu@entry=3D0x5555578e0cb0, addr= =3Daddr@entry=3D18446741874686299840, oi=3Doi@entry=3D32, ra=3Dra@entry=3D0= , type=3Dtype@entry=3DMMU_DATA_LOAD, l=3Dl@entry=3D0x7ffff4efd540) at ../..= /accel/tcg/cputlb.c:1803 22 0x0000555555ca3165 in do_ld4_mmu (cpu=3Dcpu@entry=3D0x5555578e0cb0, addr= =3Daddr@entry=3D18446741874686299840, oi=3Doi@entry=3D32, ra=3Dra@entry=3D0= , access_type=3Daccess_type@entry=3DMMU_DATA_LOAD) at ../../accel/tcg/cputl= b.c:2416 23 0x0000555555ca5ef9 in cpu_ldl_mmu (ra=3D0, oi=3D32, addr=3D1844674187468= 6299840, env=3D0x5555578e3470) at ../../accel/tcg/ldst_common.c.inc:158 24 cpu_ldl_le_mmuidx_ra (env=3Denv@entry=3D0x5555578e3470, addr=3Daddr@entr= y=3D18446741874686299840, mmu_idx=3D, ra=3Dra@entry=3D0) at = ../../accel/tcg/ldst_common.c.inc:294 25 0x0000555555bb6cdd in do_interrupt64 (is_hw=3D1, next_eip=3D184467440723= 99775809, error_code=3D0, is_int=3D0, intno=3D236, env=3D0x5555578e3470) at= ../../target/i386/tcg/seg_helper.c:889 26 do_interrupt_all (cpu=3Dcpu@entry=3D0x5555578e0cb0, intno=3D236, is_int= =3Dis_int@entry=3D0, error_code=3Derror_code@entry=3D0, next_eip=3Dnext_eip= @entry=3D0, is_hw=3Dis_hw@entry=3D1) at ../../target/i386/tcg/seg_helper.c:= 1130 27 0x0000555555bb87da in do_interrupt_x86_hardirq (env=3Denv@entry=3D0x5555= 578e3470, intno=3D, is_hw=3Dis_hw@entry=3D1) at ../../target= /i386/tcg/seg_helper.c:1162 28 0x0000555555b5039c in x86_cpu_exec_interrupt (cs=3D0x5555578e0cb0, inter= rupt_request=3D) at ../../target/i386/tcg/sysemu/seg_helper.= c:197 29 0x0000555555c94480 in cpu_handle_interrupt (last_tb=3D, cpu=3D0x5555578e0cb0) at ../../accel/tcg/cpu-exec.c:844 Peter identified this as being due to the BQL already being held when the page table walker encounters MMIO memory and attempts to take the lock again. There are other examples of similar paths TCG, so this follows the approach taken in those of simply checking if the lock is already held and if it is, don't take it again. Reviewed-by: Peter Maydell Suggested-by: Peter Maydell Signed-off-by: Jonathan Cameron Message-Id: <20240219173153.12114-4-Jonathan.Cameron@huawei.com> [rth: Use BQL_LOCK_GUARD] Signed-off-by: Richard Henderson --- accel/tcg/cputlb.c | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 047cd2cc0a..6243bcb179 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -2022,7 +2022,6 @@ static uint64_t do_ld_mmio_beN(CPUState *cpu, CPUTLBE= ntryFull *full, MemoryRegion *mr; hwaddr mr_offset; MemTxAttrs attrs; - uint64_t ret; =20 tcg_debug_assert(size > 0 && size <=3D 8); =20 @@ -2030,12 +2029,9 @@ static uint64_t do_ld_mmio_beN(CPUState *cpu, CPUTLB= EntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - bql_lock(); - ret =3D int_ld_mmio_beN(cpu, full, ret_be, addr, size, mmu_idx, - type, ra, mr, mr_offset); - bql_unlock(); - - return ret; + BQL_LOCK_GUARD(); + return int_ld_mmio_beN(cpu, full, ret_be, addr, size, mmu_idx, + type, ra, mr, mr_offset); } =20 static Int128 do_ld16_mmio_beN(CPUState *cpu, CPUTLBEntryFull *full, @@ -2054,13 +2050,11 @@ static Int128 do_ld16_mmio_beN(CPUState *cpu, CPUTL= BEntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - bql_lock(); + BQL_LOCK_GUARD(); a =3D int_ld_mmio_beN(cpu, full, ret_be, addr, size - 8, mmu_idx, MMU_DATA_LOAD, ra, mr, mr_offset); b =3D int_ld_mmio_beN(cpu, full, ret_be, addr + size - 8, 8, mmu_idx, MMU_DATA_LOAD, ra, mr, mr_offset + size - 8); - bql_unlock(); - return int128_make128(b, a); } =20 @@ -2569,7 +2563,6 @@ static uint64_t do_st_mmio_leN(CPUState *cpu, CPUTLBE= ntryFull *full, hwaddr mr_offset; MemoryRegion *mr; MemTxAttrs attrs; - uint64_t ret; =20 tcg_debug_assert(size > 0 && size <=3D 8); =20 @@ -2577,12 +2570,9 @@ static uint64_t do_st_mmio_leN(CPUState *cpu, CPUTLB= EntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - bql_lock(); - ret =3D int_st_mmio_leN(cpu, full, val_le, addr, size, mmu_idx, - ra, mr, mr_offset); - bql_unlock(); - - return ret; + BQL_LOCK_GUARD(); + return int_st_mmio_leN(cpu, full, val_le, addr, size, mmu_idx, + ra, mr, mr_offset); } =20 static uint64_t do_st16_mmio_leN(CPUState *cpu, CPUTLBEntryFull *full, @@ -2593,7 +2583,6 @@ static uint64_t do_st16_mmio_leN(CPUState *cpu, CPUTL= BEntryFull *full, MemoryRegion *mr; hwaddr mr_offset; MemTxAttrs attrs; - uint64_t ret; =20 tcg_debug_assert(size > 8 && size <=3D 16); =20 @@ -2601,14 +2590,11 @@ static uint64_t do_st16_mmio_leN(CPUState *cpu, CPU= TLBEntryFull *full, section =3D io_prepare(&mr_offset, cpu, full->xlat_section, attrs, add= r, ra); mr =3D section->mr; =20 - bql_lock(); + BQL_LOCK_GUARD(); int_st_mmio_leN(cpu, full, int128_getlo(val_le), addr, 8, mmu_idx, ra, mr, mr_offset); - ret =3D int_st_mmio_leN(cpu, full, int128_gethi(val_le), addr + 8, - size - 8, mmu_idx, ra, mr, mr_offset + 8); - bql_unlock(); - - return ret; + return int_st_mmio_leN(cpu, full, int128_gethi(val_le), addr + 8, + size - 8, mmu_idx, ra, mr, mr_offset + 8); } =20 /* --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634808; cv=none; d=zohomail.com; s=zohoarc; b=oA8rUvLI60lqwTrRdaI7RsqEaIE5bhuY2SONwdNIylnnoz6TF5mrPXfR0bPC0XDsges2z+GahaBRtoHFxwaKBBIp0VAvQ+enc8SElBdFnqrxeqYnMkKzxvl7ZtCEmWmXI7v61yEgfEpymKtB8lz3bx2jjBX+Dj370EVJREs4NDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634808; h=Content-Type: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=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=mg91hJe99nUZ3c0/SdB+xtjSaEl4Q9VbLcnz1OjN+hghfWz/9x5mTpOldNzgBr8eDxIndEHsnijTq06lJHvipayA62SXzSO/upUrbgGhYZoNf0p1bFqssLrM5SQHaoABoHRkYtilRliwKbAyQkVGTAc2AsC9jIhxlfErh0JtoU4= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634808844378.3341514827956; Thu, 22 Feb 2024 12:46:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFuq-0006yD-8p; Thu, 22 Feb 2024 15:43:36 -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 1rdFuo-0006xs-QX for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:34 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFun-0002bl-73 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:34 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d934c8f8f7so520585ad.2 for ; Thu, 22 Feb 2024 12:43:32 -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.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634612; x=1709239412; 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=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=SwfpMlbChj9GimvK00b40lmzlQeHldHj7r499f+741B7BIeowbyP6D6si+/My+1Cfx RmKgqCK/QVkLZ8u5CftMrA4vjSdzIcwXVcRC5lTlBIedSiXBJ8PRiPdsLk2ouekQATc4 Z4lYMeKg/Xkwfq0mQOsDeG2YdondWjStf8SOu7/g0j6sD0QfZoM1aSYk27hf4GA0s6dV QGsZQT8FFMGS4hCwNbzgqEPlV5h+2NfSMqL2rcOwZWgzfbYIbLhW7JPnP9v3eGU2UgZ8 ceZ65KvMKlFg5Bj7NbWD+WZhbvJmAuRp36BZb8yrpg0I8nC3LY3ZzbCTcHuHOPILL4mh tzjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634612; x=1709239412; 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=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=j3CUbG4GqH3NVvoMfNouqz9Vo43wvUtvudhEIS0J+YdYJnS/LL5Z0Pi3OmsGinynSo vFf65Wt9Q0uTcwbw6qhEPD9xWq5n062VbS6LcAbnOK+gUQmn2NhstvVy/Nbxasi+3XPK w7WNVaSqFAHWUxG81m7yHjgTdtG6nnyCWDbc/t3+IIbEGjieMNrusfpv7wSh4Op1Skxq FS9Sgn8dbcxNpfH4A0mJOXRypxY2xfJ2JkjMQD2mXB4M8di+eXQ//8jQ1G/VYM5gr0gX T4fOL41InaF26ig/tavrhdxJPq9zcrJJ4Hh0OponFfvEtPzE0lfwPw0YtZ+IK/Kq9A0N 9sgA== X-Gm-Message-State: AOJu0YzXh9BAHPcjI5wpiIbgv+RvguIzyLdEc5h/g2jY69aet3C7mSO2 uu+NTVL4C7EpDubDPQorv20yqe8yiVjssq53YbpmHJooWdPNe6p9qSzpn4Cxdcv/R2GmC+xjiOH V X-Google-Smtp-Source: AGHT+IHslhyFBJCm6uPiyIGzPEI7Rf8m5cp/0bXtqZF8LH667ETcoPoyOEUE3pdQwWYdYkjOOSZzsQ== X-Received: by 2002:a17:902:6ac8:b0:1d9:f83e:3a54 with SMTP id i8-20020a1709026ac800b001d9f83e3a54mr17359368plt.64.1708634611972; Thu, 22 Feb 2024 12:43:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 04/39] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Thu, 22 Feb 2024 10:42:48 -1000 Message-Id: <20240222204323.268539-5-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634809963100001 Use qemu_real_host_page_size instead. Except for the final mprotect within page_protect, we already handled host < target page size. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-2-richard.henderson@linaro.org> --- accel/tcg/user-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 68b252cb8e..69b7429e31 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -651,16 +651,17 @@ void page_protect(tb_page_addr_t address) { PageFlagsNode *p; target_ulong start, last; + int host_page_size =3D qemu_real_host_page_size(); int prot; =20 assert_memory_lock(); =20 - if (qemu_host_page_size <=3D TARGET_PAGE_SIZE) { + if (host_page_size <=3D TARGET_PAGE_SIZE) { start =3D address & TARGET_PAGE_MASK; last =3D start + TARGET_PAGE_SIZE - 1; } else { - start =3D address & qemu_host_page_mask; - last =3D start + qemu_host_page_size - 1; + start =3D address & -host_page_size; + last =3D start + host_page_size - 1; } =20 p =3D pageflags_find(start, last); @@ -671,7 +672,7 @@ void page_protect(tb_page_addr_t address) =20 if (unlikely(p->itree.last < last)) { /* More than one protection region covers the one host page. */ - assert(TARGET_PAGE_SIZE < qemu_host_page_size); + assert(TARGET_PAGE_SIZE < host_page_size); while ((p =3D pageflags_next(p, start, last)) !=3D NULL) { prot |=3D p->flags; } @@ -679,7 +680,7 @@ void page_protect(tb_page_addr_t address) =20 if (prot & PAGE_WRITE) { pageflags_set_clear(start, last, 0, PAGE_WRITE); - mprotect(g2h_untagged(start), qemu_host_page_size, + mprotect(g2h_untagged(start), last - start + 1, prot & (PAGE_READ | PAGE_EXEC) ? PROT_READ : PROT_NONE); } } @@ -725,18 +726,19 @@ int page_unprotect(target_ulong address, uintptr_t pc) } #endif } else { + int host_page_size =3D qemu_real_host_page_size(); target_ulong start, len, i; int prot; =20 - if (qemu_host_page_size <=3D TARGET_PAGE_SIZE) { + if (host_page_size <=3D TARGET_PAGE_SIZE) { start =3D address & TARGET_PAGE_MASK; len =3D TARGET_PAGE_SIZE; prot =3D p->flags | PAGE_WRITE; pageflags_set_clear(start, start + len - 1, PAGE_WRITE, 0); current_tb_invalidated =3D tb_invalidate_phys_page_unwind(star= t, pc); } else { - start =3D address & qemu_host_page_mask; - len =3D qemu_host_page_size; + start =3D address & -host_page_size; + len =3D host_page_size; prot =3D 0; =20 for (i =3D 0; i < len; i +=3D TARGET_PAGE_SIZE) { --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634653; cv=none; d=zohomail.com; s=zohoarc; b=Zb4UPbgFwMEi85n65eBUULRGFH+tgB6ccJV26u5R0pC1QudqP9RWTBm957N7XhveAaAyhdryHqeiBicySzNihM7LDOPB2kKA1Sv33rB4jJtzaUX5qwlyHb7npLg1QPGThhOc7sCXIzgqWkyA7IhivB1aPvj0NoxTDiORD5m5LzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634653; 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=h8fyFwW8pAulkSt7Khr4olX1Ketssi9Ly9LMkns+dszRFxPoc8Q8GhAr3MzPKc9wHr0cGrVuehVxFkEmvJLFj5UOCUwD2GOE9BdmauIPjcc/BNjvcoD7Z359lGkS62ct6hQlw1Z2KXKgaYD1okNMjXkp7ucfkRXJxgcIvTFihF8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634653841715.0365443534965; Thu, 22 Feb 2024 12:44:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFus-0006z1-Kj; Thu, 22 Feb 2024 15:43:38 -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 1rdFuq-0006yM-Kr for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:36 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFup-0002by-3n for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:36 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d7232dcb3eso353865ad.2 for ; Thu, 22 Feb 2024 12:43:34 -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.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634614; x=1709239414; 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=PfLkPevn825ugMpAo702PT0p+t/DiRPWWi5tRdvAsEwz8Kyr2X1SfG7nG9Mr3zGzzR ksxL2VORDPbAq4d4gt5uM/on0aGA0V2hSNKzRrVBzTaR5ZGS+8mVfY4qAFT4LIripzZT 3+td0U6EcgGp9US50orQeQcRJrahbgUF+E5R3yzBSVdXRRTD3O/qJDCDJWAIlw5RXawZ Xc3Pcl9gXRTNGTKUw19mjOxQLMoIsayFmpEOoRF+a6ZLIbkpSM26prwHKlcB9d87YdKd eK5qCT41wcPCS85J5XFgPoybMgBOgYXL3IH49l9BUMyw/7dZ1fJ4Xr51wJBPdexM+MG1 kiNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634614; x=1709239414; 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=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=kp6eBu23YiEqk/wrZ9kZuC6gxDbC70/Fc7TNv1Hh7eKoZjtx4urq7hV94OcLDUl+VP Ed9PBq8VXvb/4s//gaMSoEFyBteuuD1Y6fJoKf/mC0MBZOmOtv7P+QBY7hHC85iznTe6 ycxy+y8szdI5rod11MRExtv7SSNxcUh2QlskouUgkSG1K3vtBx9ji7XtX6I9CMG/Hg0g wpGSUpNUW2IYoz/KODqukVJ5oLY0JAi4tRmKPb4HpbWcKejbJJANabSc7mX/V1MZPQjg 0imgJBOxwD0doWQdxi2qJbY2mhlSMdXUN0IB0t2QwGQz3qK568HluiW8836muIbRTRZn gW0A== X-Gm-Message-State: AOJu0YyFoVoj9THP83ZTYj/iseqGIV+K1tAZwlD2/svCqPqUwOF0MH6B SWCm91py0O7AeExUdQoyAlErWaZ7gpHY28IYRvC8gf7IO9bldkkZrCJ0jmQPrd0WFFEoTlE7KQP R X-Google-Smtp-Source: AGHT+IF5q5UPALYgHWNKN4dHd3H6eNGItd9ca+N9As9VGDOe/3/wGV0sI09yoZ0wEYWIaBD1vQm1Tg== X-Received: by 2002:a17:902:7d84:b0:1d9:7095:7e3c with SMTP id a4-20020a1709027d8400b001d970957e3cmr19202644plm.57.1708634613748; Thu, 22 Feb 2024 12:43:33 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PULL 05/39] linux-user: Adjust SVr4 NULL page mapping Date: Thu, 22 Feb 2024 10:42:49 -1000 Message-Id: <20240222204323.268539-6-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 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: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634655448100005 Content-Type: text/plain; charset="utf-8" Use TARGET_PAGE_SIZE and MAP_FIXED_NOREPLACE. We really should be attending to this earlier during probe_guest_base, as well as better detection and emulation of various Linux personalities. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-3-richard.henderson@linaro.org> --- linux-user/elfload.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b8eef893d0..e918a13748 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3912,8 +3912,9 @@ int load_elf_binary(struct linux_binprm *bprm, struct= image_info *info) and some applications "depend" upon this behavior. Since we do not have the power to recompile these, we emulate the SVr4 behavior. Sigh. */ - target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + target_mmap(0, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC, + MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); } #ifdef TARGET_MIPS info->interp_fp_abi =3D interp_info.fp_abi; --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634737; cv=none; d=zohomail.com; s=zohoarc; b=fpwj6zWXHjU4ofjLS3ncWFyNcpcgYdZjR0jnCjuCowBNfqHFh49SQ+VZi9chH4KlsgENr5wGvDh20qCbtE4ahYEfCUCw196mBbJZhQUC4h5sMK3xiRNz1kWPaWhGFkiSeyLCUAAeOw1ZxPytlr/pttJyBYfD3nhy6WPEfa04NDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634737; 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=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=hz+k0CHcOzLbJdTYIOS1ukfAlEMEhb8HqMY0a33cTA7CLQI17SaQPSlY9gKbeR95rRfgM0MSnfYxFTsKlQx5r8l2d3ZxdzvgQX1Kj/UTnQTcX40gsZfUsjiGKcHJkgDuh7Q4M1UNo24fXC+ch791E0LeXmIEBrUiHlTZM7zU34Q= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634737732600.0372850639562; Thu, 22 Feb 2024 12:45:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFuv-000700-LB; Thu, 22 Feb 2024 15:43:41 -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 1rdFut-0006z5-8Z for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:39 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFur-0002c9-NW for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:39 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d73066880eso2070575ad.3 for ; Thu, 22 Feb 2024 12:43:36 -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.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634615; x=1709239415; 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=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=anpyhmLpTbAXrCgl01JfOe98PpXZ6jVSSm19PoQ+fTrjYHyqLNTFNuWjBcZt2GpZTz lueict9CA5G0Go9AkP+u2i4GSpwSfW4uWCn9vzkX2TO+Az8wg4YWbNneg9q04a8HfBVi q0qOxfU7Szs+UUWgySNCE5aFye/1ADTSFhOBNU69AvLAojCpORpIrSVZ8H92373l1U8K vO6csWLOXXEes+uIJPUZI+G35elCYi/1sVTOVLaxfY86Yj9NcSEuZ9/ZUwe/4W030X0S b10u71flj/uKef38ZHFptHdvoVYne3oPAMttM100AReLo2tV+x9FCN7yEILwLWaOjQn6 jL/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634615; x=1709239415; 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=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=jHza5xslqljIYQtJzEs1x8Jha+4/yt1RkIvOrWEF2cScrvdlPWYL3VdjD6N+1QHomn 5SXpPzNw/RwdrFJx+B8D73i/HFEb1BFyJm3XTbXiQZdVF1krDC6IJZxCNvOMfxAWrHdS 9hVgZwmCMl6KskP+xZyDhxVEVmJr+trT5Vu9DSqDXbW6aZndqkmY+E5LaemJGv4K1JnO +eDYoa9Tb8Di8/PhvtpCCW7UrS6UhM25+jr1u+DrnnWboG7VVGaIOKCYk8tzSYYy2meF BuDbCnDzCGQ43OlgQOdJ9sVDGON7CxP6aLX2bdZI111QdT9Cbws/0QxGazbBEGjBIMJL QHog== X-Gm-Message-State: AOJu0YzWi00xYrvwYt086PBCq4wuP86IW5+pD1PXHwqstKPJ0GberX0A Dfz80Lb6SZpWFQoAmgWhbIKpWKismj2Rlp9SQyLGEdm6xvx9AJ4EX0UygBd6mwMGljq6t0Xo7RA + X-Google-Smtp-Source: AGHT+IH6fkUsuO7V5W/elbU7FrcWJw9+jn/TcS2Q+OEznwW02JUaE73O465WG9Zn5HBaRLp6rXW1bQ== X-Received: by 2002:a17:902:f68c:b0:1db:e9ea:31 with SMTP id l12-20020a170902f68c00b001dbe9ea0031mr15479254plg.62.1708634615327; Thu, 22 Feb 2024 12:43:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PULL 06/39] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base Date: Thu, 22 Feb 2024 10:42:50 -1000 Message-Id: <20240222204323.268539-7-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 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: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634739749100002 Content-Type: text/plain; charset="utf-8" The host SHMLBA is by definition a multiple of the host page size. Thus the remaining component of qemu_host_page_size is the target page size. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-4-richard.henderson@linaro.org> --- linux-user/elfload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index e918a13748..e84a201448 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2893,7 +2893,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong gues= t_loaddr, =20 /* Add any HI_COMMPAGE not covered by reserved_va. */ if (reserved_va < HI_COMMPAGE) { - ga->bounds[n][0] =3D HI_COMMPAGE & qemu_host_page_mask; + ga->bounds[n][0] =3D HI_COMMPAGE & qemu_real_host_page_mask(); ga->bounds[n][1] =3D HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -3075,7 +3075,7 @@ void probe_guest_base(const char *image_name, abi_ulo= ng guest_loaddr, abi_ulong guest_hiaddr) { /* In order to use host shmat, we must be able to honor SHMLBA. */ - uintptr_t align =3D MAX(SHMLBA, qemu_host_page_size); + uintptr_t align =3D MAX(SHMLBA, TARGET_PAGE_SIZE); =20 /* Sanity check the guest binary. */ if (reserved_va) { --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634679; cv=none; d=zohomail.com; s=zohoarc; b=nUdDZxJZtVQud2ov2/0lJ71FeTbCf5L5SJZNd0RgeYQ8Hvo29GG470Lrmttm+4pZGKWQDIZA+106niQWpsJPBUMt+Qb0G+ibCFQkaEhIF7OnmnUd91/4X3+uLP5UIbM9TJPOCB3drxgwla1taOJeBibuGLnEWyV8de/YZuVn76k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634679; 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=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=QzlIBqqbwECPXdzlaRQnlM8+FB/0009R7JKWS+SVtK2N50J+0R4u8bXrfx2vAUjpBL6DwJxZl+VLfic9DNBpz7FyVMKtOvRec7tfDJvkjOx8ujiz1krm31Fd1bqQpX4A2SciHoJYhmtKCkJcCsilEG6VjQqOka3GnqQxsSUzxug= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634679461941.9168124186766; Thu, 22 Feb 2024 12:44:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFux-00070K-G6; Thu, 22 Feb 2024 15:43: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 1rdFuu-0006zU-4m for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:40 -0500 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFus-0002cL-J6 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:39 -0500 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-5dc20645871so143271a12.1 for ; Thu, 22 Feb 2024 12:43:38 -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.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634617; x=1709239417; 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=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=aPLPVX+N+7Whu647T+22YnYcLbBdXxwug5fBZiGehhqN5DuNOjRK+MyvykEdy2PV9Y dYWiv1JhnRSnSC/OWfYL/uyDDaIDfVJ9psY32YAr+amyXyOk82qORTgOD3LI6l6s8pDa p9cCI1MY/3J3zQ9KRdI0upMjbIr2uX7gIYfCj8FduObfqxXZxi6dWsa58cvtVnj5pKRT KetRwCj0MmVfTywSc0fI/QbzPI/k4nYqAYLAa9GbV48ZAUfRBxINgXvhwTofaTxXlZeq e74Deu8r2mtweCyEtZ99IhjAjjUAs8ic6cEcHMKCzAOU+UcOr0QmOU5NYiHOSn47mQfz i7kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634617; x=1709239417; 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=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=PKH7l34bl7+siozkVQy2vJkDXoXc2GJ3uG1L40jN58VzFo6JwepYOnSwhdLreO0tSA qN7ieEUcIjKNNJ8A96jxxFWvcdEx/RgqTfhmZVG6DetZDWmi58pQL8lQCg5R3hdnBz+y BxW2UaJgduWgmoiDUaqi3/3a96TUnmCJPuNxGzqIuIcWWg49L1kCidjqP28XAuM+C86N annuS8WecZqj8YqPLLO76Pv2haW47NO5ACKM91bC61ExRW0w9C1PBpBtVE5JdqegDZ2x htkml6o+vYgeaeFRHC52Z900fbduIcrtXgTq6DLx7i6vj/4F4LWj+7qN7w/zBdUUkitQ r2OA== X-Gm-Message-State: AOJu0Yxqh6W6aLK6ORe18+32v01TBrBIeKTzzmVUH5QYS6/a0oGf7/Op zHUvFlzt2rwWl9lzBLIGqbU3H/kZxyWi51debBlBwvyA0jajLPvJsMMpEkMqqkN6VATAf5ogqvj B X-Google-Smtp-Source: AGHT+IEjNSpaWRAUWmDhTwQS+MrN9qDrAUGuGYUCtX+eV8vSgKmG1IFuf1p4BYJbRNu7AJuYQVjxCQ== X-Received: by 2002:a17:903:1cd:b0:1db:beac:61af with SMTP id e13-20020a17090301cd00b001dbbeac61afmr270755plh.0.1708634617006; Thu, 22 Feb 2024 12:43:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PULL 07/39] linux-user: Remove qemu_host_page_size from create_elf_tables Date: Thu, 22 Feb 2024 10:42:51 -1000 Message-Id: <20240222204323.268539-8-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 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: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634681570100001 Content-Type: text/plain; charset="utf-8" AT_PAGESZ is supposed to advertise the guest page size. The random adjustment made here using qemu_host_page_size does not match anything else within linux-user. The idea here is good, but should be done more systemically via adjustment to TARGET_PAGE_SIZE. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-5-richard.henderson@linaro.org> --- linux-user/elfload.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index e84a201448..dfb152bfcb 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2679,13 +2679,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int = argc, int envc, NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff)); NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr))); NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum)); - if ((info->alignment & ~qemu_host_page_mask) !=3D 0) { - /* Target doesn't support host page size alignment */ - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); - } else { - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE, - qemu_host_page_size))); - } + NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info ? interp_info->load_addr = : 0)); NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0); NEW_AUX_ENT(AT_ENTRY, info->entry); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634813; cv=none; d=zohomail.com; s=zohoarc; b=S86bj6I4w+c0N8Q53zx1lUTumnDs4CKlJ9hprCIiaeyG0hXYVtIZEXtBkIwEIAHbH4JVlU8er0Z0T+AJBipTZ+fKAcqTcjpweqFdS1Y+utMz/Ei3PrGfQSb/w9T0AdG+zx5XCiGSFkJRGKbuwmezVDTHLBkeQjkbBQWLSS5uQ60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634813; 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=XT/Eywr2J6L9mUszDOq9XJd5B5qFTrsZ1HJPZHlg+6neo0SCsZqcZLk20U08YDqDdyGBliYhMZhshxt9c2dKlTDwI+hsum+hU4/ilWKrTSoLNWUffLvD4xf3hx4TBr1EIomzzvtVP6ALJEvAkR2MFVOhlq4R/cIfy3qsuf5aZTQ= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634813565578.9558623257104; Thu, 22 Feb 2024 12:46:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFuy-00070n-96; Thu, 22 Feb 2024 15:43:44 -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 1rdFuv-0006zp-9Q for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:41 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFut-0002cS-Mc for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:41 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d934c8f8f7so521735ad.2 for ; Thu, 22 Feb 2024 12:43:39 -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.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634618; x=1709239418; 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=IXY3FNMlf5tD4tkHfrXxIkdWE84Lo257kMH4kL6eu1Xzbg93yqpbHxEv+x2pZYniSG iQY72bxqvGHmHh0j7i7kssPboxK47hZvHPYzAFutWAND8rrayWvLw26pUittbhFTG4cj Av7eKNujTyijnIeLBO63/oUWgtdOzyy1QGGemrXiidss+HYwFWOkTldu5mthHYusczVf 5axnJ1MF68461ZTTtg6f2+RjqwP4QxeiQJYonU95rHMYu5I94CvBfp9GA9D/Z5OmL0TJ hbMetGxTF/9B+aY0wDctjA2Pm6YnP5kkrFNNuJNA1qbNxZSaonerJC4eT54fCnKtLN9Z G8xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634618; x=1709239418; 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=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=fkdC63Zv6dxMqatm/tX6AI21Kxo3bFaYDIu/d82jX2j0K5iL3iceNMAdWNja2av8cY 0fPM7IsOEIOxRNs04ChoE1p44wX8io9CrZx5stKhmjCQNkKwpXff8kYrJM0/vLuPyEga IF8k/IGZEP3KhDnnGzQ3bWbD7Dif6/Ug0tEj2/RmNtZHagzcJX0L4D2oLWJa3m8Bnd0Z RNjTCASMz4Ikzob8SL/18PeBbVLYKbJX1gTw7BqVfPSEgC7g4UreNuELc0VpqWER0NI6 3Z3tL6khgbHpXif0IOOY6EPhUxxYV8yMpDqxX1+leU1AqveqBVdBvTqgjkz0sHbEhm1S 3VoQ== X-Gm-Message-State: AOJu0YxDPTbB62X4AVBarLPEN2HT03uZq3vA6PetobeVBn27n6xvx2lh udaJNI83guTSR4RM42EP3S3gXR1z2WqQ22vhP2H5W/AMdH4JrLMsV3AW8tG4kPZ2lJqBBXJA8xL S X-Google-Smtp-Source: AGHT+IHvM5bA684xWryyQ9GmZRMcHOL0zYp3ZGA35yzyBMWSzV8xKSyFi1lYd5I9fojNeQ9R+yXyZg== X-Received: by 2002:a17:903:1c6:b0:1db:d7a8:850b with SMTP id e6-20020a17090301c600b001dbd7a8850bmr16589191plh.25.1708634618559; Thu, 22 Feb 2024 12:43:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 08/39] linux-user/hppa: Simplify init_guest_commpage Date: Thu, 22 Feb 2024 10:42:52 -1000 Message-Id: <20240222204323.268539-9-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 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: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634813983100001 Content-Type: text/plain; charset="utf-8" If reserved_va, then we have already reserved the entire guest virtual address space; no need to remap page. If !reserved_va, then use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-6-richard.henderson@linaro.org> --- linux-user/elfload.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index dfb152bfcb..1893b3c192 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1970,16 +1970,20 @@ static inline void init_thread(struct target_pt_reg= s *regs, =20 static bool init_guest_commpage(void) { - void *want =3D g2h_untagged(LO_COMMPAGE); - void *addr =3D mmap(want, qemu_host_page_size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + /* If reserved_va, then we have already mapped 0 page on the host. */ + if (!reserved_va) { + void *want, *addr; =20 - if (addr =3D=3D MAP_FAILED) { - perror("Allocating guest commpage"); - exit(EXIT_FAILURE); - } - if (addr !=3D want) { - return false; + want =3D g2h_untagged(LO_COMMPAGE); + addr =3D mmap(want, TARGET_PAGE_SIZE, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1,= 0); + if (addr =3D=3D MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr !=3D want) { + return false; + } } =20 /* --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634676; cv=none; d=zohomail.com; s=zohoarc; b=btaVIFtt2e0yHWxmi8gPrGO0i3UbqGs5XSf0PTGDubOhWE/qw1RvTXPNKrMOpRULe+ANVcHuMy8lonTICWGqNxp4XI2m1BzbwSPa7Qc4zO1oxEcifN8FxwKHzB8aqw/9AePvh+kfqaBKtr2rHEhwN2QeBJ38rA+2kPl8YS4mNd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634676; 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=D1JsYCpi6dUhs1epAOsWjPhMNT6xL6sAR+d/0LTaqE6+1Suihcoief7FmTxW/Lcl1cYMy11tfFJ8cDgrjgWghBNCIVV4SlIwAmZE3MFh9VxWIehIKk8B8NC3efHZ1K13K2JemqIFtictbRPHM9zE/fNwjO+5+BWrNlYEY5xe2Lw= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634676665358.9011251209396; Thu, 22 Feb 2024 12:44:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFv1-00075S-T4; Thu, 22 Feb 2024 15:43:47 -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 1rdFux-00070f-P8 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:44 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFuv-0002cm-4b for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:42 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1dc13fb0133so400895ad.3 for ; Thu, 22 Feb 2024 12:43:40 -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.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634620; x=1709239420; 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=VsdgqmSn3KN7WNHhYg2ADbbWpZJ5QJzlpqs7sfR5UM3qZs/EyhvCXQXmt0BSu0oDoZ +0+t2nQyP3XSBX+Xh652ycNLFFoUuK/DTOjRMZyoCgAEI7i2yzQ6ZaO8E4odky4kU08a IZr43tmNNwSrYBIWQKtyLigYMoHSICKvzkQyG12AoF3wTTTCO7dorh4tjQml2RxiT2By HpV5Ws3334Ig+53Q6LH1U+BKWdaH0u53WQoUjk589Yn4rVwFxlCuYplQ1CwjP0ZPjQwR /zqLCNCH/wP2JaAJMrT2o02jZMmYuAUSG0TtkJCHDCcpXQzExj2hqDcVUz/ZQOpxBZIN M4UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634620; x=1709239420; 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=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=w4HNIt8j12czhnS7NIZ8447ZmaEijK73armHAK59iW4DrGgG8bJzJC22Kq/ZdDPt5Z 9o+j+EXO7V3BGzyrvQfszTjNGUBjrzmBOr2OGcAOPHQ44KuymvhHNWD8EWOPEvng3pfz MvKet0Rsy41gwIUGm9kTDOdmIxFrEby2lerZypl5GMDAVR6CTt41TYLnq5g/LghMH/G9 tlfO101DA4h1kWBqEVxrNQUs4EKaIO2bIuVB3LveHancwTs/NJ3ycYud1aF2zkatc3Aa L5/1O9VyA84+Dj4Wt+OTADVKn8toTGL+lyhyhj1Glm0gTl9xjr9r5YyLoqQyi46qsKNp E3gw== X-Gm-Message-State: AOJu0YxbhpO7/mjGwOJHsq8Wew1GA6/l05KxrkLPHsBZ4skfcXNFHvHc FD3OJzD54EjbezjH4gnjeY/oY9U+Mh2vxSFPl+JFmQrvj+wVUKvdvYfmIYbQV1s02i7KVkgJzVs J X-Google-Smtp-Source: AGHT+IGFSz5KPcJYr2c4+rE8XHTN5WltgBYqhZTzmSsYXJRi2R6o+nCFd5HmCdadzd0RMNyVtlNFsw== X-Received: by 2002:a17:902:e551:b0:1db:be69:d037 with SMTP id n17-20020a170902e55100b001dbbe69d037mr22021957plf.46.1708634619854; Thu, 22 Feb 2024 12:43:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PULL 09/39] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Thu, 22 Feb 2024 10:42:53 -1000 Message-Id: <20240222204323.268539-10-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 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: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634677496100001 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-7-richard.henderson@linaro.org> --- linux-user/elfload.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 1893b3c192..a9f1077861 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1532,10 +1532,14 @@ static bool init_guest_commpage(void) 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ }; =20 - void *want =3D g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size =3D qemu_real_host_page_size(); + void *want, *addr; =20 + want =3D g2h_untagged(LO_COMMPAGE & -host_page_size); + addr =3D mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr =3D=3D MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1544,9 +1548,9 @@ static bool init_guest_commpage(void) return false; } =20 - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); =20 - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634758; cv=none; d=zohomail.com; s=zohoarc; b=KRZevJy/9aroUQhvtQz+7ASaqAaVcJJEoXfGztovqd1wpHe6tDL4hULet+meXLsRDa8QLRYhUWeijWLWPXa1r/K4X/wUOUe7QZFQl3Kgby0/7MYvkVS+/vumnWodnkXcYOxv2ty5kWnqHmq1WhTw1bSlzWGadA1J+8A5gsjPkNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634758; 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=L37VAsZYFcWoBazd33PR7hij8/eMfqoOUQCD/RoBrKRNS7T9u/tCOQLxqTRy+8JJ3swlgdCPxoruRZH4Swms4/B+Ae2+y/hI4aviYvzYuupb3WfLI2ZiT8etTBeuC1lT4B4o1Yx/9h5o4etBA9a0LePzi6Bh7S+BCwx8nJhujoA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634758441323.32578366874463; Thu, 22 Feb 2024 12:45:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFv0-00074R-Al; Thu, 22 Feb 2024 15:43:46 -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 1rdFuy-00072X-Vn for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:45 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFux-0002cz-9C for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:44 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1dc139ed11fso10251345ad.0 for ; Thu, 22 Feb 2024 12:43:42 -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.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634621; x=1709239421; 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=Njeeik9zO19UpleMaIDKuJa5PCejUa3nrDoAGi3qUoDdjdRGOZ4BYwNWjvmuJdEOFf nwncKrZt5TXsiQQgu4HClU33N4pj1RcroDvLthoW18tq1BF+ukZCc+GneIPJOghFKiv+ 9SPYd2RoagkVV+6EqXnKelIYuRNhcEKYcVdxuXSSzsIIWVvDoM2O1Z21k/HSPe/YWSrm QUMPSO1MZEKGkSNCm0LdtRfEAD4Kb1wL7GbrF5+lTJL3PkxS5lH+4+NKbGoFRVD638nK dIh/ut7B4L+C157X1JRujb63xOihyTy7NYSjPVVROjBdQRFU/nKZNU53OzNkpkRRlZlZ BQcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634621; x=1709239421; 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=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=NmpXdLwm0MTDpOvI7qKdprSCZLhNYNTc+qPX4ANpOS+4O/aeT3hBPd54X/cr0Tv2P5 37Uu9c/a6pGk0+N6BVKUR098Lu9I65lLbG5IlgdD+JztKqRK+ugcLEL5WYpAY+lo9CNJ +NYNEJkofwZ6RCXKVYdgrWTqQQQEL6o3UPX/9ff88atN/XidnwsLnyFu5TyGSRkjMCEJ A7IPVKjOTB2j47BqCIoqY3VWtaZZSZCT+GFxRPqhxscpWNhjxsUeJYrCzO9fWQOzrcPs K8x6ZX6+x0BlfOqZgBWQEnKWtTPCt/M2biFz0C3P2AeBW98jvJ2dlEHPu1Pya7zo+w/6 SUuA== X-Gm-Message-State: AOJu0Yyt5wIZKMRB7k26h+nKUZ5j3xZek68lA308HSORTLYZtLXg9mfM piRCLfIhMsgUOTdpzSOtrUGWfllNqOrnqjti+7uBbXHTRDPJmAfKSG4NWEcxANq3vq1xa7Gdayz y X-Google-Smtp-Source: AGHT+IEwJziSyEuRCWD5PkVaxtUS+nDgchiFl2JkjU3dNR7mB2TJyn6RO23QS3xB/01LGUzrjNPZvg== X-Received: by 2002:a17:902:ec83:b0:1db:2caa:6c5e with SMTP id x3-20020a170902ec8300b001db2caa6c5emr5538661plg.3.1708634621183; Thu, 22 Feb 2024 12:43:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PULL 10/39] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Thu, 22 Feb 2024 10:42:54 -1000 Message-Id: <20240222204323.268539-11-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 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: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634759833100002 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size. If the commpage is not within reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-8-richard.henderson@linaro.org> --- linux-user/elfload.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index a9f1077861..f3f1ab4f69 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -460,6 +460,7 @@ enum { static bool init_guest_commpage(void) { ARMCPU *cpu =3D ARM_CPU(thread_cpu); + int host_page_size =3D qemu_real_host_page_size(); abi_ptr commpage; void *want; void *addr; @@ -472,10 +473,12 @@ static bool init_guest_commpage(void) return true; } =20 - commpage =3D HI_COMMPAGE & -qemu_host_page_size; + commpage =3D HI_COMMPAGE & -host_page_size; want =3D g2h_untagged(commpage); - addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + addr =3D mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (commpage < reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); =20 if (addr =3D=3D MAP_FAILED) { perror("Allocating guest commpage"); @@ -488,12 +491,12 @@ static bool init_guest_commpage(void) /* Set kernel helper versions; rest of page is 0. */ __put_user(5, (uint32_t *)g2h_untagged(0xffff0ffcu)); =20 - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } =20 - page_set_flags(commpage, commpage | ~qemu_host_page_mask, + page_set_flags(commpage, commpage | (host_page_size - 1), PAGE_READ | PAGE_EXEC | PAGE_VALID); return true; } --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635082; cv=none; d=zohomail.com; s=zohoarc; b=b2tpyqPKHc4ypRYVcAhehBB0f0tRWMie12gePFye22fUJ7Fsqkjs8sXFM3HQ4vh5RhzHh4DJdQabebTvpqvhs9aFMsAmgwEz2txaI088rerMleSOQm9iaabdy+ysLatHpGiuA5jCW0n/FBhm6cZFTsG48/cXpV72YeTyv8YrT68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635082; 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=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=EVbGJKzkd+8FKDc0xNwYJzUuds4KWRqY1QuicWskN40o8quleDBpj85y1AfaFHdvpmR1OuJ42UV3VeymGVYpObwXRc1zFK3bgz+UJCABfw36cvzrLpsM9y1JojdrmsX9z6HYN6iJGRO1gyTiCQ/beTCXVz+QBZ3/4fwq2tykCI8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635082737800.0809551179156; Thu, 22 Feb 2024 12:51:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFv2-00075h-RL; Thu, 22 Feb 2024 15:43:48 -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 1rdFv0-00074W-RP for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:46 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFuy-0002dc-Lx for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:46 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d932f6ccfaso1932215ad.1 for ; Thu, 22 Feb 2024 12:43:44 -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.43.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634623; x=1709239423; 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=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=fyOwwk1oVImLseSw6eWTx/wO2b48zr/06VHOlfAIx3f6IOM+Vt5mNR880NcpnvdjP2 vGlzmv/JJhE0Kj/9wh/1R/+OQqE2UuMwyjpE8qEuyOTJt0IDtv4FIV1idaATBBndN8Pf YIevwM8kDEcZ9gMND0JjwL2w4xQoHDteuBmuSAJoWQYNEDSjC7RgV6pbC8usnDDuySvw dMTFOsd5rywHBsuPI3QQAOr7E4lJRLlrCnbJzD+EIuuHvwciZrc363jAROFABmL7kudC UOTZHukoY77QhUu0f7eP+04qReHTcTpMIGvQX4VwoK7DliLI6aal9T94LfuDyhJ0gCrV kmZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634623; x=1709239423; 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=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=Qw4M48H4ym87Rix+74zqh0AVZxA1KCEdAQr0l20gMhJOx3xuw4AF41oSFYmPES3BVo RORe6uP8w2isppnNJ0ilgweBBf77gMx6ewrvV7REnfP+jy5TPFzHfDNJhwXFfYF9ownb NGEFWlV2YvbaV7XQ31uhZvoHtvxhs3AYoAdraMnZdf+/YAdqiVPJuCOOqji2T1hEKvXr fCBCuxXCbG/XGVx7GnciQ0BKbngIvNOC3ZXqUQG7ezzNZGpn1kcXufE6Vw6X+mQLc3N4 vuG4GTtGplGvU8erATaCJ1Ezdom/Sf8AegXvl+vdEMDIa69FDtHXwFaR4rq8nN+F/zCC xZcA== X-Gm-Message-State: AOJu0YyRAtZ0GOUDzPA3Q+x6JaPysV7trS5i5Ss8zVLJ/jtb4tqEHKjH dLmxSuLmOw8RCWKDTHRXoNm756bQzJ+m2ueNE0Sf5HDR+689HtsqklkYAlQxbe7/gGx0HryKQoE s X-Google-Smtp-Source: AGHT+IFoDbPcEJdJI33eruKgutUBjX7fzVs+WDRlJt9Ex1cxlY6qrQKD4ZoKQ18NCWIUnSXnZnK4nQ== X-Received: by 2002:a17:902:9a83:b0:1dc:3d5:bdcc with SMTP id w3-20020a1709029a8300b001dc03d5bdccmr8527856plp.42.1708634623172; Thu, 22 Feb 2024 12:43:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PULL 11/39] linux-user: Remove qemu_host_page_{size, mask} from mmap.c Date: Thu, 22 Feb 2024 10:42:55 -1000 Message-Id: <20240222204323.268539-12-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 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: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635084851100003 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size instead. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-9-richard.henderson@linaro.org> --- linux-user/mmap.c | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 96c9433e27..4d3c8717b9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -165,6 +165,7 @@ static int target_to_host_prot(int prot) /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong starts[3]; abi_ulong lens[3]; int prots[3]; @@ -189,13 +190,13 @@ int target_mprotect(abi_ulong start, abi_ulong len, i= nt target_prot) } =20 last =3D start + len - 1; - host_start =3D start & qemu_host_page_mask; + host_start =3D start & -host_page_size; host_last =3D HOST_PAGE_ALIGN(last) - 1; nranges =3D 0; =20 mmap_lock(); =20 - if (host_last - host_start < qemu_host_page_size) { + if (host_last - host_start < host_page_size) { /* Single host page contains all guest pages: sum the prot. */ prot1 =3D target_prot; for (abi_ulong a =3D host_start; a < start; a +=3D TARGET_PAGE_SIZ= E) { @@ -205,7 +206,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) prot1 |=3D page_get_flags(a + 1); } starts[nranges] =3D host_start; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; } else { @@ -218,10 +219,10 @@ int target_mprotect(abi_ulong start, abi_ulong len, i= nt target_prot) /* If the resulting sum differs, create a new range. */ if (prot1 !=3D target_prot) { starts[nranges] =3D host_start; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; - host_start +=3D qemu_host_page_size; + host_start +=3D host_page_size; } } =20 @@ -233,9 +234,9 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) } /* If the resulting sum differs, create a new range. */ if (prot1 !=3D target_prot) { - host_last -=3D qemu_host_page_size; + host_last -=3D host_page_size; starts[nranges] =3D host_last + 1; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; } @@ -270,6 +271,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong las= t, int prot, int flags, int fd, off_t offset) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong real_last; void *host_start; int prot_old, prot_new; @@ -286,7 +288,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, return false; } =20 - real_last =3D real_start + qemu_host_page_size - 1; + real_last =3D real_start + host_page_size - 1; host_start =3D g2h_untagged(real_start); =20 /* Get the protection of the target pages outside the mapping. */ @@ -304,12 +306,12 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong= start, abi_ulong last, * outside of the fragment we need to map. Allocate a new host * page to cover, discarding whatever else may have been present. */ - void *p =3D mmap(host_start, qemu_host_page_size, + void *p =3D mmap(host_start, host_page_size, target_to_host_prot(prot), flags | MAP_ANONYMOUS, -1, 0); if (p !=3D host_start) { if (p !=3D MAP_FAILED) { - munmap(p, qemu_host_page_size); + munmap(p, host_page_size); errno =3D EEXIST; } return false; @@ -324,7 +326,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, /* Adjust protection to be able to write. */ if (!(host_prot_old & PROT_WRITE)) { host_prot_old |=3D PROT_WRITE; - mprotect(host_start, qemu_host_page_size, host_prot_old); + mprotect(host_start, host_page_size, host_prot_old); } =20 /* Read or zero the new guest pages. */ @@ -338,7 +340,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, =20 /* Put final protection */ if (host_prot_new !=3D host_prot_old) { - mprotect(host_start, qemu_host_page_size, host_prot_new); + mprotect(host_start, host_page_size, host_prot_new); } return true; } @@ -373,17 +375,18 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong sta= rt, abi_ulong size, */ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) { + int host_page_size =3D qemu_real_host_page_size(); void *ptr, *prev; abi_ulong addr; int wrapped, repeat; =20 - align =3D MAX(align, qemu_host_page_size); + align =3D MAX(align, host_page_size); =20 /* If 'start' =3D=3D 0, then a default start address is used. */ if (start =3D=3D 0) { start =3D mmap_next_start; } else { - start &=3D qemu_host_page_mask; + start &=3D -host_page_size; } start =3D ROUND_UP(start, align); =20 @@ -492,6 +495,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; int page_flags; @@ -537,8 +541,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, } } =20 - real_start =3D start & qemu_host_page_mask; - host_offset =3D offset & qemu_host_page_mask; + real_start =3D start & -host_page_size; + host_offset =3D offset & -host_page_size; =20 /* * If the user is asking for the kernel to find a location, do that @@ -567,8 +571,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, * may need to truncate file maps at EOF and add extra anonymous pages * up to the targets page boundary. */ - if ((qemu_real_host_page_size() < qemu_host_page_size) && - !(flags & MAP_ANONYMOUS)) { + if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { struct stat sb; =20 if (fstat(fd, &sb) =3D=3D -1) { @@ -595,11 +598,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt target_prot, host_len =3D HOST_PAGE_ALIGN(host_len); host_prot =3D target_to_host_prot(target_prot); =20 - /* - * Note: we prefer to control the mapping address. It is - * especially important if qemu_host_page_size > - * qemu_real_host_page_size. - */ + /* Note: we prefer to control the mapping address. */ p =3D mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p =3D=3D MAP_FAILED) { @@ -665,7 +664,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, * aligned, so we read it */ if (!(flags & MAP_ANONYMOUS) && - (offset & ~qemu_host_page_mask) !=3D (start & ~qemu_host_page_= mask)) { + (offset & (host_page_size - 1)) !=3D (start & (host_page_size = - 1))) { /* * msync() won't work here, so we return an error if write is * possible while it is a shared mapping @@ -694,7 +693,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, =20 /* handle the start of the mapping */ if (start > real_start) { - if (real_last =3D=3D real_start + qemu_host_page_size - 1) { + if (real_last =3D=3D real_start + host_page_size - 1) { /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { @@ -703,21 +702,21 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, goto the_end1; } if (!mmap_frag(real_start, start, - real_start + qemu_host_page_size - 1, + real_start + host_page_size - 1, target_prot, flags, fd, offset)) { goto fail; } - real_start +=3D qemu_host_page_size; + real_start +=3D host_page_size; } /* handle the end of the mapping */ if (last < real_last) { - abi_ulong real_page =3D real_last - qemu_host_page_size + 1; + abi_ulong real_page =3D real_last - host_page_size + 1; if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { goto fail; } - real_last -=3D qemu_host_page_size; + real_last -=3D host_page_size; } =20 /* map the middle (easier) */ @@ -784,6 +783,7 @@ fail: =20 static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong real_start; abi_ulong real_last; abi_ulong real_len; @@ -793,7 +793,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_u= long len) int prot; =20 last =3D start + len - 1; - real_start =3D start & qemu_host_page_mask; + real_start =3D start & -host_page_size; real_last =3D HOST_PAGE_ALIGN(last) - 1; =20 /* @@ -802,7 +802,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_u= long len) * The single page special case is required for the last page, * lest real_start overflow to zero. */ - if (real_last - real_start < qemu_host_page_size) { + if (real_last - real_start < host_page_size) { prot =3D 0; for (a =3D real_start; a < start; a +=3D TARGET_PAGE_SIZE) { prot |=3D page_get_flags(a); @@ -818,14 +818,14 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi= _ulong len) prot |=3D page_get_flags(a); } if (prot !=3D 0) { - real_start +=3D qemu_host_page_size; + real_start +=3D host_page_size; } =20 for (prot =3D 0, a =3D last; a < real_last; a +=3D TARGET_PAGE_SIZ= E) { prot |=3D page_get_flags(a + 1); } if (prot !=3D 0) { - real_last -=3D qemu_host_page_size; + real_last -=3D host_page_size; } =20 if (real_last < real_start) { --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634784; cv=none; d=zohomail.com; s=zohoarc; b=P16G+Y6pI0RBnn/M8uBHcP/ufZ10bjFrdb7wKxDA5oEbTL4PQtu2zGgA9z8bDwcrA+9tfNuyM3Pgn2jfK9Rk9E4Z7x4OgGT6QLXHltQZdWeR8BhraSBXZB/aBUjb1HKfW9XoHLxPvI7IX/vCxO02v4mDymtS/w+7OpvJwfKoCmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634784; h=Content-Type: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=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=iBWPLnvQlWOXYnAEoX9rJRCO3f31QM3U0HoU2j67hiLJvW1WUX8GZfMpiikPigEb3scZoGH4wN5BGlKWLFuHzertGf5AElfAvQH7zD5k5nIKISFztNMlYDvZlceRj+qEaiBHn+Dl+pogoEe0j0buq6Qrhez74/m5/1SluEvg4PY= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634784783783.763078951204; Thu, 22 Feb 2024 12:46:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFv3-00076C-Uy; Thu, 22 Feb 2024 15:43:49 -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 1rdFv1-00074w-60 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:47 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFuz-0002eL-Pe for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:46 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d94b222a3aso1907475ad.2 for ; Thu, 22 Feb 2024 12:43:45 -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.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634624; x=1709239424; 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=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=YefzncufOad2toW6MD2Us6LvBb1zDA/aUbJET7ef/SieWxd0bHhKSGuAUFxGcYCvZb 1QlctQM0vhXsvp5y42vSALv0V3WxKRPD0slOYlvtr+B+yfoAxoXb7/omFu2SpPGdbo75 l+WdWpXkEH2C1ecgMo1n3ybt+Fl5wLlgrAw6Y+yIX/tGD8R4Tu8rNHXPJu3B4B2oDN1J rQVAF5Kdy58J2e17cnFrPrglYgM4k4qvP03jY1bGI/WDd2bpqDN4D+Hw+O0mitrawo5i CK7ZS7DxeB9QpWy8ayCgy/peDSjJ66CkxooD7gQI0YqyZVTMIDdUe8Ckwu1m1XmQ/Nm2 DBXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634624; x=1709239424; 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=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=i7SuZ3vPfm1qTsSzrhowFcyoIPPMuPuIY8VR8EdBnKTfXODmW0dJ6DefaKvBBL3vvc U7FqyVBaRlreouF54caxjJ4XpryNAnn8jSSouWCBNCvNGusj6MJHTYCbx1QD0tohNlQJ v3Fd6tdcAE6IGvEoZrSED+1SKTrHAPC/bNiyEZL9S29YxnZnflKzyaVKEW2G45OWdMek IDxnUE0zJL/tdHHYT0RxOImAmUks9IaJkOE5/u+VE8lcq8jJQZQMXPB/eddNJ/IXBqz/ w6iVNTreKbSE3Erriw07q9wZMklop2PHJ2qx7YqH9MfdCNJduWDddPcmFt7uHXUSMbvM v1IA== X-Gm-Message-State: AOJu0Yxj8o+7/GpfKLoOJQZcprB22bVRrtZsCcB5vymExPXr5EC/8uPg ZHugOBx2/ZXNtfMobolcNoDi4n4/id1o8Kv09gf8RVFMdD0krooG7UeiJm2hBPc4teYqxcOiFeJ u X-Google-Smtp-Source: AGHT+IGLAQIiCdkn4JcgGvYppS43mkFBwl0pdDGUPCeFRj4Qp9DKME1aiwGDZPaRA7iUYIFtkjcPGw== X-Received: by 2002:a17:902:e789:b0:1db:fa84:9be3 with SMTP id cp9-20020a170902e78900b001dbfa849be3mr10994096plb.8.1708634624592; Thu, 22 Feb 2024 12:43:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 12/39] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c Date: Thu, 22 Feb 2024 10:42:56 -1000 Message-Id: <20240222204323.268539-13-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634785880100001 We already have qemu_real_host_page_size() in a local variable. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-10-richard.henderson@linaro.org> --- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 4d3c8717b9..53e5486cc8 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -585,7 +585,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, * the hosts real pagesize. Additional anonymous maps * will be created beyond EOF. */ - len =3D REAL_HOST_PAGE_ALIGN(sb.st_size - offset); + len =3D ROUND_UP(sb.st_size - offset, host_page_size); } } =20 --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634715; cv=none; d=zohomail.com; s=zohoarc; b=kpmbYQnCyX1j8gvKIqYCRQMVCJmYChjVFJVVgnccLLF50SEvyKLidQDOcXHXjQ/q/vNvuEFZdLRu5f7jPgXPXlgws1JDnc0rk7zef24Ao1+9C7Vxg9jDoS+afCud5QAM/RkXrNIMeuDSdPOru9Jz3cJuu8KmTM2xsbC75p70Xvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634715; 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=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=P1ukl//lWq176rmvUNNS5tOUjx+3nZLF6RjDRq2EncNlLoZZzXuH7w+xmZNG/DoEk+0D2o2isrrpYINHV354IDE2tV6tNLEIQ4YkmGgi38dUtRqn6NjCLZXVzhNYextwojDdWO50Ycl/KMJ/mjb+FYrdEjM3lkqiJLSNVZMqMTM= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634715477382.5267304358256; Thu, 22 Feb 2024 12:45:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFv7-00078c-9K; Thu, 22 Feb 2024 15:43:53 -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 1rdFv3-00075k-1z for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:49 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFv1-0002ej-El for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:48 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1dc3b4b9b62so2023715ad.1 for ; Thu, 22 Feb 2024 12:43:47 -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.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634626; x=1709239426; 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=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=H+ajFqd8obqTtbx1c/AzI2RPKxqKppZdW00DkdCHHyrdNkPmkzf3BoEGmjRoZEfEKt t9U4cGjvWedxF9X2VY6q0Fvua1+xGsgfNHjPAFctB8t+88U3KonDaxe0R8aJx2nyzEQ/ /URlWTBzVhOH8gv1+/l/68MpoNLcjdZBIfzdro1B/wKXp43tUf1Me8FeachzukFflsU3 3rgPv41MKzE1zT4ZVJ0LxPHAoC+dbObFCM6Z2fOmLfoFMuwA4T9km4367hbC9HLod/QV 7D2sU7K1ZC4zIeIYxZJ4XVPlENG+K8rLGU8FkHhs5FVDFmx61PxNIOI3ZnN2L/5hETAX /IiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634626; x=1709239426; 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=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=jrYKosyfjTPMFh9PdqDc2mFe3a9BaMxSTh7TDRnANCNx27WfqUjjIYtsB5YJM8rpZa bR6uNd/6vACPIAotd0szQffwLean65WT5oyu4ie+mweyAgT70AQc9VEUMk6kYDVQJ/Yf 8LXhri4yOMY2v20nJQs8yYo1e+np88My344v2gJJZnUgvKRlNqF2ImsDaWSa707SU7cr TzTH8deELNOzglVya4T7xxXrsK6TtWujClZGZ/iIiuVrxwFDSevI7VGQRJr8MG7LHXgR PT5JEcxNqOIp+OvQDEZ6J8gg6QSZ9PTQ2x2NNhcSIoS0c3gq1K+GEM8kSH2H/K+SnnfY e2gw== X-Gm-Message-State: AOJu0Yz6MTpRrsfhdJDxXLcG78cyQv1nBvblHWrku3TrQ+OtMeKeXFZ/ 3nLb+CSuEjvzyJbDH1goHJJftEsWB+aia13598jHm9voBbTnMuzqjSiuaE5NiheVjVCnzWf7I89 n X-Google-Smtp-Source: AGHT+IFLfX0qbOK2LVfyUGGMQGn+LI4ZclT0Y6JaNDcP2mfDam5Vq3nk774ZD7BMOS8Qvpc6jVcIiA== X-Received: by 2002:a17:902:da92:b0:1db:f15c:85c0 with SMTP id j18-20020a170902da9200b001dbf15c85c0mr171752plx.33.1708634626133; Thu, 22 Feb 2024 12:43:46 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 13/39] linux-user: Remove HOST_PAGE_ALIGN from mmap.c Date: Thu, 22 Feb 2024 10:42:57 -1000 Message-Id: <20240222204323.268539-14-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 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: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634717672100005 Content-Type: text/plain; charset="utf-8" This removes a hidden use of qemu_host_page_size, using instead the existing host_page_size local within each function. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-11-richard.henderson@linaro.org> --- linux-user/mmap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 53e5486cc8..d11f758d07 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -191,7 +191,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) =20 last =3D start + len - 1; host_start =3D start & -host_page_size; - host_last =3D HOST_PAGE_ALIGN(last) - 1; + host_last =3D ROUND_UP(last, host_page_size) - 1; nranges =3D 0; =20 mmap_lock(); @@ -389,8 +389,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) start &=3D -host_page_size; } start =3D ROUND_UP(start, align); - - size =3D HOST_PAGE_ALIGN(size); + size =3D ROUND_UP(size, host_page_size); =20 if (reserved_va) { return mmap_find_vma_reserved(start, size, align); @@ -550,7 +549,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, */ if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len =3D len + offset - host_offset; - host_len =3D HOST_PAGE_ALIGN(host_len); + host_len =3D ROUND_UP(host_len, host_page_size); start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; @@ -595,7 +594,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, void *p; =20 host_len =3D len + offset - host_offset; - host_len =3D HOST_PAGE_ALIGN(host_len); + host_len =3D ROUND_UP(host_len, host_page_size); host_prot =3D target_to_host_prot(target_prot); =20 /* Note: we prefer to control the mapping address. */ @@ -625,7 +624,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, goto fail; } last =3D start + len - 1; - real_last =3D HOST_PAGE_ALIGN(last) - 1; + real_last =3D ROUND_UP(last, host_page_size) - 1; =20 /* * Test if requested memory area fits target address space @@ -794,7 +793,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_u= long len) =20 last =3D start + len - 1; real_start =3D start & -host_page_size; - real_last =3D HOST_PAGE_ALIGN(last) - 1; + real_last =3D ROUND_UP(last, host_page_size) - 1; =20 /* * If guest pages remain on the first or last host pages, --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634653; cv=none; d=zohomail.com; s=zohoarc; b=XZgFXJe8FUWc2Cy6wA2EA8zhPFjDk8sKlV5bDyUs7Dwd0/uPa6Dms7htw6ltrlnVKgVsKWJivQI4jcIjltocGIgkp8J0wSEBb7Mr+k41ly3uuzJa9S7635djKwtyj+g8vEU99Vod0/jUPBZa8tKuQBCcGehwf59MtiPjzEpZMGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634653; 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=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=n30Cd08bCIMmLgeaSAlEz/ROPeRdo2OHFZ62WeEd82kGmsfEYaPvqJXijtWXu+Md+jJOejSbRyjJGcNerSyG6oXDh+nhgtjEAt7tysPnNqfadqZRUqBKIJAyWV48QLFYAJb8fVezyiVTigyKPVePgpyWrhJrzqKQjGvVKRwjJ40= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634653839664.2809519781516; Thu, 22 Feb 2024 12:44:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFv9-0007HX-Nk; Thu, 22 Feb 2024 15:43:55 -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 1rdFv5-0007Cb-W0 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:53 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFv3-0002fO-3H for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:50 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d73066880eso2072135ad.3 for ; Thu, 22 Feb 2024 12:43:48 -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.43.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634627; x=1709239427; 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=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=g9JkkC78kXu590aZzhZDQGh3vXufgZDGk/pLXVSNopNrqAow5tDlZitYpxgnT0+rbb 9nfupNRA/SApjE/uPonO1p1D/38Pi4NjyCLqk3RmZ7W3ekbWnOMC958TWzTjUaT7cdl/ hY4op/O3Rv+jrya4IRLxNDpda9oruJK582TYebSkb2WHN5+wtIFIukQbFKpbu/H+K9Wc +S8lQc0Aek6OfcfWU4mLeixWT2kOOJqTrc6+3IztWj60BDSTCUq/dZ3u+sPSgbetg1PR 3DskF6gxZe7XI8Km4l6z5/826fpFU5Jb9iIi9fuiu4xZrdPeJ4Um9Aa5rkj+2s9Kb6Qa nEIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634627; x=1709239427; 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=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=khm1Nyo94WCwBtoXHdm13jrKika9TgQfiHk8qcGGyFUDJDUisk7YImq0ypw+ZEY5UA SH9+u4ex1CPBLQOxepE2OpFOyweyF6rX+6ufTon8B6O+/CdD5v8AinoInR5+neN2q9Zf KjIUR1aytKvgDF8jG2dhNvG9JCXpihH/twSxpq7lNvFGu1ckkw8Hp7veNXVBlZDXPx0G Q+3/CYA56HjtFyC8rt6U2K69WUU/dbbpylD1H7zWAAPTik0SrxRgn8VCJz8dMJ/S1CA3 M21EckiutgiTls3XcfJF/DsAIredUiBKGZdZm6izRRQd1sHmrGpjKruXVqfDxcsWEIxK iYBw== X-Gm-Message-State: AOJu0Ywkl726fbF/idHn8+Q4Kp1faOytkqbkwWz2Wps3caZLfEy2Ch6r yOqPJvst8Yy9AKwmmLfUtx9uXdXZYxFdTNL9uR/Tahl43Nw3riUCT4NJ4lqMqzwRQ2kYVI+qtMg p X-Google-Smtp-Source: AGHT+IGqMMl87NciX6E9cvagZpZTphc4TxdGyPnytQaCAzhuUuBo680g5GPhi/pDhdcbUkqWIO1odw== X-Received: by 2002:a17:902:6e0f:b0:1d9:167b:8e6c with SMTP id u15-20020a1709026e0f00b001d9167b8e6cmr20193636plk.46.1708634627595; Thu, 22 Feb 2024 12:43:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PULL 14/39] migration: Remove qemu_host_page_size Date: Thu, 22 Feb 2024 10:42:58 -1000 Message-Id: <20240222204323.268539-15-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 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: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634655459100006 Content-Type: text/plain; charset="utf-8" Replace with the maximum of the real host page size and the target page size. This is an exact replacement. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-12-richard.henderson@linaro.org> --- migration/ram.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4649a81204..61c1488352 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2935,7 +2935,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) { RAMState **rsp =3D opaque; RAMBlock *block; - int ret; + int ret, max_hg_page_size; =20 if (compress_threads_save_setup()) { return -1; @@ -2950,6 +2950,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel =3D f; =20 + /* + * ??? Mirrors the previous value of qemu_host_page_size, + * but is this really what was intended for the migration? + */ + max_hg_page_size =3D MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + WITH_RCU_READ_LOCK_GUARD() { qemu_put_be64(f, ram_bytes_total_with_ignored() | RAM_SAVE_FLAG_MEM_SIZE); @@ -2958,8 +2964,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idst= r)); qemu_put_be64(f, block->used_length); - if (migrate_postcopy_ram() && block->page_size !=3D - qemu_host_page_size) { + if (migrate_postcopy_ram() && + block->page_size !=3D max_hg_page_size) { qemu_put_be64(f, block->page_size); } if (migrate_ignore_shared()) { @@ -3792,6 +3798,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *bloc= k, ram_addr_t length) int ret =3D 0; /* ADVISE is earlier, it shows the source has the postcopy capability = on */ bool postcopy_advised =3D migration_incoming_postcopy_advised(); + int max_hg_page_size; =20 assert(block); =20 @@ -3809,9 +3816,16 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *blo= ck, ram_addr_t length) return ret; } } + + /* + * ??? Mirrors the previous value of qemu_host_page_size, + * but is this really what was intended for the migration? + */ + max_hg_page_size =3D MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + /* For postcopy we need to check hugepage sizes match */ if (postcopy_advised && migrate_postcopy_ram() && - block->page_size !=3D qemu_host_page_size) { + block->page_size !=3D max_hg_page_size) { uint64_t remote_page_size =3D qemu_get_be64(f); if (remote_page_size !=3D block->page_size) { error_report("Mismatched RAM page size %s " --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635105; cv=none; d=zohomail.com; s=zohoarc; b=jbSaw789rpeTLjQOlkfddPIyMM6skcWi0r9oJ6UC2a2BkYLb+vHZ7Ww0ho6FNaNfsrllDUR3HmU9yvrF+AwUXvZyyM38xZEYoZXr99p0y5dpIW8KXbsZrC6qzz0/8zurwwXrX+m0ID/p/xMERycmmyQm1YHRlsVqXVjYmAvHylY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635105; h=Content-Type: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=9UuugcteI3wsnFXZ+gvu7oCS1Hb/WPFzjY9R5VsQ974=; b=ZUs36wNoUO8DLpXcuQEpSejUxydXJauYWaAvvZYHX4pXQlh1x9TiyaE+IH5e2BrytyAjeuki5zwpCv4Ppz0f9h1LTQ2A/I5CPdec2DqDyae4u6yPU5qfVtcqHn02aYlopltu6NMKnCS4wCT2zVRWbGFfrrIGapP6zYuTtmVPdwA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170863510551736.5161302979875; Thu, 22 Feb 2024 12:51:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvC-0007Lg-1F; Thu, 22 Feb 2024 15:43:58 -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 1rdFv7-0007FJ-FA for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:53 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFv4-0002fz-7Y for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:52 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1dc09556599so1893345ad.1 for ; Thu, 22 Feb 2024 12:43:49 -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.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634629; x=1709239429; 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=9UuugcteI3wsnFXZ+gvu7oCS1Hb/WPFzjY9R5VsQ974=; b=aiM9tOI62KtGtR2JFQ3MF1GeIN7slAOqzVwX6Rob7pkxFNjB3uWjMfynuv+eUFYMGW KjXRqGB2eMBUBESL2/KKREiaOGDZ9AUR3qOFIHP4p9ZfvxpUvP8/xEdbGRFB65rHUhOJ fUG19UVzt491J1rPEuEoqLllh93B4GjsAM2RAEmzOZ23nTp0Y1gR2h+QZ5rkCY3nqoPU FVM3GKrYwFCwVU0kLIDyxZAqxkqggJBVS537DVk9+7knu44M/Da36eNJumuIgsBY6Lyq UHQ7C/+QDlVCkpzJrR6rriPpG6OAoSozrJLq2Iuu/Ze2rQFLq8BvtWFFNkI95qdOySdR 92xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634629; x=1709239429; 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=9UuugcteI3wsnFXZ+gvu7oCS1Hb/WPFzjY9R5VsQ974=; b=CcEe27B4MwqLSl9Dgiqn+qWK+uMAErPwNyGTWdgjsrLHaKZdKpL4bwPKvIvR97yN08 eOcr6tuE7wEfjxHI2yLhPT7wJX502fMhNwya7bORlV5XWlaCHJZX+Jqj9LuflI/Bx6WJ aK9trafHSRBw3sM8kg8xBu9DeYFyDzZUVrxW09GJHOFgNdzemTpSiCvYXJEeTrnjEF0n YZ2pGgcZIAtEtVyXonpBakMHdCUlyl5wjcIvPvfKb9BtLGuurSPRgCUM5zTPNzyFSi+z 0y54QlkmUk3vJZpt6Q2u+hbiaSudR7ZB109pLauK/56LDfEYfon5xXtcsd5P8u08EUaf LylA== X-Gm-Message-State: AOJu0YyfPopOlZ++YsPN+esXzF03xeFz4YCMTMzQ/k7uMHHpcOqqaLW8 yzHggiVf7RA85PQQr2r52TnZnOWjWcaz7cMWr56rOD5jcxCV2OO6Gg1BP8Lm3DWLRcO4Hn/7Ctt X X-Google-Smtp-Source: AGHT+IHTYa+a/K6CNDzmXH0Z1jnDBthB9dDd+QQD3FLFcEDaoJ6pEUulcrvICEysCwwB6cW3LcU/6g== X-Received: by 2002:a17:902:ecc7:b0:1dc:15db:bcca with SMTP id a7-20020a170902ecc700b001dc15dbbccamr10964375plh.55.1708634629026; Thu, 22 Feb 2024 12:43:49 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 15/39] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init Date: Thu, 22 Feb 2024 10:42:59 -1000 Message-Id: <20240222204323.268539-16-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635106854100007 This removes a hidden use of qemu_host_page_size, hoisting two uses of qemu_real_host_page_size to a local variable. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller --- hw/tpm/tpm_ppi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c index 7f74e26ec6..f27ed6c35e 100644 --- a/hw/tpm/tpm_ppi.c +++ b/hw/tpm/tpm_ppi.c @@ -47,8 +47,10 @@ void tpm_ppi_reset(TPMPPI *tpmppi) void tpm_ppi_init(TPMPPI *tpmppi, MemoryRegion *m, hwaddr addr, Object *obj) { - tpmppi->buf =3D qemu_memalign(qemu_real_host_page_size(), - HOST_PAGE_ALIGN(TPM_PPI_ADDR_SIZE)); + size_t host_page_size =3D qemu_real_host_page_size(); + + tpmppi->buf =3D qemu_memalign(host_page_size, + ROUND_UP(TPM_PPI_ADDR_SIZE, host_page_size= )); memory_region_init_ram_device_ptr(&tpmppi->ram, obj, "tpm-ppi", TPM_PPI_ADDR_SIZE, tpmppi->buf); vmstate_register_ram(&tpmppi->ram, DEVICE(obj)); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634669; cv=none; d=zohomail.com; s=zohoarc; b=Agrv0hRBQWEGxmPTIbfEPsXk++pjQI0OPL4wWUhBSEmPftkh3sy8Jld/GW/92dTQ+WFLj3UFxWaMns8hnwwUkOt2uXhACDAJ4zbZAJ9KLi+zhOYDkCFrhb2s+5lVIT2S6byEOgjjCwu0oNuy8fuVngnuMoHkUlP3j+DbU2Qlh0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634669; h=Content-Type: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=Utr6CY7GZcNfj8e7YUB3Ing2Y6m3UnMyzHBBd5nSQRo=; b=nNxK2L4bCj3CWXcIzZeWnSI44Iu6ePTzo5N8YbSaayxXa4OJTNe9vvKpBrKonS5xND7W2CnK/MBVLAvImhYCGoNAOprlGrxkBes7LaO+4tUjnStX5SuXi+A7HPDCPtsNuRhIcJrwSAU6812fiFYd1bzlcoEjPJ30pBcvkW59NzA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634668997560.8196027123694; Thu, 22 Feb 2024 12:44:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvB-0007LA-QK; Thu, 22 Feb 2024 15:43:57 -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 1rdFv8-0007GP-Mz for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:54 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFv6-0002gA-LC for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:54 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1dc1ff697f9so1995085ad.0 for ; Thu, 22 Feb 2024 12:43:51 -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.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634631; x=1709239431; 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=Utr6CY7GZcNfj8e7YUB3Ing2Y6m3UnMyzHBBd5nSQRo=; b=LhrWrRa5yphmSfgH8AFGg3m3J/K0a+zZpzn9L6X5jDFpxXTlHq+B629Nah2BMMFUty jhC/LsBfE+jWnCKYfozqx4Nq6BuSNeSwihGKnxFgX0JDvhSFPzZXODeg/cBVfQe84pr3 au/uSZy5Bzgdm6TKUH8KF6JclS+H5iH29Fgvf+Fk3dFfY7V+8H+fk3hbLpJaskwK1Ckc dRySbb038mqI9zPQCz27xhlDgODh5q3OiZjQ8z+2Eq46ECAKCJliTViawLsmnQxu8f/1 CV3QOMiO3V6MGXnhiVd8uEalmFhbTzzT+zhCTmohW4W/IUoN9vx6bK4qkTS/h6OyEFZr 3UYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634631; x=1709239431; 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=Utr6CY7GZcNfj8e7YUB3Ing2Y6m3UnMyzHBBd5nSQRo=; b=qD7hPwdGgFiPYlnQ7bMQ1F5Ir9LK9crJPVukYPhtVM6COosGDxQXbgdzWGbvsleCx/ EuEjRH5oPvmBoGkTE+UEUQ/mj3SkkZrDvi37K+dB3kXncU592YEohYXBVMCLBbEKfVzf iz1FSwev7QAG4h/XwAqRH+Zhit0m2A/nbVEW/o64JUw3VL3EjU/19lcYMQWes1n4uxHf tz6jcpo+28y7ORJDrUDswqAZH49NFN22O8skknjUYObe2fahVuxx5FiZizHBkns6sOd5 NxtcSTC0KQ6JFtHVr2QtssP0U41gyce9srHcZlgfbLSY3b5+ZLIYqpboFMg2a1juqFlI HQxA== X-Gm-Message-State: AOJu0Yw0OsflRsjP9ZEdMaSkPw7Bix/B0SRxpxw/YN+qk/5XAs7vzVrM 5GJop3lTg0rk3RzA3HulgQK0WXo0B/cx05no0XTKoXpgQNQDCEFKHhIC3xyDTeSh/EFKqEtNf7r s X-Google-Smtp-Source: AGHT+IGjZgQixJ+pWhtnY9g01dKeCbpIoA1KNjOhjs64feytNdPX1hjHmmQ4xu4xWt0nDAfm0dhpZQ== X-Received: by 2002:a17:903:2350:b0:1db:fc02:f96e with SMTP id c16-20020a170903235000b001dbfc02f96emr12801397plh.24.1708634630848; Thu, 22 Feb 2024 12:43:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 16/39] softmmu/physmem: Remove qemu_host_page_size Date: Thu, 22 Feb 2024 10:43:00 -1000 Message-Id: <20240222204323.268539-17-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634669455100002 Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-14-richard.henderson@linaro.org> --- system/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/physmem.c b/system/physmem.c index e3ebc19eef..3b08e064ff 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3511,7 +3511,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t st= art, size_t length) * fallocate works on hugepages and shmem * shared anonymous memory requires madvise REMOVE */ - need_madvise =3D (rb->page_size =3D=3D qemu_host_page_size); + need_madvise =3D (rb->page_size =3D=3D qemu_real_host_page_size()); need_fallocate =3D rb->fd !=3D -1; if (need_fallocate) { /* For a file, this causes the area of the file to be zero'd --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634658; cv=none; d=zohomail.com; s=zohoarc; b=SH9Qlku7OLd1eQgYJ4KDP6JAK5BLXpEAMHvBJg+Y1htO2LIxp9v3lJkJmI5iJl4YjHrCH1Kzo3qHauZRARv+CiShNnsVHu/C2u3QYfwH3dTAikLRkkKCUf2pv31/4me8IptKaKvIaMgoodbX311zeGP+3HCkT7eGuQ9w/U7nYzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634658; 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=dE6xy9+D6Je1Etl+ajN+bavVnxpk9B7ygAyJhkrFQtk=; b=C49Jfa9OKOK4p2oJVYbmGdwCVbz2sRfQ+u2J5zleWoDUGTFGf54VZgrqbAKMbAgenx8AZhR2mr+lS0lt4BMC5bJpXzeU1vNICtUXx5a/Ps2+8kihPzrX6mn4TW6GseEWMeXdAxigWkxh5S+F7q+DNVhlLkX2wSoSNInMkzjOaqw= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170863465875752.181020031342996; Thu, 22 Feb 2024 12:44:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvE-0007Ot-QW; Thu, 22 Feb 2024 15:44:00 -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 1rdFv9-0007IX-SW for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:56 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFv7-0002hZ-Ky for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:55 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d71cb97937so2312355ad.3 for ; Thu, 22 Feb 2024 12:43:53 -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.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634632; x=1709239432; 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=dE6xy9+D6Je1Etl+ajN+bavVnxpk9B7ygAyJhkrFQtk=; b=ZPcjilfwiB9pFaFEHttDEb2Zqa4XhyG/2l8moqjrSCn/w9R25x7xGFDkWu0w/kw1YI WEyxXOLWded6ejm55hxcbttaXTUOS+nYyj/LuKHA5AP7/lednII02b2YT1PECRiZv+DV nj65aUd9YtRwB7efmyKgT1eAjfmrqeqoRtwB9tdV3aU/49DehUz9oN4WbsgwNX8nv/a4 tcb+fl9XDTnoe3XZDteo0cd1hhttqaRMB3x3IlWIQNuWGqMILH2V4xuJJDcbxmPl81k8 54dWUX3dAQiZuT2Ek9R1ObdDBz72EnFoOUmnO6coEWQAQ5dCjexwLnllugQp87VN62f/ 8aSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634632; x=1709239432; 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=dE6xy9+D6Je1Etl+ajN+bavVnxpk9B7ygAyJhkrFQtk=; b=NNncZmAyFlsaDs8khgXNbEkEYq53ZB3/wVWgvnUUcTbYzRet4Zrn4qVLhjM7Jux/fM fhLkwJnfzaEPvKhhoyedxje5pfkTPOtb3elUuzGugSffxsOtxTJTcPzpiFZvRGX7TCF3 zg8KHG3xkLMqd2ztsRXHtEA8yPNNca4msc5aVgdLtcfb/Rh5YqLkwElR/mYvxz06YUFZ OcAEDp89SMpZMhXREn4RrPpVyd0iMwMZZIfviO5owA1eiv1ZlWeSlxTaO+IdTX9hshHx XmFTXUjKxH9+vemYdSXUvBY9JQF2xtBODk+rsLZMC0ORughHHIz4L4nVi3M9wh8RccOY 06nQ== X-Gm-Message-State: AOJu0Ywn+jxUxEYQ+4sM5tbzJCwe+AfFXK3lI9CklmMlfSYd+sZITyBn /hQrtidS5Qma/9eFLSdoj38Vu3sYKELx9PTho/37ROVGFzpY71jpRT82X28CV/JhGTtfflzzFAO g X-Google-Smtp-Source: AGHT+IG9+60t4gx+wBn0FPSNh0kEcv84Q0jrmCfcpRCHkWKGRJM2X453l6ukGYgTwNvpEz3GCpy3KA== X-Received: by 2002:a17:903:2442:b0:1db:fc18:2db9 with SMTP id l2-20020a170903244200b001dbfc182db9mr12395566pls.64.1708634632438; Thu, 22 Feb 2024 12:43:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PULL 17/39] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Thu, 22 Feb 2024 10:43:01 -1000 Message-Id: <20240222204323.268539-18-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 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: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634659482100003 Content-Type: text/plain; charset="utf-8" Align allocation sizes to the maximum of host and target page sizes. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-15-richard.henderson@linaro.org> --- system/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 3b08e064ff..3adda08ebf 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1680,7 +1680,8 @@ int qemu_ram_resize(RAMBlock *block, ram_addr_t newsi= ze, Error **errp) =20 assert(block); =20 - newsize =3D HOST_PAGE_ALIGN(newsize); + newsize =3D TARGET_PAGE_ALIGN(newsize); + newsize =3D REAL_HOST_PAGE_ALIGN(newsize); =20 if (block->used_length =3D=3D newsize) { /* @@ -1916,7 +1917,9 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, Mem= oryRegion *mr, return NULL; } =20 - size =3D HOST_PAGE_ALIGN(size); + size =3D TARGET_PAGE_ALIGN(size); + size =3D REAL_HOST_PAGE_ALIGN(size); + file_size =3D get_file_size(fd); if (file_size > offset && file_size < (offset + size)) { error_setg(errp, "backing store size 0x%" PRIx64 @@ -2014,13 +2017,17 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, = ram_addr_t max_size, { RAMBlock *new_block; Error *local_err =3D NULL; + int align; =20 assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC | RAM_NORESERVE)) =3D=3D 0); assert(!host ^ (ram_flags & RAM_PREALLOC)); =20 - size =3D HOST_PAGE_ALIGN(size); - max_size =3D HOST_PAGE_ALIGN(max_size); + align =3D qemu_real_host_page_size(); + align =3D MAX(align, TARGET_PAGE_SIZE); + size =3D ROUND_UP(size, align); + max_size =3D ROUND_UP(max_size, align); + new_block =3D g_malloc0(sizeof(*new_block)); new_block->mr =3D mr; new_block->resized =3D resized; --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634796; cv=none; d=zohomail.com; s=zohoarc; b=O3igLLfwsNb0KtW7Fmt8/bCU6eBWcKsCQwydWJClZEl1ZrRYMNNwxdHY9RBDOVUrDnLy8jx5L7qvdvq6VFJtNgWoon8R5tSZ+mP5aB1Wp012rOuQrabmyj/1Xy3SVqfXUzHGwQdQ1OifK3a/IKix8dS0I17gKV1LpYscVdc7RkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634796; h=Content-Type: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=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=kt8WEsqBMdgn89cK01l7bO7y77dLhrXSORQibMb1bLfcznNXYzdbRCO8Bi/xNlOa9qmjqeYjGS4e7+rIlqwz5GbmFez5YO7mZDuTDYiqulvX26m8+KD7m1g7rz3T8IWouvp6bFxnM0iKTp3Tota/Ggm22gMUuEd/59/zBOqZZaA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634796390340.14160860267316; Thu, 22 Feb 2024 12:46:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvG-0007RX-Ao; Thu, 22 Feb 2024 15:44:02 -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 1rdFvA-0007Ji-UE for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:56 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFv9-0002i0-A2 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:56 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1dbd32cff0bso2134855ad.0 for ; Thu, 22 Feb 2024 12:43:54 -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.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634634; x=1709239434; 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=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=RsyXnn73y57gyDkwUIBbtfDXsXCLbEgFRPqiHqLp6amJH+kLAIDmwi8MJjINWCFoME wXouhiMID6n8fYRH+kj1g3K1NL3wb6l98oacuiUY/q/8MPRteHv5kQNTlMNuu0H6sTFb GtPfSiTspdPDWlxXHtp7McSJvGQQK+hJ+yR/OCmIOIRNJi+4fUGzAOLMoVyNHTascPZR EgKDdgXYBU1suo1HRRPEuUh2HCnGyYzbgS8V8jCWFnjmofnhxAmLOdvsMQmWgA51qmIO PpEoAH7LMG8cDXGeMc1CbZ4UPJsuHAYw4VP6HP6hayayhybTDipNufgR2Zl+wIrjeqXH /xlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634634; x=1709239434; 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=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=TT0DvIduE7/opdyHNJQvtK6Aqjp3VOTXbnJM9rZ8FZcuepVxEC05wGvwasrjf7enjJ fCrqr0P/ofnr/8jOBEjDBTeIkexHnWpp8ftnyj+ouV+zrwmxVsdhTSFeKvDeasDyUeKw aSeF8Nt4KD7g14AXv32QfB4bXafb5QZVdcDBrbHbMTqDxxyL9RwSQLawPMzWEh8XqLfP QqfXwP6f+znxmixs7q8EWeWyTUFpcgVO0hFBoyxxTDUoKGNre36WWP0GZPbFtcBPewOj 91gNcUWQoBhiT76/cKvYg9HUOH+khqDZGzx03pTavveLGkOH8Qdl602KbAzGA0yLLjaW 3qNg== X-Gm-Message-State: AOJu0YwjMxuokF7tlpMdosFfi0SNwNzcrw0+zP3bO0wbh4VmgCZXO7Q9 leZFyupzyJmp3dGGYjzVGBXq3raZygnBRBI+JoajwzXPlSxN7hgAOjwTKFCvchMn19NmrncQ26X L X-Google-Smtp-Source: AGHT+IF1Hzlxd2DbvHsKIwLQSpwa+5XE8Z79DClSdlRPbx+SPNUadnHfWBWfTGFtWORSGe1uLxHsjg== X-Received: by 2002:a17:902:ecc1:b0:1dc:43d:964 with SMTP id a1-20020a170902ecc100b001dc043d0964mr12783669plh.48.1708634633879; Thu, 22 Feb 2024 12:43:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 18/39] linux-user: Remove qemu_host_page_size from main Date: Thu, 22 Feb 2024 10:43:02 -1000 Message-Id: <20240222204323.268539-19-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634797932100001 Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-16-richard.henderson@linaro.org> --- linux-user/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 74b2fbb393..e540acb84a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -781,7 +781,7 @@ int main(int argc, char **argv, char **envp) } cpu_type =3D parse_cpu_option(cpu_model); =20 - /* init tcg before creating CPUs and to get qemu_host_page_size */ + /* init tcg before creating CPUs */ { AccelState *accel =3D current_accel(); AccelClass *ac =3D ACCEL_GET_CLASS(accel); @@ -804,8 +804,10 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va =3D MAX_RESERVED_VA(cpu); if (reserved_va !=3D 0) { - if ((reserved_va + 1) % qemu_host_page_size) { - char *s =3D size_to_str(qemu_host_page_size); + int host_page_size =3D qemu_real_host_page_size(); + + 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); @@ -902,7 +904,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 =3D=3D 0) { - mmap_min_addr =3D qemu_host_page_size; + mmap_min_addr =3D qemu_real_host_page_size(); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx (fallback)\n", mmap_min_addr); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634813; cv=none; d=zohomail.com; s=zohoarc; b=oId+UOgVYPsy6MDgYgbA7Na/z/jE5fvenXFkL8A3w43gP42i+FNirEKDdF4cvYlbBIRTwAzKs3ObO+Xq5P+zIvFOOH0Bus/y3FQrahtU/V1cPOJGd0VJvXrLoPPIK7uSv/NaCVtXiMNt23bq7dRuIAvzl67zD3b4spbV2l+RsDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634813; h=Content-Type: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=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=LmfsYjTg4ahx5sNsMUkDbStlq+/c7sDRomcYCdg0XyC4httZCRfry4JBueyDsRY2FTx3+uB5sDLOhhVUmE45rgV5h8MNT8jZwmGmIBfpvbYwWDJuH9itpYeo3KpTVzw9KE2S2FF11eqX3DK2Yk24Oz0k0G9A0atGJgc1xhoTjtA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634813876349.4800558682754; Thu, 22 Feb 2024 12:46:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvG-0007Rk-Ca; Thu, 22 Feb 2024 15:44:02 -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 1rdFvD-0007Ou-CN for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:00 -0500 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvB-0002iQ-CB for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:43:58 -0500 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6e332bc65b3so48520b3a.3 for ; Thu, 22 Feb 2024 12:43:57 -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.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634636; x=1709239436; 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=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=SN093ug67QNHP8bcCFYrCPXZ/l/yRHqIknj2FKResxWvxRc8rTJEYQvllgknLy98ls K2N1cTdkJ+q5Syrmm97djyTXjFqhqWatyMomkGskVkwJ4LNt8c2iBNrJBdzMPv0+4RL2 yqZOeFodS9NmWW9BtoWq0Zc7MOwGp+q0Ecnj5Qn8N5DGwmJ8REEQuuCU2EQjm7/zW8p3 QCxsTqpLgVjSCRQRUr3LkMOOSFi8vcAV9PB9bL3hv3VtHAcesvbHmPiRJpFCV2qHxZF9 +qA6HeZq73sHD6t/Pu6UIPdLzARSH+v4gbCN6p7Abf8rSI6mJFDK6nQWPgpmRw1ukVyy n61g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634636; x=1709239436; 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=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=n0PhXjINRx5PdmO74ZhI2GJmC9rUNG47pMNTpcaw45emenW4NZNvc9aZZRc2pvcb1M RTAm9iqRUMOpgnP8bEMI7FxOK/vyCWL0kCzqq5VnXksu0J7zg97fGV+maR1ZuZOX0FoN Rv2Z8az22ng6bEaLkFJvYI/IYBbgJzXQOH3uIcaiom7ZLIBftNAxBpJprrJVnEpQBqi3 KdafwGEAMdC0Q9ExS9jLGOamoRRPbB70uirSpp8y2Kbuv1foQ63OucjYsgky8wI86uJa ngCxT+Hr0BTTYFhI5mbFXO4WSDK8Excgi0chHYKBDOfJsjeui78qufyjsKr3/s58w69c erOw== X-Gm-Message-State: AOJu0YzZSp7HPIfxpiTb7tCn8ytl63IRdHvfcJJkw5WHGyg/V23pve7O 2eHbIEL4rFk28c7xZjFN7i5+Hr2wFjONO5TTRJ5/DcQotpXr/7B9OnPiHEwUud989v3+eAFnVha C X-Google-Smtp-Source: AGHT+IFFXHN1dGBUeQt3S7WWYjUKwWy6BH4V5AYK2bSxYlWgxgRd7kty/HWVVi5v1ObsVgI1C63q5Q== X-Received: by 2002:a05:6a20:c886:b0:1a0:73b9:85e2 with SMTP id hb6-20020a056a20c88600b001a073b985e2mr24059324pzb.10.1708634635881; Thu, 22 Feb 2024 12:43:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 19/39] linux-user: Split out target_mmap__locked Date: Thu, 22 Feb 2024 10:43:03 -1000 Message-Id: <20240222204323.268539-20-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634816018100006 All "goto fail" may be transformed to "return -1". Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-17-richard.henderson@linaro.org> --- linux-user/mmap.c | 62 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d11f758d07..b4c3cc65aa 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -490,9 +490,9 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) } } =20 -/* NOTE: all the constants are the HOST ones */ -abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, - int flags, int fd, off_t offset) +static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, + int target_prot, int flags, + int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; @@ -500,30 +500,27 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, int page_flags; off_t host_offset; =20 - mmap_lock(); - trace_target_mmap(start, len, target_prot, flags, fd, offset); - if (!len) { errno =3D EINVAL; - goto fail; + return -1; } =20 page_flags =3D validate_prot_to_pageflags(target_prot); if (!page_flags) { errno =3D EINVAL; - goto fail; + return -1; } =20 /* Also check for overflows... */ len =3D TARGET_PAGE_ALIGN(len); if (!len) { errno =3D ENOMEM; - goto fail; + return -1; } =20 if (offset & ~TARGET_PAGE_MASK) { errno =3D EINVAL; - goto fail; + return -1; } =20 /* @@ -553,7 +550,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; - goto fail; + return -1; } } =20 @@ -574,7 +571,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, struct stat sb; =20 if (fstat(fd, &sb) =3D=3D -1) { - goto fail; + return -1; } =20 /* Are we trying to create a map beyond EOF?. */ @@ -601,7 +598,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, p =3D mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p =3D=3D MAP_FAILED) { - goto fail; + return -1; } /* update start so that it points to the file position at 'offset'= */ host_start =3D (uintptr_t)p; @@ -610,7 +607,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, flags | MAP_FIXED, fd, host_offset); if (p =3D=3D MAP_FAILED) { munmap(g2h_untagged(start), host_len); - goto fail; + return -1; } host_start +=3D offset - host_offset; } @@ -621,7 +618,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, } else { if (start & ~TARGET_PAGE_MASK) { errno =3D EINVAL; - goto fail; + return -1; } last =3D start + len - 1; real_last =3D ROUND_UP(last, host_page_size) - 1; @@ -633,14 +630,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, */ if (last < start || !guest_range_valid_untagged(start, len)) { errno =3D ENOMEM; - goto fail; + return -1; } =20 if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { errno =3D EEXIST; - goto fail; + return -1; } =20 /* @@ -671,17 +668,17 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, if ((flags & MAP_TYPE) =3D=3D MAP_SHARED && (target_prot & PROT_WRITE)) { errno =3D EINVAL; - goto fail; + return -1; } retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, (flags & (MAP_FIXED | MAP_FIXED_NOREPLAC= E)) | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr =3D=3D -1) { - goto fail; + return -1; } if (pread(fd, g2h_untagged(start), len, offset) =3D=3D -1) { - goto fail; + return -1; } if (!(target_prot & PROT_WRITE)) { ret =3D target_mprotect(start, len, target_prot); @@ -696,14 +693,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { - goto fail; + return -1; } goto the_end1; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, target_prot, flags, fd, offset)) { - goto fail; + return -1; } real_start +=3D host_page_size; } @@ -713,7 +710,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { - goto fail; + return -1; } real_last -=3D host_page_size; } @@ -739,7 +736,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, munmap(p, len1); errno =3D EEXIST; } - goto fail; + return -1; } passthrough_start =3D real_start; passthrough_last =3D real_last; @@ -773,11 +770,22 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, qemu_log_unlock(f); } } - mmap_unlock(); return start; -fail: +} + +/* NOTE: all the constants are the HOST ones */ +abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, + int flags, int fd, off_t offset) +{ + abi_long ret; + + trace_target_mmap(start, len, target_prot, flags, fd, offset); + mmap_lock(); + + ret =3D target_mmap__locked(start, len, target_prot, flags, fd, offset= ); + mmap_unlock(); - return -1; + return ret; } =20 static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635014; cv=none; d=zohomail.com; s=zohoarc; b=Ad7wktUP2TAybmAOqYSt+8PznBT4vVd3RTZPnsTT0AcX/kwZWQYgfgeGib+Uw4x4welDcOiXKLwyZJ4E+v3q3O7LOEz+QRxdNVW2U5qaVCl1dA6aLblQ0Q9whOToFx7d2LkPNUQ3Uzi6hWh69JdUoKijEgeCQmDx8MeQL2BVGVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635014; h=Content-Type: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=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=kH8qBosm8A5Jq3Gjdskut4FiWNXVDVfR3U5GR6PrEKFtdwxUJuC/1QCHERSfuFS61SXHySNnV5o4YJ2jAqMd6SVKr25bhYe6JYi3MAAARCaLbxGmlvdSJNCBiP+o1+GbEh8wIBmHtK2KCD5xlnBKk0p67am3x0hpji/f6gzqvq8= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635014137274.2864184418071; Thu, 22 Feb 2024 12:50:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvI-0007XR-00; Thu, 22 Feb 2024 15:44:04 -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 1rdFvE-0007PE-KU for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:00 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvC-0002ie-Hs for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:00 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1dbf1fe91fcso492055ad.3 for ; Thu, 22 Feb 2024 12:43:58 -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.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634637; x=1709239437; 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=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=XwPez6m+ao/Dw3QS8JcMSGkKzWjx80/oQytGgHK2J8BKZCgdKCbfxy0wRwfhaW/7rb npoKdNIVCu99riSQPSfVw7TpU5sYyPVp21CnhwLSv5ey+7h6m07sCqWM3o2nm3/UP+l7 cTcXDTar9xuTD7fFUHIo3lup8nYAxiQxxsLugOJFYfikkkHMmMRc3wkvEZBSou6q/ONu UWeOtIT8VpbD3Fn04nfAjPwv7qgNks1rY4BHEyPr/DlgNVl7+1ltgGYHNvIg/aTtUHfn qZuqjlFtGFKXb+xm+p7JhAqFbs+vdl07ml+vRPOI56++OSf9RoCR/AHkb/J6OeDzpJLL 6e3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634637; x=1709239437; 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=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=Nq7b5AqhHGge51l/gUT319TDu4rlUOJELp8pcNM3uaGF/jSqepywHAFx5P1GpPx4Te mpH7aTeEPPVq1SyE3PcF1XbuUmG+fCJIa8tBg3k1q4G0/Dqyo8BazwTUWl67hs2cep9V YCTj+Qmiemp71r58/p3dazCBL41X5JYnxHGNJyDUk3KMDJfFnHChHh+McXgA1PvA0itR r6LsY4EfsFGvdOupQymvdS5i/VS1tUFoW0OkF1wCMzE9mW9/Q746LCvrO099etMYfzmw 8ygfZdPwIZoAeEW2iJB8JV3Aljtp7MWBUV3DNpNeX1mOLZxX1sQEC7ki9STiOwZQk/3B Vq1Q== X-Gm-Message-State: AOJu0Yz5ig/oNgwy5gV6u8Qxmr1Y3Tjp4B9ZKzg4WDqI0ed/1BuYgEc6 Atknpl4vBmQuQbSwvtPVa6R8noy/dEFQP9oKPMetZs2r/buJd3iYFRIWF4BF/5ABuT//KqpKZZ6 0 X-Google-Smtp-Source: AGHT+IFf3ay4fTeQQSa0LltVzFNHuf0JrjYlLsxRzEJl9iCH8bCvqOz/5ikRRAUH88sejUUxG1MHig== X-Received: by 2002:a17:903:286:b0:1db:c743:4687 with SMTP id j6-20020a170903028600b001dbc7434687mr19867029plr.1.1708634637332; Thu, 22 Feb 2024 12:43:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 20/39] linux-user: Move some mmap checks outside the lock Date: Thu, 22 Feb 2024 10:43:04 -1000 Message-Id: <20240222204323.268539-21-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635014666100001 Basic validation of operands does not require the lock. Hoist them from target_mmap__locked back into target_mmap. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-18-richard.henderson@linaro.org> --- linux-user/mmap.c | 107 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index b4c3cc65aa..fbaea832c5 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -491,52 +491,14 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong si= ze, abi_ulong align) } =20 static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, - int target_prot, int flags, + int target_prot, int flags, int page_f= lags, int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; - int page_flags; off_t host_offset; =20 - if (!len) { - errno =3D EINVAL; - return -1; - } - - page_flags =3D validate_prot_to_pageflags(target_prot); - if (!page_flags) { - errno =3D EINVAL; - return -1; - } - - /* Also check for overflows... */ - len =3D TARGET_PAGE_ALIGN(len); - if (!len) { - errno =3D ENOMEM; - return -1; - } - - if (offset & ~TARGET_PAGE_MASK) { - errno =3D EINVAL; - return -1; - } - - /* - * If we're mapping shared memory, ensure we generate code for parallel - * execution and flush old translations. This will work up to the lev= el - * supported by the host -- anything that requires EXCP_ATOMIC will not - * be atomic with respect to an external process. - */ - if (flags & MAP_SHARED) { - CPUState *cpu =3D thread_cpu; - if (!(cpu->tcg_cflags & CF_PARALLEL)) { - cpu->tcg_cflags |=3D CF_PARALLEL; - tb_flush(cpu); - } - } - real_start =3D start & -host_page_size; host_offset =3D offset & -host_page_size; =20 @@ -616,23 +578,9 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, passthrough_start =3D start; passthrough_last =3D last; } else { - if (start & ~TARGET_PAGE_MASK) { - errno =3D EINVAL; - return -1; - } last =3D start + len - 1; real_last =3D ROUND_UP(last, host_page_size) - 1; =20 - /* - * Test if requested memory area fits target address space - * It can fail only on 64-bit host with 32-bit target. - * On any other target/host host mmap() handles this error correct= ly. - */ - if (last < start || !guest_range_valid_untagged(start, len)) { - errno =3D ENOMEM; - return -1; - } - if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { @@ -778,13 +726,64 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, int flags, int fd, off_t offset) { abi_long ret; + int page_flags; =20 trace_target_mmap(start, len, target_prot, flags, fd, offset); + + if (!len) { + errno =3D EINVAL; + return -1; + } + + page_flags =3D validate_prot_to_pageflags(target_prot); + if (!page_flags) { + errno =3D EINVAL; + return -1; + } + + /* Also check for overflows... */ + len =3D TARGET_PAGE_ALIGN(len); + if (!len || len !=3D (size_t)len) { + errno =3D ENOMEM; + return -1; + } + + if (offset & ~TARGET_PAGE_MASK) { + errno =3D EINVAL; + return -1; + } + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (start & ~TARGET_PAGE_MASK) { + errno =3D EINVAL; + return -1; + } + if (!guest_range_valid_untagged(start, len)) { + errno =3D ENOMEM; + return -1; + } + } + mmap_lock(); =20 - ret =3D target_mmap__locked(start, len, target_prot, flags, fd, offset= ); + ret =3D target_mmap__locked(start, len, target_prot, flags, + page_flags, fd, offset); =20 mmap_unlock(); + + /* + * If we're mapping shared memory, ensure we generate code for parallel + * execution and flush old translations. This will work up to the lev= el + * supported by the host -- anything that requires EXCP_ATOMIC will not + * be atomic with respect to an external process. + */ + if (ret !=3D -1 && (flags & MAP_TYPE) !=3D MAP_PRIVATE) { + CPUState *cpu =3D thread_cpu; + if (!(cpu->tcg_cflags & CF_PARALLEL)) { + cpu->tcg_cflags |=3D CF_PARALLEL; + tb_flush(cpu); + } + } + return ret; } =20 --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635064; cv=none; d=zohomail.com; s=zohoarc; b=lXQZ0QpIIlsEone/SjoTKWWiE9miDAW0/1/H3CllCBT8sy29f6mbJ696BZwcD5HUhazZeGDWSofywnJAOzsawv40FDKPYB51YFHbUiCuf7YeNyCVLQ1z6vSwqBBEbagn8T6nJujd+KG+NG+nORaI4+At1P3yJgUO7zfbLJ2bH3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635064; 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=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=GbvlqYW/aQtizGMZ9XO6sNDikf/zzi2KcdKuBBEyEbG04TFNeYOZhWR29WO/QdeMNdgl/XrKDh6UDJ4XsjsHDX06ZMmXilKKwArqytKSmaYAv67zvXv137tWXaXFTbhI0yNR8Rw9c489npYn7+nXH9Motn/m6X5zhdZEr9tpldk= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635064497334.022873682095; Thu, 22 Feb 2024 12:51:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvK-0007Zd-5p; Thu, 22 Feb 2024 15:44:06 -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 1rdFvF-0007R6-Tp for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:02 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvE-0002ik-A4 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:01 -0500 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6e4751b97eeso60704b3a.1 for ; Thu, 22 Feb 2024 12:43:59 -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.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634639; x=1709239439; 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=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=O4OP+juH4k/OmXO5yZxWjdIeFFQcilPrteiC49Pb2FvpG/Cay7gvm5zP3cfHrVMnnJ vDSkdvlNNi9To+FFHERq9yWRQ4g3H4QJICru6JioprVyHFkVnbF6fMBM1Nggjs6C/Zjj qD2FDF6JZrO/gNTQDKYBBC89X/5VrE9DB54LuUhhalyeVB1UXTDvVg5GkO18/uDx+ncM oZfN3urRb74CyRN0+PJ1KLdGgimkiDhAiN8T7n6Y3aMLXB0oSK7CtZlwIQsoz3Xy/m52 2BQRBEe4PKxuAPA7REwuKI4W8YHh6xLrTRivqE9Hw2/gSnRei4qp+jcn83oDRXJeEgw+ n4iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634639; x=1709239439; 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=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=h9nIT442NE/BFTOpAGhtV2JjHSrAUEhli6k0lfJ8RS5I84YoSuSv+YhliKowfkzXvv L7QaYugGJOmacXKLcq0jkwyC/RLGGYraVqGh3uv+46XUzzImoCPwOFlsa2kmC/whGrTa JpIa/C3YXlsT4yWBkLEUS+SNNlJ/VflZ0heyzMJzCzNE4+puXRw7k2sTsv2rj9poHk/e rtN88yi/9vEDW4NScgfP034lLhEavHkmv7HHo4s/8n9bSYlfh8hjnmh1ITe8OHiSTj/Z LLViZKYfyHIF6i92v9XyvwsM936KEVc+/keczUTtnLIJZEl3R0rPErW8WbLn3ObpGTRc kNrg== X-Gm-Message-State: AOJu0YwpchpdSSfZY5tnQWHhD24ijSpZY5L15SrqfaHPYQV1H8PAOTWO BznbfnHf6nfUcqIolFYMhr8vxKNgzIRf978QCmuuKHXsqF/G6laOTJBTAlIEJPebnzAZQG8MbPH 9 X-Google-Smtp-Source: AGHT+IEzgNeSB9iEL73eJ6vutCstagS3fngCXf18kC2Ur9HNZ2WlFC9k2DkXFaWM7wkL/g7XuTHITQ== X-Received: by 2002:a05:6a20:9d94:b0:1a0:cd54:6d9f with SMTP id mu20-20020a056a209d9400b001a0cd546d9fmr4859887pzb.23.1708634638728; Thu, 22 Feb 2024 12:43:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 21/39] linux-user: Fix sub-host-page mmap Date: Thu, 22 Feb 2024 10:43:05 -1000 Message-Id: <20240222204323.268539-22-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 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: pass client-ip=2607:f8b0:4864:20::433; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x433.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635064774100001 Content-Type: text/plain; charset="utf-8" We cannot skip over the_end1 to the_end, because we fail to record the validity of the guest page with the interval tree. Remove "the_end" and rename "the_end1" to "the_end". Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-19-richard.henderson@linaro.org> --- linux-user/mmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index fbaea832c5..48fcdd4a32 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -643,7 +643,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end1; + goto the_end; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -690,7 +690,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, passthrough_last =3D real_last; } } - the_end1: + the_end: if (flags & MAP_ANONYMOUS) { page_flags |=3D PAGE_ANON; } @@ -708,7 +708,6 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, } } shm_region_rm_complete(start, last); - the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { FILE *f =3D qemu_log_trylock(); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634668; cv=none; d=zohomail.com; s=zohoarc; b=Gan2oyenptVpCQFTlB+LDrWkEH61Eq8ebvFRQ2Xsm+lorgss+eBI5/iBcWEZLiIgNFiGsMQca8bBLD5Ct63BJUYfX0xsGe+MLTOss+zXujlyoj6oLjILudM8XgK1mEN8M8spG/Sv6hcnKAolLqy6H5Sk7lKJqMNxTc4uRY1pWZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634668; h=Content-Type: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=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=jZDpy5ltbLmq8IUuUTzwr7eXl7B14RriLXvzpLNI2OKy5UZRjKi9558YpvcKQCh+XOZTuip9t8KLnT9hzOgxIaivw1d60fWzWiMQMQeP/Iey5dVqwb+SluWRBrTIklZcZ8K8AYhFVG+fEqBzQ6uKE5+1WhzF1+5gAcC6RgxrDX0= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634668297721.9076892649911; Thu, 22 Feb 2024 12:44:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvL-0007dJ-US; Thu, 22 Feb 2024 15:44:07 -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 1rdFvJ-0007ZV-W6 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:06 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvF-0002j6-C1 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:05 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1dc1ff697f9so1996555ad.0 for ; Thu, 22 Feb 2024 12:44:01 -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.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634640; x=1709239440; 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=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=HtCZcS4rnN0CRbolkLyb4UyZcW2xUNSay+3Pi0LecdOx09YpEOA0cFus3hGwRT3R9L 9R0d35j8/IPbr/vjQNrFNhznoTccB/5pM7l7C8lQkNDm0f0ghs8X+8KB/NCCZVlB3kac UHeHTfq58UFpzXXkFxJpmngPU5rvaaS3BAnUpmB+Zp7S70rdWP2BHCVBYguooSMmwv1z BOUZVerM+xt+EXD14EtW+4owSLgW/QStRJfqeW7DZTLh5HQa5HFRzXcPgLuvK8tRP2G+ ropee1sRsybOxO8t/r47aaUJqfvFVKBIo9UR2UuVNALeRhCB5SMB/lVc2XRabYLHXMve p1Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634640; x=1709239440; 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=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=xNUrLYXkcD/EAIXvVQg2LqFYniOs7PkIGlOgH8PHoknKC/9/HPw5f4AcRExbivePen MqgkZ3PndXhnyeV9SlMRR9bSRgshKMP3xDokYlfqlJyC61QNcCe5dvZWLw8oCrifmR6k JrT0fcUMuzCnCZuBaTRgLFqMEwN0eEpUt1+ObPdHSaMnAAdAirOZ0lcJlqwBVK4X8ifs x+vTFTqZ6SSIK2L4C4e+xOvo6+N7iwpKGRcfZwBWOeU68Xjfd3ZgffeWxcXd5cadL+nz paSpBPHCI3fDJ54Kkf84KVkjjPTt+QusYSCWNpo/pAOu1ywY4RxWrbrcDFZR7Ay0uCys 9Z1A== X-Gm-Message-State: AOJu0YwWsiVR142DWP0OSJ9/6fG3Wd+pBFFt4YBifDOvnETXS+AzUUv3 3iIeSSizLrA/1+Y3M6V7wXwPkaH3/ZVewbLmHAgc9D58E/RDRjfFqCAZVKZ16NUD6B9FWg4tGdv k X-Google-Smtp-Source: AGHT+IEQGIDVz2f2V1KJKPufMFaDh4njKgljOg58FS8lNAbMbimtmlEMz5vedB+yCXP1hfP5+X6qLg== X-Received: by 2002:a17:903:1c4:b0:1dc:685d:f0e2 with SMTP id e4-20020a17090301c400b001dc685df0e2mr379596plh.12.1708634640167; Thu, 22 Feb 2024 12:44:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 22/39] linux-user: Split out mmap_end Date: Thu, 22 Feb 2024 10:43:06 -1000 Message-Id: <20240222204323.268539-23-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 @linaro.org) X-ZM-MESSAGEID: 1708634669475100003 Use a subroutine instead of a goto within target_mmap__locked. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-20-richard.henderson@linaro.org> --- linux-user/mmap.c | 71 +++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 48fcdd4a32..cc983bedbd 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -490,6 +490,43 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong siz= e, abi_ulong align) } } =20 +/* + * Record a successful mmap within the user-exec interval tree. + */ +static abi_long mmap_end(abi_ulong start, abi_ulong last, + abi_ulong passthrough_start, + abi_ulong passthrough_last, + int flags, int page_flags) +{ + if (flags & MAP_ANONYMOUS) { + page_flags |=3D PAGE_ANON; + } + page_flags |=3D PAGE_RESET; + if (passthrough_start > passthrough_last) { + page_set_flags(start, last, page_flags); + } else { + if (start < passthrough_start) { + page_set_flags(start, passthrough_start - 1, page_flags); + } + page_set_flags(passthrough_start, passthrough_last, + page_flags | PAGE_PASSTHROUGH); + if (passthrough_last < last) { + page_set_flags(passthrough_last + 1, last, page_flags); + } + } + shm_region_rm_complete(start, last); + trace_target_mmap_complete(start); + if (qemu_loglevel_mask(CPU_LOG_PAGE)) { + FILE *f =3D qemu_log_trylock(); + if (f) { + fprintf(f, "page layout changed following mmap\n"); + page_dump(f); + qemu_log_unlock(f); + } + } + return start; +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) @@ -632,7 +669,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, ret =3D target_mprotect(start, len, target_prot); assert(ret =3D=3D 0); } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } =20 /* handle the start of the mapping */ @@ -643,7 +680,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -690,34 +727,8 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, passthrough_last =3D real_last; } } - the_end: - if (flags & MAP_ANONYMOUS) { - page_flags |=3D PAGE_ANON; - } - page_flags |=3D PAGE_RESET; - if (passthrough_start > passthrough_last) { - page_set_flags(start, last, page_flags); - } else { - if (start < passthrough_start) { - page_set_flags(start, passthrough_start - 1, page_flags); - } - page_set_flags(passthrough_start, passthrough_last, - page_flags | PAGE_PASSTHROUGH); - if (passthrough_last < last) { - page_set_flags(passthrough_last + 1, last, page_flags); - } - } - shm_region_rm_complete(start, last); - trace_target_mmap_complete(start); - if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - FILE *f =3D qemu_log_trylock(); - if (f) { - fprintf(f, "page layout changed following mmap\n"); - page_dump(f); - qemu_log_unlock(f); - } - } - return start; + return mmap_end(start, last, passthrough_start, passthrough_last, + flags, page_flags); } =20 /* NOTE: all the constants are the HOST ones */ --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635077; cv=none; d=zohomail.com; s=zohoarc; b=Py+4ClwYNeEbZt0bdoaxcPfbTdDmqycB9oVRbWpdbjSTQfvOm/lNRztUu7QydwrJ6mceqyg7MQwx+lCWQmPxvMFi9AssBr1nHjI2rDSXsfQ1ZslTGlMTslTd+BSyMeMc/LMWrsJ2mcjhSXfe8Ls17u5klJ9rhqerSOTVxJYg8Gc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635077; 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=T4LpMcpbkwjao8TY6tge6qZD13wWePdA/KJRu5rSi1Rh9nSFgv3/pocmXb72Q649ZWp0qdyAfrPOFK0bdcqkSqYAxLY4/j/peNHs4CbFMlt1SlFQIJfB2nTkAp1OaShVrVtMC0Q2WU9uMkny/DIR6zaYIbkUklzApPIi0pmKowY= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170863507755741.12561375739813; Thu, 22 Feb 2024 12:51:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvK-0007Zz-AD; Thu, 22 Feb 2024 15:44:06 -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 1rdFvI-0007Xq-KY for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:04 -0500 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvG-0002jP-WC for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:04 -0500 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5dcc4076c13so194343a12.0 for ; Thu, 22 Feb 2024 12:44:02 -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.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634641; x=1709239441; 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=ToZF6eZmeo0VzJRBOSANiVU9rNopyEErWWxC6hpA+ZwsTpzaKEVHPSEpdwzx2ZS6ks qEo1SbEgDgpj4W0CSM9V3+WxMGB3q+Yem49PmKnNLU81Z1RAxL31zsSFtzGZUINMbYLS JqDQj59zEtWXbnIrEykS8VWziCspwa11vLG87dN5ZH8jI7jV4odlcElx31VmA4TH/Fpj dZlFVxwcYd/moaVQWPX3f4+mB3g7FJYUt6iEo2ZteNJsLnDFN4jCrvx/1ScHV2q6xLjY o2vglr7jJUqCmLAWJGb/SOK2K82tBhPl3GPCrIwRoQiRoxpUUY+FkYRuDn/L9+HHA0ji y7Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634641; x=1709239441; 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=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=ea0FfmPtGGKjiOHvv8xhbyPN94kaa/3Nyz+ED9deSQpwGG7fJ4eINw/Miq41hxl7u4 Btj8GV1z6fC6GVEBEFmSUI2a/6Wc5jyWrvNxU0AmNZw1WQSl03AqH3SyHu67TMhxoGLu 40l38AO3awEZqiUSNStOqCA+REzfF2f+AQxIHCPX4IQZrxpMTry8E2lzpejj0CcO5694 NLV1AgS4Lea0z/uVM+bav6E+0IMU7LcdhJcl7Ovq9zD+E41RkpwV+NUog3phssDZ2hxf WKqCeLNfm4YEtSnVmNNPenpJaiHVGTNKwYzZFFtOvoHwZ+ADe6f5zKUVmpBsWXewqoWO Bicw== X-Gm-Message-State: AOJu0YyZiARAj4dFrQaIkc3OSERp1IVRhnSVZm3OqMrEBinmpDJ+NRJT dXl2qV0uz9ZTesfssrWIQWcq1/T3LOjxaltyrCxOHtMhJiVtXQfl6GDlKaXFXkk4TmDqZJfZt/a k X-Google-Smtp-Source: AGHT+IFnVLLQSzQNJh53u4pqPvXtdjSGv0LEG5cfEwN9Tnmtoo9Mf6CgVpDh9rzgZ1hwXkUOcJIo/Q== X-Received: by 2002:a17:902:f545:b0:1d9:e1aa:f217 with SMTP id h5-20020a170902f54500b001d9e1aaf217mr146740plf.22.1708634641623; Thu, 22 Feb 2024 12:44:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 23/39] linux-user: Do early mmap placement only for reserved_va Date: Thu, 22 Feb 2024 10:43:07 -1000 Message-Id: <20240222204323.268539-24-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 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: pass client-ip=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635078791100001 Content-Type: text/plain; charset="utf-8" For reserved_va, place all non-fixed maps then proceed as for MAP_FIXED. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-21-richard.henderson@linaro.org> --- linux-user/mmap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index cc983bedbd..1bbfeb25b1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -540,17 +540,19 @@ static abi_long target_mmap__locked(abi_ulong start, = abi_ulong len, host_offset =3D offset & -host_page_size; =20 /* - * If the user is asking for the kernel to find a location, do that - * before we truncate the length for mapping files below. + * For reserved_va, we are in full control of the allocation. + * Find a suitable hole and convert to MAP_FIXED. */ - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len =3D len + offset - host_offset; - host_len =3D ROUND_UP(host_len, host_page_size); - start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); + start =3D mmap_find_vma(real_start, host_len, + MAX(host_page_size, TARGET_PAGE_SIZE)); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; return -1; } + start +=3D offset - host_offset; + flags |=3D MAP_FIXED; } =20 /* --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635017; cv=none; d=zohomail.com; s=zohoarc; b=OO40sY3QBrtWAlmiFMbfnPXGHszU0l0xvIDb2BLPbPagbB7xlbYkdH45sndBUSKD5YNsVrJxfTGi4Z2DWXBCf24fl5MmcFhtuGyUoDjIzieQKzZXOf7mx06+9IhqzFEE4Nm6SpcHr6dexXhrErkjg8YTBEgzP5dNgPdtou7/h+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635017; h=Content-Type: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=5K1zjw+5Oj4rrjx8HADPxYdAwsCVv3T9uofL+YVvOaU=; b=DaxJ2YfKDLMuM7/ZnCUldd/VtVLbKeX0lLuay2XoJMW8cpbo9H5K/AJmRRHahv4wy8paYmfMleq+8tsh9jXAlHz/o/qHfaNwL7St/3eyJ1I1u+fbThglGgggD3Dri2c0Tbk9zciiHELBFOket/rdQejeaLrHRp6bA/kxP4xh5VQ= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635017448143.74633493260512; Thu, 22 Feb 2024 12:50:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvN-0007ep-Rq; Thu, 22 Feb 2024 15:44:09 -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 1rdFvM-0007dQ-2W for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:08 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvK-0002jz-Dc for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:07 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e46dcd8feaso33295b3a.2 for ; Thu, 22 Feb 2024 12:44:05 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634643; x=1709239443; 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=5K1zjw+5Oj4rrjx8HADPxYdAwsCVv3T9uofL+YVvOaU=; b=ltjVkg6ZCBwum9isc65AA08IAdjByq17DfWWHgS+EoYnEo/zPiA+cGN95RBzLRugjC nxkdixDaVsDY2mNl9/tPoEU/U+T8TS0I+rVdRyqqvcaKzr2aGEkf41qgMUHB6yZCtUKt GojdiES3m9byY9BTrBPD1I7yhC6mCdvfcpFpB6nqgtGzxn2tDfueKMFrd4o38v8EWuFL cEcaQuWx7mjynmemFDRQuM3it6LAL7KRe6bsVgAJ7RwO9OgoIv4nyNXrY83FSmox88x+ baZXUu96SZDZhlB3PN3tuTTnru+U0CW+lr/pCaQdqUweBSxpg6D1j+KR0/9kSwxM48bk HLzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634643; x=1709239443; 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=5K1zjw+5Oj4rrjx8HADPxYdAwsCVv3T9uofL+YVvOaU=; b=GNlwLoPOHPA+cSup2DMl2UpOd2ZS51LY5Sq+5CKM6cDT8VkZCQ30MBJ9n0bQY04uzQ 2Scp3rXnbXcwul9fpOMYy4S3HHtJZ3T+FR3PtbgZKTX7Xs1i1Opc2MeNE0mPQHbIVrkG qZnb7Mdcewhr6X86VyVpPDHt+qQLT1tWNIDvkknLMi5QIA0ki0RcYnfwrSJPJ3TolZyN 5mZC8m6cG97IDXYWRuTlM5ZeyI1GcKWK4acFqE1mTDcSanklwmHuggzY6im7QGWYETkG QYRP4cOMRptF5bSEZ2G7aCBkLyvrZpyHXmp/ktn9xBgaxDE9rTlLAMg0LLvTz99SDKfn 5rnQ== X-Gm-Message-State: AOJu0YxRI8Coa3defe6N8W9J23VYlpcpN2sa3ObECRi14EH5Dt32NNH/ j46kmamSvqh/lBBPmw9AesSGtsFxOg+5wllmTBjhcVldRqFkuL4ELjqzOanVq0PPZtMh7lLuRCF c X-Google-Smtp-Source: AGHT+IFrHlkwexOK0vx8DQG+hs+3FnEgJusKWw+l9An1A48F1MSa43PjNFkrB79bTUfu9AdF0WcSCw== X-Received: by 2002:a17:902:9006:b0:1db:717e:d8ff with SMTP id a6-20020a170902900600b001db717ed8ffmr23933279plp.69.1708634643141; Thu, 22 Feb 2024 12:44:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 24/39] linux-user: Split out do_munmap Date: Thu, 22 Feb 2024 10:43:08 -1000 Message-Id: <20240222204323.268539-25-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635018615100001 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/mmap.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 1bbfeb25b1..8ebcca4444 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -267,6 +267,21 @@ int target_mprotect(abi_ulong start, abi_ulong len, in= t target_prot) return ret; } =20 +/* + * Perform munmap on behalf of the target, with host parameters. + * If reserved_va, we must replace the memory reservation. + */ +static int do_munmap(void *addr, size_t len) +{ + if (reserved_va) { + void *ptr =3D mmap(addr, len, PROT_NONE, + MAP_FIXED | MAP_ANONYMOUS + | MAP_PRIVATE | MAP_NORESERVE, -1, 0); + return ptr =3D=3D addr ? 0 : -1; + } + return munmap(addr, len); +} + /* map an incomplete host page */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong las= t, int prot, int flags, int fd, off_t offset) @@ -854,13 +869,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_= ulong len) real_len =3D real_last - real_start + 1; host_start =3D g2h_untagged(real_start); =20 - if (reserved_va) { - void *ptr =3D mmap(host_start, real_len, PROT_NONE, - MAP_FIXED | MAP_ANONYMOUS - | MAP_PRIVATE | MAP_NORESERVE, -1, 0); - return ptr =3D=3D host_start ? 0 : -1; - } - return munmap(host_start, real_len); + return do_munmap(host_start, real_len); } =20 int target_munmap(abi_ulong start, abi_ulong len) --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634733; cv=none; d=zohomail.com; s=zohoarc; b=MfFIvu7MWuxRdkmRiI87ULVbBKdH1dt8rZVpwFzq2U7Wu2BLJTgvstrGeFCNmiRfBXRmtIeacIWol0yiItaq79C+w940bkorz437sRVRYmvk15OvWZkeoh5Rvrc/bnYOQAf07GZ5oIEYnknDyxaQxNIgLLrdhCczejFYlnJ9Iuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634733; h=Content-Type: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=qMAzWUeeNJh47c4bkyOP/O/3UzvTHZWrc2G+MJg3FB0=; b=n0N72hzn16P+XyYPK/hlUpgZwqOs0r60Ly6yqynk9hWoI33bCzg6dbM+bcitu5o9yZAgEXtLmtKLH0L0woKq6UZHDys17WwWRMcNU0VKn4S2SpQg7LMXNjPcvEdpgxFzvSzI9ihnX4SP5VA/3RRalUcPWs8u7E4kl1HsV/0QKgU= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634733747670.9833456977309; Thu, 22 Feb 2024 12:45:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvM-0007dy-Jw; Thu, 22 Feb 2024 15:44:08 -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 1rdFvL-0007cE-8U for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:07 -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 1rdFvJ-0002kB-OB for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:07 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1dbae7b8ff2so1561925ad.3 for ; Thu, 22 Feb 2024 12:44:05 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634644; x=1709239444; 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=qMAzWUeeNJh47c4bkyOP/O/3UzvTHZWrc2G+MJg3FB0=; b=QG8/g7yvT+2v+FhhKtUPWtN34FEgxi2jLwF7nmB0aZs+YN7mG8taaRQjOjopBxGE9C eNI0cen+X2wB113lcF56aJdA9MEBD8UlhOnDN9t4Gm893C2Ijxmey+dd1pyAMBmfWBrt mCRE4dUcs/fPRFmHP64ULPZ8SPhc09dn5v5Rt/afeHkkLe83Whtb0cybAdp2AW6YoI/N ymITuXaqdHUn4uijOjqIy/s4MXyyAt4Ehpj5LD6dUlnQ8kChCy0ZVzAGWsm7UBRZe+6p P+utZwY9Uz2lH8NDqadSm8Ds6+LzJ6FucBVOpYYnCZhRmhsDol4WjunWdVCuPEsPAdTE ZfMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634644; x=1709239444; 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=qMAzWUeeNJh47c4bkyOP/O/3UzvTHZWrc2G+MJg3FB0=; b=FiB72rNP+r4U1gjrD7yMM/YQJ3cE6w2vLn7/k77Kbrm5QsFx3drQ4MS3ehD7sVkiss gu1lq14zhcPd6WdUC5oG1Y5iHu2xwZ+8Wk46l+Oeq7xIEo42JBjDiJnY+0uIlQkO3qBr Y8e3TIwBjhvYEeZWgUYmHTC5SSyiacUd3ekADmqUhH7jrf8kKLZUkHXGr2o6D7YbudmP 424Co8yGKBzppiFLD6FcUkrpTxVUyyl4TDqhgYcq8e/jt+v/sveh7bS6iHK0wsNjqvDh w0mZint3w9e4Q12DtNJ6WP96Sg6wB+76sACLp4vy61wrdyvFL5GpVq8m+R1aqoa7pmvc opig== X-Gm-Message-State: AOJu0Yw140J4JZ2pmiopuDFdLmRm0UDXY7U4zhndjXB9FoIuthlNvlEh 6OlQ4wjr4ry1DRma5venVaYrLlkL52sz7NzNftG0RdiEEuKFG411VlbPLMop11EhStBeDS88SdE p X-Google-Smtp-Source: AGHT+IFu5GjrHgItmCuhEUfHdFVm5SJvy2RHOWhOQzC6co8WwHNhTsSXE5cyCQmfHS/U6nKKkowzkA== X-Received: by 2002:a17:903:41c9:b0:1dc:38c7:ba1a with SMTP id u9-20020a17090341c900b001dc38c7ba1amr6134454ple.25.1708634644363; Thu, 22 Feb 2024 12:44:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 25/39] linux-user: Use do_munmap for target_mmap failure Date: Thu, 22 Feb 2024 10:43:09 -1000 Message-Id: <20240222204323.268539-26-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 Content-Type: text/plain; charset="utf-8" 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: 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634735749100001 For the cases for which the host mmap succeeds, but does not yield the desired address, use do_munmap to restore the reserved_va memory reservation. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson --- linux-user/mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 8ebcca4444..cbcd31e941 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -326,7 +326,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, flags | MAP_ANONYMOUS, -1, 0); if (p !=3D host_start) { if (p !=3D MAP_FAILED) { - munmap(p, host_page_size); + do_munmap(p, host_page_size); errno =3D EEXIST; } return false; @@ -622,7 +622,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, p =3D mmap(g2h_untagged(start), len, host_prot, flags | MAP_FIXED, fd, host_offset); if (p =3D=3D MAP_FAILED) { - munmap(g2h_untagged(start), host_len); + do_munmap(g2h_untagged(start), host_len); return -1; } host_start +=3D offset - host_offset; @@ -735,7 +735,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, flags, fd, offset1); if (p !=3D want_p) { if (p !=3D MAP_FAILED) { - munmap(p, len1); + do_munmap(p, len1); errno =3D EEXIST; } return -1; --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634785; cv=none; d=zohomail.com; s=zohoarc; b=Oy38d87Ia9sFAiwfcySF6SRCKuPPwaLWUqNmarxDOdY9GhOy+k1tXHoFwXNoSVFoEZQAlqB5CKVoF9X+OYCJpBnoz32wfuV3GCbIrYqZ8fuOT2mbdvem72/HZ+a59869cTk1Y3zZ5RPY85gj7AzcbQe4zNIXSlhbLj0wPL1j0Mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634785; 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=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=PZK5psCt4jcSKbs/G4D0F6lz6quVlAXACXj2zMcOSq0KpZ8AZZq54rzsOrOFx62wtT7vPZUfB9AZQcvWYNdQME82seYJAxWxa8HkVzePfJ/1zWnl6zHdNUkdaRFie1TrZ7tZw6ViPW2AKYy4Z7A8tVknMpxiXcjnA+mRu+l+c3A= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634785254435.2628519756332; Thu, 22 Feb 2024 12:46:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvO-0007f3-KD; Thu, 22 Feb 2024 15:44:10 -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 1rdFvM-0007eF-Vl for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:09 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvL-0002kO-7l for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:08 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1dc1ff697f9so1997345ad.0 for ; Thu, 22 Feb 2024 12:44:06 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634646; x=1709239446; 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=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=VIhlhAbpL5iXGhnY5rZzpRWNY0dB9c7JHJjo5RkstGK5cE4Bt5jyppMQ/pvhDrPtos z2TT3rykEwUpzs8aiUz9GAUnRAkF5rsMMsaWjYzajz5somxEA3T+bvEZBPJT1vL9RsT7 SLOKQO5oH1I/j6gbasbs+1f5korRVytoEsXB+5oT6oCljXjIn5LDOcBCMirz5WE/1QnZ cbfl1xGuyU1sl+oxEE5TTsp2jfIRobDdEp9MlomipAUcKxiFI3sD36meSYxRIN2Y59Jq sN+znUNHvawe8tgzjWS+0sEQqbK31OotNBmAUIHgY93h2/TIsXVjiu8WSvvtK8n0fj4+ aTBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634646; x=1709239446; 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=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=Vhun6DuD4lGQuoiZYWrQguxFEosSz2PTewynWQ57eOJC0BUjjd9qiUryCvyJs+LOHo fMr8arYHhAd7WunroH+98Winvn26a/uPSOpSwiIl7L29M4gkBW5NNfd1tX1jO+eS8/Qf oQbLIlgeyaxCg9O2cs1H2VDSFXH2PGhS6dthQsucC+cc3JeTv5eKAXVhCcOBQ29eutv8 gy4m5EZBBrAyxWry1jTBuP3FXTM23/EozqpuVlw/bu3Kk1pU+YC5YNrWwkW5AIvLAbS9 tMKo36IX3enNS+ijTPoTGZr/F/cm+nBxa2uJczeiub7PwIcHH8OmdKgJ3f/FG7YeBMGq ULHg== X-Gm-Message-State: AOJu0YzvljaFM8fmmrC/deYpDWDU7H7X0LToisA2TzXgtIa+yn2s6TYB 0RTUfnHFvAlIfW0S8r3D2WcCA8fhY74eVQj1oqXT5SkI0z6QZHTojMIK36dILMBXV3VWZ+jKdTo e X-Google-Smtp-Source: AGHT+IGJQXINA+zntUgjfujiTO13Tk5er0M2KLyX3IG0XVpHUc1nAnPiwOxBID8VRbC4M2mZ5zlvnA== X-Received: by 2002:a17:903:1105:b0:1d9:8832:f800 with SMTP id n5-20020a170903110500b001d98832f800mr25026852plh.8.1708634645785; Thu, 22 Feb 2024 12:44:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PULL 26/39] linux-user: Split out mmap_h_eq_g Date: Thu, 22 Feb 2024 10:43:10 -1000 Message-Id: <20240222204323.268539-27-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 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: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634785913100003 Content-Type: text/plain; charset="utf-8" Move the MAX_FIXED_NOREPLACE check for reserved_va earlier. Move the computation of host_prot earlier. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-22-richard.henderson@linaro.org> --- linux-user/mmap.c | 68 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index cbcd31e941..d3556bcc14 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -542,6 +542,33 @@ static abi_long mmap_end(abi_ulong start, abi_ulong la= st, return start; } =20 +/* + * Special case host page size =3D=3D target page size, + * where there are no edge conditions. + */ +static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, + int host_prot, int flags, int page_flags, + int fd, off_t offset) +{ + void *p, *want_p =3D g2h_untagged(start); + abi_ulong last; + + p =3D mmap(want_p, len, host_prot, flags, fd, offset); + if (p =3D=3D MAP_FAILED) { + return -1; + } + /* If the host kernel does not support MAP_FIXED_NOREPLACE, emulate. */ + if ((flags & MAP_FIXED_NOREPLACE) && p !=3D want_p) { + do_munmap(p, len); + errno =3D EEXIST; + return -1; + } + + start =3D h2g(p); + last =3D start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) @@ -550,6 +577,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; off_t host_offset; + int host_prot; =20 real_start =3D start & -host_page_size; host_offset =3D offset & -host_page_size; @@ -558,16 +586,33 @@ static abi_long target_mmap__locked(abi_ulong start, = abi_ulong len, * For reserved_va, we are in full control of the allocation. * Find a suitable hole and convert to MAP_FIXED. */ - if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - host_len =3D len + offset - host_offset; - start =3D mmap_find_vma(real_start, host_len, - MAX(host_page_size, TARGET_PAGE_SIZE)); - if (start =3D=3D (abi_ulong)-1) { - errno =3D ENOMEM; - return -1; + if (reserved_va) { + if (flags & MAP_FIXED_NOREPLACE) { + /* Validate that the chosen range is empty. */ + if (!page_check_range_empty(start, start + len - 1)) { + errno =3D EEXIST; + return -1; + } + flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; + } else if (!(flags & MAP_FIXED)) { + size_t real_len =3D len + offset - host_offset; + abi_ulong align =3D MAX(host_page_size, TARGET_PAGE_SIZE); + + start =3D mmap_find_vma(real_start, real_len, align); + if (start =3D=3D (abi_ulong)-1) { + errno =3D ENOMEM; + return -1; + } + start +=3D offset - host_offset; + flags |=3D MAP_FIXED; } - start +=3D offset - host_offset; - flags |=3D MAP_FIXED; + } + + host_prot =3D target_to_host_prot(target_prot); + + if (host_page_size =3D=3D TARGET_PAGE_SIZE) { + return mmap_h_eq_g(start, len, host_prot, flags, + page_flags, fd, offset); } =20 /* @@ -603,12 +648,10 @@ static abi_long target_mmap__locked(abi_ulong start, = abi_ulong len, =20 if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { uintptr_t host_start; - int host_prot; void *p; =20 host_len =3D len + offset - host_offset; host_len =3D ROUND_UP(host_len, host_page_size); - host_prot =3D target_to_host_prot(target_prot); =20 /* Note: we prefer to control the mapping address. */ p =3D mmap(g2h_untagged(start), host_len, host_prot, @@ -731,8 +774,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, len1 =3D real_last - real_start + 1; want_p =3D g2h_untagged(real_start); =20 - p =3D mmap(want_p, len1, target_to_host_prot(target_prot), - flags, fd, offset1); + p =3D mmap(want_p, len1, host_prot, flags, fd, offset1); if (p !=3D want_p) { if (p !=3D MAP_FAILED) { do_munmap(p, len1); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634853; cv=none; d=zohomail.com; s=zohoarc; b=EYmvFJPwz0kgJLS5r8nYMln/dmChzel7KUA/zcS0Z2ZA+8PKJaNYqmg/dfslXFIPtMvK5wUMTVaMcMphej2yO2ZFBR9VAM5x1dUz4w5JsXQ6ZHtWEDkzuNLuB3u77NQp1WslgFyINWCZwZPuVmgEMDl9AE3aQtZhKPXUXyCLE8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634853; 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=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=MWtaKIcF1RA5U4iM8J7Krz8Qp5mDWzuTJGSud67olR2mb7Ox2s8CKh1mnkl8BVFStiM+sGqO4pnCfb0ohiBFygmhQnN7AgO6WQyVIWmw07piKjQ3j7LFw3ZvaAZAIqR0b/KwlCn81CzZTtZcATY0jVCdNELYuq0WczW6jZC213U= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634853655455.26312706797887; Thu, 22 Feb 2024 12:47:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvQ-0007gf-Fr; Thu, 22 Feb 2024 15:44:12 -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 1rdFvO-0007f9-NN for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:10 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvM-0002kt-P2 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:10 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1dba94f9201so2033125ad.0 for ; Thu, 22 Feb 2024 12:44:08 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634647; x=1709239447; 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=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=vYcoB7I+svat1gp4rABqsuXPL7k+lOamSGb8G5j4P25bOA9yiZv8V1cKvbpRcz7+I3 OVGgN+t7VUvMWtjICIH57xLuN30mv+PQRGgNCjkUFHkwl4pIxST2qOSTZcgvD6QxUjiS QCUV6fY1HgJ2QKvMMfO0Kvq/lThYiGkbUsnJmun4N72SYnVaT5TwOzrfWpGP4EZYqduJ e/vVL7TdF2WKzQB5jwuNyXdeIgB//2zajH9YA4wnbzBf3jUkusym84FvcwmFKUmcgiAu bUninxD2ghcTbD4n/Kt7olQkjX4smCSdWmhUvO7XXIvhruJp+kSNELsgm7Ap0uO9KST+ IJyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634647; x=1709239447; 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=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=HUXX2vDcaWOJ4x+aNHm5VBCC9BuXd/XEV5CgLLD1UqvBi7JMGTGeRKrgUsYzx8BvhL 5HQSCMMjZN7jQHZ/PiMIOG26mZd2JLSxo4eFY5rOTXtpqdywYbgPF5bycBFXohsZZ3fu 0reK+aCMU3udl4m4dOGU7924y8YWK24Fp5CwXvTHCe1I4hrDPpafsDdvG/xI3QyFNrPx kWiOazmf8M5clQZusteW7cBf47sHlf4nuSim1j6YWRfKR29Lk0UNlLaUMNZ960JRkESh Gten/gwqNmby1QdauBJCxAcgeQZhB93EKH2HKu6peLxkdLchT/PLvn8W6nXhIDTrV3A1 oedw== X-Gm-Message-State: AOJu0Yyml2BX/GucMrDSo4hZLQDdXQaupQXqLHRn6y8ekP/VaO530XmI EtzPOsqL2oFSbyXFMq85tD4EftZCM6aiSEpySUKIkhg9I/RS7bCFT97MmT9NVeBqi8tTODiJIrJ R X-Google-Smtp-Source: AGHT+IF+l4iOQG0U0BFS83Mb/VCge+6IS/YLjeVIjqf6v3eoetL/Z/MNs5oCnM3RhCKyYqWuOsBAVQ== X-Received: by 2002:a17:902:ecc1:b0:1dc:673:1932 with SMTP id a1-20020a170902ecc100b001dc06731932mr13462931plh.38.1708634647523; Thu, 22 Feb 2024 12:44:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PULL 27/39] linux-user: Split out mmap_h_lt_g Date: Thu, 22 Feb 2024 10:43:11 -1000 Message-Id: <20240222204323.268539-28-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 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: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634854128100001 Content-Type: text/plain; charset="utf-8" Work much harder to get alignment and mapping beyond the end of the file correct. Both of which are excercised by our test-mmap for alpha (8k pages) on any 4k page host. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-23-richard.henderson@linaro.org> --- linux-user/mmap.c | 184 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 153 insertions(+), 31 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d3556bcc14..ff8f9f7ed0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -569,6 +569,156 @@ static abi_long mmap_h_eq_g(abi_ulong start, abi_ulon= g len, return mmap_end(start, last, start, last, flags, page_flags); } =20 +/* + * Special case host page size < target page size. + * + * The two special cases are increased guest alignment, and mapping + * past the end of a file. + * + * When mapping files into a memory area larger than the file, + * accesses to pages beyond the file size will cause a SIGBUS. + * + * For example, if mmaping a file of 100 bytes on a host with 4K + * pages emulating a target with 8K pages, the target expects to + * be able to access the first 8K. But the host will trap us on + * any access beyond 4K. + * + * When emulating a target with a larger page-size than the hosts, + * we may need to truncate file maps at EOF and add extra anonymous + * pages up to the targets page boundary. + * + * This workaround only works for files that do not change. + * If the file is later extended (e.g. ftruncate), the SIGBUS + * vanishes and the proper behaviour is that changes within the + * anon page should be reflected in the file. + * + * However, this case is rather common with executable images, + * so the workaround is important for even trivial tests, whereas + * the mmap of of a file being extended is less common. + */ +static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, + int mmap_flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p =3D g2h_untagged(start); + off_t fileend_adj =3D 0; + int flags =3D mmap_flags; + abi_ulong last, pass_last; + + if (!(flags & MAP_ANONYMOUS)) { + struct stat sb; + + if (fstat(fd, &sb) =3D=3D -1) { + return -1; + } + if (offset >=3D sb.st_size) { + /* + * The entire map is beyond the end of the file. + * Transform it to an anonymous mapping. + */ + flags |=3D MAP_ANONYMOUS; + fd =3D -1; + offset =3D 0; + } else if (offset + len > sb.st_size) { + /* + * A portion of the map is beyond the end of the file. + * Truncate the file portion of the allocation. + */ + fileend_adj =3D offset + len - sb.st_size; + } + } + + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (fileend_adj) { + p =3D mmap(want_p, len, host_prot, flags | MAP_ANONYMOUS, -1, = 0); + } else { + p =3D mmap(want_p, len, host_prot, flags, fd, offset); + } + if (p !=3D want_p) { + if (p !=3D MAP_FAILED) { + /* Host does not support MAP_FIXED_NOREPLACE: emulate. */ + do_munmap(p, len); + errno =3D EEXIST; + } + return -1; + } + + if (fileend_adj) { + void *t =3D mmap(p, len - fileend_adj, host_prot, + (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED, + fd, offset); + + if (t =3D=3D MAP_FAILED) { + int save_errno =3D errno; + + /* + * We failed a map over the top of the successful anonymous + * mapping above. The only failure mode is running out of = VMAs, + * and there's nothing that we can do to detect that earli= er. + * If we have replaced an existing mapping with MAP_FIXED, + * then we cannot properly recover. It's a coin toss whet= her + * it would be better to exit or continue here. + */ + if (!(flags & MAP_FIXED_NOREPLACE) && + !page_check_range_empty(start, start + len - 1)) { + qemu_log("QEMU target_mmap late failure: %s", + strerror(save_errno)); + } + + do_munmap(want_p, len); + errno =3D save_errno; + return -1; + } + } + } else { + size_t host_len, part_len; + + /* + * Take care to align the host memory. Perform a larger anonymous + * allocation and extract the aligned portion. Remap the file on + * top of that. + */ + host_len =3D len + TARGET_PAGE_SIZE - host_page_size; + p =3D mmap(want_p, host_len, host_prot, flags | MAP_ANONYMOUS, -1,= 0); + if (p =3D=3D MAP_FAILED) { + return -1; + } + + part_len =3D (uintptr_t)p & (TARGET_PAGE_SIZE - 1); + if (part_len) { + part_len =3D TARGET_PAGE_SIZE - part_len; + do_munmap(p, part_len); + p +=3D part_len; + host_len -=3D part_len; + } + if (len < host_len) { + do_munmap(p + len, host_len - len); + } + + if (!(flags & MAP_ANONYMOUS)) { + void *t =3D mmap(p, len - fileend_adj, host_prot, + flags | MAP_FIXED, fd, offset); + + if (t =3D=3D MAP_FAILED) { + int save_errno =3D errno; + do_munmap(p, len); + errno =3D save_errno; + return -1; + } + } + + start =3D h2g(p); + } + + last =3D start + len - 1; + if (fileend_adj) { + pass_last =3D ROUND_UP(last - fileend_adj, host_page_size) - 1; + } else { + pass_last =3D last; + } + return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) @@ -613,37 +763,9 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, if (host_page_size =3D=3D TARGET_PAGE_SIZE) { return mmap_h_eq_g(start, len, host_prot, flags, page_flags, fd, offset); - } - - /* - * When mapping files into a memory area larger than the file, accesses - * to pages beyond the file size will cause a SIGBUS. - * - * For example, if mmaping a file of 100 bytes on a host with 4K pages - * emulating a target with 8K pages, the target expects to be able to - * access the first 8K. But the host will trap us on any access beyond - * 4K. - * - * When emulating a target with a larger page-size than the hosts, we - * may need to truncate file maps at EOF and add extra anonymous pages - * up to the targets page boundary. - */ - if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { - struct stat sb; - - if (fstat(fd, &sb) =3D=3D -1) { - return -1; - } - - /* Are we trying to create a map beyond EOF?. */ - if (offset + len > sb.st_size) { - /* - * If so, truncate the file map at eof aligned with - * the hosts real pagesize. Additional anonymous maps - * will be created beyond EOF. - */ - len =3D ROUND_UP(sb.st_size - offset, host_page_size); - } + } else if (host_page_size < TARGET_PAGE_SIZE) { + return mmap_h_lt_g(start, len, host_prot, flags, + page_flags, fd, offset, host_page_size); } =20 if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635132; cv=none; d=zohomail.com; s=zohoarc; b=jb5T2DQqnsyh5K2ee+/QUAlriDTaVzOM61hBHmQMtAZjMWAqFT0WHTgzY3uDTJi+tpbvdhsdpM+AcsWshCHpFhP46IzynD4xE+Sc9Zyib/UXTe87M7/G0rQ72bGoJb5YmnzO+W/0EIYe24SvK9Tv2ZDd+f95/1BhlVVmGaUCYA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635132; 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=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=RNxGgvVco3M5ZjE5o1ImXd9KSava6S2hB5xvDsvx+Tr5ID5/+s3mhbajSU2X9aza6BJrzHfiDMTKAMhLeV3u3STYUVmT2zBFNcFPVg+YycRdmcSdxLff628An0ErEJgrZBaFi4Y0w+foKRcmyQebilUrPCUaWq6/UT2do/dBp9M= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635132270468.17879413118885; Thu, 22 Feb 2024 12:52:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvR-0007kz-KI; Thu, 22 Feb 2024 15:44:13 -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 1rdFvQ-0007gb-Ba for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:12 -0500 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 1rdFvO-0002lr-7W for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:12 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d953fa3286so485075ad.2 for ; Thu, 22 Feb 2024 12:44:09 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634649; x=1709239449; 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=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=jmMKvmWF8WNZyVIOnP4VIOKJD5vEZbgdp5PXcTqmosoJpfgZgzcgLd4Yq8OfEgWZsb WXK3vrlkd9rS/HrfMgTDDkCpwMQ+wQxk1F6HMo7VPa06R7DmJgoCqQMd5O2DSqdiqrdb oeWmvHd/uAsB+NNmoOluDWVNanOOGcwEyd9Sw+Doa65UeVCOzdrLQYdBmOfYvmdsPdbG ZtWxYtuqenLvxBZZvnF1euG4XShhTSdV8318zYaHWUMCne1nghnWAsnc2t9OMAcZuEqq VrA996z7A+I+F65ov6BhS6mWoitEbtKxAtz6DkmBrPP31FYeLaDvHnU3+/bOKVXfBmgb sgjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634649; x=1709239449; 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=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=FQwu9gQMBCoizy6tK6YT/dxUkQ1KHO0F3Pd4DyK2dGflSZauTqW6ltOHx7ubkf28kM B0bQeR7GcFysG39TCUdI6Hv6xfNuOCcBojPKfdyDUqckdQpyXOwd8POCV99tBMznacDv iIKO1ORiVMNdivk5dcwWe59nzi6HPZ6UrD/hZ952J+PWoKJEA5D2oWv5NMabNKgOPhi4 RNy2OLVf0TFeHmmOS9FxyFe2640d0p5uJv7yMt6SaXSJZHassHRcuhOxrsCm1nhEhzWu 9vDnBwCUHFAUpmK39a++nVLLMArYLAQQNhdiExFEq51RutoK/RTLifwjhjPdJGLFLAJw L/pQ== X-Gm-Message-State: AOJu0YzKDiaf3tVqPoJn2cxY68Xurutc8PqCx+AzLmmNclmQwPa/vklc 1ctyzAiBeLRh8o9nJH9ud9W0E+Ly0zDk3lNCJJYzqjfofZf5acSbe8NZ2RotmntqEAgprW/LiWH O X-Google-Smtp-Source: AGHT+IG98EL4HHBXS6w+XbrUxwDgWhGqzZUMIvX9dz2+dFc2k5Zz2ihjyu3RKI5CIekSCa3LTTKshA== X-Received: by 2002:a17:903:298b:b0:1db:be69:d02d with SMTP id lm11-20020a170903298b00b001dbbe69d02dmr23269427plb.32.1708634648954; Thu, 22 Feb 2024 12:44:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PULL 28/39] linux-user: Split out mmap_h_gt_g Date: Thu, 22 Feb 2024 10:43:12 -1000 Message-Id: <20240222204323.268539-29-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 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: 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, 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 @linaro.org) X-ZM-MESSAGEID: 1708635133040100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-24-richard.henderson@linaro.org> --- linux-user/mmap.c | 288 ++++++++++++++++++++++------------------------ 1 file changed, 139 insertions(+), 149 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index ff8f9f7ed0..82f4026283 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -282,7 +282,16 @@ static int do_munmap(void *addr, size_t len) return munmap(addr, len); } =20 -/* map an incomplete host page */ +/* + * Map an incomplete host page. + * + * Here be dragons. This case will not work if there is an existing + * overlapping host page, which is file mapped, and for which the mapping + * is beyond the end of the file. In that case, we will see SIGBUS when + * trying to write a portion of this page. + * + * FIXME: Work around this with a temporary signal handler and longjmp. + */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong las= t, int prot, int flags, int fd, off_t offset) { @@ -719,19 +728,138 @@ static abi_long mmap_h_lt_g(abi_ulong start, abi_ulo= ng len, int host_prot, return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); } =20 +/* + * Special case host page size > target page size. + * + * The two special cases are address and file offsets that are valid + * for the guest that cannot be directly represented by the host. + */ +static abi_long mmap_h_gt_g(abi_ulong start, abi_ulong len, + int target_prot, int host_prot, + int flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p =3D g2h_untagged(start); + off_t host_offset =3D offset & -host_page_size; + abi_ulong last, real_start, real_last; + bool misaligned_offset =3D false; + size_t host_len; + + if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + /* + * Adjust the offset to something representable on the host. + */ + host_len =3D len + offset - host_offset; + p =3D mmap(want_p, host_len, host_prot, flags, fd, host_offset); + if (p =3D=3D MAP_FAILED) { + return -1; + } + + /* Update start to the file position at offset. */ + p +=3D offset - host_offset; + + start =3D h2g(p); + last =3D start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); + } + + if (!(flags & MAP_ANONYMOUS)) { + misaligned_offset =3D (start ^ offset) & (host_page_size - 1); + + /* + * The fallback for misalignment is a private mapping + read. + * This carries none of semantics required of MAP_SHARED. + */ + if (misaligned_offset && (flags & MAP_TYPE) !=3D MAP_PRIVATE) { + errno =3D EINVAL; + return -1; + } + } + + last =3D start + len - 1; + real_start =3D start & -host_page_size; + real_last =3D ROUND_UP(last, host_page_size) - 1; + + /* + * Handle the start and end of the mapping. + */ + if (real_start < start) { + abi_ulong real_page_last =3D real_start + host_page_size - 1; + if (last <=3D real_page_last) { + /* Entire allocation a subset of one host page. */ + if (!mmap_frag(real_start, start, last, target_prot, + flags, fd, offset)) { + return -1; + } + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + if (!mmap_frag(real_start, start, real_page_last, target_prot, + flags, fd, offset)) { + return -1; + } + real_start =3D real_page_last + 1; + } + + if (last < real_last) { + abi_ulong real_page_start =3D real_last - host_page_size + 1; + if (!mmap_frag(real_page_start, real_page_start, last, + target_prot, flags, fd, + offset + real_page_start - start)) { + return -1; + } + real_last =3D real_page_start - 1; + } + + if (real_start > real_last) { + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + /* + * Handle the middle of the mapping. + */ + + host_len =3D real_last - real_start + 1; + want_p +=3D real_start - start; + + if (flags & MAP_ANONYMOUS) { + p =3D mmap(want_p, host_len, host_prot, flags, -1, 0); + } else if (!misaligned_offset) { + p =3D mmap(want_p, host_len, host_prot, flags, fd, + offset + real_start - start); + } else { + p =3D mmap(want_p, host_len, host_prot | PROT_WRITE, + flags | MAP_ANONYMOUS, -1, 0); + } + if (p !=3D want_p) { + if (p !=3D MAP_FAILED) { + do_munmap(p, host_len); + errno =3D EEXIST; + } + return -1; + } + + if (misaligned_offset) { + /* TODO: The read could be short. */ + if (pread(fd, p, host_len, offset + real_start - start) !=3D host_= len) { + do_munmap(p, host_len); + return -1; + } + if (!(host_prot & PROT_WRITE)) { + mprotect(p, host_len, host_prot); + } + } + + return mmap_end(start, last, -1, 0, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); - abi_ulong ret, last, real_start, real_last, retaddr, host_len; - abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; - off_t host_offset; int host_prot; =20 - real_start =3D start & -host_page_size; - host_offset =3D offset & -host_page_size; - /* * For reserved_va, we are in full control of the allocation. * Find a suitable hole and convert to MAP_FIXED. @@ -745,6 +873,8 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, } flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; } else if (!(flags & MAP_FIXED)) { + abi_ulong real_start =3D start & -host_page_size; + off_t host_offset =3D offset & -host_page_size; size_t real_len =3D len + offset - host_offset; abi_ulong align =3D MAX(host_page_size, TARGET_PAGE_SIZE); =20 @@ -766,150 +896,10 @@ static abi_long target_mmap__locked(abi_ulong start,= abi_ulong len, } else if (host_page_size < TARGET_PAGE_SIZE) { return mmap_h_lt_g(start, len, host_prot, flags, page_flags, fd, offset, host_page_size); - } - - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - uintptr_t host_start; - void *p; - - host_len =3D len + offset - host_offset; - host_len =3D ROUND_UP(host_len, host_page_size); - - /* Note: we prefer to control the mapping address. */ - p =3D mmap(g2h_untagged(start), host_len, host_prot, - flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); - if (p =3D=3D MAP_FAILED) { - return -1; - } - /* update start so that it points to the file position at 'offset'= */ - host_start =3D (uintptr_t)p; - if (!(flags & MAP_ANONYMOUS)) { - p =3D mmap(g2h_untagged(start), len, host_prot, - flags | MAP_FIXED, fd, host_offset); - if (p =3D=3D MAP_FAILED) { - do_munmap(g2h_untagged(start), host_len); - return -1; - } - host_start +=3D offset - host_offset; - } - start =3D h2g(host_start); - last =3D start + len - 1; - passthrough_start =3D start; - passthrough_last =3D last; } else { - last =3D start + len - 1; - real_last =3D ROUND_UP(last, host_page_size) - 1; - - if (flags & MAP_FIXED_NOREPLACE) { - /* Validate that the chosen range is empty. */ - if (!page_check_range_empty(start, last)) { - errno =3D EEXIST; - return -1; - } - - /* - * With reserved_va, the entire address space is mmaped in the - * host to ensure it isn't accidentally used for something els= e. - * We have just checked that the guest address is not mapped - * within the guest, but need to replace the host reservation. - * - * Without reserved_va, despite the guest address check above, - * keep MAP_FIXED_NOREPLACE so that the guest does not overwri= te - * any host address mappings. - */ - if (reserved_va) { - flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; - } - } - - /* - * worst case: we cannot map the file because the offset is not - * aligned, so we read it - */ - if (!(flags & MAP_ANONYMOUS) && - (offset & (host_page_size - 1)) !=3D (start & (host_page_size = - 1))) { - /* - * msync() won't work here, so we return an error if write is - * possible while it is a shared mapping - */ - if ((flags & MAP_TYPE) =3D=3D MAP_SHARED - && (target_prot & PROT_WRITE)) { - errno =3D EINVAL; - return -1; - } - retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, - (flags & (MAP_FIXED | MAP_FIXED_NOREPLAC= E)) - | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); - if (retaddr =3D=3D -1) { - return -1; - } - if (pread(fd, g2h_untagged(start), len, offset) =3D=3D -1) { - return -1; - } - if (!(target_prot & PROT_WRITE)) { - ret =3D target_mprotect(start, len, target_prot); - assert(ret =3D=3D 0); - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - - /* handle the start of the mapping */ - if (start > real_start) { - if (real_last =3D=3D real_start + host_page_size - 1) { - /* one single host page */ - if (!mmap_frag(real_start, start, last, - target_prot, flags, fd, offset)) { - return -1; - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - if (!mmap_frag(real_start, start, - real_start + host_page_size - 1, - target_prot, flags, fd, offset)) { - return -1; - } - real_start +=3D host_page_size; - } - /* handle the end of the mapping */ - if (last < real_last) { - abi_ulong real_page =3D real_last - host_page_size + 1; - if (!mmap_frag(real_page, real_page, last, - target_prot, flags, fd, - offset + real_page - start)) { - return -1; - } - real_last -=3D host_page_size; - } - - /* map the middle (easier) */ - if (real_start < real_last) { - void *p, *want_p; - off_t offset1; - size_t len1; - - if (flags & MAP_ANONYMOUS) { - offset1 =3D 0; - } else { - offset1 =3D offset + real_start - start; - } - len1 =3D real_last - real_start + 1; - want_p =3D g2h_untagged(real_start); - - p =3D mmap(want_p, len1, host_prot, flags, fd, offset1); - if (p !=3D want_p) { - if (p !=3D MAP_FAILED) { - do_munmap(p, len1); - errno =3D EEXIST; - } - return -1; - } - passthrough_start =3D real_start; - passthrough_last =3D real_last; - } + return mmap_h_gt_g(start, len, target_prot, host_prot, flags, + page_flags, fd, offset, host_page_size); } - return mmap_end(start, last, passthrough_start, passthrough_last, - flags, page_flags); } =20 /* NOTE: all the constants are the HOST ones */ --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635090; cv=none; d=zohomail.com; s=zohoarc; b=UL8H/SPUa+F5+ZCmel2iwdY4Yzaab7fm/Bz65KuVYwLt7p+X1/OS5OhPLjpP4KG9YzIgrNwvbN3s4s15oA1HtGsyPbS7uHQT50k84Chd45Z4imui2EvBMEmoH9jIOo1p9n5cBBtcilZiV4amaUV+ar/6/zFaKLXOTRtAds2H39M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635090; 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=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=OCLGeKiqe9oJ5wlr9U8yxhAZQH4+56URo7iAqnCCxRx2b0H3e1CvlkOJe5Rk+Xnf7GjOGilhF3blLRpqUiYcN+6a5c3e17wPuK9nPwvB3mp0KnF4Q5gZm4xjdOlGSZrdaFnmNwVXhzGyIdgh/RDbM/j2XjFRRZrWXhurFKEea8E= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170863509004678.71572599035972; Thu, 22 Feb 2024 12:51:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvU-0007zO-53; Thu, 22 Feb 2024 15:44:16 -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 1rdFvR-0007kj-EN for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:13 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvP-0002m6-JF for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:13 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d93edfa76dso526625ad.1 for ; Thu, 22 Feb 2024 12:44:11 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634650; x=1709239450; 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=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=a2fCnJs8PWt2Eox79SovwMovZO914dkzb4e2G6hzIY5L4/ljkXfAawsSJc/cL/YMIm G3zWeNv3kYK/Te0KI0XInhDKeouNYrEVOAoaZwoPd2OhDrDXwyZh7PSkl1z4Ygb9Utej aTe74i8pokbd7CZ1W1BEzCCmgs6WOz/F4qtl0Cwt+5P38Q1j0JtEbsER1n5lmMs3LnCR Wd+HaCkXK8l4jIFZDJ1CPjZYYO1quqHl8iTDWG/S9CO5DlN4mDUq1Huap9tDsdeB3UGE +CcFdYwkhZ5HmsRs+UDB3PDJQRv6cSo8Hi3CffeVY/G6zQztyyoRujOUyrCtT1b90aVk MXwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634650; x=1709239450; 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=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=DVZHUr3pXixw+mQF1AN9k0K+XxCNx6V5SJXWkRTChkU765Yf0oOawcdLgvsCq9wVS8 eFIWVON0PYcsyKpUF8R8Wh+L9HkvFe4uFc4rXfnteLSiWulmHtGHf1Oj1Er55eiQdWLl jkoAvKHEyb805InpMQpLN4bOhMwm97O7hFVAaL1dYNAoqSIFT0OLS2sPgY+OngfXve98 gntATD8550Y6fnZM8UzIIC3ipt8imMiInBpmcsg8HYCsajNWtCnMVKrnx7xRDEG97dSe G2yuDEJch+v4463aQjYPgztVQ7prKtzC7Rm3tC7cktEIkFacQu0pbS9zijB259iXx826 JdQA== X-Gm-Message-State: AOJu0Yz7ZQyFAJdU/H3EmtVRdLIFZKRLXBL5l8M7KxhK1DGRKIM942yd c/qNdU1oOyYdLClMLEpNmbwWQYWto46f61sL+HVAjK1Tx7W454BvCmQ1IbiHoiPNhrniv7l6fz4 O X-Google-Smtp-Source: AGHT+IHAXwfllyccLeApk6u5LeBSODnWRxxm8uOuSZoPdnLnssgyJ5LjVwuoTXt98+Yy78X/JdJq4g== X-Received: by 2002:a17:903:234a:b0:1dc:1831:8ecc with SMTP id c10-20020a170903234a00b001dc18318eccmr9975697plh.53.1708634650394; Thu, 22 Feb 2024 12:44:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 29/39] tests/tcg: Remove run-test-mmap-* Date: Thu, 22 Feb 2024 10:43:13 -1000 Message-Id: <20240222204323.268539-30-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 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: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635090852100001 Content-Type: text/plain; charset="utf-8" These tests are confused, because -p does not change the guest page size, but the host page size. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-25-richard.henderson@linaro.org> --- tests/tcg/alpha/Makefile.target | 3 --- tests/tcg/arm/Makefile.target | 3 --- tests/tcg/hppa/Makefile.target | 3 --- tests/tcg/i386/Makefile.target | 3 --- tests/tcg/m68k/Makefile.target | 3 --- tests/tcg/multiarch/Makefile.target | 9 --------- tests/tcg/ppc/Makefile.target | 12 ------------ tests/tcg/sh4/Makefile.target | 3 --- tests/tcg/sparc64/Makefile.target | 6 ------ 9 files changed, 45 deletions(-) delete mode 100644 tests/tcg/ppc/Makefile.target delete mode 100644 tests/tcg/sparc64/Makefile.target diff --git a/tests/tcg/alpha/Makefile.target b/tests/tcg/alpha/Makefile.tar= get index b94500a7d9..fdd7ddf64e 100644 --- a/tests/tcg/alpha/Makefile.target +++ b/tests/tcg/alpha/Makefile.target @@ -13,6 +13,3 @@ test-cmov: test-cond.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) =20 run-test-cmov: test-cmov - -# On Alpha Linux only supports 8k pages -EXTRA_RUNS+=3Drun-test-mmap-8192 diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 3473f4619e..0a1965fce7 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -79,6 +79,3 @@ sha512-vector: sha512.c ARM_TESTS +=3D sha512-vector =20 TESTS +=3D $(ARM_TESTS) - -# On ARM Linux only supports 4k pages -EXTRA_RUNS+=3Drun-test-mmap-4096 diff --git a/tests/tcg/hppa/Makefile.target b/tests/tcg/hppa/Makefile.target index cdd0d572a7..ea5ae2186d 100644 --- a/tests/tcg/hppa/Makefile.target +++ b/tests/tcg/hppa/Makefile.target @@ -2,9 +2,6 @@ # # HPPA specific tweaks - specifically masking out broken tests =20 -# On parisc Linux supports 4K/16K/64K (but currently only 4k works) -EXTRA_RUNS+=3Drun-test-mmap-4096 # run-test-mmap-16384 run-test-mmap-65536 - # This triggers failures for hppa-linux about 1% of the time # HPPA is the odd target that can't use the sigtramp page; # it requires the full vdso with dwarf2 unwind info. diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index 9906f9e116..bbe2c44b2a 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -71,9 +71,6 @@ endif I386_TESTS:=3D$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) TESTS=3D$(MULTIARCH_TESTS) $(I386_TESTS) =20 -# On i386 and x86_64 Linux only supports 4k pages (large pages are a diffe= rent hack) -EXTRA_RUNS+=3Drun-test-mmap-4096 - sha512-sse: CFLAGS=3D-msse4.1 -O3 sha512-sse: sha512.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/m68k/Makefile.target b/tests/tcg/m68k/Makefile.target index 6ff214e60a..33f7b1b127 100644 --- a/tests/tcg/m68k/Makefile.target +++ b/tests/tcg/m68k/Makefile.target @@ -5,6 +5,3 @@ =20 VPATH +=3D $(SRC_PATH)/tests/tcg/m68k TESTS +=3D trap denormal - -# On m68k Linux supports 4k and 8k pages (but 8k is currently broken) -EXTRA_RUNS+=3Drun-test-mmap-4096 # run-test-mmap-8192 diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index e10951a801..f11f3b084d 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -51,18 +51,9 @@ run-plugin-vma-pthread-with-%: vma-pthread $(call skip-test, $<, "flaky on CI?") endif =20 -# We define the runner for test-mmap after the individual -# architectures have defined their supported pages sizes. If no -# additional page sizes are defined we only run the default test. - -# default case (host page size) run-test-mmap: test-mmap $(call run-test, test-mmap, $(QEMU) $<, $< (default)) =20 -# additional page sizes (defined by each architecture adding to EXTRA_RUNS) -run-test-mmap-%: test-mmap - $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages)) - ifneq ($(GDB),) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 diff --git a/tests/tcg/ppc/Makefile.target b/tests/tcg/ppc/Makefile.target deleted file mode 100644 index f5e08c7376..0000000000 --- a/tests/tcg/ppc/Makefile.target +++ /dev/null @@ -1,12 +0,0 @@ -# -*- Mode: makefile -*- -# -# PPC - included from tests/tcg/Makefile -# - -ifneq (,$(findstring 64,$(TARGET_NAME))) -# On PPC64 Linux can be configured with 4k (default) or 64k pages (current= ly broken) -EXTRA_RUNS+=3Drun-test-mmap-4096 #run-test-mmap-65536 -else -# On PPC32 Linux supports 4K/16K/64K/256K (but currently only 4k works) -EXTRA_RUNS+=3Drun-test-mmap-4096 #run-test-mmap-16384 run-test-mmap-65536 = run-test-mmap-262144 -endif diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 47c39a44b6..16eaa850a8 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -3,9 +3,6 @@ # SuperH specific tweaks # =20 -# On sh Linux supports 4k, 8k, 16k and 64k pages (but only 4k currently wo= rks) -EXTRA_RUNS+=3Drun-test-mmap-4096 # run-test-mmap-8192 run-test-mmap-16384 = run-test-mmap-65536 - # This triggers failures for sh4-linux about 10% of the time. # Random SIGSEGV at unpredictable guest address, cause unknown. run-signals: signals diff --git a/tests/tcg/sparc64/Makefile.target b/tests/tcg/sparc64/Makefile= .target deleted file mode 100644 index 408dace783..0000000000 --- a/tests/tcg/sparc64/Makefile.target +++ /dev/null @@ -1,6 +0,0 @@ -# -*- Mode: makefile -*- -# -# sparc specific tweaks - -# On Sparc64 Linux support 8k pages -EXTRA_RUNS+=3Drun-test-mmap-8192 --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635103; cv=none; d=zohomail.com; s=zohoarc; b=CYt6DWLVfM6Le2um/Y9Ub3b+bkll+Qrh6nfyQJNJQs3jXY0BU5f9T2PJGexnbAMfm/yMwsamHuFC8i37SV97UBI3rWP2zjfgci1sQe+YZ/4w+oHGPav3xePvu+OFQ5O99FAdsklbXCNIMGtQl8gQ7NDe8Qh3jhfhOu//ifAnOGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635103; h=Content-Type: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=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=YwJMOa/qGcr370Tg2z9GlNSsx/B1H4ggRVicEyifnQuEK34iUDZW3Vm2jo9YscwA1gRME+ivQAG4z8IiPr2OoNag7CSFzTFDVB+y3LzWG6U5JHOngDqRAe031pL8zY2JmbXqHUBGymN6kl1T0Bb4m4RyL5v6XmFrRWSE46dHiyo= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635103594168.62652008866223; Thu, 22 Feb 2024 12:51:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvU-00080U-AM; Thu, 22 Feb 2024 15:44:16 -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 1rdFvS-0007q3-Jo for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:14 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvR-0002mK-2h for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:14 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1dc1e7c0e29so1599065ad.1 for ; Thu, 22 Feb 2024 12:44:12 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634652; x=1709239452; 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=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=hZ/4CrhMaNF1HjeJrPF8OHuJNdFTLFA4fEx03C6PKPWV3gpdKvw5Kt9cMBDW8quEA8 VvO3b4fReqsO3wVD+JP56u8Kw2FcSPqbrZwwWJHtywSPyQgpCfct7+KQbDin5ITkl+7c KM0jCBW56pvhEO6bTfjhNwDDhdpFf30lcxqRxilPBTEAXKD7uXyqJ8Fuzj7IFI3JUz5P 5vqtUHb7fL1xcG42GcY/KNqr54sK1RgxEQpNrZch/FUdgLFjz222mZ2j/Am3gIDbNiSE bvjfEoBUBZNXVpplwge5cQ/qt9VD/vZN/PQZVenFTupjXYhHFGtFwMesL8/HqFDO7Raf orGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634652; x=1709239452; 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=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=FzWKKGIR2/ZNrtlRJhVKDZL9T/fsqBzKmueZa+jdflkyGbvBlPs0aYlIgvWhJdqf2i yaxTlnFSTIPMRbudyzhgQ0be9830XZgxiMSSRMrioniQgqw8IsESlJpZMLFKaGhmPczL OWiUbhxU6fRl6wGiFcpi/kkN1Lm4v/Hf2l7M/nx1qccJCy6e6PldCd+RE45l4fLgOkCi OgmMKsOlztdQqKIDdJw9EU2/wGlIgk7cNrrRYbWHLo1Ksz7+jGyhsV0B3Yi5MDFTJ1og QW0McetP23CXjmvev0bIft7s2oI5tyAaVRM3RAlbfLb2vB4D6EfGwc4xuiEC5+j7so4m 6XLw== X-Gm-Message-State: AOJu0YzDFbJ7VHwhJUxD0TGzaMO7TumttotucJHO5PUS8ctne56pNyeI 8Fhi5elRaZhA3xU23xqXCvpqAW7RveA3Vhl3XqrHdCg2W0yhqNr0CJRF6fwHMzZVVOgJ0zCgppT M X-Google-Smtp-Source: AGHT+IFcuTy8EJ2o76Foed3DNGOgF7w8raPHKOVmlAW1Wx8ej7Aaizp3M8y5OQxUMBQueKGRfvMBWA== X-Received: by 2002:a17:902:ea0d:b0:1db:e792:bb38 with SMTP id s13-20020a170902ea0d00b001dbe792bb38mr15388661plg.63.1708634651868; Thu, 22 Feb 2024 12:44:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 30/39] tests/tcg: Extend file in linux-madvise.c Date: Thu, 22 Feb 2024 10:43:14 -1000 Message-Id: <20240222204323.268539-31-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635104846100001 When guest page size > host page size, this test can fail due to the SIGBUS protection hack. Avoid this by making sure that the file size is at least one guest page. Visible with alpha guest on x86_64 host. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-26-richard.henderson@linaro.org> --- tests/tcg/multiarch/linux/linux-madvise.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tcg/multiarch/linux/linux-madvise.c b/tests/tcg/multiarc= h/linux/linux-madvise.c index 29d0997e68..539fb3b772 100644 --- a/tests/tcg/multiarch/linux/linux-madvise.c +++ b/tests/tcg/multiarch/linux/linux-madvise.c @@ -42,6 +42,8 @@ static void test_file(void) assert(ret =3D=3D 0); written =3D write(fd, &c, sizeof(c)); assert(written =3D=3D sizeof(c)); + ret =3D ftruncate(fd, pagesize); + assert(ret =3D=3D 0); page =3D mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0); assert(page !=3D MAP_FAILED); =20 --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634668; cv=none; d=zohomail.com; s=zohoarc; b=Lfs/csq8OIfB4wFVaO4yQL7gZEwIv8qwyTW4+9Q2JE/TcsXPzaEE9iG0LJuqsazjlJpF4K8xEK1E6dSmgJigvDa9Fw3OBaHfxCNcUzpyavVuPcqPCmn2AJSDq5IdT+YSkEKOMBwTVglD1mh3WYmQQaXQb0VeEJidqNY1ymeRysc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634668; h=Content-Type: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=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=eb7W1vZ6chqb6prshsomqiRTE6RwgcL0kF8lbNbUIVx2koXjCCrKusii53eLONgONlAKPfd+gal/cZ+ROXdHZyRCfzVpS+MRUXCg5AK01/nUiBuqvR9bVT7YyIXZj5qDinkWvjCHmyB2MEIC0hcvawx0oe3e/h8SCluEl2uncRU= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634668411420.48091162459457; Thu, 22 Feb 2024 12:44:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvW-00084k-RO; Thu, 22 Feb 2024 15:44: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 1rdFvU-00081X-Dc for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:17 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvS-0002mh-LS for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:16 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1dbf1fe91fcso494295ad.3 for ; Thu, 22 Feb 2024 12:44:14 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634653; x=1709239453; 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=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=BwJybVUgi2xnrQ57pHFLTv/mEiFALlbR3Kz7gHe3wtuRgyUpfyUYhUebVW0Bsx9lN4 Hi4YUv+1s801ld+UdygCPxTj0ylyXSGSbmx6J+jkgWdkE/fW3WiMBnWniXJy5GBPo//Z 8OovFSrrTPYa2r+F48xXssNYgr0+6qqK75NFAiwNosmub5YM6HuoKoiiZJI/FyfssQUZ qbJn0OusWMRiIGsv8DjvYtYoQZBEnOE3uAycxbL5NAE8/EROtum1f4BOjzIzfKFSWgl3 tSrWx8Y34zd9kM1yRRqzWNESoD67Vec2NQ9hrBrpPl3ROLsqCUZeQwR58i029ZpJGuw3 f3OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634653; x=1709239453; 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=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=sxbZrgPHkgkv8ibZzli2IcHqf+iZ/FerzfYA8yyWdfu8RZY3Is3UM23J92ookDKexg c38pT047slUkgq7a/nEgmmTYcwFxUGQIbXIANeXVqycsMGZtVFCFi2UdVj2b3Ru9rolf WPE5MN0Re3vPTFMpMFUkKStodOrzb7VPmth+WcKHe4lGudeLal1vLQ4yAN+yyhA4iON2 qjc0H/rAj6Kr+nLZFEtnW6UdtKTMN38edmsBQSu/QQxztKPOawTfjbbURnJnIqRAeKQ/ clJT+ZJ0ndSFqQT4LG+Eil2rROtv4ft505yVmUmeOkkrdubbZ6cmpIUy46LGG44AmbsP Tpaw== X-Gm-Message-State: AOJu0YzgJfHfnSNpysJBRzzt9pagMcNplx/0GCQ3LRdjbH9qgj31+w7P FADr409BnqSPTlzA5EX+emCV3VeBQGGNK5SSIiuNc/3lGeEJVxwhnXkmGSkFcPHL7fPX4bIXv2k v X-Google-Smtp-Source: AGHT+IFqMyFOP8gtE5UCMwokSI/QEG1OFkBf+dEJPKGkf6xOmKlE0YZ5HDYu38aANzps+iYI+onbJg== X-Received: by 2002:a17:902:8207:b0:1db:51d6:5889 with SMTP id x7-20020a170902820700b001db51d65889mr20211659pln.64.1708634653347; Thu, 22 Feb 2024 12:44:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Helge Deller Subject: [PULL 31/39] *-user: Deprecate and disable -p pagesize Date: Thu, 22 Feb 2024 10:43:15 -1000 Message-Id: <20240222204323.268539-32-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634669644100010 This option controls the host page size. From the mis-usage in our own testsuite, this is easily confused with guest page size. The only thing that occurs when changing the host page size is that stuff breaks, because one cannot actually change the host page size. Therefore reject all but the no-op setting as part of the deprecation process. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Helge Deller Message-Id: <20240102015808.132373-27-richard.henderson@linaro.org> --- docs/about/deprecated.rst | 10 ++++++++++ docs/user/main.rst | 3 --- bsd-user/main.c | 10 +++++----- linux-user/main.c | 12 ++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 5a2305ccd6..3074303b9c 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -63,6 +63,16 @@ as short-form boolean values, and passed to plugins as `= `arg_name=3Don``. However, short-form booleans are deprecated and full explicit ``arg_name= =3Don`` form is preferred. =20 +User-mode emulator command line arguments +----------------------------------------- + +``-p`` (since 9.0) +'''''''''''''''''' + +The ``-p`` option pretends to control the host page size. However, +it is not possible to change the host page size, and using the +option only causes failures. + QEMU Machine Protocol (QMP) commands ------------------------------------ =20 diff --git a/docs/user/main.rst b/docs/user/main.rst index 7e7ad07409..d5fbb78d3c 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -87,9 +87,6 @@ Debug options: Activate logging of the specified items (use '-d help' for a list of log items) =20 -``-p pagesize`` - Act as if the host page size was 'pagesize' bytes - ``-g port`` Wait gdb connection to port =20 diff --git a/bsd-user/main.c b/bsd-user/main.c index e5efb7b845..521b58b880 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -364,11 +364,11 @@ int main(int argc, char **argv) } else if (!strcmp(r, "L")) { interp_prefix =3D argv[optind++]; } else if (!strcmp(r, "p")) { - qemu_host_page_size =3D atoi(argv[optind++]); - if (qemu_host_page_size =3D=3D 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) !=3D 0) { - fprintf(stderr, "page size must be a power of two\n"); - exit(1); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D want) { + warn_report("Deprecated page size option cannot " + "change host page size (%u)", want); } } else if (!strcmp(r, "g")) { gdbstub =3D g_strdup(argv[optind++]); diff --git a/linux-user/main.c b/linux-user/main.c index e540acb84a..bad03f06d3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -332,11 +332,11 @@ static void handle_arg_ld_prefix(const char *arg) =20 static void handle_arg_pagesize(const char *arg) { - qemu_host_page_size =3D atoi(arg); - if (qemu_host_page_size =3D=3D 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) !=3D 0) { - fprintf(stderr, "page size must be a power of two\n"); - exit(EXIT_FAILURE); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D want) { + warn_report("Deprecated page size option cannot " + "change host page size (%u)", want); } } =20 @@ -496,7 +496,7 @@ static const struct qemu_argument arg_table[] =3D { {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "write logs to 'logfile' (default stderr)"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, - "pagesize", "set the host page size to 'pagesize'"}, + "pagesize", "deprecated change to host page size"}, {"one-insn-per-tb", "QEMU_ONE_INSN_PER_TB", false, handle_arg_one_insn_per= _tb, "", "run with one guest instruction per emulated TB"}, --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635104; cv=none; d=zohomail.com; s=zohoarc; b=eUPL2FJmjmLtd1ZZxfZi2rlyp7QLla3fZY7sPXgc1QQfnQVW48trNEmjiq6C6HhkX6/IAKDzTHqA3kx/rZvqXVrLetuQK0SJ9OcdKZ1Lx1WcfVVD6q5OmlQI+RCwP2BX434L45o+cNeKhfrWBxmMwJl6tEcs/YufZaPh4XxfNhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635104; h=Content-Type: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=udP+pGil6gAHeo/JHSsvoaPGgz4MOYyC4J6GT3yPeXc=; b=gJ146Cabt77bnFVT+FYsVKuOALF3ID4YeGAlhZPPJN07Nt4gC+BALsQOii585II1LyMg7a566me6fRnpIYUzBZlSrkpJ84kze2ED950VppHYi2e8izwPfzJqmNQpLd6fZmdXIfE7ofejSq5FSn9RpTMINw1+YD07CjsuENIiX8w= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635104926890.3561363001867; Thu, 22 Feb 2024 12:51:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvX-00085X-Bp; Thu, 22 Feb 2024 15:44:19 -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 1rdFvV-00081v-Uk for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:17 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvU-0002nJ-74 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:17 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d746ce7d13so735305ad.0 for ; Thu, 22 Feb 2024 12:44:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634655; x=1709239455; 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=udP+pGil6gAHeo/JHSsvoaPGgz4MOYyC4J6GT3yPeXc=; b=L35Wv8i/oAv4rLRX/wwXGQupBb2keeJ7y0nozbetbqxu/OqL2PmZQuGhTFJTmC8g69 8eGmDRQWolb9Q+g5o1SQiugFKkjOHsbMmZZFzNvKuoXSIclYMATmhbfW470jJ1RFqn8l 9FSaOe0uAogfLHSmzUrt+YDV5Y6L13GS8f5We7wQRVvuSqfOgcMN0TUJ8tY91VF54u79 UwOjLbCyqass88YLN1S49x3S/90yRxDzxDFlnhSL+p2lxqTxV+oV1DPAinwxC200g5hy ajn/9e0jnYujrc/4/V3cqao8JBNHWU61Xl37JhYfC9qAXwpFhjV5GgENOEO9W5NBsLjv Hnew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634655; x=1709239455; 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=udP+pGil6gAHeo/JHSsvoaPGgz4MOYyC4J6GT3yPeXc=; b=HcLhG26E2OIoR1s/dnrfXS0Bpxo2Z0unDGjGmd49KNtzu92QGhm0zLOOA1679rgBvh 9zi6DaCGObo1WazZt6+VdplVgg9PS1tWTd4Vnn5GE7uElajBFx5DOApW+KffyAj4Rjen NCssTC+iV1zM+68fqOfw8H1+KGOl/y7/o+gfwFgZdL0KG7v1mcDfKmWByPVYRs/oHf42 E+sGLM9YnpqoPOomwsywnnm4X6iZgyn4DDX8xsFX3RKVH4SVGu3chQDHwkSmRHzaCjeZ eSKxTJYiCpx6HZAhOe4PBIR1BoRXioNywvkA8IAbLy91bRyfL2+viy9ewI+wilrfvvm/ 0bPw== X-Gm-Message-State: AOJu0YwB89Xb9XP28tLOFvw0t1ONNw0b9LuzXJYYBOWtTGATX5oEN7TU 08zo3Ab92597foXl4AYEvqUKVDvHmK4SVzDz5wo9sfHuB7t/TnSzsQBRcmpk7puBXT5Tu0H+tKm K X-Google-Smtp-Source: AGHT+IHmRldTC2Oj1M+mEVc2bPTfcjkS1elRciYvXqFJwyVQ53+rYoa+Y2PpqeDUwSY3raIPCecSsw== X-Received: by 2002:a17:902:6f08:b0:1db:8555:55b1 with SMTP id w8-20020a1709026f0800b001db855555b1mr16310209plk.37.1708634654987; Thu, 22 Feb 2024 12:44:14 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 32/39] cpu: Remove page_size_init Date: Thu, 22 Feb 2024 10:43:16 -1000 Message-Id: <20240222204323.268539-33-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635106890100009 Move qemu_host_page_{size,mask} and HOST_PAGE_ALIGN into bsd-user. It should be removed from bsd-user as well, but defer that cleanup. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Tested-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-28-richard.henderson@linaro.org> --- bsd-user/qemu.h | 7 +++++++ include/exec/cpu-common.h | 7 ------- include/hw/core/cpu.h | 2 -- accel/tcg/translate-all.c | 1 - bsd-user/main.c | 12 ++++++++++++ cpu-target.c | 13 ------------- system/vl.c | 1 - 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index dc842fffa7..c05c512767 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -39,6 +39,13 @@ extern char **environ; #include "qemu/clang-tsa.h" =20 #include "qemu-os.h" +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +extern uintptr_t qemu_host_page_size; +extern intptr_t qemu_host_page_mask; +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) + /* * This struct is used to hold certain information about the image. Basic= ally, * it replicates in user space what would be certain task_struct fields in= the diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 9ead1be100..6346df17ce 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -20,13 +20,6 @@ void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); =20 -/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even - * when intptr_t is 32-bit and we are aligning a long long. - */ -extern uintptr_t qemu_host_page_size; -extern intptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_si= ze()) =20 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 4385ce54c9..5c2d55f6d2 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1179,8 +1179,6 @@ bool target_words_bigendian(void); =20 const char *target_name(void); =20 -void page_size_init(void); - #ifdef NEED_CPU_H =20 #ifndef CONFIG_USER_ONLY diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 1c695efe02..c1f57e894a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -256,7 +256,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t hos= t_pc, uint64_t *data) =20 void page_init(void) { - page_size_init(); page_table_config_init(); } =20 diff --git a/bsd-user/main.c b/bsd-user/main.c index 521b58b880..4d6ce59af4 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -49,6 +49,13 @@ #include "host-os.h" #include "target_arch_cpu.h" =20 + +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +uintptr_t qemu_host_page_size; +intptr_t qemu_host_page_mask; + static bool opt_one_insn_per_tb; uintptr_t guest_base; bool have_guest_base; @@ -307,6 +314,9 @@ int main(int argc, char **argv) (void) envlist_setenv(envlist, *wrk); } =20 + qemu_host_page_size =3D getpagesize(); + qemu_host_page_size =3D MAX(qemu_host_page_size, TARGET_PAGE_SIZE); + cpu_model =3D NULL; =20 qemu_add_opts(&qemu_trace_opts); @@ -403,6 +413,8 @@ int main(int argc, char **argv) } } =20 + qemu_host_page_mask =3D -qemu_host_page_size; + /* init debug */ { int mask =3D 0; diff --git a/cpu-target.c b/cpu-target.c index 86444cc2c6..8763da51ee 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -474,16 +474,3 @@ const char *target_name(void) { return TARGET_NAME; } - -void page_size_init(void) -{ - /* NOTE: we can always suppose that qemu_host_page_size >=3D - TARGET_PAGE_SIZE */ - if (qemu_host_page_size =3D=3D 0) { - qemu_host_page_size =3D qemu_real_host_page_size(); - } - if (qemu_host_page_size < TARGET_PAGE_SIZE) { - qemu_host_page_size =3D TARGET_PAGE_SIZE; - } - qemu_host_page_mask =3D -(intptr_t)qemu_host_page_size; -} diff --git a/system/vl.c b/system/vl.c index b8469d9965..7913cc28aa 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2118,7 +2118,6 @@ static void qemu_create_machine(QDict *qdict) } =20 cpu_exec_init_all(); - page_size_init(); =20 if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635126; cv=none; d=zohomail.com; s=zohoarc; b=Ek56p7WHnjCBzHM0fDyLBDQKWI6+6jre5woh/wTvNddCFR1/pIazusphfg4KaEHUCFHUWG6gA2gLvzsw1dKze1NtIDQ2WyNFMTxuoSiR2OExxP2ZlvB6tVBr75jP2GcAHlYPF+4nRi7LqPAyKgkx20aUQj9UlOGBpXMhS5QRHQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635126; h=Content-Type: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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=i8K06obGzRjGa6sg2tTH+1u94w3XqRv54iJqPUutjPilJmqC1VNQ2/muo8mFCdee9fHDyL+xxB1AFxEj+8kPHejsAH1VX2hjLo4QzgqJ0ePrdMxV1CESuQAtFHdkjSE4QTNUcYyDEJbGj8q43cYqdVEymJ+0sEB7G3ahU95ZP98= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635126711522.787373530033; Thu, 22 Feb 2024 12:52:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFva-0008Am-E6; 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 1rdFvY-00087p-Pu for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:20 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvW-0002nX-9v for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:20 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1dc139ed11fso10254735ad.0 for ; Thu, 22 Feb 2024 12:44:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634657; x=1709239457; 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=cewAROzRJluIMgKQAMvQECa8EoX7t/lej6g/hIyeFwo5xXYmld45rmlh9RBd/AkK+5 /RM+sfWwS7nF5jPCyCjLoFJugOwMCmJAfkBrvY9m0IsL8ep84ffShbGzhuuRd5GMDKs9 BFH+lkT1rbSJgqxg8nuOYsERpXpE6SYeC4oEs7D0tCCDXhS8mzFVrINhQQ8MMFXvYRBO SvqZqoeX0dpu89SWqF8JkoaNyV3/LYCNG436INlQvFqiZZTqigj7UNREzgE7jUWM+5gW gfD0xNipQKIp9A+UiMTxQirzAIVjkO9JC0Z4HWgXIuO3b44yHEeVe2mPc9yDwJA52qy0 xkKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634657; x=1709239457; 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=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=A6LeiEgzGA89m+1QVgHHQokuKkcUUn91pLWas0Y73FoYw5rY9WeN7WJR6SDLYP9fjK ZT1ZxeaZdl9aB5w5YFflzqhBnhmPYzl51n6scllmFigi7alkApZjGMJ1Oa4ACbyYbMf9 Q9AEXEV24G4fIb/rnhJPocDvmHd7gIEljpm8eWwr38LHtw0MoPiQdy6lKRoD3KqPGEhM BNo/Ns08CbcI9F+7ki6s5Ztr27FUmmTwDnE7ClAc76MpASoo5M488V5rTgowO9hhG01j dZ00x0RGLNhrGopaDj0wlJOWY1+mJsYKCGc5HjETXMdIb9ixnxXnlLwvZL2ksAYcInXP nkIw== X-Gm-Message-State: AOJu0Yx8q1U2zMZ7BPKWQCNek/ggdDxpoKNumTvWxsKeycS6QgpOgcZL V/uhSmOLz1FFtLDvzMFXwzFp3gbG6wff2pFtTx5P6Yw90lVOpzy5ynkYy8KjDjdPJJ+iFrV8yEI M X-Google-Smtp-Source: AGHT+IGKmEqptejhuqQ8Xh4Axro+8zv2UVti17Bt2ZCSZ72RESjA2z2OXX5LRtpSVZ8PZ7zTWsTFGg== X-Received: by 2002:a17:902:da92:b0:1db:f15c:85c0 with SMTP id j18-20020a170902da9200b001dbf15c85c0mr173183plx.33.1708634656959; Thu, 22 Feb 2024 12:44:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 33/39] accel/tcg: Disconnect TargetPageDataNode from page size Date: Thu, 22 Feb 2024 10:43:17 -1000 Message-Id: <20240222204323.268539-34-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635127040100001 Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-29-richard.henderson@linaro.org> --- accel/tcg/user-exec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 69b7429e31..3cac3a78c4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -864,7 +864,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *e= nv, vaddr addr, typedef struct TargetPageDataNode { struct rcu_head rcu; IntervalTreeNode itree; - char data[TPD_PAGES][TARGET_PAGE_DATA_SIZE] __attribute__((aligned)); + char data[] __attribute__((aligned)); } TargetPageDataNode; =20 static IntervalTreeRoot targetdata_root; @@ -902,7 +902,8 @@ void page_reset_target_data(target_ulong start, target_= ulong last) n_last =3D MIN(last, n->last); p_len =3D (n_last + 1 - n_start) >> TARGET_PAGE_BITS; =20 - memset(t->data[p_ofs], 0, p_len * TARGET_PAGE_DATA_SIZE); + memset(t->data + p_ofs * TARGET_PAGE_DATA_SIZE, 0, + p_len * TARGET_PAGE_DATA_SIZE); } } =20 @@ -910,7 +911,7 @@ void *page_get_target_data(target_ulong address) { IntervalTreeNode *n; TargetPageDataNode *t; - target_ulong page, region; + target_ulong page, region, p_ofs; =20 page =3D address & TARGET_PAGE_MASK; region =3D address & TBD_MASK; @@ -926,7 +927,8 @@ void *page_get_target_data(target_ulong address) mmap_lock(); n =3D interval_tree_iter_first(&targetdata_root, page, page); if (!n) { - t =3D g_new0(TargetPageDataNode, 1); + t =3D g_malloc0(sizeof(TargetPageDataNode) + + TPD_PAGES * TARGET_PAGE_DATA_SIZE); n =3D &t->itree; n->start =3D region; n->last =3D region | ~TBD_MASK; @@ -936,7 +938,8 @@ void *page_get_target_data(target_ulong address) } =20 t =3D container_of(n, TargetPageDataNode, itree); - return t->data[(page - region) >> TARGET_PAGE_BITS]; + p_ofs =3D (page - region) >> TARGET_PAGE_BITS; + return t->data + p_ofs * TARGET_PAGE_DATA_SIZE; } #else void page_reset_target_data(target_ulong start, target_ulong last) { } --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708635140; cv=none; d=zohomail.com; s=zohoarc; b=fBRSvrDxCafVkCeKATgux7DcaU2xvE2B1ChtWMjUvvhPRT+q57wzF/Ja4FU51JdgdxAiZV75VRTX+1rkjzCP/2Fm4G1eMaHuX/KBMMyNIUMfIIEJuvyJnkZ/0PP56LbKYIppTPtT4IxsYBA/2YxIve5obKfr9B8yqFvMOd1vWwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708635140; h=Content-Type: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=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=V+adHzpq8mbqwjVxl4mwwLr9diL5DPwAcJS2nKHz00ZddXrstwqNeWQ3NgdQEk7jWoGKt15816+05yFp+4Il2PC6UEI+7C4vl64NmMP0vBWqdXDuc2NdfXxQXdI8ovf6XHjP9cLFc35NALCtsRDNtdijltbPh9g2Do/Is/FOl9Q= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708635140888418.5920308613381; Thu, 22 Feb 2024 12:52:20 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AGHT+IG06JrflUAQqv79rhFaLmJaLmi6UpqZx3lE75149ZTqxcXgRF/X2cpbYEMlac+PUPuLyMHCOw== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" 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: 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708635143009100003 If set, match the host and guest page sizes. Reviewed-by: Philippe Mathieu-Daud=C3=A9 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" =20 #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; =20 @@ -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 =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); @@ -804,8 +816,6 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va =3D MAX_RESERVED_VA(cpu); if (reserved_va !=3D 0) { - int host_page_size =3D qemu_real_host_page_size(); - 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); @@ -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 =3D=3D 0) { - mmap_min_addr =3D qemu_real_host_page_size(); + mmap_min_addr =3D host_page_size; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx (fallback)\n", mmap_min_addr); --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634694; cv=none; d=zohomail.com; s=zohoarc; b=UAN+2piDNNg/KCs3zY2wKvKGTen55QxyhFxpe+mVkLmoopUyjbOEQcYJ4cVxtqqmAFYOWdRFY43W512NuyRtYfcisLNBNcBDvZz7m2+lkfQynafl80MKYEVgk/KSCNOyRKFN0u8ACh23oh7MMwy9n96PvGbh8+HDntCk1EUagGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634694; 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=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=dySo6ncxRzSeXc2e1Am1Pk78dwx3IbIoLwTnzHGrbg/Lea0uwqHhj1iDzE/iOrIAWYD4Zsue1MHqxYtQOi/ZVNlKsjsBPKczQVFi5pwLFllUCTRVkhWPQTnc5dn6WLDbw+P4txjgkeehRCycq4z4y9MDaqtGuxJUz5YaD4Ai1Qk= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170863469443510.712587608234344; Thu, 22 Feb 2024 12:44:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvc-0008CR-1g; Thu, 22 Feb 2024 15:44:24 -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 1rdFva-0008BR-Ts for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:22 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvZ-0002o9-8G for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:22 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d7431e702dso2274875ad.1 for ; Thu, 22 Feb 2024 12:44:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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=1708634660; x=1709239460; 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=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=MCW1gh4Z6LvjG6XcVCAqvXJL25fVM5H1tIDHvZuA7ZwuTfXV9aW/aY7Meb9ykuV/qm BnYvJ37vhQwPfQ9ECPgkbJXwlMiDRG8rXe85hqSwgMLtB4hBWT/aCfhZZO+SZV79RTph /mwA0d/7WvpxrbYH1rBXiiFL0bN6DK0/XPVc/d29QqU2eub7b2acDFcnMnSEd7ouQUMS PjuhnQFa44F59OGsJhoBiHPC+GaAhJhSV8dFV+cM5lST9ubwgVpWv11Qm4/pCPoYAfy9 GTbJThp2vOhHKOb8q/fNwKN2Vbh9GwaF1ZaF/2bMGW16il9mrZCFM2Vvs0os0XAXM8kp oLMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634660; x=1709239460; 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=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=l9EXCDLNnX3Fkf+fH6TeejWGdk7/p8QIWswoTmUAN4es/YL2nTYaP8aNIOHme7zK4x dA6+1yGaDQdEk7hMZM4mDj4ytP97i45mUM3YnwzsdiHgzx1fkhd0HsDZPjQSzZccM9Lo TsFM4Do1bBwmTI2EPFKz0YhVzuBeHl+POEWZ6ULhYOl1rQyKgcmPnZ0QPWlAks5EbbPB 4Nd3DWSFiZtTZO2rYBmqrRWdAxH3z4WdAhvTWexmL/57rWNrF4TN6gzlPE9xTtO6PQ18 UqPyh0+EtCQZvfeR/+62ZQVPE0ZlV+7iwvgECzKCuDkjKPUhO+SUUe+dGLJF0gF9MEgr 6WDA== X-Gm-Message-State: AOJu0Yx5dxXk+6gfvU8NcpPnjPzJbU82Ovl+gSCL/Vz/cV5d3KJQmJrn wD37iVrZMM28NBHcQHCZlwNuCQ0rI7eNJaC9hS5UNqSHI8cnizJHg9ylOgLSKCmEXmzDVZcNmI5 b X-Google-Smtp-Source: AGHT+IEdWzwPJBH6227neRzvDAzwO+ClwUrkcp8wmtteXbAZ/uHB7QPYFxb5urDKVHJU1wyJO0tQ4A== X-Received: by 2002:a17:902:6504:b0:1dc:4aa1:df32 with SMTP id b4-20020a170902650400b001dc4aa1df32mr2747689plk.14.1708634659940; Thu, 22 Feb 2024 12:44:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PULL 35/39] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Thu, 22 Feb 2024 10:43:19 -1000 Message-Id: <20240222204323.268539-36-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 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: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634695597100001 Content-Type: text/plain; charset="utf-8" Since aarch64 binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-31-richard.henderson@linaro.org> --- target/arm/cpu-param.h | 6 ++++- target/arm/cpu.c | 51 ++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index f9b462a98f..da3243ab21 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -19,9 +19,13 @@ #endif =20 #ifdef CONFIG_USER_ONLY -#define TARGET_PAGE_BITS 12 # ifdef TARGET_AARCH64 # define TARGET_TAGGED_ADDRESSES +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# else +# define TARGET_PAGE_BITS 12 # endif #else /* diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 5fa86bc8d5..2325d4007f 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1809,7 +1809,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) ARMCPU *cpu =3D ARM_CPU(dev); ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(dev); CPUARMState *env =3D &cpu->env; - int pagebits; Error *local_err =3D NULL; =20 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) @@ -2100,28 +2099,36 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) !cpu_isar_feature(aa32_vfp_simd, cpu) || !arm_feature(env, ARM_FEATURE_XSCALE)); =20 - if (arm_feature(env, ARM_FEATURE_V7) && - !arm_feature(env, ARM_FEATURE_M) && - !arm_feature(env, ARM_FEATURE_PMSA)) { - /* v7VMSA drops support for the old ARMv5 tiny pages, so we - * can use 4K pages. - */ - pagebits =3D 12; - } else { - /* For CPUs which might have tiny 1K pages, or which have an - * MPU and might have small region sizes, stick with 1K pages. - */ - pagebits =3D 10; - } - if (!set_preferred_target_page_bits(pagebits)) { - /* This can only ever happen for hotplugging a CPU, or if - * the board code incorrectly creates a CPU which it has - * promised via minimum_page_size that it will not. - */ - error_setg(errp, "This CPU requires a smaller page size than the " - "system is using"); - return; +#ifndef CONFIG_USER_ONLY + { + int pagebits; + if (arm_feature(env, ARM_FEATURE_V7) && + !arm_feature(env, ARM_FEATURE_M) && + !arm_feature(env, ARM_FEATURE_PMSA)) { + /* + * v7VMSA drops support for the old ARMv5 tiny pages, + * so we can use 4K pages. + */ + pagebits =3D 12; + } else { + /* + * For CPUs which might have tiny 1K pages, or which have an + * MPU and might have small region sizes, stick with 1K pages. + */ + pagebits =3D 10; + } + if (!set_preferred_target_page_bits(pagebits)) { + /* + * This can only ever happen for hotplugging a CPU, or if + * the board code incorrectly creates a CPU which it has + * promised via minimum_page_size that it will not. + */ + error_setg(errp, "This CPU requires a smaller page size " + "than the system is using"); + return; + } } +#endif =20 /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will overri= de it. * We don't support setting cluster ID ([16..23]) (known as Aff2 --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634913; cv=none; d=zohomail.com; s=zohoarc; b=GSUMD+q4q+oRqQuubqixrIyJQOH05zlX16YoxebT+36+sXm4Knq6s/K3dAh87lBN2HkjDdTJN4Wr59nvmbHows8ZSfnAyV8Jt1m7aYrIxRe6I5BM5JVHl3dsJxfdM2TnBWhk9WHsiMeijz00cbiMhFMhrr1QLUxAfZUIqySmpi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634913; h=Content-Type: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+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=cZbzCap0kW/FtjYz5vHH2HOLArOJwx9Yn2rIRtvdK4xyACRwo4nyNeIO19CnsFsp1+t6pmDIvzqqGvRYq1PS4ZFNVvqj0DGbRmgBSeiXftpiPVu/Z741/b1acEuOTIkdKoMmN1pIkJtlo4JnyytAG3wnZevz9YsBHfdBmyXALpE= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634913688628.6877611034187; Thu, 22 Feb 2024 12:48:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvd-0008I4-Ku; Thu, 22 Feb 2024 15:44:25 -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 1rdFvc-0008CS-1u for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:24 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFva-0002pe-LL for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:23 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1dc139ed11fso10255355ad.0 for ; Thu, 22 Feb 2024 12:44:22 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634661; x=1709239461; 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+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=RrxczqX+DJ4rzVYxr7cCaSq6WYI4RSotzi5F4ezjurSAHy/rOrlKz/QZ+Ms3gWACOM 5gdI5crYQrQC8xBYi1dRR6N2NXU69uDGr9MqwNifraFl6rFXj+FFSCpA2Tq6aKPEJLdx sFDbZfOGzJtWFUC+8Nru1fAc4bPIgKnoo4jix9fcyDbXu9dO7miVUWegZMvQivG3bWaw nqlxT9WK/XJVoHV+/4L4kQY5e+ZpetnR0bQiduiYgxoBGq7InfIm5YX8S+5YjBYOiFCW hE5JfIJvVb7aVyea50WzeqQeMBrzma2G1fhZM8YyhCt7cMVQHKYgBiZaP+9Q4ko3aQmP YDAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634661; x=1709239461; 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+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=JukUD7LxSbbu0sOsp8+kQTMWd+YUvn6ckBQvgrOhYqJyNmkI2jcZ88GyW3Pc53BjaS mLY1lwsdGOyQ/LRk8XlQruAq3golS6hN+eO5gSLBSrWNa6R5RtaMjYIOHQvBuwEYf/4L wRsJAD6Ul9csef615dxnVqVy6VIbXDkq4y5tCpuCsuDCecLd2H47ymqgKc1jnJt4CJMo fy31gLqJjbQCLbOcx4nUcPi1fRgWgvPDLgj8/+3W4VhUnzJTqYj9uT/A4/yMJT9bTYie DHlcHvp86UjDzgX7+CzSaMtVbNNO5JNWtJrbQ16U2CcqZQ5HZfwHjo/ph+9mmdAXZsK8 pe0Q== X-Gm-Message-State: AOJu0YymqH3UIzp2VIfsr5oAoyn0ydsz3aC6kJrl2xj6QaXYjShbFolK goUhbkNu/Pr1WhS7rab3bBklKX/swjUxqHEhXfllHqJ4hsZMkbf4qiyqfCd0f16HS/i1dsRh7fc B X-Google-Smtp-Source: AGHT+IHj4x4KoLMrZPuSmly4HIFtIoXiJHEcY/4fxE7YzC+IG65DzjnX8lBKkrLmgEMYNB7kM/k/mw== X-Received: by 2002:a17:902:c942:b0:1db:b96f:4a50 with SMTP id i2-20020a170902c94200b001dbb96f4a50mr206635pla.14.1708634661426; Thu, 22 Feb 2024 12:44:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 36/39] linux-user: Bound mmap_min_addr by host page size Date: Thu, 22 Feb 2024 10:43:20 -1000 Message-Id: <20240222204323.268539-37-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634914319100001 Bizzarely, it is possible to set /proc/sys/vm/mmap_min_addr to a value below the host page size. Fix that. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-32-richard.henderson@linaro.org> --- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index 12bb839982..551acf1661 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -901,7 +901,7 @@ int main(int argc, char **argv, char **envp) if ((fp =3D fopen("/proc/sys/vm/mmap_min_addr", "r")) !=3D NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) =3D=3D 1 && tmp !=3D 0) { - mmap_min_addr =3D tmp; + mmap_min_addr =3D MAX(tmp, host_page_size); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx\n", mmap_min_addr); } --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634970; cv=none; d=zohomail.com; s=zohoarc; b=H4wVVnLmU4i3XKFnbTLJGPlA7EfHApBP6h6n0ENaSrZ7qc5dGbqYx8j5nLnyZaBCLwGL074bjVkWxxtp8hKDzMB7z4FVYo3A+oWMosSHnkk+2tv56UKiPZAQh82s1+8Sp6/ofHWEg2RGRevZ1MDLStLlnhzLl1ZsJrqwtU3f1tU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634970; h=Content-Type: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=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=nEWvSOMed0arqHszo9RYVrmBpa45TuQnr203ms6YZnjuqoTicJalU6xfV7FU2j8+egGwsJlzPu37rzlbByIR9g8B/8qvIRckmxLfnx+cDqaUTmyYH9rmfyrvRA20PmwgISn/QpaWAs7fx+QdHxogAW10vmCFbtClKXey2c9TuzA= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634970551375.12256650316306; Thu, 22 Feb 2024 12:49:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvh-0000Bu-9L; Thu, 22 Feb 2024 15:44:29 -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 1rdFvf-0008U3-Kn for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:27 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvc-0002pq-1M for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:27 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1dc5d0162bcso613605ad.0 for ; Thu, 22 Feb 2024 12:44:23 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634663; x=1709239463; 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=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=QI42+2rj+7GidUYbORxEOjUYcCvca6yba9mtOkpm4TIhiDR/A+IPE/EAmnKUMw47Y2 IFF0bOYlGd0xVssNDAo+7hcGY87ceNdm3lvaPWIEDyVP+mQhw/JLSto0F6s9m/QVeTmF d2+c90ZuGfcSwGv5htTHoeQxEmJfQHGcOn9l3nH2fQdUP6/jBR21PM671bpf1VsAzs+M HEMXWhKVuFh6Ntns0RxFzfEFCXHb48bkCnM5/mdp05sWRvi0n+ldL8RgSOaSkQFgYNLO jfn4pzGUUJ2v/o3J0R8jZAedHH2yWuy4Hx61ZgElht6dJg80Zhme+2pwgfrK+mesHq7W Y5Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634663; x=1709239463; 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=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=X3bC1pbOScLhCTbKo7mMZfC426DgI93tjlj7gLnlSr5wQVgIX8UDy1h3cOaOIYhjIq LXFWosbSdAYPu1Rds/xIIe20WJsjj+gy0fGBgXqqg73x6QjRjFRYVByszSVLpf0TTwlj S7JvAKMf6k98KCVr49yG5Jd78UFrc3r0usoG/qIj5eaapWbPmkc50q9YiKVCT2TDse5f yAv47R4HDbYWuuwhFMWM3jstlPniq1rWvKvMT1sQ1du883OW7jYTCDscY840hWkbWMYb XbibqYAK/gsT3GZeJ2FerQ9/G07ipeLwSAAACqVeeQvdtnpwsNxIcEx77iCAqjjetxiB QPVA== X-Gm-Message-State: AOJu0YyZgVw8mBZApzHBCsReAag0nzGBLJ+LDO4Ko4C/CLghAK4zdiRw 32UtbvO2EY+xK1Is8u4Iv3aet8fzRQNZm7hA8Ypr83p76Fzg01yZ4igeEtolg8DuYyLwnezK4Bm r X-Google-Smtp-Source: AGHT+IG4megIkJ/DOoXf3Swsa/+1KpgVYZ2p24cETZIU/FgFKa+qM2MtubqK6bETL4ILS90GdrccSQ== X-Received: by 2002:a17:902:6f10:b0:1db:9fa4:c770 with SMTP id w16-20020a1709026f1000b001db9fa4c770mr14920062plk.34.1708634662870; Thu, 22 Feb 2024 12:44:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PULL 37/39] target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only Date: Thu, 22 Feb 2024 10:43:21 -1000 Message-Id: <20240222204323.268539-38-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634972480100001 Since ppc binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-33-richard.henderson@linaro.org> --- target/ppc/cpu-param.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/ppc/cpu-param.h b/target/ppc/cpu-param.h index 0a0416e0a8..b7ad52de03 100644 --- a/target/ppc/cpu-param.h +++ b/target/ppc/cpu-param.h @@ -31,6 +31,13 @@ # define TARGET_PHYS_ADDR_SPACE_BITS 36 # define TARGET_VIRT_ADDR_SPACE_BITS 32 #endif -#define TARGET_PAGE_BITS 12 + +#ifdef CONFIG_USER_ONLY +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +#else +# define TARGET_PAGE_BITS 12 +#endif =20 #endif --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634992; cv=none; d=zohomail.com; s=zohoarc; b=SxGu0F/kn78gmM0L+Vxo1DjhCAxf6lxEMzCRBa2L1mFwo09pCft/2LDlqPVxG6HYU1O6cUWTtIFvUUlofTDj+gvylOpEUAbNT7PXSorBJFSUgmvqRO9tB4JM+OUNUbzkbgfiUCBBefUmHGeYDPWasMmhFaid878mBQejEpTyFac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634992; 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=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=DNdH02OQ8N2T9MIO/bs74CoFX30WBog6MEqHKc+18L5BbC+qcRPJ/ulepQ24ZQ9/QwN4hw/+an8izx5RBBUCwsHnfukEZXA0+Rtyi9XhcJw6sySk/pkYq5hsHFzGRJvaSSgb+/1GVEzgfCy22HszUJl/gCA2kq+Tmv0zbairfug= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634992498581.8558430369551; Thu, 22 Feb 2024 12:49:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvi-0000Q4-Dy; Thu, 22 Feb 2024 15:44:30 -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 1rdFvg-00008Z-Rc for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:28 -0500 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvf-0002qm-3u for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:28 -0500 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-53fa455cd94so77017a12.2 for ; Thu, 22 Feb 2024 12:44:25 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634665; x=1709239465; 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=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=aapvMTa08l9dR6SGmYHP3k3nF1Jf7GTaTyZQI4KhzOYnjMQv1983H2ENRgrDL5wYDD lgSGkxCgLyW3qooo//o4xCb7Zkpm9fm0fdk5ITUx9OS9EPst87rsXXZ3ZRAGiRYuIp7h e+Jdjp7gv+51tnOZcbr96eAzV2EXRik61XXyyMYhqLZqidiDbznfWeSOvw+BCKcPUkzW pbuZIUlmdtF+SxI/HA1vwwUFVEgidvyIEinzwiAtmgQoiTdanBaxFyAM3G5Pn9NCPu/b ZTPCRrgm55BQW/jYJAC3JcrDeoBqF2TKNkV/e8ZGAZRFBJCAiVoGdI88XHFGGrGF4gfI 7FAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634665; x=1709239465; 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=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=sjlbrruH3o+1wRpcU41imEqBF5aJjfepTMjKyz0EZoFC1cb3aBiIlXRZb5AUSg8rWb BTfJxWe8XczitLkUg5JGoL+6w863QcEAf6xsi0NtBR/rlNu2hc8sWrMuKiM4O+QqP6gT rpSZCHI/cWID1SqJ1gzk8NfYH2FjgQGRLlnx/YL8jpV3FbAmHMuKFK9fmqgTHEBhVMFI jNm0icW89ngo7NlqQZ0P9Hu6wcZadcTeU096SAWD/q5rK4TqoEq+573S+YBbJUF1Nq7J L1rI0XJXS/2ohpbq1rG+5TvozhPYr0JRed8OnHubHXMv3Ip+4TBrAS5nzl7eaiKKTVN+ 7OxA== X-Gm-Message-State: AOJu0YwpTmW/K8fOSeAhEP78puNF9/d5JhTmNzFrf9zXdJi9bTGFaKj1 L6WA4nFaoP7nSTsEPBaXEwBKG6q26lR3Hup8i/sSR8DttjVcjggLO+EYzm2I49ylqmuHAbP+cQp Q X-Google-Smtp-Source: AGHT+IGtk8U1oBd9J2hNINjlM3l+J+lqFhSsY3Q2lflLXPqzceAc/B1PsZTo/7Lifj7hZJAlFhQftw== X-Received: by 2002:a17:902:a3c3:b0:1dc:1ff5:3dfe with SMTP id q3-20020a170902a3c300b001dc1ff53dfemr7073216plb.27.1708634664745; Thu, 22 Feb 2024 12:44:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PULL 38/39] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only Date: Thu, 22 Feb 2024 10:43:22 -1000 Message-Id: <20240222204323.268539-39-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 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: pass client-ip=2607:f8b0:4864:20::531; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x531.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634994543100003 Content-Type: text/plain; charset="utf-8" Since alpha binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-34-richard.henderson@linaro.org> --- target/alpha/cpu-param.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/target/alpha/cpu-param.h b/target/alpha/cpu-param.h index 68c46f7998..c969cb016b 100644 --- a/target/alpha/cpu-param.h +++ b/target/alpha/cpu-param.h @@ -9,10 +9,22 @@ #define ALPHA_CPU_PARAM_H =20 #define TARGET_LONG_BITS 64 -#define TARGET_PAGE_BITS 13 =20 /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */ #define TARGET_PHYS_ADDR_SPACE_BITS 44 -#define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) + +#ifdef CONFIG_USER_ONLY +/* + * Allow user-only to vary page size. Real hardware allows only 8k and 64= k, + * but since any variance means guests cannot assume a fixed value, allow + * a 4k minimum to match x86 host, which can minimize emulation issues. + */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# define TARGET_VIRT_ADDR_SPACE_BITS 63 +#else +# define TARGET_PAGE_BITS 13 +# define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) +#endif =20 #endif --=20 2.34.1 From nobody Tue Nov 26 09:34:34 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1708634781; cv=none; d=zohomail.com; s=zohoarc; b=B04m2cIGDKQoKdt45DcCLxWzCJttRQoHBZPchid8lmL2HwRaFpzPi0RhoDJBINsuJYYLhIIemKm2/V7QP1SgSs1biP5ym2V4Pa/IO6O6OTmV//llvOSuaejtRGhcCrVvjZv/e0X0nNVL+Ud6JIlZDvZbJf+OS7zgVMoEMpqEAEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708634781; h=Content-Type: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=8IHP5ncEs8tF3IKC2tmO2/I2hmkIrpcpNSR+zNTTzRE=; b=W8VUmWCNCO1j+cMpKWDeDyvcvqqVMfuCxQcH9rdxp7Tn8mREE8ytesPSaazH627aHdCZrraZ7NeJc8iEG+spD9uut5d+bPu5/k3C/QbBppBi/mEPh8zSwZXrEjTYyNwXyruKHn33AP8ci0JW5pAukAx1muldz8hWgL7RMyOe/Pw= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708634781673210.39840773012997; Thu, 22 Feb 2024 12:46:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdFvk-0000cw-8v; Thu, 22 Feb 2024 15:44:32 -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 1rdFvh-0000Ap-3z for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:29 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rdFvf-0002r9-C4 for qemu-devel@nongnu.org; Thu, 22 Feb 2024 15:44:28 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1dc1ff3ba1aso392585ad.3 for ; Thu, 22 Feb 2024 12:44:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:44:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708634666; x=1709239466; 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=8IHP5ncEs8tF3IKC2tmO2/I2hmkIrpcpNSR+zNTTzRE=; b=zFvQBNZ4z+cZKLLa9HO6ZhSEqZszskTadS7m3eeKK3dFB9jzelPniaZwmrZNzCCTAG HvFEcWhGXXKoVahl1CtmQ3Toj+UuJTVNbdUx/lOrLsS+8INZ46AXUvoZ8cKEJ3ePSOAd WkFSOGxQgFo3duVha/WEyIsckNAYKtz0vhBz7u6QqjNhu5lbMNf5o+oJRzOqCNsdV7tw aeZLWG3eNUyjYGFAe0i1m3Fvi6Xu1iE8RyJNH0w9mvNcPg25gOukssv+YvW6BmlRXZz/ D43Gjq/4ffgUPnyRS1qw+ebM8BNGzb23KRc47pakqcDiqMVcAplNSv7UliURk3L7shIF ryag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708634666; x=1709239466; 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=8IHP5ncEs8tF3IKC2tmO2/I2hmkIrpcpNSR+zNTTzRE=; b=DXqqBlkP3DP33Io42TBFcs1afZ0VzPsOpo2GRuEf273PL9I11NmyRuEPsCwAZZa8zG VFRZq0PFSqXstymtY1t/oe1BUbyRbU7NY03If30d3adIqCkoiS+uLqStxiV5gfyZr+Pt UiFry3Nh6voa6xryeJFtJqi+0JU6nEZWffrUe0aTApvBSvQpmA8vRhKXiBkQKQotojgd yJmhU3QlH8yHcvljzUSbfQowZ1KgJh510IpOiEuZ28WQ3EvyO8NKWt7PSJqAMUlklmZd MU8vq6WjTHr9I/shT1BAjmNbzBT+d2sDVrbbpV38eALGLg+TNxj+wF3ip2zGfaqccxfR dHGg== X-Gm-Message-State: AOJu0YzpwjoMt00N8+8hBvUv1JbuFQqv4bUk80e5clBus4+bi9DS34n7 0BxZg7yv4QBIGHBorOLgcOPF6W1S64SEM2OlTMG6hOD70LPvH57X1/TDKxmE9gPIeB1mJR07V4v f X-Google-Smtp-Source: AGHT+IHFEOzU9Tg4swhd+twq6hRB7UvutgSNhHJxmwPp3XpdY3d92zeLvbYD805AhfB5jiFLMum8lg== X-Received: by 2002:a17:902:8eca:b0:1db:53cc:1b71 with SMTP id x10-20020a1709028eca00b001db53cc1b71mr19682143plo.45.1708634666121; Thu, 22 Feb 2024 12:44:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Alexey Sheplyakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 39/39] linux-user: Remove pgb_dynamic alignment assertion Date: Thu, 22 Feb 2024 10:43:23 -1000 Message-Id: <20240222204323.268539-40-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 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1708634781894100001 The assertion was never correct, because the alignment is a composite of the image alignment and SHMLBA. Even if the image alignment didn't match the image address, an assertion would not be correct -- more appropriate would be an error message about an ill formed image. But the image cannot be held to SHMLBA under any circumstances. Fixes: ee94743034b ("linux-user: completely re-write init_guest_space") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2157 Signed-off-by: Richard Henderson Reported-by: Alexey Sheplyakov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/elfload.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f3f1ab4f69..d92d66ca1e 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3022,8 +3022,6 @@ static void pgb_dynamic(const char *image_name, uintp= tr_t guest_loaddr, uintptr_t brk, ret; PGBAddrs ga; =20 - assert(QEMU_IS_ALIGNED(guest_loaddr, align)); - /* Try the identity map first. */ if (pgb_addr_set(&ga, guest_loaddr, guest_hiaddr, true)) { brk =3D (uintptr_t)sbrk(0); --=20 2.34.1