From nobody Tue Nov 26 20:23:48 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=1704160791; cv=none; d=zohomail.com; s=zohoarc; b=RlsZJxtIhof7A1fXjji0WXy5uLmNAG4glvkHlak8mrR0a7Q1oT9F4A+5hIC5cOjzz1KtgiR936ojEkOT0q0vbn35I6nnbFIxt0OlsSgfe6Kp9MjQi8HHl3y09o5nTG6ls3Kvvh0ZlF99CwLOIyihrEk5QJS/ytt6St06nAo79MI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160791; h=Content-Transfer-Encoding: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:Cc; bh=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; b=Pc5YqQvlLs1qcd4M75BhStOz8ebNgHvHFDO8o2F5/tCZrKJ1N4NNm3zsMbKA/Phw3e6HKr4/kn+sjnOr5WRQ0A9Kvl5hjIZwPtxcdNb4BkxLrGIuwQOQGXrfI/zJvZMJCt2vk1akoXi6gzbsdpguW+tL/ZOTHmaumwCQUQEpd4Q= 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 1704160791884130.36974959439203; Mon, 1 Jan 2024 17:59:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU2t-0003Do-NI; Mon, 01 Jan 2024 20:58: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 1rKU2t-0003DM-37 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:19 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2r-0006yI-IH for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:18 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6da55cc8e78so1691795b3a.0 for ; Mon, 01 Jan 2024 17:58:17 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160696; x=1704765496; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; b=GwM1sn00+uFANYpDwleArGWWQbKqb+x2Ye8uELpxezt6ly8lDViscHGf9GLmTboUnL IZg+/ZPrF7HxqwANSXE6SNHe+X29hKHKy8Z38DIV79ry+DGppCeesqdHLq8eHiAJLd2Z ybZBziNa8SDpM0KVHQ3Ck8ZfvzUfeLdCjfLHZlC3StYzWyF1QyVhRMWU4FtRGOTwcGv5 cQ3rgLRdHtvxR5GB2oFpX7VaR73saI5OxTKViJwJiFl3i4KNP+a8hlf6Yc/VuFQJzO9I ZxvuCyprDe6yF8Mj7ChPn0JaEpOGzltnLKDtcoPwPNb/F9GbCDBhM0zoCcTxio7pBoXd /4cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160696; x=1704765496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wg9EFLLWpi5SohBEjtuSdGlbfZAlBUwGcqfT4yUFvzU=; b=xRLLyMUnEdIBmoTBxLlntkS+dBkeWBLq5GqG93Uootsk+pV7bdrQ3+KNLGc2WpFp5i Q47kg3anNqHsJFQO957a4JO3U3C41Eem88oTZ7duzzyJxnBZX3IZji88c5Csr7CfoPYr qK924bpYbHJ35ykSt3iu+Y4CjHa37ga3QVIYwobsDtCz2/rB9cdTQ2QQLY9ly3CpSHo7 u8aY9ayv1kQvTBcJ1D5LCOX69sdGLtk/0Pm/boI1swjlUUZ0sHFck2LEM2Ad3R41SD90 WC80RNVcgZ78a10FDxi6vHOoTVqJHdi/OktlN51dQWbZuBUDb6NU4ZQ7fGQkT8o86gbu KBPg== X-Gm-Message-State: AOJu0Ywahs/kArV8N7G/v6MEpw9J3/YjwqgfzPSrzsmmqLf2sZn2xnwF llPCSOqBUbH6s/Jl1WY9G26Bq8IGtJyEky8ljsO56Wi6Kvg= X-Google-Smtp-Source: AGHT+IECdaUnI10UzsbunB4hFlq/2/1tgvSo9ONowlHk6M1VhGmEJVJv55F2h3OnSrZ2AdldN3yvuQ== X-Received: by 2002:a05:6a00:6a04:b0:6d9:9277:b702 with SMTP id hy4-20020a056a006a0400b006d99277b702mr15270836pfb.1.1704160696186; Mon, 01 Jan 2024 17:58:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 01/33] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Tue, 2 Jan 2024 12:57:36 +1100 Message-Id: <20240102015808.132373-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: 1704160793231100003 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 20:23:48 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=1704161013; cv=none; d=zohomail.com; s=zohoarc; b=agXGh/F/saxh2HiuHfIj2gJlI1huew3YQcrwbHv7SKYoMdWalKcXCV+gxwe7c312DMqhX0U7jrv1Wfgmg2YELx0uWFydvOQgEd6GS7eIKOtZc/anIhGZnpFvRK6OPz7HqLWMDhqYf9I5J9PK11hXRzl+KY8HWUg6Vdx3fT154BI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704161013; h=Content-Transfer-Encoding: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:Cc; bh=l62Z9VXoyvTMtkttPIPmMaK8R/9tk3/QfUP+wlVNz/k=; b=Q4nJBsgLYnCtN9yBsHC6LnAUOsNUsVo87Et8DnbDJzd7Ua6dIg/0fHRUH7WU1fLXRpdpRqTQP5IMABl6mWh5QRibo+FNovTmtTW5yXr9ktUREro5NfIwUbGQOUcoqerRMP+l1hSBiKi4s4tYuCBNkSq5HWfP0lZEHjbaIsVP8Zk= 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 1704161013781806.2593583278444; Mon, 1 Jan 2024 18:03:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU2x-0003Ea-9K; Mon, 01 Jan 2024 20:58:23 -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 1rKU2v-0003E5-UB for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:21 -0500 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2u-0006yU-Dp for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:21 -0500 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-35feb61c91fso30808955ab.3 for ; Mon, 01 Jan 2024 17:58:19 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160698; x=1704765498; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=l62Z9VXoyvTMtkttPIPmMaK8R/9tk3/QfUP+wlVNz/k=; b=y4Amshy1Hp9nkLEcpNUUAsO/SoCyVfNmgYVZhmpwtW0lxL1xesQwmKsR5ZMf0lOgMz hWKVHDFBuT/R28bpz9WGHRtOdwDMn6XDNbBS15C+iM9SUUpY9gvtlt8s33ro2jsJO/I/ EN+tl1wIfFEv7IYun6REkwyLiLWE3XHfy2DPAVuOdwOZ3BuLUmXBToAF+ge1RgEjUAg0 gHlIcyc8txcKXHClJbPqxwQCNZzi+KWuiVww085DTeJ3Ao71ma/OzXMB5/9hBSJKHR+m zr1b03jjd2wKemSnTyDxb1ZvdKS6L+N1B8kZoktF0k17ANmINzW/O9tnd0q12oSqNe8H 8uFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160698; x=1704765498; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l62Z9VXoyvTMtkttPIPmMaK8R/9tk3/QfUP+wlVNz/k=; b=DVIjhloKMzMWCkGRZgWr3z0oEdVZYhOGYCa77uXeoIVUTx2791/DdUg9RDijclPLoD ruYL4JGrjftiRiZuRgKmQ+hYKCfdeZZfWZ0yLbLyRL3GlTb0xWk2vh2tE0WqjLISM6rn EILzqPDkgYVcXsXkdJD/nLWgrLCye2g1SX1B3i7V41AnoBCWJw4KmW9bosQVkKqssq9F 9/lIaVpv2LuG8WD3iA6ZF2BbcfaIkuP0q7S6AfWHRpISkOwAHSzivUPnz7gPRSCl8jGu Q/CcclMucMBls8exWXMgaZAypn+TrRLN4QCEd0LW/CWRztrIrkn+OOb8tPYJvxSTnmwQ 0iZg== X-Gm-Message-State: AOJu0YzemjoDqrJuzJ9+RwE5kj9GeQFp2b8nKz/ac78wTry3SCXvRcQT 7MSycHJd7unJCom2FDr1zbTjeo+kRikFKWOFTJqUGFbpaJg= X-Google-Smtp-Source: AGHT+IEMWqBKFdfumainh/u5vhap5ruY89ncyugK3RcufyB6OuRxZFoeCRrqKAdqlA/97KDDbaGKwg== X-Received: by 2002:a05:6e02:1c4e:b0:35f:d727:1dba with SMTP id d14-20020a056e021c4e00b0035fd7271dbamr14346991ilg.63.1704160698152; Mon, 01 Jan 2024 17:58:18 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 02/33] linux-user: Adjust SVr4 NULL page mapping Date: Tue, 2 Jan 2024 12:57:37 +1100 Message-Id: <20240102015808.132373-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::136; envelope-from=richard.henderson@linaro.org; helo=mail-il1-x136.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: 1704161015836100003 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 cf9e74468b..f3c1e0fb64 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3911,8 +3911,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 20:23:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704160775816612.6286686849952; Mon, 1 Jan 2024 17:59:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU2y-0003Eu-Dk; Mon, 01 Jan 2024 20:58: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 1rKU2w-0003EG-P3 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:22 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2v-0006yh-9w for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:22 -0500 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3bb53e20a43so7596303b6e.1 for ; Mon, 01 Jan 2024 17:58:20 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160700; x=1704765500; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3V4UcCieB3zB1M+n0kFdLlq+X9hWVNWezL6ktHMn9HU=; b=QOJ1/peMffkk8WtK+wkUiIdjqz7Ix6/gRwd2bpcT/+pTwGm4tuGhQXlni/F1ZmKxn/ VmoqK4TMEt2hCQYfGVFlWNuginiWMM1FWd4AtYpC8RSSBx/rhcHreS3+weO3DepDTQ26 nAJu53DLDbwhh2mzQcGQV90sU+ZDSBbjkf5kOKCTTD41ibaS10sgPsIPzr1edv8DB2Fp ppQR5w/uG15CiZWxf8+DxO0nw01Enec+x9mjU5A3wR1Cgp5V2+JQmJh464aKkVtquuEg JKxabwoa3dc3gwZv6S2ob3CShOCV9xteUIW3jXXZcX2jdB/tyS/J8GcAZmEHhU3muVQM DO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160700; x=1704765500; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3V4UcCieB3zB1M+n0kFdLlq+X9hWVNWezL6ktHMn9HU=; b=BSw7t6Kjt3XOMjrF54aDNzqxlGR0gK9Z6mU3MkubQbmCA+AGE6LFWXp9mn4jhHy/m6 coQcPLYQ4tilw58sbeSZiTup6GKiE/5uHKJH0C28tuxbTXYb1CNEx2pJJlaSyJr1cAm0 GeZi1FNUy429dZz31WGZdO7pCqz/v8RBCR62CDtz6WH0nTNrEgO5YX49ef5kO4vdUTlD x4vxOBr+AFh+Aw2z1TMMA4/oiiPPubxTNfbzV9pa3L0xIPmRU9MQ7qQMCXmxq8jj0Qyz 2RDKn7qCVekS6nOXx5rtA78owJp3p++sr0QeL+RhXxCC6VbNHcTIVRbZWfGRTPA1CzYt o5RQ== X-Gm-Message-State: AOJu0Yyper52RGbxBWo/Palq1AMlOhOYxDowx/2E92p69O5WAtVncBWU 3v2Hwz2AasTQ2oB9/BwW21IUTfNRU8aG4xuy0M3NAPlzmd0= X-Google-Smtp-Source: AGHT+IFRsv4pnJdcddbZEr/jtt+xsU3/JmVHdMKIKHgjzFQWkCp39oB54cLNwR82i/DvGzHG0FT6Wg== X-Received: by 2002:a05:6808:171b:b0:3bb:e8c2:e29a with SMTP id bc27-20020a056808171b00b003bbe8c2e29amr6900189oib.101.1704160700071; Mon, 01 Jan 2024 17:58:20 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 03/33] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base Date: Tue, 2 Jan 2024 12:57:38 +1100 Message-Id: <20240102015808.132373-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1704160777212100003 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 f3c1e0fb64..4df565d64b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2892,7 +2892,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_size(); ga->bounds[n][1] =3D HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -3074,7 +3074,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 20:23:48 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=1704160739; cv=none; d=zohomail.com; s=zohoarc; b=lxGRRTbUBvyZMkVFMJCespszvTIpZ4LtEN4BNOhcqbG399xFB37++WiAeEBejtjnBBSJWbq0P0g38n2GW49AfufCpeeCBNmIdJyzLdh8hdvYiZioPu4XVf6sd5VZzmVBBBJnwkiAWyJqijKzHrqoWIgLBoZ3zO8BwQMQBJ05A5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160739; h=Content-Transfer-Encoding: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:Cc; bh=HPXK9kHV+jGx1v/PMtKU+RQr0a5HO3R80iapTrtjCrM=; b=a70lkyQizlTDizXdtU2oPctP4ninIIl9iD4niz9n0pVbL1N5SIjNxQ9b9UfoFIyaLcriwGeBWymS6mer51gu1GHkxkppcioAoI7odXevmIQrFlmJVRFM56gdFLHE9laUK7blpPQKxYLR089xsDjw55nFgCgpg7XQid2ptqy981M= 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 1704160738996416.85818598900687; Mon, 1 Jan 2024 17:58:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU2z-0003F6-Vs; Mon, 01 Jan 2024 20:58:26 -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 1rKU2y-0003Ex-HP for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:24 -0500 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2x-0006ys-2p for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:24 -0500 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-7bae735875bso422555039f.2 for ; Mon, 01 Jan 2024 17:58:22 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160701; x=1704765501; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HPXK9kHV+jGx1v/PMtKU+RQr0a5HO3R80iapTrtjCrM=; b=wAZ29ia+o28Vbk/E3+aA8CMLwPSNXlbbEDb1V3okaFDhoB8N9SlcWu/kvA5TSloPsl goEYU2rhQGf9n1oxznHMvEREwrV8TzjCoo0hKHPSQLQCAK/R85m3F1d6wztQmKTb4NZP T4sB4w51fTahoSPBkCLvzKXqhbqZPDM4iNeZ0JwBGwxdMFJZ3BsKcawLepWTcQHyPlWn IFdcJ4XlpZSK6fxbGt3QwVezxc5w0GpvLArGC7+CLu3xQa3xBJeViVXujgarrSWUOMzd UMBKXSc0ptz5EYQVTGbrDeVvFtEX4zD6Z54OwNjIEawWk8m4u7CDI6bSkQIxWizJ6YWB yCSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160701; x=1704765501; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HPXK9kHV+jGx1v/PMtKU+RQr0a5HO3R80iapTrtjCrM=; b=Y/SAWzu8iRrv1k3ysmNvlRl69XMdocijaI3r3Uml1kHHYf+HTa1qgeekbrPCA9cQd9 XKFpxx9jd/kcCjdSHJku1rhJvu3bh7RV490XVQtKowUXnNP21yPk0hkntZ46D9KashOm uJ1bgkEoFW7UfGZ63rXlOmGHKqrR8djgCso9xN3qsDfW8fZsPzQ1FFYjwZLFVvB76LPE HBMHr2W1Hqxz893rAAKlmPG1Y6L40fGaSy1CkGg56tr79TDa6aSBImcaGVwCUu4r1kFu RkGVmIT+TldKXFigtHa9FFO3MddP9LKZyI2HbPQFwvyG+jHhPHCuGwLDTZxn4t4qUVrp kBPA== X-Gm-Message-State: AOJu0Yxk8uAAeyi7imHe1m9SHaE39Jp0GrOtkoMhOvfry2ixWgiK0A+U aa5bFKaGgzbl5llYK4IiZpbMMoRE3vcyiwBVuLigWdqk5VY= X-Google-Smtp-Source: AGHT+IGDKsIlqoL0o7XJJ7rt7gKDWlzIDWGOycliW9M0LcLG+x9SFSdfP8Q4d3byotxCoWJREhsuZA== X-Received: by 2002:a05:6e02:1847:b0:35f:b93e:6a7 with SMTP id b7-20020a056e02184700b0035fb93e06a7mr28136922ilv.58.1704160701787; Mon, 01 Jan 2024 17:58:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 04/33] linux-user: Remove qemu_host_page_size from create_elf_tables Date: Tue, 2 Jan 2024 12:57:39 +1100 Message-Id: <20240102015808.132373-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::d2f; envelope-from=richard.henderson@linaro.org; helo=mail-io1-xd2f.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: 1704160741218100003 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 4df565d64b..c166faabab 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2678,13 +2678,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 20:23:48 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=1704160732; cv=none; d=zohomail.com; s=zohoarc; b=Rg3nhjDbmFixUGQoOAp3AG7aPCn9YHHPWhr12v/WJ2652wJlpyHIA6dvkqS18iiL1KDAKPfNknBt/v3rT4FH8hoV2WaQmZYbhhQmxxUm8iAAj/sWuAaxIhsAnp0BtnbSk9efhNEI/4y+b7PFVREfZgHavva9/gn1u3jdg2zM5k0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160732; h=Content-Transfer-Encoding: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:Cc; bh=78dfRtxu5FZmtTcGt9x+K6ObYYej+Dd79lpS+g2uV20=; b=b1kP1cl9dUuGjebQutjBooLEsGpYvA9touwGAoDIUsZ54BYtSHI+dF4K3i2H7yLYrTCxRP1FjLB8ewOmPsC/X7fm7uxV5JAmvHagU4g7sEK358/ucnTebQi5cXI72Mfq4csIohLVsgnNoK4lX0pkW8uZs0+pHiLtyTXeTtFwM60= 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 1704160732594782.3729784229824; Mon, 1 Jan 2024 17:58:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU32-0003FU-Nu; Mon, 01 Jan 2024 20:58:28 -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 1rKU30-0003FB-DK for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:26 -0500 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU2y-0006zi-Vw for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:26 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-204a16df055so4590524fac.0 for ; Mon, 01 Jan 2024 17:58:24 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160704; x=1704765504; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=78dfRtxu5FZmtTcGt9x+K6ObYYej+Dd79lpS+g2uV20=; b=KoPkmBNn3fsTzzfZDDBD4glny9XDdl280EzeqRlta+qii6RVGKRu2WVo59pwr0vGLS TyguKSLoNiKXI0Zj0v7YxptX0FXycyZ/qAs1GVY2cZFYKX7KcKOkivlcKXODD5pnRSgR zxr51xGeDa/xSkiuRndef+WN2/iSb5GClkA/FS8a8borZNyqf/4qKWxWivWT29VIZQ3x ehJGQiqcmsaP7LPSHbElyHJz5utRwix0Nle4P0JIJ68Izm7GRjJhI7l5oJOhxDyOoztZ YF6FrRByE35gO7dcwO7Cx16FNIFoSaaMryZoEuCw5/3wdEINRVQKkcD4jjK478AA8cLP YyCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160704; x=1704765504; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=78dfRtxu5FZmtTcGt9x+K6ObYYej+Dd79lpS+g2uV20=; b=qH1SS7e8mJ/mPH4sLG+fnOT/WPzIi57Lj1zzVXREl+2MrSCW2Qx+jyeRWVzljMusZI n1Cx5uqR1D/T7d6mTSAMApQHVQjUxjpDz1/nQJZG0uYmD0/z+KjHJtGiUpRQtDQUrpqa tJjUx7vQK2mfsOoWnYVeJpkvByjCCDBo+EGYMUTy4u+9o5UMeal5Ek8OfFM7O6PJSQex kZDLnFgODJ0+TdaMbYLT0sxJdDU+NuJYPyp+trR0+6dK/ko0RrEKAf4Bdh1wCuVHbnTH YM1m+unoZ5nqpG8qO50K7OGY5L8XrQ+ehpQwtE1TX3zy2gKwH58jnLMjeGBjBGXGMufd 9HSg== X-Gm-Message-State: AOJu0YwOSp3IYIE6odHEXqltDx2XhaGZa0yAie9SvTqD+xWEz8BfdjoM f0tAnKb0S5fzmYeGgcAx2z26+hb1OAcf9xsITQSHBiUTgTQ= X-Google-Smtp-Source: AGHT+IEKcu6Oot8nb2g1mvV+10w5DCuNUI80lw1mQ+rZ3vv5cqmuKCdtRwqAtD8cWnFSaYjhfOL78Q== X-Received: by 2002:a05:6870:558c:b0:1fb:e34:e31c with SMTP id qj12-20020a056870558c00b001fb0e34e31cmr21828007oac.37.1704160703516; Mon, 01 Jan 2024 17:58:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/33] linux-user/hppa: Simplify init_guest_commpage Date: Tue, 2 Jan 2024 12:57:40 +1100 Message-Id: <20240102015808.132373-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2001:4860:4864:20::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.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: 1704160733332100003 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- linux-user/elfload.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index c166faabab..96d8d4f84c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1969,16 +1969,21 @@ 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) { + int host_page_size =3D qemu_real_host_page_size(); + 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, host_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 20:23:48 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=1704160973; cv=none; d=zohomail.com; s=zohoarc; b=VwiZzU+i5TB+zMEYTiyOFm5U2pdOwdiYdYV8jLQ0UFdPgJUr8jFG2drJlLmicOep92OtKPobA2R0d8jxGFHJjkjAZ559zd1nrFTeKFkJKbiMfu0a9WrH3RsBnZdij6F/HOkl/JJ77casYM44ala+Ter8Jec+lihK6tDNBJ92pfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160973; h=Content-Transfer-Encoding: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:Cc; bh=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=aQ71OCjaGKi/oBrBj240y1XspWYi4Rhd3QjMB3mmmfSXYDj9A9Dl99iLh8tCwFTjyTjd2gslq5wB+yWvD25ZhEE5yB1wJjCNmSTN4ORrTGh1RlXtpNWndgqi+2ppOJ3C/zBTPbwSXIhdjfn6zDKTJi4fsT2u54huJV5LIL5pyP8= 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 170416097397327.46473455272053; Mon, 1 Jan 2024 18:02:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU33-0003GO-MR; Mon, 01 Jan 2024 20:58: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 1rKU32-0003Fj-N4 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:28 -0500 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU31-0006zz-9g for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:28 -0500 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-203fed05a31so7078298fac.0 for ; Mon, 01 Jan 2024 17:58:26 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160705; x=1704765505; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=iliY3WQORQojL66bodB69O5hvrV+cAO2r9GuP4k77jVbyDV+zU+LBkfaFtzHo8Eb6o nTJb3t8kx3+UzJmCXDYv9nElccOaaKojTFvfgvgicZGLP5GftFB7SWmspzZZFR3G8sbP EzOgYRdBCxRPvTRe63Mh324Me3SDiBSfIwbtNqCFuFtHCfH1Hceh0ISOoPPyon31y0+C wI6S5C0oGMNIIiZbV5wjH2s2KrjYzm4sWIlSLNM+ny/9XssmquWp9d0BQJDb0/rEpaKb PlZbrsLHYQ1nAr+bD5eFfjcnDlOQcIbjhrQ92EFOg7K8m6wDULdnkkL2yOduZYAWj66U W+XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160705; x=1704765505; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=doJtWyMStqOAlo7bZL0mf6PIzbVYMD2KRSmUqFYZbbM=; b=N6zzk2d9laBlkO7CnuyV4gDpCmcIDJSTlNBIK0piLyUEez0rOz8RlsIMANXcbx8NHo 0YYW6Wsh0Jwro5E7rf0M0fCAMEVghsoKplSFsrzR8FX29rSfo38vheYSInI13p0nsNNy uk+28eKacVOl703LShIRNACWqNYgGdoNh4gPQSN0h+XrYPj0q5+lJnyN3ZPV3YDp5MJ1 6kuEThe1IqnnaSPD0O6Yzi30ysM3j0X3fzyWt1CIbgIpnwNDOKb7KEMuIfBSe1RNvxyD Be7Xl3sU96IB2YOy0rpOXVdShv5xYVVtf5jhHm8fkV78Wsx0GY0BTExt8lFkldFmbcZN DJiA== X-Gm-Message-State: AOJu0YzTsCwSbHsHBuX9w+Tt9e5mzYktEbYo2L6St6ePdQzcUKpx424T CtOSLFdziMwn0gn+rvc6ZRosw1J0pPL25ABcTWiImzgEmA0= X-Google-Smtp-Source: AGHT+IHCCh9Re7FIx9x17Wv2DnDG6ExxZLinFRQKjPxkht/v3c4eFg1Yr015/3PaAW3FuXFBHe1eZw== X-Received: by 2002:a05:6870:e38d:b0:204:2bc4:87c9 with SMTP id x13-20020a056870e38d00b002042bc487c9mr18563179oad.86.1704160705491; Mon, 01 Jan 2024 17:58:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 06/33] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Tue, 2 Jan 2024 12:57:41 +1100 Message-Id: <20240102015808.132373-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2001:4860:4864:20::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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: 1704160975747100003 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 Acked-by: Helge Deller Reviewed-by: Pierrick Bouvier --- 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 96d8d4f84c..4fcc490ce6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1531,10 +1531,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); @@ -1543,9 +1547,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 20:23:48 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=1704160762; cv=none; d=zohomail.com; s=zohoarc; b=XkGVCguHX2VF5HEyOjVuAUMwIwO3SRCB/TzHBYdD+pe9J8e+GxSACVJZSER+pOy2++AhHVZz1n2XGxMwh2KpZoUka/XXZ6ZVYjL26gIhrrj4msWRpnwZc7S6JPqx2eqjGsHAEmIhF/WB7Th6MHgwxkuZNi+IevhYUKTvmGZnOfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160762; h=Content-Transfer-Encoding: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:Cc; bh=ZDwDZzgZPSCJA7Iemq6JqoeDjmqj1wl0Di9VaTuvxi8=; b=eLHaAsjJWkzxNCbTNwuQcaX8iPCxwAmqIC+iPWyjP7Cp1Gumgu40Apqu7V6XFf0cjBHpJjF5Mstj8POouUu0/comozA4L2Yzk+plAHADktK3mSY3vYcTSNE39fo331oG0zPPIsmlMmDZQYCzmOP+PkKUVhmCFfbeZGRTNVoKP6c= 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 1704160762461607.6441429120833; Mon, 1 Jan 2024 17:59:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU37-0003Gz-8W; Mon, 01 Jan 2024 20:58: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 1rKU34-0003GZ-Ds for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:30 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU32-00070B-Uv for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:30 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5c21e185df5so6727821a12.1 for ; Mon, 01 Jan 2024 17:58:28 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160708; x=1704765508; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZDwDZzgZPSCJA7Iemq6JqoeDjmqj1wl0Di9VaTuvxi8=; b=k+BMJAhji4QtB6AlWIpbaNLh3A+Z1M+I4MDVRDlhV0r4IQGCdQFX4MBXTdUCN99il6 BDLKdN/PZrizXIYQQ6HQng2grRIjJ50ngsXg8xRsGZomChe+O9Kd++vAoj2sM5pDxY2Z azbC8D3gyqwlQC0SG23u9MInKDxS/a74V8qDOK4alY0zXduV/E5pKBXmMMtuZFrNjQY1 VWywLsaOPZIQCDXH/DRuuxTGQctUakDX2BAVeoBpqWzGs8cqptQTboilrk7ME4dUeluV BvkXrZbpbegJi1B9EveU+DKLVLvn04qHsAefMQkiThfFqUxum5gBiFrWgsnzgGPeISoU Mrcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160708; x=1704765508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZDwDZzgZPSCJA7Iemq6JqoeDjmqj1wl0Di9VaTuvxi8=; b=vMPOWj1LF204snVDetuRNIboGB6fZTSTYpGnDh0tsc8x8a/FI0gSa6iHY3mdT8ymp5 N+TgwRU+GZ1GY7DcZQMjpQnH7HldyHPNJ9GdIO05CB0jBN4d7RJ6knd8S0BIjnhaC9EC 1TomD2ekqbmMqdqivb/79f1Stp8BLyEH4E4A9FMx8WcZXNwMEfsswlQNAi87kz1/EAxx ewIxM7mrybO0VCaHaDjPX8NV9MUymxgckjpHIayGzMTvmXTtffrYmsFuJfwL5w7eN4G1 ZhBixHSERbBDgLli4lV6ulW1b58lrs7h1JbprOv9YcFtjI4p7fv3cDUw2Zt4/2hK5sLx N4jw== X-Gm-Message-State: AOJu0YxkYBpwpsWrnnSUO3W0D9L38I6tKDZyH0Kn37dgPrjxqlDX7opj kyrNPPQzCrvkRLNZAeGx+KgLAL4lMWUjMgGSXblPEUTP4Hc= X-Google-Smtp-Source: AGHT+IE+o+9kMFWMMIBfJAl3GjjWpR2UEpfrPW9oTQPzc47uIEhx8bpL4Z5joWOworC2H1zkZs7PHg== X-Received: by 2002:a05:6a21:1a9:b0:195:d8d9:a193 with SMTP id le41-20020a056a2101a900b00195d8d9a193mr14856787pzb.77.1704160707759; Mon, 01 Jan 2024 17:58:27 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 07/33] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Tue, 2 Jan 2024 12:57:42 +1100 Message-Id: <20240102015808.132373-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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: 1704160763269100003 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 Acked-by: Helge Deller Reviewed-by: Pierrick Bouvier --- 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 4fcc490ce6..2e2b1b0784 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -459,6 +459,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; @@ -471,10 +472,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"); @@ -487,12 +490,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 20:23:48 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170416076381650.59784843715454; Mon, 1 Jan 2024 17:59:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU38-0003H7-82; Mon, 01 Jan 2024 20:58: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 1rKU37-0003Gy-6D for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:33 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU35-00070T-4w for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:32 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-2043e721daaso6235288fac.2 for ; Mon, 01 Jan 2024 17:58:30 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160710; x=1704765510; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6oj7N0j8k7lH/G5CYw2mFZpUqD7q71OK17K96jHMboM=; b=DPHKoT8rnWBxAgUSCLcjcYa5CuZPks/hdsO3sbK3TiH3am8DygSaNTV4xYynZnbLkW nIXISsOd9P/pJ/DKHBcyBQS+UfAdePuIeTNgejEYMcs0LHpfxFxemp9eQkLZ1UzkdZlH v3Qp3YfDMWmini6tHQIyRXWihFJ0A1OLcCNVjj1z6wGPYbtuMWN4NIOOlrPcqJbq2dZu tKRGhSuluEB/VB7aCSYLIzrQnnXVm+qTLgOytH+1H35SlEx0LJFyMWZy6VQFF/MEptbU dSbyCr7K7eSBsaerc1uZp+PHEbBcJ8SsejmrehinTU8aInmd6qFHtI+lUzoAs1AhPFoy VukA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160710; x=1704765510; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6oj7N0j8k7lH/G5CYw2mFZpUqD7q71OK17K96jHMboM=; b=Y7n2Bv+49Y4LSXU2cKgPBxP3+gMe5+7O15WaSx1+iW7RQu1xWtWvawkYmH6aNwxVPG VHLzAhed6hjmuVVD6oPaGR0I/s3KhkmMgTjoim4PBDoX1mJrKf4JK5JFUOXt5Rt95+DY x6Hek4Matxflm1zOirFgA/TCHkyPNGR8F1WDEtNCf2YsnrGiNVo7O/mpeXEcL/rUo/dM rX2is6QXbeKGOcblH+6oiyqO1oXLkyi7dnZUkOegC0nQ01FpgKfBdTIwD+9SSouAdn81 MvhYeJHLGKg0k+TPVZDwIihYxGyJgSvm22dc4s+YPM8NYfOOa29MkFXItAqNG6HAtG8d Ahkw== X-Gm-Message-State: AOJu0YxE83KuHGdNPJqyACt7x/uujY+vaEym3CGJxvC48V422PRVcehl zY998mgdU4H1av8wiZE6+Cz9eGSGsLJHnLLTn5/F+Lt1o0A= X-Google-Smtp-Source: AGHT+IGHB1JiCLS13UMEUf1pC0qnI3L4u3pFrbNdZ1QQ+GY7HEXuOUpMwfgAZjN7J+uZRyvzXhfRKg== X-Received: by 2002:a05:6871:588:b0:204:3f62:a8a0 with SMTP id u8-20020a056871058800b002043f62a8a0mr18792889oan.71.1704160709915; Mon, 01 Jan 2024 17:58:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 08/33] linux-user: Remove qemu_host_page_{size, mask} from mmap.c Date: Tue, 2 Jan 2024 12:57:43 +1100 Message-Id: <20240102015808.132373-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1704160765243100015 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size instead. Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 20:23:48 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=1704160732; cv=none; d=zohomail.com; s=zohoarc; b=BB20GOIMQJDUvk7gVqUazAVzsnKaLt3JMQnsjJMVgRbMHrj7FDYjMX/aemeh6C1VCM3/X8lCWX+xGGdXO1enM2BFlTcwEIcpTjqOatVFIdhlSUmaFu/lRw8py07kkXrmO9al0GHJUug4wGOcYQK3nf2hd2xxsN0Zkz4C19qRgTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160732; 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=7qyMzlpzWlHoGSx0bplKdPfg7TJkUYYgysQjBpEEncg=; b=Sh3TcVc9HowLXCsQItRAP8lIA+e04zuxuYa4ktbHHBHKZQQtS/mqp3j/6jRFJcYdwMGkcOS/IHKaBdWsTkdZcZr1ncabvLGvyL5o9iQec0N6ctEBLHoQjEjw0I3jFrNV1cI1W4tk+h0pQY1g8kr3xyWNwrl+VGsGslKSdcyykII= 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 1704160732519695.4841587225761; Mon, 1 Jan 2024 17:58:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU39-0003Hb-Rv; Mon, 01 Jan 2024 20:58:35 -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 1rKU38-0003HO-Qd for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:34 -0500 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU37-00070a-97 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:34 -0500 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-20400d5b54eso7076022fac.1 for ; Mon, 01 Jan 2024 17:58:32 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160712; x=1704765512; 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=7qyMzlpzWlHoGSx0bplKdPfg7TJkUYYgysQjBpEEncg=; b=wCrmBHiQBmvk9tFIhNgjBNYnvBQ2v9j5Occ7+z4qOupkZyPqGIeiILuSFzaJhnM/Sl ffTVI1GH/uzK3XAZBXhwsdSt7+mhCGsKKd1sw63EI44R2hj0d96Dx1GJfs/JYVkOIymj tIwibiFbrN5yMh+Z0swkLcFwp9UvkIsXjzObyeXLy4Q3fNYRy50dLXXKmnLbWvOkFbop EUR3vpF/wbMerOxM/2B5TA4oxVwIIpVBAQSVYrncE+5ZuqRDAJTdCYP3XVUqivSxJ9F6 STBTglV+Ie7aXXiMc+l3TMaAsgI4Jp5gJM1UR8doZJY1hjViWJumWETp821F5FpywWwl 1+vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160712; x=1704765512; 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=7qyMzlpzWlHoGSx0bplKdPfg7TJkUYYgysQjBpEEncg=; b=f+4hfvxu9Xvryp/jLfrC7ZiGtG9YsIxrpSIhGaFSYi2NZ5SJEiugxdEYSj+K7gPlSz lBdd/H1CPp/nuTx5F+Ii65py04wQnqjauYdogkWaoYuq7jt+0Fyrx4uxxm8JOWtusg/c ue3/kuIswi3Aksw3u/YQU1WX7r1UIHtxVBge1J63zrXwQMDlR8rqUg0Z+sXhuhYgTDRH TrfRYHrdKPlaFA7qsHBC3gHujX7VwfpUToFq7JY6EldCPZLO0RAZ3u/Is6J8q3o5+mdV /TShTn1ImhuC69lCfUgd6G2yUM049rfVLcPRFo5DdO1T/7dXdK+c0LLsC943eIzayIyq tCXg== X-Gm-Message-State: AOJu0YyD+w0J+1QoS59w/JJDuSfSXhH+v7sBJ0vun2DaX2wFqXXLTUmG dEt9opAuuJ+QLh0zkSIwt4GFS8YodsW8alWPPrsZwk4vtdg= X-Google-Smtp-Source: AGHT+IERAvOAqKRj6cRuXptjlkI/bmbiVJefHVFdswW3OVZOHLN8smhyxMDvUhSOyw+pi9RglhCPmQ== X-Received: by 2002:a05:6871:5228:b0:1fa:dac9:1cd2 with SMTP id ht40-20020a056871522800b001fadac91cd2mr19439525oac.27.1704160712082; Mon, 01 Jan 2024 17:58:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 09/33] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c Date: Tue, 2 Jan 2024 12:57:44 +1100 Message-Id: <20240102015808.132373-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2001:4860:4864:20::36; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x36.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: 1704160733336100004 We already have qemu_real_host_page_size() in a local variable. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich --- 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 20:23:48 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=1704160979; cv=none; d=zohomail.com; s=zohoarc; b=LP9gRwvHVGWSCckFVjOWzlzfviwoE7vkVpTo04g2ANF15lSd2Y1McHhdu4P1vX8fyJMWzVND1j7NZwjD2eggyGSzaa3qcFt0KMUgp3AjThz2kzG2D43h/Z6ZCmb/iri0isJpD/0FRvgzcYt8Ox42dENbhgkK/DVV6uy8Jp0cbhI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160979; h=Content-Transfer-Encoding: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:Cc; bh=m5E6L9ef0SVPlAxhBuGX4coZacolJ6Ms5EPcHyzN0k4=; b=Rb1vpD2HfqVTJdZKbSUTaCy3SMhocYiwoBzUWM4Mx2Y3sHwTk2Su9Dl7jRwPWECeO2UPMaZYQCMdKJNc8BMDsnbYJvc6I5++fPozBbMamz7Kpvts+H8cWATxAYOzHu6gEqKkC6gF7aKDmVURK5Bjq5r4XOuyh90EoMhRbN6/1G0= 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 1704160979521192.83510595297537; Mon, 1 Jan 2024 18:02:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3D-0003Ik-BC; Mon, 01 Jan 2024 20:58:39 -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 1rKU3B-0003I2-Rp for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:37 -0500 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3A-00070m-9v for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:37 -0500 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso7046983a12.3 for ; Mon, 01 Jan 2024 17:58:35 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160714; x=1704765514; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=m5E6L9ef0SVPlAxhBuGX4coZacolJ6Ms5EPcHyzN0k4=; b=v8RG6yId8v8SBxspgXrUD3q43RL/Ekkcs9gQdYpa0lXhej13t+tZ6rU/mRgh9AURgn CvEBEfSpsJGlJvVoiFDfc45rLKJHRovxguVDLJxk8+2Kz2zKIZhGlH2/Bix+ZIF/DVTl YaN4lU5HEp5XpAZysJqYab65BmeWMq3Ctmbjia6cep0Tqndbvg0hvkmsrbLJ+Ww5E1Ln nPphpBPrggTUezLPwdbrnLtZFZPWeSf+SRrz68QFrFAV95DgVh7EuX69YNE6W91bhJqG znw9iiPovJRR7AofpO9s6ESZO2tCETvO0EgEbJfObz6s2AYbA9dFgBkv+RWwguI4pt+U 0LPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160714; x=1704765514; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m5E6L9ef0SVPlAxhBuGX4coZacolJ6Ms5EPcHyzN0k4=; b=YjwRkTMhcYpMZZj476D+KUV2O6OZ8nRyW7HGa19FrQWilaAslgSGr+PtwReJL6vtrQ 5qmkVY1GZtOTORnQ1SXtVeGdBbev5w6g7aPYZQEisDf/bdh0ObcKg9dfjRMjKpkqcCrM 6IYSWn5KLCjDnfMnQTdudE3C3J1XkSfCIxFEI1AEFgBaIiPVtDQh770u/IFTx8wCHV18 HtyLTEp5Gy6MFJdWTfmbIs0uzPLxUx1B6mqPpv/wOtqUD5JhOH3MACiFD7qb4VrcJDMl t72ntleJosBjqtePkayJ4ElZpSRndEc93dcMvG1r7qIiIQ97mkvotj0jrJbcg8n8gecS c0Sg== X-Gm-Message-State: AOJu0YwQZTocKHmpfvk33Zr34gx+dIHmu0WN1T6weDHl7YMho1hnWW2v +NqN2lUQn0+HZQeJrYWbHmgM0q69Kfn+AhZ8yh1w9ajKrlM= X-Google-Smtp-Source: AGHT+IFmvA8OXDGhE0dFIy//tPSPj21k84hy0717YKqkNzuuG91np4dAZlCYCAsS541px+D402uFyg== X-Received: by 2002:a05:6a20:9149:b0:197:d2d:1c0f with SMTP id x9-20020a056a20914900b001970d2d1c0fmr3019289pzc.87.1704160714045; Mon, 01 Jan 2024 17:58:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 10/33] linux-user: Remove HOST_PAGE_ALIGN from mmap.c Date: Tue, 2 Jan 2024 12:57:45 +1100 Message-Id: <20240102015808.132373-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::52e; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52e.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: 1704160979750100004 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 20:23:48 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=1704160735; cv=none; d=zohomail.com; s=zohoarc; b=MufwtaATEQi9oo+Qjk+mYFHswgSMstGh6M/K3zhPDeLPJQ6eBryeSsfeCConJ+ie48e4eic/4wszSqnOtFSSRmycO8yPlcI6fJxgSBL5Jd4mSSPMJZ47SbjXgejC6YdiJQWCUNnP0bAF2B3KP68QlGfF+ePg8dVX2/ACEX8Z3LY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160735; h=Content-Transfer-Encoding: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:Cc; bh=IenBg9AYpQ9l8BWTXQNXUpU41uv7QpRC4SvYweV2rAA=; b=HQuTHXA6XKbwv3JhXfIRhdHqLLl7mN/PugYbR9MAZicQzpE1EQ32qwlQ+1GF6weZELXtd03+Do524D2BmdWogrPTra7UO2zUWolc3awo532yf+ud1YHZLByJwF/QttnEKHMYl2CH+YksG+YiOtarqDnRdz0KkLgATHqRx3p9SoI= 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 1704160735552262.2113595762564; Mon, 1 Jan 2024 17:58:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3E-0003JV-TT; Mon, 01 Jan 2024 20:58:40 -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 1rKU3C-0003IQ-Uu for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:38 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3B-00070z-Cg for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:38 -0500 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6dc36e501e1so2061727a34.1 for ; Mon, 01 Jan 2024 17:58:37 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160716; x=1704765516; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=IenBg9AYpQ9l8BWTXQNXUpU41uv7QpRC4SvYweV2rAA=; b=aHzGquAaP6EDXNCYSTqyeVL+f302JMwrg8MA6cvZGw2VP1HBpIQaUmWnOO5JHzaqfP VELLgej4Pa1QR88LyjvsCkrGovmtKJVCH1TglKVXTxgKiH71e5rB4FyqXw03I7/RqjsD MkkpTezNZ/Lvl/QAeIeTiehnM8fsX0UyR3UJJwlR2IiUu4YI8JL+tEG73r8V8A2SnL8w rbvv0V6CYR21yArDUVd/g3NjvwFSabD0WSI2OcaMnOnETc4y2BE0CBrgoTG5usqH1xeA LqAcByKLGlErVFMv4ykchM2oUJSdB526h9KzMOielUES32JbkiQ2t61pmcAXDxUosR/+ UcXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160716; x=1704765516; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IenBg9AYpQ9l8BWTXQNXUpU41uv7QpRC4SvYweV2rAA=; b=CBziCHg9ag/wBbw+ei5rGEsXKntA6wy7HjE2WtVh3dLfwR0BhStWlYnTnr3oqYotkr HVSWSjj/EZFAGT/0gNSFxCC4QjZzznbh0X7oYJ04iRGaqvWXJ2EKHiXEHKOAzd/JNlf9 aB5ZDZ0ptwMCmWZnTQpoDEFvK39cpDguHvKOxWDuGGfKnc/G9R6QOSlAtmbpENCZvzwQ YiQvZl9ZPnT0LwsYRgANLZsiyNXGoWYL/0wZpkjLRQF8EcCGskhl8KmffACgdUQnMt8A xhEEe8oyjGxFqLPlYQzwqWQTDXujB3S9aAncJgvYHO/NfgIWNx8tJ8vc6tDFK33TlnOF rDeg== X-Gm-Message-State: AOJu0YyIzWS/o04zT6MQhHv6/B0dphhdHEk4flBobfQyqeqosGzj3bbq 6nq5xGV4oaRGW+mJwcZPGDLhEJu8P7VV21pDHLe2a3vAJMY= X-Google-Smtp-Source: AGHT+IFY7cP+etaBoInOV0rV0/F+0wH7ONollLCvAkA25enL46XrY8TBqRlXNgCIgZNhQIV0ZyPcDA== X-Received: by 2002:a9d:4b16:0:b0:6dc:54:f52a with SMTP id q22-20020a9d4b16000000b006dc0054f52amr8654884otf.4.1704160716169; Mon, 01 Jan 2024 17:58:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/33] migration: Remove qemu_host_page_size Date: Tue, 2 Jan 2024 12:57:46 +1100 Message-Id: <20240102015808.132373-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.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: 1704160737146100003 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- migration/ram.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 8c7886ab79..aa3109fca3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2936,7 +2936,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; @@ -2951,6 +2951,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); @@ -2959,8 +2965,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()) { @@ -3794,6 +3800,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 @@ -3811,9 +3818,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 20:23:48 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=1704160940; cv=none; d=zohomail.com; s=zohoarc; b=UK22hQoy3H1e2UTLQgoWYTa26LoT8TXRGWZ3Pjo9rJgsHmHkcxhMKdwpL8ju0eHtGDCw0x7exCs0QBWFIavwMlIpRBAtm5Lt2sF/g/cIrJppR1q5L9ETVFDx68LPT1+2ciFNot7z6Xiev/T7WyqKPf9pejNdJIPU3GPZcP9zHJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160940; h=Content-Transfer-Encoding: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:Cc; bh=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=R6KoCY51fm8zhepVEHq3OmhJT5CN98L3mlWR/bj47VrwcFduOezO/+3ecxmNNoVl9g2YrRJYkaXPhv/w5Pvp+WGNkMEne3YIxLSPjhxw99vs1YDzJ4shsoSgymQwezXVRdrvpc1e9Kp28UG604QMndYRSNzI+d84Xf6AVF9yEk8= 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 1704160940907568.4788831042604; Mon, 1 Jan 2024 18:02:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3H-0003Jo-75; Mon, 01 Jan 2024 20:58: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 1rKU3F-0003JY-Ls for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:41 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3E-00071D-6a for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:41 -0500 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3bbd1f9e0b8so2631243b6e.0 for ; Mon, 01 Jan 2024 17:58:38 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160718; x=1704765518; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=uDF82imLYBepCEfXFvcLfB9u9YqZe0xZYwaeE+0prisb2eFGZSGK69IUPIctCA7F7k /4ELreAyE8RdFdPEVwJlKXInwvMbv0+KYRv2oI93gihL+j6vkVMV2ytAYoZQi2I1m3zE T6pNU4H4H4X9W9gP7NmKd2iWLlJHzRAMraXeHHsayD5Mna6MqlbhCPFUVBcRdRnpF+oo NS7vFoN0nUffQBPOuonk+Nu1NGRxXLFhzvAKRKygAWS5t2yt922c6kXxyXblNo1kesOP KnL1F0JNEFLaK+ux5ufLD3DW6SADwUvSTtGwSzgx0GgY6Zc4ejFX6HEO6T3z2pnt3Omk Pj5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160718; x=1704765518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jBDFYDN4txkYXCl4MK4JvDX5trolAszB5+TZawsyMV0=; b=qnsjyXLwEDWjySbV0MzvI3iep7Y/QM88b181R12gAMWLc2JLCRB7qyninIOwBG1G0M hs2mWMHyRVXgOqFJrY33aJFFdjzPH7RxGQLTsePo4bm77vLinn3FRaOWPiwZnJrV1ZhT eP+yd+LWeKYfujK88sJ6vwjohIGzbKALYRgf90thXxV4m3tNWi2s297MzolByHnK63A4 NnTOw48qqJnZI6KcS2McLlhK0x0/dDKlwXZaRTvR14RMBrGuUuTRlhOeDoRZFWA3LCbu 8WjuefFFNmA+9Nvw75dCg1Wljid2tSwEp35GcfS8r0sPDARU729fVYIM4KneRuk2vF4E ++Zg== X-Gm-Message-State: AOJu0Yw4ohRealh++vsIw8xrX8P0BwuuNPHAa+8emU837uXtw+4kwjtB BuuYobc/EHD2Za1i277AwLFYVBqMrH9iEqimyxHCXM2G2ZU= X-Google-Smtp-Source: AGHT+IFTwfSQI7z8JWiFFfhWd0VVozOgzsc21xzNgSU6Fq1vYoO+L39xDzTrakM4BWwV56AqXC/goQ== X-Received: by 2002:a05:6808:148b:b0:3bb:cc89:3fa9 with SMTP id e11-20020a056808148b00b003bbcc893fa9mr8869508oiw.43.1704160717985; Mon, 01 Jan 2024 17:58:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 12/33] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init Date: Tue, 2 Jan 2024 12:57:47 +1100 Message-Id: <20240102015808.132373-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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: 1704160941720100014 Content-Type: text/plain; charset="utf-8" The size of the allocation need not match the alignment. Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/tpm/tpm_ppi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c index 7f74e26ec6..91eeafd53a 100644 --- a/hw/tpm/tpm_ppi.c +++ b/hw/tpm/tpm_ppi.c @@ -47,8 +47,7 @@ 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)); + tpmppi->buf =3D qemu_memalign(qemu_real_host_page_size(), TPM_PPI_ADDR= _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 20:23:48 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=1704160992; cv=none; d=zohomail.com; s=zohoarc; b=jK0szSqKONcOkLc8v1Bps3n3NcaQ9Nz6UNHTwhZ8MUjnWuXqaOa+Zx7foatSofq6xvpqm6sqUUkuUr4Eazl0n3qIF9tMLFTvAot4u43HU6RinMR9+psKYqfkss49tImkiWHTaBxBQWd1Uwn73gYIZd5xgrVB+/wqmY/fMF/rHqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160992; h=Content-Transfer-Encoding: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:Cc; bh=7M01tA40HhYtf6OFCfsrnOQ6yOhmNiUUj7BsAbVg9so=; b=lfGXWtgQrCKX7LYhyVLcAlgH7GZP+bYd33w9sgQcYdWUudcUvZIWz1TGs52TiqUVzTaMthj0+gG8lY1C5MKdQ9Js67psef3yPKAfjaPP1aVuv/jBe1NN30OMeNaJx81c98JdT2bjJ+Cu6mfunDJbsXExqOGIXZNGIu7E+VwxSmU= 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 1704160992792656.116222311568; Mon, 1 Jan 2024 18:03:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3I-0003KB-Cr; Mon, 01 Jan 2024 20:58: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 1rKU3G-0003Jg-ND for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:42 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3F-00071R-5N for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:42 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d98ce84e18so6562281b3a.3 for ; Mon, 01 Jan 2024 17:58:40 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160720; x=1704765520; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7M01tA40HhYtf6OFCfsrnOQ6yOhmNiUUj7BsAbVg9so=; b=Pmg3ki/r0FoBGQ69BDCW0COvKbsNHewTFo3uLo8OuMCMujCD37ybqFiiGi08UCKBWx VxHnNXJD217OKVDZzvA37Yh1kj4pr9TvcTcoc2d89laPO83yU96+iuMOe/roMmSLjRrB SA75gxlZZqk/eX3a7reNkFzuMB+nrGXYPzWdAMLp6brRbshAvOsPkTpeqxJ2uVxCHesF 0IQDBCpdyLlJz+bADuiWXm+NTu4cXs91Nb8mSx/2w+RBwhttbe4E5nuq73T3ejXhE0XJ qxXQh1YXYhittZQWfbWQ8RgokKpup4xC09d2zf7TcabTyKfugm0HalDGixq8GCXpbKbJ z7BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160720; x=1704765520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7M01tA40HhYtf6OFCfsrnOQ6yOhmNiUUj7BsAbVg9so=; b=hU061zzcY1Kqpof2ZBPupBeM2sy/Iu85ClpjHDD33NP2ufQxg31lBP5wNLhX7YWxmh Z6EtQiX+KzkazRUeWfpUE6Ujll1Q8DGHh6Kwy5EzmPtR4YK8K1eDuHn29JHD6AFW44UC nrT0OlvyfzLB+F0VhP1F1E5Iq360QChMAGYB8FOh2u1bYGniKXfcmaQ5EYE7pCFnB/QH 5OMAKrz9L4eW/s7Beji2PhSDHcehz2xud5IxJ2WILHWgYIHDWyFjNKv9xwaMlKJ6Ausn cW+qPDvdo+fkWXJSj43hihS1GJNjoB5gnA+FrzNuyxVsg58iN4t2lVeZ27WBM2fxdVr3 GQeg== X-Gm-Message-State: AOJu0YyZZufnxwRllrtfN6cyiTM4aadQSCAgmpE0Q8QEVI/uWgNK30sG W5uuPvQT40NiMAuSQNNWcs2YBwMUdwAEL77KybT2DfsC9jY= X-Google-Smtp-Source: AGHT+IG3TefqriWGAQoAbLIW38ItmrM++lpgu+M4VFyWu5luv/3+qbi4nhDU2p9nnpmCBSTEeQ6TcQ== X-Received: by 2002:a05:6a20:4e16:b0:196:52a5:e2c9 with SMTP id gk22-20020a056a204e1600b0019652a5e2c9mr6859811pzb.40.1704160719806; Mon, 01 Jan 2024 17:58:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 13/33] softmmu/physmem: Remove qemu_host_page_size Date: Tue, 2 Jan 2024 12:57:48 +1100 Message-Id: <20240102015808.132373-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: 1704160993804100007 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- system/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/physmem.c b/system/physmem.c index a63853a7bc..c09953270f 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3520,7 +3520,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 20:23:48 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=1704161027; cv=none; d=zohomail.com; s=zohoarc; b=mRGrdjbhtOLLXbQ8IgA6gjYQc18bisFdAkaEWJ+i7lGnRc0OUw5jSDnsDqYtIiOGa7j6P4oMxSdyOXCVx3o0y3suRIVLDpxG+dQIlbXl98+XBsel0WM2M0U5vZ0Fbbe0cGY1EDrZ9bS5Wki0orEwswg/w2WylfWBPMXvT0SAIwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704161027; h=Content-Transfer-Encoding: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:Cc; bh=SjN83cVYCiop/vN+SdqqhBrpQ2lAiZ7szn5smiP5b+Q=; b=MH4dtAsC4N1nSlFJLlJ7Q0eOOIq8vb636jgYcc7YAb1z17hQNKX5rw1tQjttk7jwdOGmd9mQOyDg2qQ/YSFrFLhi/bblvwSgr9U/dv9NxN+MaegcnaE8fZ0T9oTLesUun+j397DIQzYGpgQxexzvlOKv0rPRcyBTOI+Dr2Cc/F0= 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 1704161027385982.6440522429681; Mon, 1 Jan 2024 18:03:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3I-0003KY-TU; Mon, 01 Jan 2024 20:58: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 1rKU3I-0003K5-9y for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:44 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3G-00071g-RW for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:44 -0500 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3bbd6e377ceso3057820b6e.1 for ; Mon, 01 Jan 2024 17:58:42 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160721; x=1704765521; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SjN83cVYCiop/vN+SdqqhBrpQ2lAiZ7szn5smiP5b+Q=; b=sbaovuYRX985LPidP+U2lfMs8Y5PZ9ZgvqEEWAFQtNbaFIBlS1YS0y6odAF/kWEOuF fOqyMJXg2y3xyjYyVe3vYdmph/44jF7l0wUPvmEUPBc3c9YEjXYMp24jt1rMu2k0g3fy V9zxY3lu1YvivS3ltdousGJEl0gc+QUwmikZ1sn69b+8tPwfk4bIUwDW/mxiP+LLiuR+ hFzH2ONXIGom9exAaVO6Asulzk+1O5gC1B+WC/5V1NwKSCC/RJ+RdfAmxU2u7D/MIi0n uh2CnF00BDgMPwethy1x4aILx1dZQSx/3gYede5VzVGpNFd1d/H+65+DNmbkglUb1Nul HDhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160721; x=1704765521; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SjN83cVYCiop/vN+SdqqhBrpQ2lAiZ7szn5smiP5b+Q=; b=FgEOi3yembWsQ17O5NdJYnEQPq+VnJseG/iwp92rEcBeuPHPtTLvuu5eY8+FY4s/24 t/Rg+iFzB6BCaEpd/RYSTwFMICbucObL4stpfEM4BuQ9als8dda6H9QEkivIOQC0otd4 xrg82cc1K8nNGtGTH16JFtEHKO1fu7I70B0ZhwgDN6xFWmsZoWYdV/5/wFy06+sojwjh 86RNzhvU8l3fvnifap+fSSik3ZhOkUi+Gk0vfOFe3ZLpm/qPtdTa3ghhD96n95hfLtAY 6Lq/sUSLWt3Phb/UnZVMfFJfk26UaBbOI5p0CORjjJoEAS0HrJmdSRvyukqBzXVKkdwG z8Hg== X-Gm-Message-State: AOJu0YzD5zATeToHwptX2R3Y0P0uyFGz0EN0BKxS3R+fnkVPlqTbvp8A r4zrDlKb4oBDtD0CSu2P11GtlBT50Ea5WSOcNjjI4ai4CDs= X-Google-Smtp-Source: AGHT+IHSAkNQIUF9l/OvgwFEI9CCyA655dCGDJQx1UepLwuAqHCzcmzVD6cVpvpmTZ7xvPvJdcPbnw== X-Received: by 2002:a05:6808:208e:b0:3bb:f5f4:e5ce with SMTP id s14-20020a056808208e00b003bbf5f4e5cemr4818747oiw.41.1704160721692; Mon, 01 Jan 2024 17:58:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 14/33] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Tue, 2 Jan 2024 12:57:49 +1100 Message-Id: <20240102015808.132373-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704161027855100001 Content-Type: text/plain; charset="utf-8" Align allocation sizes to the maximum of host and target page sizes. Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- system/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index c09953270f..c1e48dfb6a 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 20:23:48 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=1704160745; cv=none; d=zohomail.com; s=zohoarc; b=MBwMUu7iK2AR+/taInGgjfZCWSN6c9auDKVC+f4WfkYWDzkr0PYj//ACBRbZaMcQ34sf94lUyk6hrMjuSoSHJaPE7Pzno0Adswv5VS2rwojdqY2BKpUtE2cm9RgavPz5mIK8iM8tae8knr7WuvuUboPQCWIgTT8ml5cgb//cRNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160745; h=Content-Transfer-Encoding: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:Cc; bh=bGbmvk3+bB4juRZKIWkw0J9XlNF5J8UzTPZ/yNXv5VY=; b=HxN/s1NGxrDJPiV4VIUrNRSURkl2wXkUCy2/28lti5G7pcM4euWIjlhgEdKj3sZTTJ+Cxn1UAvliqQ5SBCoyFtC2u/ISsA8zV6dKy1wOZ7Ptv9Ikm2i1VfHsAFW72ant5NozPLBdhAIgW8rqgyzBoZd2nTqVYZueUOMQ04AQxJ8= 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 1704160745424413.3314247467491; Mon, 1 Jan 2024 17:59:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3M-0003LC-NQ; Mon, 01 Jan 2024 20:58: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 1rKU3K-0003Kp-Ac for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:46 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3I-00072D-TF for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:46 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6d9af1f12d5so5211405b3a.3 for ; Mon, 01 Jan 2024 17:58:44 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160724; x=1704765524; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bGbmvk3+bB4juRZKIWkw0J9XlNF5J8UzTPZ/yNXv5VY=; b=XQJ9ASJb+HSGq8F+KtKQyb4Gi6vTlxQCOwxtwbaUkaU6VjmmdNF07qHoHN+fJ8znd2 WzlDdwHkvIYGKaosDG2rxsAiFbp80Z4KYsh21VWaOBVEVsrHXlxlNFc4bX9JBXCYiSQ4 j4vnguviUCHlqMlp0pjffckfgxXQ8ulHZVxr3TOAu5ZyJ5H+vbKby4suMfhwOiFDSFXM cdq6WgCksfV2bx1jgYuMr6w4oFI+r0Tx4mL1s/qdhCyVCq4GvRTSNNiuHHZEco2GrOSa c3rE3B9Py8NwyAZjf3MEhn/LpSoK8dOEkE4uEGxytVECyfAFnwPqfwYX1ITg2OeHUC8B ynZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160724; x=1704765524; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bGbmvk3+bB4juRZKIWkw0J9XlNF5J8UzTPZ/yNXv5VY=; b=isf4yx8eqlyX3zpYhSpNwvE8feed9llp9sfHMG/jShKlOQLLS9gbHKmRjkYu+Msq9d aP0vcyuoaQ3JBb9Y0UilLR0mW4OLyqYtjWeN8r8Xjk7oTESp2q9wmDnw1hAGdKvHcnVw 0zuUnX6YjAw1c+uG6BVmpp2Nf8yfn2g4pnm/nWSRCvc/0QLVTqhIzv5LJeaFukORzNZi 5maYXr/x/14TEMrmiAEeveLPmvMFTPHJGvDq8y/3awV0kYu9ylnZRAm1gVQvH96S13HF ac7Ln0n/yo+KC5DB5+ff2e9E4xBsrTI4bevvOHaPlFvdQVcugA3OeDcjcodBYNgAYatq n4LA== X-Gm-Message-State: AOJu0YwFhvT2IgphgvuKVesmHEOrrU+WqAiypZoLa/3i+Wd9Dnc3/Y18 RZCy66lPRB4Yd92QfvOKGxFAOS6S7n0V1ZPc3G4M1SuZDKg= X-Google-Smtp-Source: AGHT+IEs6pHKaLYXaeVOlhAnctcsXIKewSB1Pe3TeNMUNLmFV0apX+RD893/3JkslgeN4tbZvgiY7Q== X-Received: by 2002:a05:6a00:17a9:b0:6d9:b320:94c9 with SMTP id s41-20020a056a0017a900b006d9b32094c9mr17630407pfg.33.1704160723757; Mon, 01 Jan 2024 17:58:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 15/33] linux-user: Remove qemu_host_page_size from main Date: Tue, 2 Jan 2024 12:57:50 +1100 Message-Id: <20240102015808.132373-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::431; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x431.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: 1704160747296100003 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 0cdaf30d34..5f217cc2a8 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -783,7 +783,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); @@ -806,8 +806,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); @@ -904,7 +906,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 20:23:48 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=1704160941; cv=none; d=zohomail.com; s=zohoarc; b=Uye+aa/n57rNNcazFOb1pdLnChu1qLyRESrhmmJgcgFsMqGcywfzU5qWEhjgNOHrRQSpxB1GMgEtK8P0OeEAp/+BzgolMTGJcg8BlxYHpHQe4KCxYHqY3sffPDLxdi6qux8uzsMbRP3BOY2UBncuJj7EpRJZZQRZZ3/HjNrZ5ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160941; 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=TCVGxN0fnWUc6maO2wa7dwEI9dVIrhQYXz7yUCQwr68=; b=hsYrtWmARwnHfizhnmrcrpD/yt+M4+FSjI2y8ttBiRDoN/1v+z0TWlcQwTlxYejssfMq1LXhUlTvn7gdgUApcAA2FIX+v0LZO/a4bVnUIEQr9CiooqcUg0unZqu/7ef3Q6GiXJeVIvjiaWOuojNvXtlq7peZkB/tfwGO+Y5BblQ= 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 170416094105090.49040286654758; Mon, 1 Jan 2024 18:02:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3O-0003Lh-99; Mon, 01 Jan 2024 20:58:50 -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 1rKU3M-0003LD-U9 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:48 -0500 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3L-00072X-4O for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:48 -0500 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3bbd6f87959so2438372b6e.1 for ; Mon, 01 Jan 2024 17:58:46 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160726; x=1704765526; 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=TCVGxN0fnWUc6maO2wa7dwEI9dVIrhQYXz7yUCQwr68=; b=Gk9qLQmxGv4qKw8p86XCfG4z+OwjmQuWyHIBOSx3Htu4N0q3gZII+kZFHZZWQ16IEo GB2BpgHcxrI+kzcFEizQmMHxps4Bm8PxgI5b/pVwB9ph/0qza+ZxVsG2VrSgV3E2tLhK RtkVmQcMen+jUC9k7ByYsrMc3qqCTKKh8UNdT1i9jXdcWLBBnZVxLUUy6ZWUGMqp4y8y lba7JnVNMDCGTZuKVnTxTWm3hALGY09t6K3zl8f8kASeEGLuubBpSOmlO5iNa7GZPJmd G5HLgAiLEeVP9HENIDHq1XB7Xd+4HRu2nxc/P4mRTuuQjxOL7SsGZCwNY90hYpPa+1Qf ev7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160726; x=1704765526; 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=TCVGxN0fnWUc6maO2wa7dwEI9dVIrhQYXz7yUCQwr68=; b=wDn9lVbb/PkTTR28Bf1YswB2T4n1jTx7cUNqpLex7hb37e/Kfhnpa1bSoez982xwOK Sw8eMPzlHBp78SozLnyHHU8+TY+jLQ+uegB1WV2Je1SfwwHmSOQRwOylLDi9iCXx4V2A RGgIFzjGEkMm+zZxo13mbpcMyiUKD/m4uRbQkqBG2pLynt252vJ4q5o6ZBPJaX0Ucs0g UBzIa604wFFtpjNoIi1ATEHi+gy6Oa6EIHNZg3vw1SOr4cbHxblRuvmyjZUoH9B/ORP2 CMUXt0v42ZpF/j4lFffsgsbW90hqeb4TYSK11LYLWnzZ2YJMHyJCsBk3I6sQEH95QUTa 2dzw== X-Gm-Message-State: AOJu0Yzb4RT0Hlq9aPFAI1mV455ELay7ID7pljUgA1r2aAdt2VKFyxBl 1e81I08H1dTeUXmdQptILlNRqj96fKiR3u2PSypQk5kfH3s= X-Google-Smtp-Source: AGHT+IFSfWkWw+ykc02cxF/IAAJDocZtPwmgTGs/MlDQprQgtZciMKLd4Fspg3DQWJUyvtVRKG319w== X-Received: by 2002:a05:6808:159e:b0:3bc:18d8:d208 with SMTP id t30-20020a056808159e00b003bc18d8d208mr317011oiw.30.1704160725851; Mon, 01 Jan 2024 17:58:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 16/33] linux-user: Split out target_mmap__locked Date: Tue, 2 Jan 2024 12:57:51 +1100 Message-Id: <20240102015808.132373-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.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: 1704160941719100013 All "goto fail" may be transformed to "return -1". Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 20:23:48 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=1704160762; cv=none; d=zohomail.com; s=zohoarc; b=gbFCWLZ0to+VNzq4x/MTWOSZmiLlu5UZLp1v73sHQR4UlGnw2CMJSRKmK/e8+7PaTvfUuYGOPhTjFEwTHRbFCLgYav/smQe2o4zSuqLFpe8HGCKd20hV0fxyeoZswk8ZvapkhSeaqiD170SoLhvYymvQAwDJPpk3OCLRKxy0LgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160762; 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=tnSJisjhmOEPjG/usSlqH7jpNx1heRPl0XkUSpAoUU4=; b=O7UyHwPdn5TmrWn8/gilaZ95F5g/LH7K7qRPGH9cq79VowB93mMCvS4GhdcvF6KoRW8QGQLvNS1gow71LTUGn/dHaJT6yjmnok91z8OUA1Z8CGSA1tFvfF9Sk6+FyNJQQ5aqzISCk4olC990ZEqdkosU1WLA/+VqfGvBsc+4OHM= 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 17041607627673.7246314127431788; Mon, 1 Jan 2024 17:59:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3R-0003VH-K2; Mon, 01 Jan 2024 20:58: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 1rKU3P-0003Lj-7U for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:51 -0500 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3N-00072u-Hi for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:50 -0500 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6d9bba6d773so4527187b3a.1 for ; Mon, 01 Jan 2024 17:58:49 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160728; x=1704765528; 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=tnSJisjhmOEPjG/usSlqH7jpNx1heRPl0XkUSpAoUU4=; b=aDr1PqNlVmx4prsdKZJYRIm1vVLFrlbT6SY+3REZiZoWHYh3Oj+ALdajLfoNkPsZh7 PUx6vukihpxMCfj0LC0oRtdffGQukkr80+Egwfr6iE8lzzLGYtjqlKy6vNGA01kyF7Tg RyzeiFyIClFuFE97n/IymEcNvGUmBlIUR+hmNzAcj6WfVP+7om1Bvfm2ODNkrZUP/Goy rxd9w8cUPUl+pAMHEGyOA6/C6rP/AMhq0TCLUDBpMP1vuy9QOc1dLcZ2v1loOFhasIpo G1Yj0MVvUGy6np5T0Eof3ZI82ryXuFCYhbSZarF2GJyQzy2tNNa/KrbGF1hJo3dCGzhd MvrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160728; x=1704765528; 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=tnSJisjhmOEPjG/usSlqH7jpNx1heRPl0XkUSpAoUU4=; b=MEB1pD6rQCL/PwJDuhOsNwFhns2lJ2ZkJIrLxq432uvz3jj+Mx1wAZit4SR1eF9jZf vRl0bXcz6k2panp6KnG0uSIQ54SgFN9Fww7vebqQYhk38+9Pp1dH87oF++J8HyISsg4g QWmy71O+7hcmo1/tYfb2webZwEByx9B1xdpxTg288oot5prnsmk57OSARQ64JvhiQvOK 4Ou+K5cwlDRfg1gshaYsRplqJ+zdqvZJf5b20epDobtJYPp/Lkp/XbgJMTbBuGxGOVl4 4D0i1lHUOfJYxs2xy94BJo1Dn3Aqyg4Yb7hzeESXOsHDt0cCbaJ3vbCSCsXFA8cagwaV Qbag== X-Gm-Message-State: AOJu0Yz40f9+oiqNHmSysAPvqJuGXeV69CriohRRvGsB3IwFCZBPAD/5 VchgXQ3pkEMs80ATrPt4o0VosRi5PtMcIB/aNr4FrS8p/2w= X-Google-Smtp-Source: AGHT+IEAGlexuAg3lxm+T1XIQe1a0LOV0XxZb3TleOCDXhLfRg4LkVgcjkmJOnp+ilwF+MBVdDVeVA== X-Received: by 2002:a05:6a00:1d96:b0:6d9:af31:293b with SMTP id z22-20020a056a001d9600b006d9af31293bmr17005737pfw.61.1704160728179; Mon, 01 Jan 2024 17:58:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 17/33] linux-user: Move some mmap checks outside the lock Date: Tue, 2 Jan 2024 12:57:52 +1100 Message-Id: <20240102015808.132373-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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: 1704160763310100004 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich --- 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 20:23:48 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=1704160764; cv=none; d=zohomail.com; s=zohoarc; b=DY3WwE451gjWbOA0qrznfIysuhpiIcX4E+2FK0w2GShltgxW8lolOkgXwYsAr5V2rDAsJ8BbKa6x6tFMY6fZfvrQowxF2cMDsZQ/UvJOaxqx1zcSnXrKYQzP2ZeUtZnD0IsQPjZCaCaUJLIq7yXIZpT6oc0KDONYCc6KYSvNFME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160764; h=Content-Transfer-Encoding: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:Cc; bh=/pDTiX/W/3uE1ebfbK0jDL+RrICwab7UesIidaqTDMQ=; b=V5tV6pd4cADBuVpILpoWZKdXIVuM7DhBkr4yyFzEG6IXvpEY8wprrgxkhiFauaL5lHRAG+09ohEsSwiWgAhVIVjXaxrdUD3zOSXdgLdg5trHsfdr+KuMl+80n9cJDREbdxy1mBIWJE7oFX59YlfH2D92FQNJCVr1B5Q+b4becLU= 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 1704160764586592.4237650484428; Mon, 1 Jan 2024 17:59:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3V-0003Ze-So; Mon, 01 Jan 2024 20:58: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 1rKU3Q-0003UZ-W0 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:53 -0500 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3P-00073E-Df for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:52 -0500 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-2045bedb806so6360451fac.3 for ; Mon, 01 Jan 2024 17:58:51 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160730; x=1704765530; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/pDTiX/W/3uE1ebfbK0jDL+RrICwab7UesIidaqTDMQ=; b=mta5MaAf8zmWkyZMiZx/Ho8mpo4jStj/WSBz183q2UusqAb4BpLik6lyTV5wkSs/lr 4oRWj+lpe/ZCWPKH0xCSbFXgf45Y+09x83c+3WfR0MtRm5g5A8Qzz7MT+bbzmouoI9cT WUKlMg9kltbAfvoece6yjlc/R7W3nskLZoamB23eZneWyGm3kgLvGayyfwK/fPVoZl1I 6x8NEfEh+RE01vwgZJYrB6Fb68hPyeOOVSLKc53RtK/X5ftROUEhqCPPZoEyKvhiNlJg PirrintzKyuYtQSxqtq5+K60SWM3M+oWbCq4RGfLe1XRYzpVZGLDtrOPEvcHw2mTv7IG 39Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160730; x=1704765530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/pDTiX/W/3uE1ebfbK0jDL+RrICwab7UesIidaqTDMQ=; b=Go6kUORICTiyfVqJ1qk2h5rcDa++AVj0DldbvztvJ8TtogiFYzd7k5tsGaANaID1Ua GB0xNBtCY5ctyt5KJscuGWlxvUsErvmtmRZIxpZU1a0RZiDj9a+j9wxe/ELaa1NVKOhV 8mL7v8CzkKDij564bg8G9UomSGysgAqlDOmT3FZzi4Pk2OxBe9ACPcX+UkVt4KU2MfEX WUZPv8EVUCpqa97VPdYs6ZWvJVbDyEXa55J9M7czsqSBN3dzPgFnB6OqEx82m+qzik0v CL+n3Cd/rwC1ZH9XmqTujqcC9N9Xo8uP5NQ6SxsuaJj9EwwNcy7NzjKn7qOw59IPFPdW FSqA== X-Gm-Message-State: AOJu0YzNasW9FLPUUSyiTeRNbSDi0NRVoze+u9TO2DmOMUXHCYgK6/Hy Wr5KF90xyAOFqx+cvuEvvVB5kr5O/kEjFushyLa/ruIqe78= X-Google-Smtp-Source: AGHT+IH4DOe402Om0PZiBkW8rrcVki8Ybgk9LbmIgEXNW9HvwnpnHiQJ9vRb85c0DqTDNYSAhNw08Q== X-Received: by 2002:a05:6871:606:b0:204:c23:8831 with SMTP id w6-20020a056871060600b002040c238831mr21960222oan.37.1704160730184; Mon, 01 Jan 2024 17:58:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 18/33] linux-user: Fix sub-host-page mmap Date: Tue, 2 Jan 2024 12:57:53 +1100 Message-Id: <20240102015808.132373-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2001:4860:4864:20::29; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x29.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: 1704160765164100013 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 20:23:48 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=1704160941; cv=none; d=zohomail.com; s=zohoarc; b=QzT27apBBPRC3XVi2896NDZOBmK68Qqlt93OowJIQrBbXgVELs5iTL0pkBuQiIvfpsFesuNa33xFIW7wnC74BaFv6sHut97pR12zDgGw9YcO37f+fuV8W8y0pLBxrpxyq2i0aHaPsZ5bLzqBegDK5F82VyCOaw6NybtVHDAsCQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160941; 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=bKRPPYNauFVdl96BCtCoGjZgyH5GMNCuP4SDa2Vhch0=; b=FH/bzj/oknigA2EVkUUdt2XndDktw2ucIqsx6RjT00o2ruBlYyGaeULaaV3gnF27j2OPF4/Exehg+If/vQs5RT9faaV4r/TCUpXoSK6fNxkouv5CsfI/r73pdvlpPR2v0MBUOogJftz61CgeNKGMPVe2jkJIUvo0WLdDCDfMdoI= 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 1704160941248693.4151086771769; Mon, 1 Jan 2024 18:02:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3Y-0003dc-9b; Mon, 01 Jan 2024 20:59: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 1rKU3T-0003XI-6D for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:55 -0500 Received: from mail-ot1-x32c.google.com ([2607:f8b0:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3R-00073e-Ix for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:54 -0500 Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6dc02ab3cc9so3595964a34.3 for ; Mon, 01 Jan 2024 17:58:53 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160732; x=1704765532; 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=bKRPPYNauFVdl96BCtCoGjZgyH5GMNCuP4SDa2Vhch0=; b=hGjqh8EQtDOqDomytn/TRuQYx0vKuasDwt8jikwaUu0ZkrdnYOB8W/bV1K3ANlBXhM 6yyB1jbgZxQvbUKpEfbNXasvBDKHblgB7KTkkRznPUbShaHKC4TpAonQVgdbsq6m0SJo hwDunXp2fpP0KiMvOKOgElHIAf8AHsq8uCcHie6wgIAMMNi08W125TmE6OjhVcjh2pOX VcaA9DcLnjHWuI5/sBWvUx6CUFr0HG3HBKUBb32A5m/46L2nLXYMJsztPU1b0705Jo5N VhCDrwOj8rNYEKn5+QBEQOJokngIUSDN4NEDzg1/Q4gRMOClRtkqhqLx0fO5DXfTwNQt L0tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160732; x=1704765532; 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=bKRPPYNauFVdl96BCtCoGjZgyH5GMNCuP4SDa2Vhch0=; b=S6cG/HrdvyxwLKOHilwJoAsZWlxF/zeZ5qUPWta9SZ9tS9TIAmCQD5sklzpNp48UaT 1CoeEvY2b/tNCkDycavOurEK4YHgWbCacOGJwH3de4Tw4Lu/bm3TGDlQe5+0rfbuXtiY 4V+qP/nMPUKVFtmnzytr7eVLT4VPZlleoSSRc685ynbGRX6rYTl/d/5aPc9fkgpObccJ 7vvuRA0rLfWixBaVglzaOs3kMymhygbC1SH1QchMV7EueM+Gjj8cdZ+b4oSJlTW9P4/H I/8OGY5s1raN/woFSkwzt06F5KCidfSNOsL1DisA5upPuaR8bF0efm67qtdMGrBC2ohW YtjQ== X-Gm-Message-State: AOJu0YzE2ZQhcLJ/yYN9Hi2gw+3/oBBZExiIIblYvcu4yIs+cXpqkvsX P3LmExbiw4k7DJEVYSR4TMbT1JE/gsrHaBMRUTiEBnilw4g= X-Google-Smtp-Source: AGHT+IHajtkrpVBsApKCNlShAchPHZiqyAyNzvdVUxp6YKNt2ABxYRbhk/OQgcrWCxtzglnQmC4kzw== X-Received: by 2002:a05:6808:6543:b0:3bb:d7ff:982d with SMTP id fn3-20020a056808654300b003bbd7ff982dmr9579468oib.98.1704160732598; Mon, 01 Jan 2024 17:58:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 19/33] linux-user: Split out mmap_end Date: Tue, 2 Jan 2024 12:57:54 +1100 Message-Id: <20240102015808.132373-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::32c; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32c.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: 1704160941728100016 Use a subroutine instead of a goto within target_mmap__locked. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich --- 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 20:23:48 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=1704160941; cv=none; d=zohomail.com; s=zohoarc; b=nRS4mvNKtauj7DMs0WBT49gboyqUIPGIGtUbYvK0BVTFveYGGw2UmOroqeWkIaDbfv4V05KxcM8x8Q0+ahJ/mOUV50hVLZmvVRAeOiwEuRdFgNuvNznrZDciv5stuuRH1NOm8yfX238TNg36muCE1ZoejdmXyKv3XsTGdtX7PMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160941; h=Content-Transfer-Encoding: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:Cc; bh=ON4YI1y2oDMx99Q4aY169Mgist3E8ZTpYrSmG7+E5s0=; b=hxwQ8EWG6MTt/Aq5LVi/CbxRFNXsBpvABP6O4UoR9C34/x1tLDt+Pv54/Q7x5fesgjLwmEzlxac8kL0+xu0N3B0ivXXcQYbb4DC+QBMAFixKPTX4rOSkOAlmFvrBAlCz5FebvuCKD2lBayXqj0aUNujYQzjxelPPa5O3VQMa0tg= 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 17041609411777.229966642809927; Mon, 1 Jan 2024 18:02:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3c-0003f2-GC; Mon, 01 Jan 2024 20:59: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 1rKU3V-0003ZL-4m for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:57 -0500 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3T-00073z-Jl for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:56 -0500 Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-7baa8097064so369441439f.3 for ; Mon, 01 Jan 2024 17:58:55 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160734; x=1704765534; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ON4YI1y2oDMx99Q4aY169Mgist3E8ZTpYrSmG7+E5s0=; b=Tb4xDMgsQUE+5uE/iEygMpjqTaA1PBZBNfE73lM0RsI2oJjm1uO4S2vnAuyAwjkFFS H5DLnNpeWD8n7Ln43ABMuAeBgv4M9T0jH1MJL4NyZrdKU30la3CHHC6fExh4GkubCR9T a3zTtY65pNhsnZt2DKotiHv/qIGQ1qx3izQu7UzQ0rPCho8QjSsnNNFS90nNr2FHZkTT PIij2kTppHK6s1OJnz2ShhOPaSzwVYApuJWMRwks9+Zt/vad+jBq+Ify6+q3vWqdjBHf m41L4mTlfrc+J5Dg350JfuoaAGQb/QsiBp6NjLDhHRGJwbKRd2WwXGiEvVAnNAWHhWId cKGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160734; x=1704765534; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ON4YI1y2oDMx99Q4aY169Mgist3E8ZTpYrSmG7+E5s0=; b=WvCKrCQEKxwBFKzahdEKHqZS+0JVOXnkAUAFLpaFJlGEovurhd5MAl891LxBhzEi5p cGLDT0fS0wph1cu+TKqYHoLp9V2CwKTt5DaQnuECCt/xJ9bmU4Ot09GS3zvStKFN1k/p jmBIQV/1lhtrKFuwuccygxgDehshFqVbCR89EkX0PTofsHbnOhzjs93z8+DP9c2dLN6W YCzMQTPNAw6qsyl5rICHyvtQV0l6lrAUm5pe8qT5kYB+eE8llZKpjZGY2u9Prxfm7Bqe ByixvmZzOayrdpiDSUm0DXVtpylRuVDgUduvBhC57vnIzJRlDFNHZTVDFgR/yM9Cnwam HXyA== X-Gm-Message-State: AOJu0YyoJg9p0G+4BrTN30DG1hFEiJBDrPDzY1vju4uoOSRN0Yy6fmIR 0jMISMASMRYIpQnVMR4rCeM7+TOymlfSUXrBzde/LuZGDjg= X-Google-Smtp-Source: AGHT+IG3sens6DQ6corqPLeMTLMbBHMKNCCpEDzSGH+CUPGDNTlc1ALD9WvMeSVc22K6tfYTTdG8bA== X-Received: by 2002:a05:6e02:17c6:b0:360:16c7:2d6a with SMTP id z6-20020a056e0217c600b0036016c72d6amr12526230ilu.48.1704160734489; Mon, 01 Jan 2024 17:58:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 20/33] linux-user: Do early mmap placement only for reserved_va Date: Tue, 2 Jan 2024 12:57:55 +1100 Message-Id: <20240102015808.132373-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::d34; envelope-from=richard.henderson@linaro.org; helo=mail-io1-xd34.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: 1704160941727100015 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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..42eb3eb2b4 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 suitible 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 20:23:48 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=1704160941; cv=none; d=zohomail.com; s=zohoarc; b=m/FJ/8reZ2Yr165KP1Gt+FT8EcUXr2LpYjYDegz0Yo1TslMReEbcO3CfXsVeJ8IlEAEnTWSGxMoiGC/H0IKoIogBLiqPL9LyVT8H+SJbJ5rnqBd66kvPsd+HzQA/3BgWgTKJgSI59mJlCGdEK2tscVD63D2xmE+sAvWoofTHOmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160941; h=Content-Transfer-Encoding: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:Cc; bh=Agx2bj5+PO3H0m/DZ+WXfvcf7Vu2LJVqySA/YVtXeLI=; b=fxd40qqU0eYSAJvQ3PPXTwChtH00JU38qbqWRXeH7TtlwPTmk70HYdf0Q4nQ1FhwzNCPyOsfRlvh23BZmQ9DH5CAFuwLu6EiL4PWgEFC/lgkthE1Lo4IpuTAJNgIkbehGKbxRNhuG67xzF33kutgd67TTeknPZtXoqY0UOSmMhA= 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 1704160941213840.3651665264005; Mon, 1 Jan 2024 18:02:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3e-0003h0-Fy; Mon, 01 Jan 2024 20:59: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 1rKU3X-0003ca-V1 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:59 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3V-00074J-P8 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:58:59 -0500 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-28c467446f0so3839128a91.0 for ; Mon, 01 Jan 2024 17:58:57 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160736; x=1704765536; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Agx2bj5+PO3H0m/DZ+WXfvcf7Vu2LJVqySA/YVtXeLI=; b=MJ21oOH6KOGyz7Jwk2LdJrOs+delovfo2tJApoUL7RsNSLn0oEohvF4s4Wzm30E9Rn UHSCRBmbGYSaDPpOo4cYUi9DaDoQYCPfuXAFURFeKwpFBtwYQx9HV3Hn5UhGfVp/WN4g boiSXGmYkBIKTtwXqEHJI3TJaYLWEvfq3tv3PZb6NTtWMRAIsMiNPmv2wlzUKgzF0d+S XlE4M6XbXjUOzKsZrElWbHOS79ePgpO8+lGZ4/2RKoJxSLOb94pKsZ18/eVYFv3KgtTv PSCA1Nhjj6sD8bHGyrMhkha5rCopwcI9GtPtX3OZVDjV2abfmjdivJMxyrB/RpKRLk77 GXHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160736; x=1704765536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Agx2bj5+PO3H0m/DZ+WXfvcf7Vu2LJVqySA/YVtXeLI=; b=YnvpT7Hlz9kqXyLhnEHVwSV74/2QzIFfcmWDAGdW/guUL+Jtap757nsw/Eve3OsQDd zYf0Dnzno+mmQOo/Rdpzmlz0sWq/rHc0fksgt3OhNMoJFIn/cZSYyBzLywuy1jRrLfca dKZ8an1+9bWIfCCawvN1G+xrs/q0MMFAcDiTmBH+hgj1EL05mUdckSzT5LUg6DdIbfCt Vo60RYjjJCLuizC9wUyqoAUPZ6uxSuhSdP+cyqQ53RmDyzVnJZ8/uaaZHNh48RQr7V66 5MGrekkVr0gEmjzhibk4Qs8f8OhTOQAASt30grjbF1ZZHD2SgJkLnXe9PxLoJ3SdZAva Tdyg== X-Gm-Message-State: AOJu0YxfKThpOcUOd+TuassZHMfpYa3wVzY3UoNznDTHO9OgpTLL1kSc RnG/nRg0/IKf0OZ7wWzXOJe2E94m0Wry96Y8O3on/4gD944= X-Google-Smtp-Source: AGHT+IG0p43Jz7zHHpmdcqtX8fOuBNtEIX5Rnnjmqh7KeozxvvemLvLDx1OOogkoVU1ieh9wp+qYnw== X-Received: by 2002:a17:90a:de04:b0:28b:bd9d:8d50 with SMTP id m4-20020a17090ade0400b0028bbd9d8d50mr19527276pjv.13.1704160736445; Mon, 01 Jan 2024 17:58:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 21/33] linux-user: Split out mmap_h_eq_g Date: Tue, 2 Jan 2024 12:57:56 +1100 Message-Id: <20240102015808.132373-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.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: 1704160941737100017 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 Acked-by: Helge Deller Reviewed-by: Pierrick Bouvier --- linux-user/mmap.c | 66 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 42eb3eb2b4..00003b8329 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -527,6 +527,31 @@ 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 ((flags & MAP_FIXED_NOREPLACE) && p !=3D want_p) { + 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) @@ -535,6 +560,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; @@ -543,16 +569,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 suitible 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 /* @@ -588,12 +631,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, @@ -716,8 +757,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) { munmap(p, len1); --=20 2.34.1 From nobody Tue Nov 26 20:23:48 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=1704160857; cv=none; d=zohomail.com; s=zohoarc; b=S8Yg9sfAp/xZ8L64BG7CXg/9xW/GTx/Gq6BObHY0W8kg745RU7N5qlUGlzUfqzfb8xLU34Jl8eZdoBqnarr4CD9jYgVRoVkJJfo5YzhQNcAEXycAQqow01W5ogzDCbgAzzeVkPCC1pIcsA7ci/aK+g2GN2tAcWuprHAMghmXf4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160857; h=Content-Transfer-Encoding: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:Cc; bh=qA2a/PTKZLcZg5cbX228JZnmG9F2Eb0mEU1DFgp6lOI=; b=bWwbNNo/kU8IYM1K3HalPycflEtn0ksqClXB4L5CyU0hasfIlbUaX6duv6I9hSLZ0DVsmL+89twq6ke/2sj8euUfj7/6V/VvTcjsizS3wrnj0/lO4IGNDIc+/GN0raZBOna0Elb2gSSOLM/mWjzC94wW2ZlDuWxHEj6JcOEvwTs= 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 1704160857116591.1066242233601; Mon, 1 Jan 2024 18:00:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3l-0003kr-Ow; Mon, 01 Jan 2024 20:59: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 1rKU3Z-0003eP-Gl for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:02 -0500 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3X-00074b-NB for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:01 -0500 Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6dc018228b4so3062009a34.0 for ; Mon, 01 Jan 2024 17:58:59 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160738; x=1704765538; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qA2a/PTKZLcZg5cbX228JZnmG9F2Eb0mEU1DFgp6lOI=; b=tXc2OJRCBlQorvRvX/hn7/nUSOktcroMzwn7shw9Ag9QDegfsFDZL9vh7pP7BDY7c9 eWkvxNHJwGNUEmNHcnsg4HTkQBsYMDYnuxj8ejlLAkdhyyCkfE3+5R+fLg7PU0kthK9p pHHI+CgX5sJa/qSONH7mzWCpXkX9p/l+m3iqCE0JhSwx3fLDAMkMUJhey0DN8o19n/8K 75rGkVfBNqQwBT/r5xU+3GqNKjmr+vMoryFe5OKqDCMzPFuwGE30M50MqoedJkdAcpxg JJMKTATANwZ0BS4mTmZdS2HFQSwAagMwdzKkweq5Y28ERjRG5PnfTsRjSWnDpodXjr+6 Szfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160738; x=1704765538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qA2a/PTKZLcZg5cbX228JZnmG9F2Eb0mEU1DFgp6lOI=; b=ltEru97ggWBl4JCiDGqeucl2+tdK3q1ukBpAR26kyLnI9k0VlFycTOPYi6jQrhTXm5 zr24f47eCJbGYiIdb3BonG9BdYcF5+ktMfTsIN2CZ92daCnzgeHol9QDu6pq3kZLyMoQ iM3Cpa3RS+mULl1MwgcW7N1Mpwxf2c6IidGoxldjzm4BoQoo1yBrmQBj1ukfP06CJoxh mxff6yj122w6Sdutg1mCqsTG7ERwOGn6Z8yYCEvACUhC4k/EzEG9/F6JUXYo2ODvlam6 H3aMMakjoOb76QsolGhJFniqfJcfVdSjmhRDudqjGJfAWljWCcW5k4j6fagw/xt6GX/H ZmYw== X-Gm-Message-State: AOJu0YwAi/PH4bFFRHXunPr82S96hvvz7zpHYlE3oP6ZxiJqK5OQftqK pZFJXQgvtJ1kHggVN++dugSGn3rMRpSqs0qiExkgMa4moe0= X-Google-Smtp-Source: AGHT+IEW1aa2hupVZ45dmHHnSO+I1c8E6HwKME+OmDikxt4hfGmRSgxV5JyDWtKG4MkAZT/WaX4KcQ== X-Received: by 2002:a05:6808:238e:b0:3bb:e1bb:3546 with SMTP id bp14-20020a056808238e00b003bbe1bb3546mr6643355oib.44.1704160738363; Mon, 01 Jan 2024 17:58:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 22/33] linux-user: Split out mmap_h_lt_g Date: Tue, 2 Jan 2024 12:57:57 +1100 Message-Id: <20240102015808.132373-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::331; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x331.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: 1704160857508100001 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 Acked-by: Helge Deller Reviewed-by: Pierrick Bouvier --- linux-user/mmap.c | 156 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 31 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 00003b8329..8b0a26e50d 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -552,6 +552,128 @@ 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) { + 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); + assert(t !=3D MAP_FAILED); + } + } 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; + munmap(p, part_len); + p +=3D part_len; + host_len -=3D part_len; + } + if (len < host_len) { + 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); + assert(t !=3D MAP_FAILED); + } + + 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) @@ -596,37 +718,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 20:23:48 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=1704160962; cv=none; d=zohomail.com; s=zohoarc; b=Z20ikNgMq/GFct53J97n1KhteuMjk5fR/hxjRQQkL6tw3HWFJt9l8h4OjENV3UzBILxsUp4wpiETDZdHWKX4Pgtf/Qh/a9TOAVs4jZ6/D3TV+fQADUqbXEo7gZiqvDiJC5ZnCs+aNfGKaBV1EWpF3/VtPx0alJ36kPwVOHYMrL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160962; h=Content-Transfer-Encoding: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:Cc; bh=91iOKn1k81Cro3s73UIymmbxi5Yza4EKTI5xgt9Gnn0=; b=RHSFb5vRKqkvzt+jheOOfYQf1UnoKfjl3CkdTJwCyoY5qYWScObU/c3DWURAnB1ekmQfMgX+UnzWTHw2hhJfDnNHz3a0QYH2DSm+QRSoeS9Yk0OrFjdJKkUVcH5orqKD4DQpRKYTxIpwXYynpIsDW/hluDjNgYHGeRRfTzWDg50= 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 1704160962067980.420882665965; Mon, 1 Jan 2024 18:02:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3m-0003m5-Gi; Mon, 01 Jan 2024 20:59:14 -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 1rKU3b-0003eV-Sy for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:04 -0500 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3Z-000750-T0 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:03 -0500 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-2053f5e97b2so986358fac.3 for ; Mon, 01 Jan 2024 17:59:01 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.58.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160740; x=1704765540; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=91iOKn1k81Cro3s73UIymmbxi5Yza4EKTI5xgt9Gnn0=; b=OldZWGLkhKhYvSqCuv2XATUwEtFySavBMHQlSRyBGMXaoqtkujjEegVCniQccg1vNJ w7auVqEd+p34eSDT78iR2NIERR4yhHQg24UgYaMhQ2x20D14ja1en2XAQZs3fLkU/fkj oluK9ujK5zfzYAROdyQCzmr4GOK/RziIZkQs9sYnUmkH+9JlpHQzvfWQwlnnnwscHdIW 72IvlZwVUreRYJ//abw8MLApq3IC66eQ/qcb4zoKPktWOBsH04XmX/WytFdahJLVi2If MwpnI4WDddNoSKuM2pZNFCTxiabVWSFApfiVuIpQD99MxwnK6z8PIv1FNWZykEssZpLP asEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160741; x=1704765541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=91iOKn1k81Cro3s73UIymmbxi5Yza4EKTI5xgt9Gnn0=; b=dxk5YCqVlfeMyKzm0kqFooASeugkzotoJeV6B9oPVRt82eKbiMQ0GlyTsTJzPI0AW6 d3V9VS9vt/AJGcslNyPD0hrZ56m0Nn1tOWNokEDo+A0yLDnEMLzZcZoejeadqH6Jdv+1 FXnhX0hYKPxd25IjgX4knufzon3hlEge2byIk6PIqKLgISQxVVfk3301SZUoMxOCIhpG qwyqkvirosPcEtO20UU5G1oKOG5TNUSjpNa84L60joyHWtdb/wcUIsoQV12kmZSvGWJ1 eWelvW7B1r7mY/BUzBGE7hJtFDTZyxiCACJLJU0do1aYQMiQe55IqWmF/9cpJHLPtVw+ F8xw== X-Gm-Message-State: AOJu0Yylo3IlMsUpaBDW9D/Yjq74U1uVzts2wDFNA0WtjvtVr5GhcMXB eoMkDi5z5CREeEDz6LMgs6LDvP5zF55rEpjojo3GtJwTHOc= X-Google-Smtp-Source: AGHT+IGYg5vM0SNurC0dUPO4jU8nv3ckvfsHueTbmkKGj2jkei0FS5Cvr2u5UJZC4aazv9cYWROAVA== X-Received: by 2002:a05:6870:ac26:b0:203:7dc:6f26 with SMTP id kw38-20020a056870ac2600b0020307dc6f26mr20833991oab.63.1704160740652; Mon, 01 Jan 2024 17:59:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 23/33] linux-user: Split out mmap_h_gt_g Date: Tue, 2 Jan 2024 12:57:58 +1100 Message-Id: <20240102015808.132373-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2001:4860:4864:20::31; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x31.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: 1704160963723100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Pierrick Bouvier --- 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 8b0a26e50d..552656edd4 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -267,7 +267,16 @@ int target_mprotect(abi_ulong start, abi_ulong len, in= t target_prot) return ret; } =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) { @@ -674,19 +683,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) { + 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) { + 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 suitible hole and convert to MAP_FIXED. @@ -700,6 +828,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 @@ -721,150 +851,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) { - 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) { - 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 20:23:48 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=1704160940; cv=none; d=zohomail.com; s=zohoarc; b=E1O3jFv2GCy9M24k2IVQnnx6QrtM7YLZOlc2faMpQtc/pB2TFhnQ1Kr1NNPeExgVAf2O4CWmFRy/oeBKLOGxNKl03UP2uhy26/pyVm+CdivloGyIxhU3NgbglCa2ccGwIb+q/qCPQaR8pEdrucG3Kb59R5vx+ChPtyrHewpUk3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160940; h=Content-Transfer-Encoding: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:Cc; bh=bvIqJJvCSw/W2rsjpUyM+grSiLNxzontPEfDkoi+BAY=; b=A6Zp2LUGjNMsug9XPo/KSskQB3Cg4/PNNOhZx/etGQyAMVzn1kzUl6ChnS3qI16YN6j39tnvodkjvgJVwuXPFwSToOeCmBOcKlVoV1A+qR+L5tiR9Erv4RIGaYMW0jgwKkJVCQwBhh9kQhZB/2/hnT8JsdYwt4F7uMO5lbVXIEk= 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 1704160940495334.301091567428; Mon, 1 Jan 2024 18:02:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3l-0003ks-Om; Mon, 01 Jan 2024 20:59: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 1rKU3e-0003h6-98 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:06 -0500 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3c-00075G-8E for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:05 -0500 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5ca29c131ebso7061097a12.0 for ; Mon, 01 Jan 2024 17:59:03 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160742; x=1704765542; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bvIqJJvCSw/W2rsjpUyM+grSiLNxzontPEfDkoi+BAY=; b=JRk9mckAbx0Gpo8a8kue4mqgn766jHX06a0Cm+FmT23Hg1JBs7tF6+EQy0vYA9p/3r Zi2i21MbQsw+wisPvsRgEtlWlDTyRQC3Ecjpb6mLPdy0wgemdBdI3e85wEbq4SBvn9at XZX/XhQioDKieZPAiFDuta1IRwSMQUtxZGxaPEOjy/AcwzFLGBbT25EfaiACIfME2uQI 35vMmPfGD58cIztEZbJ67kyLL5Rh/dpnaWczLsk01k3XbJf9s098jaP69b+rsMuTq/26 rGYi2d0I0oEhq0DOwHU1JadPGNldv32/ZjEO3UmVC/8lhHCGa3iPsdFLm2sr1ZEpqA6a 7peQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160742; x=1704765542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bvIqJJvCSw/W2rsjpUyM+grSiLNxzontPEfDkoi+BAY=; b=slzA+5vzppHWz5fEs5xRyw0lZlCEpKyFBTzjdkkQBRqBCJf3LKuHb0+gwkWDaXK3cW c9H7jOUTOQCGIq6K7r0syKTBI0oFH0yQ3EAYPA4/xhIyG9XnSiD81ecNXxymxKbpNvFt 8vlX6gNlnGjxKuPGiC/GpaGxcwk/I4y39YC8OK7X9oL9FsBifVhAFZvBCe/IZ3ose2mw xExNHHh+4TB437/JM2LjyoQVc7ji2RJQFwQz3X6J/6YkRHxE6NhN85Ad0C9WOAehBazA VNukUr35DJ+8FTEa/eLHlHTZ5NyO3O33+SDePFW9kIVvX4pHWP/8dVX8vi7wo1Hyd4e6 RhFA== X-Gm-Message-State: AOJu0YzJpHedoujS04BJgpvGYRhW1/ejhYHyWyUouDH0X0QF86DCdvgY XWVUQ4LxzAE0CfghjPxaI9/01PfDpFvmAjZhp+s051C0iE0= X-Google-Smtp-Source: AGHT+IFraYfav/X8fjYTrS0tGuYreEBt71E+gkv9Bw/uq1AeatsGlSOAuSD5f2MQSNPvCAYwYY2VqQ== X-Received: by 2002:a05:6a20:54a5:b0:197:2fae:794e with SMTP id i37-20020a056a2054a500b001972fae794emr1559210pzk.70.1704160742526; Mon, 01 Jan 2024 17:59:02 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 24/33] tests/tcg: Remove run-test-mmap-* Date: Tue, 2 Jan 2024 12:57:59 +1100 Message-Id: <20240102015808.132373-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::52d; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52d.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: 1704160941767100023 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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 3dec7c6c42..53540ac96a 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 d31ba8d6ae..313f7417ba 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 20:23:48 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=1704161031; cv=none; d=zohomail.com; s=zohoarc; b=ToTkD/Jy2EJRoABJ3fdFLoS5NoFX1AX96l0NsZgBzZeT4zvOSVtWthUuIzs7wcnVTGrkT6YuoBMumGGWT4FK2UIfC7eFGPLmx2ZxqpWiurI/pCH7xKP/rZLfSBqcf782nSONeFJ32RMKBS+a39kM2DuttqxAhgF/wMvxRGwk5Kg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704161031; 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=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=lDQpptU5XxLF1sd83eO6tXZ8sDgGE+EXqaKQ7PGJOlqM3vJbqMmcvdGR2mVTDlwc7X90DE0Ase/KRTtVxXaToMqQxURydoJ5PTnkfRt6XIXb/YMDEh64OpClF3zm+JJMj0q/SID5uYG7m2I5fz8HppD9JcVAk/LfuC72z6+WXWs= 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 1704161031181670.1069922819819; Mon, 1 Jan 2024 18:03:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3n-0003mI-Dg; Mon, 01 Jan 2024 20:59:15 -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 1rKU3f-0003i5-Iu for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:10 -0500 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3e-00075W-2P for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:07 -0500 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c21e185df5so6728040a12.1 for ; Mon, 01 Jan 2024 17:59:05 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160744; x=1704765544; 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=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=MPckM0YuV/jFqFQXkL4L3ij7UFn8w2pCpZEHmpn+IL2RfR5jbjDktgy5t4Z6Wy1MtL wONNQiuRd4U9nyiJxrxq7rexQeBT01y29735acTYma7+OvbXFXo1Vkl2FRtYhMbHJYCp XpNmb/3yjJWeKZsnkqwbGEikK9nBEOzVbIHJNeGYjuqN4d4c1fRQNFZngH4Qqr/Q5pVT i02PEQ7CC4b0YBaC93mcqT5FNSAiGXa3cftdBFS14IXVk5pPs8mU1WhjpUboe2m/tygN VogTsoOCAHXbAPXvNbzTRWLWpH4ZkrvVZk6kbMr9XpoT5NS/375NcWa/tAEDQfBLxPzD ppMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160744; x=1704765544; 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=NKBqBWVnteg7nBg0Ct8xapNabPHsKvd3tq3kc9va8Z0=; b=iYHo4d6TtDC/OcAGHk0W2McCOVL7KyDnJaQknabJqWwvIQ/xOk0m6anW2EWa8jSgmo 9wz6BZ8WS/sia9HN2Biwh6nVYClO0spf2JECy9s4diAOXTlNEL/6P9uAnzJdXJyRneVR 2tCgswJ03ofsfmDg1L06FP4m4mllQYDloHoXhMTw37uS4n5zlXgfwqyCvrHVBXusM+Ns 25FltSO7UVnviyRTQJg3E71sqAFUuKI9/q24S3UmFlPXmHqxH/9KteDFEfghT5Hu26GP ZH3HTB/Dr9wQu+CQSZSk9MD41lemfbqrSIUzVqUP6/XA5cEE0oMC4H2XAb6ne+zhcF6G BoSw== X-Gm-Message-State: AOJu0Yzbc0B8ErW0ajTtGiI9eVD04LyqBa5bTgf7qeI8owIVWBFjd3rv W1fe9QZj3nrzQvkQ+KPidl7s1vKVu0oSaTPs6Ov1CHcdjGI= X-Google-Smtp-Source: AGHT+IFyMl1BSFmDo1oCTQ1t0Wp94IaM/eRJ8+F+zqGdVPQfbblnHF3Q5w9g52gO8YEsDlOXQzB94Q== X-Received: by 2002:a05:6a20:3791:b0:194:ae7b:3847 with SMTP id q17-20020a056a20379100b00194ae7b3847mr16474705pze.34.1704160744753; Mon, 01 Jan 2024 17:59:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 25/33] tests/tcg: Extend file in linux-madvise.c Date: Tue, 2 Jan 2024 12:58:00 +1100 Message-Id: <20240102015808.132373-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::533; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x533.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: 1704161031884100002 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich --- 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 20:23:48 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=1704161021; cv=none; d=zohomail.com; s=zohoarc; b=A1+74tuFeE42DDpUEGsaQhwodPS22WPQvQxbCTQejHGl/4Tl9LTzivCTlLeet7xRYWDmUsqRAmucotrged+AThxy7pRbaiVziAh01e6Mibwb+dPl4ay4uVo8hSSLsdIk/pLDF73Q4ycRsuJI98EiKv7zVVPJJ7XSZG2p5iggHYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704161021; 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=/LV9BWeIPWKBGrvgXFvetwVNAgJ38p+dzeW1kf+TIio=; b=kzTdz4T6pa4kM5a+gk6tld9jSvu9HnSLpKmMG9EqPE8YbENZ2Kq2CNAnmnyYzJxKxFzWPARa2uYV5NtgxPzTJQH9twpz7y3zhu7oCVMOqBgdmYs1ZKZZBkKZUMgNCTZmTdSAzaBFBw75Rk2MOJ/VDBzFxmKnzg3Cxj+MwnnL+u0= 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 1704161021894159.3202274443995; Mon, 1 Jan 2024 18:03:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3o-0003ms-Bp; Mon, 01 Jan 2024 20:59: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 1rKU3i-0003j9-Lg for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:10 -0500 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3g-00075j-Ed for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:09 -0500 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6dc076e9e59so2729515a34.2 for ; Mon, 01 Jan 2024 17:59:07 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160747; x=1704765547; 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=/LV9BWeIPWKBGrvgXFvetwVNAgJ38p+dzeW1kf+TIio=; b=SG/N1pj7BXKzF/Ss96QBChs2jsUHiYT36UCi15Nq2XipIoKNbt/2YezgIJaPfw0bra BlP1EmDs8zROAWZ1roYgjjN+YMQ0aS1hRS+3uFNirjnRsN9hd3QM+36AGx3b5SObvs9a BHafrX1wr0VeF3UI5P83Wo8LrhH4uoKk/zDCl+AhM9ns+Gk9+0gOkECD83cmYOM74O1H 0n2RwdDzLpSwU0c7ratI9DEYP6bfWGwwMhR6sklbg6VR3n4HLEy/FH0PcqoAbmokE2xQ 4B1acsgztcpxXplbMDhzFi1/TADHZbe5oWkb2QM1vIUyPuYDmGjGOI5hX6JsHrDmtseQ ROXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160747; x=1704765547; 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=/LV9BWeIPWKBGrvgXFvetwVNAgJ38p+dzeW1kf+TIio=; b=A5CEy12flEhTOAG529tvN+CKFBoAbv5Hll6h5iF5otvkuSv3QPVmVSBiF5yAKAMVUr i9rXjTz/eVy+iiJDNQmUS/WDQd6ZWaDQ/9vKMbmYnoiAeTTAQ6Pk7b8XQEf40kb3htzW +TxjP8adzMyHRRnkKTQ9atVtBYpGtujmcQgX8unceYnq29GCSZaV59MJ9WENMa1tf1/T pAOY7AOWOECOLteFE1foj+OEtzVRBQhQIjmtwfwWMxwa+ICIt61rkOUsOmby/n/ocjSL Gv/DC/8iJP7+EU8JwQciRUF1VHiHrZGNF13R8G5Ejqnb58xg7ko1q2c5guH8oCHFDL6q hGtg== X-Gm-Message-State: AOJu0YxoCBpqI5j2OOR8M/4bqQS7u5qo15XGKprR2aNzccKwEVC1+Yqg MEVkzavcYDWQfhSIGS62q8OZNqLdKe06J3zmrb7qutoy9rg= X-Google-Smtp-Source: AGHT+IEYU0ikW+j+V1JZPhxVm/73oA5fxUtqhtTGcbdV1s3BKxrC+q7yu0IeqU0GKAbfqlvT8igRCg== X-Received: by 2002:a9d:7659:0:b0:6dc:48c1:3e4c with SMTP id o25-20020a9d7659000000b006dc48c13e4cmr1888122otl.57.1704160746868; Mon, 01 Jan 2024 17:59:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh Subject: [PATCH v3 26/33] *-user: Deprecate and disable -p pagesize Date: Tue, 2 Jan 2024 12:58:01 +1100 Message-Id: <20240102015808.132373-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::333; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x333.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: 1704161023918100003 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Helge Deller Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/about/deprecated.rst | 7 +++++++ docs/user/main.rst | 3 --- bsd-user/main.c | 9 +++++---- linux-user/main.c | 11 ++++++----- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 2e15040246..a499583a62 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -95,6 +95,13 @@ Use ``-accel tcg,one-insn-per-tb=3Don`` instead. User-mode emulator command line arguments ----------------------------------------- =20 +``-p`` (since 8.2) +'''''''''''''''''' + +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. + ``-singlestep`` (since 8.1) ''''''''''''''''''''''''''' =20 diff --git a/docs/user/main.rst b/docs/user/main.rst index f478635396..3a07be1278 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 e6014f517e..ba159d2984 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -365,10 +365,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"); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D want) { + error_report("Deprecated page size option cannot " + "change host page size (%u)", want); exit(1); } } else if (!strcmp(r, "g")) { diff --git a/linux-user/main.c b/linux-user/main.c index 5f217cc2a8..9ba4dc5872 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -332,10 +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"); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D want) { + error_report("Deprecated page size option cannot " + "change host page size (%u)", want); exit(EXIT_FAILURE); } } @@ -496,7 +497,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 20:23:48 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=1704160979; cv=none; d=zohomail.com; s=zohoarc; b=itUG2BSbPL2hUV/PD7crUWDpjeEx6oXBBuCJqoos7yZFgebIxa6v3f+RRADe6KARH/Q5gq8snGJ42hEqvS5Q5accg1BfOUnxdasp7tyeB5JfGdIs4qoJhglJ+FrqghgDhNI4e2AZFnAbQZGNPmbbCydW/mzSFrxAh2yiBTTxX1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160979; 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=niLg9Fo3ohbp8xRcoT4yGSYdzX+fXCYm2yVgdAWEpSM=; b=bQgb1935+flrNQ6wB+nks0Zt+BYNXYk6Ga38jhgVIPqekwfNYFPQYn/6gJLcSn05vkNtfmdCZexJ+xT+UuUs3xsaLAdqS+itBWG7wRa288xRn+vOgYVybIheLncvFGNmMkTky9SDK8y5IhKYofAgUwa+X8Gz9GScmkVbBbQsUek= 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 1704160979510871.4998663830345; Mon, 1 Jan 2024 18:02:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3o-0003mP-5I; Mon, 01 Jan 2024 20:59: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 1rKU3l-0003ku-10 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:13 -0500 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3i-000765-EX for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:12 -0500 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-2044d093b3fso6010981fac.3 for ; Mon, 01 Jan 2024 17:59:10 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160749; x=1704765549; 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=niLg9Fo3ohbp8xRcoT4yGSYdzX+fXCYm2yVgdAWEpSM=; b=Kbrn/QI2g285S3RS6kAJu/uo8GbEm/zQgRL5rSjWbXC7mEUkZX3yTGUTJiKfWAsDRA s6Ov2mOagUz5K1zCvoHmYmS6ggvce9z9s1F4vO98WMXBDDJiwoP6IpeXxXdjCjag5FUp /XggRl8Yb0WnDPeLHa41djmSIkXa5JbPqPLCAcTNZNBcYX5QBeCYOgJwB8k1oThAFncC be2oPHGSRXvF7NY+XDjsArZk2qpFJ8AsS22cgSWd2BOnumAnwX939lvsC8m2+gBfoOHB 76RJ/gu1j/8xm7wyrVt1dgt9bhB/OlQr63lPvaQkviyIkgFo7XW5XR6MeSS4te9USKrO XGDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160749; x=1704765549; 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=niLg9Fo3ohbp8xRcoT4yGSYdzX+fXCYm2yVgdAWEpSM=; b=OpjQx4VGmyzjFPV39KS+icm53gtZRj59UPvW0WjUqqCfLXefQs5CKczND8C7eT3l3C mECSLzmV3inttILaQsB1zu8QcQXNUtY7+6545X7bUSKFo7Y2RKCtjs6Ezbb7snWw4ayk mejrfW0o4JhpNxd1SHe86jjZf9jrQNfwwyWOH5X5Cdn24Jk89rq/WkmDot1FlnPzWLPP hT8qdR1sKd1+icgLh1PmJ+lJzb/Hz4/NdCnO8LVYqe1nel40kzb7Nal6DT1qv+4+7UrZ JDfDtRHnUuXklSuJfjQYOjo6JteQ6XciusgPe1FuTlDLZVHT0zdyJ3b0fgZ5qz8FpYQx bpKQ== X-Gm-Message-State: AOJu0YzpYEO6K6HHYtNYy2cjVJeACV0e4gEAp0wlcP+2vYgpQ55IDSPD rwJVGArlxARPEmqnCFsAIKmImZAX/ug2JK/aotr7CbFAbEo= X-Google-Smtp-Source: AGHT+IFT+AtcmE56JpSbu3zbN9zL1ifGtUo3++vf8EPhE5i4RngjIZMhnoBB5IrmqSTnrPVgf4Nukw== X-Received: by 2002:a05:6870:b1c5:b0:204:7385:31d2 with SMTP id x5-20020a056870b1c500b00204738531d2mr16338388oak.117.1704160749372; Mon, 01 Jan 2024 17:59:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 27/33] cpu: Remove page_size_init Date: Tue, 2 Jan 2024 12:58:02 +1100 Message-Id: <20240102015808.132373-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.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: 1704160979818100007 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 Acked-by: Helge Deller Tested-by: Ilya Leoshkevich --- 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 41115d8919..e5b4e062ae 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -29,13 +29,6 @@ typedef uint64_t vaddr; 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 c0c8320413..61bc88a0a3 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1169,8 +1169,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 79a88f5fb7..7c29dd97b2 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 ba159d2984..184d94b0a4 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; @@ -308,6 +315,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); @@ -408,6 +418,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 508013e23d..ee04baae7b 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -411,16 +411,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 6b87bfa32c..d4f5a42075 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2108,7 +2108,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 20:23:48 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=1704160953; cv=none; d=zohomail.com; s=zohoarc; b=D5HRNo2qLW03q83Ok0CyAqsY9VekIiOgv496gViB8LalQO1pw+tlPnDxbIlHKvKdNe2Wzl2W7YyxvMPWTxRnxzLcnq8abFcAVCDtkkdMuWZW6IFDjImNQC2QVKkBtPJosIaNCCDPjJFx9BBZL5Xh8clRQjHIpf6HbQxNZ2Wo1X0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160953; 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=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; b=TqS33IT08u40x7/RgwbHNtgeAF7CXgH/DvRZR0NeYrBx7tVgSPKkbecPshxDBOdti6ZF8kuNFfVTqu/aoHvP3IOk0FMejVDJPHhT4gVnPQEILxHt08pUYIAJGqVvxaNM95CjDejf1RtEljpB2bp2VNtJiLd7sY4dLJ2lh7/tHDY= 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 1704160953777528.2227766173146; Mon, 1 Jan 2024 18:02:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3q-0003uR-ED; Mon, 01 Jan 2024 20:59:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rKU3n-0003mQ-Hh for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -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 1rKU3l-00076K-2f for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:14 -0500 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6da16ec9be4so2960039b3a.1 for ; Mon, 01 Jan 2024 17:59:12 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160752; x=1704765552; 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=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; b=C6ST8qIzbaU42A9lEtS7ekxef0XwDsuruGRnmCpEB0JjOgKDeNkSaMWiZ57Akwf+4e 7im0+1R86pa71KK+ism5m4vu8juewvFB/d9qrxPtRjSrBKUct5PyUpk1Jjm0oYA6RbCV Ii/NcEaC9WRYT1LTjUHd4oZLF9+OqSwMmPvOXEH+f9qLV9DaBxhvi7ZpGlSx0sFZv555 Vcyh2pxt5wx6Yw6iWXlmRb8rhTSCzThAgvZ97dCvPi+reRR9kQNORtc0K7hn8SvM5C9c rWGU8JQXpwwlyQamBuNl08kwsYTE1IUF2Yo1nrd7y4EdobMc502WUxbHrUJmZAoYiMcb 2jig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160752; x=1704765552; 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=va71e7xBlqUEdFqBnPLdQG8F1PWGxU4pyOMI1WZcB6A=; b=qC+uwnpxE8I3eemnOM//osKQ067qzp3/MVa+3CvOs42vHwO8PHE71Ek6hRkBXje+4Y fzkM6w/2m/eWWdcqJHzVxeoYdoGcya3Y6TaLnyri4NSCYzZ2tp/NeMDsc+NsnFVZTyck LJZT8ddrLX8UA0a/0IU7rZk6SyAyrcF89geY3HmLwDBw8SbOttpS0VL9n+hzJpMERW7m Nl0KTYN52JsyUppbhgVeed4xS2oBdOCWlde6c3Xl8VpZh69Rwe2niYC2wRi3ENSqoK2n 6DW/ke9x9r+vpdyxHFGZJXYJOADqFndoH1bY+aAy/HavjQIKIpShmY7+g7DDINrxh0GF T7Vw== X-Gm-Message-State: AOJu0YyxKNWOlXP6UzH5ZiHMHbZrKJGjkiqo25SSYr2ZRhb3IXpgXX1b +0TDRfjsmeSlN6BChRczKccsVyy8IDcgs4i8YtKE7GQegRE= X-Google-Smtp-Source: AGHT+IHxOpMw/kFulV8BXv8uvk7dhDlJoeuHsqZInbhZZWiJ7IZzzOrZpVRoSbhvLdeItmPUD7cxjg== X-Received: by 2002:a62:8455:0:b0:6d9:8f56:106b with SMTP id k82-20020a628455000000b006d98f56106bmr14876576pfd.39.1704160751781; Mon, 01 Jan 2024 17:59:11 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 28/33] accel/tcg: Disconnect TargetPageDataNode from page size Date: Tue, 2 Jan 2024 12:58:03 +1100 Message-Id: <20240102015808.132373-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::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: 1704160955692100003 Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich --- 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 20:23:48 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=1704160781; cv=none; d=zohomail.com; s=zohoarc; b=V9OGhqmz7TYlNdy5s1TgIkTjiQ93QxCH++6wMOqD10e/j7pze7Gh/AvvDV7e6angreDsDu+OHwCM45MPygOVCUZXpedDIE51xP5AsMt7hNWFml4vPZhcFxBYktN091/MY4VnfoSHaPmZE6RjmtmBYotExDBHCBeQmEvOJ8ALFYw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160781; 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=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; b=QbKo6YBZxylcWJowMkuFJipq2HfMFbtXJJTaNBDbM0U80jUFuPegacCNOAtNVMLU4+Rix30iM9F6ATNxzfJBoHQQpMfGdmJVCf3Y/qdSDAUeaY6hMAOeM3JaB9lvzq0M7xBo4OSA70XzG5Mt9wiXOXx/Ct8Xvu4jbziq29H/7N0= 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 1704160781409769.8042279043312; Mon, 1 Jan 2024 17:59:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3q-0003wz-TC; Mon, 01 Jan 2024 20:59:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rKU3o-0003nJ-Rw for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: from mail-oi1-x234.google.com ([2607:f8b0:4864:20::234]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3n-00076e-Az for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:16 -0500 Received: by mail-oi1-x234.google.com with SMTP id 5614622812f47-3bb53e20a43so7596606b6e.1 for ; Mon, 01 Jan 2024 17:59:14 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160754; x=1704765554; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; b=Z0nnq+/b1pW4yKSicEQF9GaDRiXWh+0hlcENiwZ/kShnZpxvRe0wt/b5DN6RS/McI3 vVhImIxmWesfn/+k1CVCiXQZtsMnAaavU/+DaUbGCeplS7gHngGTCk5BDcen+g7yY+YE 3f79uChMAitwr/OlAxKvA178ds1cb6uxsskKvDn8ZufNObxnEjQ5c7eMozcbI1BgJerA 7U4hbEfMGV9maDzE9kUVdbqmEf4epQHiDWy8+toctbxJG7S43yNcRDqEkhM9pgHifchR JSTYknfuxS9ImascdbN83vp0AC+UafEXtHmPBVTM4gm3yAKCLM+kcxu8X3YJFvjngy2j w95g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160754; x=1704765554; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k2uOfnGHlQ+o+S9iOylPG+ACTd3Ii4k/xbpKgSOUwLQ=; b=q5GHnplpMxD4d+LBTH8TVoFAsUe4l45N98lTVMrkKZp7sRTZAEFW14j2r5QFUWfljD n2/uHIUdLq8Zb/Xj/FGiA899tPm6SONyXpv/aCLA1c4bEWk/NYmMoqrraZLM5eFS6TQg +Fr8CUvJ3Y+Si6NoDNzW0PUgK6W6PMk7zpMJbke9SU/sT7zLSoRezsbHSKu5fznrBNZJ jdH60BNo0eX+eROAOynSXird13zFVbfa/6FxORuHt6u6OkibcK46FZoOO0zrE9EQZY/d mw52rD5TVvnnLiVaqG7IJuFO5LnLkqNwjcSRs+kuKeROCqw1zN09+25lW7lmDSEOyzXF TIyQ== X-Gm-Message-State: AOJu0Yxca5SbZaqSph+MgV4BQwuQUfp4IDJJs7Y3/N6i7q10znkB4wQ5 NSLsYt+Wac+mSU85+tjhwCex9eDFUmaK67RAUPXxXOw0YVQ= X-Google-Smtp-Source: AGHT+IFG95tlgadQklNOeu0a1JBMiiEE3NcS664mbmF1vUGQpBVLRx+EvOVCWXQvq/WmVfUMVGqirQ== X-Received: by 2002:a05:6808:130e:b0:3b9:dcf0:63b9 with SMTP id y14-20020a056808130e00b003b9dcf063b9mr20258295oiv.23.1704160753974; Mon, 01 Jan 2024 17:59:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 29/33] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Tue, 2 Jan 2024 12:58:04 +1100 Message-Id: <20240102015808.132373-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::234; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x234.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1704160783221100007 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 --- linux-user/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 9ba4dc5872..d00a0d7d1f 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "accel/tcg/perf.h" +#include "exec/page-vary.h" =20 #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -683,6 +684,7 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; + int host_page_size; unsigned long max_reserved_va; bool preserve_argv0; =20 @@ -794,6 +796,16 @@ int main(int argc, char **argv, char **envp) opt_one_insn_per_tb, &error_abort); ac->init_machine(NULL); } + + /* + * Finalize page size before creating CPUs. + * This will do nothing if !TARGET_PAGE_BITS_VARY. + * The most efficient setting is to match the host. + */ + host_page_size =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); @@ -807,8 +819,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); @@ -907,7 +917,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr =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 20:23:48 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=1704160780; cv=none; d=zohomail.com; s=zohoarc; b=hv0YXkCkxJ1VhyiScaV4+86fXNVEi0Yoi47v26bMiNX9E907QnlKyb3IeTSSruq2+aPh4KPUZ/xnfWSze4S7hNHXReIipXujab33s/gVV16d1w5v7b5G+tZrQWEl/leQpjcmFw/E8OjXNzXp2ODVmyAC66vpcSI+3tYO6UMWiLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160780; h=Content-Transfer-Encoding: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:Cc; bh=X/nN0RXer0FvEyJPG6YS7iKCkVjd2CoiUqtQ4iddbsQ=; b=AZKk4XVUnIHhtxK3deI7nQAM9zw75wPeBcAdneigLSCUIx/UIYgAUCWgFUabYfUFPA/BxhGdseZeRbyZDOs8x7eIOGx2mAKk1Xun5ByUu8Ajqjq0m/7wysZCXv6xVPCBPQjIYEwcJSyZxmjntBO/8JtK6LG+2m8aQYCIOKJP5aI= 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 1704160780167510.7202086121023; Mon, 1 Jan 2024 17:59:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3t-0004AV-U5; Mon, 01 Jan 2024 20:59: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 1rKU3q-0003xF-UO for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:18 -0500 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3p-00076o-4b for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:18 -0500 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-59496704246so3342563eaf.2 for ; Mon, 01 Jan 2024 17:59:16 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160756; x=1704765556; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=X/nN0RXer0FvEyJPG6YS7iKCkVjd2CoiUqtQ4iddbsQ=; b=rE10QV9nUKPqCnlX7wjLmse7lSVX3maC9G0l0JF1p4/0RHPb9IXfANd2vl+0XhY/pT zCgahY3GHzR1TzZso3ftmfxUOqJ61iPNtL7TISnEfhah98mKacnG3Lt0VfoS7CaadKb4 paoEfeL1xEkszqO/KgVP2ZsCUtnXVhR+KYsdG4+cMo+RFNqVkjbMYfKLq9lfFkzySIBm SMgEInj7qK1sLJn6P+pHnqo+0esqoVXDBcLym/uDWwU+9lKaBTQVi/cqDx2MwfBeB/m8 2HgDAhPV1T0eyEugMdj7HNPzHmO9b+2oRaqAAOcx9F/n45G9xCL/AtfiT3NXrDyxusHB c9QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160756; x=1704765556; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X/nN0RXer0FvEyJPG6YS7iKCkVjd2CoiUqtQ4iddbsQ=; b=QYCsnSWIDZpPY2Q/r8Jb1nGMXcJocmwYOJs6eT9AS7AAQ+r+JnlsXZ9glxn1gM+/nq 3lMnYVsb3vBABc73rEdzpQa9mdz374qDxaMtGIj5DQpzu9GoqsIgIKQ9ZvKkbYK+w7Fz nBttpaHKR+fBCi7cGQzPkJxwjCxbAxDlB1qadxDS/922l3nA47DLxAS4ZYq/x2F7JNku 1mHRJiH5sPuTpkihdWVmcJbQAo7jUWASzXUu3J+H9A4ucdhXmj1cmRa8WMJvxuTdYdWb jgovKSHnpOMeyEffvxIHDgNt28BJYUmoyC5QTktLsDd8RAmJCc69TB6Q9pYSlJMHamKK Wq2w== X-Gm-Message-State: AOJu0YzpuTVPp2Wgd8OYnrw72VSThM7BkUPXfo2sT9zMG+ImGfV6DQB6 uZVTiHzFBfSM67ttpDkYOi56wH+xOqo5oalgXZ7e28QgqVA= X-Google-Smtp-Source: AGHT+IGRTRLzvzJaPaPnldx7BfnEIo6YVII7WifDwUSTN+SF/LqlMcnKjvyYAlVDxPlX6FLLqOHyaQ== X-Received: by 2002:a05:6870:2254:b0:1fb:75a:de6f with SMTP id j20-20020a056870225400b001fb075ade6fmr20876889oaf.93.1704160755855; Mon, 01 Jan 2024 17:59:15 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 30/33] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Tue, 2 Jan 2024 12:58:05 +1100 Message-Id: <20240102015808.132373-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::c36; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc36.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: 1704160781243100003 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 Acked-by: Helge Deller Reviewed-by: Pierrick Bouvier --- 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 650e09b29c..55c2888f2c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1788,7 +1788,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 /* Use pc-relative instructions in system-mode */ @@ -2079,28 +2078,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 20:23:48 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=1704161032; cv=none; d=zohomail.com; s=zohoarc; b=cASqdutO/R6Ay4Y6Ih5LjnWaZCS8x2JqpuO+hYSAZrSLq98sue6EzDBq93Fm6wn92bX/moAX4vt0IcYs1LGOWYJM8oBBOhOQvgPPTEXGJG2assJGRwCkRFZyOUH2oyxu0VdHBimQadHuT17uyogH6iwT1w4ox75atu62IBfdTHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704161032; h=Content-Transfer-Encoding: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:Cc; bh=cKA7tvrOkGtPLWpEPatX1MbkSLxefO/Qsp6i6MEPEuU=; b=Jh3gfq1CLBx8WW+OnS/+nWJtlGkw2+IRmyoZ8jcoydPLqPNw1d4BcdxAiq7GKIVc639mt2259WGfDTAma0yj4v7tRLuI6STk6n2PRjntV9quzgXMV03BORHUBdga+QSW6xwvaGCN5J1aaEmwjImQw4AzwSgMSRGLLI/ZWu8Qxn0= 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 1704161032687973.5887394101766; Mon, 1 Jan 2024 18:03:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3u-0004Aq-Ge; Mon, 01 Jan 2024 20:59: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 1rKU3s-00044I-IZ for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:20 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3r-00076z-0X for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:20 -0500 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5bdbe2de25fso7047200a12.3 for ; Mon, 01 Jan 2024 17:59:18 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160757; x=1704765557; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cKA7tvrOkGtPLWpEPatX1MbkSLxefO/Qsp6i6MEPEuU=; b=Xbv57JQwqEVC7t8eeKcadGzP8eoMWfKouwFxmMHCgmBpH2m8mqSqWubw3n3xV+wAmr XIDABjfTqDz7dm6HXiJPxmuiaM5UOEDgp8e6j/x0dZ+oQYPqAIdcUDbXUjIsthJ2qJl/ oZDGOSTOrJuPQTkwlMZHDQlH4Tc54FrXHQN8UDnn/gOL5AH/F32ccLOjnrztg5VPUktS NbeXrwPfZxa0wRSMwTHnzmWDKeNXXxEWJ7iTU6iox2nLxXYBWJKQ1BBdEDp0TSDyE93L OJvsXWJkbwIN0evh0LWy+Zy/Io1CveslhPwMSgHD2bdLALDJl2hyJVNh7Sm3xJnJqfEC zdhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160757; x=1704765557; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cKA7tvrOkGtPLWpEPatX1MbkSLxefO/Qsp6i6MEPEuU=; b=aKfbOYW0FiW/KK3rRopA79Ck1zq3vWO77wF+W2Ix0r0CWaXNSOqpvQeV/6/YhLczqw 6Rz5bTghYFYLiehAluHFnNeGgVYNbIiFniKMwjpK0iFpWIRfxG1n5TCdr2s+2Ckpc4ss jftcbm0mWC9UwLDYKNFt4uZCE2MnDaSRfWpGqA+kIDcQRgh7TaaDWRDT+t+Tw3202Aet u7w13oYXohlwJ4GvuL3e4Hrb5a14gAf8/CQm5SLE6/ONK429RTF5VCKiUMksRk6rjduR H9NocqlU8ay1auIR2yaugB0ePxjolF0PXcs3quWzAG4SfuC+9yAQsEtEeHSEEVDKcLoA 0Qkg== X-Gm-Message-State: AOJu0YxgfrsEkbtu/K2FUKomz7L2qKjAXg5/u8YwHd7UHjhc4XNlZ2BE pESURMkW5UnjtnYo9G/aSUG2qyikPpWbd8k7C13QO6VfY+4= X-Google-Smtp-Source: AGHT+IF0VPFNCiKp6I6Eq/Eruaa8wVMAxzlNRHyjfPYWdOyZa/83k0so/SQZYzKzRLH3ksC6OgqwHQ== X-Received: by 2002:a05:6a20:321b:b0:194:228d:c24d with SMTP id hl27-20020a056a20321b00b00194228dc24dmr20490371pzc.42.1704160757558; Mon, 01 Jan 2024 17:59:17 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 31/33] linux-user: Bound mmap_min_addr by host page size Date: Tue, 2 Jan 2024 12:58:06 +1100 Message-Id: <20240102015808.132373-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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: 1704161033863100005 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 d00a0d7d1f..d5f3fa26c0 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -904,7 +904,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 20:23:48 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=1704160991; cv=none; d=zohomail.com; s=zohoarc; b=jE1mR80JfkO1dLaTz3kdCAn48ZjrcHCcefVRkNFO+5F085yH+vyjvHsoQWNWJ+HO5Mr2JpDSmzqaCL+n3zfv+kb6AIiJgImrtYR6OrKrGKOcVMF6Ygb5M/iM/xTQKv3mt6UK2fq2JmMrxpaOGfb0ZmiYF0/j2Py2859PRoxEZ4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160991; 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=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=PWffdNbXv476SOsTnc2mV2qMgx8sJ1eL48YKo9d18bXKfKh/gGZ1ZhCWRkYS2Xou1F2ibbXNpH25qr1ydl+QeatJlxN8QMUKcat61X18MfTlW8d0C5mSX+/nkd3w9C0ZB0TXpsaTirYUj/EfAW0e9b8cqwznvVoYD+wfdHCEgLk= 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 1704160991289201.40516847734864; Mon, 1 Jan 2024 18:03:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU41-0004lj-7H; Mon, 01 Jan 2024 20:59: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 1rKU3z-0004ib-GM for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:27 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3s-00077B-O2 for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:27 -0500 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3bbbf5a59b7so4339660b6e.3 for ; Mon, 01 Jan 2024 17:59:20 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160759; x=1704765559; 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=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=VO745913dsuHX2SLsDvYLQNo6hJS46AwNkxsfMcQmrlkBf2kpVCNV/9X7Ksml++tXH kTDHSWDHItq8t3YPlFjPCGiLFGJrmoTbco5gtvZClfilow6S+1rpazuXlaev1neXFduP RPyJSBoP/If2rRyCelysW+NL4hmnB7LbMZqAqpZWBsH4rZZIMJkSYaTsvZ5Bj6dWwxwW Tr+Xi3fROCD00hBIFa502xxZdYCVQyuc7QaWiUusEWBOwT/qH7jTT2bt6cF2cTusR7SL ZSxlUtuOQw6lPsmytOkH5wG+zKKp5SL9bX27xAFmUDx78BrWZwL2DTc/yCbPXQ1Gq4xf eGBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160759; x=1704765559; 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=YzcEJzTW0FxXggtPi1Qrm/hCkn19peXK5YmTgg9HZqo=; b=WfuQXhSpILCIG06tvq4kGfwkWIDJnyZG36nldmbcknUF/PBzfgPgTq7m9UdovqFtUC rLpM+i3W4IDuIfc2A257Pg8TlBHF97K+evQRyuifxXd+QKsIk17CgMMYxmhL/S+xQIJ3 Yu3R/1JaIhgvpn3HLvhFF22dQUJ+rgO8Dz5mKTCv83sxLar7htAGuYnkQGjyGU7/IBad +H8aMs/3Vo7OPtcgSJ0ghExhp6IsToZR0ucK6s5Vvp2/9FKsMqXYSaTXLLGg1k/byn+2 glXew30KmCZOUms49QOHtqctQVr9SPB7rLujq8x7BaYUCMQ96hTb/S7wRdR/NSRSQSU6 iRWw== X-Gm-Message-State: AOJu0Yycfm71EoX7sphSVHpEBYfeQ7IsQ5LPl/ClgCeY1mIPwybxtAY+ drTKaYRhykGczQho0GBn2hAT4tG1EX27o/7b6wVVvPEY2cc= X-Google-Smtp-Source: AGHT+IFQNcHWcw3KkJhcwY8+VfSAVyEyJmczxmS5MF1V39TwLfThdfJexxvi9KATckhMuXtPKPW3Dw== X-Received: by 2002:a05:6808:16a3:b0:3bb:d7e8:d8e9 with SMTP id bb35-20020a05680816a300b003bbd7e8d8e9mr8161374oib.109.1704160759687; Mon, 01 Jan 2024 17:59:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 32/33] target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only Date: Tue, 2 Jan 2024 12:58:07 +1100 Message-Id: <20240102015808.132373-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.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, 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: 1704160991863100003 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich --- 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 20:23:48 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=1704160944; cv=none; d=zohomail.com; s=zohoarc; b=my40zZkDs12mRBUjeU5lzcNVBgS8KoUZ1rWroMVVtMQyhmQ3ARhOkC5fHmx82gZgQvyQ2H/0KqUbULCdVFNw4ssNAIGLLQAcY2XUuJ+VWAGdcNmf+MOssYxmGggpNGIaPYF/tHqyGwDql0W4ooSoq3G4OqgBaCeSn52FC/6AbFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704160944; h=Content-Transfer-Encoding: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:Cc; bh=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=ipT4P2gC0lg+XRAn1ds1EgDoqpfthFp+Ijl0PF4A23A+2LcEFa5bfUs6uRcQNyPEvPSlC8AdlqAFVvfFX96u8FDc476or1AhCa+z3wLAegkZR+zKA75t0I3Hh2fR3EZfhqLsZy00alyazce/nkszjw1ZP0HYgG+oxEIw0/PwOtA= 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 1704160944113409.66864001806994; Mon, 1 Jan 2024 18:02:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rKU3y-0004cG-DW; Mon, 01 Jan 2024 20:59:26 -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 1rKU3w-0004Sf-5X for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:25 -0500 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rKU3u-00077M-Ki for qemu-devel@nongnu.org; Mon, 01 Jan 2024 20:59:23 -0500 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6dbdbf680d6so3213197a34.0 for ; Mon, 01 Jan 2024 17:59:22 -0800 (PST) Received: from stoup.. (124-149-254-207.tpgi.com.au. [124.149.254.207]) by smtp.gmail.com with ESMTPSA id g33-20020a635221000000b0058ee60f8e4dsm19561891pgb.34.2024.01.01.17.59.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 17:59:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704160761; x=1704765561; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=JmG/eE9xS4jfimcftYUo7w61UlVwPRi+yzdC9gArNjlg2EM/XBQB+YGLbKcbtkskl9 JXrEfywIQIhWs3nwxZWiGYTi9jeCptG0dYedLgFUZ8YyuLHkr2LhQqetCRHYDIZ+aSqg 42zMxwvltjih5PKXnqzhPLpwLqN59d0Uk7dLnLE8xYcgN/3KORQAcVB9PNs8qitLz6ZB z5iZgnIv3jpMjknnywEO4nLno+fP5OVm7TvYfEmeCjbRH3fuGX5uDwrIT/8tNOGdd/kB YJ/h0/eS5GbF9cnFL9k8nnu9GFRhGlzcOnKZrZzlAXwU6DPT21LoUpZ+95btYPqw5bd7 Igiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704160761; x=1704765561; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UM3G3JW9WxcLT5Dzb3w4vT9giwKkE+uVqc4Wz3d/fxQ=; b=S4fKHbZyBklG7Z8/5YrjUq3ISuy8J96m4O/TQQR0/Igb3nu/zZ9NdtixPKczRvlXAo rIEtAhLh1fMtgLSn88A3UHqZvFZIApDmO1OgUFdEGX+sTEW3hW34XIKY+mspkuVHyBJ8 6/57kFRfBbQBSVTSwbJ2TVwtlmx97Lmn84E4Bk8yKq6mhBr3F+LzUwTcLMuHpMs4dygk 4A1hirDgd62OUinavk8QhQUV40Oa4EeYtm0T2h6AtI8vCdS29S70LSiNmY/vcSEtz/j7 x29b9sDmMqFGbSeNNiTT3TP0Okw1NQZYTNV5GNxxLUWMTH4m8qiLm3XJOEo7JW7okpWW ar/g== X-Gm-Message-State: AOJu0YyX+GBg+a8EznqALmhI+CuGBJD/xg0/EO+y+v7efcSvtCs+FfUQ HJVXTBv9sz6QhAzSSmHVcTjnKuZWoMJevvIXEiL8RBt7FSw= X-Google-Smtp-Source: AGHT+IHM6swGndq9IOkuhVAJsq033Gtk1O84E17zQVSVAfy+dy7TEEhX4NG1dANepxXORvt6CP+Eog== X-Received: by 2002:a05:6808:13c5:b0:3bc:1169:d467 with SMTP id d5-20020a05680813c500b003bc1169d467mr1140810oiw.65.1704160761612; Mon, 01 Jan 2024 17:59:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 33/33] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only Date: Tue, 2 Jan 2024 12:58:08 +1100 Message-Id: <20240102015808.132373-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240102015808.132373-1-richard.henderson@linaro.org> References: <20240102015808.132373-1-richard.henderson@linaro.org> MIME-Version: 1.0 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::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.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: 1704160945646100003 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 Acked-by: Helge Deller Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier --- 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