From nobody Wed May 8 15:49:06 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=1641295981; cv=none; d=zohomail.com; s=zohoarc; b=IwXc7Hcz+FeIfLYRJKG7gbpT50N7QkSiYaf+h6i72qZ4rWaxk4z9c/6H34rOBAQUzbCwzHsxdZt3Fgymt3eqiJ5o/abdBN4dYvFJOMFa020tPksg2HGed/F+Ovw/llPuMbO6t6jd909Ehch6XboRvhwfalDmp5neJiFvzrRWmiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641295981; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=yT+gANTJzhvLSKJ00i6kx5zZarxpdYRyDoY4W8MdHrs=; b=hjID+N3oJ3LP4kvwJxwtBNODHZBdd2WSRVoD5O1qEftTCUXfATMCcLV10wA+m5MhsalEUQNV11EVuQINohRwFkMMHuwnwK275zRcQX/Lbxo410cTFYVnBDS0QmJl33mFA3dx0xPl2wC9Tz99jLngeS1nseX+yo/5EUU1TWvCYy8= 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 1641295981224410.416371994648; Tue, 4 Jan 2022 03:33:01 -0800 (PST) Received: from localhost ([::1]:48626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n4i3n-0000Lg-DE for importer@patchew.org; Tue, 04 Jan 2022 06:32:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n4i35-00086t-Ph for qemu-devel@nongnu.org; Tue, 04 Jan 2022 06:32:15 -0500 Received: from [2a00:1450:4864:20::42a] (port=36521 helo=mail-wr1-x42a.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n4i34-0002iv-4e for qemu-devel@nongnu.org; Tue, 04 Jan 2022 06:32:15 -0500 Received: by mail-wr1-x42a.google.com with SMTP id r17so75523162wrc.3 for ; Tue, 04 Jan 2022 03:32:13 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g3sm37679984wrp.79.2022.01.04.03.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 03:32:11 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7B7791FFB7; Tue, 4 Jan 2022 11:32:10 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yT+gANTJzhvLSKJ00i6kx5zZarxpdYRyDoY4W8MdHrs=; b=OTReLHwL4gSgBta73R99PP6+jOjFWEprMRoJMBWgCCDE6e9CZVG+hD75e4c4Ohv6mV HkTjMJJ33Oyg9MtposHzW4V1t8b2MDACkti+yhooe1ND+ie9ZELoa1f0crqdgx9BuzpO Yo05xaEPLOjQfJTTrOR2dNlB9B4CiQM/m+cDc3MAH+A7TxvVQjoUcyRnfl38/qI1im61 VvFB/Q4mFavd3A4TzxY+p2jvorrGh+7kK1+2FcKqE8doGOUBAKODjCuRldzmyltj9rpw mV7Fp+JgsnDcGMp7ytTbDUI4DCGJ2C1MFYUfs6gZ5gMQmNky/q9h+/aTlDvy4UH3eLGp w1Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yT+gANTJzhvLSKJ00i6kx5zZarxpdYRyDoY4W8MdHrs=; b=RnfMWuvFjb1RmR8PYM59jdgqpYQc0k0isDBan21R2NUGIt4xFGYpe4z/ubwgIvIU// onivjuADhiZwX9rtTZV4YaKglV2/Nj8iKCyhvKSzf+1pS7Z5M4G3d95SGR39MYB6q08s DyjZ2hIWhjqKZ69JnmDzUQeC885KUtwbebymABig+P/kDd8JRgE22Uvo5vASql63zhR3 NhgYFccewp8zhqfss9ZvoS4d6ltKLWgKPQz6zfp9FyvV8UkvQ3u4ecId0zqr9HhsoztX VBl0MSYADGUazKisTK3wRQODCd5LpVNnVBCDjzphhSPvKwhnR0/qhwUTAbJctLb5k2OV jQtQ== X-Gm-Message-State: AOAM533cvKkngGtT9I5D2dUy3UjF6oW0NOOLHlWbt4rhcA/Sn6LTQI0O sHmSqMqmEV+3WK88+tu67jsN+w== X-Google-Smtp-Source: ABdhPJwgGfVDxIfyMIhcWLkhACwM7s1N5Qyf//rlpKiUpV86DTM+dHyq5gDXOqhfsVakkW7ulLxv6w== X-Received: by 2002:adf:d225:: with SMTP id k5mr42497260wrh.360.1641295932266; Tue, 04 Jan 2022 03:32:12 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2] linux-user: don't adjust base of found hole Date: Tue, 4 Jan 2022 11:32:02 +0000 Message-Id: <20220104113202.766884-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42a (failed) 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=2a00:1450:4864:20::42a; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: 6 X-Spam_score: 0.6 X-Spam_bar: / X-Spam_report: (0.6 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1641295984048100001 The pgb_find_hole function goes to the trouble of taking account of both mmap_min_addr and any offset we've applied to decide the starting address of a potential hole. This is especially important for emulating 32bit ARM in a 32bit build as we have applied the offset to ensure there will be space to map the ARM_COMMPAGE bellow the main guest map (using wrapped arithmetic). Signed-off-by: Alex Benn=C3=A9e Resolves: https://gitlab.com/qemu-project/qemu/-/issues/690 Reviewed-by: Richard Henderson --- v2 - also make same adjustment to fallback --- linux-user/elfload.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 238979b8b6..fa9dae5f3f 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2293,8 +2293,7 @@ static uintptr_t pgb_find_hole(uintptr_t guest_loaddr= , uintptr_t guest_size, brk =3D (uintptr_t)sbrk(0); =20 if (!maps) { - ret =3D pgd_find_hole_fallback(guest_size, brk, align, offset); - return ret =3D=3D -1 ? -1 : ret - guest_loaddr; + return pgd_find_hole_fallback(guest_size, brk, align, offset); } =20 /* The first hole is before the first map entry. */ @@ -2334,7 +2333,7 @@ static uintptr_t pgb_find_hole(uintptr_t guest_loaddr= , uintptr_t guest_size, =20 /* Record the lowest successful match. */ if (ret < 0) { - ret =3D align_start - guest_loaddr; + ret =3D align_start; } /* If this hole contains the identity map, select it. */ if (align_start <=3D guest_loaddr && --=20 2.30.2