From patchwork Wed Jan 12 11:27:17 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: 531583 Delivered-To: patch@linaro.org Received: by 2002:ad5:544f:0:0:0:0:0 with SMTP id a15csp4312431imp; Wed, 12 Jan 2022 03:55:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJy85l/HSUDTPtQkMV6KPGal+KyPRAHblFwTvHXv4hDvMoLv5JcvzzZf1zE+TINQ7uTpTVdx X-Received: by 2002:a25:b992:: with SMTP id r18mr11971780ybg.679.1641988517609; Wed, 12 Jan 2022 03:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1641988517; cv=none; d=google.com; s=arc-20160816; b=J6JS6ZhTgStisAXE1pcP1Mk5zyzPIJVxDIapmTgvZO+wE64ZNyubSEuJXVr1aD3w6Q M+GVp9z7qup+MT8GG53AwQxa702k/iMzI6jv8i4Qs1XaE6LNDFhQJh1WUsyabkn8wGSr rfbDPIjK9J6g0vZEOrp5EIn7v8NWaBeRaTos2nje+K9ELfwJFWVwtl0h5cjVzaOqCO1W 4aPaGTIGvyecLBpKlDedKjrtdMtEI2WmoFp0qi9QiDmV3fYLp0MUVaMXVtgqrs+AB5QF eaR8TiksCPrqfi9FFII8UfNV+XAFtQVfIXgk+zAOKrySLBUF7KttoxEY8Gv93iiTGN4x NjNQ== 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=WVQWEwB7DW0S7EcK0bMuECSnyWWWVwcHAm+O9XR3q5c=; b=twORNuSx+cqikgqViey6rpd2Y/PgEDDQc0WcfjrMfZmMXIa2I0K8gFBXyfcOiLcnSt PjoDzAcmP5CQ74Z2xDfkOYAJapgiMU9U4n+e/MNWlJsL453dzQild7x1odhZ2LaDi655 OpTPK88asvzCxECBcMWgrpwil8NWb4Lrd9LRrNUdbGEo+dohz2YOKtcBw7dv0bqUPkrM ILS5Px28CV+wc/+QAxDGLLUUjqaEXvFgWo3OslOksIKbWP04fAIEMPz7lPK6AebCteSr wlK2725Yc/fz8HTqZVPOOr/WtFF6wtQGIQPFy2qe/Xr6IzbdPXrNpHDwgBzm7XkIjtph WIag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YcEMhx06; 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 w67si9909534yba.332.2022.01.12.03.55.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Jan 2022 03:55:17 -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=YcEMhx06; 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]:36400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n7cDj-0001cy-5m for patch@linaro.org; Wed, 12 Jan 2022 06:55:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n7bvT-0007dD-RN for qemu-devel@nongnu.org; Wed, 12 Jan 2022 06:36:23 -0500 Received: from [2a00:1450:4864:20::52e] (port=46770 helo=mail-ed1-x52e.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n7bvS-0004kN-9e for qemu-devel@nongnu.org; Wed, 12 Jan 2022 06:36:23 -0500 Received: by mail-ed1-x52e.google.com with SMTP id k15so8590732edk.13 for ; Wed, 12 Jan 2022 03:36:21 -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=WVQWEwB7DW0S7EcK0bMuECSnyWWWVwcHAm+O9XR3q5c=; b=YcEMhx06TnrXme5oeVI0TyFYTBnMhT4oyza/kS+ye3mCfutjZlduiKOAKlwKsxMpOX eGFiD0vtJArC97yyKz5iDceQw83EKEyCC4/8T623tTbyjzpe7QKJqSkYY41HytgGPOvy KA3MHa9JOkFFv+taGHiGNK1jiirv5YRPP1aVsguw6W9zxUCMjGKua1954AqFX5ai9eKR f55mZDT0TkuBrY+pNY+Xk3bB4VNsAarUqgsvyttUhf7yZcNIiqc/3EZzpiAnF+l5deMk a+BLohymcQp3fgTy+RU/klAOaiXm97msD1SqxaTZ9f5+1zxMYLR8NTdS+ouejIqBvmBu QAdg== 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=WVQWEwB7DW0S7EcK0bMuECSnyWWWVwcHAm+O9XR3q5c=; b=OETwXQnXVcrShViGC6nHMaj6jqqKhiSELABtXfoHQwSJLM3OwY3Kt+kdidEeHmLtqp rAK6datBJTpm5GgnZOirFLvMgN3EFabuxQl5ZtQaKLBCx7ZQgOfLzOirKMdH7BLoTcQv xe+UY1KFIsl+tEQWFmYxV80B0pS5cE9EiOn9A3+b0q9/k0kshcvDM235UHst6Ogp+tpL U3TmliRcAenpDpm8sh03rQTl55gitg8wB2155wavvSBrmRr7JpuwFFbFEtPlOJfr9cc4 T4Q+lpz4mBBXjNc3K+niOmJzneEsApEclsWDy2K03uATtPDWTx3i4GLhRocuhCq58+Ck 6iGA== X-Gm-Message-State: AOAM532L+EsrK5/d3cz/WI5ueHKOnNphHxFvgMQNzC5Q5BOtO+ArvRGv +XqH5A5X/1sRVkmZOS+GGm6SchSHNKngng== X-Received: by 2002:a17:907:6d1e:: with SMTP id sa30mr7420694ejc.1.1641987381027; Wed, 12 Jan 2022 03:36:21 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id j11sm5978319edv.0.2022.01.12.03.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 03:36:16 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A333E1FFD2; Wed, 12 Jan 2022 11:27:24 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 26/31] linux-user: don't adjust base of found hole Date: Wed, 12 Jan 2022 11:27:17 +0000 Message-Id: <20220112112722.3641051-27-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220112112722.3641051-1-alex.bennee@linaro.org> References: <20220112112722.3641051-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52e (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52e.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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , qemu-devel@nongnu.org, 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 Reviewed-by: Richard Henderson Resolves: https://gitlab.com/qemu-project/qemu/-/issues/690 Message-Id: <20220105135009.1584676-27-alex.bennee@linaro.org> diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 8ef0626eb0..cb2f01ff01 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2339,8 +2339,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. */ @@ -2380,7 +2379,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 &&