From patchwork Tue Jan 4 11:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 529868 Delivered-To: patch@linaro.org Received: by 2002:ac0:9f5c:0:0:0:0:0 with SMTP id l28csp1567950imf; Tue, 4 Jan 2022 03:32:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGhUChsWLWDQnSb9YPV6At282lFJwSZzS3d95IEskgVmzhhSdy54qMwz19YL3nNlmbqq8w X-Received: by 2002:a25:d94d:: with SMTP id q74mr44371980ybg.484.1641295964141; Tue, 04 Jan 2022 03:32:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641295964; cv=none; d=google.com; s=arc-20160816; b=vu/VpvZDGgTNnJ+loxgeIej2t9de1lTBCBarCcbpH5dH+hZkm/gt5ZrJeWoRWiL60t a/ffKrUjkE9DVLX3IKkxdHGWmzHTf+O5chF04q4b1+1l2rd/3nQGGlQIhYCSi/i3nrhZ adO9psY/wi2Ya4EmyMFT7UB5M2gpo/nDblKyfdTogNXC8nMAwMlvcXfxxj7HKiRc1VZq 5vWImO7xMfJITRJP4/qeqSihPXFcEF51oN7Pqqym2jaA5iGzet3V158Vi7GkVCc7yIVC PadsdBF8msbgh7lO2hRJni6eyBBm/9bPKrph1WSOVaDPGzNHRhxDFLer2qh0oZu/D3sN rwow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=yT+gANTJzhvLSKJ00i6kx5zZarxpdYRyDoY4W8MdHrs=; b=h8a/6jbXo7JNzPKtpkcWvnFvJxeS5zmPJzrcAAg1IdSXhiuYsBGEzQyCwOjLuE3rm4 8xgto/+Ic/Jjam7s9ksIGRaEHoXdvuseRlOk+x/yaU3+OaaeyXdD6BVR+tlF9M1LO3gO A/OYr9bo83wRmRUP8JEYjZ5ZFI4YzlJy8LU7HJ+adiQvSaMIxEbN1vz4JSCIEVNP+264 uq7jkJRp5ON89XZePyxiClhUddk6pXLBZxQWtvESChAevmX3RlwdvbyzxEaXz3tHOblb ri+sje3pbISS9K8gP58LQ4+5BswfXP3vb5hYYCxQoizCQUqRTwOKvGe9bfPlUzKhzDtP yjcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OTReLHwL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g6si35850ybf.730.2022.01.04.03.32.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Jan 2022 03:32:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OTReLHwL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n4i3X-000872-M2 for patch@linaro.org; Tue, 04 Jan 2022 06:32:43 -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) 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-Received: by 2002:adf:d225:: with SMTP id k5mr42497260wrh.360.1641295932266; Tue, 04 Jan 2022 03:32:12 -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) From: =?utf-8?q?Alex_Benn=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 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::42a (failed) 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_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée 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 = (uintptr_t)sbrk(0); if (!maps) { - ret = pgd_find_hole_fallback(guest_size, brk, align, offset); - return ret == -1 ? -1 : ret - guest_loaddr; + return pgd_find_hole_fallback(guest_size, brk, align, offset); } /* 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, /* Record the lowest successful match. */ if (ret < 0) { - ret = align_start - guest_loaddr; + ret = align_start; } /* If this hole contains the identity map, select it. */ if (align_start <= guest_loaddr &&