From patchwork Wed May 13 17:51:25 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: 186677 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp670555ilb; Wed, 13 May 2020 10:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIgXhszQa55gn5Ds5RxSZZ8ULBr4CejOk/PqiKPvIu9ez54dawzoheGoFCVx7ZWjqquEMN X-Received: by 2002:ae9:ed95:: with SMTP id c143mr880433qkg.314.1589392465893; Wed, 13 May 2020 10:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392465; cv=none; d=google.com; s=arc-20160816; b=RGS0WID9rOP51VLPA1/dZg4XuI6PIShLbm9O7pK/hpsqKo83B6XphF+B3ytnDXxHyE 7VJ6ahdLZR+Car4Up+5POBf2cSKhnTUKGGu1RCqpeYepb6Ekm1LHDz8DSABqyhVkqF52 7ev9v+FcXFluSh5Ro/UBP2jjgkT1jVvkf1iocb+yz2BQsfqrV+zRd/hm5KKnLz0+bHYC DPSHOPHS0d190HW06R3pFU5XuHUV22YrqYC7nhRp5vDBYwP1baTL4ajLuGM5S9AXfV8U fhUhNQD5dgkfGBzV13jtqpSZSBluVHdqQ7MhzQRaRgBa5G6LjiRkckMv/cVHqRzge4C4 qtcA== 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=yZ7Kz7mTKR6F85RFkM8gYJqayYGL/UEHlzggZx2/D6I=; b=mtDiWwaTkzxx25JkIIp+e9Giyv/eeDCvOuQvJhPsuqRHe8LcG3MwGZyPvtDYc+XiQY 1TpNyK9NRsNlzilH4F97BSKNR2mMaiNbvtyDw61I6yVtmk23EkJhL9ZDtuMBBvhtfuw6 BFZeOaL8V5u3w0IlN5IfljZHV2/vp7blvA77LfsN2piRsjR11pgER2azCPy/+bgZ1Tbz Stv6qAyke2oXqpvOw46AlTCDDASgAi7H553DumCaOUD6xA9YRriWHhuhZEsGexrLgwtW ivD4Bx1RJCVLeAFKvmpgv5T+qIyfJe9dh50PcFqC+6KcDS78PJOHoXvpiYLXWL4sg/V9 A/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Hewj1P5T; 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 d18si105719qka.110.2020.05.13.10.54.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:54:25 -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=pass header.i=@linaro.org header.s=google header.b=Hewj1P5T; 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]:48850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvaL-00045g-Bz for patch@linaro.org; Wed, 13 May 2020 13:54:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXh-0000jS-H4 for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:41 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:34151) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXg-0004xc-Ci for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:41 -0400 Received: by mail-wr1-x442.google.com with SMTP id y3so567639wrt.1 for ; Wed, 13 May 2020 10:51:39 -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=yZ7Kz7mTKR6F85RFkM8gYJqayYGL/UEHlzggZx2/D6I=; b=Hewj1P5TdhhgUKPudvdnzaBTw1wD+rS6hItKNQ+o/MlUR1xpwEtapYYZvzP2ha2udC P8GGrL7w6Iulx4T42llediNkBOWnWn0S3HBHBCJuGS+QeLWQef5e0x0xUVbjk5mfmwEA xGJ196Hizcgsw2QldS34Et1VGioPsW/VuoYn9r6JmeSLwiiZymeNEenykwfOkunEyGnP 4PS9gvoLMiIcvo3+lBbWBCW5gHi/RQStGJ3tgvJ2wHPt5WCqlwQv0xx5oOinppV7288g 3aLRK6lPrggMTrtadLk5v7Put1Boy75RE8qI0hWkch9r8qvdMnIfMBxITBdw0BZm6Zwq Eb4w== 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=yZ7Kz7mTKR6F85RFkM8gYJqayYGL/UEHlzggZx2/D6I=; b=CpnmXl2cBCQb7RqXUX5YCqAI+7LFCH2XLmEbVtQ7KbhDCqwiK8cHffAEnrcxgGXCO+ 6PB4mIWI45qF5xWBWWOPuKbEsYo39TQhwWnGxD3IPxAKHwk1pe5PnLNLxtrhgA2CI9/Y HZsDfvnx8mMeT3UUtOJUlaiJ/jYka0k6aREqCBHkUlmK35HOtWmEdm5l4mCJcq7TNG8u 76svRZew6dEgYoZNBYKVXD+cBfR2ISuXAETJPGZFKtnEfmbwH424XHE91vjFqIex6ORd 36TWIM1IIjicxinjKm404D4kmlsA5l/tB/1bA+03xaynXZHpemf3GQOPgJ/9C/uLGqpO NDug== X-Gm-Message-State: AOAM5300fVovLcGFrUicBHTadJKeor5k8PqitmA9UwzpAmps8hBevqKB STXzBcf7wYx7vNZmomhH2uV/NQ== X-Received: by 2002:adf:dfcf:: with SMTP id q15mr482206wrn.137.1589392299029; Wed, 13 May 2020 10:51:39 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q17sm19462878wmk.36.2020.05.13.10.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E21DB1FF87; Wed, 13 May 2020 18:51:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 01/10] tests/guest-debug: catch hanging guests Date: Wed, 13 May 2020 18:51:25 +0100 Message-Id: <20200513175134.19619-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" If gdb never actually connected with the guest we need to catch that and clean-up after ourselves. Signed-off-by: Alex Bennée Message-Id: <20200512104338.27365-1-alex.bennee@linaro.org> --- tests/guest-debug/run-test.py | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py index d9af9573b9e..71c55690546 100755 --- a/tests/guest-debug/run-test.py +++ b/tests/guest-debug/run-test.py @@ -80,4 +80,10 @@ if __name__ == '__main__': print("GDB crashed? SKIPPING") exit(0) + try: + inferior.wait(2) + except subprocess.TimeoutExpired: + print("GDB never connected? Killed guest") + inferior.kill() + exit(result) From patchwork Wed May 13 17:51:26 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: 186673 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp669137ilb; Wed, 13 May 2020 10:51:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjG+x3sbdE67sCDEpGCWg0hBCAJYHbE3h4r0tLBUqdDd9EEDddkhOGiidk6kVeeOMEoC71 X-Received: by 2002:ac8:27ed:: with SMTP id x42mr266978qtx.231.1589392318024; Wed, 13 May 2020 10:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392318; cv=none; d=google.com; s=arc-20160816; b=QSkBtEFG3wpBrk4ytl24zVaL/BmQyUQ/UGGKyotrIVHyBNH9LuQIYQ3rPTZeQnvmnr G47BZV1Na+g0YJ/zLj0/yIGIPrlorpD0glF6D/MFAFif5KrNGuO9Z60YyLxLH+JLg+Ry MI8Kin/VWkE89yKVpVhQIddCkjCXiQW+xWG7PeeB/FGNh51Jrb/s7/53d1Zhiz6CVahq b6jUeXjzNLAhPw3rkLVI5+MMtzBcYTIk22ct3c6myvWZk/cHGqI3cS96+rweQ0tCCVBq r6wQhZlqAGzr7M7jqwNKDW4aOYAGuv7HgJQ4Rc8fjdm58wcTZpH9/e/aJUoS1Pb1QfZe ThAw== 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=HFDLFAKOqzqDM16uDgH8kQv5arlsfvslWta0/Fd6rk4=; b=PwFeduW6ebpYUskWtNmrUjoq9O1wzfR+gn1R2VJFM8VMO5dMyQ+lg9I8EQMC3YyJIJ CWJ81DdmFh18znkpHTwjB8SZ9Y9WSfD8k5JcF9+MwFJfDkCDjg/GvewBYPojay1V453G OS3s0hy5rIyDAmRsXvBXZ9df0DErFHiVFxlDwPrB7eO4t2bqgz2A5SpK9vmilaFSsibi mp8nSMGSDlkgFpYA6pQ3IZaKpu+6jCSOI7z1/oG5MnvhOdMsrWlovgklHXOfu/nA0pEU xWGEfILr7RS3OXwDwBDYyZq21L0VHn0k4sXTBCsRtOLuPBlDrwDew8m5zvRokPT/mj5Q TWbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FdgXZ2PP; 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 w9si269604qtb.187.2020.05.13.10.51.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:51:58 -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=FdgXZ2PP; 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]:40810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvXx-0000jh-36 for patch@linaro.org; Wed, 13 May 2020 13:51:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXg-0000jC-CL for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:40 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:39574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXf-0004xN-GS for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:40 -0400 Received: by mail-wm1-x32d.google.com with SMTP id y24so29581936wma.4 for ; Wed, 13 May 2020 10:51:39 -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=HFDLFAKOqzqDM16uDgH8kQv5arlsfvslWta0/Fd6rk4=; b=FdgXZ2PPep7Gw/rPsOqbqlantISX5CYa3goFQ7oYj3/KXa3OMC24rnfaVSjU/CHNdl rR/bV5Dl6f6JNkUTheYRXmbcwm6EeG9yBWSIcvS+pWFkJVbwzbIPFUocjE8+SLhjGxzJ BT3JWyBjrXaxB+CrjQKT+ysvmO8ctZoZalbPPSLZGvRx4wmHHFCnYgZ2OAh9qQA8kfLg GsP/mHOs+QF7bgradK0Xixqr6Iu3cQrsZqERbb4Sh359Rr3gqSg+44vS4bBdwH9Hvnh8 o7kh18Jkp2X1DZmvOqED7ybrH82JpgfG186z866ckST0H1r38YpanMGWLElHXeE7GbZh chhw== 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=HFDLFAKOqzqDM16uDgH8kQv5arlsfvslWta0/Fd6rk4=; b=i2/ba3oWihmIP+DP56XcC5R/bxiAX7KkUq5A26VW2UNy9U64iNfjSHHzzo420zH1nM bDfs9gYwoXI3kmKfCtavPA8BreGZAmzt9/HMHpUG2fIbBGh9eqmUK6imu27pp2EcXMrf JElq5JKk55KRzx2O3GimBpY309Fqw5nbgo4ZMfUfEQHk20hckMIQ2W+R34ib3yGZ/OVL my3XXh7PX2W3tX0soDfgjdH1PQelP7SozL2EXENqzmrk/py+xu/OAx6T+rxi8SP3Q1BG syr87UvWt93pKlacadziwvefvYxbfzLvVH/kNvMOys8hCreLLg4xDEbuNshLlHGazbbZ gDvg== X-Gm-Message-State: AGi0PuatJcbqlc9A++zV+/vAgtu8E9rkAzZh9xivXAj6xkfOSALhrgJG qYuBq6nzF+9TAPe0zt6z5bwI8A== X-Received: by 2002:a1c:5988:: with SMTP id n130mr34162317wmb.187.1589392297948; Wed, 13 May 2020 10:51:37 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q17sm19462879wmk.36.2020.05.13.10.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 02B8C1FF8C; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 02/10] travis.yml: Improve the --disable-tcg test on s390x Date: Wed, 13 May 2020 18:51:26 +0100 Message-Id: <20200513175134.19619-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Fam Zheng , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Cornelia Huck , "open list:S390 general arch..." , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Thomas Huth Since the s390x containers do not allow KVM, we only compile-test the --disable-tcg build on s390x and do not run the qtests. Thus, it does not make sense to install genisoimage here, and it also does not make sense to build the s390-ccw.img here again - it is simply not used without the qtests. On the other hand, if we do not build the s390-ccw.img anymore, we can also compile with Clang - so let's use that compiler here to get some additional test coverage. Signed-off-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Cornelia Huck Signed-off-by: Alex Bennée Message-Id: <20200512133849.10624-1-thuth@redhat.com> --- .travis.yml | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) -- 2.20.1 diff --git a/.travis.yml b/.travis.yml index fe708792ca2..1ec8a7b4657 100644 --- a/.travis.yml +++ b/.travis.yml @@ -502,9 +502,10 @@ jobs: $(exit $BUILD_RC); fi - - name: "[s390x] GCC check (KVM)" + - name: "[s390x] Clang (disable-tcg)" arch: s390x dist: bionic + compiler: clang addons: apt_packages: - libaio-dev @@ -528,21 +529,10 @@ jobs: - libusb-1.0-0-dev - libvdeplug-dev - libvte-2.91-dev - # Tests dependencies - - genisoimage env: - TEST_CMD="make check-unit" - - CONFIG="--disable-containers --disable-tcg --enable-kvm --disable-tools" - script: - - ( cd ${SRC_DIR} ; git submodule update --init roms/SLOF ) - - BUILD_RC=0 && make -j${JOBS} || BUILD_RC=$? - - | - if [ "$BUILD_RC" -eq 0 ] ; then - mv pc-bios/s390-ccw/*.img pc-bios/ ; - ${TEST_CMD} ; - else - $(exit $BUILD_RC); - fi + - CONFIG="--disable-containers --disable-tcg --enable-kvm + --disable-tools --host-cc=clang --cxx=clang++" # Release builds # The make-release script expect a QEMU version, so our tag must start with a 'v'. From patchwork Wed May 13 17:51:27 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: 186680 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp671322ilb; Wed, 13 May 2020 10:55:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnyChhotkfuL6QX5u3sfAZL1EwQbHsXP901weg3GVp5O2HhG/ijDj0qBiGjEYaNBDQLswP X-Received: by 2002:a37:f517:: with SMTP id l23mr873039qkk.475.1589392550964; Wed, 13 May 2020 10:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392550; cv=none; d=google.com; s=arc-20160816; b=errFthYzJTjtGFODv3ClRJLxAT6b5ecEEBW04RVNNqFVPgs57tXCmtHAalrtUIaYUX 7DCQmVz4maImhSrCUCd3GlFvLX0GXfMeEBETk1zs8OUKbkncyTENwIetLh/zG9enXi5u Yx5v8w4gGtVYL3J/oep0JVmmqYEy7Vet/3F7nVbjqo7xc0SkVJnIdjVfbxmyLIub0iEE A2geKo1fOq4q1ptHQS3Ljohb/0B6Zeg15OYBdcXUxoarMw1l3ZiVmfoDu16g3DKTMRkH kW7O+SGexpalXDZewJCeMpeiu1IM+pbTryC38GWhVyyZNe1hr+Ds8bQy4Ymp6oauHCNF P6dQ== 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=PSejtQaKsSmZz/8Wr+NX++8sCGeGvlfmEfdXWCygToQ=; b=U3tKCdO23PlGjz0RCA7+usyysWsvcJzuqfnXCl/px2Gme3ThjNYBMJKbL0V96ZMedx raG30CxMer+GpobAQBjP3JC15wxXykCPN83GRJd2B+2JUBh4X4Hw0tMA5275IMZ2Unrn qlKz8DsbZX6lgtATlM0xhyiKZeNIxr1e1ToFdzBWTLmR8NNYedIwhEVKu2Wzo/Vz6W8e nSVkZwINOz8NgKH6sP9XrmN3H7ckhZ2Reg0eOY2U7ig/D9Sueif3Qz6xUDHRE5AhOKfr q5B3uJKRX+xKZ39NmnOMSfxLA1mwJ/ORCDC4hPO67OW7S3rwEMRbX0Lbi9EWGpBH3Mgd mx+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EVmfn26Z; 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 75si120534qvc.160.2020.05.13.10.55.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:55:50 -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=EVmfn26Z; 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]:55626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvbi-0006sQ-Eq for patch@linaro.org; Wed, 13 May 2020 13:55:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXi-0000lP-J2 for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:42 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:33857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXh-0004xs-AW for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:42 -0400 Received: by mail-wm1-x341.google.com with SMTP id g14so12414459wme.1 for ; Wed, 13 May 2020 10:51:40 -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=PSejtQaKsSmZz/8Wr+NX++8sCGeGvlfmEfdXWCygToQ=; b=EVmfn26Z3z+7bUbRO5nloiuSx9YmvczUwFD4Y8avIreMZKTFK/HH0sbXIwERQgaO7g /u6zrH5v+xtwdim3Y538lL8wQUxo7WSUSTeEOJPFgo+0Wkndw4oKOiBvQt8PRfoNMGbX DOATXVaCK7uvx6vAdgG1ao+/9/xVUFawNtlrW/hADPYUMyT6nijoBCFgdOYLzJ4vKVaR dGRb6peCtmpsKPkuE4tUt5zHR2uLG50OCly2yNWj2Ep9YAiIML0x75fyrj5eV1nUX8+p h/HqoUeryo+1MBRZ0qscG9Xf7nh8rvNYwEp6fuEeWVFhcAmEE3YZLdR8XpNEp6zQmtxi rBzQ== 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=PSejtQaKsSmZz/8Wr+NX++8sCGeGvlfmEfdXWCygToQ=; b=BxRJZqOHra8ZJ/gF7Qfc/m9cO9gQHk+IM5l8qrI8qIJOXIgbV0zpSHAHp8ude1JliL 6bAR6ur6yDZ+W74MGww2y28D1PYcLcMfxQ4kSkE+exA4UUwKEAb9eUejkLzcAGXon61B CFnxt0/hVbmYs3CFkf2UWZjSn6z1kAaJH668o+nm7QWXr1+7Q5bsMh6VkxV4dK7KSYXG qW0AELGXArnyJM60X/9HxRfIljNJU2hbGwQtT2MC/xPqrq6Y+mXgWFwMQAxRDaqC1U0a aEP7PAZLSCjYGB7O3NbrP+jLXVJTsQq4zY16W0gv90NaEkHwPsHnDb+8sG1Il9TqGkw8 HYHg== X-Gm-Message-State: AGi0PuZACHkU6RC/Lct5sbC7aLq9uBgDJbQpx7HuraQ99PqE6eNRnJbb T+5C8EOBYZsKOinCn3/Az9hf8kLuYPQ= X-Received: by 2002:a1c:a545:: with SMTP id o66mr14712113wme.167.1589392299919; Wed, 13 May 2020 10:51:39 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id m7sm13722433wmc.40.2020.05.13.10.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:35 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 189221FF8F; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 03/10] tests/docker: Kludge breakage by pinning linux-libc-dev Date: Wed, 13 May 2020 18:51:27 +0100 Message-Id: <20200513175134.19619-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x341.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Christian Borntraeger , =?utf-8?q?Philippe_Ma?= =?utf-8?q?thieu-Daud=C3=A9?= , Salvatore Bonaccorso Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Linux kernel commit d5767057c9a [1] aimed to fix an issue with the swab() declaration, but doing so it introduced the BITS_PER_LONG definition, without using the kernel __ prefix, leading to odd failures in userland code using kernel uapi headers, such: CC block/file-posix.o In file included from include/qemu/timer.h:4, from include/qemu/timed-average.h:29, from include/block/accounting.h:28, from include/block/block_int.h:27, from block/file-posix.c:30: /usr/include/linux/swab.h: In function `__swab': include/qemu/bitops.h:20:34: error: "sizeof" is not defined, evaluates to 0 [-Werror=undef] 20 | #define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) | ^~~~~~ include/qemu/bitops.h:20:41: error: missing binary operator before token "(" 20 | #define BITS_PER_LONG (sizeof (unsigned long) * BITS_PER_BYTE) | ^ cc1: all warnings being treated as errors make: *** [rules.mak:69: block/file-posix.o] Error 1 The issue has been fixed in Linux kernel commit 467d12f5c78 [2]. Some distributions already backported the first commit, but still lack the second one. This is the case for Debian Buster. The linux-libc-dev package contains the Linux kernel headers. Kernel commit d5767057c9a has been backported in package commit 1fb0eb7956 "Update to 4.19.116" [3], see debian/changelog: +linux (4.19.116-1) UNRELEASED; urgency=medium ... + - uapi: rename ext2_swab() to swab() and share globally in swab.h The previous released update before it is debian/4.19.98-1, released as debian/4.19.98-1+deb10u1. We can find this package in the Debian snapshot archives, luckily archived on 2020-04-28 21:20:54 (see [4]). QEMU use Debian based Docker images for most of its cross-builds, which are tested by our Shippable CI jobs. The current broken package makes most of our CI red. We can kludge this by using the latest package released before the breakage. Do so by pinning the package version (apt hold), and using the snapshot archives, similar to commit b4048a7cd1. We'll revert once the fix is backported on Debian. Reference to commits: [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d5767057c9a [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=467d12f5c78 [3] https://salsa.debian.org/kernel-team/linux/-/commit/1fb0eb7956 [4] http://snapshot.debian.org/package/linux/4.19.98-1%2Bdeb10u1/#linux-libc-dev_4.19.98-1:2b:deb10u1 Cc: Salvatore Bonaccorso Cc: Christian Borntraeger Signed-off-by: Philippe Mathieu-Daudé [AJB: dropped pinning] Signed-off-by: Alex Bennée Message-Id: <20200513120147.21443-1-f4bug@amsat.org> --- tests/docker/dockerfiles/debian10.docker | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.20.1 diff --git a/tests/docker/dockerfiles/debian10.docker b/tests/docker/dockerfiles/debian10.docker index 0769700a416..58b23117240 100644 --- a/tests/docker/dockerfiles/debian10.docker +++ b/tests/docker/dockerfiles/debian10.docker @@ -9,6 +9,15 @@ # FROM debian:buster-slim + # Use a snapshot known to work (see http://snapshot.debian.org/#Usage) +ENV DEBIAN_SNAPSHOT_DATE "20200428T212054Z" +RUN sed -i \ + "s%^deb \(https\?://\)deb.debian.org/debian/\? \(.*\)%deb [check-valid-until=no] \1snapshot.debian.org/archive/debian/${DEBIAN_SNAPSHOT_DATE} \2%" \ + /etc/apt/sources.list +RUN sed -i \ + "s%^deb \(https\?://\)security.debian.org/debian-security/\? \(.*\)%deb [check-valid-until=no] \1snapshot.debian.org/archive/debian-security/${DEBIAN_SNAPSHOT_DATE} \2%" \ + /etc/apt/sources.list + # Duplicate deb line as deb-src RUN cat /etc/apt/sources.list | sed "s/^deb\ /deb-src /" >> /etc/apt/sources.list From patchwork Wed May 13 17:51:28 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: 186674 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp669244ilb; Wed, 13 May 2020 10:52:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx02lud7kT99SoAWWyhNxOPKuGeUgVrYc53IzYOHFslYZWdb+VfM/NZZWbnnrEfHZBj+2ma X-Received: by 2002:aed:24a1:: with SMTP id t30mr265853qtc.93.1589392325963; Wed, 13 May 2020 10:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392325; cv=none; d=google.com; s=arc-20160816; b=JvvLwIVI72jIEaBasBLIXMFzWGjqpMptmgW+zf8ZdifWG6871aoflmdkwE2OBBuaY0 jDiNZ/y4RmZAClZzGpqm3TpdRyWZGin/+B1TNq9bk33wqrzW3vbt8y+t66pFUrzlIqH/ ZQEsVM296TUg9IV1aC+V9DuOeg43dj4kd2+eYYwbbGTPJ15voe0mydawVXldj5wa5GV5 06Qbj4zTWi0rrMYkQ0UkHR73TwUjEkPCqN2Uj/0NB53kRLn1TG3Tx2jfMUwVlHSR1bTG GlFq6C597TowPXdDuClVJGOMjxOWFkvl2CYph9rEFk2J9/VIWmWq+WUu9Jx39qPGl8E6 7DZw== 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=+PfT2RtwPcawNcwL1qLwylzR9izb5vf8Hl8/JAptIBo=; b=Z87HEpSyA2ohZznFhrQZF9v0LCwV1gCFd5SEpgJKAvm5rBJOeMA+RNeu+X2g+P/xcC y0H3ivawXoO7DlciB6Peyv/5g5p96Emsn8J4xV3XDKpRkfLBXQyFxxKp7E44CeghnBKF 5i/NNvQluV7HeDiDPbpYMK2eT/d00vYvILPoF6Re4em1+TexRmMWiFfJpSNJ4TIcKmYr TJUuTSoIpX3e3o47l8VmXMnSdS+UMmKBztKgqkKseG6ZzdoXhnyuxW+Pf3bL1/m14nJz q8mPIraZOmM+JPbM0k+6sT31e9mAIoLcb6cD3kWbpGZASFEhKF8rwKHmoo9yggdSwBQN 60DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=mrWpv0qV; 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 e2si135178qvr.61.2020.05.13.10.52.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:52:05 -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=mrWpv0qV; 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]:41212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvY5-0000v6-EK for patch@linaro.org; Wed, 13 May 2020 13:52:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXm-0000sU-Qp for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:46 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:38961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXj-0004yG-Lf for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:46 -0400 Received: by mail-wr1-x42f.google.com with SMTP id l18so527914wrn.6 for ; Wed, 13 May 2020 10:51:43 -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=+PfT2RtwPcawNcwL1qLwylzR9izb5vf8Hl8/JAptIBo=; b=mrWpv0qVyNbZvoOoPHBHv1P4SMPLoFvRpwgff+jIDz3Jq73VKl7dWjF6ZSIClpxxOa ukKQHMbaD5H6JkI8nP987wwCnd6eYzoPoYEGLF0eX1MlV8ureX0v+XqUEb86tWinnlgw QCi6QcAnryXKxiaLcr1mSr28p5jy3iN7d5BJpaJDgnIsWvCnjjHZe35973wwjRUHWoeA MItV6FqFtgbPKCkBkpLExEVCtkC7e0+MhQiey+stNkWcSzawR2reqWfndJiC8AC1343o fQ2Z5FEgQx4K0S73GbqD7lU6o6vUM3Zei/vsBSm5V3m1/VMm63FBgEHMlv7QtJRfbWEe 7eVw== 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=+PfT2RtwPcawNcwL1qLwylzR9izb5vf8Hl8/JAptIBo=; b=iKG04LVeHBUWhtPVFIJn/STH/tkXCnjStuawvUtEpyaz3jmDxAEAINQ8nOb+ZyzGK4 /KgXzeIhJ4JwHTLDU+Yrx/fvY2C6X5CMESWT28/qWHAfpQ9fv6NoRF5RdbfQbjYgJpiR 8uffI7ofXbnedPO+rq7llMyiSj+93M+mZVd3wwmRYOE3N+sHcAgiIAaX5nbfsgEgG4GC LuUdYzmQHuyLcQgH+EtWx2MXj59AC+4dVtHAfuN3JibdtKDRV5EmiTnHImKdLx5ZZePQ iUK3znt2iggJbxHBqN0lIUCAz8tRiLA+H832HlLf4+J62A3+isVHx2JhJ+Pyqbjh4n62 gYbw== X-Gm-Message-State: AOAM531tqVC8f9kQE/T47wI/kQw8KiwsQX58HMQl4XK98Cr+D8h31sc8 XBncsHKm9sKFHUh6xSOzhLOmCA== X-Received: by 2002:adf:f344:: with SMTP id e4mr474971wrp.395.1589392301672; Wed, 13 May 2020 10:51:41 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r11sm25328908wma.35.2020.05.13.10.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:38 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 36DF01FF90; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 04/10] linux-user: completely re-write init_guest_space Date: Wed, 13 May 2020 18:51:28 +0100 Message-Id: <20200513175134.19619-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42f.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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" First we ensure all guest space initialisation logic comes through probe_guest_base once we understand the nature of the binary we are loading. The convoluted init_guest_space routine is removed and replaced with a number of pgb_* helpers which are called depending on what requirements we have when loading the binary. We first try to do what is requested by the host. Failing that we try and satisfy the guest requested base address. If all those options fail we fall back to finding a space in the memory map using our recently written read_self_maps() helper. There are some additional complications we try and take into account when looking for holes in the address space. We try not to go directly after the system brk() space so there is space for a little growth. We also don't want to have to use negative offsets which would result in slightly less efficient code on x86 when it's unable to use the segment offset register. Less mind-binding gotos and hopefully clearer logic throughout. Signed-off-by: Alex Bennée Acked-by: Laurent Vivier --- v3 - include rth updates that - split probe_guest_base into multiple functions - more heuristics on gap finding v4 - whitespace fix - added Laurent's a-b --- linux-user/qemu.h | 31 ++- linux-user/elfload.c | 503 +++++++++++++++++++++--------------------- linux-user/flatload.c | 6 + linux-user/main.c | 23 +- 4 files changed, 277 insertions(+), 286 deletions(-) -- 2.20.1 diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 792c74290f8..ce902f5132a 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -219,18 +219,27 @@ void init_qemu_uname_release(void); void fork_start(void); void fork_end(int child); -/* Creates the initial guest address space in the host memory space using - * the given host start address hint and size. The guest_start parameter - * specifies the start address of the guest space. guest_base will be the - * difference between the host start address computed by this function and - * guest_start. If fixed is specified, then the mapped address space must - * start at host_start. The real start address of the mapped memory space is - * returned or -1 if there was an error. +/** + * probe_guest_base: + * @image_name: the executable being loaded + * @loaddr: the lowest fixed address in the executable + * @hiaddr: the highest fixed address in the executable + * + * Creates the initial guest address space in the host memory space. + * + * If @loaddr == 0, then no address in the executable is fixed, + * i.e. it is fully relocatable. In that case @hiaddr is the size + * of the executable. + * + * This function will not return if a valid value for guest_base + * cannot be chosen. On return, the executable loader can expect + * + * target_mmap(loaddr, hiaddr - loaddr, ...) + * + * to succeed. */ -unsigned long init_guest_space(unsigned long host_start, - unsigned long host_size, - unsigned long guest_start, - bool fixed); +void probe_guest_base(const char *image_name, + abi_ulong loaddr, abi_ulong hiaddr); #include "qemu/log.h" diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 619c054cc48..01a9323a637 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -11,6 +11,7 @@ #include "qemu/queue.h" #include "qemu/guest-random.h" #include "qemu/units.h" +#include "qemu/selfmap.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -382,68 +383,30 @@ enum { /* The commpage only exists for 32 bit kernels */ -/* Return 1 if the proposed guest space is suitable for the guest. - * Return 0 if the proposed guest space isn't suitable, but another - * address space should be tried. - * Return -1 if there is no way the proposed guest space can be - * valid regardless of the base. - * The guest code may leave a page mapped and populate it if the - * address is suitable. - */ -static int init_guest_commpage(unsigned long guest_base, - unsigned long guest_size) -{ - unsigned long real_start, test_page_addr; - - /* We need to check that we can force a fault on access to the - * commpage at 0xffff0fxx - */ - test_page_addr = guest_base + (0xffff0f00 & qemu_host_page_mask); - - /* If the commpage lies within the already allocated guest space, - * then there is no way we can allocate it. - * - * You may be thinking that that this check is redundant because - * we already validated the guest size against MAX_RESERVED_VA; - * but if qemu_host_page_mask is unusually large, then - * test_page_addr may be lower. - */ - if (test_page_addr >= guest_base - && test_page_addr < (guest_base + guest_size)) { - return -1; - } +#define ARM_COMMPAGE (intptr_t)0xffff0f00u - /* Note it needs to be writeable to let us initialise it */ - real_start = (unsigned long) - mmap((void *)test_page_addr, qemu_host_page_size, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); +static bool init_guest_commpage(void) +{ + void *want = g2h(ARM_COMMPAGE & -qemu_host_page_size); + void *addr = mmap(want, qemu_host_page_size, PROT_READ | PROT_WRITE, + MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - /* If we can't map it then try another address */ - if (real_start == -1ul) { - return 0; + if (addr == MAP_FAILED) { + perror("Allocating guest commpage"); + exit(EXIT_FAILURE); } - - if (real_start != test_page_addr) { - /* OS didn't put the page where we asked - unmap and reject */ - munmap((void *)real_start, qemu_host_page_size); - return 0; + if (addr != want) { + return false; } - /* Leave the page mapped - * Populate it (mmap should have left it all 0'd) - */ - - /* Kernel helper versions */ - __put_user(5, (uint32_t *)g2h(0xffff0ffcul)); + /* Set kernel helper versions; rest of page is 0. */ + __put_user(5, (uint32_t *)g2h(0xffff0ffcu)); - /* Now it's populated make it RO */ - if (mprotect((void *)test_page_addr, qemu_host_page_size, PROT_READ)) { + if (mprotect(addr, qemu_host_page_size, PROT_READ)) { perror("Protecting guest commpage"); - exit(-1); + exit(EXIT_FAILURE); } - - return 1; /* All good */ + return true; } #define ELF_HWCAP get_elf_hwcap() @@ -2075,239 +2038,267 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, return sp; } -unsigned long init_guest_space(unsigned long host_start, - unsigned long host_size, - unsigned long guest_start, - bool fixed) -{ - /* In order to use host shmat, we must be able to honor SHMLBA. */ - unsigned long align = MAX(SHMLBA, qemu_host_page_size); - unsigned long current_start, aligned_start; - int flags; - - assert(host_start || host_size); - - /* If just a starting address is given, then just verify that - * address. */ - if (host_start && !host_size) { -#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - if (init_guest_commpage(host_start, host_size) != 1) { - return (unsigned long)-1; - } +#ifndef ARM_COMMPAGE +#define ARM_COMMPAGE 0 +#define init_guest_commpage() true #endif - return host_start; - } - /* Setup the initial flags and start address. */ - current_start = host_start & -align; - flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; - if (fixed) { - flags |= MAP_FIXED; - } +static void pgb_fail_in_use(const char *image_name) +{ + error_report("%s: requires virtual address space that is in use " + "(omit the -B option or choose a different value)", + image_name); + exit(EXIT_FAILURE); +} - /* Otherwise, a non-zero size region of memory needs to be mapped - * and validated. */ +static void pgb_have_guest_base(const char *image_name, abi_ulong guest_loaddr, + abi_ulong guest_hiaddr, long align) +{ + const int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; + void *addr, *test; -#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to map not just the usable memory, but - * also the commpage. Try to find a suitable place by allocating - * a big chunk for all of it. If host_start, then the naive - * strategy probably does good enough. - */ - if (!host_start) { - unsigned long guest_full_size, host_full_size, real_start; - - guest_full_size = - (0xffff0f00 & qemu_host_page_mask) + qemu_host_page_size; - host_full_size = guest_full_size - guest_start; - real_start = (unsigned long) - mmap(NULL, host_full_size, PROT_NONE, flags, -1, 0); - if (real_start == (unsigned long)-1) { - if (host_size < host_full_size - qemu_host_page_size) { - /* We failed to map a continous segment, but we're - * allowed to have a gap between the usable memory and - * the commpage where other things can be mapped. - * This sparseness gives us more flexibility to find - * an address range. - */ - goto naive; - } - return (unsigned long)-1; + if (!QEMU_IS_ALIGNED(guest_base, align)) { + fprintf(stderr, "Requested guest base 0x%lx does not satisfy " + "host minimum alignment (0x%lx)\n", + guest_base, align); + exit(EXIT_FAILURE); + } + + /* Sanity check the guest binary. */ + if (reserved_va) { + if (guest_hiaddr > reserved_va) { + error_report("%s: requires more than reserved virtual " + "address space (0x%" PRIx64 " > 0x%lx)", + image_name, (uint64_t)guest_hiaddr, reserved_va); + exit(EXIT_FAILURE); } - munmap((void *)real_start, host_full_size); - if (real_start & (align - 1)) { - /* The same thing again, but with extra - * so that we can shift around alignment. - */ - unsigned long real_size = host_full_size + qemu_host_page_size; - real_start = (unsigned long) - mmap(NULL, real_size, PROT_NONE, flags, -1, 0); - if (real_start == (unsigned long)-1) { - if (host_size < host_full_size - qemu_host_page_size) { - goto naive; - } - return (unsigned long)-1; - } - munmap((void *)real_start, real_size); - real_start = ROUND_UP(real_start, align); + } else { + if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) { + error_report("%s: requires more virtual address space " + "than the host can provide (0x%" PRIx64 ")", + image_name, (uint64_t)guest_hiaddr - guest_base); + exit(EXIT_FAILURE); } - current_start = real_start; } - naive: -#endif - while (1) { - unsigned long real_start, real_size, aligned_size; - aligned_size = real_size = host_size; + /* + * Expand the allocation to the entire reserved_va. + * Exclude the mmap_min_addr hole. + */ + if (reserved_va) { + guest_loaddr = (guest_base >= mmap_min_addr ? 0 + : mmap_min_addr - guest_base); + guest_hiaddr = reserved_va; + } - /* Do not use mmap_find_vma here because that is limited to the - * guest address space. We are going to make the - * guest address space fit whatever we're given. - */ - real_start = (unsigned long) - mmap((void *)current_start, host_size, PROT_NONE, flags, -1, 0); - if (real_start == (unsigned long)-1) { - return (unsigned long)-1; - } + /* Reserve the address space for the binary, or reserved_va. */ + test = g2h(guest_loaddr); + addr = mmap(test, guest_hiaddr - guest_loaddr, PROT_NONE, flags, -1, 0); + if (test != addr) { + pgb_fail_in_use(image_name); + } +} - /* 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; +/* Return value for guest_base, or -1 if no hole found. */ +static uintptr_t pgb_find_hole(uintptr_t guest_loaddr, uintptr_t guest_size, + long align) +{ + GSList *maps, *iter; + uintptr_t this_start, this_end, next_start, brk; + intptr_t ret = -1; + + assert(QEMU_IS_ALIGNED(guest_loaddr, align)); + + maps = read_self_maps(); + + /* Read brk after we've read the maps, which will malloc. */ + brk = (uintptr_t)sbrk(0); + + /* The first hole is before the first map entry. */ + this_start = mmap_min_addr; + + for (iter = maps; iter; + this_start = next_start, iter = g_slist_next(iter)) { + uintptr_t align_start, hole_size; + + this_end = ((MapInfo *)iter->data)->start; + next_start = ((MapInfo *)iter->data)->end; + align_start = ROUND_UP(this_start, align); + + /* Skip holes that are too small. */ + if (align_start >= this_end) { + continue; + } + hole_size = this_end - align_start; + if (hole_size < guest_size) { + continue; } - /* Ensure the address is properly aligned. */ - if (real_start & (align - 1)) { - /* Ideally, we adjust like - * - * pages: [ ][ ][ ][ ][ ] - * old: [ real ] - * [ aligned ] - * new: [ real ] - * [ aligned ] - * - * But if there is something else mapped right after it, - * then obviously it won't have room to grow, and the - * kernel will put the new larger real someplace else with - * unknown alignment (if we made it to here, then - * fixed=false). Which is why we grow real by a full page - * size, instead of by part of one; so that even if we get - * moved, we can still guarantee alignment. But this does - * mean that there is a padding of < 1 page both before - * and after the aligned range; the "after" could could - * cause problems for ARM emulation where it could butt in - * to where we need to put the commpage. - */ - munmap((void *)real_start, host_size); - real_size = aligned_size + align; - real_start = (unsigned long) - mmap((void *)real_start, real_size, PROT_NONE, flags, -1, 0); - if (real_start == (unsigned long)-1) { - return (unsigned long)-1; + /* If this hole contains brk, give ourselves some room to grow. */ + if (this_start <= brk && brk < this_end) { + hole_size -= guest_size; + if (sizeof(uintptr_t) == 8 && hole_size >= 1 * GiB) { + align_start += 1 * GiB; + } else if (hole_size >= 16 * MiB) { + align_start += 16 * MiB; + } else { + align_start = (this_end - guest_size) & -align; + if (align_start < this_start) { + continue; + } } - aligned_start = ROUND_UP(real_start, align); - } else { - aligned_start = real_start; } -#if defined(TARGET_ARM) && !defined(TARGET_AARCH64) - /* On 32-bit ARM, we need to also be able to map the commpage. */ - int valid = init_guest_commpage(aligned_start - guest_start, - aligned_size + guest_start); - if (valid == -1) { - munmap((void *)real_start, real_size); - return (unsigned long)-1; - } else if (valid == 0) { - goto try_again; + /* Record the lowest successful match. */ + if (ret < 0) { + ret = align_start - guest_loaddr; } -#endif - - /* If nothing has said `return -1` or `goto try_again` yet, - * then the address we have is good. - */ - break; - - try_again: - /* That address didn't work. Unmap and try a different one. - * The address the host picked because is typically right at - * the top of the host address space and leaves the guest with - * no usable address space. Resort to a linear search. We - * already compensated for mmap_min_addr, so this should not - * happen often. Probably means we got unlucky and host - * address space randomization put a shared library somewhere - * inconvenient. - * - * This is probably a good strategy if host_start, but is - * probably a bad strategy if not, which means we got here - * because of trouble with ARM commpage setup. - */ - 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(); + /* If this hole contains the identity map, select it. */ + if (align_start <= guest_loaddr && + guest_loaddr + guest_size <= this_end) { + ret = 0; } - current_start += align; - if (host_start == current_start) { - /* Theoretically possible if host doesn't have any suitably - * aligned areas. Normally the first mmap will fail. - */ - return (unsigned long)-1; + /* If this hole ends above the identity map, stop looking. */ + if (this_end >= guest_loaddr) { + break; } } + free_self_maps(maps); - qemu_log_mask(CPU_LOG_PAGE, "Reserved 0x%lx bytes of guest address space\n", host_size); - - return aligned_start; + return ret; } -static void probe_guest_base(const char *image_name, - abi_ulong loaddr, abi_ulong hiaddr) +static void pgb_static(const char *image_name, abi_ulong orig_loaddr, + abi_ulong orig_hiaddr, long align) { - /* Probe for a suitable guest base address, if the user has not set - * it explicitly, and set guest_base appropriately. - * In case of error we will print a suitable message and exit. - */ - const char *errmsg; - if (!have_guest_base && !reserved_va) { - unsigned long host_start, real_start, host_size; + uintptr_t loaddr = orig_loaddr; + uintptr_t hiaddr = orig_hiaddr; + uintptr_t addr; - /* Round addresses to page boundaries. */ - loaddr &= qemu_host_page_mask; - hiaddr = HOST_PAGE_ALIGN(hiaddr); + if (hiaddr != orig_hiaddr) { + error_report("%s: requires virtual address space that the " + "host cannot provide (0x%" PRIx64 ")", + image_name, (uint64_t)orig_hiaddr); + exit(EXIT_FAILURE); + } - if (loaddr < mmap_min_addr) { - host_start = HOST_PAGE_ALIGN(mmap_min_addr); + loaddr &= -align; + if (ARM_COMMPAGE) { + /* + * Extend the allocation to include the commpage. + * For a 64-bit host, this is just 4GiB; for a 32-bit host, + * the address arithmetic will wrap around, but the difference + * will produce the correct allocation size. + */ + if (sizeof(uintptr_t) == 8 || loaddr >= 0x80000000u) { + hiaddr = (uintptr_t)4 << 30; } else { - host_start = loaddr; - if (host_start != loaddr) { - errmsg = "Address overflow loading ELF binary"; - goto exit_errmsg; - } + loaddr = ARM_COMMPAGE & -align; } - host_size = hiaddr - loaddr; + } - /* Setup the initial guest memory space with ranges gleaned from - * the ELF image that is being loaded. + addr = pgb_find_hole(loaddr, hiaddr - loaddr, align); + if (addr == -1) { + /* + * If ARM_COMMPAGE, there *might* be a non-consecutive allocation + * that can satisfy both. But as the normal arm32 link base address + * is ~32k, and we extend down to include the commpage, making the + * overhead only ~96k, this is unlikely. */ - real_start = init_guest_space(host_start, host_size, loaddr, false); - if (real_start == (unsigned long)-1) { - errmsg = "Unable to find space for application"; - goto exit_errmsg; - } - guest_base = real_start - loaddr; + error_report("%s: Unable to allocate %#zx bytes of " + "virtual address space", image_name, + (size_t)(hiaddr - loaddr)); + exit(EXIT_FAILURE); + } + + guest_base = addr; +} + +static void pgb_dynamic(const char *image_name, long align) +{ + /* + * The executable is dynamic and does not require a fixed address. + * All we need is a commpage that satisfies align. + * If we do not need a commpage, leave guest_base == 0. + */ + if (ARM_COMMPAGE) { + uintptr_t addr, commpage; - qemu_log_mask(CPU_LOG_PAGE, "Relocating guest address space from 0x" - TARGET_ABI_FMT_lx " to 0x%lx\n", - loaddr, real_start); + /* 64-bit hosts should have used reserved_va. */ + assert(sizeof(uintptr_t) == 4); + + /* + * By putting the commpage at the first hole, that puts guest_base + * just above that, and maximises the positive guest addresses. + */ + commpage = ARM_COMMPAGE & -align; + addr = pgb_find_hole(commpage, -commpage, align); + assert(addr != -1); + guest_base = addr; } - return; +} -exit_errmsg: - fprintf(stderr, "%s: %s\n", image_name, errmsg); - exit(-1); +static void pgb_reserved_va(const char *image_name, abi_ulong guest_loaddr, + abi_ulong guest_hiaddr, long align) +{ + const int flags = MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE; + void *addr, *test; + + if (guest_hiaddr > reserved_va) { + error_report("%s: requires more than reserved virtual " + "address space (0x%" PRIx64 " > 0x%lx)", + image_name, (uint64_t)guest_hiaddr, reserved_va); + exit(EXIT_FAILURE); + } + + /* Widen the "image" to the entire reserved address space. */ + pgb_static(image_name, 0, reserved_va, align); + + /* Reserve the memory on the host. */ + assert(guest_base != 0); + test = g2h(0); + addr = mmap(test, reserved_va, PROT_NONE, flags, -1, 0); + if (addr == MAP_FAILED) { + error_report("Unable to reserve 0x%lx bytes of virtual address " + "space for use as guest address space (check your " + "virtual memory ulimit setting or reserve less " + "using -R option)", reserved_va); + exit(EXIT_FAILURE); + } + assert(addr == test); } +void probe_guest_base(const char *image_name, abi_ulong guest_loaddr, + abi_ulong guest_hiaddr) +{ + /* In order to use host shmat, we must be able to honor SHMLBA. */ + uintptr_t align = MAX(SHMLBA, qemu_host_page_size); + + if (have_guest_base) { + pgb_have_guest_base(image_name, guest_loaddr, guest_hiaddr, align); + } else if (reserved_va) { + pgb_reserved_va(image_name, guest_loaddr, guest_hiaddr, align); + } else if (guest_loaddr) { + pgb_static(image_name, guest_loaddr, guest_hiaddr, align); + } else { + pgb_dynamic(image_name, align); + } + + /* Reserve and initialize the commpage. */ + if (!init_guest_commpage()) { + /* + * With have_guest_base, the user has selected the address and + * we are trying to work with that. Otherwise, we have selected + * free space and init_guest_commpage must succeeded. + */ + assert(have_guest_base); + pgb_fail_in_use(image_name); + } + + assert(QEMU_IS_ALIGNED(guest_base, align)); + qemu_log_mask(CPU_LOG_PAGE, "Locating guest address space " + "@ 0x%" PRIx64 "\n", (uint64_t)guest_base); +} /* Load an ELF image into the address space. @@ -2399,6 +2390,12 @@ static void load_elf_image(const char *image_name, int image_fd, * MMAP_MIN_ADDR or the QEMU application itself. */ probe_guest_base(image_name, loaddr, hiaddr); + } else { + /* + * The binary is dynamic, but we still need to + * select guest_base. In this case we pass a size. + */ + probe_guest_base(image_name, 0, hiaddr - loaddr); } } diff --git a/linux-user/flatload.c b/linux-user/flatload.c index 66901f39cc5..8fb448f0bf0 100644 --- a/linux-user/flatload.c +++ b/linux-user/flatload.c @@ -441,6 +441,12 @@ static int load_flat_file(struct linux_binprm * bprm, indx_len = MAX_SHARED_LIBS * sizeof(abi_ulong); indx_len = (indx_len + 15) & ~(abi_ulong)15; + /* + * Alloate the address space. + */ + probe_guest_base(bprm->filename, 0, + text_len + data_len + extra + indx_len); + /* * there are a couple of cases here, the separate code/data * case, and then the fully copied to RAM case which lumps diff --git a/linux-user/main.c b/linux-user/main.c index 2cd443237d8..e18c1fb9523 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -24,6 +24,7 @@ #include "qemu-version.h" #include #include +#include #include "qapi/error.h" #include "qemu.h" @@ -747,28 +748,6 @@ int main(int argc, char **argv, char **envp) target_environ = envlist_to_environ(envlist, NULL); envlist_free(envlist); - /* - * Now that page sizes are configured in tcg_exec_init() we can do - * proper page alignment for guest_base. - */ - guest_base = HOST_PAGE_ALIGN(guest_base); - - if (reserved_va || have_guest_base) { - guest_base = init_guest_space(guest_base, reserved_va, 0, - have_guest_base); - if (guest_base == (unsigned long)-1) { - fprintf(stderr, "Unable to reserve 0x%lx bytes of virtual address " - "space for use as guest address space (check your virtual " - "memory ulimit setting or reserve less using -R option)\n", - reserved_va); - exit(EXIT_FAILURE); - } - - if (reserved_va) { - mmap_next_start = reserved_va; - } - } - /* * Read in mmap_min_addr kernel parameter. This value is used * When loading the ELF image to determine whether guest_base From patchwork Wed May 13 17:51:29 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: 186676 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp669464ilb; Wed, 13 May 2020 10:52:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkayNepiTZ5g8FBj8WOml3EXJvTSb4mIjtzGyq+boL/SXtM6T2vcs6jdjWPQzgafmjwjcq X-Received: by 2002:a37:c20a:: with SMTP id i10mr874602qkm.29.1589392351093; Wed, 13 May 2020 10:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392351; cv=none; d=google.com; s=arc-20160816; b=g4XPkSUlFpAcofmj6OIw1KwHx1jwpb6UwjWz0MzliLpzJpNWVQPX3dNyxWaP962CtQ dvCVb7MnLZVGTyDmSDc6IbxGtoxG8kcdWFuldzX2fg/aSoT7tjPDseaklQa4mpALvuAY OjkPoNJeuhKWmF3fPGmabHsQWYNgnCzSsZiycfoDsRFspvd5cT00p5w+8LhpS8YDNBip hyQeB0xoBRuTT9T4UzjACMbO6rZHBqXTv0OPqb0t6BCiBcURIBSam/AFf0uDtCwYrn2O PwHAePEv99k5ygs+Vt3fnffwmfaFx6MmVtVz+LGCVuF8FGPHKVV3w/EAY0VsP1ewLoir QKtw== 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=bhfhYkItu0rqms7vA34WYfwwnNQGZCVSd2qUpQYXdFA=; b=gKzCGdDJIf1A6gAg6CxENKMVhhbZCrXJKjS/jXKIB98WzZ3r/DIIeYOkzi2wIx1MsR Bp3kM9vBezdaZ3yqsIJ4PnnVu4n9HqcSO1IcSMZClOOH1VQpsH8AKRiGCIwqoj/61oVY ZkHIfuvxhxRl3CKxMyWAy/Bfcsn7LQZ9Fr3+WqdZsGMdAr8RTwLQfZgXTOGM7+ly04bS xH/UjleYsW9syBz5s2oQ2REb5Gr3LbkzNLJnVtNgDLrjyMsOp7afvDrd7WW8E+vxh4Jf xUNy1vicIsEihlukHoEPdWGaDAU0at6qxW4m7usRc69kfHcEg3hwsTwQfZ2qUeQP+DR4 4spQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Za6nCZ2Z; 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 22si91934qkj.288.2020.05.13.10.52.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:52:31 -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=Za6nCZ2Z; 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]:41142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvYU-0000tE-IL for patch@linaro.org; Wed, 13 May 2020 13:52:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXl-0000qK-Dy for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:45 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:43385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXk-0004yO-2a for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:45 -0400 Received: by mail-wr1-x441.google.com with SMTP id i15so497294wrx.10 for ; Wed, 13 May 2020 10:51:43 -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=bhfhYkItu0rqms7vA34WYfwwnNQGZCVSd2qUpQYXdFA=; b=Za6nCZ2Z4dF899st7vJkN/HoIC7eG9JHSqVaZIIJTwBLf+ns3fszMWEEDzckl2v5Fh 0zUwDlPDdRk8UE1/GMoxgLa7Il8k8vktCJwT7B6PBxVi9GGwNcSEgVwMbsPdsv7Wpang x6i6913KTew5J99MVfSOjFkikcGB2bw2Gb3EyDlbm4rdyVv7TdUOwKz403ysXc+4Hmo4 lnJVC3LwTQ+vWKGy/WunbQRoLjBF6jXQeKUyB1XB7Lk9Vw9EBrOmmslfqXfQooVMObCx KLiUAXKe6c6+lJJZ/tGapoxoBKFPet6vsJ8hykLVyLYQHXLKQ6Tp1nN+J7XuZ8eqZGyy P45A== 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=bhfhYkItu0rqms7vA34WYfwwnNQGZCVSd2qUpQYXdFA=; b=MgxPIoZHc3OvWUQhuBN0abdH0taCm6VU26nUw94uHtrByO+iVxlcGL92UGUUuUDWR3 lUhAp861ID7XhTmdqkFPWXwAW0xNqXS+df+LOZMSCst84WlwvIf8rbYmT0C+RHmFyv1a T+PfwuRDjsS1mf6eG1iFdIkEAgiLTwcKvf4dMn29Eb+r0n5J7xOsy4sUzYFLOL0tIpW6 zl5i1Yu9kqWwwLJ//r8b9rTfMih5Gcahl+kFspN1XcivxLHpEy9DgEEwCvEvAUe4qXOt 133NkjRqOZpoU0xVVoBMasn7BDIk2S+1aw0qlg+Ixj3gK6wuFVq6zDKi9PIyOSyPC+40 vC2g== X-Gm-Message-State: AOAM532z2rr+Vn7ytIxeXltBNw/w0TMhhCJM2GdGvwwIcldJCLxDkedP +Sk5cjly8qtfS7vf/cVYPUkMaQ== X-Received: by 2002:a5d:604b:: with SMTP id j11mr483272wrt.193.1589392302566; Wed, 13 May 2020 10:51:42 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id r9sm19625722wmg.47.2020.05.13.10.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:39 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5078A1FF91; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 05/10] exec/cpu-all: Use bool for have_guest_base Date: Wed, 13 May 2020 18:51:29 +0100 Message-Id: <20200513175134.19619-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Riku Voipio , Richard Henderson , Laurent Vivier , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Richard Henderson Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- include/exec/cpu-all.h | 2 +- bsd-user/main.c | 4 ++-- linux-user/main.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) -- 2.20.1 Reviewed-by: Laurent Vivier diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 43ddcf024c6..0895a57881a 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -159,7 +159,7 @@ static inline void tswap64s(uint64_t *s) * This allows the guest address space to be offset to a convenient location. */ extern unsigned long guest_base; -extern int have_guest_base; +extern bool have_guest_base; extern unsigned long reserved_va; #if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS diff --git a/bsd-user/main.c b/bsd-user/main.c index 28f122b80e6..0bfe46cff93 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -42,7 +42,7 @@ int singlestep; unsigned long mmap_min_addr; unsigned long guest_base; -int have_guest_base; +bool have_guest_base; unsigned long reserved_va; static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX; @@ -828,7 +828,7 @@ int main(int argc, char **argv) } } else if (!strcmp(r, "B")) { guest_base = strtol(argv[optind++], NULL, 0); - have_guest_base = 1; + have_guest_base = true; } else if (!strcmp(r, "drop-ld-preload")) { (void) envlist_unsetenv(envlist, "LD_PRELOAD"); } else if (!strcmp(r, "bsd")) { diff --git a/linux-user/main.c b/linux-user/main.c index e18c1fb9523..3597e99bb10 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -59,7 +59,7 @@ static const char *cpu_type; static const char *seed_optarg; unsigned long mmap_min_addr; unsigned long guest_base; -int have_guest_base; +bool have_guest_base; /* * Used to implement backwards-compatibility for the `-strace`, and @@ -334,7 +334,7 @@ static void handle_arg_cpu(const char *arg) static void handle_arg_guest_base(const char *arg) { guest_base = strtol(arg, NULL, 0); - have_guest_base = 1; + have_guest_base = true; } static void handle_arg_reserved_va(const char *arg) From patchwork Wed May 13 17:51:30 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: 186681 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp671336ilb; Wed, 13 May 2020 10:55:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRvY6npNfDvBbyz/xmLRL9Z+fhCms55kaUvX52nQULMe4AioPrKWD8RBcURvnp2XKyWdwh X-Received: by 2002:ad4:5843:: with SMTP id de3mr826159qvb.195.1589392552823; Wed, 13 May 2020 10:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392552; cv=none; d=google.com; s=arc-20160816; b=kbPu4z7/97t3KBFy259E17iPpYom//ua/Nj/8+T04PnZGpQE+iZa1SgUgnurcPV1QS LGg2kNuEGf42hH4wKHTadt9FDRfGZKwnbuq59xxYJdD//rrLHywoFxXOXmcALVJl6jQY 7BYQwHF9mLhxfKvAzOJQF5ETtu0X8emWT/JTifsMeVbBO6btIlDXkUxyXazHYvkEUfSr qqXMz26CS3KaYp9QNBuWzSYgGhE+lo+IKk3HmAWo+IvM+ApjDH9UCktyHIrvll5m+HNx 2+yUZiQPqli9D3B21yB3yk8ikOkPScZd/BY8IvAVrLwdEW6+TTnXzWBZJLYOCj+GyUYy +z9A== 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=VZws7rNsmkttLaHHknoSz9IXsCb2jY4GEzAaEB1rYxI=; b=wq5O99yB8LQI9jGu5SfEZUblB4OLJytbgZlPZleYPMu5gTe8yKkGTXYCHTbZel64vH 8RUJX44SXcsXX9MTGA0kWt01rWCFNS8fS2eRje5j1g4EKwBl7xCeteOPfnCj5+ry1jcv nr3N+4+IYnHsljFBEnbSKJV8fAPs64k3kZSdi2BT3Yqy5bCHEkp3eafI4kcVWTd+p3lx LVD6StVaShnPM0toAGQXd28cbiodIo+NjXUV7iQJd7Tqoi1AIoLmpUjs7Vy+VMi/fJAe aHpDqtDE19U7ueE9fdGD3Gf+7SelKZucLWrY05VEakkcGnYQOiBb0TzFQFbrTgFTatig AxTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FxKn7ASb; 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 z10si155270qvj.40.2020.05.13.10.55.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:55:52 -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=FxKn7ASb; 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]:55824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvbk-0006xN-AP for patch@linaro.org; Wed, 13 May 2020 13:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXn-0000uT-VO for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:48 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:39967) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXm-0004yi-Sc for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:47 -0400 Received: by mail-wr1-x444.google.com with SMTP id e16so520672wra.7 for ; Wed, 13 May 2020 10:51:46 -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=VZws7rNsmkttLaHHknoSz9IXsCb2jY4GEzAaEB1rYxI=; b=FxKn7ASbZ2LmvO+yVZLayI/eKxY4RrWSv54GHecmNOzlIwHiu5jjh+OAoXk78c3xUA xsLLEI12cYKIMiSIgoVfVBsCa4ahPX8culZnP1uAWFKG/uBlI6SO5MvjwU7gcIoV4wz7 yTjQvp5o+z1IyXhfMTi6qPeYSxBoOdL7S0BkqFL5xNNoBvfH1nsB++RTeYQ+atGcjgk2 Wb1EFoDVq79mralEma8wFnnQwn4Qn1EFDxDQdnTSPhZK7AkPnQrCSAmG4as9dXvBOXVr szuM1bZHcVmcqJh2SpTNoy+ZyC3xtwngecw8UcQS19c2SM9hFkjVs9mewx0B/Auuy+xs M3Cw== 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=VZws7rNsmkttLaHHknoSz9IXsCb2jY4GEzAaEB1rYxI=; b=WzOtD/tIFdNwax8N0MNIxha+GSqMFO5yuunUZpA1QIDXphFpU5KJXQRyDc/BMxY21b HlGp/0ZlVYV0kh6alWUsKhEukor0WN7UnkAd/Z3JEB0w4X8mpFWl2AvPDLRr+m+fG1N3 89X6BvU4+KMZ229EB9lDDA38h/kJlVEPG2cxp5NG17nUPhILE6u9qLnpNqFJ81F7cm4r jMvUT1gSFjah/eVweu0Jj7hyUYhvFtxu135kVE7zmjt4xl18PObdzQUmmvQ6k0greomV x1VWEMQIZ3NA/70OivgwgE0NBzngzW8Vp0YeEYbdIuaWJIeWX+WVJCCcwkg+Ji68JRjI BCYg== X-Gm-Message-State: AOAM532iAk8ObtEvb/ILqr+ZJndae3xJmeeimhbaoAMyTxRdhHb4AZit b1pFd5RMi816vwvkDJVAaB7YWA== X-Received: by 2002:adf:dfcd:: with SMTP id q13mr524459wrn.22.1589392305378; Wed, 13 May 2020 10:51:45 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id d13sm36450784wmb.39.2020.05.13.10.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:39 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6A34C1FF92; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 06/10] accel/tcg: Relax va restrictions on 64-bit guests Date: Wed, 13 May 2020 18:51:30 +0100 Message-Id: <20200513175134.19619-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We cannot at present limit a 64-bit guest to a virtual address space smaller than the host. It will mostly work to ignore this limitation, except if the guest uses high bits of the address space for tags. But it will certainly work better, as presently we can wind up failing to allocate the guest stack. Widen our user-only page tree to the host or abi pointer width. Remove the workaround for this problem from target/alpha. Always validate guest addresses vs reserved_va, as there we control allocation ourselves. Signed-off-by: Richard Henderson Signed-off-by: Alex Bennée --- vN - shutup checkpatch on ~0ul --- include/exec/cpu-all.h | 23 +++++++++++++++++++---- target/alpha/cpu-param.h | 15 ++------------- accel/tcg/translate-all.c | 15 +++++++++------ 3 files changed, 30 insertions(+), 23 deletions(-) -- 2.20.1 diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 0895a57881a..d14374bdd49 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -162,12 +162,27 @@ extern unsigned long guest_base; extern bool have_guest_base; extern unsigned long reserved_va; -#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS -#define GUEST_ADDR_MAX (~0ul) +/* + * Limit the guest addresses as best we can. + * + * When not using -R reserved_va, we cannot really limit the guest + * to less address space than the host. For 32-bit guests, this + * acts as a sanity check that we're not giving the guest an address + * that it cannot even represent. For 64-bit guests... the address + * might not be what the real kernel would give, but it is at least + * representable in the guest. + * + * TODO: Improve address allocation to avoid this problem, and to + * avoid setting bits at the top of guest addresses that might need + * to be used for tags. + */ +#if MIN(TARGET_VIRT_ADDR_SPACE_BITS, TARGET_ABI_BITS) <= 32 +# define GUEST_ADDR_MAX_ UINT32_MAX #else -#define GUEST_ADDR_MAX (reserved_va ? reserved_va - 1 : \ - (1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1) +# define GUEST_ADDR_MAX_ (~0ul) #endif +#define GUEST_ADDR_MAX (reserved_va ? reserved_va - 1 : GUEST_ADDR_MAX_) + #else #include "exec/hwaddr.h" diff --git a/target/alpha/cpu-param.h b/target/alpha/cpu-param.h index 692aee27ca9..1153992e42a 100644 --- a/target/alpha/cpu-param.h +++ b/target/alpha/cpu-param.h @@ -10,22 +10,11 @@ #define TARGET_LONG_BITS 64 #define TARGET_PAGE_BITS 13 -#ifdef CONFIG_USER_ONLY -/* - * ??? The kernel likes to give addresses in high memory. If the host has - * more virtual address space than the guest, this can lead to impossible - * allocations. Honor the long-standing assumption that only kernel addrs - * are negative, but otherwise allow allocations anywhere. This could lead - * to tricky emulation problems for programs doing tagged addressing, but - * that's far fewer than encounter the impossible allocation problem. - */ -#define TARGET_PHYS_ADDR_SPACE_BITS 63 -#define TARGET_VIRT_ADDR_SPACE_BITS 63 -#else + /* ??? EV4 has 34 phys addr bits, EV5 has 40, EV6 has 44. */ #define TARGET_PHYS_ADDR_SPACE_BITS 44 #define TARGET_VIRT_ADDR_SPACE_BITS (30 + TARGET_PAGE_BITS) -#endif + #define NB_MMU_MODES 3 #endif diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9924e66d1f7..e4f703a7e6d 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -173,8 +173,13 @@ struct page_collection { #define TB_FOR_EACH_JMP(head_tb, tb, n) \ TB_FOR_EACH_TAGGED((head_tb)->jmp_list_head, tb, n, jmp_list_next) -/* In system mode we want L1_MAP to be based on ram offsets, - while in user mode we want it to be based on virtual addresses. */ +/* + * In system mode we want L1_MAP to be based on ram offsets, + * while in user mode we want it to be based on virtual addresses. + * + * TODO: For user mode, see the caveat re host vs guest virtual + * address spaces near GUEST_ADDR_MAX. + */ #if !defined(CONFIG_USER_ONLY) #if HOST_LONG_BITS < TARGET_PHYS_ADDR_SPACE_BITS # define L1_MAP_ADDR_SPACE_BITS HOST_LONG_BITS @@ -182,7 +187,7 @@ struct page_collection { # define L1_MAP_ADDR_SPACE_BITS TARGET_PHYS_ADDR_SPACE_BITS #endif #else -# define L1_MAP_ADDR_SPACE_BITS TARGET_VIRT_ADDR_SPACE_BITS +# define L1_MAP_ADDR_SPACE_BITS MIN(HOST_LONG_BITS, TARGET_ABI_BITS) #endif /* Size of the L2 (and L3, etc) page tables. */ @@ -2497,9 +2502,7 @@ void page_set_flags(target_ulong start, target_ulong end, int flags) /* This function should never be called with addresses outside the guest address space. If this assert fires, it probably indicates a missing call to h2g_valid. */ -#if TARGET_ABI_BITS > L1_MAP_ADDR_SPACE_BITS - assert(end <= ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS)); -#endif + assert(end - 1 <= GUEST_ADDR_MAX); assert(start < end); assert_memory_lock(); From patchwork Wed May 13 17:51:31 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: 186678 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp670565ilb; Wed, 13 May 2020 10:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3O8yl+sm+Tz5SxfZVejrYWCwN3u1DrUWj2++TD0PKNd54oKRSQnfShnkuKA5+naiEJIdx X-Received: by 2002:aed:3f92:: with SMTP id s18mr283478qth.145.1589392466786; Wed, 13 May 2020 10:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392466; cv=none; d=google.com; s=arc-20160816; b=hCwlFUjqz0KCXvtAu+LJPOg0AyYJDhY8r3FHNBF6cBxhE3pwC50tG334mZqMnUgrD0 kUbWUaMY4SgG36wT3kQbp17o0jNYyID0FRR58btBfGKzIld0HD+8SrfPF8/GWUcgugZD HjlW9ZmLwRARycA3aFjd/rsj8VsheIPCqPfp9P42cIzPb2DYgRBGJW0qrQKCGycqKyfj dS8Th81jNfuLOrHZJyO5NJL58Tzwvx2Ylug/RdtOqmVnJs0zAlibVfZP8c0vdrTnHzBz yjAhM4yD6UmaD9Z/kP63TP7bcgcBImdW6hpTMFwi7MNwavXtxFrXAOS27vYetdT28v/M aMwg== 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=DRD2Oc+28edn4pGWZOmfAbES32+12APNylpSTMMls1g=; b=F55uzrct/puYzJ4ylY6v1DsVQDIHwsG+wu+iuBI3HTLdp7WD28xdm64HlnrsX8kPRu n48pd50OooYTaFieFDAV4yoM9Ulg2je+bn1JE9qquwbpl8ykltYp90SbqnZ8TsZJzFHs bp0o3mnckHrmRpl9Cv5EC1WMkEH3pguI6FkFYnFjMR1QTyr891eixrKcN9nH6icBH5wx BGZOBVHNz1CGutQHU0peyZ0LHUrbO0hPgs9PPr091sWIesKBpd0guWXGEkaBLRz1kTh+ 0sVGbVCyKYRvOb/V2s1YOpWfOr1XSpbuvoUOk0EPZkH/MvuZJTCrAqHPhCxESQGBpKgX un0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=InmqEqad; 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 q52si291240qtf.136.2020.05.13.10.54.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:54:26 -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=InmqEqad; 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]:49000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvaM-000498-AV for patch@linaro.org; Wed, 13 May 2020 13:54:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXm-0000rI-5L for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:46 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:41018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXl-0004yU-9W for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:45 -0400 Received: by mail-wr1-x443.google.com with SMTP id h17so512344wrc.8 for ; Wed, 13 May 2020 10:51:44 -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=DRD2Oc+28edn4pGWZOmfAbES32+12APNylpSTMMls1g=; b=InmqEqadv4fWc0UnVha5DVjkWZAY4cxuqXGO4upPEenVBpYAX82j3E9FoXNQ2HzNOj MqAG6Pw5+nJkbh2w+MVTH+m9mqyF/rO/RMfUdQxwCp6AYl1HZMFkfHeVrRurDHs5a+rE oPFeYF0jj1hxkWFIMIvhHp4pYSSInlIPm6q05oS6P8iq8HEMoALE2WOKhaq8FO3gBUff NaLD8jub6iozDi+ATPTpQgomNHntfryh9Goqe1sqITmKDAYqNQvuRY/htct5lmYu3hqF wbzsHijjEzuxN+MjOQSX8DVKBP0viLVfvB1VnOtCDqNQiXoYWywwHSwa8Y3HuWLwvaVQ P8og== 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=DRD2Oc+28edn4pGWZOmfAbES32+12APNylpSTMMls1g=; b=fGK2oxBXxQw6MILsdQipvfVB86E6bl2zJNHJzDr85PUrYUiXBpj8Ph4LexBEjuYCj+ rT1en4bOG/aaGLuPmARfE4K2ij5iIUsTFvbOOvbJbZlucih4WwGUAcvJJ7Dt6Rf0edSG xI/eZc20+6KGR2ieclXO+2Q7jEiZ1YpRWQLNapNpvglRL6QBwvbDj/P88vpuYjZF6cqn qeRZl7q6m3QWbP1oYHDhiTj+SfKE+w2GMZUztj+hP678AuzrdrTsFcfNG0mk/MAt9tvg 5ABJCQ8TrZKnOYUoSyFG3D7prBxNRmrXgSF5+7AE7jGq9dHuBTYjFUqjE9o2Km0CadxN OjLg== X-Gm-Message-State: AOAM530QcLkEGrKlpOUew4XSFjFfvCjP+YVYFM+TsQ9FJT0cxuVGnyeN JR0Oitll1HLWfJAca+gRDqSOBcoHe5I= X-Received: by 2002:adf:ca0e:: with SMTP id o14mr559591wrh.254.1589392303678; Wed, 13 May 2020 10:51:43 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u67sm24162531wmu.3.2020.05.13.10.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:39 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 8101E1FF93; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 07/10] accel/tcg: don't disable exec_tb trace events Date: Wed, 13 May 2020 18:51:31 +0100 Message-Id: <20200513175134.19619-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" I doubt the well predicted trace event check is particularly special in the grand context of TCG code execution. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/trace-events | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/accel/tcg/trace-events b/accel/tcg/trace-events index 01852217a66..385b9f749b8 100644 --- a/accel/tcg/trace-events +++ b/accel/tcg/trace-events @@ -1,10 +1,10 @@ # See docs/devel/tracing.txt for syntax documentation. -# TCG related tracing (mostly disabled by default) +# TCG related tracing # cpu-exec.c -disable exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR -disable exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR -disable exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" +exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR +exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR +exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=0x%x" # translate-all.c translate_block(void *tb, uintptr_t pc, uint8_t *tb_code) "tb:%p, pc:0x%"PRIxPTR", tb_code:%p" From patchwork Wed May 13 17:51:32 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: 186683 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp672472ilb; Wed, 13 May 2020 10:57:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCcXwsZV43TIlFV8TPftBwpl3qB/qLad/PZry6Bxqlzf4bKB1q284tVxvtSIiOuAgxKOWb X-Received: by 2002:aed:3b75:: with SMTP id q50mr314183qte.23.1589392646123; Wed, 13 May 2020 10:57:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392646; cv=none; d=google.com; s=arc-20160816; b=qqZKxrOxKy8+yrRR/1101eqd/Pz6kkEw+mR9Ke5hrhS54H5wxpn3DBb4Ug4ec4naqB k/Z4OZVSfohaoiUOU/a1XXIPtPKDXjzZ64Yr51nogemlBN/9cdDvuJI9zq7n/SahJeyb U2CZ62tUBRVOF39i7sxNRdu2/sdr4tY6OtZ0Hv7ASwDX3CTfIyjtqnDrBMOZZItrncC+ vSj+9IiOfJSWsy3yMcAoB1iqVSv4S/eKLYmzv8jurI7CGAikUjW90982Qpuh5u1ANCat kUqjwewNisQAHJHgxV1L57jH9zniQb6eXV4lZSyMyjRFJhnSFTGaibmn6UpBzBt9ju34 J62Q== 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=PX0EAKRt7eTMltMwvNNft+7Zaeu/0FTD7z/Hv6BbjkU=; b=I2AopcnKFfyChXkXhpd7gy1Zg4Z/ChcSuh3bQ+sAs/K3YteLGPtmE1Bmx0PCVKJM/K UJgmrFlDSU63jWXimr/vrdgvygymJzjbYEyg0P1NfHFBPLsAyAXYJ32tGSMI7eVeITi1 yktbt5kpOKR/0atJHYwq0V9LhcJpZNy8lHy8qG/6EyHAMcJ5z5mUpIoG5cxeWTCYTyxQ uETDc1AKYQlUE2D6KakHCZeUZXwxc53+lPqQZ6cmNIpOtjRW9ZCJvXL2wyxoybsLAz9D Tncd/+4S/k0B3DfOKZY++8Dr2nQKSEPpBDzijfv93qb66uoi+CYEi1/ASNwiQgp7RO4G 68Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FHwfVDPf; 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 s31si285417qtk.212.2020.05.13.10.57.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:57:26 -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=FHwfVDPf; 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]:33384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvdF-0000yv-L3 for patch@linaro.org; Wed, 13 May 2020 13:57:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvYA-0001bi-Cg for qemu-devel@nongnu.org; Wed, 13 May 2020 13:52:10 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34930) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvY9-00059x-By for qemu-devel@nongnu.org; Wed, 13 May 2020 13:52:10 -0400 Received: by mail-wr1-x443.google.com with SMTP id j5so559748wrq.2 for ; Wed, 13 May 2020 10:52: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=PX0EAKRt7eTMltMwvNNft+7Zaeu/0FTD7z/Hv6BbjkU=; b=FHwfVDPfDMJlknw5hlgqjPioiyNycoe2bNodJT+GZ6fmJ4xB4qw+BMt2o/9KLchfL3 /51gA94o5vxTVrGGH0dAvwZHfiSWdxhZ790gTPB5qLPbebEO5JBGcwmDfviHNN/BDH3V m4JCRqmAfjlFYGO+lbxjqat9NYIcHb21UYbtIfeLP88n5lwGPI3EGnu7tlYmxk8zBTwn b/0e3M2NZITJRUhipqAB95cUptiOGqO/ii539m52nGP6w1Ozmllb5rAZC4Cy5gPc7izu 6EyNvVeozFiT9r+qUkoBa4sDANgj0LtL4Pa8iaunjNKdoZgXfqrUGUVoXoamZnLqzmdB klkw== 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=PX0EAKRt7eTMltMwvNNft+7Zaeu/0FTD7z/Hv6BbjkU=; b=jQbgMzezD0A+lhQ3pDM3rh+z8W4tP8GFCcS/GOj9ZynHh6f+JDgTKpM1C2RUR7hZiZ nIpXHfYWgWSdfLSl2XEUdA9f464q/Ub+PU67Q/KtRU+Yqznk2A7i51EDsb/R0nL6pMiw Q4FBckAOcLdBu0IlD1BILl89s8fVQJSdLReCB5uv8BWR+0C/9J7D4mbefbkDIl2yykbD PnSRmqh6+lX5pQz/JeuxbNu5ZQxLz1Gl+PaA2EgSkrwm7N00B5PDZj1SFlmuY4YwH9JF 5jOQbLkqN7YTHyvxOETQkvDacm3+PemzjrVpWxhSXZkGcxa8pZaG6THxsnTd2tfIe54N v7WA== X-Gm-Message-State: AOAM532cCtkH3w2EOwOsE7odkZGXGSdvGssxJXPgu01q0vEYndzC+kPr xrrOgGzor3MRvfyQ0IQ+/IzlE1gyYAA= X-Received: by 2002:a5d:5607:: with SMTP id l7mr523518wrv.370.1589392306353; Wed, 13 May 2020 10:51:46 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q74sm30721232wme.14.2020.05.13.10.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:40 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9C5CA1FF96; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 08/10] disas: include an optional note for the start of disassembly Date: Wed, 13 May 2020 18:51:32 +0100 Message-Id: <20200513175134.19619-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This will become useful shortly for providing more information about output assembly inline. While there fix up the indenting and code formatting in disas(). Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- v2 - minor tweak to if(note){} fprintf(out,"\n") logig --- include/disas/disas.h | 2 +- include/exec/log.h | 4 ++-- accel/tcg/translate-all.c | 4 ++-- disas.c | 14 ++++++++++---- tcg/tcg.c | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/include/disas/disas.h b/include/disas/disas.h index 36c33f6f194..1b6e035e32d 100644 --- a/include/disas/disas.h +++ b/include/disas/disas.h @@ -7,7 +7,7 @@ #include "cpu.h" /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size); +void disas(FILE *out, void *code, unsigned long size, const char *note); void target_disas(FILE *out, CPUState *cpu, target_ulong code, target_ulong size); diff --git a/include/exec/log.h b/include/exec/log.h index fcc7b9e00ba..3ed797c1c8c 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -56,13 +56,13 @@ static inline void log_target_disas(CPUState *cpu, target_ulong start, rcu_read_unlock(); } -static inline void log_disas(void *code, unsigned long size) +static inline void log_disas(void *code, unsigned long size, const char *note) { QemuLogFile *logfile; rcu_read_lock(); logfile = atomic_rcu_read(&qemu_logfile); if (logfile) { - disas(logfile->fd, code, size); + disas(logfile->fd, code, size, note); } rcu_read_unlock(); } diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index e4f703a7e6d..cdf58bb420e 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1800,7 +1800,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, size_t data_size = gen_code_size - code_size; size_t i; - log_disas(tb->tc.ptr, code_size); + log_disas(tb->tc.ptr, code_size, NULL); for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { if (sizeof(tcg_target_ulong) == 8) { @@ -1814,7 +1814,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } } } else { - log_disas(tb->tc.ptr, gen_code_size); + log_disas(tb->tc.ptr, gen_code_size, NULL); } qemu_log("\n"); qemu_log_flush(); diff --git a/disas.c b/disas.c index 3937da61571..7e8692de301 100644 --- a/disas.c +++ b/disas.c @@ -586,7 +586,7 @@ char *plugin_disas(CPUState *cpu, uint64_t addr, size_t size) } /* Disassemble this for me please... (debugging). */ -void disas(FILE *out, void *code, unsigned long size) +void disas(FILE *out, void *code, unsigned long size, const char *note) { uintptr_t pc; int count; @@ -674,10 +674,16 @@ void disas(FILE *out, void *code, unsigned long size) for (pc = (uintptr_t)code; size > 0; pc += count, size -= count) { fprintf(out, "0x%08" PRIxPTR ": ", pc); count = print_insn(pc, &s.info); - fprintf(out, "\n"); - if (count < 0) - break; + if (note) { + fprintf(out, "\t\t%s", note); + note = NULL; + } + fprintf(out, "\n"); + if (count < 0) { + break; + } } + } /* Look up symbol for debugging purpose. Returns "" if unknown. */ diff --git a/tcg/tcg.c b/tcg/tcg.c index dd4b3d76844..a2268d9db0a 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1092,7 +1092,7 @@ void tcg_prologue_init(TCGContext *s) size_t data_size = prologue_size - code_size; size_t i; - log_disas(buf0, code_size); + log_disas(buf0, code_size, NULL); for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { if (sizeof(tcg_target_ulong) == 8) { @@ -1106,7 +1106,7 @@ void tcg_prologue_init(TCGContext *s) } } } else { - log_disas(buf0, prologue_size); + log_disas(buf0, prologue_size, NULL); } qemu_log("\n"); qemu_log_flush(); From patchwork Wed May 13 17:51:33 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: 186679 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp670655ilb; Wed, 13 May 2020 10:54:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbY/IbHsdU26cEzQOiWqfZjOV9vqZFbOVb09MKNsnUa3+0D1NwC01WE2KReMJD9yqOcqo9 X-Received: by 2002:a05:6214:13d4:: with SMTP id cg20mr844564qvb.214.1589392475782; Wed, 13 May 2020 10:54:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392475; cv=none; d=google.com; s=arc-20160816; b=Qr723KHw0oaqWQmc3eC5XszI5WHaPKU6NAqmy6RJxlXNQ8+Ra4nfwTp/92loF2kmGf 0MxsTK7H9gP7L/E8Ocxp4orxnbbLKEAL0vXWkkqAVJXb/KgPP5sNQIP+tmqsf0P8SP5j S4dUGkA5WsGWrdsOAHi3haYeS6C7MCbKTrX7mXTz+4k2nrGXU00YdU2V/rWHW/sn7LB7 njc1m63qt/ZmZX058bkA/wfNOmefomDGMMe835jhIOqQQ1fipFHdlS9heIpb4796uCxb sLYLeZcwyf6Xh0xQgDHbim8NS2vkZStlgXEiNMqPmzNskPzyC/pM9dVn5/s4oVhMcYGO ymag== 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=cOXxIq5n0K0tWjPWqLAjM36kY0q6yO5L0IxUaG95YzQ=; b=zT3v3m/AVUyTpwHicllBeNshOKwrZ6G9PKwJ/cs/X3e3AlBCUpyeL8LuU9hWqXghJQ q+UCJBdpZy20K6d/BZkFtqhaUkwJV1NnojSWhkMS9wsZG0Ra7nnMSOz3hYBsUREWtae5 zbSgX5inYqO7yc6l8qiMy3pjbTbRn+mIPLxpInxux0cfHMM6fkZDpP2x7DxCFgM9sfTv JVIt481gULjvlOd/VGdUUZLk5UFMBz87wQwjKMeg/thr9MxDNwuvCuv0f7VU5UU08o98 0BemownN0miHnjw0WE9A/vBVZgDAedVLgzD4Lz3ddAfNgb0JwTWY/NzSBpVzM/lsnGJl zkTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=thfkpzSl; 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 i3si98848qkf.251.2020.05.13.10.54.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:54:35 -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=thfkpzSl; 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]:50032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvaV-0004Ym-8p for patch@linaro.org; Wed, 13 May 2020 13:54:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXp-0000yU-QM for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:49 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXo-0004yw-PL for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:49 -0400 Received: by mail-wr1-x443.google.com with SMTP id y3so568132wrt.1 for ; Wed, 13 May 2020 10:51:48 -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=cOXxIq5n0K0tWjPWqLAjM36kY0q6yO5L0IxUaG95YzQ=; b=thfkpzSlQDTHelMG2nTVFPXtE91o86V0kBkQrcPTL+8IU98HP7Rzhrg9g0MgqI2TOK /sg+hsEAm4DPxIb2jxjYL1hYGADZuN16Mz+FLni7BaxK4WF8URCIKaOI031h/krCvV8b 2GS4KAImkR3/7yUEwzH0wDtc20wUVumWSjNznS5NdTrfOO5zmG9TE3/0cljzxnR3FcPQ O4L0MTSb7lSp7OQ5CsE4Ee9R0SW5MNFRSZkWJVyLfidvVkvNoYA5iOAJvUeDu8pWRpqn Mo9jyCQEjevXDnfhUPpIJHrcM0aHZ+Dp7XctJWqjmv8+l8MnqfGK1hydSqJyDYHB65Ri L9Fw== 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=cOXxIq5n0K0tWjPWqLAjM36kY0q6yO5L0IxUaG95YzQ=; b=rYRrX2/mpxNPtPvyc2Wxp6W1iRCpZpj1AFpQcaNbQDFZpBK837g8SXrisIe3MKTaNW fwU87Be96uL6wE6uBEWXAtym9v0lvXq0uq6tAO1hrPafPWMfqZ/uOWbQAgC5vtt8QdkJ v9/8VKwQwmhSOgk1UNIk+/wLipNelL1C8pPgAIkJMDTKoxoKqAUobzKCyxzEneuYtWOs aHCCqjCLASxc7uCVmdZmmF/WDc9QgfPI8qkOhndKd+vQ7xScEe2igw0gm9TpaaKQqXKQ t6OtAqGOYQKFsxiZqUef7y/crewmyqVKyvAGQoa4nLv7/u6sWHv0mfWMFUBhpqi9v1r7 mmwA== X-Gm-Message-State: AOAM530LSnlviNlvcCTpN6nEiGsA+VZILTWFH1Iw+8KvEzZdbBcBbTjF R4K+ltEcV5Emd9q7YocLjuHK7w== X-Received: by 2002:adf:b301:: with SMTP id j1mr480997wrd.221.1589392307379; Wed, 13 May 2020 10:51:47 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id g135sm19365401wme.22.2020.05.13.10.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:41 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B0DF61FF98; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 09/10] disas: add optional note support to cap_disas Date: Wed, 13 May 2020 18:51:33 +0100 Message-Id: <20200513175134.19619-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Include support for outputting a note at the top of a chunk of disassembly to capstone as well. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- v2 - always pass note down to cap_dump_insn --- disas.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/disas.c b/disas.c index 7e8692de301..45285d3f63f 100644 --- a/disas.c +++ b/disas.c @@ -260,7 +260,8 @@ static void cap_dump_insn_units(disassemble_info *info, cs_insn *insn, } } -static void cap_dump_insn(disassemble_info *info, cs_insn *insn) +static void cap_dump_insn(disassemble_info *info, cs_insn *insn, + const char *note) { fprintf_function print = info->fprintf_func; int i, n, split; @@ -281,7 +282,11 @@ static void cap_dump_insn(disassemble_info *info, cs_insn *insn) } /* Print the actual instruction. */ - print(info->stream, " %-8s %s\n", insn->mnemonic, insn->op_str); + print(info->stream, " %-8s %s", insn->mnemonic, insn->op_str); + if (note) { + print(info->stream, "\t\t%s", note); + } + print(info->stream, "\n"); /* Dump any remaining part of the insn on subsequent lines. */ for (i = split; i < n; i += split) { @@ -313,7 +318,7 @@ static bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size) size -= tsize; while (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { - cap_dump_insn(info, insn); + cap_dump_insn(info, insn, NULL); } /* If the target memory is not consumed, go back for more... */ @@ -342,7 +347,8 @@ static bool cap_disas_target(disassemble_info *info, uint64_t pc, size_t size) } /* Disassemble SIZE bytes at CODE for the host. */ -static bool cap_disas_host(disassemble_info *info, void *code, size_t size) +static bool cap_disas_host(disassemble_info *info, void *code, size_t size, + const char *note) { csh handle; const uint8_t *cbuf; @@ -358,7 +364,8 @@ static bool cap_disas_host(disassemble_info *info, void *code, size_t size) pc = (uintptr_t)code; while (cs_disasm_iter(handle, &cbuf, &size, &pc, insn)) { - cap_dump_insn(info, insn); + cap_dump_insn(info, insn, note); + note = NULL; } if (size != 0) { (*info->fprintf_func)(info->stream, @@ -402,7 +409,7 @@ static bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) csize += tsize; if (cs_disasm_iter(handle, &cbuf, &csize, &pc, insn)) { - cap_dump_insn(info, insn); + cap_dump_insn(info, insn, NULL); if (--count <= 0) { break; } @@ -416,7 +423,7 @@ static bool cap_disas_monitor(disassemble_info *info, uint64_t pc, int count) #endif /* !CONFIG_USER_ONLY */ #else # define cap_disas_target(i, p, s) false -# define cap_disas_host(i, p, s) false +# define cap_disas_host(i, p, s, n) false # define cap_disas_monitor(i, p, c) false # define cap_disas_plugin(i, p, c) false #endif /* CONFIG_CAPSTONE */ @@ -664,7 +671,7 @@ void disas(FILE *out, void *code, unsigned long size, const char *note) print_insn = print_insn_hppa; #endif - if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size)) { + if (s.info.cap_arch >= 0 && cap_disas_host(&s.info, code, size, note)) { return; } From patchwork Wed May 13 17:51:34 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: 186682 Delivered-To: patch@linaro.org Received: by 2002:a92:5b0a:0:0:0:0:0 with SMTP id p10csp672449ilb; Wed, 13 May 2020 10:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvXp4Twqx4s+FnJga40r5bKe1gwbmRh2pOpF8f2uhyldS9fl6tPzNpO3QbD4U2nPYzbZz1 X-Received: by 2002:ac8:7304:: with SMTP id x4mr352079qto.4.1589392644431; Wed, 13 May 2020 10:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589392644; cv=none; d=google.com; s=arc-20160816; b=FSi/ovCPHOjQGa/QUXA2tSEQ7EbCC2rWYrUjcYJnA5rIZJAzDE1LEOvky9drIzCNOL MLNi3pOcy9yhI9H/2inL2n213+ULAO0kl9KVVMZAhGPqvsz0ConkLuubNppKNcEWND35 bwPeAvW7nTQ7ErWxVrIWbZq04HVt4GigduG4slCsDaZUKwrQddZYdL1PLyBEWZ5akyTO +Ync//8tzIe+Ira63KEh035EjDTjlUHIwvVjAMXdG118ysGTB3agYQyJwpqnH6Zodoq/ /vO3KkqUtQ03NOtXcYvkw/miaTzmqdxrMjJOIqZ6V0gzTgXH2twRMVR7JuIt8jjW3CTG m0zg== 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=vIuy+49GjNnXS0U4P2UnKZDtDhiy+1MKHIiwaKmxtXk=; b=tjBFqGjGA05DdJ60pz/uXuXwXGEEG/JQqUZUlGhGtuoU7zsiWT8rVktX1PIZmTlMgi djEIFqOnXhBmm0F+83Anh4D6Ym6wSgZMqLCRzVeTR2e0oy0w3CqnoY92wLZRmw352w/w SoIVVidazAZvjx2adC1i3J3frCBMGxYfal+hYwxw22HHZeW11BGsLhNzcMp+jdD9muF9 VE0dlvheS2wrSmaytLDuTE74q+cZN9AjKXznTcZXHlKk75BclSg15q/UAnfo3WHkELhv BASn23FvpCdPqr8wnTHpBClmOe6UddR+qzIVfxylwVaknHOCFR/b+gmG0PiFZrDvlvjF sXtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=sCG7FvrF; 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 g74si92970qke.359.2020.05.13.10.57.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 May 2020 10:57:24 -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=sCG7FvrF; 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]:33268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYvdD-0000wG-VE for patch@linaro.org; Wed, 13 May 2020 13:57:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYvXu-000110-Nm for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:54 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:44630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jYvXp-0004z3-OM for qemu-devel@nongnu.org; Wed, 13 May 2020 13:51:50 -0400 Received: by mail-wr1-x442.google.com with SMTP id 50so492614wrc.11 for ; Wed, 13 May 2020 10:51:49 -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=vIuy+49GjNnXS0U4P2UnKZDtDhiy+1MKHIiwaKmxtXk=; b=sCG7FvrFcphaiut0lleKtWhGxtRuMr9MwqFJ6uOfnkMcFRAchV3vciPJmmg3PFWQdy GbcWVuOQ21oliL21EnA9g6odK/KMA4on9HgZ6hSPmdPOubjGvYbpOuYvjWub+7S3oq20 BSp0pzBbG8GB4X0soZuw/1Yyfrf3WfDB57Unz1tUDFDVeulDLixjsfrMWszFpNqBDtq4 GxQRkFJOek3WOBEEA+J4Ys30iT01h9kdu0u2XfVDg1k5n6+YvqDDZFvWwXvkES/YaFDW Mm3gK1aAc/MizSYhyU0tykLPbqPKicMn9HwcMaMxjdRZed7wFNrTZ0t2EwNI72g/pO9H FOpg== 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=vIuy+49GjNnXS0U4P2UnKZDtDhiy+1MKHIiwaKmxtXk=; b=q/LunSUhy3R3HopN3jag1lQ/r0l84ip6JD6l39xPZkXqi4yH87ypAPp7qcpv0KZzlj rVUIRsDQ4JxaSFRxIrISjL27pjjMqqC/h4M/S8enTZtj8c85/AKQzFIspiB9W2ARQLHL aOzhlau8JWx7pfbXNuSMysm1SKNP2bY/ybh/OsmfWJ4OSTiltXg/QB7RbW0ikdWT4Jn6 C6y6CVjCbJJ21liA9ukSoIp2msJtIkGZTSY33TZdhkgTfJqI9FMfgu1eA9vJYeXIp3v3 gvdhlYCGzDfDzqvDaSMtv9dnMfvw4QZwX/KpzUAO0bDZOSntGRf+8f0v2XmBYuW4LvvK OyyA== X-Gm-Message-State: AOAM531ctg22PnDPDvYC8+TYwygnoOfDteqImKYuWunsc3cuF5el0doi 2Pd4cY6C9gIEKRwXUvZ5xsdDSQ== X-Received: by 2002:adf:edc1:: with SMTP id v1mr485126wro.125.1589392308395; Wed, 13 May 2020 10:51:48 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u127sm37160769wme.8.2020.05.13.10.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2020 10:51:41 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C574E1FF99; Wed, 13 May 2020 18:51:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v1 10/10] translate-all: include guest address in out_asm output Date: Wed, 13 May 2020 18:51:34 +0100 Message-Id: <20200513175134.19619-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200513175134.19619-1-alex.bennee@linaro.org> References: <20200513175134.19619-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We already have information about where each guest instructions representation starts stored in the tcg_ctx->gen_insn_data so we can rectify the PC for faults. We can re-use this information to annotate the out_asm output with guest instruction address which makes it a bit easier to work out where you are especially with longer blocks. A minor wrinkle is that some instructions get optimised away so we have to scan forward until we find some actual generated code. Signed-off-by: Alex Bennée --- v1 - better logic for doing chunk at a time - use new "note" facility to tag address - rewrite the commit log v2 - don't terminate gen_insn_end_off, trust your termination conditions ;-) --- accel/tcg/translate-all.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) -- 2.20.1 diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index cdf58bb420e..42ce1dfcff7 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1794,14 +1794,43 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { FILE *logfile = qemu_log_lock(); + int code_size, data_size = 0; + g_autoptr(GString) note = g_string_new("[tb header & initial instruction]"); + size_t chunk_start = 0; + int insn = 0; qemu_log("OUT: [size=%d]\n", gen_code_size); if (tcg_ctx->data_gen_ptr) { - size_t code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr; - size_t data_size = gen_code_size - code_size; - size_t i; + code_size = tcg_ctx->data_gen_ptr - tb->tc.ptr; + data_size = gen_code_size - code_size; + } else { + code_size = gen_code_size; + } - log_disas(tb->tc.ptr, code_size, NULL); + /* Dump header and the first instruction */ + chunk_start = tcg_ctx->gen_insn_end_off[insn]; + log_disas(tb->tc.ptr, chunk_start, note->str); + /* + * Dump each instruction chunk, wrapping up empty chunks into + * the next instruction. The whole array is offset so the + * first entry is the beginning of the 2nd instruction. + */ + while (insn <= tb->icount && chunk_start < code_size) { + size_t chunk_end = tcg_ctx->gen_insn_end_off[insn]; + if (chunk_end > chunk_start) { + g_string_printf(note, "[guest addr: " TARGET_FMT_lx "]", + tcg_ctx->gen_insn_data[insn][0]); + log_disas(tb->tc.ptr + chunk_start, chunk_end - chunk_start, + note->str); + chunk_start = chunk_end; + } + insn++; + } + + /* Finally dump any data we may have after the block */ + if (data_size) { + int i; + qemu_log(" data: [size=%d]\n", data_size); for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { if (sizeof(tcg_target_ulong) == 8) { qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", @@ -1813,8 +1842,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, *(uint32_t *)(tcg_ctx->data_gen_ptr + i)); } } - } else { - log_disas(tb->tc.ptr, gen_code_size, NULL); } qemu_log("\n"); qemu_log_flush();