From patchwork Wed Jan 5 13:50:01 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: 530170 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp341281imp; Wed, 5 Jan 2022 06:46:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyLE7WDXzeNPW5xRx2VqUId4iPGBr/XkMynO92r41FTkDRBhte1Hauy3+Sq598IXerWqXP X-Received: by 2002:a25:a385:: with SMTP id e5mr53163880ybi.481.1641393980036; Wed, 05 Jan 2022 06:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641393980; cv=none; d=google.com; s=arc-20160816; b=GklqkTIfQczN/utSHPL5qOGRPZTR5lzI68EaOL6SWos2nrPO5PvNyGOkpnv4/ZD/DO oqE28PZQVM77KIRY4FlsjBVXfHhtaCGisK8pyOwVt2/mUgJcjSEf6u29l92jzkNJKeTm lVs8AZ55Sv4te1tGdkbipx4oy5tL5mXSV6AFMlhhFQBY1QVKi8VTuaIyK3Ps/S0HlGGU dtUydnYQT7h/UarnJ5P0i0NRLRuL5ghrg4fya97VnnWDj8LZcsmhCEjhIM2JDtoZLef/ N2a+s6rcuLnH8wvK8vxSvPcp3zUtiDu2R8UoEyWko/jYko/2uEyU0n5bJvjTH5Aw3HvA Ir/A== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=9fEorODw0prngKGvWe8LjMgb7BbQnuD2gvb64lkzC/I=; b=qGHmwRBAhtHxBWk442uTaPmwWtwOXEW8AfZNf9ESu07qQbgNUxlHzruUSR5Mb5uVJ6 zRmWtK6ZyPTARraq1GkY7tszLxD7TxpwaQjX2N8Peszn4CpKl/vXHo8UDaCURsV+DO5c DK3OO21p+bDs/4IUsQxHkl/aWVgUgHH2v/TY39znUNgUfTqyZw5vw5wynpo2dtbFBpPc iQ0/qPpNbjJyLdl7FBkg75FcdtBC53a8/pX5JSHZPR3nvqluRaH/VlaiqXPQanVOvrSe FXgywIyqGiBUFJt/C5MPMf9vN+v49gJhc6R57WOpLofDCTLeUzHaw4wIqohUqYchhJx/ T1bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=atTKctJV; 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=fail (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 f7si7442625ybj.165.2022.01.05.06.46.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jan 2022 06:46:20 -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=fail header.i=@linaro.org header.s=google header.b=atTKctJV; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n57YR-0001ph-IQ for patch@linaro.org; Wed, 05 Jan 2022 09:46:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n574l-0001JE-CP for qemu-devel@nongnu.org; Wed, 05 Jan 2022 09:15:42 -0500 Received: from [2a00:1450:4864:20::435] (port=37820 helo=mail-wr1-x435.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n574a-00081y-6N for qemu-devel@nongnu.org; Wed, 05 Jan 2022 09:15:38 -0500 Received: by mail-wr1-x435.google.com with SMTP id t26so83298719wrb.4 for ; Wed, 05 Jan 2022 06:15:15 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=9fEorODw0prngKGvWe8LjMgb7BbQnuD2gvb64lkzC/I=; b=atTKctJVxD4NIxljB55HWUPiYgQu3x80qGGIr6KfTrsV6EB50IJclAVkfqOXvMZnep n/XlTR4lo479PMgpuiUQw0Jdd5Ab+jAJbw4CEdJy9S5X82urDe4I8WoRoYb1TzXInlGG ArfJahz+11361T4y7kheFmvtRs3cPG/pGMVuaRpcRkCr0umcgALdiF9H9/9p9qJe9+2x 75iRxbz8P1s9SqbuQ+PfJlOF5fzZfT9cQMjKpUmY/2EK/jd2bCvpYd4C2t/IFd5JvPMT JxIfypQ7r4cWht2mMxiTwtwTV1Cs/q8wjpirDqjSFsn0WYPqFFYRW3PvPAe5XesIF2JE +JXg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=9fEorODw0prngKGvWe8LjMgb7BbQnuD2gvb64lkzC/I=; b=zBEcSv13OyfQ0ovvZnGrIgoVWygHUb061aMhBsGTMF5DTAiAJrf+Jq7xPCHpMOOHCw l78giCgaMtMpIivKTbzn7KFieTiyXrCbMjEj6dPdjnAhs3lmc22uPrMl6vwaGLJ5chHj wOW6k5smDMekAKuFaZFpcl6WCyFJjINRfMMcrnTf9guAk/LtnMsRLn6q/ivIExnJ7Wo9 d3UZc4ZP6JpriVM5Nuli/XfWz0wOugxO7Q46Uff8BVdqZKUAdx06FfnCm/kwiS0b1uy/ 2BHI6Fzr1RI/k9dkdNYnUpDLM1tUw7d6O/nzM2bDzcXCYrl5FEuhJdFOUcSzKZ/Li7fz qzPg== X-Gm-Message-State: AOAM530Af5OrdtFV3KFBcY0/+AEUs/Bwc+AwCscWQbhTHhSGaQpj7cAg Ut7w9DsNM+tKgp6L+L7I6JFEQg== X-Received: by 2002:a05:6000:389:: with SMTP id u9mr45304855wrf.22.1641392114578; Wed, 05 Jan 2022 06:15:14 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u3sm53205743wrs.0.2022.01.05.06.15.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jan 2022 06:15:13 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7026C1FFD1; Wed, 5 Jan 2022 13:50:11 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 26/34] linux-user: don't adjust base of found hole Date: Wed, 5 Jan 2022 13:50:01 +0000 Message-Id: <20220105135009.1584676-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220105135009.1584676-1-alex.bennee@linaro.org> References: <20220105135009.1584676-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::435 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, 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: fam@euphon.net, berrange@redhat.com, Richard Henderson , f4bug@amsat.org, Laurent Vivier , stefanha@redhat.com, crosa@redhat.com, pbonzini@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , aurelien@aurel32.net 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 Reviewed-by: Richard Henderson Resolves: https://gitlab.com/qemu-project/qemu/-/issues/690 --- 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 &&