From patchwork Wed Apr 1 09:47:53 2020 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: 185135 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp329813ilr; Wed, 1 Apr 2020 02:49:48 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuoI0i+TuaGsk55DtVr1dqqgrtTwIep9VXiubNUoiZgJzTBaKH4btFo6CXTerITqBJ0fEDS X-Received: by 2002:a0c:fe04:: with SMTP id x4mr20793000qvr.69.1585734588652; Wed, 01 Apr 2020 02:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585734588; cv=none; d=google.com; s=arc-20160816; b=jzHbf4OjpC1AR1bws4/GTsBT1wfK/2qntQxnftPee23WKDI6ixhbxubXTp2Nye4n5a 7RZlPn1M6uk8NOqlQpYIKrHflbvyYR0H1+nfi/K5skncmeyOQU17z0VKaLT4F+1zOvuQ V/9Tf5YGAQX6Z6tZWs1zu7zeR77J2zYwj88GaGZlkRwpcsfHvt+8vGJNyuFXHhlV4QmI mrPkFlTghsQP3URt3HPugniLquAIRNbgTigRgTHUxZNqfPuvHguOTF7x2287rBzTxLCE npEYKabmoW6wj4jAEUzRXv98jlOwdCj7LB/prmHZiXyFBGdbaW7r+9N3+xRTuq9DxWn8 og+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=L6skE25jv77X3Ic3q30MQuACWpAXjktUtUIdWwwluKc=; b=riMwtk1H2wsnYgevFyWPxi9JewosiJEN/jC29P0gqihIKf7jPJ99Ga0L8noszm+KS2 0UbMb8cPAKHDzGwoJjV9pdg+lH64noUf1HTWSfCRkqoBdTIXmGlDni/lchLWpLMzVa4i w304TaYTzUBiAqDlFHuPRyqjkuJKNgOlXVDT0yEjiki3Ymz9B3aE8pdI+bJs88aSfgl4 DVMbBIIK56qkT8BHMT1WEdrxVsgFs2f3Tf/OZ7v9gfn/1QuVtPejgjb45FUmkHFkqCPS 8r3PHU3+kqBHV/sa2E4TVwJTszkdeeMT9w8x2CDn8Igg2aieaHjDOAjOc5hUnRldZwDN odew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=qaddUt6g; 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 w6si820828qki.311.2020.04.01.02.49.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Apr 2020 02:49:48 -0700 (PDT) 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=qaddUt6g; 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]:57238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJa0K-0007co-5u for patch@linaro.org; Wed, 01 Apr 2020 05:49:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38431) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJZyj-0004FR-G0 for qemu-devel@nongnu.org; Wed, 01 Apr 2020 05:48:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJZyi-0002As-Ed for qemu-devel@nongnu.org; Wed, 01 Apr 2020 05:48:09 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34653) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJZyi-0002Aa-8Z for qemu-devel@nongnu.org; Wed, 01 Apr 2020 05:48:08 -0400 Received: by mail-wr1-x442.google.com with SMTP id 65so29784059wrl.1 for ; Wed, 01 Apr 2020 02:48:08 -0700 (PDT) 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=L6skE25jv77X3Ic3q30MQuACWpAXjktUtUIdWwwluKc=; b=qaddUt6gSnfHtUbqDT8fOIjsUNFsxdg2jY032MjTS8Zc3Fkzy+uCiHF7IUyOY9TT3P igJF8E+F/vNAOD5so1Q7I3sFuMjso/YvUBbU65qpg00cGmcXqGd1VIsAYOPZ53kxLa66 Cd6sjMit8Hcqofi+3GCryuvhPk39ryUd1lipzLvF5qCy1GdMF7iPjHd9rkRKoUQonGff eRe8lUfhNphDBBQpUXM6Bsqh818DS9SNjBcdjs1JyC9Xa0eGsz9mrcBnzGvShrXSI4Hg Gxxh6ZsPcrAo6vDmJ7jTWLNtEMyWwLb8aCukw4rl7ZNRFbovcwSU6OBVQ5AJZuAH0D3N ++Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L6skE25jv77X3Ic3q30MQuACWpAXjktUtUIdWwwluKc=; b=tBDwtU53SV5LH9pNvl9htFCqMrONxelXQgy86LeBMif1zjbX6zBMWUhgoPP8Amf8na q6SnKcvyQsactUU5L3E+aNZLaH/FateBal+Eqaerj8QkJpS6/0wZtXzAyJXo9XG+YL5r Pace7b2+jy5BCASy2t0onTX+xqTMHZAKGyUqMVs4Muh4pMYzqaSPJJhaqLitpBcMP3vC dPJXMIE3QWd/bsI7+WuQXCxOmxmpMnyC1XfPsHkBtUJffZ+bLzK0UKO38ptNhbgJbGz8 a2PT/SDocXMrjoAOok3zSqTpaK33sYIKNqnlBOs8tav0znd6R0bntmFoq1K3DEs/j3Up MH/Q== X-Gm-Message-State: ANhLgQ1KoP9b3SARGrAZJz+EEGbnZWm9vDt+PUhEnQJ/dLgLI52WBtlO pqmG2oCvL3U7QYihZitRw/sXTQ== X-Received: by 2002:adf:fc8b:: with SMTP id g11mr11313672wrr.51.1585734487218; Wed, 01 Apr 2020 02:48:07 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id b82sm1073589wme.25.2020.04.01.02.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2020 02:48:03 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 933431FF90; Wed, 1 Apr 2020 10:48:00 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/10] linux-user: more debug for init_guest_space Date: Wed, 1 Apr 2020 10:47:53 +0100 Message-Id: <20200401094759.5835-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200401094759.5835-1-alex.bennee@linaro.org> References: <20200401094759.5835-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Searching for memory space can cause problems so lets extend the CPU_LOG_PAGE output so you can watch init_guest_space fail to allocate memory. A more involved fix is actually required to make this function play nicely with the large guard pages the sanitiser likes to use. Signed-off-by: Alex Bennée Reviewed-by: Laurent Vivier --- linux-user/elfload.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 8198be04460..619c054cc48 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2172,6 +2172,8 @@ unsigned long init_guest_space(unsigned long host_start, /* Check to see if the address is valid. */ if (host_start && real_start != current_start) { + qemu_log_mask(CPU_LOG_PAGE, "invalid %lx && %lx != %lx\n", + host_start, real_start, current_start); goto try_again; } @@ -2240,7 +2242,11 @@ unsigned long init_guest_space(unsigned long host_start, * probably a bad strategy if not, which means we got here * because of trouble with ARM commpage setup. */ - munmap((void *)real_start, real_size); + if (munmap((void *)real_start, real_size) != 0) { + error_report("%s: failed to unmap %lx:%lx (%s)", __func__, + real_start, real_size, strerror(errno)); + abort(); + } current_start += align; if (host_start == current_start) { /* Theoretically possible if host doesn't have any suitably