From patchwork Tue Jul 9 16:36:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1129915 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="f+RSbrIZ"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45jp112qhpz9sBt for ; Wed, 10 Jul 2019 02:38:42 +1000 (AEST) Received: from localhost ([::1]:51914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkt8V-0003Af-Dp for incoming@patchwork.ozlabs.org; Tue, 09 Jul 2019 12:38:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37897) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkt7I-000393-4u for qemu-devel@nongnu.org; Tue, 09 Jul 2019 12:37:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkt7G-0006Wz-84 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 12:37:19 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:39447) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkt7D-0006QP-I4 for qemu-devel@nongnu.org; Tue, 09 Jul 2019 12:37:15 -0400 Received: by mail-pg1-x542.google.com with SMTP id u17so9237624pgi.6 for ; Tue, 09 Jul 2019 09:37: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:mime-version :content-transfer-encoding; bh=JVOyp/SQtLtkdq8BjHn2mlzsOWIS2SvfgbnRIW9MzD8=; b=f+RSbrIZuaswgLSXeBK5hU/c/5bgbr2AuerajJMVw+GRyWgrOOX05ai/0S8/LHZisD EqUwPB5qTVJpGHvpB7dWyY85DD7P76o6wmXpsK1g9gZtvQ1OmReqhnp/SchCC5EqPHLo 6XBunsMwINll0qnCPRDONQUzR1jiXNeOvzpzs/oNEMFgpwzBj02pytvAtTLLIMjmhrMa Y5Xqbin+DaNGYnWjp4GETzlvk7mIgE6zjaKdtWXT9LsxFCMXj825rya+Pl2OMKzxlSbm qulQqDeXsjfJmHhMVcRZM3wHfCwUkMpLqgOabnuPZ4oqk4zs+aRU8ld7YZgm8KBbpNqR /UYA== 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:mime-version :content-transfer-encoding; bh=JVOyp/SQtLtkdq8BjHn2mlzsOWIS2SvfgbnRIW9MzD8=; b=oCcBtzEEImgvhw9L8So1vi3mWWkTqh2BS6Hvb3aK9R90Ec4bkqGMssaRZTt/XgmaDT FBgLWYLhR1UQbscJLI0N5vBVU1qKicJeItpJZNnUBywjnLx8ejTz81/tcOehSA3FMsvL QEEnREa2LZqQTH5nKg7zTkFSFHMSx4ENhhiVcWsC8aq3erPc8bvZbb8Fhuwj5BAvkZDR aiHIPUscLsMFylFKPaGvO6DNFefYmj32h2e9x72BaOHjHRVN8n+mutGPBqo5wTJ9pZQ/ WprtcbxHUcUSg8JLICnw493lqmZf4zvVo0mOmh1HHYjmIXRR7HuvEoeHgQlemkiH6wQh 25JQ== X-Gm-Message-State: APjAAAWc1yUFoCfqS5OSBhi5NkS17slX90zSRqqC85gnN0NsCgzDocsj CRe7gMXK04B2MaoCWDSdrwrZYlmj0Ps= X-Google-Smtp-Source: APXvYqzKwffXyji522+N677RI0Bi575GgRKjLe2y2urf1nUzWjpo0w0UGXfCSU5+J3ZAv+Eo9CRvSA== X-Received: by 2002:a63:fb4b:: with SMTP id w11mr31690318pgj.415.1562690227163; Tue, 09 Jul 2019 09:37:07 -0700 (PDT) Received: from localhost.localdomain ([172.56.12.212]) by smtp.gmail.com with ESMTPSA id v8sm19225231pgs.82.2019.07.09.09.37.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 09 Jul 2019 09:37:06 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 9 Jul 2019 18:36:51 +0200 Message-Id: <20190709163656.3100-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2 0/5] tcg: Fix mmap_lock assertion failure, take 2 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: lvivier@redhat.com, peter.maydell@linaro.org, alex.bennee@linaro.org, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Changes from v1: * Fix whitespace error * Fix cpu_lds*_code(), where cut-and-paste failed to extend the data. Noticable with check-tcg with docker cross-compiler for cris-linux-user. Blurb from v1: While I could not replicate the failure Peter reported, the apparent root cause -- the old magic fixed page -- should affect other guests as well. In particular, the old arm32 magic fixed page at 0xffff0f00, and the hppa magic fixed page at 0. In the arm32 and hppa cases that I just mentioned -- but notably not the x86_64 case that Peter reported -- there is special-case code in target/*/translate.c to handle those addresses without actually doing the read from the unmapped address. Therefore, until we fix these sort of address space representational errors, we cannot even rely on page_check_range() to validate the execute access. Instead, modify the host signal handler to intercept this at SIGSEGV. At this point we're sure that there is no guest special case that we have overlooked, because we did attempt the read for execute. Also, I noticed that we really ought to have some barriers around this code to make sure that the modifications to helper_retaddr are in fact visible to the host signal handler. Also, some minor cleanups to the set of read functions that we expose for use during translation. Also, a trivial duplicated condition. r~ Richard Henderson (5): include/qemu/atomic.h: Add signal_barrier tcg: Introduce set/clear_helper_retaddr tcg: Remove cpu_ld*_code_ra tcg: Remove duplicate #if !defined(CODE_ACCESS) tcg: Release mmap_lock on translation fault include/exec/cpu_ldst.h | 20 ++++++ include/exec/cpu_ldst_useronly_template.h | 40 ++++++++---- include/qemu/atomic.h | 11 ++++ accel/tcg/user-exec.c | 77 ++++++++++++++++------- target/arm/helper-a64.c | 8 +-- target/arm/sve_helper.c | 43 +++++++------ 6 files changed, 136 insertions(+), 63 deletions(-)