From nobody Wed May 15 07:00:49 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=1707978170; cv=none; d=zohomail.com; s=zohoarc; b=YuyfWyf3qmwEnXLG2YnWr+LtViDgrs5Ij/Kts3viGAIoNFGC2r+h4XOtqTrN9BPPYshts2+t9dwOsJhLAenAzETnbefJbJuPojdrSAKcOwziP7v0GJRREsbqyK67rcMOR7/hKEahKkQUA0WxjqOszrlY90garld6HxBBYIeuL9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978170; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=GvMTyR0BcwVSXjX7DlFrKa4jehAO9kTUeQtf7UZMpa/79pD7cn8WbDEbtF4LFiHB2icyaH7tlJagGy6Cz+YgM3YTMG50UMDlhouOjSrDsBTXEhl1dhfniLG3ASv2RwakA4q1GAtjJJiDA4S3z6577FfyLgKyNK4BLLyvVkF9wU8= 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 1707978170130237.11877716517972; Wed, 14 Feb 2024 22:22:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6i-0002FC-8B; Thu, 15 Feb 2024 01:20: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 1raV6f-0002EP-Lo for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:25 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6d-0005Iw-NR for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:25 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d94323d547so4406855ad.3 for ; Wed, 14 Feb 2024 22:20:23 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978022; x=1708582822; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=C6DB3DVdqm8erd2cdHDnzlaYP2qpWWt6WKBakXN8i/AJjN0jbwsTbqKsKf5yi9jOsl /8i2dLgpltV7XfxCfk4cwDaoUrSmx/pwC3rF66Qv22gRMEmUX4ov4r6UMPuYdimiGOxY AFq9/ZluAFf1KdhlgikeZD34EzTi3w16hwjHPgvnEY+w/0MBe5O9lnIQUOlr1DC8CDP2 lFbvgpaCF3BHKd2FjeLfYa/bdIQjUmx9SnnLwfFSzR1mT3+KoklEXI2FYnHBrRipsb3v eay9yIK8//E0kR2HVJUXVZF/EzdfjjzfWFK5UpsHL+gpDz8/hG5YyWVjLRBCqZK4M441 ht4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978022; x=1708582822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G2VXMZpzicQ4Dm28fmEM7ZpGthYgfI6UDANYII3bJPA=; b=hovhhSIz5n8aKP1FMwb0UDKNgKvYwKEKyBOIrEYGh7b53JOSS2xD6ib3jUNxOhj+9e HDbdEj9EhJeKtIe21IxgosX06M3CSKSEOKId5X64ZMXZJxI6+fosFFEuREbcJDy+XvUk nMA6FlFHUTOIXdvaplj2g3u5zRFZTvcUB5HghjV1L+JBK90hMUxIjjW8t9rs4y+XcKIg hrHMrqzjWcE+O3JeRpLlQibIk6bDLpFIhNBgH6sH+8jNyk9z3SyN927/9/ZtPTch2yK0 /SSJMooz7fohuAcCzll0UkRbPA90r3rrSyJu/rEg+s7u1jQjZ/ZNLEwkqFddr7fkONz+ 5ePQ== X-Gm-Message-State: AOJu0Yxh7+/pKcYbFpzIOWU7016287+/h7vFkZ2k67I8PNpRpHjw7RQY Q5cZe9T3AfAlQnBknJuQXfpvlZQ6ir8iunc+rXmU4BrBH9pv7oPHGUVQ3v1OicLNNLfv6RgCrGF B X-Google-Smtp-Source: AGHT+IEF52YibLsNNp2Mu5MkQP7MpXQ09mwMLB17Ak7zW0O4tngxN3LDW8W64aL9WoS8vaLHL9srzg== X-Received: by 2002:a17:902:bb16:b0:1db:8f3d:d48d with SMTP id im22-20020a170902bb1600b001db8f3dd48dmr150517plb.22.1707978022425; Wed, 14 Feb 2024 22:20:22 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 01/36] accel/tcg: Remove qemu_host_page_size from page_protect/page_unprotect Date: Wed, 14 Feb 2024 20:19:43 -1000 Message-Id: <20240215062018.795056-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978171889100001 Use qemu_real_host_page_size instead. Except for the final mprotect within page_protect, we already handled host < target page size. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-2-richard.henderson@linaro.org> --- accel/tcg/user-exec.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 68b252cb8e..69b7429e31 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -651,16 +651,17 @@ void page_protect(tb_page_addr_t address) { PageFlagsNode *p; target_ulong start, last; + int host_page_size =3D qemu_real_host_page_size(); int prot; =20 assert_memory_lock(); =20 - if (qemu_host_page_size <=3D TARGET_PAGE_SIZE) { + if (host_page_size <=3D TARGET_PAGE_SIZE) { start =3D address & TARGET_PAGE_MASK; last =3D start + TARGET_PAGE_SIZE - 1; } else { - start =3D address & qemu_host_page_mask; - last =3D start + qemu_host_page_size - 1; + start =3D address & -host_page_size; + last =3D start + host_page_size - 1; } =20 p =3D pageflags_find(start, last); @@ -671,7 +672,7 @@ void page_protect(tb_page_addr_t address) =20 if (unlikely(p->itree.last < last)) { /* More than one protection region covers the one host page. */ - assert(TARGET_PAGE_SIZE < qemu_host_page_size); + assert(TARGET_PAGE_SIZE < host_page_size); while ((p =3D pageflags_next(p, start, last)) !=3D NULL) { prot |=3D p->flags; } @@ -679,7 +680,7 @@ void page_protect(tb_page_addr_t address) =20 if (prot & PAGE_WRITE) { pageflags_set_clear(start, last, 0, PAGE_WRITE); - mprotect(g2h_untagged(start), qemu_host_page_size, + mprotect(g2h_untagged(start), last - start + 1, prot & (PAGE_READ | PAGE_EXEC) ? PROT_READ : PROT_NONE); } } @@ -725,18 +726,19 @@ int page_unprotect(target_ulong address, uintptr_t pc) } #endif } else { + int host_page_size =3D qemu_real_host_page_size(); target_ulong start, len, i; int prot; =20 - if (qemu_host_page_size <=3D TARGET_PAGE_SIZE) { + if (host_page_size <=3D TARGET_PAGE_SIZE) { start =3D address & TARGET_PAGE_MASK; len =3D TARGET_PAGE_SIZE; prot =3D p->flags | PAGE_WRITE; pageflags_set_clear(start, start + len - 1, PAGE_WRITE, 0); current_tb_invalidated =3D tb_invalidate_phys_page_unwind(star= t, pc); } else { - start =3D address & qemu_host_page_mask; - len =3D qemu_host_page_size; + start =3D address & -host_page_size; + len =3D host_page_size; prot =3D 0; =20 for (i =3D 0; i < len; i +=3D TARGET_PAGE_SIZE) { --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978295; cv=none; d=zohomail.com; s=zohoarc; b=ID3PQ+YO4UVTjkYUVih4OXc2i2llw2+jAYhScXy9IYaHa7Z7HePbPGlXsqYPPMlFNcgUijm+61lHo1udAbRPtipkh0tEk7alf5kZVCTtyhAOOCBDK/Yg2osSev2qHCfH6GFu01N+VtiePCnHk1b2cgjaV5FEOoEhRyLb5AUXyzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978295; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=kZPbxEVk9vs9aRhJ2vWauQP2/dYcU6cYluKC8sIzVBrXpXTxMO5j76KF5hGU/JkxbwRLCvvpfKns3E/oO2jpEqYvI+y3Q4wfA2cv1thSrftor2XqWzMwKUGRSZCj7ZZufPDT/6jdeTOv0NAnSbUVMQolegSMW/3VmhlzJnn6zDo= 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 1707978295150704.8881618126682; Wed, 14 Feb 2024 22:24:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6j-0002FR-CV; Thu, 15 Feb 2024 01:20: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 1raV6h-0002En-0J for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:27 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6f-0005JP-7v for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:26 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1d94323d547so4406915ad.3 for ; Wed, 14 Feb 2024 22:20:24 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978024; x=1708582824; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=df1jQ9nn0h3aSO6nnsYW1nF1/3ECGV8+AhgrhIomokIQnflH0KW+3wgGMX/1FEaDl0 pBGf3EPTOKMG6MRauKwpmcnU/la1Sj9ULKATrkyJ3/kle/jTbRx5Hrr1Etir5OZLeqSC /rNdiEAda6G9GqDVCh6gPcSbs7OWkYhkQadRCKRcxiuUQMgic1NYhroNiydabPYwlnZX okwkCg6g1HuYeFRSltY17Us9jy99JOLsOtLeO+6QeX3iAJCVqNPKVdac/KxiQGL0KDUk 48P6qnKhLMZ3NceHPmDEg2J7J5dBYLpuIzZKOjwHOYR11GcKEfnxp7u81b/3cjo9Lhok g+NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978024; x=1708582824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sNAOuzYKunseGhjt30zEM/eN7uq1Wl50v8pWc8K9LWs=; b=DB4cq9lgvR61yl7kIsOWkQCJ07z7T2dHJNaEx+e385rnPb4uyayD7lv9hSQorPstGb +IyEjxc8r+YO8Umje4CtFVq3vpgo874IpmcBxADz5TY5TaGY0r4OrCn1P7gpmK4eb0m+ GqbyNEskx0fGszWjfgqsSS3p2xGhrOCu15GD5cQPexspHP9K9k21n1vN7L44LExah8Wu /g7gBI51ZYh6dV3Qm9NGBYpVYoYWSECMNsdg+jbjhMAZbG53brVLwb9SaYER7sdk+o2E onzyhrjxmoLPFWxsTQ8ytP+HmBw3+3gAYiTyLUBtmDFpWVxynLPIeCmtbT0RO5JXTxiO IXwA== X-Gm-Message-State: AOJu0YzRfPfrZ7zuuW1IBLBALPNNtLaNMBgWmSYwbt2eyLWhnRW1Z93T hpDUFjrHlbR/HgYTLj/0Eqo2dZUzqpTSbfOJxhaD+Mxv3oOYC9b/ELZn6UJU6XEzOhVYDrNubXS 4 X-Google-Smtp-Source: AGHT+IFZ/57uvY7YvXLIrwn1yHMllRkzWECQZhniPiaGQ4xDkMdx0mpTq5/fraMXHc18GdauUW0Vlg== X-Received: by 2002:a17:903:18e:b0:1d7:88de:cffa with SMTP id z14-20020a170903018e00b001d788decffamr1095734plg.19.1707978023844; Wed, 14 Feb 2024 22:20:23 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 02/36] linux-user: Adjust SVr4 NULL page mapping Date: Wed, 14 Feb 2024 20:19:44 -1000 Message-Id: <20240215062018.795056-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978296303100001 Content-Type: text/plain; charset="utf-8" Use TARGET_PAGE_SIZE and MAP_FIXED_NOREPLACE. We really should be attending to this earlier during probe_guest_base, as well as better detection and emulation of various Linux personalities. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-3-richard.henderson@linaro.org> Reviewed-by: Alex Benn=C3=A9e --- linux-user/elfload.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index b8eef893d0..e918a13748 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3912,8 +3912,9 @@ int load_elf_binary(struct linux_binprm *bprm, struct= image_info *info) and some applications "depend" upon this behavior. Since we do not have the power to recompile these, we emulate the SVr4 behavior. Sigh. */ - target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, - MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + target_mmap(0, TARGET_PAGE_SIZE, PROT_READ | PROT_EXEC, + MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, + -1, 0); } #ifdef TARGET_MIPS info->interp_fp_abi =3D interp_info.fp_abi; --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978262; cv=none; d=zohomail.com; s=zohoarc; b=N1sGheP6myFUIGomU/45UYVFubkdfx7aE4knQMbCb43LpuxDIjEMq7+9mltxvA2FjR+0sU+WWkyia8LqcGGIq5RO9jnVY+NO4MqoumHSQ7uxoIEC9Ndiyr3NrZ4dINrG5iazcWwv5NfjIRNk/Ceo7LO9wH154/h8ETWCtZw/drw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978262; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=YTc2F2j8AKhKB91BEfUHk4MWzG2CL/PqMUCi5p1cTr96ckqOHYjAacxBg6TzTMqXgYt1pdGtxZ69xVxbiiLOA8Li9XB1Vu8tTV+7WK5Ybz/jlfHYnOlNpOXJKqh/5dvU4itDDfP+Dfj8npupdxx+Vf5R/3p0PCVlJ9WUNEMFWBY= 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 1707978262817608.501427860989; Wed, 14 Feb 2024 22:24:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6k-0002Fe-49; Thu, 15 Feb 2024 01:20:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV6i-0002FE-BE for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:28 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6g-0005KJ-Nv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:28 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d95d67ff45so3822795ad.2 for ; Wed, 14 Feb 2024 22:20:26 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978025; x=1708582825; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=cNoxOKojC4UzF4AI7na1FxJY3m+K4nHX7XgnBCbuMD6ROJIsL87b5JC5wJQHTVuTOu 1vbHxKLb+Jx3fivdH/YzcnFTaNzLE6Q9HSIxEuLvhERzFCur+qqCJLo9rbuRhsUhmMZG akU7NT5PbdDenhOlQaDqhW0uINQuoJ9pmAKp2fZ9uMOqQj24w7M3UOlD8WLQLZU7j1u4 YPcnRkst3Dh31yU2H07Mhn/Mk7v3S2p246opv5g6l2Av9V33ihg9CtSsViiozHwhioWc uIloU01jvGekARzCtVv5+CknWYl5v06ou7b5kICQCdd1JYHCnSLheKILsiLtBad2P05K rYlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978025; x=1708582825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4czMnwy4ONozXZRRucTuxGhHSF3+8ljKdOePhx3D1do=; b=ZwLsXbXtiBjXYQrXDWUJzWVpYLh7ineZEglHxiRO+WNF0Evbnx3CurFN1rl4an4VFC 4n7QJOx/fBlvD1vlMQsotYvypCvwgzydmA+/OO4rdFILNtNs7Mxr0Aon+kYHCcEoLII0 TzZ+SgrMVihvTPHZMUf9aM8h/pgHY7sRqvKrI4Fh4ODmOXSnBk25Cg9I0YPgSCNANlmx 0OxGGGdixqa1mYKduZ66HM3qi5JebUNe7Kg1zDIlnLlcb30hVnv0s4+K96Qd9RedORLL LKNUY/QJUOVz6Pd8p/Vr7CikxyBM0xTfnh22CThJiUUcafG+otlaqjjJrMFCfGTNa45p maDA== X-Gm-Message-State: AOJu0YwoGFWgUq8iGS7DKboDwWFtsi+yz0uAIrgP9TnFRQZU/7trk5ug g/YUOFUgOEVkO7Jt8J6Hx6EaYzfIED4SVnTkUmN+PZBxDZUD9vD4OMxrq7lbiAnSonaff1+i5uk F X-Google-Smtp-Source: AGHT+IEuFWdY2rlfZm1CLsQaVYHVLx7Vgf3y3H8w4YLdsvzH98Uo9ieGUP7F6z9EmfSVMJ5FkZuoPQ== X-Received: by 2002:a17:903:183:b0:1d9:d300:a670 with SMTP id z3-20020a170903018300b001d9d300a670mr1083474plg.15.1707978025383; Wed, 14 Feb 2024 22:20:25 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 03/36] linux-user: Remove qemu_host_page_{size, mask} in probe_guest_base Date: Wed, 14 Feb 2024 20:19:45 -1000 Message-Id: <20240215062018.795056-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978264159100001 Content-Type: text/plain; charset="utf-8" The host SHMLBA is by definition a multiple of the host page size. Thus the remaining component of qemu_host_page_size is the target page size. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-4-richard.henderson@linaro.org> --- linux-user/elfload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index e918a13748..e84a201448 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2893,7 +2893,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong gues= t_loaddr, =20 /* Add any HI_COMMPAGE not covered by reserved_va. */ if (reserved_va < HI_COMMPAGE) { - ga->bounds[n][0] =3D HI_COMMPAGE & qemu_host_page_mask; + ga->bounds[n][0] =3D HI_COMMPAGE & qemu_real_host_page_mask(); ga->bounds[n][1] =3D HI_COMMPAGE + TARGET_PAGE_SIZE - 1; n++; } @@ -3075,7 +3075,7 @@ void probe_guest_base(const char *image_name, abi_ulo= ng guest_loaddr, abi_ulong guest_hiaddr) { /* In order to use host shmat, we must be able to honor SHMLBA. */ - uintptr_t align =3D MAX(SHMLBA, qemu_host_page_size); + uintptr_t align =3D MAX(SHMLBA, TARGET_PAGE_SIZE); =20 /* Sanity check the guest binary. */ if (reserved_va) { --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978336; cv=none; d=zohomail.com; s=zohoarc; b=PiYPs1yukSuBc2dw++vyeKmnDlu6W4AwwvTbTEJ2CbHd+O6OczgOyylCyi0n6nmdF7N1TpcIdkHbrh1Td5a2gcjCNQpCR3yOco/VzfP68rkcBarmQsHP2yUd8Fg0t83WyP0btdTplhm+/Sr4SgIqti6WNmoBWoPLxiSvk7U1+AY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978336; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=eEMQrhebVMkbnOU1ObNEESJWZfip9CUNrSbhCnkGKgPm6RWUwTcF2i8rVj1+XCKV/LRn4R1KJ3jKztTD5cb0mxrwoi1iGg8wm6EE0nWwflg6ypnkPAjPuMVeaksqftBJlL9KaVvNE/4SWObScsHUw37Ake6Jay94K4aeJ2Fp0qw= 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 1707978336925374.5132058858102; Wed, 14 Feb 2024 22:25:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6n-0002I0-13; Thu, 15 Feb 2024 01:20: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 1raV6j-0002FT-Jt for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:29 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6h-0005Kv-VT for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:29 -0500 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d9b2400910so4240035ad.0 for ; Wed, 14 Feb 2024 22:20:27 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978027; x=1708582827; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=PoZHd75WBc6LC2ahvP1zKctqUDqlM0VsZrH1A84+kemCZRB1g8khlO934k9XwgkzjK nOmeKsZm+NNxKsodDpKTbHjCaZbzgC0HZWlNwuL92/tPIHrSNIzkKufJ81CxPWHxRQZ7 eWZR12OfdrF5PK5NvcnYfwXv1WLw60Q0k7+JzsNoYRyGv3Y7Tf0QzRPA3IyeFLSzOEUB 2ZEVQFLJ8c0L1Jy/wolIK0VsJeCbtakOzGshEZgtycTDcckzZbZfWutTu9IH/cubGIw0 mI/Okzz2Sm7uOZNSM7afHYLHIbnE3HCt3CKzqlAz/asaTOwO68WgwfVbapRsOqPqx9TH 2eFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978027; x=1708582827; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bhq/S13VfihOVnnYi8cdcfrHcq4G1EwJdAWP437jNUw=; b=fIH1ths7PoO4pAt3puGuSPGJrKqIcfCMP4F6Yw3FIrVztewwBqPkbCG93E2nAi/nK9 r//+zPf+HsTjduWiLGU+DKU653/MNXmsWeia+FJ+feSdpX9KJQeS2Q8t7RHMGo2VQtSq iWVtkqXm6cW/ReDJeTKxFUkbUV1Oq4rFyWWZutkjBMKq9eHvJLJN5OXWjK5vVDUTJmCY vvSRcxWWoPfTO1mTl20B9+2ZKFbaG3DHq2OBka/pkODI4ZjCSwi6UomumFCoa6rZLclo lDVUV85A0ikEtGqD4b019jgSHPqIupqKOo0p2y5IjHAHRMXOvaGYcQBkUc5FQZUb7lDe UQNA== X-Gm-Message-State: AOJu0Yym2N8XVAPRMR4EWxyHK0lrrSYWAZn0nBgl72Bi4oItT7ihwSv1 vsb9W6wjaUXXPGVNOiLp2l/iPssQEU5kb2x/ziBqVFKv0Iy1DEXgxeqxyTJo0X7SyTd8nts6vQG X X-Google-Smtp-Source: AGHT+IG4OP7mLyna24I5e8M75C9kuI7rLRM+dOa/w42lqDzRMcJSp+DYydicdPpXTHNdtGEKxqjX1w== X-Received: by 2002:a17:902:d549:b0:1da:2b5e:6728 with SMTP id z9-20020a170902d54900b001da2b5e6728mr1600826plf.21.1707978026750; Wed, 14 Feb 2024 22:20:26 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 04/36] linux-user: Remove qemu_host_page_size from create_elf_tables Date: Wed, 14 Feb 2024 20:19:46 -1000 Message-Id: <20240215062018.795056-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978338471100009 Content-Type: text/plain; charset="utf-8" AT_PAGESZ is supposed to advertise the guest page size. The random adjustment made here using qemu_host_page_size does not match anything else within linux-user. The idea here is good, but should be done more systemically via adjustment to TARGET_PAGE_SIZE. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-5-richard.henderson@linaro.org> --- linux-user/elfload.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index e84a201448..dfb152bfcb 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2679,13 +2679,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int = argc, int envc, NEW_AUX_ENT(AT_PHDR, (abi_ulong)(info->load_addr + exec->e_phoff)); NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr))); NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum)); - if ((info->alignment & ~qemu_host_page_mask) !=3D 0) { - /* Target doesn't support host page size alignment */ - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); - } else { - NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(MAX(TARGET_PAGE_SIZE, - qemu_host_page_size))); - } + NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_info ? interp_info->load_addr = : 0)); NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0); NEW_AUX_ENT(AT_ENTRY, info->entry); --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978091; cv=none; d=zohomail.com; s=zohoarc; b=iK5RYQpG+UzegfXeG/FKcxkZwYDJsIEg/mV4e1dse8dYtR9moCKN9BoSS9Lqr2H3HjxpBHo2tgklpckp+1sE0/U96zFt9Pl5iYNhJ2wiFg84E+oVEuX55JN96c2BAvNTevXj5CQRFFK5piWHNUVwnT+ssSWKdl+Q322O7HKXBd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978091; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=fYAxFHa5M6uqe1gXhjmYZA9rnrHaA9QNn/iLOtXRBlhD5oKow8KbK05sb5q2aZJiZA3tkAWmwcSchhmRR7cIwXVCadErr6JjDqqHMHt/ijJEvutBwxw+jzPfLo6LY0+E5QQtRqUxiyjFLtZfXvWgrKySk+h+hYuEYZzrrnR6Kgk= 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 1707978091799783.7428214169564; Wed, 14 Feb 2024 22:21:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6o-0002Id-MS; Thu, 15 Feb 2024 01:20: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 1raV6l-0002G7-4F for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:31 -0500 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6j-0005M4-GC for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:30 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1d8ef977f1eso4469275ad.0 for ; Wed, 14 Feb 2024 22:20:29 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978028; x=1708582828; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=zJFJ/SjXHE7Sqn4HUoCS/MuJRdx0bQFgr0XiEu6NKwX9V1tOOdkiIxYMukF1MJ3x1T xDl0bbVyhVwiwmeGwePBg8sJSMUodD6prl/HOM8ymn7Dkb/X0qZ3LsbZuTqosbgYsVMQ E4LQTqOtLYYtTBE4g5kE8MYQbDk6o/ieEJP5Eu1M1428qfnLBpam1IqQN2nsUM30ikoO shPccr5YcRFe5wve94Db2OWqNlBfZqCQDSfpsW41Dvvq2QNqEBawqcKxLoXUgReYWrlc Fq1EvqhbdqDbrniThsFqi0IRp4R5UwZhys7sdsHKr8aXoQ1bCJ97LW10EkA2o6elJX3o vTIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978028; x=1708582828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=emMi1h1Qw5IeyN9nGFR+tElZTiLuS0cNV7Vg5JxneO0=; b=Vdf80zVwVCgJ9qclKmSSQkKtGyU6nj/m0n0HEV3aKBEiW7Xhs2Rn9TKcotbkBzP1TF vR3WMVX/X1f9o4y2P2BT2GVfaEIo3aw+r2YErluJ5vF/EmpDg4mtxIYsx3qxT02dJYzK Q5negPj3Z4wotkQTuGQQXNGM4gluOgv6hdiw5IPwU5dDDCbUc1VZlaTNCxEySj6s0PwB SSUKLhINAQP1jdcItlbnfwr0PzaCq92UtVbMYlqxT7iNsBYwUMhMBppF47pEasEUSOK5 eE9uV4jUGf129i5vZzn7QeKCHrXwsj6AODfu2YutIrkCQHfccN9aayvj1tWd8NHbyjGa rwnQ== X-Gm-Message-State: AOJu0YwfkccT+6yl2kf6R6SS2U4GGIlkOuW2vmpVPZoQlpN6ScMdkYgk TcEuYh8/i7aEjm2za2NXSCth+nvh8goCQ5S6sadMRmf0Hhn0Eu7tis8Mzea8lKM3ipuocFrJ4/D k X-Google-Smtp-Source: AGHT+IHQblyR9F7Qyb08Jc8NnbGd1b8+aT4L1UnTE6GwG6dVNrZ4YVJhGvFSki5qyJSE1WeYcr0HlA== X-Received: by 2002:a17:902:654d:b0:1d9:6dc6:6616 with SMTP id d13-20020a170902654d00b001d96dc66616mr769027pln.68.1707978028155; Wed, 14 Feb 2024 22:20:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 05/36] linux-user/hppa: Simplify init_guest_commpage Date: Wed, 14 Feb 2024 20:19:47 -1000 Message-Id: <20240215062018.795056-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978093592100005 Content-Type: text/plain; charset="utf-8" If reserved_va, then we have already reserved the entire guest virtual address space; no need to remap page. If !reserved_va, then use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-6-richard.henderson@linaro.org> --- linux-user/elfload.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index dfb152bfcb..1893b3c192 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1970,16 +1970,20 @@ static inline void init_thread(struct target_pt_reg= s *regs, =20 static bool init_guest_commpage(void) { - void *want =3D g2h_untagged(LO_COMMPAGE); - void *addr =3D mmap(want, qemu_host_page_size, PROT_NONE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + /* If reserved_va, then we have already mapped 0 page on the host. */ + if (!reserved_va) { + void *want, *addr; =20 - if (addr =3D=3D MAP_FAILED) { - perror("Allocating guest commpage"); - exit(EXIT_FAILURE); - } - if (addr !=3D want) { - return false; + want =3D g2h_untagged(LO_COMMPAGE); + addr =3D mmap(want, TARGET_PAGE_SIZE, PROT_NONE, + MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1,= 0); + if (addr =3D=3D MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); + } + if (addr !=3D want) { + return false; + } } =20 /* --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978334; cv=none; d=zohomail.com; s=zohoarc; b=lu33fpAv/pssk52QP+tVPQhoTRicF6fUXWoos38B3aMIEKndIiVrC30RRhqGA0vVehARBuVkBHPBEpDYatfDVmbRcWUSsnMDKaVy/+oB0bbUm2iMz7UW0yo8GiZS5BhQOF1//Hbijf0WK7LcNhz2IQ3/8DcmXqnPrGlO5MODOjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978334; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=KtR6yber2ay4bk4RaxQ21VDxoDO5QmrEcp3q+HoPNy224+w4I+0wbOzLObUnh29skWo0xiwkg7Iyd77hYuRjVao3hrEJXJQR9Y5clqqypWYtNGi5Lx/I8QEKMs/1fi5VR5ksJ/x60SIzot1e8CCHumQ2314YCr18PYSSWaYVJck= 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 1707978334491220.84964596140003; Wed, 14 Feb 2024 22:25:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6q-0002J6-Q6; Thu, 15 Feb 2024 01:20:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV6m-0002Ht-Pe for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:32 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6l-0005Mt-2x for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:32 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d9b2400910so4240335ad.0 for ; Wed, 14 Feb 2024 22:20:30 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978030; x=1708582830; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=oks/L9GrJ2CpPAMuCaYTWC7zE9nJVed3jyX4EV7asGzUGTOmU6vIjY+VVGrc40FrQU Rt59eRdkrXZt7Iu53MXeiJkN31JB2qnCXGNEy9lCrw70F0A7FYsDK/dUZTbAdTii73GL 1VnM3wD7pn+pfJ7W5ZOUBNwAfeOYJFU5uLgUXyb3RAC6TPHOOEdWjeYQbVVG0g7HKO1n Gme5gL+dIVzGihRYfAzH584qO21Nsu7+NXFDNv3iYtpSsoyU9ZOJu7ADPap3Y5dX8YAr VtC1YhNckpUBl/P4mNYOGNMO/fn83V1juoiX5QT+ib/sB7ZrmxEhFih7rTX7HOHOfIEY aT1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978030; x=1708582830; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=on46I2b8riCprdxQ1GrqNDsO17YyckywkPgL9RszReM=; b=I2XdY6qaKERi232JiahYlbJI1930JIKeQRu54lUpOjqKFUdbDy2GVIBJ8GKSQv3aH1 2fiAfKnMXzAZ02ZyQM4ltCAwUDGaFziMn5VUWHTBaS9CmcvhY7aNN+3eoeaEZyla5+Mv 22k3JMbnYMutjoFIz2TwukS5wppJdq8JFSAevZZlasTLNgZY9h9EKGxoMGjPZ7DJZhL+ ES8JRV9g30TH5Xsb5LAjyAuphfxibxyPpgfIINFOjQXphKGSYvc/5NmbQ99k3yuQQSyw x9A8rQcrJlF2xEnz31hi2wshh98fHe23SO50f3AqYHsRzOOA97Ol9+0qQyXQSRaHhZiR EVDA== X-Gm-Message-State: AOJu0YxmpFiIPGkj9A54YBkVsTrkIkO7hXr/8vfIcdN63gsZ73tkr0r/ V5wyH0M7/CUU18z/J5k4i/V+yDu52oEGvXYnru93apU4TDX9t1kdTwRtXfWGs/sCbD3frbr5ykC d X-Google-Smtp-Source: AGHT+IG40zulwDY1MBQVHAVV6pGHYLhc1+lsT1wT0XKnVLjW6UhAeKSnnEzEhVnWUqUoa3yl1wFXfQ== X-Received: by 2002:a17:902:ce8e:b0:1da:1fe7:cacf with SMTP id f14-20020a170902ce8e00b001da1fe7cacfmr1519807plg.25.1707978029794; Wed, 14 Feb 2024 22:20:29 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 06/36] linux-user/nios2: Remove qemu_host_page_size from init_guest_commpage Date: Wed, 14 Feb 2024 20:19:48 -1000 Message-Id: <20240215062018.795056-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978336466100003 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size. If !reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-7-richard.henderson@linaro.org> --- linux-user/elfload.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 1893b3c192..a9f1077861 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1532,10 +1532,14 @@ static bool init_guest_commpage(void) 0x3a, 0x68, 0x3b, 0x00, /* trap 0 */ }; =20 - void *want =3D g2h_untagged(LO_COMMPAGE & -qemu_host_page_size); - void *addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + int host_page_size =3D qemu_real_host_page_size(); + void *want, *addr; =20 + want =3D g2h_untagged(LO_COMMPAGE & -host_page_size); + addr =3D mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); if (addr =3D=3D MAP_FAILED) { perror("Allocating guest commpage"); exit(EXIT_FAILURE); @@ -1544,9 +1548,9 @@ static bool init_guest_commpage(void) return false; } =20 - memcpy(addr, kuser_page, sizeof(kuser_page)); + memcpy(g2h_untagged(LO_COMMPAGE), kuser_page, sizeof(kuser_page)); =20 - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978262; cv=none; d=zohomail.com; s=zohoarc; b=SIMRXr0ItD/gaGS2O2GeEhZsXLpblAWrWn8OPwBhZtM9FKWqiPtE/VeK964lEa9SXG+AnJsWWmfTtQ7la+ZzERtl9RB4SpGFJQ2rN9Q6Qly9OGZJIwXcFpehHcNC/OtkLf7DQ4EX/n9X5jpzilXAj7lOhnJ9kr1+5PcNm9l1+jM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978262; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=fSdxN6LGI2v4V3Ls76HgpUIn4g8mbyvlR+vSA9CG2rRfEkgLwfrxEA+yMpHf6WwfddmSR2uXGE9vT8++idKgPprSsPvlWceklEIMn1wB/T4RlTEww0Y3PcCfj7GPYGjj3jtjWGdr0egJXj4iFi/jswvDWuIF5x2pu6Cz6CnhxQ8= 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 1707978262936915.5614275820824; Wed, 14 Feb 2024 22:24:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6s-0002JL-GB; Thu, 15 Feb 2024 01:20:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV6o-0002If-4L for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:34 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6m-0005OA-Ca for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:33 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d934c8f8f7so4643605ad.2 for ; Wed, 14 Feb 2024 22:20:32 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978031; x=1708582831; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=brLrEsIZtnVmD+npeC2nKkYX1gQbDbr//W+t1wYWPhextsakKtpAapyxbEZZX5khM2 MXa1l/kjVOBYFk5Gwz3HiGPzLZT9i3qATzbIm/KHSf6LGbJXWkXtdl95OzXwPVF+nxKU yHOGC8koBnJUWhOjfK8fiGixINQU0YcM7w3DAdort9T4rPM23lzV0yMVEFgBMDok1zLc FqO1Eq5+vEZ59isSatGIqcmSRjNUQwtw/cSSQ1oY/xHRTHtZY/Ifgc8RvqTHFiP432uT zyUDbWF1cXwEp/yNFYQ6mrw0MNqHNz9/VsFFTP9bnUEeTzjbwbUXQLqQPNXA/Fwa4Q4O Hdvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978031; x=1708582831; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aaAlM/N1pdfPJQ0AFuX+476ixWIzFXGcl3gsIXYKRec=; b=cm+6vxFIKR19ZVkamPSThA9cpGrEU2rfX7W46hiDCNw/PDQ4C0JT7FbFKRwxjAXyht sW2xNu8GVzVXeYuDmq/u7HJ0oscjD6/IxnmbcXVTntF+gycBwjoqpGqRhUxqokUpGXkj pBe3ibVDO7SeN5hqzrRR1Aa1O4onANySrHiXGEUbr980Ppq5o2siun34J2Xz7JvYXs0Q xFTNmKhglJWhV/hVFWjKfW6WMzcJry05uUj8ECBCsSyCS0Uy//wJX9gbmJdeRvuBDV8w LDT7JrxxHbjgmXuaFOS57fTDEXKINUHVjIGhhXx6mxSOWMfxRGP7PCg335Zs4CaXnkb3 tzTw== X-Gm-Message-State: AOJu0YyilzGZZ2N087cVZMo3SaP6zVP1BRNzYuSK60sn26XCxIf9KQAP GONUm80ziF5IYA1uiCPQ6RVzhxQBcEJbDQ69qrgEKDO7H851EaacsMJJ+Qq3Vc7Y6H0tZ1uhs31 J X-Google-Smtp-Source: AGHT+IH8Y1NOkI8kLhzP7B7HnJUmHCcBQ91HRFeC5GpEFkzcsewaf5sbReCP2KRvRqHGl3JkTup3kg== X-Received: by 2002:a17:902:e5c8:b0:1db:3592:a6a2 with SMTP id u8-20020a170902e5c800b001db3592a6a2mr844246plf.12.1707978031127; Wed, 14 Feb 2024 22:20:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 07/36] linux-user/arm: Remove qemu_host_page_size from init_guest_commpage Date: Wed, 14 Feb 2024 20:19:49 -1000 Message-Id: <20240215062018.795056-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978264162100002 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size. If the commpage is not within reserved_va, use MAP_FIXED_NOREPLACE. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-8-richard.henderson@linaro.org> --- linux-user/elfload.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index a9f1077861..f3f1ab4f69 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -460,6 +460,7 @@ enum { static bool init_guest_commpage(void) { ARMCPU *cpu =3D ARM_CPU(thread_cpu); + int host_page_size =3D qemu_real_host_page_size(); abi_ptr commpage; void *want; void *addr; @@ -472,10 +473,12 @@ static bool init_guest_commpage(void) return true; } =20 - commpage =3D HI_COMMPAGE & -qemu_host_page_size; + commpage =3D HI_COMMPAGE & -host_page_size; want =3D g2h_untagged(commpage); - addr =3D mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + addr =3D mmap(want, host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE | + (commpage < reserved_va ? MAP_FIXED : MAP_FIXED_NOREPLACE), + -1, 0); =20 if (addr =3D=3D MAP_FAILED) { perror("Allocating guest commpage"); @@ -488,12 +491,12 @@ static bool init_guest_commpage(void) /* Set kernel helper versions; rest of page is 0. */ __put_user(5, (uint32_t *)g2h_untagged(0xffff0ffcu)); =20 - if (mprotect(addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, host_page_size, PROT_READ)) { perror("Protecting guest commpage"); exit(EXIT_FAILURE); } =20 - page_set_flags(commpage, commpage | ~qemu_host_page_mask, + page_set_flags(commpage, commpage | (host_page_size - 1), PAGE_READ | PAGE_EXEC | PAGE_VALID); return true; } --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978316; cv=none; d=zohomail.com; s=zohoarc; b=M5Too903O9EKvxUt5084asdrt0+YkyA5+BwlLOcoeTO7RbV6iVBI8WP0BORjof3sBFAGXhyU6kOAx8gdzr1k2JKMR+dTX4fulYuIpFyLObt0mgKJoSNC4xHa/DBISjoLK2TJux5gRS8vAvi9Hj6ZKD6APCNMbqhxhXB8Cu8YA9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978316; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=REpEFKbRow/JCMTxElv/CPzfp/2/1EkKvwnQhRwVPvmYI/p0MhACNPtVvCB/0PEms9+CLEeYKXQgOgfogNezuondIzpbnSlzHrsoMwDhaF9eENxGbNvLDL5NUwFrlHpheS+l7fWMjxdHr8ph2Lu7n7tNZWkHaDu9tyNSUeIIgwk= 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 1707978316834721.0744705503607; Wed, 14 Feb 2024 22:25:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV72-0002MB-VH; Thu, 15 Feb 2024 01:20: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 1raV6q-0002J7-PP for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:36 -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 1raV6n-0005S7-W7 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:36 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6e0aa4bb62fso311105b3a.1 for ; Wed, 14 Feb 2024 22:20:33 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978032; x=1708582832; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=HiZUsGsXbAtdEqzv/Os4T9VrVa0yu+xpnlfE4xlXWLopnliaEpL82eKTOBqewQ2yY4 7uHcPQ6U3FdCCd/EV+Q7OeRyVQRyZtfC0jPUrhpreDPVb2KTuSmvWHlXaAiKZALhyjxk PqCeDtvk2VcEIN2dUmgBsB7bSIbbbs0uO3ycHl+xL+S6azxMR6JLQVYNFQCXyyNB/b1t mL/kOVllON2Yhuznb8jkKIaGwdnXcxEkRldIPrTrO37/d5nW8166vY//ZaMBTt5i9HIW 1ExZBJXjvOp5qlocicISW+TUHVEloeDkkTXsB/H3/KAoB7rgUh9+6aZ+P6Z3CzXKRrGd qnKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978032; x=1708582832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7FHxKdfDsfaKmMG5O+L7r4x4DJpI3IWY2MOpcFadlFM=; b=me/jKj7Y69vZvCKLxrusvFobHXIsb3cKoB6LnFGuieAU3cSK9v7Na7cqm6lHizDqqe wW1upSFWIjguyP8K+4P9UFejCWyDEq2xWQ7JJTWiAC4bCGjNWL10GgIlt5aL7mm2PbUd 9lfUH3XRFZ1Kc2COK8O3jlIuDGRSo8GOAbNWLbQHNoIfby5NhUguMQOpFAXY7WGdDIGh YzoDX87a8D1QGbqEVm/Z+ldRdc6IsKId2s28Aedsdm6vqh+CXhFzN6DjfIlaBE16Sv1i zIzTM/TPHzI5rD25LimLoq2L1L7CJ7RsmYPBo28BMctxuioFCA5JytzhxOiIGhlvfmHg a1fA== X-Gm-Message-State: AOJu0Yxm0p5zIFXTCD6LIumbNaZqdrq4kERzHItxh0gS9pdVJQ9HYgAN hVm3BnvIJUHYj7fP51v8eouQDdP6l7xEpT565RbqzMH6jy8QHzcRdt0+efjNCKp0S10OM0oFy9n 0 X-Google-Smtp-Source: AGHT+IG/O8kknsbcGiw7V1Nj771ayHUf7/85oePPuQr3uQ1SSYs7CoIhsc8dr8wVB0y1qifOFUtDbQ== X-Received: by 2002:a17:902:d48b:b0:1db:8181:9d04 with SMTP id c11-20020a170902d48b00b001db81819d04mr876527plg.38.1707978032587; Wed, 14 Feb 2024 22:20:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 08/36] linux-user: Remove qemu_host_page_{size, mask} from mmap.c Date: Wed, 14 Feb 2024 20:19:50 -1000 Message-Id: <20240215062018.795056-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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: 1707978318429100009 Content-Type: text/plain; charset="utf-8" Use qemu_real_host_page_size instead. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-9-richard.henderson@linaro.org> --- linux-user/mmap.c | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 96c9433e27..4d3c8717b9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -165,6 +165,7 @@ static int target_to_host_prot(int prot) /* NOTE: all the constants are the HOST ones, but addresses are target. */ int target_mprotect(abi_ulong start, abi_ulong len, int target_prot) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong starts[3]; abi_ulong lens[3]; int prots[3]; @@ -189,13 +190,13 @@ int target_mprotect(abi_ulong start, abi_ulong len, i= nt target_prot) } =20 last =3D start + len - 1; - host_start =3D start & qemu_host_page_mask; + host_start =3D start & -host_page_size; host_last =3D HOST_PAGE_ALIGN(last) - 1; nranges =3D 0; =20 mmap_lock(); =20 - if (host_last - host_start < qemu_host_page_size) { + if (host_last - host_start < host_page_size) { /* Single host page contains all guest pages: sum the prot. */ prot1 =3D target_prot; for (abi_ulong a =3D host_start; a < start; a +=3D TARGET_PAGE_SIZ= E) { @@ -205,7 +206,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) prot1 |=3D page_get_flags(a + 1); } starts[nranges] =3D host_start; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; } else { @@ -218,10 +219,10 @@ int target_mprotect(abi_ulong start, abi_ulong len, i= nt target_prot) /* If the resulting sum differs, create a new range. */ if (prot1 !=3D target_prot) { starts[nranges] =3D host_start; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; - host_start +=3D qemu_host_page_size; + host_start +=3D host_page_size; } } =20 @@ -233,9 +234,9 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) } /* If the resulting sum differs, create a new range. */ if (prot1 !=3D target_prot) { - host_last -=3D qemu_host_page_size; + host_last -=3D host_page_size; starts[nranges] =3D host_last + 1; - lens[nranges] =3D qemu_host_page_size; + lens[nranges] =3D host_page_size; prots[nranges] =3D prot1; nranges++; } @@ -270,6 +271,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong las= t, int prot, int flags, int fd, off_t offset) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong real_last; void *host_start; int prot_old, prot_new; @@ -286,7 +288,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, return false; } =20 - real_last =3D real_start + qemu_host_page_size - 1; + real_last =3D real_start + host_page_size - 1; host_start =3D g2h_untagged(real_start); =20 /* Get the protection of the target pages outside the mapping. */ @@ -304,12 +306,12 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong= start, abi_ulong last, * outside of the fragment we need to map. Allocate a new host * page to cover, discarding whatever else may have been present. */ - void *p =3D mmap(host_start, qemu_host_page_size, + void *p =3D mmap(host_start, host_page_size, target_to_host_prot(prot), flags | MAP_ANONYMOUS, -1, 0); if (p !=3D host_start) { if (p !=3D MAP_FAILED) { - munmap(p, qemu_host_page_size); + munmap(p, host_page_size); errno =3D EEXIST; } return false; @@ -324,7 +326,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, /* Adjust protection to be able to write. */ if (!(host_prot_old & PROT_WRITE)) { host_prot_old |=3D PROT_WRITE; - mprotect(host_start, qemu_host_page_size, host_prot_old); + mprotect(host_start, host_page_size, host_prot_old); } =20 /* Read or zero the new guest pages. */ @@ -338,7 +340,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, =20 /* Put final protection */ if (host_prot_new !=3D host_prot_old) { - mprotect(host_start, qemu_host_page_size, host_prot_new); + mprotect(host_start, host_page_size, host_prot_new); } return true; } @@ -373,17 +375,18 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong sta= rt, abi_ulong size, */ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong align) { + int host_page_size =3D qemu_real_host_page_size(); void *ptr, *prev; abi_ulong addr; int wrapped, repeat; =20 - align =3D MAX(align, qemu_host_page_size); + align =3D MAX(align, host_page_size); =20 /* If 'start' =3D=3D 0, then a default start address is used. */ if (start =3D=3D 0) { start =3D mmap_next_start; } else { - start &=3D qemu_host_page_mask; + start &=3D -host_page_size; } start =3D ROUND_UP(start, align); =20 @@ -492,6 +495,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, int flags, int fd, off_t offset) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; int page_flags; @@ -537,8 +541,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, } } =20 - real_start =3D start & qemu_host_page_mask; - host_offset =3D offset & qemu_host_page_mask; + real_start =3D start & -host_page_size; + host_offset =3D offset & -host_page_size; =20 /* * If the user is asking for the kernel to find a location, do that @@ -567,8 +571,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, * may need to truncate file maps at EOF and add extra anonymous pages * up to the targets page boundary. */ - if ((qemu_real_host_page_size() < qemu_host_page_size) && - !(flags & MAP_ANONYMOUS)) { + if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { struct stat sb; =20 if (fstat(fd, &sb) =3D=3D -1) { @@ -595,11 +598,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, i= nt target_prot, host_len =3D HOST_PAGE_ALIGN(host_len); host_prot =3D target_to_host_prot(target_prot); =20 - /* - * Note: we prefer to control the mapping address. It is - * especially important if qemu_host_page_size > - * qemu_real_host_page_size. - */ + /* Note: we prefer to control the mapping address. */ p =3D mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p =3D=3D MAP_FAILED) { @@ -665,7 +664,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, * aligned, so we read it */ if (!(flags & MAP_ANONYMOUS) && - (offset & ~qemu_host_page_mask) !=3D (start & ~qemu_host_page_= mask)) { + (offset & (host_page_size - 1)) !=3D (start & (host_page_size = - 1))) { /* * msync() won't work here, so we return an error if write is * possible while it is a shared mapping @@ -694,7 +693,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, =20 /* handle the start of the mapping */ if (start > real_start) { - if (real_last =3D=3D real_start + qemu_host_page_size - 1) { + if (real_last =3D=3D real_start + host_page_size - 1) { /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { @@ -703,21 +702,21 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, goto the_end1; } if (!mmap_frag(real_start, start, - real_start + qemu_host_page_size - 1, + real_start + host_page_size - 1, target_prot, flags, fd, offset)) { goto fail; } - real_start +=3D qemu_host_page_size; + real_start +=3D host_page_size; } /* handle the end of the mapping */ if (last < real_last) { - abi_ulong real_page =3D real_last - qemu_host_page_size + 1; + abi_ulong real_page =3D real_last - host_page_size + 1; if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { goto fail; } - real_last -=3D qemu_host_page_size; + real_last -=3D host_page_size; } =20 /* map the middle (easier) */ @@ -784,6 +783,7 @@ fail: =20 static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) { + int host_page_size =3D qemu_real_host_page_size(); abi_ulong real_start; abi_ulong real_last; abi_ulong real_len; @@ -793,7 +793,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_u= long len) int prot; =20 last =3D start + len - 1; - real_start =3D start & qemu_host_page_mask; + real_start =3D start & -host_page_size; real_last =3D HOST_PAGE_ALIGN(last) - 1; =20 /* @@ -802,7 +802,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_u= long len) * The single page special case is required for the last page, * lest real_start overflow to zero. */ - if (real_last - real_start < qemu_host_page_size) { + if (real_last - real_start < host_page_size) { prot =3D 0; for (a =3D real_start; a < start; a +=3D TARGET_PAGE_SIZE) { prot |=3D page_get_flags(a); @@ -818,14 +818,14 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi= _ulong len) prot |=3D page_get_flags(a); } if (prot !=3D 0) { - real_start +=3D qemu_host_page_size; + real_start +=3D host_page_size; } =20 for (prot =3D 0, a =3D last; a < real_last; a +=3D TARGET_PAGE_SIZ= E) { prot |=3D page_get_flags(a + 1); } if (prot !=3D 0) { - real_last -=3D qemu_host_page_size; + real_last -=3D host_page_size; } =20 if (real_last < real_start) { --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978073; cv=none; d=zohomail.com; s=zohoarc; b=d4GqYatW4zTgaQHwVL7v2cNshxLxTpi7EgHqtGH+LmUJ88WzcJPW8vkUUswir9rXW/Qjy5Za5CPNpvM91k1HQfUcHgBatt1C5G7CB7m0rBEE7ueRvp9GSMTOwicvVaDgMACe3NN9C3bGgyxh0ILxLi5bWZS30Gsy4+VYQvjuycE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978073; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=ixBT4zgoyg6+GvVu5f/1aq0Jffc+5YkgxgZhqejj5rOqOCXaIQS8jeJ4yuIUXHGkFnANMftX7gSVXRLZeWY/jaLEvJ6UNbUZq3YT/K8ldsUCTvTWJp6OtlBNAv59F1Vv7KaSdjWnB84D/hiENxJQ6ll5D4VK4U1+SF+0OIaYids= 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 1707978073845532.4879940574288; Wed, 14 Feb 2024 22:21:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV6y-0002KF-B2; Thu, 15 Feb 2024 01:20: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 1raV6s-0002JJ-5U for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:38 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6q-0005SV-GL for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:37 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1db562438e0so4115615ad.3 for ; Wed, 14 Feb 2024 22:20:34 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978034; x=1708582834; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=u++Z0SWJyJ/Qkfh/aAowtDc8Yiyd3wOUOnq6/Y0U9OY662wVzjZI5XdCkLfdMW25sj ibcS0e9H0akrR6JaVnt32Z2/5gs66TK1Rjlc8upbiUXZdMiuR1qdPq3pEGmBrjj/QKlg k914j1vHQPBaQ7LGy4imfcv4jMuCNgyxKjG7Jf3zUJeZKEKBGN4rwcWo+2kSgcpwlZqy gqp9eKLLEgIQW7Y64q7r4KOfPJEiMqyVHiXK51ZjW4LTeYn3u2V3bQo3xkJaxvCPIvwr OIj9iW5ojMOcqvZ23JEzx1R3io5iS+j8gW3wFPzZmjfpXS8R4e7olBzcMz/1ZIHbNBBz PwBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978034; x=1708582834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QqsG1I779d9YjbXcffYW5wImE5mXquA1bGyFgIG+R5A=; b=oFhizmgKcOj/TsvQ00Y6oinMjpvO7a2S+GIJEnf5sd4CinkQFjbRmvqrkAiw9XzIEw kkQo9OFxCZv3ZGKug1xRnRQxHFhFRnHqDrj7twBlJr3x6dDSz7+7GKpgRfUuyNPgkCDE ioBcxz0suMnlTNYpnaEUmso6L+Cfr/Bc8FBwVyEkIF0BfC2Ndwn639aUJBU+Rqsis6X0 ddo5zpYOQjS3Z8AXcrQdD1HAmRO8SXtPL9gN8/pa9mScDkJGX+5/ev5UJNmxLJR9vctM yg5MEWEhxxKRO3thGIroPpiNVaS3MDItjX5/E4I1ituvV4sY5uyaHIxAGBiCJJS/r8Wz aQlw== X-Gm-Message-State: AOJu0YyeZeKN1+ij0x0+MR7fujRW13kh982Nq5y+RGQ7SQvAk3shpqT0 Z3barSwBnIrP7kbEvv8nadUtFIY8i2a5iRUh0eicRqDolQbNC8VdvC/scBFHaFqt8hFohvirCb3 2 X-Google-Smtp-Source: AGHT+IF9A4Oe5yYP2/x8YV3UrRqkWacjyPe1m51pND9X/vptygIIXqJYelNQZ8nxDDH5fW7i4zzcEA== X-Received: by 2002:a17:902:e551:b0:1d9:5ef2:abdd with SMTP id n17-20020a170902e55100b001d95ef2abddmr1119429plf.0.1707978034007; Wed, 14 Feb 2024 22:20:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 09/36] linux-user: Remove REAL_HOST_PAGE_ALIGN from mmap.c Date: Wed, 14 Feb 2024 20:19:51 -1000 Message-Id: <20240215062018.795056-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978075789100001 We already have qemu_real_host_page_size() in a local variable. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-10-richard.henderson@linaro.org> --- linux-user/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 4d3c8717b9..53e5486cc8 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -585,7 +585,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, * the hosts real pagesize. Additional anonymous maps * will be created beyond EOF. */ - len =3D REAL_HOST_PAGE_ALIGN(sb.st_size - offset); + len =3D ROUND_UP(sb.st_size - offset, host_page_size); } } =20 --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978161; cv=none; d=zohomail.com; s=zohoarc; b=Re/OXICKT17HHlL9E3JLcAgZ7+d+akF8zeJbqW1H5opXZGvdE3VNOP3uy4UELTMbh7Sw0m4JZZ5O3JY3lRQR90+hwr5/Oh8VfDKTkXJK0Psu5pypY18xbsTPPsDa0oTip94q44WcYbbkH23V+Vi86fljhC293JKkoy9aaWjCk3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978161; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=QJm0rb7ZYxKcRJjlxGN1JVw5u6sI6zpX7+sskNu6TXvKv63Expia6D/BN+KhCU57OjYsybpWeT8VL5JFDUuan0IunZ0Wwt+yn6NmMiME5osdUa+L+2JygPfGSoE95uvAsPb+ZcF083a1M8FVixVCeHDG2K6mR20TQg22gT/oN78= 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 1707978161112789.4742912063009; Wed, 14 Feb 2024 22:22:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV72-0002Le-D2; Thu, 15 Feb 2024 01:20: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 1raV6s-0002JW-L0 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:39 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6q-0005Sm-Qr for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:38 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d7881b1843so4655405ad.3 for ; Wed, 14 Feb 2024 22:20:36 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978035; x=1708582835; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=cDdGRQUz26fPfj8B/+35MOCl7Bal9svozW2JK3ehIkjqbEvMEw2W0GwlUfF9EXs26y vUuLgw/zU9V3zWDkhHiZU9sfseC1cHi7cTwcdZCNl8zILCNXU3f98I8mvVTjK5FKBznU cXz9D2C7ifYpNBbo+o1ffzyrJUQtwTHCoPWBHcVLB3BYKUvoCnzQUavZYeX+dvvpC3S6 j7S/ylpYbFrMVNRQvRSrGSLIQ+KB0paZtooM+U28+rDEOlcq+uORAqQITTnoo7YLlcWS a6EdF9R1e2Kflfpba/yb4eQU6sSH67vTWKlnFa2NL9muVIaLpNwlZ7MbXbE5BIHWeC/B g65g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978035; x=1708582835; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K5KQN5vcI0KBxXe8ErUYFGLj7ZU4KIuwkr3avJe+C4E=; b=oFXDcz8f4a/xZCi8pRPcdeaoXKV3YATWfN4XRHd6fI/oCZJvseJ1Zpiq6tSpKubV1n hDSjlvCFTiG/urmevKx7QLAbUFAOze+BFykaE5/9B2xwO6vGsos08k6EJKf3aVznXgK9 qacrvJBib6GgNg2EtAmhH5tAP9Zdi692BxOCZRaWVEGAMaV9Z/Uv+FDAbquQsU3xV4x9 FJHW87h4I8xc6/4bWZRHWxYWruDanMJtlbrz+T9qH3pna4zA0VqYxEjhQUDbBZVuwAEJ m7qSamlrhCzX9gOWmapkeds9XtG9va3qWRnNxUlqO6sRjAzmRf9prwOzPhHa4TQ+lA3H 5ziw== X-Gm-Message-State: AOJu0YwJbxxU/l5UFebInWd9zdVWivEJYvk0ON8lCEpfHeebsr6QKdmc 8TWRZtEdc8WB/CnB5GuaKPYhT94LZ2FIzDzDz97WUcR6Pjh/aay66l6Medf7F6B8HRMXNX6MU30 0 X-Google-Smtp-Source: AGHT+IFiWJfsPfpR367MqvRoP7qh+elUHOrw+yFv76U5k/fKbVI6A8Ep53d19H0vC4/FUDoeXvcWvw== X-Received: by 2002:a17:902:f7d6:b0:1d9:7095:7e4e with SMTP id h22-20020a170902f7d600b001d970957e4emr723723plw.27.1707978035381; Wed, 14 Feb 2024 22:20:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 10/36] linux-user: Remove HOST_PAGE_ALIGN from mmap.c Date: Wed, 14 Feb 2024 20:19:52 -1000 Message-Id: <20240215062018.795056-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978161855100001 Content-Type: text/plain; charset="utf-8" This removes a hidden use of qemu_host_page_size, using instead the existing host_page_size local within each function. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-11-richard.henderson@linaro.org> --- linux-user/mmap.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 53e5486cc8..d11f758d07 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -191,7 +191,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int= target_prot) =20 last =3D start + len - 1; host_start =3D start & -host_page_size; - host_last =3D HOST_PAGE_ALIGN(last) - 1; + host_last =3D ROUND_UP(last, host_page_size) - 1; nranges =3D 0; =20 mmap_lock(); @@ -389,8 +389,7 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) start &=3D -host_page_size; } start =3D ROUND_UP(start, align); - - size =3D HOST_PAGE_ALIGN(size); + size =3D ROUND_UP(size, host_page_size); =20 if (reserved_va) { return mmap_find_vma_reserved(start, size, align); @@ -550,7 +549,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, */ if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len =3D len + offset - host_offset; - host_len =3D HOST_PAGE_ALIGN(host_len); + host_len =3D ROUND_UP(host_len, host_page_size); start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; @@ -595,7 +594,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, void *p; =20 host_len =3D len + offset - host_offset; - host_len =3D HOST_PAGE_ALIGN(host_len); + host_len =3D ROUND_UP(host_len, host_page_size); host_prot =3D target_to_host_prot(target_prot); =20 /* Note: we prefer to control the mapping address. */ @@ -625,7 +624,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, goto fail; } last =3D start + len - 1; - real_last =3D HOST_PAGE_ALIGN(last) - 1; + real_last =3D ROUND_UP(last, host_page_size) - 1; =20 /* * Test if requested memory area fits target address space @@ -794,7 +793,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_u= long len) =20 last =3D start + len - 1; real_start =3D start & -host_page_size; - real_last =3D HOST_PAGE_ALIGN(last) - 1; + real_last =3D ROUND_UP(last, host_page_size) - 1; =20 /* * If guest pages remain on the first or last host pages, --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978367; cv=none; d=zohomail.com; s=zohoarc; b=GjOkddA9DIwj/hzEtaA/2S+rRcuGeDd9KhrZVkLDpcojv/k/YYHNWUz37bN9EXbp6AeshnyB6So7aHM0T441KXWM7J0ROMTb9426vCQoIKhRj/4qJB01ozioGrhsdAntjy9cdsmGIfxXYYUGDzqGLovtn+woxVNe7/A0t/ZGecM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978367; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=dqsCaU7xkBNpUEPfjBIrFswyFdFT27Uyo7EoWA6f8HhkN7mvI2aS8OPkawkmYulKn/va82ICROCCvp2ttENrs1fa8cVQeJ8enW2dmOCSzGIoHte+oV0orjstQUTqqTnA6RvFJ1e5+tYa7g5zf1RVEh36IjlkvH1fqZjackJ+4oA= 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 1707978367526985.4408228845588; Wed, 14 Feb 2024 22:26:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV74-0002Ml-FB; Thu, 15 Feb 2024 01:20: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 1raV6t-0002Jb-UZ for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:40 -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 1raV6s-0005TB-8t for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:39 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5ce6b5e3c4eso398238a12.2 for ; Wed, 14 Feb 2024 22:20:37 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978037; x=1708582837; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=kyE+u9nVvw+xMyRJ9BwM+rq86mWks7j+fwgHWUFj3SD1sFd6VTJPxTFkstVkmRNkgr Zz6Mn75ODKSZoBp+0mqRH+PKrLc3KZaHeoZ5z7gn89UIk4DSk/CrzoHKwsqJain9aIkD vF9oo/EgDlcDktVDzmJiFFaSjDAIaF6a1NVkec7qmXDyQB2R4O3VRN/ENQ561WAkFvuc +a+DaTfQD9mFiwmNDoGaJCmDIPXzCixUVceTx+7k0YMrEpiJKRQw8Puz99iiiSagYy9W 0CLwC3ibMykqJap4HIbDTnWc6ppXDd1e74Umc4MRU7x8Sy9mFe2+g54ylarsURluR1ei 9d5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978037; x=1708582837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z/9ie+RjhRAxWQRFAoaHPcdtrZYsCMJBCi3SaKV1dlk=; b=PnYJD4AWTRJVkkYhN4nR8DWVGsfMJAVfg8Y7ZyRLMyORxcudU7vzrKEc4Y0At9epjz copYxIxXydgWLt5BBIhI5glIsQigQ/45tVtPJ15vLqgXBDIG+6ofHhqfn+D/A7yAXRXZ UAcdfBTEktpQDb6XLmiW8HkLoaS72V4/Kr5zIRQxk7EU97rB+yZDTCgqrxyEZrsgd1Jz iWwFZq/3gjRiO2esHA80HaFo7/pa1NgMgZdDFr8+pnkwiVCGCvnlDiN3qXSGMzAMAk7K i5JPN3xkkRB6+cA9SDCK0Ig2nz9dIlRvc7+VpBtFSY80cZJjuHJjALab2U4bBowuL4jH 8cfg== X-Gm-Message-State: AOJu0YzhkeC0H+9jboERXC0GETQFSmGr0Axxny+WWuIC1XYkOUJZTVWq hlOYO0Ja3/Qaozp0MJGFl11cvRVZzrQ3RpIadgPHnY5xocsPH4i/uF6OCavg5xaCg9oOpxVCpPC s X-Google-Smtp-Source: AGHT+IGwE7m9GInItJziaAaBXCCX8w+tWtIQk1sDDLvWFB7AKvfxgHUTnItrWaa0O6s/tOAD8U7yZw== X-Received: by 2002:a05:6a21:1519:b0:19e:9aec:ba1d with SMTP id nq25-20020a056a21151900b0019e9aecba1dmr1442595pzb.47.1707978036792; Wed, 14 Feb 2024 22:20:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 11/36] migration: Remove qemu_host_page_size Date: Wed, 14 Feb 2024 20:19:53 -1000 Message-Id: <20240215062018.795056-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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: 1707978368557100009 Content-Type: text/plain; charset="utf-8" Replace with the maximum of the real host page size and the target page size. This is an exact replacement. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-12-richard.henderson@linaro.org> --- migration/ram.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 4649a81204..61c1488352 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2935,7 +2935,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) { RAMState **rsp =3D opaque; RAMBlock *block; - int ret; + int ret, max_hg_page_size; =20 if (compress_threads_save_setup()) { return -1; @@ -2950,6 +2950,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } (*rsp)->pss[RAM_CHANNEL_PRECOPY].pss_channel =3D f; =20 + /* + * ??? Mirrors the previous value of qemu_host_page_size, + * but is this really what was intended for the migration? + */ + max_hg_page_size =3D MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + WITH_RCU_READ_LOCK_GUARD() { qemu_put_be64(f, ram_bytes_total_with_ignored() | RAM_SAVE_FLAG_MEM_SIZE); @@ -2958,8 +2964,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque) qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idst= r)); qemu_put_be64(f, block->used_length); - if (migrate_postcopy_ram() && block->page_size !=3D - qemu_host_page_size) { + if (migrate_postcopy_ram() && + block->page_size !=3D max_hg_page_size) { qemu_put_be64(f, block->page_size); } if (migrate_ignore_shared()) { @@ -3792,6 +3798,7 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *bloc= k, ram_addr_t length) int ret =3D 0; /* ADVISE is earlier, it shows the source has the postcopy capability = on */ bool postcopy_advised =3D migration_incoming_postcopy_advised(); + int max_hg_page_size; =20 assert(block); =20 @@ -3809,9 +3816,16 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *blo= ck, ram_addr_t length) return ret; } } + + /* + * ??? Mirrors the previous value of qemu_host_page_size, + * but is this really what was intended for the migration? + */ + max_hg_page_size =3D MAX(qemu_real_host_page_size(), TARGET_PAGE_SIZE); + /* For postcopy we need to check hugepage sizes match */ if (postcopy_advised && migrate_postcopy_ram() && - block->page_size !=3D qemu_host_page_size) { + block->page_size !=3D max_hg_page_size) { uint64_t remote_page_size =3D qemu_get_be64(f); if (remote_page_size !=3D block->page_size) { error_report("Mismatched RAM page size %s " --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978368; cv=none; d=zohomail.com; s=zohoarc; b=m9reZS3TiahbhE7Ks4VKvdGnjcgLrSCgjgXN5h/pZoPPzBtF5VAD2adeS//yXr6w8FPBFgGpaHRJzmts8AhCPQkaMFcE+9RJorqHe/bhNdOS7Y/ooVO4sC4r/yshmpUhcjgZPiQNWBLVAE6ueN6Mjdan1W8Txy6T/HB3dgIJIMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978368; 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=8e59UVGjA+rf7vDiYDlVPV0vb6j37PsuKcjN1UFSiz0=; b=BwQw4vApuoAWXuunoY5ITt2jJCbVnPSKQ1vJiiSMwlwUIO2h2GXnYWPTIcz7bSoC3rIfm5JQZhncG9VckFbzPAh/wvDe04WhXoSoDYVB2ffPxxDPS59gkUrYQdYUqpWtTEAUMmVXP23IKK7RHuH9C6v8Q/Ov0pd2JmbiLvEhWac= 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 1707978368762903.2076052765793; Wed, 14 Feb 2024 22:26:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV75-0002NI-C3; Thu, 15 Feb 2024 01:20:51 -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 1raV6v-0002Jv-28 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:42 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6t-0005Td-G8 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:40 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d8aadc624dso4184415ad.0 for ; Wed, 14 Feb 2024 22:20:39 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978038; x=1708582838; 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=8e59UVGjA+rf7vDiYDlVPV0vb6j37PsuKcjN1UFSiz0=; b=m6dM743nvCBONtmpXoTrg98ube4wBIS/1gKtxfx3gVz5jGnSFjMZcvEIX90u6Bi40b NKgfUan9q6KpdckTTYBQiWxy57lFN6i0eSK1gXCuNFSpBwqf8oKEzEmsUa1F2DIghhws cSBN7Vlh1b7GAXIxmu+OZPrC5Ej5wQzYw6B933EYhl7KYxwHezKHXQRrnWe3LKGmCm2l z3b5uGHq8Nk3kArITyPE0bKIKi/qPoy+kELXwgxF8chmc50ldy6KgD7qlMUB4pStrkip uPCF735JclVbccypzr8B0f9GLr/knPKdB55iNph3kTZDBPhDXSe20JfQiYgYrJ4GdcqE MNAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978038; x=1708582838; 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=8e59UVGjA+rf7vDiYDlVPV0vb6j37PsuKcjN1UFSiz0=; b=kj98B+e4kgiaCzZL/H7RlcoQB1WRyIW5cGL69L9uFUfPZvO/f9vjvYB6a2SoOigxo7 vF/2sJsCZ9znI+Bav5N08gSqygvjyR9cq8GXitRfzWAOdn28oWMmE0Z1CLYuZuQvLrZu 3L0zzDwAv8lCKCa9iWSW+d2/IibCukAMcIdrCK7Yab8usI8KLLgFepP+2TK3xjhaUmUT ceh1nYKHtyqHSAqngDMGXYxDcwSwDvgODYGab08+KDeOD0Q29APtjZTk4HdgZkwtunl3 FQYxjWjJy/UgQfF41GfTO94gH34+mCV0Rh7mxNzBFJCTa6Utx6ZGE1Z3qRGILPurfsU+ v97w== X-Gm-Message-State: AOJu0YwewvCyWBucBV1D7AwDkMMjNVleLdbV0m2j2X8GXSVN26qxP18b 0WbL8sc7EjG9cu+0HZwmSu1umzsCwflC27XdH9AfZIDiMFD5Fygx3Pp5Q9RWP12vMEQY2yocmYO 9 X-Google-Smtp-Source: AGHT+IGOPl7aLeb+RTsbvuqH8pWpd8f3a0w1l4a3JBWEDz1RjmGBP8n9D8UKg29DE749eB5plPmV+w== X-Received: by 2002:a17:902:c40c:b0:1db:5093:5e23 with SMTP id k12-20020a170902c40c00b001db50935e23mr1026511plk.28.1707978038374; Wed, 14 Feb 2024 22:20:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 12/36] hw/tpm: Remove HOST_PAGE_ALIGN from tpm_ppi_init Date: Wed, 14 Feb 2024 20:19:54 -1000 Message-Id: <20240215062018.795056-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978370552100013 The size of the allocation need not match the alignment. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-13-richard.henderson@linaro.org> --- 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 Wed May 15 07:00:49 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=1707978334; cv=none; d=zohomail.com; s=zohoarc; b=aNc7dYt5k+oS+nYgmo/AsCLWs5qy2tSQ1I1uVJL8Twr6KR5JWkk77o84nkshUkwiF3llyT2coRPOe7zh1dvmrQo3Ocqy8mJwDTwcgnJJPJityFryfy1ddotrlHZp691SFqA6NKd1W8beGT1VCo4peQhZbQiXfI+BCuP7aPbbqmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978334; 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=wG9KSOs67vbPNFTw70Lf+VF+Rn5tDSL+goWS2BCj7Lk=; b=kzkpuKy0ry4+ioZDY4DBPiTsj/TyUedLYN/McN1yz1Zc36DnFHrnCHYpCqDASQSeCxzSJMlB56omS9Ox5AaVbnd4R+EOS/+IVlQMTs5GfSnAatCMB8RBrP9Hr95Fny8hbKDgwyuZudU/Nj+5lwOZwTq3BU36ELaT7MYSPLjJRv4= 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 1707978334446271.6171830551576; Wed, 14 Feb 2024 22:25:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV73-0002MJ-T1; Thu, 15 Feb 2024 01:20:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV6w-0002KC-PK for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:43 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6v-0005U5-7d for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:42 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1d93edfa76dso4049215ad.1 for ; Wed, 14 Feb 2024 22:20:40 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978040; x=1708582840; 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=wG9KSOs67vbPNFTw70Lf+VF+Rn5tDSL+goWS2BCj7Lk=; b=kXTSRTuI6o2qStHv1sX7oBbUcD3km1U2ZKlxRiJXf+TJ7o28pZ9Sg0OT1+poWJH6I4 ZvwBVYE2LtO3SDU+C5EmaMsXjsD9BONrylWEp65XdLoaM+CP8hm3zj0bWCr7YF3OEiwk 2cmEazCVd9VDhuwk52/hV2kfe6l7Ds5U6GFMRm0NHJnlJQgZtnu2r9E9VpkLE4XYMB1K Qx5w9aNl2M2dsraGoPtRB9Tn7z20W69yAmwrAsKnilYd9KDBuVOVbJBomC2z6Jkm0Yk6 JE7rQSvarkiMmXAXFeC41VmKVZKJkBv/Plrloy/dbiOPx1pDsojHxhVrEOK3Q/BzBjqU IE7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978040; x=1708582840; 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=wG9KSOs67vbPNFTw70Lf+VF+Rn5tDSL+goWS2BCj7Lk=; b=E++tJJCE5u3wrKxmqLXiAThuLfVyWZjrGdzJv/bLdQtUv2FuOvOJm9MsSJUsrFj/Ts dHn42Lt+z0uYymaGDTrv9raj+zLN1BaMeYMjvl8r7t7Gc2QjoDrYmSVF+Eox3Mlrhqai AmP97wmDYUDm8U0g0tjHUEd4ddRk+ok1Dt+wbyo4Aa6wqzGSZESPmc9VET/XWbK84A8R HRGpgbjOF44BAQXcvhYxIEZAF/6WaEZtwXgfGThpZulOcVh5WZbAY4w8+gnLK7BOYx9/ 7GmNpQgWiSj913dNOxgSpHmPLC/SfWDMJdieXF2+6MKVlJlTiAmMAvD44Da+fjUWjPtf AfZg== X-Gm-Message-State: AOJu0Yy2L63zNWBnL8B3WwRuxKC4NjHVrC2AoQDwmBKvACpq9wdrsHMW DuIsHBHeUmm+tGpFaPQytzUgF2Zd+PipA24/h8ZpMRiRgYjYiot0SqknxwnJFHesEkWYOQAhH+P E X-Google-Smtp-Source: AGHT+IEFxXMXJqOPeOdZ4wmJgRxi1hXTCwI7yV6NnbxfibDur6HhXWtHGiT8SgN9xz5UmmbQ7uuO7g== X-Received: by 2002:a17:903:183:b0:1db:6a20:24ca with SMTP id z3-20020a170903018300b001db6a2024camr1062036plg.5.1707978039823; Wed, 14 Feb 2024 22:20:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 13/36] softmmu/physmem: Remove qemu_host_page_size Date: Wed, 14 Feb 2024 20:19:55 -1000 Message-Id: <20240215062018.795056-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978336427100001 Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-14-richard.henderson@linaro.org> --- system/physmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/physmem.c b/system/physmem.c index 5e66d9ae36..508dcb7494 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3515,7 +3515,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 Wed May 15 07:00:49 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=1707978358; cv=none; d=zohomail.com; s=zohoarc; b=f9efRFZLa//ERHizav5r28fV+NbOol3/aIv9Y5eEE13MrU28QY+xvVa/lamUAFvDObdRapTq9A/bo0CHhYbzUXOXqb3TA2PuU/RyS93S5UcIYmY6xnx/tPDg9mIgvxYgWDitAcnG86zHKX7mZlzAma+cF/lNfwVVIUw//pnsXLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978358; 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=xf7vdSAvh/ZeTBRvXJBUTE4ih7Lx/NEC7LNkf984wzI=; b=Xa1r18ZAfnUxxFKpLsXx5Eytxb8nZVe8XqxQ1Obsd9M1RCNIv6HtmfHEUICf9T8lUE08EAjKhwCtTB1pCmvQIRfXtjl2zTlmGPOoulAsdBI+BVmWTl+FQxZJH4T0T79TaF6AS0/1EJ0mFmv9CoNUcjLqQb8wYFPSe3R58z/D90c= 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 1707978358472613.8468179215461; Wed, 14 Feb 2024 22:25:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV75-0002NH-7n; Thu, 15 Feb 2024 01:20:51 -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 1raV6x-0002KX-VU for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:44 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6w-0005UT-CK for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:43 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1db5212e2f6so3915055ad.1 for ; Wed, 14 Feb 2024 22:20:41 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978041; x=1708582841; 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=xf7vdSAvh/ZeTBRvXJBUTE4ih7Lx/NEC7LNkf984wzI=; b=b5/s+50jnCvU47HaumMDOWrixy55mYqUwuR/6/oF8ZQh98ljwurwbGyaUJpWEeBiQI zJezHEtpBOsPxXYxLtr+vX4OOvMok2YfDATUmCLrdm0OBK4frbaQlykTQuBlRjWSweu2 9ZR3U82t7EJkjTadc+hfBFjOr9b+20MMPwMTqQ3HROvo8MYClsIZVFOaIKYFUCQiE4CI yPKJ7JMENxmklh6Hm5IhJaypXHHMMPphmCWGx58g5DP4+QrrsUruxOkOB1nFOgpYm/bn c26MCpjMBQ0wX3NAKttexun9VrCuldaixBOYQ9l8tttNS1Fyn8TcXTAzqyNehQFaV4yU JqBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978041; x=1708582841; 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=xf7vdSAvh/ZeTBRvXJBUTE4ih7Lx/NEC7LNkf984wzI=; b=NQB30TGLvCnykAgZOXOpmMrURX03AFVn0M2KfIdbH/J9t1Bv1EPp3ebvOnj+ZW+59H wj3Csa55aycXYbpj5KSXIachBABKlY/RXywxWNiK/0gWCoE4+AsXHFW2JrxnnB+KgC0G nccYHmT4LXQNlxj26HGgfPl7wua7/tjy3N3B606kIXjeAR6Lyk+FkN+t1ZBtlGqmeOxA Iqu8EXhumNFOksD5lX33MkkDTPIEn6tXYq86amRHeILJ+74PPcVzloSJ2WlB2qZMLWJZ 0bbO/OWC5U4XIhB4c3ZDN7vIk37bUguh7fKRiBn2TrXgJWFAAH5p9h9Q1IUaPG2GBg8c c4gA== X-Gm-Message-State: AOJu0Yx8XCyOQrIo991lrBuLB+es6dG/cgo1gLuktYXNVSPxXMb5Q8T6 HNHJWiCySRqQOn6GGsHBRzeIP1k0xyg2Q9lnwMwUXDMrJTExKxguaSbF+0kfUKkSd4Sw2x7ZK+u G X-Google-Smtp-Source: AGHT+IEdH6d01RJl0y/+qBoK/94nPayho6ADeqOQKWLhTi3fS0C5Ud+YeaSabt8VQzwESczyTzbiTQ== X-Received: by 2002:a17:902:d2d2:b0:1da:2128:eb3b with SMTP id n18-20020a170902d2d200b001da2128eb3bmr6822345plc.28.1707978041161; Wed, 14 Feb 2024 22:20:41 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Ilya Leoshkevich , Pierrick Bouvier , Helge Deller Subject: [PATCH v4 14/36] softmmu/physmem: Remove HOST_PAGE_ALIGN Date: Wed, 14 Feb 2024 20:19:56 -1000 Message-Id: <20240215062018.795056-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978360540100005 Content-Type: text/plain; charset="utf-8" Align allocation sizes to the maximum of host and target page sizes. Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-15-richard.henderson@linaro.org> --- system/physmem.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 508dcb7494..6b7c5747da 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 Wed May 15 07:00:49 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=1707978106; cv=none; d=zohomail.com; s=zohoarc; b=L0mcbYE/0Hcbt4K5rGo3LJ6aBnF0gCpZH4EgRALwmM9GUxrm233upKHGQBcxWb4v1stAmYutPGhAAaFpp1jZd343niE+bbydQUf471UEeiJEZg23MOdccN/Kzwv9/mqW4aNxNlIE6Opt053Eohp+Esh8W2X6+jTqu0xu7Iq6AWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978106; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=m9Wf1HvqPkvrlwjp7RqggtK+wiZzOAIbmJ885Shwi2Lu6LoAXG00Un7sa88vdtzCHusWQVkG1ZCOS7HtszdMWmU2c7dQH851Ze/ROkdKvqdexzT97+2TQGpd2rxu1+3QFbFOWUUflH64WsYasiviFfn6ZLGVO0MvBnsWXqdmBh4= 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 1707978106763782.3045817881127; Wed, 14 Feb 2024 22:21:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV76-0002Nd-So; Thu, 15 Feb 2024 01:20:52 -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 1raV6z-0002L7-Ay for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:45 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6x-0005Uy-N3 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:45 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d93edfa76dso4049355ad.1 for ; Wed, 14 Feb 2024 22:20:43 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978042; x=1708582842; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=b6PaTaZmEC5BKo0TzRJqcR8Cp5VsAbyS39upUhfg2IimeDdId6ntz1ONy+W1OVqAvW 3gzaurdQmMLKMf6tMPIoOktjX7rYtWSqngNSY0kVAZA/xgo6ufJ9RZOj1FcuVzF9i1Rl 0GSPo68/qUGiawA3VcgOE4sZc+vFWAM55qFX4E2CDaJJp0ObEeO7Jy6UW3kGiZMzAc8e hua+R/A7Ilu7HGjRHokL5PuUtkclONNp/0JMV7I0sCebwzFhcauVtgDIXw1coRGaHSOt fea6B+qUT1cuv8iRTHTszmGcIJCotkAiPzi9r1h4QafFR7VA8IZykOV7De1QKeni9un8 JUGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978042; x=1708582842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MJwI7j8qAfDRGrC+KBy3NdL40EXjR4qHacqKh2GDQwg=; b=urk8PXqZzKAygUPbyDKYkiXuxU0cpMQKFItCo+AHeWQiBh8P0nVAtknDFlpUm7i1M7 iDWLEQ8fpzYanItaEzRgV2xvRsDNGelRPf0ZSeFwccMqQUVXhrmHKlkDPkOBES4+bv3M 5fG5omYsal2KFntuS15Jqyp+LKu3xXWu59AXRZnuHbAjsYFNzrQyCG9oWAU5ChfOBAFa +OFOFYfFwibZIEA8CvnwMW+3GI5Q/HN/DG9g1oHGtjAmk10j55wjx/cb7R/RUep6kmDg /CVGlbwvr8gg9K2tuRI8siNo1ZYzHDtGkK3oPknGF3FkDXr4fce+nk/veSKCiMKRantL xXaQ== X-Gm-Message-State: AOJu0YwDVFh1qDe6msU13dGubEqBlMK/pT5mNxnpQQxuLsqQO6taLky6 KWlFX+IXCllgeT5FQx1isR6bhvqRhWBtoDgCVaiOrY0uEdXPgQMcokJqqPS5lrfZcfE8p7Vf1Fl T X-Google-Smtp-Source: AGHT+IHL09jobZaOXWynFqV8jUYEXLonUZWHHv8Atf7B2fptXqs6SYacy0N1dna0cLGBrerePXmakw== X-Received: by 2002:a17:902:6502:b0:1db:65a3:e17f with SMTP id b2-20020a170902650200b001db65a3e17fmr698708plk.6.1707978042587; Wed, 14 Feb 2024 22:20:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 15/36] linux-user: Remove qemu_host_page_size from main Date: Wed, 14 Feb 2024 20:19:57 -1000 Message-Id: <20240215062018.795056-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978107654100001 Use qemu_real_host_page_size() instead. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-16-richard.henderson@linaro.org> --- linux-user/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 74b2fbb393..e540acb84a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -781,7 +781,7 @@ int main(int argc, char **argv, char **envp) } cpu_type =3D parse_cpu_option(cpu_model); =20 - /* init tcg before creating CPUs and to get qemu_host_page_size */ + /* init tcg before creating CPUs */ { AccelState *accel =3D current_accel(); AccelClass *ac =3D ACCEL_GET_CLASS(accel); @@ -804,8 +804,10 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va =3D MAX_RESERVED_VA(cpu); if (reserved_va !=3D 0) { - if ((reserved_va + 1) % qemu_host_page_size) { - char *s =3D size_to_str(qemu_host_page_size); + int host_page_size =3D qemu_real_host_page_size(); + + if ((reserved_va + 1) % host_page_size) { + char *s =3D size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n= ", s); g_free(s); exit(EXIT_FAILURE); @@ -902,7 +904,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr =3D=3D 0) { - mmap_min_addr =3D qemu_host_page_size; + mmap_min_addr =3D qemu_real_host_page_size(); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx (fallback)\n", mmap_min_addr); --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978345; cv=none; d=zohomail.com; s=zohoarc; b=ZcWzZA+u4EO0z9f4+zKFR699x80CnjAhKTX/EnL5b/0YdiaBmvm1KDVqn8LsrfRLy5LDB2FP8zcY1zepJSF1V+75az3h3hBNHA4G5XoazztVkxbXRco9sPs+ULqogksEWysMavp5ouqAopXnU7EKL2RT3TZUmnr3B1OJxbXEfJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978345; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=DhMujnuekb/ySpFAcEvdsIFs5YAClIpIW8zplcwd9NwJ+sCvvpdUAzKpslWMWsHRTi9TWTRJLK43kVKxUyWQnGqY4OAydv1XzhPobrQd+oKxzBuI+rULRsYvbhxwuJRcdH7R4RQmFB/QVDhUpv740zvgiIVqMVzvPOdsZO1OrVo= 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 1707978345739101.85301361357415; Wed, 14 Feb 2024 22:25:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV78-0002OK-25; Thu, 15 Feb 2024 01:20:54 -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 1raV71-0002LP-KO for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:47 -0500 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV6z-0005VQ-M2 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:47 -0500 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5cddc5455aeso411631a12.1 for ; Wed, 14 Feb 2024 22:20:45 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978044; x=1708582844; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=hMX3/dye6Y3L1T1eAPoMuzPYU25ae4CvShnW2sBb1A99JSfxkzdqbqj7Eeeo1dm0yr SxGgxpoBIJKYNNZMK3Y7yYSOScwEneTuUHdokco+PpCAP538rC02O81ZTTMZm8ABUAdt KWc7xz87Moz7T7Djefvw3meWfkF8ouLDe2H1BpFNy3/J5sRVqYSHE4aqxBHKAaZYLjuM PULxN33iivAgbrw8IxIPqw017lIuf/b5iNdOypgi4EPK2TCMdDdxQUj/kMYNQCt6Q1wJ UqkyaUcOXdUn+8A90nxDR6qdKh6BVMUTJpPHb2JXbwfx9FXR9GkGt51RRN0b2c+PDbIt B5Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978044; x=1708582844; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qzBaOBmrgtVcZmBT0VJjVQXI2NhHPFgQ+IyeqJADkZ4=; b=SPXXMkqPrITOxv+lYGohi4RgIrXhqVr5x6cm50wBL8ZSx/OhdKj+1443PODDzG8ykT YBj/3poWAniEDWlvi38epfOFMF/KW6ysx3UK3/ATUdn4uuysTJLCu9arHr8XCl7DaVuq sM5dC94BbjogQD0/RdR0Ss/B9kRVb2L18GsTQTNKyRq7fsldoqPWvh0SwrIEuMaPjBfm 5lJVHvL/UWbm40LYZ6Icw3tZFNYcBL6cXNSqVos6chGJfXQc2hQH9tOZdOsWrUoMJsIr EqFx+WtsU3VqE451den0oirC6T8YrHDRVfmQgrLkL0nQJI91DmArmu88S7CdNVkjucVS YcfQ== X-Gm-Message-State: AOJu0Yx4LoIx6IuarlpxWhbbuwjw/WP2gsNPDVtiRKEF8m1HThT4YDK6 ZL6jyZywdWZC/wGrAxof51XBZJlTRTfLWixCM+mIW3ZFX1vwffxKayDDbxXF7mcrXFxdCrfcba7 x X-Google-Smtp-Source: AGHT+IFQNYiZUtBt+e26S+lBBRCXKS3xSVMZwalPT4mtPAfciuQWBx6Q0Z4GYKmzEd/g+5YeIWggBQ== X-Received: by 2002:a17:90a:dd41:b0:296:6a37:c528 with SMTP id u1-20020a17090add4100b002966a37c528mr789257pjv.24.1707978044222; Wed, 14 Feb 2024 22:20:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 16/36] linux-user: Split out target_mmap__locked Date: Wed, 14 Feb 2024 20:19:58 -1000 Message-Id: <20240215062018.795056-17-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::52c; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52c.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: 1707978346503100001 All "goto fail" may be transformed to "return -1". Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-17-richard.henderson@linaro.org> --- linux-user/mmap.c | 62 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d11f758d07..b4c3cc65aa 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -490,9 +490,9 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size= , abi_ulong align) } } =20 -/* NOTE: all the constants are the HOST ones */ -abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, - int flags, int fd, off_t offset) +static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, + int target_prot, int flags, + int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; @@ -500,30 +500,27 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, int page_flags; off_t host_offset; =20 - mmap_lock(); - trace_target_mmap(start, len, target_prot, flags, fd, offset); - if (!len) { errno =3D EINVAL; - goto fail; + return -1; } =20 page_flags =3D validate_prot_to_pageflags(target_prot); if (!page_flags) { errno =3D EINVAL; - goto fail; + return -1; } =20 /* Also check for overflows... */ len =3D TARGET_PAGE_ALIGN(len); if (!len) { errno =3D ENOMEM; - goto fail; + return -1; } =20 if (offset & ~TARGET_PAGE_MASK) { errno =3D EINVAL; - goto fail; + return -1; } =20 /* @@ -553,7 +550,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; - goto fail; + return -1; } } =20 @@ -574,7 +571,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, struct stat sb; =20 if (fstat(fd, &sb) =3D=3D -1) { - goto fail; + return -1; } =20 /* Are we trying to create a map beyond EOF?. */ @@ -601,7 +598,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, p =3D mmap(g2h_untagged(start), host_len, host_prot, flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); if (p =3D=3D MAP_FAILED) { - goto fail; + return -1; } /* update start so that it points to the file position at 'offset'= */ host_start =3D (uintptr_t)p; @@ -610,7 +607,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, flags | MAP_FIXED, fd, host_offset); if (p =3D=3D MAP_FAILED) { munmap(g2h_untagged(start), host_len); - goto fail; + return -1; } host_start +=3D offset - host_offset; } @@ -621,7 +618,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, } else { if (start & ~TARGET_PAGE_MASK) { errno =3D EINVAL; - goto fail; + return -1; } last =3D start + len - 1; real_last =3D ROUND_UP(last, host_page_size) - 1; @@ -633,14 +630,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, */ if (last < start || !guest_range_valid_untagged(start, len)) { errno =3D ENOMEM; - goto fail; + return -1; } =20 if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { errno =3D EEXIST; - goto fail; + return -1; } =20 /* @@ -671,17 +668,17 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, if ((flags & MAP_TYPE) =3D=3D MAP_SHARED && (target_prot & PROT_WRITE)) { errno =3D EINVAL; - goto fail; + return -1; } retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, (flags & (MAP_FIXED | MAP_FIXED_NOREPLAC= E)) | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr =3D=3D -1) { - goto fail; + return -1; } if (pread(fd, g2h_untagged(start), len, offset) =3D=3D -1) { - goto fail; + return -1; } if (!(target_prot & PROT_WRITE)) { ret =3D target_mprotect(start, len, target_prot); @@ -696,14 +693,14 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, /* one single host page */ if (!mmap_frag(real_start, start, last, target_prot, flags, fd, offset)) { - goto fail; + return -1; } goto the_end1; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, target_prot, flags, fd, offset)) { - goto fail; + return -1; } real_start +=3D host_page_size; } @@ -713,7 +710,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, if (!mmap_frag(real_page, real_page, last, target_prot, flags, fd, offset + real_page - start)) { - goto fail; + return -1; } real_last -=3D host_page_size; } @@ -739,7 +736,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, in= t target_prot, munmap(p, len1); errno =3D EEXIST; } - goto fail; + return -1; } passthrough_start =3D real_start; passthrough_last =3D real_last; @@ -773,11 +770,22 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, qemu_log_unlock(f); } } - mmap_unlock(); return start; -fail: +} + +/* NOTE: all the constants are the HOST ones */ +abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, + int flags, int fd, off_t offset) +{ + abi_long ret; + + trace_target_mmap(start, len, target_prot, flags, fd, offset); + mmap_lock(); + + ret =3D target_mmap__locked(start, len, target_prot, flags, fd, offset= ); + mmap_unlock(); - return -1; + return ret; } =20 static int mmap_reserve_or_unmap(abi_ulong start, abi_ulong len) --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978350; cv=none; d=zohomail.com; s=zohoarc; b=hoi9GExKqsPhCrrrSZCAXssqXNn5IydHlyybwc1TQ74xGKa94Nfdb4WkFnjOwRoM6Qi8GtXDmYMzkWfKNYMVNPPAFr2oBgU9bxW7nIscedTtbpkqRjLOdqU7JP7URS67tarNejYJKd0C77reN3pvdiqwQd/qwa2/Zges7pLyPpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978350; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=jtiYNzlZfm6QNNmSfo9IF0m4EvJ5lx4oFQp1dh3fkDHWK4Sz6OgvUVr1Fnfp4iiqDNBydCx04uXUbR51uHJzNcAXP+LEZWT80BuptK4IdEC1i/fQjCAKqWwZ3vMx8K6llNXnWhY9sUJiNMELkaiJcpzYoftIJ/2IuA0zEYiAPGA= 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 1707978350074543.9853697123328; Wed, 14 Feb 2024 22:25:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV77-0002Nm-GD; Thu, 15 Feb 2024 01:20: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 1raV73-0002MV-TC for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:49 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV72-0005Vk-0K for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:49 -0500 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so450889a12.0 for ; Wed, 14 Feb 2024 22:20:46 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978045; x=1708582845; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=nKHdF8kErZf2byCR7DRDfZpbofKhm30+gsI8hj4nUR3fzHMKx2NysXuoDpGfzqJOT/ jrUCVHxTJIAQRYVrHgAFHqRgCAEnjzk2vmPTTGbOCcKcUk3OUPa+Lk+LG5LBhrWksnqN 2rNzD+bbaY5hsaQkiSMAGgCTpwCOkwF4FQ1HldOxZKp7lfNFKJvHr0cBvfZGa3jiqR78 aK4OcWPGN+3g6VuAnzBwYyF59qS0sTKH/CINuJSvUxHIF5XkH+KN+3A2qO8t7kuJ3H7K 8D6jqf8eg6vA9G9Y/eB8qtMx7xE73CadVeW8JmNz528ZcU0Jh2ZpO91jEnqp9EnapS5M 1nAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978045; x=1708582845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=48MAJNKY8itF/Uvxdy9leMjwL6Lq94BoHatvMOlA6tE=; b=kmog/E9os/wqap/S406U2Gal8Z/yQLNUgj/1f2gbN+bstqPzhEdV4vafT68YhiEFRD knR3TKRsUUGK6OtdyxTRg8i0qyX2ncoL9uS34O5teHDsiiK5d9qK6/eUESPonlx6cboj rDEtMz3pHIfKq/bNv3jH8dVvzc8XqBUoEoo8UrbKjEfpBpm3VAf/m1z6XzQs9QDhRCaH LRlRHzOhadUQctaGNyFSak6HqkMsR/jACslzU9vcti1/g2cdS4bVA+ASjJMXQmb3ebRl Bd57ZqJDO+NBdy/wLsSkTpHe00aD6ikIeXzAuWeFga+M281e3xNqUqVQsMV2YNMsWzxy SzfA== X-Gm-Message-State: AOJu0YyoB1JodZJqah+cu/JhnRB/XoxYXr+UDU1iVThrJVaOyHTYZIwL WRg6X4NbIzqYlN4zWOGqMZjZ0HrX5Ws/nEfanUp1PUnsl03kTGzJZBYjgyZm/qcLNg/QKht0PWV n X-Google-Smtp-Source: AGHT+IGMaBPi1eRGeLtZl3oMvDtoslSoLZjmdMQaGckTHAWccMqvV4S5FE2JSSJkxFN+dU6Rta73Tg== X-Received: by 2002:a05:6a20:6683:b0:19d:9089:9ca6 with SMTP id o3-20020a056a20668300b0019d90899ca6mr924655pzh.32.1707978045675; Wed, 14 Feb 2024 22:20:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 17/36] linux-user: Move some mmap checks outside the lock Date: Wed, 14 Feb 2024 20:19:59 -1000 Message-Id: <20240215062018.795056-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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: 1707978350557100001 Basic validation of operands does not require the lock. Hoist them from target_mmap__locked back into target_mmap. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-18-richard.henderson@linaro.org> --- linux-user/mmap.c | 107 +++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index b4c3cc65aa..fbaea832c5 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -491,52 +491,14 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong si= ze, abi_ulong align) } =20 static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, - int target_prot, int flags, + int target_prot, int flags, int page_f= lags, int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; - int page_flags; off_t host_offset; =20 - if (!len) { - errno =3D EINVAL; - return -1; - } - - page_flags =3D validate_prot_to_pageflags(target_prot); - if (!page_flags) { - errno =3D EINVAL; - return -1; - } - - /* Also check for overflows... */ - len =3D TARGET_PAGE_ALIGN(len); - if (!len) { - errno =3D ENOMEM; - return -1; - } - - if (offset & ~TARGET_PAGE_MASK) { - errno =3D EINVAL; - return -1; - } - - /* - * If we're mapping shared memory, ensure we generate code for parallel - * execution and flush old translations. This will work up to the lev= el - * supported by the host -- anything that requires EXCP_ATOMIC will not - * be atomic with respect to an external process. - */ - if (flags & MAP_SHARED) { - CPUState *cpu =3D thread_cpu; - if (!(cpu->tcg_cflags & CF_PARALLEL)) { - cpu->tcg_cflags |=3D CF_PARALLEL; - tb_flush(cpu); - } - } - real_start =3D start & -host_page_size; host_offset =3D offset & -host_page_size; =20 @@ -616,23 +578,9 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, passthrough_start =3D start; passthrough_last =3D last; } else { - if (start & ~TARGET_PAGE_MASK) { - errno =3D EINVAL; - return -1; - } last =3D start + len - 1; real_last =3D ROUND_UP(last, host_page_size) - 1; =20 - /* - * Test if requested memory area fits target address space - * It can fail only on 64-bit host with 32-bit target. - * On any other target/host host mmap() handles this error correct= ly. - */ - if (last < start || !guest_range_valid_untagged(start, len)) { - errno =3D ENOMEM; - return -1; - } - if (flags & MAP_FIXED_NOREPLACE) { /* Validate that the chosen range is empty. */ if (!page_check_range_empty(start, last)) { @@ -778,13 +726,64 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int target_prot, int flags, int fd, off_t offset) { abi_long ret; + int page_flags; =20 trace_target_mmap(start, len, target_prot, flags, fd, offset); + + if (!len) { + errno =3D EINVAL; + return -1; + } + + page_flags =3D validate_prot_to_pageflags(target_prot); + if (!page_flags) { + errno =3D EINVAL; + return -1; + } + + /* Also check for overflows... */ + len =3D TARGET_PAGE_ALIGN(len); + if (!len || len !=3D (size_t)len) { + errno =3D ENOMEM; + return -1; + } + + if (offset & ~TARGET_PAGE_MASK) { + errno =3D EINVAL; + return -1; + } + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (start & ~TARGET_PAGE_MASK) { + errno =3D EINVAL; + return -1; + } + if (!guest_range_valid_untagged(start, len)) { + errno =3D ENOMEM; + return -1; + } + } + mmap_lock(); =20 - ret =3D target_mmap__locked(start, len, target_prot, flags, fd, offset= ); + ret =3D target_mmap__locked(start, len, target_prot, flags, + page_flags, fd, offset); =20 mmap_unlock(); + + /* + * If we're mapping shared memory, ensure we generate code for parallel + * execution and flush old translations. This will work up to the lev= el + * supported by the host -- anything that requires EXCP_ATOMIC will not + * be atomic with respect to an external process. + */ + if (ret !=3D -1 && (flags & MAP_TYPE) !=3D MAP_PRIVATE) { + CPUState *cpu =3D thread_cpu; + if (!(cpu->tcg_cflags & CF_PARALLEL)) { + cpu->tcg_cflags |=3D CF_PARALLEL; + tb_flush(cpu); + } + } + return ret; } =20 --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978084; cv=none; d=zohomail.com; s=zohoarc; b=HaEidoMiDNP/XIthXV0SqcSXFfVfnEwJxkmX/3uZ/YA/qNJiknt8D7YUayZSaHJrMelv6iv3EgYSIX1Rt1qDenxivpeA3YXZc2K+gbemmLUsMBeeg0bdTsIS5ZxBpzOAspQQWHC7fC5onXczALpAnlVSzPEV2cGdXD5LcHhyzAQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978084; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=OUMkUF2wTdm2RSOB14dulibL9lNc2Jn3zvjTpmBFyP+ZY/5cIydAwCAveUijDjoR+5AYe5PNYekTrDClOgXvn5tm29AHj3jNZ4Tln3CXUGO5qG+TXlDi57rV+GIoTa7R/Yi8ktLdLM49mNzsUUekJ+iE8+FDKq/SanWw4klLXKc= 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 170797808491587.11201126772733; Wed, 14 Feb 2024 22:21:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV76-0002Nc-Sc; Thu, 15 Feb 2024 01:20:52 -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 1raV74-0002Mt-76 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:50 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV72-0005W8-G4 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:49 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1d8aadc624dso4185245ad.0 for ; Wed, 14 Feb 2024 22:20:48 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978047; x=1708582847; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=pIQjbg2ctySqn2luCY29UoF3D7Eo0f3GZnKh47ONb5ajptfCAX7GADqWJcT+nFbldb 0crTD6fhIFkzDJZA9mwS8se2u1WpMVBtf+fTmjUyk9ymF1zXm3l+neUZvKH9J6BKVSqr OP0K0Js++tKj5zyDokjBgbfFmSDezIJjQ28n29guvxLTZn90ZOTkBABGM0K4qbGX9TF3 UMtwZjagFinRnYP9cl8YclzysmXN+DrusY+dpm8PV6LCUjdZMaL4rWG4rH1n7aXunYXy 6aSIU0i4R1VmCY7h/B2TNxjxHRM7LdjE4bLuzn6loHwvZVf6elMi/C3+1qohCpvdErLM fEzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978047; x=1708582847; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aJy5WaQ99ApNqzP+t8EteVWeLJYZZHFF49xziucGjOo=; b=bSZreLYcJM8gcaSfZPApJVS3Cd+2Wxjm6KUMmjkIRiPze5Rg14/F3jkflf3c1ii+sb UzLB7tIReJmKOZWeqxAmSn8vgcYQZmlWA/sHAeW8WPbDrmvWuXEUtuiKjQKoQBaZhjyE rfjWhdauJHUC168E0IYP3dAA9cfe9pHDOlwYWyRAekQpEVwesszI60JNC58vu0ISKHek tJA583lBZAizcauWlPDY4qQqa0+qinKa7uy234OdGLvRNoLkVog3O3u5BWZcLpsJRaEa 1UfNF7E6O/1EP+4b0lT0Yr8aonD7n7Ss06z5aBOBVpij67NZGMVItKrB5myx5WW73W4C gZ2w== X-Gm-Message-State: AOJu0YwH8fUNNmWFBaOV6Oqpt0umoQGFbET0kJerO6r9wpYTmN/0PMmI UQqm1MKFnNvKZifPWlSB9xel+OW5qEELdE5KZvSwdWuKOQ+7YvIwWm6P53q3FneYo6HAL6SRIt+ V X-Google-Smtp-Source: AGHT+IEvApMhR6A9DVyuj4fJEOTS0xAlLmNddoWGME5ULu9c3FFoZR9Jnq4EaWXJTaGB5ArQAaNZOA== X-Received: by 2002:a17:902:d2c9:b0:1da:2a2c:90da with SMTP id n9-20020a170902d2c900b001da2a2c90damr894717plc.12.1707978047312; Wed, 14 Feb 2024 22:20:47 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 18/36] linux-user: Fix sub-host-page mmap Date: Wed, 14 Feb 2024 20:20:00 -1000 Message-Id: <20240215062018.795056-19-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978085820100001 Content-Type: text/plain; charset="utf-8" We cannot skip over the_end1 to the_end, because we fail to record the validity of the guest page with the interval tree. Remove "the_end" and rename "the_end1" to "the_end". Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-19-richard.henderson@linaro.org> --- linux-user/mmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index fbaea832c5..48fcdd4a32 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -643,7 +643,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end1; + goto the_end; } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -690,7 +690,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, passthrough_last =3D real_last; } } - the_end1: + the_end: if (flags & MAP_ANONYMOUS) { page_flags |=3D PAGE_ANON; } @@ -708,7 +708,6 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, } } shm_region_rm_complete(start, last); - the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { FILE *f =3D qemu_log_trylock(); --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978358; cv=none; d=zohomail.com; s=zohoarc; b=hfBblfHvRDHf39zenzKRMNKIPxvkMNuisJrEVW/n6AIDKftqr8Uj74vzRUQlf8oBYXgngYGRSLqo1CJIMP59Yy2u5Gn6bkc7nhKQ5++qnTrTjsTz6k30YLnMuNzgPYs9WFr6Ijcitxs4zHyxsAza8N6kD8BZiM5HLb9UQniE1yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978358; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=Ljik1Sfe1iiUYExzhAYvEAwBRnA0JjkXIn6B2C5i5kgYpFvOA7Rfog69Rhi8a244NAzm1rylNDSmzngP5T136ogpl/UXoO/70OObQc54n4jPifGWghEs2ZrHySHszmIhOf006shJzwkZA1TBqXP4pbzPqXPkaVJoUYioIbiAat0= 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 1707978358035384.7256521999076; Wed, 14 Feb 2024 22:25:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV78-0002Oa-7p; Thu, 15 Feb 2024 01:20:54 -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 1raV75-0002NK-W5 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:52 -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 1raV74-0005WV-0o for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:51 -0500 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so472684a12.1 for ; Wed, 14 Feb 2024 22:20:49 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978049; x=1708582849; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=YLx2hBbNTAcc2lkKvVj7S/7psvZupK5l5Idvj8nUz1B6eK6uS3jg33zMykD9YxPIlS O7RWo69eldz6OBG0A+/8/U1Me9lOxVe7ehFNnK/I8tATvIkAVfjJKJVW0zBE4IvqWoE8 fFrz8objzloX6GHOQF13dK9UCh/kPiBGPCCKHdS360X9+9pAdaoRAl6H42NDCZsapk5y 6qjTIqD76VyjEnCkVdrn+RIk7YYUNV0VW60+grOgL3uVgUp08icXnIi/I9wFF5g4dGak aeheE6zLB0vWefsLY3EQHgIxOmFTlOD5/aS7mmMrkv/uz1R+GehIKVhQFsV+NUR59kSO dW7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978049; x=1708582849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t1OILcn76v2zPwlGFZzc7UG2ju3QgEVusg1rS5CPk58=; b=ZZaEFlPgDcscVFOpJ/46zdSxJHdmFj1+mR/S0YKkYGKVFhjAKlZz+uDYUPAqCDx4F6 9UfXQnoI6A3fIpf7a5V0NrAbyyaRms/WU2tOggsz9FJMvztiu+SEwIm/501oYctNBuJ4 TjIKaWTNwAAwoZNl0azxhQNAQDTZo1C2LvRm4473l9w7aFJfL87MHaHvBHD7YYxn/EvM DHcRFR7GGMC9/fLFODKTSd/Cv8ZAjWfBz0sZAAZYwuXBafS4qCoF5oIoFthpiF2lUHt4 Mr8JRo3CM+zdx3p8KGN8FTIE+oznlDu59K4IZeuSnjxhzwq2yoQtokkF2vS8x5dfsOaw H3DA== X-Gm-Message-State: AOJu0YyifhHRhWgmNRT1UYwjbx2c3of8WQOJFb17n7HVYqQMqZ68+nI9 G0+AK0eWT0m66eBHDazhlv4WCvqeI0VXoiFDRSoeaa0UOwyQgrgeh8Ij1ltLgvlLb4uGmVKvZ9n c X-Google-Smtp-Source: AGHT+IGhxIMzeR1o5Qi3VF56p8ZnWYRSxcy6xFjU+t23KSi2u1iWJdkwHoZ0iIiOzGCGEJlHGgRkgQ== X-Received: by 2002:a17:90a:d301:b0:296:2afe:25e with SMTP id p1-20020a17090ad30100b002962afe025emr892906pju.32.1707978048754; Wed, 14 Feb 2024 22:20:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 19/36] linux-user: Split out mmap_end Date: Wed, 14 Feb 2024 20:20:01 -1000 Message-Id: <20240215062018.795056-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::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: 1707978358571100001 Use a subroutine instead of a goto within target_mmap__locked. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-20-richard.henderson@linaro.org> --- linux-user/mmap.c | 71 +++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 48fcdd4a32..cc983bedbd 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -490,6 +490,43 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong siz= e, abi_ulong align) } } =20 +/* + * Record a successful mmap within the user-exec interval tree. + */ +static abi_long mmap_end(abi_ulong start, abi_ulong last, + abi_ulong passthrough_start, + abi_ulong passthrough_last, + int flags, int page_flags) +{ + if (flags & MAP_ANONYMOUS) { + page_flags |=3D PAGE_ANON; + } + page_flags |=3D PAGE_RESET; + if (passthrough_start > passthrough_last) { + page_set_flags(start, last, page_flags); + } else { + if (start < passthrough_start) { + page_set_flags(start, passthrough_start - 1, page_flags); + } + page_set_flags(passthrough_start, passthrough_last, + page_flags | PAGE_PASSTHROUGH); + if (passthrough_last < last) { + page_set_flags(passthrough_last + 1, last, page_flags); + } + } + shm_region_rm_complete(start, last); + trace_target_mmap_complete(start); + if (qemu_loglevel_mask(CPU_LOG_PAGE)) { + FILE *f =3D qemu_log_trylock(); + if (f) { + fprintf(f, "page layout changed following mmap\n"); + page_dump(f); + qemu_log_unlock(f); + } + } + return start; +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) @@ -632,7 +669,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, ret =3D target_mprotect(start, len, target_prot); assert(ret =3D=3D 0); } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } =20 /* handle the start of the mapping */ @@ -643,7 +680,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, target_prot, flags, fd, offset)) { return -1; } - goto the_end; + return mmap_end(start, last, -1, 0, flags, page_flags); } if (!mmap_frag(real_start, start, real_start + host_page_size - 1, @@ -690,34 +727,8 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, passthrough_last =3D real_last; } } - the_end: - if (flags & MAP_ANONYMOUS) { - page_flags |=3D PAGE_ANON; - } - page_flags |=3D PAGE_RESET; - if (passthrough_start > passthrough_last) { - page_set_flags(start, last, page_flags); - } else { - if (start < passthrough_start) { - page_set_flags(start, passthrough_start - 1, page_flags); - } - page_set_flags(passthrough_start, passthrough_last, - page_flags | PAGE_PASSTHROUGH); - if (passthrough_last < last) { - page_set_flags(passthrough_last + 1, last, page_flags); - } - } - shm_region_rm_complete(start, last); - trace_target_mmap_complete(start); - if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - FILE *f =3D qemu_log_trylock(); - if (f) { - fprintf(f, "page layout changed following mmap\n"); - page_dump(f); - qemu_log_unlock(f); - } - } - return start; + return mmap_end(start, last, passthrough_start, passthrough_last, + flags, page_flags); } =20 /* NOTE: all the constants are the HOST ones */ --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978090; cv=none; d=zohomail.com; s=zohoarc; b=DL99tgBhKlRw0gwpsIRsXh5SrVhOt7QmoESaMtOZgb77hVg5h/xBP0+WcK0+LsZy+gGRGRPFO6Ctl+HvvtPts2/QwGZFrilAVAQnxXFOtlILG6vmvtoO+M5ogex6/GUt1/EY7cAYcn2Rx6xd7/Ed6Td9O+xkgVlawTll+o4wNuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978090; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=bUGhv0zA+UUF4LZZ621SMV/Zxe8Dnku2bVUJRK7NTZU3oXxXknIDulUe3I77q8/zL0o0KnzQ6ltLYP9phmKVxTR4J8H5aVKlmKqzB2LHuMfhD46DbtkMq8hzHqVEr0SQLhJaqUpEQzkbTJ/TzxL4eEoAgBPnFrTmZlppf9cMuHI= 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 1707978090410275.8206858392791; Wed, 14 Feb 2024 22:21:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV79-0002Pj-VC; Thu, 15 Feb 2024 01:20:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV77-0002No-CH for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:53 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV75-0005X5-MD for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:53 -0500 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5d8b519e438so479237a12.1 for ; Wed, 14 Feb 2024 22:20:51 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978050; x=1708582850; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=t03gNKuXKadnS+julro7m84XhQpYQKueLooIhn09u8b9wHv2uWVtGqzQFpWVgREywF pNyWAeZAv76g7Zua+Iw+GPWdz1Bfw28htCubvzLGxk4L4qMesezHaWOHE1UQax3vdRS/ ntiTUJutmlzWagt2DVHYuJZ2o827pQUCxOho4p9o6pZcV1bfpMUN0w0FhJ+PoBkXy2fw H8DNfmHQUnRJjtgNBpavJT02DHmbvwACJX/X+kvfavjgX+o39TcY8iNnWy5XjuOsIYnq AL72/l2C1h5u7uW0MfOKm8R1F/OeRU0lk3/qKDUoZJ2VdFtvBIC0vXMOmzUqbpdHHZDv trtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978050; x=1708582850; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZykOOhGWRLaDSZ6ojBtzy1ZtPjktUdeyK8bHHdP5Cx0=; b=WL+S5rlLRRnndFl4pjmXC3liKprjTfannbDg8GSkDP8w2gm8pN45UFDXi9SnBg6ZgL cF2EM2ETX/29eA4HK+r6BwS2ypLDAhER3gH08vnFR8nIiZiBEgUFcaJVzgI+Fhaq7PRH YQ5upW/R1xnEtT7buF5qmIyr3OZB3K6de35+uU4afqWkbtNvS+VknTB+KVsQMaTJKlxW Wnww5WQQHb/0/sBq8shXTb6v1rmMZBa2xM/pppigsmri/iqq3vpfa9oHaeejgQnKt9u2 /KR40kh9zyCS5EslRcFdC0oj/yg75OshpHSmbUZ50/uX40Dv8DIa7JXHf7RbtroNPnl2 llhg== X-Gm-Message-State: AOJu0YwB5Dwn6a2bcgYctNjMgc5TOf/o/JfMvVdQ8fwjR0TIBfTFGksF wgKpR2vEg0pRXVsDQ86WsBl7m48O+/38lRDNqiH+QO4jUMHiXcg6aeA9XiwriO4bKFFxr9xNf0H Y X-Google-Smtp-Source: AGHT+IGrYJV5jp1+2Ki1lBXgTtC84cxUTZmb6qr7mH7kxEnioyyFQwFQ8oiw3I8A8hjp7Qb40/RcMQ== X-Received: by 2002:a17:90a:8c13:b0:298:b523:1c7f with SMTP id a19-20020a17090a8c1300b00298b5231c7fmr797175pjo.40.1707978050262; Wed, 14 Feb 2024 22:20:50 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 20/36] linux-user: Do early mmap placement only for reserved_va Date: Wed, 14 Feb 2024 20:20:02 -1000 Message-Id: <20240215062018.795056-21-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::534; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x534.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: 1707978091567100001 Content-Type: text/plain; charset="utf-8" For reserved_va, place all non-fixed maps then proceed as for MAP_FIXED. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-21-richard.henderson@linaro.org> --- linux-user/mmap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index cc983bedbd..1bbfeb25b1 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -540,17 +540,19 @@ static abi_long target_mmap__locked(abi_ulong start, = abi_ulong len, host_offset =3D offset & -host_page_size; =20 /* - * If the user is asking for the kernel to find a location, do that - * before we truncate the length for mapping files below. + * For reserved_va, we are in full control of the allocation. + * Find a suitable hole and convert to MAP_FIXED. */ - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { host_len =3D len + offset - host_offset; - host_len =3D ROUND_UP(host_len, host_page_size); - start =3D mmap_find_vma(real_start, host_len, TARGET_PAGE_SIZE); + start =3D mmap_find_vma(real_start, host_len, + MAX(host_page_size, TARGET_PAGE_SIZE)); if (start =3D=3D (abi_ulong)-1) { errno =3D ENOMEM; return -1; } + start +=3D offset - host_offset; + flags |=3D MAP_FIXED; } =20 /* --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978101; cv=none; d=zohomail.com; s=zohoarc; b=IRwBeH/dGULdw8EBS/9Ayb2Yy9UfIQjhxDIaf8DdyTl5zvicTBvSTJH/4e5gmnQ09NDZklj73E207yVf/e0sm0jWeULsNWdkvM0C0maU0A0ohrhvCyitTsVJu49ohDHt4Z4snmln+BrSFMZlskBuKj5sIHsCPIkkJDHY5IaJh0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978101; 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=TGuf+a6g23AtWTGblDkFBLls1ueawrHAWFF+h5sCkhk=; b=JysqtH3qA6JTfjLjFP2cKdxEG2FfV6XITlPR2wWSLVpoAHKV4s96Mlnn6T2Djf+cf7hC/ArfovCzbnN6gU1h3W7IeEv490TM5zTFmte59WbJm6ahroby1mggjycpQ7lUSI61+u9FbYCvPc0u0J66kw302ecSmndylsWpQBlFiJM= 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 1707978101934793.7248128133295; Wed, 14 Feb 2024 22:21:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV79-0002Pc-Oo; Thu, 15 Feb 2024 01:20:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV78-0002On-Bl for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:54 -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 1raV76-0005XP-OC for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:54 -0500 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-5dca1efad59so492088a12.2 for ; Wed, 14 Feb 2024 22:20:52 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978051; x=1708582851; 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=TGuf+a6g23AtWTGblDkFBLls1ueawrHAWFF+h5sCkhk=; b=tpR5nYOgElZM/Euo9/P6G6KR0BvQfyMiAElmNckxbSguAykYGJymFrjl9OazvABNlG 8OR1HqatIENtX4BsRoEq4Woa8fM4o0M/SCY1lPT+8zJibjn1Ks0zcx9gsFgHV7hKNjDs Qyw7M4ieltW5HVdeMPsBhW8gMpxhZ23aZf2wJziVbrWaYp/iSPvAi9rNRo/lzo2YIiZs J+0ccheS5+I0S8QiqZidxmLKMz8fWKxXx0LVFtQ+Qd64OycVOtpStlVNgxj+SDwNGGN8 Sfpy0rpPkTJQzRwZifTC+NDJZ9PTf/7UVkMSlWHNaG4O/ZCXPUG4nFvRCJJkPoImKsPN 1AoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978051; x=1708582851; 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=TGuf+a6g23AtWTGblDkFBLls1ueawrHAWFF+h5sCkhk=; b=pfkpvqlNNOZiOpCduHq9p9K56QeidXrkdtqqxi6brX0tpxkT8PpBwWJpyUBHZl3hZf fLmdROyY4WLkkHOgu0pn6wHe2s/VoIYv/3Wx3YK2wRwV0F+SfC4UONmLZPHUZgq1Xv95 1RdfWR+YghXJ3UCrJgFoH1BcAWDoGd8evHODwwvK/JdtVWfHPgKS7XO+Ef8EQKm17R8b 7cXy3i22dFhkTziBxfFVrWcjnpaemR3kCsB1MMkH5en1kEK1uamO0jmmS/QkxkIrZWuh h0dDF23Lu2TG8T0p8zG+N5ViRtvyZW0DNFaCC5wncTWpw8SIFmzraIjBbm9lV1pNvMSD 2KQw== X-Gm-Message-State: AOJu0Yw4mCclFaxx/OjnkMYaSO8zhRdSWc/nQiAFIdOanXclsFHhmpfL 0cASvxfFoXDHdqSulAQEmJQxNywi2CpKg1MuAvhnknkigPm44eHsTHqc+04eJW6fN4/1b27IBMp T X-Google-Smtp-Source: AGHT+IEJ1KApzmH9jMaxUJrkPwokrrmDKkKrOYjRiaBxJP8IQyz+nNqTXu7iObSSeUbGRWFwtqiEvQ== X-Received: by 2002:a05:6a21:3416:b0:1a0:5841:6740 with SMTP id yn22-20020a056a21341600b001a058416740mr1061256pzb.14.1707978051409; Wed, 14 Feb 2024 22:20:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 21/36] linux-user: Split out do_munmap Date: Wed, 14 Feb 2024 20:20:03 -1000 Message-Id: <20240215062018.795056-22-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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: 1707978103655100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/mmap.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 1bbfeb25b1..8ebcca4444 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -267,6 +267,21 @@ int target_mprotect(abi_ulong start, abi_ulong len, in= t target_prot) return ret; } =20 +/* + * Perform munmap on behalf of the target, with host parameters. + * If reserved_va, we must replace the memory reservation. + */ +static int do_munmap(void *addr, size_t len) +{ + if (reserved_va) { + void *ptr =3D mmap(addr, len, PROT_NONE, + MAP_FIXED | MAP_ANONYMOUS + | MAP_PRIVATE | MAP_NORESERVE, -1, 0); + return ptr =3D=3D addr ? 0 : -1; + } + return munmap(addr, len); +} + /* map an incomplete host page */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong las= t, int prot, int flags, int fd, off_t offset) @@ -854,13 +869,7 @@ static int mmap_reserve_or_unmap(abi_ulong start, abi_= ulong len) real_len =3D real_last - real_start + 1; host_start =3D g2h_untagged(real_start); =20 - if (reserved_va) { - void *ptr =3D mmap(host_start, real_len, PROT_NONE, - MAP_FIXED | MAP_ANONYMOUS - | MAP_PRIVATE | MAP_NORESERVE, -1, 0); - return ptr =3D=3D host_start ? 0 : -1; - } - return munmap(host_start, real_len); + return do_munmap(host_start, real_len); } =20 int target_munmap(abi_ulong start, abi_ulong len) --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978365; cv=none; d=zohomail.com; s=zohoarc; b=Ia+IvmkoGtAZD6XCVR6mpeON2bA/BCwKLTyPOj4F/dHIbEzWKuoPNWCar1P3q+Lc8xF4G/j0xURxBhN3E5oWNXH3lo395Q8ZY1OsUTnq7QcpOYfidXWBFYBt/Lb0M8Sdrv+53RiX5V2aUC4e05c5XfSBMoW+3YoB1P9GMcQx6HU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978365; 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=mDHtjMX+mEQb+/p7zJ9SmZdTAU/DfY9CF76Jhj+l68I=; b=UwOm/Y3YXbuMH4Y6yTBVIAFAso18HwIqbVVwuZ4xneshOyQeMBbp1L6CBPXP6U61v+nU8o6oyzTYWyyYJy3+PFlhUKqOd50zyU+OPrh+ct+Ab4B9uFEtUcBfMYVkAVW8k8TA3owwVip0bO7lRQicBvW1nbPRGbuRtOSjvmE3QDA= 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 17079783654511020.2105057505657; Wed, 14 Feb 2024 22:26:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7A-0002Pt-Bm; Thu, 15 Feb 2024 01:20:56 -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 1raV79-0002PS-6B for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:55 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV77-0005Xl-Nf for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:54 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d7881b1843so4656725ad.3 for ; Wed, 14 Feb 2024 22:20:53 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978052; x=1708582852; 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=mDHtjMX+mEQb+/p7zJ9SmZdTAU/DfY9CF76Jhj+l68I=; b=u3ei+nhA06wfOBKGdy1US7qnEUWsIj27qpj41UgMieXqcybrSn0krIXS1S0nBRA5et t/iYFG6SOibMqOzH6RWwMzeA/Wf0UiZXciaDzE+MYSyKOnOer4OV7wYX9MBV03q6/jo2 3iZXZQp0aYjEjSd5EOlGSGDq74VAST3RRM3uifA/vJffWJYYJjSOpvUpAlJyf34hrLsT zHdJpLmnB9+U6uKbleh4zgHo6kPdpzu1aXmxLnIHxU/IVP+eN85EnxgVsyAnWmf7WXHE +r53WJ1kvwNTVmO3U1zoGdUEb112ZedOpO2HagG7rD3Lfl8cpZM0Z8hwMcob3Ky4rqdO +jAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978052; x=1708582852; 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=mDHtjMX+mEQb+/p7zJ9SmZdTAU/DfY9CF76Jhj+l68I=; b=JVyINRQWecGTMjFZqj00ipWTyWCjPIjIU5YkSkj4DFzHxGB1cerZ3V1bDIKyB6c3Au UoJYghNEFc6ptewYgEA2cY0Xey6fO4USCcUGNv32moCQ/srVvXYh7JxDYbzzrGtMpp1O Ka9Lh8ycqxeRh2T4NLnUIH3dBGkUdPQr6Hq3Akv8ILyQsG7IQmc/hWeQALTyfu/xKrWZ HIgxwsnLRbeycmNd6hEZvglN2EyCcbCDeJeFE1hSnq1IrTojwqMBzyvy5kicgoHg1ju1 DUCI/d5QC0iTAZ+CpQdJl+0u111cwqL6T6jDNDCiF9NLu/Ou32F7s2qIid4XaGl0NsTr ozGg== X-Gm-Message-State: AOJu0Yz7pJjB82QweHFjKtdz0YtNlwL4QXJCo9LGZWz3F1fTAsE+//QA SicUbRpc9xdKCwjKmTxX4G4zAxQUcEazKOgEa9afJeWzec3lEZ8jKpp8utOycLKmkwuTnMFC9L+ A X-Google-Smtp-Source: AGHT+IEC1NtfJs2QyHSIdtijE2ZK6m4Zy1z2WpvF0QgCIKRbM1j3zN81cBK20pKK6N9FYJmOflccXw== X-Received: by 2002:a17:902:f68e:b0:1d8:aada:a7f5 with SMTP id l14-20020a170902f68e00b001d8aadaa7f5mr850946plg.11.1707978052467; Wed, 14 Feb 2024 22:20:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 22/36] linux-user: Use do_munmap for target_mmap failure Date: Wed, 14 Feb 2024 20:20:04 -1000 Message-Id: <20240215062018.795056-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978366583100002 Content-Type: text/plain; charset="utf-8" For the cases for which the host mmap succeeds, but does not yield the desired address, use do_munmap to restore the reserved_va memory reservation. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/mmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 8ebcca4444..cbcd31e941 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -326,7 +326,7 @@ static bool mmap_frag(abi_ulong real_start, abi_ulong s= tart, abi_ulong last, flags | MAP_ANONYMOUS, -1, 0); if (p !=3D host_start) { if (p !=3D MAP_FAILED) { - munmap(p, host_page_size); + do_munmap(p, host_page_size); errno =3D EEXIST; } return false; @@ -622,7 +622,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, p =3D mmap(g2h_untagged(start), len, host_prot, flags | MAP_FIXED, fd, host_offset); if (p =3D=3D MAP_FAILED) { - munmap(g2h_untagged(start), host_len); + do_munmap(g2h_untagged(start), host_len); return -1; } host_start +=3D offset - host_offset; @@ -735,7 +735,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, flags, fd, offset1); if (p !=3D want_p) { if (p !=3D MAP_FAILED) { - munmap(p, len1); + do_munmap(p, len1); errno =3D EEXIST; } return -1; --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978280; cv=none; d=zohomail.com; s=zohoarc; b=jIlxKxc/x20GfhQj87XMA1jWHpqcDvaxAR5UJWeIy7NjlkHCA6aznziG4iu/QOpdsUI3otzlmi/q0QHu+DmUir/twXI3NCXJT14ZvZiv2Hw6c9TBHW8/whuS69xEmuHDweDKlfy4rU5VMaZZJ2slg+030uH6rqxBIPpjMGWZvZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978280; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=cOqtXrlVkbVwZ0rRWNTytWs6h4XwT7Zm5VCEIXU7D+WsoGrwvyrjGJTIeEHJ2PhmqeMcZ6FCzZhGyd00UOq9aAcxknDa+PZCqd03JVTXjzVaNbQjPLlwBZyA+deKVN9lnjysatFOHuFY6z91RagzK1TVRwuMPGWZNc6qDyvddUo= 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 1707978280018330.9353949935427; Wed, 14 Feb 2024 22:24:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7D-0002Qy-2V; Thu, 15 Feb 2024 01:20:59 -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 1raV7B-0002Q3-21 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:57 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV79-0005YH-Cd for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:56 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1d8ef977f1eso4471285ad.0 for ; Wed, 14 Feb 2024 22:20:54 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978054; x=1708582854; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=I1gJsuOM7IPHx7yaCrH9hBzyJsXrjcnTa1LQ952KwH31emA65soTeAAjjS0sxMjhco ER4P9OOLh2VWboDUJKZ8xlQi7/K3/P3Zhk29MoEF6yq1r7doNQcUPuGRtmq9lY2UJPUe P4MlAhaoGhnSGYZrW4VqpQh+HOe/ioOzgSe9CBcxagRWKrsJAMGSq3FdQ8CkVg+e9lL3 X/lL5GYtXbq27Nycc3cjo2qyv2D4CiqMdB06CAmj2K2Z7edbE/GB5NWW7m9aoessFEj8 s7mY1Dr0+oeDytn+MFQVMaW1zX3kmp5TIZ+UjmXlNTAuZNx99x0IAFJecqjBBnCrF9Of A88A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978054; x=1708582854; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F+mIi8OQkXxgV79040kdu3+FCdCNzpLRNnazUCypFlE=; b=oiuQaki6IYr7oTRV83IjMpuk34g/M+QmXIfBamFx/swj4N2VnQufzuwE4PdnMWkRfJ bEy2Hj3SFESF0+qyMLt3UJ6wFb4uIL3oU96iSeRqywI15vlgXo2LVmbmDQFeDpjRS1k9 T5sNHaeWrhrRjlwxo0ktFW0zXQfUvIhAiLfDUDJ2kcEvvPbEilMtgQDTc3QbqFt243Rm a7yNjKHKgldE9UnDTmJtgFBVlulPDF8E4xs8EygyBFMbvv1yAJ1k8FmieiRa4Eb7mysU u9IZt6eZRpCauJCNf87HaJNI1zcLX2GbULevEoOAJS3RZbR6G9IaQSeCIkdC80qR7XVo 2XUw== X-Gm-Message-State: AOJu0YztmzDBpPeqYepqtX2T3FFACKZc1QbOwrFyLv2dcvO1d9qeOLAz HuN1S+ivXJP3avH3h6OFDu4na9lJJr6OcNKwhCMyIRyHKeChJnJdMOWraSdMLHwrpUqmDaXTIJS q X-Google-Smtp-Source: AGHT+IF8F8kiXlNCxrvo4hYED2z1dgy1Z+uar68XA1fvECKDg1dyPrqFW5NJYDHoljybWtd2pXvEGw== X-Received: by 2002:a17:902:d584:b0:1db:8a13:81c0 with SMTP id k4-20020a170902d58400b001db8a1381c0mr648959plh.49.1707978054034; Wed, 14 Feb 2024 22:20:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 23/36] linux-user: Split out mmap_h_eq_g Date: Wed, 14 Feb 2024 20:20:05 -1000 Message-Id: <20240215062018.795056-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978280256100006 Content-Type: text/plain; charset="utf-8" Move the MAX_FIXED_NOREPLACE check for reserved_va earlier. Move the computation of host_prot earlier. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-22-richard.henderson@linaro.org> --- linux-user/mmap.c | 68 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index cbcd31e941..d3556bcc14 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -542,6 +542,33 @@ static abi_long mmap_end(abi_ulong start, abi_ulong la= st, return start; } =20 +/* + * Special case host page size =3D=3D target page size, + * where there are no edge conditions. + */ +static abi_long mmap_h_eq_g(abi_ulong start, abi_ulong len, + int host_prot, int flags, int page_flags, + int fd, off_t offset) +{ + void *p, *want_p =3D g2h_untagged(start); + abi_ulong last; + + p =3D mmap(want_p, len, host_prot, flags, fd, offset); + if (p =3D=3D MAP_FAILED) { + return -1; + } + /* If the host kernel does not support MAP_FIXED_NOREPLACE, emulate. */ + if ((flags & MAP_FIXED_NOREPLACE) && p !=3D want_p) { + do_munmap(p, len); + errno =3D EEXIST; + return -1; + } + + start =3D h2g(p); + last =3D start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) @@ -550,6 +577,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, abi_ulong ret, last, real_start, real_last, retaddr, host_len; abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; off_t host_offset; + int host_prot; =20 real_start =3D start & -host_page_size; host_offset =3D offset & -host_page_size; @@ -558,16 +586,33 @@ static abi_long target_mmap__locked(abi_ulong start, = abi_ulong len, * For reserved_va, we are in full control of the allocation. * Find a suitable hole and convert to MAP_FIXED. */ - if (reserved_va && !(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - host_len =3D len + offset - host_offset; - start =3D mmap_find_vma(real_start, host_len, - MAX(host_page_size, TARGET_PAGE_SIZE)); - if (start =3D=3D (abi_ulong)-1) { - errno =3D ENOMEM; - return -1; + if (reserved_va) { + if (flags & MAP_FIXED_NOREPLACE) { + /* Validate that the chosen range is empty. */ + if (!page_check_range_empty(start, start + len - 1)) { + errno =3D EEXIST; + return -1; + } + flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; + } else if (!(flags & MAP_FIXED)) { + size_t real_len =3D len + offset - host_offset; + abi_ulong align =3D MAX(host_page_size, TARGET_PAGE_SIZE); + + start =3D mmap_find_vma(real_start, real_len, align); + if (start =3D=3D (abi_ulong)-1) { + errno =3D ENOMEM; + return -1; + } + start +=3D offset - host_offset; + flags |=3D MAP_FIXED; } - start +=3D offset - host_offset; - flags |=3D MAP_FIXED; + } + + host_prot =3D target_to_host_prot(target_prot); + + if (host_page_size =3D=3D TARGET_PAGE_SIZE) { + return mmap_h_eq_g(start, len, host_prot, flags, + page_flags, fd, offset); } =20 /* @@ -603,12 +648,10 @@ static abi_long target_mmap__locked(abi_ulong start, = abi_ulong len, =20 if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { uintptr_t host_start; - int host_prot; void *p; =20 host_len =3D len + offset - host_offset; host_len =3D ROUND_UP(host_len, host_page_size); - host_prot =3D target_to_host_prot(target_prot); =20 /* Note: we prefer to control the mapping address. */ p =3D mmap(g2h_untagged(start), host_len, host_prot, @@ -731,8 +774,7 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, len1 =3D real_last - real_start + 1; want_p =3D g2h_untagged(real_start); =20 - p =3D mmap(want_p, len1, target_to_host_prot(target_prot), - flags, fd, offset1); + p =3D mmap(want_p, len1, host_prot, flags, fd, offset1); if (p !=3D want_p) { if (p !=3D MAP_FAILED) { do_munmap(p, len1); --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978325; cv=none; d=zohomail.com; s=zohoarc; b=hBzsmMakEUuXEyPNoNt0CTQckYA6YwLO4TvxjXWHad1m1ILk3DDRsw7cC2AvyNJ/AX95qPf4ZGyvNj2BhoBnCLGwnOFC+cQH7KLNq1TLkI39KbiykIHtbk8GCTgYCjvQDtHFBMH6rSo7eb8KdyktwgMOv8LR24Uf61QT6PNn4Fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978325; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=TwmL9GicSG7P9TwEh3d4ZuLmr3TeffPFZWFxwaupQltnuAg3SUZS/aaVp+Qs4EQQ42nvjYBgF4E/gCC5Cg8L5J5XxpoSiI9vBJkUDEa4iLeINBKwZ4akdmMJQ4eyldsnfDhwrCOxnh0Y/feB5NmJDvmzPLhl2Vi1D1rhsPR34vE= 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 1707978325860791.6926912346419; Wed, 14 Feb 2024 22:25:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7E-0002RT-Lg; Thu, 15 Feb 2024 01:21: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 1raV7C-0002Qs-Vv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:59 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7A-0005Yh-Vz for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:20:58 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e104196e6eso589664b3a.0 for ; Wed, 14 Feb 2024 22:20:56 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978055; x=1708582855; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=spbn2g2ridnxUXGHIRkCCg7x6ZhigMrvldB7oasOxrOpEJrXYQ/lIlKH5TmY1K5Qjt 31DLqunvlyd/ozWczQ+0FEb/lv0+5JkQU4Iyp1HXYrY0fzk07vSKVULkCuI/VQX4rhGI OFLgri7ou0nIHjrMhPLUuCoMGJRrYCAsT4+/zeGevd4NW0EQkYA+8J+GsaEVWsdNzQkg CbUSm9ov38kAaxNCr/5Jb8FaIndMk6Cpj7opEk8x9jP1I/k8+0v0RjaytnS8OhsmPcPm lwEAtFe8woLlgo6fv6vcbNb/BN9lzj7wkpTLQiAJjPf93VemO4OcJcu4dGbdnXuWVUMT G52A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978055; x=1708582855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I4UwZkIS26PhKHP+iY1jWw6KRSEUK2Dc0FNGbwDM3y4=; b=D+1Eiz0x48QseJxpXTahsKO9c4MCvzX6AbPO23R/PizXd7o8ajo/WpZSc3Y9r/37AY Yb8P3woNKMJsgS0kIXBra4tMoy+cfEH2wy1Vp0AEIPiwwUxUl1qHo0IYP6LztpHtgkHG Jh04Yx2LxrrioOAIW33Hg/cK9vBXW3V0fz7qkCTNZ0q63E4FFb7opA6DQgNJRZZ7noeq Pj55xTHR/w9Gb9vxQED1UNHJVSJY49ql+63/Bk0snqwtTXoeXR0zalPyRF+6LWPWpYet ESQ6zTgVE69DWqyKgxxxb13jfxGH9et8Ee3zv/NpKMSLLDf+TV0Y/C3i7cKfLqoHH2i7 Q6Iw== X-Gm-Message-State: AOJu0YwtlzpqZCVhHRDncZe1OFpWWwm1h/q/QWij1kMX4UdjeseO2t7f ZNs+O299kFj5D2mOhdTnbVI9ItQh6V0HK+mSdJy/KBQ4zar9a3sCEe30VS18oXHnyL7maca8CUL T X-Google-Smtp-Source: AGHT+IF9y7MdLtPv6XnHCM2ojJ/hQdcq/Iw96Qs3kqcypkO6lvg9NqhWoFqD4dmfDFT0ECt2IPZtKw== X-Received: by 2002:a05:6a21:3a41:b0:19e:cf1a:5372 with SMTP id zu1-20020a056a213a4100b0019ecf1a5372mr1415150pzb.34.1707978055622; Wed, 14 Feb 2024 22:20:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 24/36] linux-user: Split out mmap_h_lt_g Date: Wed, 14 Feb 2024 20:20:06 -1000 Message-Id: <20240215062018.795056-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978326408100001 Content-Type: text/plain; charset="utf-8" Work much harder to get alignment and mapping beyond the end of the file correct. Both of which are excercised by our test-mmap for alpha (8k pages) on any 4k page host. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-23-richard.henderson@linaro.org> --- linux-user/mmap.c | 184 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 153 insertions(+), 31 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d3556bcc14..ff8f9f7ed0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -569,6 +569,156 @@ static abi_long mmap_h_eq_g(abi_ulong start, abi_ulon= g len, return mmap_end(start, last, start, last, flags, page_flags); } =20 +/* + * Special case host page size < target page size. + * + * The two special cases are increased guest alignment, and mapping + * past the end of a file. + * + * When mapping files into a memory area larger than the file, + * accesses to pages beyond the file size will cause a SIGBUS. + * + * For example, if mmaping a file of 100 bytes on a host with 4K + * pages emulating a target with 8K pages, the target expects to + * be able to access the first 8K. But the host will trap us on + * any access beyond 4K. + * + * When emulating a target with a larger page-size than the hosts, + * we may need to truncate file maps at EOF and add extra anonymous + * pages up to the targets page boundary. + * + * This workaround only works for files that do not change. + * If the file is later extended (e.g. ftruncate), the SIGBUS + * vanishes and the proper behaviour is that changes within the + * anon page should be reflected in the file. + * + * However, this case is rather common with executable images, + * so the workaround is important for even trivial tests, whereas + * the mmap of of a file being extended is less common. + */ +static abi_long mmap_h_lt_g(abi_ulong start, abi_ulong len, int host_prot, + int mmap_flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p =3D g2h_untagged(start); + off_t fileend_adj =3D 0; + int flags =3D mmap_flags; + abi_ulong last, pass_last; + + if (!(flags & MAP_ANONYMOUS)) { + struct stat sb; + + if (fstat(fd, &sb) =3D=3D -1) { + return -1; + } + if (offset >=3D sb.st_size) { + /* + * The entire map is beyond the end of the file. + * Transform it to an anonymous mapping. + */ + flags |=3D MAP_ANONYMOUS; + fd =3D -1; + offset =3D 0; + } else if (offset + len > sb.st_size) { + /* + * A portion of the map is beyond the end of the file. + * Truncate the file portion of the allocation. + */ + fileend_adj =3D offset + len - sb.st_size; + } + } + + if (flags & (MAP_FIXED | MAP_FIXED_NOREPLACE)) { + if (fileend_adj) { + p =3D mmap(want_p, len, host_prot, flags | MAP_ANONYMOUS, -1, = 0); + } else { + p =3D mmap(want_p, len, host_prot, flags, fd, offset); + } + if (p !=3D want_p) { + if (p !=3D MAP_FAILED) { + /* Host does not support MAP_FIXED_NOREPLACE: emulate. */ + do_munmap(p, len); + errno =3D EEXIST; + } + return -1; + } + + if (fileend_adj) { + void *t =3D mmap(p, len - fileend_adj, host_prot, + (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED, + fd, offset); + + if (t =3D=3D MAP_FAILED) { + int save_errno =3D errno; + + /* + * We failed a map over the top of the successful anonymous + * mapping above. The only failure mode is running out of = VMAs, + * and there's nothing that we can do to detect that earli= er. + * If we have replaced an existing mapping with MAP_FIXED, + * then we cannot properly recover. It's a coin toss whet= her + * it would be better to exit or continue here. + */ + if (!(flags & MAP_FIXED_NOREPLACE) && + !page_check_range_empty(start, start + len - 1)) { + qemu_log("QEMU target_mmap late failure: %s", + strerror(save_errno)); + } + + do_munmap(want_p, len); + errno =3D save_errno; + return -1; + } + } + } else { + size_t host_len, part_len; + + /* + * Take care to align the host memory. Perform a larger anonymous + * allocation and extract the aligned portion. Remap the file on + * top of that. + */ + host_len =3D len + TARGET_PAGE_SIZE - host_page_size; + p =3D mmap(want_p, host_len, host_prot, flags | MAP_ANONYMOUS, -1,= 0); + if (p =3D=3D MAP_FAILED) { + return -1; + } + + part_len =3D (uintptr_t)p & (TARGET_PAGE_SIZE - 1); + if (part_len) { + part_len =3D TARGET_PAGE_SIZE - part_len; + do_munmap(p, part_len); + p +=3D part_len; + host_len -=3D part_len; + } + if (len < host_len) { + do_munmap(p + len, host_len - len); + } + + if (!(flags & MAP_ANONYMOUS)) { + void *t =3D mmap(p, len - fileend_adj, host_prot, + flags | MAP_FIXED, fd, offset); + + if (t =3D=3D MAP_FAILED) { + int save_errno =3D errno; + do_munmap(p, len); + errno =3D save_errno; + return -1; + } + } + + start =3D h2g(p); + } + + last =3D start + len - 1; + if (fileend_adj) { + pass_last =3D ROUND_UP(last - fileend_adj, host_page_size) - 1; + } else { + pass_last =3D last; + } + return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) @@ -613,37 +763,9 @@ static abi_long target_mmap__locked(abi_ulong start, a= bi_ulong len, if (host_page_size =3D=3D TARGET_PAGE_SIZE) { return mmap_h_eq_g(start, len, host_prot, flags, page_flags, fd, offset); - } - - /* - * When mapping files into a memory area larger than the file, accesses - * to pages beyond the file size will cause a SIGBUS. - * - * For example, if mmaping a file of 100 bytes on a host with 4K pages - * emulating a target with 8K pages, the target expects to be able to - * access the first 8K. But the host will trap us on any access beyond - * 4K. - * - * When emulating a target with a larger page-size than the hosts, we - * may need to truncate file maps at EOF and add extra anonymous pages - * up to the targets page boundary. - */ - if (host_page_size < TARGET_PAGE_SIZE && !(flags & MAP_ANONYMOUS)) { - struct stat sb; - - if (fstat(fd, &sb) =3D=3D -1) { - return -1; - } - - /* Are we trying to create a map beyond EOF?. */ - if (offset + len > sb.st_size) { - /* - * If so, truncate the file map at eof aligned with - * the hosts real pagesize. Additional anonymous maps - * will be created beyond EOF. - */ - len =3D ROUND_UP(sb.st_size - offset, host_page_size); - } + } else if (host_page_size < TARGET_PAGE_SIZE) { + return mmap_h_lt_g(start, len, host_prot, flags, + page_flags, fd, offset, host_page_size); } =20 if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978215; cv=none; d=zohomail.com; s=zohoarc; b=BJb+aN8YEBPsWiJDiv5FUTxi6+oq/VxxErwUjb3xZZkbl/sdoufp+6sGsg1z3FxitkVIS12l0nOqVW2IUr5DBjK8NM9sXgrLnRRl+VJrrt1qBc5CIcfzzLzXxWyz1aQ14HxvPhF1oz6Wxg0l/NuEIyqC7SkDkYewE8xLRjmnRbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978215; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=aSnbwhC+jNuFThOneEsO7VDKwNSydEyQRJrj8LUzDgPIHbsMwTcfWNcywLFyIqI3DebDLNsW35rDFdkHTFzdj2miC9/I3n6lqqsSqBWN0LNCICXIbxvXGqSjfcUVa02CCCB1eE3LpdiaytzKU9C8TmAFLJyldBwmCWNWDBRfXSc= 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 1707978215463112.12074539976118; Wed, 14 Feb 2024 22:23:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7F-0002Rh-Nf; Thu, 15 Feb 2024 01:21:01 -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 1raV7E-0002RQ-H3 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:00 -0500 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7C-0005Z7-9W for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:00 -0500 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6e0fc87fc2dso319093b3a.3 for ; Wed, 14 Feb 2024 22:20:57 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978057; x=1708582857; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=ggR8pGkjR1B6vTGOEjtUQ1fs05e+g8EIgIIplPv9FCbddxZiGNsrEzUYMY8kuL/+ML 5LL9va3wiD4LWDn+hbW35nl4qF2Y8cOE4t2ZvbAYwWVPSsGtB7p2TE4yiy+Bp2fDnkN0 heLhYzstlQHDdeMiOisk7iiY08JjPs0o7CZs7GTrhhEPNiLnX3rHvV1ai0dJLrJuzTtU BwWj0kl2omui1vxA0+dABMJUeWAWQIn5gfPG51jLw8s0k69GKNlR8fyHLkHCD9f1WqXD dZbkaUHQGOIMiUL7Gjdiem3hm8BSsxgp+qZ9XKCMQ7WuPcOFdhNFcWikliFRi8z38cL/ WNgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978057; x=1708582857; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MfmBcNvAQcjDLvj9qNkCIuvVr8sl09md9gL9eOBPbro=; b=w+XKtyOBqXFGWTBe69UdAm3sTqN7mtwLfc1Rur/1gCHV8gYiq5Hl23smz8v4u65SxK uAxqLr3bo+eFFzTQSztaLaR3M4zMVCPN0jf28pCEGiI0VvMNx/SqfKIZU04zObT175Mh 40VEyElqDhAQJWsO611n2lQf5Qgcw/bgAy0ddObNk6JVmVFqmXTyEVvkP8TBz9D65LTw VAdDSwT58X9T7BDvqG6S7nQHqTu4hRy4qa7Rw4H4hv0HGpGxczeUAYggvmttMI2pk2it qxhnRWIUG5xoS9vjlMPRDCq4Wf1+4QxFUXfJYFmqRATyM5K6iZeJVJVzM1egxUBfp6/2 XBnA== X-Gm-Message-State: AOJu0Yw8+VW3OmblKRu6YeASpr6cDzIraP+p7OwjkO36h3dhr33QNOOi 2m+QcL8RuVlEasMeYxB9a6eKf6yrD0xiw1WmpjlRn0v16p7Eu9MoAeSw5vx1PQmu9m/NVzNFwG+ f X-Google-Smtp-Source: AGHT+IHO/Easv/KPDu4T3OXgYV7j2wBNvuiaHuol3jLdhaKNBWHAMjHIjbkE2wlVuf90fEzBY1DBYg== X-Received: by 2002:a17:903:22c6:b0:1db:35dc:e24d with SMTP id y6-20020a17090322c600b001db35dce24dmr1093620plg.10.1707978056954; Wed, 14 Feb 2024 22:20:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 25/36] linux-user: Split out mmap_h_gt_g Date: Wed, 14 Feb 2024 20:20:07 -1000 Message-Id: <20240215062018.795056-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.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: 1707978216067100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-24-richard.henderson@linaro.org> --- linux-user/mmap.c | 288 ++++++++++++++++++++++------------------------ 1 file changed, 139 insertions(+), 149 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index ff8f9f7ed0..82f4026283 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -282,7 +282,16 @@ static int do_munmap(void *addr, size_t len) return munmap(addr, len); } =20 -/* map an incomplete host page */ +/* + * Map an incomplete host page. + * + * Here be dragons. This case will not work if there is an existing + * overlapping host page, which is file mapped, and for which the mapping + * is beyond the end of the file. In that case, we will see SIGBUS when + * trying to write a portion of this page. + * + * FIXME: Work around this with a temporary signal handler and longjmp. + */ static bool mmap_frag(abi_ulong real_start, abi_ulong start, abi_ulong las= t, int prot, int flags, int fd, off_t offset) { @@ -719,19 +728,138 @@ static abi_long mmap_h_lt_g(abi_ulong start, abi_ulo= ng len, int host_prot, return mmap_end(start, last, start, pass_last, mmap_flags, page_flags); } =20 +/* + * Special case host page size > target page size. + * + * The two special cases are address and file offsets that are valid + * for the guest that cannot be directly represented by the host. + */ +static abi_long mmap_h_gt_g(abi_ulong start, abi_ulong len, + int target_prot, int host_prot, + int flags, int page_flags, int fd, + off_t offset, int host_page_size) +{ + void *p, *want_p =3D g2h_untagged(start); + off_t host_offset =3D offset & -host_page_size; + abi_ulong last, real_start, real_last; + bool misaligned_offset =3D false; + size_t host_len; + + if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { + /* + * Adjust the offset to something representable on the host. + */ + host_len =3D len + offset - host_offset; + p =3D mmap(want_p, host_len, host_prot, flags, fd, host_offset); + if (p =3D=3D MAP_FAILED) { + return -1; + } + + /* Update start to the file position at offset. */ + p +=3D offset - host_offset; + + start =3D h2g(p); + last =3D start + len - 1; + return mmap_end(start, last, start, last, flags, page_flags); + } + + if (!(flags & MAP_ANONYMOUS)) { + misaligned_offset =3D (start ^ offset) & (host_page_size - 1); + + /* + * The fallback for misalignment is a private mapping + read. + * This carries none of semantics required of MAP_SHARED. + */ + if (misaligned_offset && (flags & MAP_TYPE) !=3D MAP_PRIVATE) { + errno =3D EINVAL; + return -1; + } + } + + last =3D start + len - 1; + real_start =3D start & -host_page_size; + real_last =3D ROUND_UP(last, host_page_size) - 1; + + /* + * Handle the start and end of the mapping. + */ + if (real_start < start) { + abi_ulong real_page_last =3D real_start + host_page_size - 1; + if (last <=3D real_page_last) { + /* Entire allocation a subset of one host page. */ + if (!mmap_frag(real_start, start, last, target_prot, + flags, fd, offset)) { + return -1; + } + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + if (!mmap_frag(real_start, start, real_page_last, target_prot, + flags, fd, offset)) { + return -1; + } + real_start =3D real_page_last + 1; + } + + if (last < real_last) { + abi_ulong real_page_start =3D real_last - host_page_size + 1; + if (!mmap_frag(real_page_start, real_page_start, last, + target_prot, flags, fd, + offset + real_page_start - start)) { + return -1; + } + real_last =3D real_page_start - 1; + } + + if (real_start > real_last) { + return mmap_end(start, last, -1, 0, flags, page_flags); + } + + /* + * Handle the middle of the mapping. + */ + + host_len =3D real_last - real_start + 1; + want_p +=3D real_start - start; + + if (flags & MAP_ANONYMOUS) { + p =3D mmap(want_p, host_len, host_prot, flags, -1, 0); + } else if (!misaligned_offset) { + p =3D mmap(want_p, host_len, host_prot, flags, fd, + offset + real_start - start); + } else { + p =3D mmap(want_p, host_len, host_prot | PROT_WRITE, + flags | MAP_ANONYMOUS, -1, 0); + } + if (p !=3D want_p) { + if (p !=3D MAP_FAILED) { + do_munmap(p, host_len); + errno =3D EEXIST; + } + return -1; + } + + if (misaligned_offset) { + /* TODO: The read could be short. */ + if (pread(fd, p, host_len, offset + real_start - start) !=3D host_= len) { + do_munmap(p, host_len); + return -1; + } + if (!(host_prot & PROT_WRITE)) { + mprotect(p, host_len, host_prot); + } + } + + return mmap_end(start, last, -1, 0, flags, page_flags); +} + static abi_long target_mmap__locked(abi_ulong start, abi_ulong len, int target_prot, int flags, int page_f= lags, int fd, off_t offset) { int host_page_size =3D qemu_real_host_page_size(); - abi_ulong ret, last, real_start, real_last, retaddr, host_len; - abi_ulong passthrough_start =3D -1, passthrough_last =3D 0; - off_t host_offset; int host_prot; =20 - real_start =3D start & -host_page_size; - host_offset =3D offset & -host_page_size; - /* * For reserved_va, we are in full control of the allocation. * Find a suitable hole and convert to MAP_FIXED. @@ -745,6 +873,8 @@ static abi_long target_mmap__locked(abi_ulong start, ab= i_ulong len, } flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; } else if (!(flags & MAP_FIXED)) { + abi_ulong real_start =3D start & -host_page_size; + off_t host_offset =3D offset & -host_page_size; size_t real_len =3D len + offset - host_offset; abi_ulong align =3D MAX(host_page_size, TARGET_PAGE_SIZE); =20 @@ -766,150 +896,10 @@ static abi_long target_mmap__locked(abi_ulong start,= abi_ulong len, } else if (host_page_size < TARGET_PAGE_SIZE) { return mmap_h_lt_g(start, len, host_prot, flags, page_flags, fd, offset, host_page_size); - } - - if (!(flags & (MAP_FIXED | MAP_FIXED_NOREPLACE))) { - uintptr_t host_start; - void *p; - - host_len =3D len + offset - host_offset; - host_len =3D ROUND_UP(host_len, host_page_size); - - /* Note: we prefer to control the mapping address. */ - p =3D mmap(g2h_untagged(start), host_len, host_prot, - flags | MAP_FIXED | MAP_ANONYMOUS, -1, 0); - if (p =3D=3D MAP_FAILED) { - return -1; - } - /* update start so that it points to the file position at 'offset'= */ - host_start =3D (uintptr_t)p; - if (!(flags & MAP_ANONYMOUS)) { - p =3D mmap(g2h_untagged(start), len, host_prot, - flags | MAP_FIXED, fd, host_offset); - if (p =3D=3D MAP_FAILED) { - do_munmap(g2h_untagged(start), host_len); - return -1; - } - host_start +=3D offset - host_offset; - } - start =3D h2g(host_start); - last =3D start + len - 1; - passthrough_start =3D start; - passthrough_last =3D last; } else { - last =3D start + len - 1; - real_last =3D ROUND_UP(last, host_page_size) - 1; - - if (flags & MAP_FIXED_NOREPLACE) { - /* Validate that the chosen range is empty. */ - if (!page_check_range_empty(start, last)) { - errno =3D EEXIST; - return -1; - } - - /* - * With reserved_va, the entire address space is mmaped in the - * host to ensure it isn't accidentally used for something els= e. - * We have just checked that the guest address is not mapped - * within the guest, but need to replace the host reservation. - * - * Without reserved_va, despite the guest address check above, - * keep MAP_FIXED_NOREPLACE so that the guest does not overwri= te - * any host address mappings. - */ - if (reserved_va) { - flags =3D (flags & ~MAP_FIXED_NOREPLACE) | MAP_FIXED; - } - } - - /* - * worst case: we cannot map the file because the offset is not - * aligned, so we read it - */ - if (!(flags & MAP_ANONYMOUS) && - (offset & (host_page_size - 1)) !=3D (start & (host_page_size = - 1))) { - /* - * msync() won't work here, so we return an error if write is - * possible while it is a shared mapping - */ - if ((flags & MAP_TYPE) =3D=3D MAP_SHARED - && (target_prot & PROT_WRITE)) { - errno =3D EINVAL; - return -1; - } - retaddr =3D target_mmap(start, len, target_prot | PROT_WRITE, - (flags & (MAP_FIXED | MAP_FIXED_NOREPLAC= E)) - | MAP_PRIVATE | MAP_ANONYMOUS, - -1, 0); - if (retaddr =3D=3D -1) { - return -1; - } - if (pread(fd, g2h_untagged(start), len, offset) =3D=3D -1) { - return -1; - } - if (!(target_prot & PROT_WRITE)) { - ret =3D target_mprotect(start, len, target_prot); - assert(ret =3D=3D 0); - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - - /* handle the start of the mapping */ - if (start > real_start) { - if (real_last =3D=3D real_start + host_page_size - 1) { - /* one single host page */ - if (!mmap_frag(real_start, start, last, - target_prot, flags, fd, offset)) { - return -1; - } - return mmap_end(start, last, -1, 0, flags, page_flags); - } - if (!mmap_frag(real_start, start, - real_start + host_page_size - 1, - target_prot, flags, fd, offset)) { - return -1; - } - real_start +=3D host_page_size; - } - /* handle the end of the mapping */ - if (last < real_last) { - abi_ulong real_page =3D real_last - host_page_size + 1; - if (!mmap_frag(real_page, real_page, last, - target_prot, flags, fd, - offset + real_page - start)) { - return -1; - } - real_last -=3D host_page_size; - } - - /* map the middle (easier) */ - if (real_start < real_last) { - void *p, *want_p; - off_t offset1; - size_t len1; - - if (flags & MAP_ANONYMOUS) { - offset1 =3D 0; - } else { - offset1 =3D offset + real_start - start; - } - len1 =3D real_last - real_start + 1; - want_p =3D g2h_untagged(real_start); - - p =3D mmap(want_p, len1, host_prot, flags, fd, offset1); - if (p !=3D want_p) { - if (p !=3D MAP_FAILED) { - do_munmap(p, len1); - errno =3D EEXIST; - } - return -1; - } - passthrough_start =3D real_start; - passthrough_last =3D real_last; - } + return mmap_h_gt_g(start, len, target_prot, host_prot, flags, + page_flags, fd, offset, host_page_size); } - return mmap_end(start, last, passthrough_start, passthrough_last, - flags, page_flags); } =20 /* NOTE: all the constants are the HOST ones */ --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978297; cv=none; d=zohomail.com; s=zohoarc; b=AyLkKb45WHadtxU2Tb+KxQaMYaaQ+mn6Gj4vThkQigkXrd4Oo6OouYvtylbV6ZQ/PNILXg9/XJuntQ8iiwliuc4ECeIUXpxMno4jsQcG8YY0dcgbraZ3o10hsbdA+BBw8ivU0Oa3p2Goy8UG2itKlskigHXb7AMttTsbj1xMMi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978297; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=PCyOdR+gbxO9aSCpc4x4q9kjUW5D8ymsGLqJrkYkyRZPCdf3Jy3LkVWI7u7l7W0tivuyHI04b5pH5i618UdTDPiocN2dCtFxVA6ZhCnlZHu5UlL1TzgvDDr5q4s5sZ7meQbvSWKVMtyfbODm36TfguX1u/VpX0ltWzKaAIH7WXk= 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 1707978297251843.7274380144952; Wed, 14 Feb 2024 22:24:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7H-0002SN-Il; Thu, 15 Feb 2024 01:21:03 -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 1raV7F-0002Rj-Rh for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:01 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7D-0005ZR-JG for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:01 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d8ef977f1eso4471555ad.0 for ; Wed, 14 Feb 2024 22:20:59 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978058; x=1708582858; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=NWxi5h2SJG9ja0acmKfI8WNKcewDyTPIvLjtCE9piJ85++m9uOjyOW6z+hcZmy9doZ wBPlf5ARZ30lfWayfT/Dqn8MxhukVY18ARinrjLTLTOy++6Vae5+DtztQcrQ1iwvZ2/7 6FjFWHyI4fF9rKT99gX/fccGeJnZrJXtreaniDsrwdQ0U85j4mrAQEdJ2cev4eljrXwx Sph8VNLgtLdCjDrAAiRju2T0tKd3o9qcEJNGOQYD0aeeTBaNTSRz93uc7pW8hhV52B8u dD58eMGIsNjH52f+HvgRX8Zp5PJT3Zw2z0mt3zQSxpnTi8ytV4aXqPA24SsWton2ZP0p jTJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978058; x=1708582858; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2NxBdbDmPXvqTBcYichP7qzlXUZvSD7xiNQMCyXrUoI=; b=MKB0b2HAs0sIV8PdptHmQ5P1jsg1GRNEVfmsxyJIDXLu7Oc7c1dRIY/y51dGYaJjGt eM6vkJgkUQzl7qgBPyK08/XpXdXgjdYl4HWllg+oWXw8FrA9vCsDjTH8WioNLRA/lA9q 8GvF7Zb2sCJk1ootR7gUBXcID7faYJDct6jxhvXwAMLenXIdjU9n5UHSsR+9J1Fih9sq jElmfTMcZkLCdey+iuYfCtwSW5tlZlUFGzJP+AMshi/D3tGsPcy3UlMPbfdJg/fzTqQv LwMwguuVJb3X6CwbWQzFDZ0e+QzpqZ7kOXgRuGjMUkUB/KbPu5vUjXr0gdss+C/HI/Gz 7c8A== X-Gm-Message-State: AOJu0YyCgymHJVzs/odHxsEc45fzX1u/mnaezgGzT1qsNQ4TXqxNi9Iv ZC2N5y7lJdZAcbWVAKArSyrTzvah4uyANeqPZ9Oz+F+kB81IQo4e+DN9+YbGXdjjYIct1Hl+Zp4 j X-Google-Smtp-Source: AGHT+IEVY8wh6IeEDXaqHj1gTyVwI56b/8r645nNk4qaLCzH0KwrkXXl9msVe+dIOonAg7g2jeWYqA== X-Received: by 2002:a17:902:ce82:b0:1d9:63a3:e962 with SMTP id f2-20020a170902ce8200b001d963a3e962mr1007444plg.6.1707978058361; Wed, 14 Feb 2024 22:20:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 26/36] tests/tcg: Remove run-test-mmap-* Date: Wed, 14 Feb 2024 20:20:08 -1000 Message-Id: <20240215062018.795056-27-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978298300100005 Content-Type: text/plain; charset="utf-8" These tests are confused, because -p does not change the guest page size, but the host page size. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-25-richard.henderson@linaro.org> --- tests/tcg/alpha/Makefile.target | 3 --- tests/tcg/arm/Makefile.target | 3 --- tests/tcg/hppa/Makefile.target | 3 --- tests/tcg/i386/Makefile.target | 3 --- tests/tcg/m68k/Makefile.target | 3 --- tests/tcg/multiarch/Makefile.target | 9 --------- tests/tcg/ppc/Makefile.target | 12 ------------ tests/tcg/sh4/Makefile.target | 3 --- tests/tcg/sparc64/Makefile.target | 6 ------ 9 files changed, 45 deletions(-) delete mode 100644 tests/tcg/ppc/Makefile.target delete mode 100644 tests/tcg/sparc64/Makefile.target diff --git a/tests/tcg/alpha/Makefile.target b/tests/tcg/alpha/Makefile.tar= get index b94500a7d9..fdd7ddf64e 100644 --- a/tests/tcg/alpha/Makefile.target +++ b/tests/tcg/alpha/Makefile.target @@ -13,6 +13,3 @@ test-cmov: test-cond.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) =20 run-test-cmov: test-cmov - -# On Alpha Linux only supports 8k pages -EXTRA_RUNS+=3Drun-test-mmap-8192 diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target index 3473f4619e..0a1965fce7 100644 --- a/tests/tcg/arm/Makefile.target +++ b/tests/tcg/arm/Makefile.target @@ -79,6 +79,3 @@ sha512-vector: sha512.c ARM_TESTS +=3D sha512-vector =20 TESTS +=3D $(ARM_TESTS) - -# On ARM Linux only supports 4k pages -EXTRA_RUNS+=3Drun-test-mmap-4096 diff --git a/tests/tcg/hppa/Makefile.target b/tests/tcg/hppa/Makefile.target index cdd0d572a7..ea5ae2186d 100644 --- a/tests/tcg/hppa/Makefile.target +++ b/tests/tcg/hppa/Makefile.target @@ -2,9 +2,6 @@ # # HPPA specific tweaks - specifically masking out broken tests =20 -# On parisc Linux supports 4K/16K/64K (but currently only 4k works) -EXTRA_RUNS+=3Drun-test-mmap-4096 # run-test-mmap-16384 run-test-mmap-65536 - # This triggers failures for hppa-linux about 1% of the time # HPPA is the odd target that can't use the sigtramp page; # it requires the full vdso with dwarf2 unwind info. diff --git a/tests/tcg/i386/Makefile.target b/tests/tcg/i386/Makefile.target index 9906f9e116..bbe2c44b2a 100644 --- a/tests/tcg/i386/Makefile.target +++ b/tests/tcg/i386/Makefile.target @@ -71,9 +71,6 @@ endif I386_TESTS:=3D$(filter-out $(SKIP_I386_TESTS), $(ALL_X86_TESTS)) TESTS=3D$(MULTIARCH_TESTS) $(I386_TESTS) =20 -# On i386 and x86_64 Linux only supports 4k pages (large pages are a diffe= rent hack) -EXTRA_RUNS+=3Drun-test-mmap-4096 - sha512-sse: CFLAGS=3D-msse4.1 -O3 sha512-sse: sha512.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/m68k/Makefile.target b/tests/tcg/m68k/Makefile.target index 6ff214e60a..33f7b1b127 100644 --- a/tests/tcg/m68k/Makefile.target +++ b/tests/tcg/m68k/Makefile.target @@ -5,6 +5,3 @@ =20 VPATH +=3D $(SRC_PATH)/tests/tcg/m68k TESTS +=3D trap denormal - -# On m68k Linux supports 4k and 8k pages (but 8k is currently broken) -EXTRA_RUNS+=3Drun-test-mmap-4096 # run-test-mmap-8192 diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Make= file.target index e10951a801..f11f3b084d 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -51,18 +51,9 @@ run-plugin-vma-pthread-with-%: vma-pthread $(call skip-test, $<, "flaky on CI?") endif =20 -# We define the runner for test-mmap after the individual -# architectures have defined their supported pages sizes. If no -# additional page sizes are defined we only run the default test. - -# default case (host page size) run-test-mmap: test-mmap $(call run-test, test-mmap, $(QEMU) $<, $< (default)) =20 -# additional page sizes (defined by each architecture adding to EXTRA_RUNS) -run-test-mmap-%: test-mmap - $(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages)) - ifneq ($(GDB),) GDB_SCRIPT=3D$(SRC_PATH)/tests/guest-debug/run-test.py =20 diff --git a/tests/tcg/ppc/Makefile.target b/tests/tcg/ppc/Makefile.target deleted file mode 100644 index f5e08c7376..0000000000 --- a/tests/tcg/ppc/Makefile.target +++ /dev/null @@ -1,12 +0,0 @@ -# -*- Mode: makefile -*- -# -# PPC - included from tests/tcg/Makefile -# - -ifneq (,$(findstring 64,$(TARGET_NAME))) -# On PPC64 Linux can be configured with 4k (default) or 64k pages (current= ly broken) -EXTRA_RUNS+=3Drun-test-mmap-4096 #run-test-mmap-65536 -else -# On PPC32 Linux supports 4K/16K/64K/256K (but currently only 4k works) -EXTRA_RUNS+=3Drun-test-mmap-4096 #run-test-mmap-16384 run-test-mmap-65536 = run-test-mmap-262144 -endif diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 47c39a44b6..16eaa850a8 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -3,9 +3,6 @@ # SuperH specific tweaks # =20 -# On sh Linux supports 4k, 8k, 16k and 64k pages (but only 4k currently wo= rks) -EXTRA_RUNS+=3Drun-test-mmap-4096 # run-test-mmap-8192 run-test-mmap-16384 = run-test-mmap-65536 - # This triggers failures for sh4-linux about 10% of the time. # Random SIGSEGV at unpredictable guest address, cause unknown. run-signals: signals diff --git a/tests/tcg/sparc64/Makefile.target b/tests/tcg/sparc64/Makefile= .target deleted file mode 100644 index 408dace783..0000000000 --- a/tests/tcg/sparc64/Makefile.target +++ /dev/null @@ -1,6 +0,0 @@ -# -*- Mode: makefile -*- -# -# sparc specific tweaks - -# On Sparc64 Linux support 8k pages -EXTRA_RUNS+=3Drun-test-mmap-8192 --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978073; cv=none; d=zohomail.com; s=zohoarc; b=Hf3ItfwyNn4ah/u8VhsBg8/hyj6/bhjEy8UtYqlXCVGkMomshXRiGtjhaeqXMsOv6Qnw73y4Y9mlE+vXKETN66CIIwqDPJcVMf9mbI9uSBwWaAG+fEegGmwBbHeBYhftSAkHP8/rcQIxhw4o788EzHoY4muVFrjvZbeUhX16jZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978073; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=M1kMrXasqeZcBoeH9VHuOzXdKoccbwa5jzh4FIxWM7BSmm4ZGabkAVX6FsXk0+JbXg8DOqcsrRFW49wIum9aKLXe3wZHVt4e3T7kl5ayS10o/yXpjtm6fej1T+qs+Vq9LDxYKhyZUO3widA95yYmFZMv+wXbi4cTAwL3iKxh9PA= 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 1707978073869318.0251186184836; Wed, 14 Feb 2024 22:21:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7J-0002WL-EB; Thu, 15 Feb 2024 01:21:05 -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 1raV7G-0002SA-SQ for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:02 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7F-0005Zk-64 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:02 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6e0aa4bb62fso311220b3a.1 for ; Wed, 14 Feb 2024 22:21:00 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978060; x=1708582860; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=jocrHhZXXPVXVOKXM8tf6O7U7e4f8XwGD5NfISYkl7L+JBquBlR8OOPE0Veo0DIpzg EQsMO4OmhDSyfiV+8V0u2f6SzEbmSR0A0qo5jKImc5xC7GHNdpp7nWgbrZOo1oQM3//8 PFUYGWBZkMdUJjuKyuZdunF1cBI/z2lBOUCFyHPPmsRZWJzsLCOlX5qc0Ie/MnM/KPtA BoYhEXbWf31pYkzlMtx0l2hO94xTjjODg2YkFz9ZtVIR66xQsl9bXnPeaavHvheVFXf6 wlw3FK8ZheX1K71wwbViAidcRh3zszGfxs7DSuPAerevO6CLffmI1IsUEkrZ2IYJsmuO 5DYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978060; x=1708582860; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e2NESTxnz6150SuLytNvY5Gmn2U5RKg4GfRtueQZH4I=; b=a8rTCODNJRUTZ8d/40bxX11mNR55kQbO4LHOAIgkDeBhlg84fPlHOWnVaIC93gdNrp ekGWZ+UaBCWqkROKX99H5bn26at2Q1VOzduBLnzAZhR0zCdWIBLfkrjuuTpkUwqwS9+f ThIlqw68ruqapOPiFntxr+Dz4MUBTfw5ySDDVz1jHMmj7+zy8BoMa7cdUK4U5pO1kDyV 6qDJ8dA62/Q4Ut09ISgzSvWTW/jhJOU/fwtjGJJI9dhqTyZxDVWtk0hus7E2m4yYC4nB ho9YX40JpOzNQbp8+vZL6ttMXHFtp4M3LXSrhJkH1DNJVSNiIyVaINqmwTqR1XTczpEs 92JQ== X-Gm-Message-State: AOJu0YxpbaE8yIQ9lYfAv14tC9vsOPnqM5/jbaz6Qlnorom5vli5bsqs WwWE/4enEcuti39YyZxHHD9/CqIw17uxdeiew0BzZYRZJ/0tHZSVXSZvFU9lDIagmWIBuZMhucb 5 X-Google-Smtp-Source: AGHT+IFJ9sDjEXtUETUm3ReyUQZDUaqmowhrRS8qjEoX1WAOvwlmCisk/xV50ygaQVkQUzzfnDWLMQ== X-Received: by 2002:a17:903:445:b0:1db:917f:5a42 with SMTP id iw5-20020a170903044500b001db917f5a42mr75351plb.3.1707978059832; Wed, 14 Feb 2024 22:20:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 27/36] tests/tcg: Extend file in linux-madvise.c Date: Wed, 14 Feb 2024 20:20:09 -1000 Message-Id: <20240215062018.795056-28-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978075796100002 When guest page size > host page size, this test can fail due to the SIGBUS protection hack. Avoid this by making sure that the file size is at least one guest page. Visible with alpha guest on x86_64 host. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-26-richard.henderson@linaro.org> --- tests/tcg/multiarch/linux/linux-madvise.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/tcg/multiarch/linux/linux-madvise.c b/tests/tcg/multiarc= h/linux/linux-madvise.c index 29d0997e68..539fb3b772 100644 --- a/tests/tcg/multiarch/linux/linux-madvise.c +++ b/tests/tcg/multiarch/linux/linux-madvise.c @@ -42,6 +42,8 @@ static void test_file(void) assert(ret =3D=3D 0); written =3D write(fd, &c, sizeof(c)); assert(written =3D=3D sizeof(c)); + ret =3D ftruncate(fd, pagesize); + assert(ret =3D=3D 0); page =3D mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE, fd, 0); assert(page !=3D MAP_FAILED); =20 --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978147; cv=none; d=zohomail.com; s=zohoarc; b=i1mH8AVQZQ8509BkeC5yDWCdhrvZnlgj7pwXmdlMIj8+A8pwG9sibuEbKQlPJtlgDhxyNsuz7YoFFj92eoPtTVurWk6+1Bf4TiGGo9kCJouD9VgFiZnN85yYybv/m+E53ST3iiMqyi9WB4Z3gGmBTvGvTnyVCxuMlDI9Buc4Yzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978147; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=QieQFmWQsn1JOy9yjEy4L2laxnB+nO6ftniGOlPorX0CnR5+x4Tfb2/Uv/U20fTs/NN2AP7vlM/hOcieo1rIPHdsj4v9a7FRj74Z3oj0XjSo490FAnDiMjVGdUKqTUttpzk7ReHu2MdDv1fOH/il0YDPAlIkSmbIKjBod4VpG30= 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 1707978147454684.2064900692991; Wed, 14 Feb 2024 22:22:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7M-0002jO-Dg; Thu, 15 Feb 2024 01:21:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV7J-0002aB-FP for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:05 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7H-0005aE-4q for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:04 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d91397bd22so3785535ad.0 for ; Wed, 14 Feb 2024 22:21:02 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978062; x=1708582862; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=iAVlYPA3IK6ae7rQCI5dUhoCxdHv87BIiZR6rzuLU0BCkBApD2gktnpMnHlyol+P3U C9tMWKRcpHto4GSN81BqvnMPjrEAwHU5lxMYP8ulg+w33Hy+Fe394w49BWsUPzrs2eP/ Picgqp6If7zZ3yUqMDgYKySdb5mt+oFk9ngduUf/fAEn3acHudRx9RLjTDTlopoTySxW ApdibbJHEtLzUTTTIoFN5bH4Crgt45+qyGk24TvdVRmk/Xypp3yN1ycTSa7L+9hi4jVP 4TmZG6MyztUD3vAzcoBDbXeoo7qWZDV0HjQjKVyKk9i+WYC7WnEWA90knuIGt7AXxGte r/XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978062; x=1708582862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n/bmjjPgt+4cAZDZblP4w6A7Xhw+0ftgWcgfLTUC2AM=; b=w7VeyvVbyGcbd9RNk88qTTPzRHu2sXTG4PeO0GiS//v9OL02mG5V4XNwXT7p9Ykata x2fqR/JNluKcot89bEOSfMQYhoY/yviDdJogedCNFINoIFAtvUz/6+fyYce4Czpg9CtP APxoKjT6LYCdvOPTiAeJ08EHB8Rsb5ROL1m6EHtYOCbDCb5I4OUyMx4L1DQ9lO2xow1B 9GTJRI5xLN+zkAXZ/IFkmfAsgWjiSJiKKpq7G7+ZuNNjrTDjLUtYU4Vaix3rgWA3BMOH cj9YvPJrsbaw1VbB+XMD9YihoGj5VwaxnfJYkVaA7JW2HpTi7Y9uY7zGkDt0zEWWh4Ld pVoA== X-Gm-Message-State: AOJu0YyBPZCoGx61tHmwhtAIeIwY7GyL7/L8ZbLWpY/EKqYWG/ORT9OG /LVQx4ZJx1Q1EzEdMKbQ0VKuizQFsrFWcdAykEXYzM6uizNboI7L5xTfyxsLS97jNmf5JScSXA6 9 X-Google-Smtp-Source: AGHT+IFtt8DndZ0a6o9UnlIWG+rcYFPDVaMRlnbct6yM6wrlh/eav1cW1IdrVFH6ugdaYp27kSmA7Q== X-Received: by 2002:a17:902:b686:b0:1d9:8f6e:86e8 with SMTP id c6-20020a170902b68600b001d98f6e86e8mr729039pls.69.1707978061977; Wed, 14 Feb 2024 22:21:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Helge Deller Subject: [PATCH v4 28/36] *-user: Deprecate and disable -p pagesize Date: Wed, 14 Feb 2024 20:20:10 -1000 Message-Id: <20240215062018.795056-29-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978148198100001 This option controls the host page size. From the mis-usage in our own testsuite, this is easily confused with guest page size. The only thing that occurs when changing the host page size is that stuff breaks, because one cannot actually change the host page size. Therefore reject all but the no-op setting as part of the deprecation process. Reviewed-by: Warner Losh Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Helge Deller Message-Id: <20240102015808.132373-27-richard.henderson@linaro.org> --- docs/about/deprecated.rst | 10 ++++++++++ docs/user/main.rst | 3 --- bsd-user/main.c | 10 +++++----- linux-user/main.c | 12 ++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 5a2305ccd6..3074303b9c 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -63,6 +63,16 @@ as short-form boolean values, and passed to plugins as `= `arg_name=3Don``. However, short-form booleans are deprecated and full explicit ``arg_name= =3Don`` form is preferred. =20 +User-mode emulator command line arguments +----------------------------------------- + +``-p`` (since 9.0) +'''''''''''''''''' + +The ``-p`` option pretends to control the host page size. However, +it is not possible to change the host page size, and using the +option only causes failures. + QEMU Machine Protocol (QMP) commands ------------------------------------ =20 diff --git a/docs/user/main.rst b/docs/user/main.rst index 7e7ad07409..d5fbb78d3c 100644 --- a/docs/user/main.rst +++ b/docs/user/main.rst @@ -87,9 +87,6 @@ Debug options: Activate logging of the specified items (use '-d help' for a list of log items) =20 -``-p pagesize`` - Act as if the host page size was 'pagesize' bytes - ``-g port`` Wait gdb connection to port =20 diff --git a/bsd-user/main.c b/bsd-user/main.c index e5efb7b845..521b58b880 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -364,11 +364,11 @@ int main(int argc, char **argv) } else if (!strcmp(r, "L")) { interp_prefix =3D argv[optind++]; } else if (!strcmp(r, "p")) { - qemu_host_page_size =3D atoi(argv[optind++]); - if (qemu_host_page_size =3D=3D 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) !=3D 0) { - fprintf(stderr, "page size must be a power of two\n"); - exit(1); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D want) { + warn_report("Deprecated page size option cannot " + "change host page size (%u)", want); } } else if (!strcmp(r, "g")) { gdbstub =3D g_strdup(argv[optind++]); diff --git a/linux-user/main.c b/linux-user/main.c index e540acb84a..bad03f06d3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -332,11 +332,11 @@ static void handle_arg_ld_prefix(const char *arg) =20 static void handle_arg_pagesize(const char *arg) { - qemu_host_page_size =3D atoi(arg); - if (qemu_host_page_size =3D=3D 0 || - (qemu_host_page_size & (qemu_host_page_size - 1)) !=3D 0) { - fprintf(stderr, "page size must be a power of two\n"); - exit(EXIT_FAILURE); + unsigned size, want =3D qemu_real_host_page_size(); + + if (qemu_strtoui(arg, NULL, 10, &size) || size !=3D want) { + warn_report("Deprecated page size option cannot " + "change host page size (%u)", want); } } =20 @@ -496,7 +496,7 @@ static const struct qemu_argument arg_table[] =3D { {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "write logs to 'logfile' (default stderr)"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, - "pagesize", "set the host page size to 'pagesize'"}, + "pagesize", "deprecated change to host page size"}, {"one-insn-per-tb", "QEMU_ONE_INSN_PER_TB", false, handle_arg_one_insn_per= _tb, "", "run with one guest instruction per emulated TB"}, --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978358; cv=none; d=zohomail.com; s=zohoarc; b=TIfWAVsMo5ezPI3GrBrd1DX9s4bGl4kkJ4sm9Ov+r+gj4npsW5LUcSSy7VtNau835RFFkHdkZa2Z3jwxBArZlVWhACQxi+KhoPKc73YgFFm+IIGtNWUOxxpIHKJvIMAyooyVMQrPjpw9Itg3bV8/d4xwUliVsEDFRspPuKvf+f8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978358; 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=qOkw1UdDHHqYlRltK3URYQYAqp5e8MWyuYN33RTPWmw=; b=W2hKFqVcd+TTwL/YmHcLlbUGS2jpODA6erjkba8luP0P9pEJmWIJS4u5R19wqV73IuqBNCDvuJ/znZkpf/U8G+yFHihOFWyjtWfAvNISoE9WqgLtpVTaWTdBRgKzXirSfWqQXsYJbNjHWbr+TwlfXpRxryLpSwGF05o8lkzAR4w= 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 1707978358878490.5384043887143; Wed, 14 Feb 2024 22:25:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7Q-0002yt-CQ; Thu, 15 Feb 2024 01:21:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raV7O-0002vR-Od for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:10 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7J-0005ad-FJ for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:10 -0500 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1da0cd9c0e5so12118335ad.0 for ; Wed, 14 Feb 2024 22:21:04 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978064; x=1708582864; 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=qOkw1UdDHHqYlRltK3URYQYAqp5e8MWyuYN33RTPWmw=; b=KT/Fat/paPsu7JQycT3mvV7cqCjgub23ewMPLvtwuIG9ftOZ7iXQTjkUCoaUClsbVH 8Xq9HzM5AtiCi7FpFvIuTNJTCXRlqr9yV5SSWNVx3gTA6VMt+aqSDRY51AAANCc61ArZ UCrfDmb6gh06ZmsHbGbgjaQ+gDonU2cgH+nJg8Er6Rl/0hi8ncSzMuWYWt6TAmpIyq01 ao8xIw0zF2Gbkwmhu/NQBi0dMatUqenJZFn6pcp+3XnYpmJuNEBlayPVIuCGsp7f4AEZ 0fEFpIXqwtCYqp7XRu6G/THwks7s4Ov7zxNiHDrKqXXD5zjBTAD1oTwqEND2DOQml5wG dTAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978064; x=1708582864; 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=qOkw1UdDHHqYlRltK3URYQYAqp5e8MWyuYN33RTPWmw=; b=aOX41UeVyxSq80GaX1HLy/mgdDqIoLOUV4vVPJDMWHFPUF0ggGFUtvfHgie8Xny7Gh T1/03xprm/KTc0hHE+WmDvTkuQV/QwaxDYe6IZfShYiUERR8/eGTF4iKdqP82Ab7nVeE TJ1/KP7c6KmIj1qr3OU30iNDr0pXic/DFbU32e+U6kzkeW5YimrQQ6RZx+d7ksmDtOWq B0X4cWeSvWTmtKD7UPcLE+UJscjUx+5whmhLS/NOB0v9jRMYlfROHGB2Tai5EMWFccL4 kULLAFE8LSpgUo1pdpfCKxqNFgh72vIEv2ChW23wh26RIyKP1+0H7pTDmQec/wHidhLo QFEg== X-Gm-Message-State: AOJu0YxzSfflC9cQnfvWzz5Nlz2D8dHsVv4eylhM8I9vktBgeNJ2OqV0 7LmjeJKeu8AIbSXX009hUNG1uORi4aBVKOSG+H9jQOSpH3vmC7iDBz/2YaEbytsTf0oVD8FJiCh w X-Google-Smtp-Source: AGHT+IExC6BMqKoNVnRQjGBWiYl/RU+EvfQoJ91vtm2SoNkslNl6dxdB8fHucxJnu7Cuvb/wXPKsCw== X-Received: by 2002:a17:902:ce8a:b0:1d9:5923:c247 with SMTP id f10-20020a170902ce8a00b001d95923c247mr6291819plg.29.1707978063708; Wed, 14 Feb 2024 22:21:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Warner Losh , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 29/36] cpu: Remove page_size_init Date: Wed, 14 Feb 2024 20:20:11 -1000 Message-Id: <20240215062018.795056-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978360584100008 Move qemu_host_page_{size,mask} and HOST_PAGE_ALIGN into bsd-user. It should be removed from bsd-user as well, but defer that cleanup. Reviewed-by: Warner Losh Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Tested-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-28-richard.henderson@linaro.org> --- bsd-user/qemu.h | 7 +++++++ include/exec/cpu-common.h | 7 ------- include/hw/core/cpu.h | 2 -- accel/tcg/translate-all.c | 1 - bsd-user/main.c | 12 ++++++++++++ cpu-target.c | 13 ------------- system/vl.c | 1 - 7 files changed, 19 insertions(+), 24 deletions(-) diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h index dc842fffa7..c05c512767 100644 --- a/bsd-user/qemu.h +++ b/bsd-user/qemu.h @@ -39,6 +39,13 @@ extern char **environ; #include "qemu/clang-tsa.h" =20 #include "qemu-os.h" +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +extern uintptr_t qemu_host_page_size; +extern intptr_t qemu_host_page_mask; +#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) + /* * This struct is used to hold certain information about the image. Basic= ally, * it replicates in user space what would be certain task_struct fields in= the diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 9ead1be100..6346df17ce 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -20,13 +20,6 @@ void cpu_exec_init_all(void); void cpu_exec_step_atomic(CPUState *cpu); =20 -/* Using intptr_t ensures that qemu_*_page_mask is sign-extended even - * when intptr_t is 32-bit and we are aligning a long long. - */ -extern uintptr_t qemu_host_page_size; -extern intptr_t qemu_host_page_mask; - -#define HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_host_page_size) #define REAL_HOST_PAGE_ALIGN(addr) ROUND_UP((addr), qemu_real_host_page_si= ze()) =20 /* The CPU list lock nests outside page_(un)lock or mmap_(un)lock */ diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 4385ce54c9..5c2d55f6d2 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -1179,8 +1179,6 @@ bool target_words_bigendian(void); =20 const char *target_name(void); =20 -void page_size_init(void); - #ifdef NEED_CPU_H =20 #ifndef CONFIG_USER_ONLY diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 1c695efe02..c1f57e894a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -256,7 +256,6 @@ bool cpu_unwind_state_data(CPUState *cpu, uintptr_t hos= t_pc, uint64_t *data) =20 void page_init(void) { - page_size_init(); page_table_config_init(); } =20 diff --git a/bsd-user/main.c b/bsd-user/main.c index 521b58b880..4d6ce59af4 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -49,6 +49,13 @@ #include "host-os.h" #include "target_arch_cpu.h" =20 + +/* + * TODO: Remove these and rely only on qemu_real_host_page_size(). + */ +uintptr_t qemu_host_page_size; +intptr_t qemu_host_page_mask; + static bool opt_one_insn_per_tb; uintptr_t guest_base; bool have_guest_base; @@ -307,6 +314,9 @@ int main(int argc, char **argv) (void) envlist_setenv(envlist, *wrk); } =20 + qemu_host_page_size =3D getpagesize(); + qemu_host_page_size =3D MAX(qemu_host_page_size, TARGET_PAGE_SIZE); + cpu_model =3D NULL; =20 qemu_add_opts(&qemu_trace_opts); @@ -403,6 +413,8 @@ int main(int argc, char **argv) } } =20 + qemu_host_page_mask =3D -qemu_host_page_size; + /* init debug */ { int mask =3D 0; diff --git a/cpu-target.c b/cpu-target.c index 86444cc2c6..8763da51ee 100644 --- a/cpu-target.c +++ b/cpu-target.c @@ -474,16 +474,3 @@ const char *target_name(void) { return TARGET_NAME; } - -void page_size_init(void) -{ - /* NOTE: we can always suppose that qemu_host_page_size >=3D - TARGET_PAGE_SIZE */ - if (qemu_host_page_size =3D=3D 0) { - qemu_host_page_size =3D qemu_real_host_page_size(); - } - if (qemu_host_page_size < TARGET_PAGE_SIZE) { - qemu_host_page_size =3D TARGET_PAGE_SIZE; - } - qemu_host_page_mask =3D -(intptr_t)qemu_host_page_size; -} diff --git a/system/vl.c b/system/vl.c index a82555ae15..3a2586a04d 100644 --- a/system/vl.c +++ b/system/vl.c @@ -2118,7 +2118,6 @@ static void qemu_create_machine(QDict *qdict) } =20 cpu_exec_init_all(); - page_size_init(); =20 if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978277; cv=none; d=zohomail.com; s=zohoarc; b=T3DBYHDxxw3k+agC1COBQTLF14lj+ufRzbi4abb4/aqEeMZc3Wi4oLlZZVZK4JWE629bLR3V9IiPbIyUUwc7Jpfc87yV2zZdOHKbZzon4dfPwpB9mDWf2m9TV6BLCUIjRmQYBNIZM6epKxn9TaQ0+Af+39q/BPINSu+EgbmKASo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978277; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=nx/h+GFqM+RRPxU3WnCSLslZNZRu4z17Ug0J8N5xJTn92JOz4GzpajZaBxoTZ9Y5Qs+5a/4i+2pHPxhiVjNPiJdknIzN+TA/CLLGd3BImacCg06FCixDsZlKnJ6YRCs63X8NrxW2n7+TF8mSFiJFn1H6kTOrNXrubxbxWAjWy2s= 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 1707978277688646.3838001140845; Wed, 14 Feb 2024 22:24:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7P-0002wn-OE; Thu, 15 Feb 2024 01:21:11 -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 1raV7N-0002o1-GV for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:09 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7L-0005av-Oo for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:09 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1db51e55023so2969545ad.1 for ; Wed, 14 Feb 2024 22:21:07 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978065; x=1708582865; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=ON0vDx1jfOO6XNXhgRG2bwbv9GCJZfaIHvQ0gRfZ/3ZBCT2LAboGCvSn/9+olyqgwb DGy9s8tD/N2dii9MXRJu33ZtLpKVNZybb5edCSBgJFgs4kWBbiyySu3wlgcPgvn4zGkd Y46i3EFX85mwaCnhbKxcIGDIiOWI6Yp7jK5sOiJ9Rg9vw3aPlOj7G//q0GnzqFwdAQZI +6sQPH2zFHBdXn47qwmeAbf7i0p2ip2kDJchghD82dClha0DrFiejjaTN+SuMEMNPEPI bD82pw0eBIp2Dm00ukt4OLzTj05gDRfThmMTIIuCqpFhzunTAmfriHBsj5Edi5dT9Xxk m6mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978065; x=1708582865; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nFLr/Nh9lR5RHGOKXL0ktJAFT8XYevI/jB1Fp1QCuj0=; b=pCZyrwXDLTFxWHuD4+6PasWKwaTZyTHEEabfplUYI7oSACDzijMR2bM5kW5Cp02DvK phzb0mkZR2Psy385O5Ttdbb26KvCUasvcn3xYbtx1zVuj8yXwum68hAhs6MJsNRf7Xf7 rN4bay1zJNcAxnCnQ+T8GpvKs1+4dKXomVJxYPob7tMrjwi/yenYE8zcIvJoO+ufoxfs BpuzN0cS2I9zPxdCcR5iyFH5IIQ+BvH/Jnr56NZb+f/kriWDMomIN0MyvJjHL6nInq6Q 3++3OMw8GVyvV7r+qwNiNNOXIcsyjC2G+K0strkkN5EYk1Hml9Q+b73dxpZr++p49JRf 9/Gw== X-Gm-Message-State: AOJu0YyCUyGnxGCmfmh50tvBCpCMU2jAsucDur3gkSXViqH+4TODnCYT M60mwFk6olrHGb5D3JmRIy9gzUHMEQBYlH2tJmrQEHOLA25C+EVbb0pGzktJnxL/cGsv+a4SFEz B X-Google-Smtp-Source: AGHT+IG+Ds5kjKXoYp85oSkZk9AloVLjxUO0mzzS6Im2QjV6I4/2R26lxlpwbwJpG5tAlPZd5CsQDg== X-Received: by 2002:a17:903:1cc:b0:1da:15c5:bc06 with SMTP id e12-20020a17090301cc00b001da15c5bc06mr1195475plh.58.1707978065257; Wed, 14 Feb 2024 22:21:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 30/36] accel/tcg: Disconnect TargetPageDataNode from page size Date: Wed, 14 Feb 2024 20:20:12 -1000 Message-Id: <20240215062018.795056-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978278309100001 Dynamically size the node for the runtime target page size. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-29-richard.henderson@linaro.org> --- accel/tcg/user-exec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index 69b7429e31..3cac3a78c4 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -864,7 +864,7 @@ tb_page_addr_t get_page_addr_code_hostp(CPUArchState *e= nv, vaddr addr, typedef struct TargetPageDataNode { struct rcu_head rcu; IntervalTreeNode itree; - char data[TPD_PAGES][TARGET_PAGE_DATA_SIZE] __attribute__((aligned)); + char data[] __attribute__((aligned)); } TargetPageDataNode; =20 static IntervalTreeRoot targetdata_root; @@ -902,7 +902,8 @@ void page_reset_target_data(target_ulong start, target_= ulong last) n_last =3D MIN(last, n->last); p_len =3D (n_last + 1 - n_start) >> TARGET_PAGE_BITS; =20 - memset(t->data[p_ofs], 0, p_len * TARGET_PAGE_DATA_SIZE); + memset(t->data + p_ofs * TARGET_PAGE_DATA_SIZE, 0, + p_len * TARGET_PAGE_DATA_SIZE); } } =20 @@ -910,7 +911,7 @@ void *page_get_target_data(target_ulong address) { IntervalTreeNode *n; TargetPageDataNode *t; - target_ulong page, region; + target_ulong page, region, p_ofs; =20 page =3D address & TARGET_PAGE_MASK; region =3D address & TBD_MASK; @@ -926,7 +927,8 @@ void *page_get_target_data(target_ulong address) mmap_lock(); n =3D interval_tree_iter_first(&targetdata_root, page, page); if (!n) { - t =3D g_new0(TargetPageDataNode, 1); + t =3D g_malloc0(sizeof(TargetPageDataNode) + + TPD_PAGES * TARGET_PAGE_DATA_SIZE); n =3D &t->itree; n->start =3D region; n->last =3D region | ~TBD_MASK; @@ -936,7 +938,8 @@ void *page_get_target_data(target_ulong address) } =20 t =3D container_of(n, TargetPageDataNode, itree); - return t->data[(page - region) >> TARGET_PAGE_BITS]; + p_ofs =3D (page - region) >> TARGET_PAGE_BITS; + return t->data + p_ofs * TARGET_PAGE_DATA_SIZE; } #else void page_reset_target_data(target_ulong start, target_ulong last) { } --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978342; cv=none; d=zohomail.com; s=zohoarc; b=lHAdAGt6mR5LGeGAAxwmCXtMuqBdRRNwPc5eLohBGJ851UaaYnqp+bCp2+gfjVOK0PEucqRx1zQv+F5QSlD9PASzVW9tdIfcwzzF2IShxvGrwuj17PHPVYVVcAcFeY6Bhuq9HRyR6d2t8We5H7H/a4q9B+uLAFzR8P5+aSor02U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978342; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=VWGRaFtZtAVwTaKierQq6sPpFKxuUl0XaOlpAXmNij5PAgPU2D+/IEveP9BYGnNAvij8kMOguRDOM2o5jpo7Ji7ZSB8gciwj1rLnqAXEq4WJqlpEK2yeYGA7L5DtOpkJGOu0hZS4R6W/39h92oTyj1OyG1GjhjXjRxmCvoFVmm8= 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 1707978342130472.8444853534585; Wed, 14 Feb 2024 22:25:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7R-00036l-Il; Thu, 15 Feb 2024 01:21: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 1raV7P-0002w9-2a for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:11 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7L-0005b6-Pu for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:10 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d91397bd22so3785925ad.0 for ; Wed, 14 Feb 2024 22:21:07 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978066; x=1708582866; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=v4wd6VKy5O2IRTProYWFR0Vcv+WPssRe5SK74jjAA2yPm6ASPm6m6kzj4ZE8ogpUFi fsSXfdqzQt9xgKcnUGQPgUEaRKvoJu/B0VIN7/GYhI86gbWiVauGD1o4c396AvTVV2BG sW58FAOp1qqxbIrgFHPusCAu7FF7Z1McXjiQL/KtNQ6cKKsD2pHTYd3RuvUQb7UKXr6/ IHVM0KCMLeBYIv0xMzMuUgxQC4bUjJJpezU0uZCvkg6+ikuEZbUhE0g0sQJUgdNernYK 3cDJv8eIa7qdzMDA8PufduinmecsefyLeCT272b2DmEy6FlgYTmKziUIDm51bsx9lShQ Qhiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978066; x=1708582866; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iM2DWBTbIODm0qN2yhX9D3hAXXDtYwow0kqtsMcFoQE=; b=cZC1e7gq9OMOAa4Veq62nzlN0UkcZK/TyE9Q6tTJMdLhrmFHryFcop23iKb7qNfH3n Yw5GG6rHwQeW4FBQuNXbqyV042eblhsch4y+O5peWQFsmf5K8ahi0G8GzW+l7p5KPRHm I2NNG3cUBhq2nEXoTUeFJKa6+PIIrX5c83wZa5u+FIQ5aQ4q0Yjsy6vAjOyKWQ7kC/Dy GLv+AHABepgkCcp6i/CTLnWiexdo6XhnfLWJonngsK7nhUGfbGqycvUvB6DGJEc5WM2E scnzSBw4l+jJX6JooCcQ7/zjfVr68MI/z8GspALI98qeaKPunUF85sJ580MkI1rzdDfv XM2A== X-Gm-Message-State: AOJu0YyyoNitrWmZtdfIgCvWrSvZU543IOPDQ6fkQ6fZiKUBXyWYSkRJ Oekeu/CHRBS+tDagK6sWvdV7Ji0kYBfktnEbBIcIYz5K+d8hqikXFjia+0LJp33n4W6kTVJNOgo v X-Google-Smtp-Source: AGHT+IEevPRBMgGW9AzdwAOYT1e4rQc8RU+6HkCg9vJCaNaj6kI1S/o6llW4TwiqCKixriLxZYgSJQ== X-Received: by 2002:a17:902:f7c3:b0:1db:75aa:7f6a with SMTP id h3-20020a170902f7c300b001db75aa7f6amr751041plw.20.1707978066567; Wed, 14 Feb 2024 22:21:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Helge Deller Subject: [PATCH v4 31/36] linux-user: Allow TARGET_PAGE_BITS_VARY Date: Wed, 14 Feb 2024 20:20:13 -1000 Message-Id: <20240215062018.795056-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978342444100001 If set, match the host and guest page sizes. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Acked-by: Helge Deller Message-Id: <20240102015808.132373-30-richard.henderson@linaro.org> --- linux-user/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index bad03f06d3..12bb839982 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -55,6 +55,7 @@ #include "loader.h" #include "user-mmap.h" #include "tcg/perf.h" +#include "exec/page-vary.h" =20 #ifdef CONFIG_SEMIHOSTING #include "semihosting/semihost.h" @@ -680,6 +681,7 @@ int main(int argc, char **argv, char **envp) int i; int ret; int execfd; + int host_page_size; unsigned long max_reserved_va; bool preserve_argv0; =20 @@ -791,6 +793,16 @@ int main(int argc, char **argv, char **envp) opt_one_insn_per_tb, &error_abort); ac->init_machine(NULL); } + + /* + * Finalize page size before creating CPUs. + * This will do nothing if !TARGET_PAGE_BITS_VARY. + * The most efficient setting is to match the host. + */ + host_page_size =3D qemu_real_host_page_size(); + set_preferred_target_page_bits(ctz32(host_page_size)); + finalize_target_page_bits(); + cpu =3D cpu_create(cpu_type); env =3D cpu_env(cpu); cpu_reset(cpu); @@ -804,8 +816,6 @@ int main(int argc, char **argv, char **envp) */ max_reserved_va =3D MAX_RESERVED_VA(cpu); if (reserved_va !=3D 0) { - int host_page_size =3D qemu_real_host_page_size(); - if ((reserved_va + 1) % host_page_size) { char *s =3D size_to_str(host_page_size); fprintf(stderr, "Reserved virtual address not aligned mod %s\n= ", s); @@ -904,7 +914,7 @@ int main(int argc, char **argv, char **envp) * If we're in a chroot with no /proc, fall back to 1 page. */ if (mmap_min_addr =3D=3D 0) { - mmap_min_addr =3D qemu_real_host_page_size(); + mmap_min_addr =3D host_page_size; qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx (fallback)\n", mmap_min_addr); --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978365; cv=none; d=zohomail.com; s=zohoarc; b=lFSQLe3gkNco7WTEYFhd8FDJAsmmy/hICTaGHyo6Cn3IvL0L1svT519QlCj9RG8d8nhWY6esriCPpAVvU7WuJYdypUtFu6HHpTNAG5A0flT8NA15OXER8TI5qo2TaoLqlUUyJ5VqaFGrvGmNXqOD6+B7Jk3ppgUi5vEqx+N8hyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978365; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=Zci3qkk7ELvIuO04JVmCXfrcoEpWbOpEGTX2MkH65iPZV3Mcsxh5rWxWsROz8i9ukIhptfRVpVv7iu2APk0WcdGuFoKsyUsGuTgqkyo7MwiVK4Bt4SO9ohLTCIZbuLCdZozmjEeqtxYIA7Ft8Vre1Kk8ZpDgMRbcxZFj+jS7moM= 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 1707978365631974.5254331075174; Wed, 14 Feb 2024 22:26:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7R-00032M-6x; Thu, 15 Feb 2024 01:21: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 1raV7P-0002ww-DH for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:11 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7N-0005bQ-ES for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:11 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d94b222a3aso4607945ad.2 for ; Wed, 14 Feb 2024 22:21:08 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978068; x=1708582868; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=fednZYHjNTaq6wbLI8smTVXFlwEDTUgaM+pKT871n49izPOZ2/I3JYyQ0L6uCz99O+ co3FYzvumfdaGjpUwVgAzoz0RLVmPB2v07QwzvM9rfsFh0B5xOeCJlqK2+m8lQ/YAM1Q D4p8K9BCbwUm20d4mbRW1AfX4B5Ez9IX3OT4ae/nk7Gj9OzWQaCnmmaa7SDzj6VdpkpQ i2q4XZiH/j5PTpSxDZ2hg7NOg8N1H2lzD+Gu2UD6R7uHKgQJ9k/ItFW4bP4f9C6hKVA1 90SbzT899xHTqVbpOkcBMqcBOwCJKyWg24IxiQx/gdgyeoQzJ80ZHbkx1QRRsouQi862 7/9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978068; x=1708582868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uW4mSrnyRkLcpmuT0B32llPRivoOZrRn2N/1ffLpPkI=; b=q2bEoOQ8vPvS6Af/EXsqUTUO1TTo9WKV8iblc7YF6+QIestSu1m4A/FIIyWirVPfT+ R7CiklC7cYWmzQJd5U6a+clssvGXeCz/jhPjFVvPoWyo18sIP3MxE9Q4LsDiXUH0mBIq vkCDYU+Cc6+wDjiSsfBr2mvnNc4oQR3+caiBmjvX54HmTnJ5ENBvXKVoT0PbuwqJ3oRB UtMIyIjP4QrZvmu38FlC7qKAroUZpUZPrIKRaZSjIfobhC2gJ1jghufjP+1L4oRDgT0u KfrIjp0j6imX+o6X9etLVF4nwa00a5eMbizPbilEL8aXy3xhG+jyubFmWRWAOMxmXVv9 Irrg== X-Gm-Message-State: AOJu0YxoVBHaLQ5LVZDK2Th8aYG9yBN8On5IE06iDhVdbzhz+Nuv93a7 N7/4iLyDPS4bYIzWvD0mN7twlcJCp7cXxgnsRo+81Wp+MLVnK2RqjLSXfui/6Kk82EzV7JoXVo3 S X-Google-Smtp-Source: AGHT+IE5XdO5r8T3pvBqL/J24t1MrA9SfpIOp9zaB4GTj0fBXclR41YLskF6XBLbgsDqZ3D9iSmG7g== X-Received: by 2002:a17:902:aa0b:b0:1d9:5371:bc with SMTP id be11-20020a170902aa0b00b001d9537100bcmr798940plb.37.1707978067971; Wed, 14 Feb 2024 22:21:07 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Helge Deller Subject: [PATCH v4 32/36] target/arm: Enable TARGET_PAGE_BITS_VARY for AArch64 user-only Date: Wed, 14 Feb 2024 20:20:14 -1000 Message-Id: <20240215062018.795056-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978366577100001 Content-Type: text/plain; charset="utf-8" Since aarch64 binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Acked-by: Helge Deller Message-Id: <20240102015808.132373-31-richard.henderson@linaro.org> --- target/arm/cpu-param.h | 6 ++++- target/arm/cpu.c | 51 ++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index f9b462a98f..da3243ab21 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -19,9 +19,13 @@ #endif =20 #ifdef CONFIG_USER_ONLY -#define TARGET_PAGE_BITS 12 # ifdef TARGET_AARCH64 # define TARGET_TAGGED_ADDRESSES +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# else +# define TARGET_PAGE_BITS 12 # endif #else /* diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 5fa86bc8d5..2325d4007f 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1809,7 +1809,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) ARMCPU *cpu =3D ARM_CPU(dev); ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(dev); CPUARMState *env =3D &cpu->env; - int pagebits; Error *local_err =3D NULL; =20 #if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) @@ -2100,28 +2099,36 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) !cpu_isar_feature(aa32_vfp_simd, cpu) || !arm_feature(env, ARM_FEATURE_XSCALE)); =20 - if (arm_feature(env, ARM_FEATURE_V7) && - !arm_feature(env, ARM_FEATURE_M) && - !arm_feature(env, ARM_FEATURE_PMSA)) { - /* v7VMSA drops support for the old ARMv5 tiny pages, so we - * can use 4K pages. - */ - pagebits =3D 12; - } else { - /* For CPUs which might have tiny 1K pages, or which have an - * MPU and might have small region sizes, stick with 1K pages. - */ - pagebits =3D 10; - } - if (!set_preferred_target_page_bits(pagebits)) { - /* This can only ever happen for hotplugging a CPU, or if - * the board code incorrectly creates a CPU which it has - * promised via minimum_page_size that it will not. - */ - error_setg(errp, "This CPU requires a smaller page size than the " - "system is using"); - return; +#ifndef CONFIG_USER_ONLY + { + int pagebits; + if (arm_feature(env, ARM_FEATURE_V7) && + !arm_feature(env, ARM_FEATURE_M) && + !arm_feature(env, ARM_FEATURE_PMSA)) { + /* + * v7VMSA drops support for the old ARMv5 tiny pages, + * so we can use 4K pages. + */ + pagebits =3D 12; + } else { + /* + * For CPUs which might have tiny 1K pages, or which have an + * MPU and might have small region sizes, stick with 1K pages. + */ + pagebits =3D 10; + } + if (!set_preferred_target_page_bits(pagebits)) { + /* + * This can only ever happen for hotplugging a CPU, or if + * the board code incorrectly creates a CPU which it has + * promised via minimum_page_size that it will not. + */ + error_setg(errp, "This CPU requires a smaller page size " + "than the system is using"); + return; + } } +#endif =20 /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will overri= de it. * We don't support setting cluster ID ([16..23]) (known as Aff2 --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978314; cv=none; d=zohomail.com; s=zohoarc; b=ZDly7FqNwfT4Qb62X0SzH28C1LZWGSps/3yf/Z44UMbyJ21Bod3XsmUUG7eVLysLyDZnysVwu2DNZAufNtnH8iQDlVv3AY2VhQtZlZMIrQVG4/5bXNLi94LsiWtKRdzt4GE/8nO0PR5mMB3rok6q0e8B94550wy46PSgGZ6RRNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978314; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=Mdb7evkBgq/4Tp9Z22gENO2cGkrWusgRJqG+3Ki5jkfk12rG45RWD2YVav5oPhMCMsVtlRnXw8y1lwpaGCpZ3Zms7M6E5Vaza8z+Ovj2cOjebjXmbbxbmlKU4SX38qNcABQ31Z0ijsH2kAZ56JkDFNdgbK71D+fgyQa1wO3xo60= 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 1707978314285984.650572980981; Wed, 14 Feb 2024 22:25:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7U-0003Es-O9; Thu, 15 Feb 2024 01:21: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 1raV7Q-0002zh-Hv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:12 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7O-0005bp-Sv for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:12 -0500 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-290da27f597so413910a91.2 for ; Wed, 14 Feb 2024 22:21:10 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978069; x=1708582869; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=ZKKbMeDrMzEYzqVTYfXnb0dqw4ImR5L3YY2JHrGAmKx6W+nEcEDxLmRWrEKQEIKpdA WvF/ZUB0PcVoYx/q6VCzs1ClGfmIXIzkzclcvckkPRVYLfKvMk2TgqJJWfTudywh8w5o Ag+O4O+4ENtY8GEdlvoSrb7vyFSj/J+zzApJawOPrFoRLHc7vsYitfllLzFeRZivAI57 lMrvBcW7mqBLElvrQBPgF9OV+xUO+WhOhZFb/ezrRhLegjsW4yA2bXchu+gr6yZluNki zk6ZD8rBQOrBLE9sfHSDsovmL6iXzJaRRQFvlFZ5owSWagPgiBkNE5OGL7lzP4W7YH2l yD7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978069; x=1708582869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e+A2qkcrgjaI9rrkh97Ktn6PEwqN2bQkXlFCXE4NZ3E=; b=Z9WWISlzwyEQWJyuZUUTotT5WIOVJnkbAhV1Zm3P2xxHjE9WMxVnS1EDHBH6zJMTUN dLX4zmmXSFaQiU+pGk8SJ/usRpgW4kHCC61Q6tsGhksJjxCU+Rbj+4kZ551L0uSQLwyu UZouW4OfvUDxrWWNJ/1vfjTAoNRKhIPyqD7EmN9JA8ulUnyTcWjcoyLpYjpdnRvut+Zd 57c0KhB0NXFCj5JllNXaqhMr6tcj9rBvf2RZrV1AqsJjSA+lxOm0mp3UbR+NlkelyhlA MuYX/YwkaT1wJB1cNe5j8KGJJT5Fbc1SMfDuCqZ+aya3iPXXHT2/XnXPr9mscbVS6jLQ efsg== X-Gm-Message-State: AOJu0YxRQyR0Mxs1kesv8mPt1CD7G04c/qd//7UDsiJLAVORpUt2Bh/I 0feW1eCnrFjbsQAK3515tep2Q4J9vG+7JFJeCnH2z5590UDmBmPhomuiRr7URwOkAYLlpQX3jvY 8 X-Google-Smtp-Source: AGHT+IHvSotyUzofOW75hdefpNocwa7y+Z6VqrRB/m8C5gG3sEMq0eITnn4RgnW6bgNDGFYNVyAXsA== X-Received: by 2002:a17:90b:2308:b0:298:d43b:812e with SMTP id mt8-20020a17090b230800b00298d43b812emr882435pjb.7.1707978069512; Wed, 14 Feb 2024 22:21:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 33/36] linux-user: Bound mmap_min_addr by host page size Date: Wed, 14 Feb 2024 20:20:15 -1000 Message-Id: <20240215062018.795056-34-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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::1030; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1030.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: 1707978316353100005 Bizzarely, it is possible to set /proc/sys/vm/mmap_min_addr to a value below the host page size. Fix that. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-32-richard.henderson@linaro.org> --- linux-user/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/main.c b/linux-user/main.c index 12bb839982..551acf1661 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -901,7 +901,7 @@ int main(int argc, char **argv, char **envp) if ((fp =3D fopen("/proc/sys/vm/mmap_min_addr", "r")) !=3D NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) =3D=3D 1 && tmp !=3D 0) { - mmap_min_addr =3D tmp; + mmap_min_addr =3D MAX(tmp, host_page_size); qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx\n", mmap_min_addr); } --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978278; cv=none; d=zohomail.com; s=zohoarc; b=l7IjTD/j1Af+o73oqnBF5KPNSgTuJI4J6RHVp99ue2XmoVrlBnoWxa7RVqRkNXAHq5ACUDWr1CTOafnJqK2ELvHdVDSoTjmgi9Ir/1hiV42EipYeJJqGvk4HB48KT0VK1z45E6fBA+6a+15cBBwL387lOatZ5yaF4OdfBxdvj94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978278; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=S5rtT5ZNWRQH4Kq59znUWjsMBXdECZQfFlaDwwlg7PI+1VNDsVPN8Bfgzm0tMtS5YLJGDg39R0fA38LjsXlMk5mUK1oTvqjba1OJAaavsa2KMKjXlI9+z1LWQkmYjazLufQeCvUZyv4cxuUv2RHwxLdeZyNuoGROEyGKdMZOIwo= 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 1707978278258361.9470907456247; Wed, 14 Feb 2024 22:24:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7U-0003Ek-GY; Thu, 15 Feb 2024 01:21: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 1raV7S-000399-75 for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:14 -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 1raV7Q-0005cP-Eg for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:13 -0500 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-5c6bd3100fcso366417a12.3 for ; Wed, 14 Feb 2024 22:21:12 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978071; x=1708582871; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=KAar5FC8e9We9YfaelMA8tDRcPvZrvRLb91Q7YnxlfG21E82bxIs0aT1KYJaPJfexu 8+Ujq92RpoW+TxTuTqANBiMVA2ym7gryIL9x6jS9tY8t/yTGi/rJ72OVgy6nApq33cik mhVgpL+oCin0KctKIhlVJmmw3OWh1exiJcIMZDT9ue7rIfRblvQNSrpY9Dutg6hOWuKa l3V0yPqPUvnRKqTH6CGTQXjYLTyvSTPqvgb+yryCSGMJvOajF/uC3UOvMF7nFC5ZXyNl ukaNLAtsUNbrnS0mpZNMComLlo+hSuCTwZdSDL2HE7J4T6wqoUCEwwqS2Ec9joytFV69 7Zfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978071; x=1708582871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KYeT1V/wjgovpdrb0SONHx5NJHYkyLqzQDA/KKTsreA=; b=bpcCsqGA37z1AMmG0FcWUgOoSVruRKvJMak9DYD+7zzo4MzwEz3M8kpaprOmWQb+Mz GXllTzknm3vKqiuWdFXKe0WeGCNo8QMFQDP565P2UzDc+xEyPHYgcI31aWWMGDNdn3Ci juwoPIXp1npNuVVMxUaWx4gtNb1D4iNQDdKZsbFY4DjtQy3oslF/b8yw2f/g1kOXnwj7 +QdMgCbvuD7xJzH9VtIUXprqQ5CPlr9C8IsYsJJ9UmxZZD1yEvffq9KBWNjhYRwxUzp2 mkm+OdcHLUHfC0nkoRKEKucCL1Vnr8xMQpZgxFAEHEU6z1DbwIFGcj1fqrOMMLxELbi9 z+KA== X-Gm-Message-State: AOJu0YzLxfnYOO2p6cmg8JuHO7dJzRZaW6xkOWhRo8z44Pkz+Ywd1RmQ AP51DVZHtpTITo1U7Io+hMz/sbQNFz7F0MdQKi3x2yqlNWAxnF708Pr3gAom2dGwYUYnwVvc3oX c X-Google-Smtp-Source: AGHT+IEcFwrTySXHEPBzoFN3QXP7ciY96FfYsMTAFNXShFtVdL+Wd07a3AVq+6UvkCrZPdc7dllnrQ== X-Received: by 2002:a17:90a:cc12:b0:298:a449:d3d0 with SMTP id b18-20020a17090acc1200b00298a449d3d0mr697976pju.47.1707978070971; Wed, 14 Feb 2024 22:21:10 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 34/36] target/ppc: Enable TARGET_PAGE_BITS_VARY for user-only Date: Wed, 14 Feb 2024 20:20:16 -1000 Message-Id: <20240215062018.795056-35-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-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: 1707978280252100005 Since ppc binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Richard Henderson Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-33-richard.henderson@linaro.org> --- target/ppc/cpu-param.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/ppc/cpu-param.h b/target/ppc/cpu-param.h index 0a0416e0a8..b7ad52de03 100644 --- a/target/ppc/cpu-param.h +++ b/target/ppc/cpu-param.h @@ -31,6 +31,13 @@ # define TARGET_PHYS_ADDR_SPACE_BITS 36 # define TARGET_VIRT_ADDR_SPACE_BITS 32 #endif -#define TARGET_PAGE_BITS 12 + +#ifdef CONFIG_USER_ONLY +/* Allow user-only to vary page size from 4k */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +#else +# define TARGET_PAGE_BITS 12 +#endif =20 #endif --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978308; cv=none; d=zohomail.com; s=zohoarc; b=PkRpdeEUYSb6GfsB5txWFulSZIsxm3ylMud2Dxr4e0WhAWjH45Pew6cnXG3Rz23iawAguQkb9lmoqSKzsExz9L65PPNQR4FjAKRhKU8tTd/3LHjG4PIUqlVsBSsH5tiNbAvLC+5LtVJM5/jObF+2MeDtUCCD3N6yKqKDR3PjiQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978308; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=WjSI86Itu3PKU3DA2q7pm05IF6GnTawkAM8IjHSquZp0jbcvQ9N53faqHp3bajV3eU7APu+1dLVj32hi0vWngFP6hrp5fk7F3vp8MsnarLE629Bm0LH0PhEfMALvgenU80kyIXfvyBvKxzHs+geE85fkt6Zof8QWTlX2aToY9Io= 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 1707978308099285.3261220921156; Wed, 14 Feb 2024 22:25:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7W-0003G2-FH; Thu, 15 Feb 2024 01:21: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 1raV7T-0003Cl-Fc for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:15 -0500 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7R-0005cs-PN for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:15 -0500 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d932f6ccfaso4502535ad.1 for ; Wed, 14 Feb 2024 22:21:13 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978072; x=1708582872; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=FFVbwpqQ0IeZ/QNmDAsgitY8l2ck6762cD5sSFyvDLX/UssGgnDZcxrSfmz7CVGyIJ mjx2X/ef30VrZyHSbCxdopbWxIbbP/6VrJc7MJzmy2zxDli3IfRFOqhNQ/7wCyGgTpwF lUPHqkicMPqMCQ5Ad5RWJdBQPO/a0L0o3IFNc13Rc1IMCcjmOGM777xx0Lx+JruuVACv c/7duZ0gLXWUvj8/d++Cz4r2PUrRL7AWGV0u6ET0tW0qb/uayzZ8uBY0VojojGeU/TNe LpK3DGsP+NCLfR+zBN7sUlcBd1vXITriOyPvKqWWHuHGmuaZaHv5lvl6LMERri/4oJbB So4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978072; x=1708582872; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nZgxz9sv+Wfw3NEh+PaVP4+cTZIcAB3l+Ojbwy+/FqY=; b=IozPfgDiMC9J2zRYO67u1vlxsI3b6vHmxSrDrrFFhpTUpa4VxHC/ejLjE73N34uUvA i7153d3eVgVKzy5Oaz2gbdsso+7soI9fUmrgb0F2tAVA1Df3jmb2mkAo9rSFxEzd5RF1 3wL9YWML6XWxuQoHLff2VDdpuBoFUZwBMTffgoMeSNYOfis2QwXd4kIPSVF/E4fSSqdm cQcxJCjLedKqO7yHy9YLqYW5MfmfHlLwadykpGrnF4FlJfuXHJIrpLvv4UShLZ9CANdt yvhZXSa4cmnfPqFdv+2NDsBWx+9Ys03qdTtSr41uEEe75qxTHl6/r07HzCj1IBAB1+rI bCRA== X-Gm-Message-State: AOJu0YzV2hFY/+lUoNXvwEBrNDSu9XkF8yvoq9WQHpjxse1X7ZMZbmLP k5r2MEunZZbfQ4avCb5Ii8oVQjQ+f07BisfpqupGXImSsBeQ2pb/tr65OBdl8cfsszyQAs5V3J9 y X-Google-Smtp-Source: AGHT+IGwtOFsP6+Q1s7TXiBuCA+KR2UgBUPh5YUS1UxwLoP+yP34JoqblbPw8FghDVVo6mtMYDMxdw== X-Received: by 2002:a17:902:b609:b0:1d7:2e86:fb2a with SMTP id b9-20020a170902b60900b001d72e86fb2amr891899pls.65.1707978072391; Wed, 14 Feb 2024 22:21:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Ilya Leoshkevich , Helge Deller Subject: [PATCH v4 35/36] target/alpha: Enable TARGET_PAGE_BITS_VARY for user-only Date: Wed, 14 Feb 2024 20:20:17 -1000 Message-Id: <20240215062018.795056-36-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978308314100001 Content-Type: text/plain; charset="utf-8" Since alpha binaries are generally built for multiple page sizes, it is trivial to allow the page size to vary. Signed-off-by: Richard Henderson Reviewed-by: Pierrick Bouvier Reviewed-by: Ilya Leoshkevich Acked-by: Helge Deller Message-Id: <20240102015808.132373-34-richard.henderson@linaro.org> --- target/alpha/cpu-param.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/target/alpha/cpu-param.h b/target/alpha/cpu-param.h index 68c46f7998..c969cb016b 100644 --- a/target/alpha/cpu-param.h +++ b/target/alpha/cpu-param.h @@ -9,10 +9,22 @@ #define ALPHA_CPU_PARAM_H =20 #define TARGET_LONG_BITS 64 -#define TARGET_PAGE_BITS 13 =20 /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */ #define TARGET_PHYS_ADDR_SPACE_BITS 44 -#define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) + +#ifdef CONFIG_USER_ONLY +/* + * Allow user-only to vary page size. Real hardware allows only 8k and 64= k, + * but since any variance means guests cannot assume a fixed value, allow + * a 4k minimum to match x86 host, which can minimize emulation issues. + */ +# define TARGET_PAGE_BITS_VARY +# define TARGET_PAGE_BITS_MIN 12 +# define TARGET_VIRT_ADDR_SPACE_BITS 63 +#else +# define TARGET_PAGE_BITS 13 +# define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) +#endif =20 #endif --=20 2.34.1 From nobody Wed May 15 07:00:49 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=1707978313; cv=none; d=zohomail.com; s=zohoarc; b=molGRalpg2OpYG18yK+cmo8ZUJH+Rj7R8CMni4xHXP26IGYrjXXQ52DN2jmcXE2A7SHPJtI6dXWRtRpFnlC7ygC4Nod9X8SFGlNqb2mBkHDyv3pcu9jhUoxdHioii6LFP6VuDnZiQ6q0q/qk7dyl9E7+Hh174abp7S7jk5GkdoY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707978313; 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=lIw0HHLdL2NvcxZjQjlv25wKknGxFlW0JytLKiI4Hg4=; b=CBY0ytLm4aIeHnNkljfz1pJ1biVScKGHbaXF7aVIpg/GFB740MioZg9K1pTh6D+BsaNrJgrw28aYsrn3XP9+3StqvtV8aFmXPfOiAzzEzL5+r/Ne/z0G446JfCfTTEUP/nSKpElhMnQ4y8ywwsw6ccL7A2MXOXy8V51/1aW+lJI= 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 1707978313044146.56144828598156; Wed, 14 Feb 2024 22:25:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raV7W-0003GN-NP; Thu, 15 Feb 2024 01:21: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 1raV7V-0003FG-0n for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:17 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raV7T-0005dC-5q for qemu-devel@nongnu.org; Thu, 15 Feb 2024 01:21:16 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d9b2400910so4243865ad.0 for ; Wed, 14 Feb 2024 22:21:14 -0800 (PST) Received: from stoup.. (173-197-098-125.biz.spectrum.com. [173.197.98.125]) by smtp.gmail.com with ESMTPSA id d5-20020a170902b70500b001d6f29c12f7sm464418pls.135.2024.02.14.22.21.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 22:21:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707978073; x=1708582873; 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=lIw0HHLdL2NvcxZjQjlv25wKknGxFlW0JytLKiI4Hg4=; b=dH0yOKfydA5ddESUduAoVM7n9d0LlyuJ0nlvDYKueG69KsA2mysm4C+DnRnX2lBe3p nHQ+CD5MgW6dRClMjvlYnXWRCs6KMEOavWXp3F6jzE5y9/vNZfX7bWEjbiAQm6l3aMU9 NCH0nofJg644ohKJ4UumrkgGt/Z7HpR1FYb4n6w0N6j8FzJ+U3djZMf6czSIr+2C4dZK l+8BwFt+u9rUl2O+LoLiAETCAIi+2nbSANetiw2bOW6oU0hoFiMUBO37hZkv8uOwG2dd GampUL6G929La6FGo2oCorpQ/bb0RAhgYHCI3Gf4q/RUaVIy81bTLbKW0Ogb+HPnzWdU wSBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707978073; x=1708582873; 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=lIw0HHLdL2NvcxZjQjlv25wKknGxFlW0JytLKiI4Hg4=; b=woHePOW2YEVh2/qyLkOwKVxZIXgOaLtlHZz6G+wZi9f4fcqijFkwZa1ho3IERNuK5i F8N7vn6wfgGtzXeEN4n3o5/fDHJ+cCmD8GGcxQHdHalgRWzDYT4trbvWwXrk4UEqu1F3 ltLOJG2Ub3/IrxhH1WLVCHWY7ty/1cdx8Hz3FGRJQvmh654Xvv7G7B3oOEJ/P8IRyaGV huswzjLrt5KIvHy1IIOwiuRb8QS5BpVF6/qYtItwjKlPw6S46P1Rb+cBG39BbNasYFeu iNzR37TftlNZCkX37C8sQBLfddN8OSl/uJkVTUI7mD67dwp93zv5QWK7En2BA1sv4qKk gBFw== X-Gm-Message-State: AOJu0YzN2QnKXepdRT4OmK42Ln4uuKpnCfyJqYS9iK6gjmXcZdnrxWkP kBI2VWNBdyxZAd6Ii/ZhEswwJZpj324iEds0yRwmwQXIfHyEr8Wya5FeauPcmtZFOy6ID67QNeP 1 X-Google-Smtp-Source: AGHT+IHnRA0oQOTYhLHregguDiI7r0MfaCFspINVFDlvaLvChrgbkiEk4WeRq10n0XRPVc6SW9S2FQ== X-Received: by 2002:a17:902:ec8a:b0:1db:28c0:3ec4 with SMTP id x10-20020a170902ec8a00b001db28c03ec4mr1443472plg.7.1707978073608; Wed, 14 Feb 2024 22:21:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 36/36] linux-user: Remove pgb_dynamic alignment assertion Date: Wed, 14 Feb 2024 20:20:18 -1000 Message-Id: <20240215062018.795056-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215062018.795056-1-richard.henderson@linaro.org> References: <20240215062018.795056-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1707978314348100001 Content-Type: text/plain; charset="utf-8" The assertion was never correct, because the alignment is a composite of the image alignment and SHMLBA. Even if the alignment didn't match the image an assertion would not be correct -- more appropriate would be an error message about an ill formed image. But the image cannot be held to SHMLBA under any circumstances. Fixes: ee94743034b ("linux-user: completely re-write init_guest_space") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2157 Signed-off-by: Richard Henderson Reported-by: Alexey Sheplyakov Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- linux-user/elfload.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f3f1ab4f69..d92d66ca1e 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3022,8 +3022,6 @@ static void pgb_dynamic(const char *image_name, uintp= tr_t guest_loaddr, uintptr_t brk, ret; PGBAddrs ga; =20 - assert(QEMU_IS_ALIGNED(guest_loaddr, align)); - /* Try the identity map first. */ if (pgb_addr_set(&ga, guest_loaddr, guest_hiaddr, true)) { brk =3D (uintptr_t)sbrk(0); --=20 2.34.1