From patchwork Tue Apr 7 15:51:10 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: 185245 Delivered-To: patch@linaro.org Received: by 2002:a92:de47:0:0:0:0:0 with SMTP id e7csp5013425ilr; Tue, 7 Apr 2020 08:53:36 -0700 (PDT) X-Google-Smtp-Source: APiQypJ7lwNfBPfPHuDu5souodK0UWiSC5aQ5/uyS6VFh3r6BYBwj8Kcto3/mGoC8mbxPsQrjV8R X-Received: by 2002:a37:a3c1:: with SMTP id m184mr3080390qke.352.1586274816068; Tue, 07 Apr 2020 08:53:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586274816; cv=none; d=google.com; s=arc-20160816; b=gHLpSfh9AIqgw7qnIHpU9DVDvOA9KJJIod4ZlLYB9/+XUogm/FuRbEwm/moydtKdd+ bE0C7GTurI+JwswR8ppm6Djx8y01V5R3lT9ZmaDkksNLsoTzvOFUdMQXU5d/TQ+NLUKv WVk4MbQ6uAW5qpxyYlIvVycGMJ57wlQiLyEux2hXOt5M0N4tKPQCNtfxeXrlQFfnE1yq sxfKOJxYO20d3SR6c+dpA0ZhVAwSliJ8DWbc22E9u6YagKv3TXBrdEIht0Ag0ZkJyXQy U7x3ZWaGv7lRzGDNp7ve5PfAE58WPv9fTpA/pP96zzuz/ewaWFXGz/n6jf9ELswJ+a5u BYvg== 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=knuvWGJJjL2l+VM/Pu56sYdaHUVTSyIKJQEQhEZXCg8=; b=mBkoGE07+ovrENNIspElhhxhAecTK1wab3SmahBF9uNPsPpC1KxteIywnOFYVPh2Ls cGyDUPe60MLduK17lAwV5FAWuGrsAOlQkImTXdNEYyVr3RANiBXWqxUrtU47CyXSTWxk AeNdrAFLzvrUfOjNM4mbVXNE+Kh4soEcUqFzVxHNMFmA1diqpjFiLI+FTqbmHc1SGRWE oAga6QL+ZWWUpUHGubNaWs9uYclz4uC/9YqCVWTriHG4G7eff3tMacoBH7cQKPU3mfSu y9gnkEKEX0QZSs8TiKAMfF+JRax99oInXMUBGWA7zlgB3X8ahfREfdP/qYxrst+NHPt0 hspg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sr4j9s1Y; 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 n21si430489qke.228.2020.04.07.08.53.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Apr 2020 08:53:36 -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=sr4j9s1Y; 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]:49672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLqXf-000726-Hw for patch@linaro.org; Tue, 07 Apr 2020 11:53:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43667) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLqVe-0003TC-7A for qemu-devel@nongnu.org; Tue, 07 Apr 2020 11:51:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLqVd-0004LX-4b for qemu-devel@nongnu.org; Tue, 07 Apr 2020 11:51:30 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jLqVc-0004Kw-Uw for qemu-devel@nongnu.org; Tue, 07 Apr 2020 11:51:29 -0400 Received: by mail-wr1-x441.google.com with SMTP id a25so4514848wrd.0 for ; Tue, 07 Apr 2020 08:51:28 -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=knuvWGJJjL2l+VM/Pu56sYdaHUVTSyIKJQEQhEZXCg8=; b=sr4j9s1YKOZfp2w+RIR3IaPWFx9+8+LQBxRZ4/zmJR/U78j8z/xVZYAgcrc1reyWZ7 v1MHYYmNnJoPzIjwV5PQjh0dvFj+uL0XOxoeY8h/3aYyzVmKpMZJvn4UbRLiEkTPlOws LitRB9IrJpeM2a8yHRhlreW0lWvrBWSLbsI//ZF5qL2Md6a/SqGJW4pkM1W1ch386eB+ P7XwxF4cy4jwZEmCe4RAJDrr+GV8VKRjsXkxAALsbQ7bbvMjOt/XfhsylbEdCHsbbGgY pLCmFPDaeRBNIlIwTzpbCw+7OXKSlkEKZBwjqPdAeHn2t06DQD2jwjjUuvrrsGahhDAF kCsQ== 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=knuvWGJJjL2l+VM/Pu56sYdaHUVTSyIKJQEQhEZXCg8=; b=JardRk4uvRaV8Nxic45LDUpwMZsw3BlDP66QWkfT3VBKc7XRIzagi0kEy+s/GvZsnZ 9vexZqw7fRr5G/qK/RzNqBvgOjm9uDWunrD1Ys1gvYd8PYuVv5ep2TAW2jdk4rmYBhVO vXbYKZMTAFG7U5w5snjKxzx4ZTEIFHdN6OeqwKXSexmgwOutY2/5Qy0JCMZY1yINs5Oz gA2O6wXHlSWR3i7+ONYNQTeNgVppDWDH4mf14Fln877L4Mx4flt/xTus4p5uu6BSLnt8 p4vfCp8LSgV3c3p7fXctVNhJBWk2NX2FoEJQOhr/7TpW0sPsVoymJAoNCIYUcnXIkKVx tYiQ== X-Gm-Message-State: AGi0PuZ0xoDpdznT47ZEuShaVEAHZApDik46OAMDD07oGz9B6QQVwn7K BZKw5sxQKf+m2SgLN2LSijZsXA== X-Received: by 2002:adf:c3d0:: with SMTP id d16mr3664143wrg.180.1586274688050; Tue, 07 Apr 2020 08:51:28 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id m19sm2755823wml.21.2020.04.07.08.51.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 08:51:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B392E1FF91; Tue, 7 Apr 2020 16:51:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 05/13] linux-user: more debug for init_guest_space Date: Tue, 7 Apr 2020 16:51:10 +0100 Message-Id: <20200407155118.20139-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200407155118.20139-1-alex.bennee@linaro.org> References: <20200407155118.20139-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::441 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?= , qemu-devel@nongnu.org, 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 Message-Id: <20200403191150.863-5-alex.bennee@linaro.org> -- 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