From patchwork Fri Jun 15 19:43:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138759 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1250390lji; Fri, 15 Jun 2018 12:51:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI8V9u+I/jLESiqbWHaH0+S3TQSci7z+SfwUH2c7XrGIvV9wT0NwMag/i9sUuNwtv5+P241 X-Received: by 2002:a0c:ae63:: with SMTP id z32-v6mr2658979qvc.108.1529092275194; Fri, 15 Jun 2018 12:51:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529092275; cv=none; d=google.com; s=arc-20160816; b=KV/oc/agGKjcjNw2zVsWlvU7U8cq5lMGV16SHasXm7uLNAbtC/IvyhlFPxsy+iDKEL FL8WggT6+wyi/heAJZNdRn6B1v3yUlbzxrpg5JKx+AR63BVM4NaPB6+IjdcmdH6EHhrR 7C7p7QGACjgrzdqu8uz05z4obXy6tIOLN6UkAVtVovrRUbB5Gl/WFn4KTW0H/vpf0diE Sc3AznTrlBqXy/UuDcsTAlS+7ux4uR6sScY/BZaM+4ygkf0n66yAWAoAevSHvvXTBDaq 8zMtwTTScUyezAnQmJO5BiGX3sLE+eO+Pn3UFAbPrjA1AH3UCxBf5369+tTd/t08hHj5 tdYg== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=zOVWT9oyOnUXGeg0GOygk0Sk7eelIiTSGEWZKkbw/co=; b=yT5weMrSUfZf99YK8KRt4x7yM+gHeOhdKsT0chq6w82WycMnz/YOrRzP5FEzCs+H33 FCy6M0u5+ZvnLMqEipsxjp10QOTWtq3nYAVAaTPihZna/rOWLIAcTX2JYX9/n6SK4d6O 0glGRbpg7mQRRaxUUrb2NdVCRSVSd+8It26hAkWhbNRBd5J9tUjKLEI5PfELI1nC4K+j Dry94OdsworgnXYUelmvHh7w94GZlSp6It0viSeVWtiFgTh3oYOPnbvY8Vx/hbZ53l7v 8TGJfGJa4jlrBSkiQisubaiEGZ+iHq9fW32ikKUsLyEkcRy+8YZPoHq+SrI/GrFIDTWn eZLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cpyupyEq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k30-v6si8440462qtk.393.2018.06.15.12.51.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 15 Jun 2018 12:51:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cpyupyEq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:48989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTukc-0005Pd-JX for patch@linaro.org; Fri, 15 Jun 2018 15:51:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTue4-0000WB-NN for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTue1-0002cL-GH for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:28 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:43852) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTue1-0002bl-Ad for qemu-devel@nongnu.org; Fri, 15 Jun 2018 15:44:25 -0400 Received: by mail-pg0-x22c.google.com with SMTP id a14-v6so4852466pgw.10 for ; Fri, 15 Jun 2018 12:44:25 -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; bh=zOVWT9oyOnUXGeg0GOygk0Sk7eelIiTSGEWZKkbw/co=; b=cpyupyEqk1Mqy9ZJW+rxN0ixuiGO/lZ05bgKHYbQs2k0KZORaX1JOy6AIJE5+trDg4 0bFsfW3skcv8MdXzj+SUIkdQ9lkKj0+e+xNx7otrnQAHy1jdCfXTrwx9SA1RFwza4r1U 0AIpFPPvoPdpt1GKMI3FU+Lulp8AHpWcNW1Tw= 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; bh=zOVWT9oyOnUXGeg0GOygk0Sk7eelIiTSGEWZKkbw/co=; b=GigprvWhGzCJtxpBhua7BcnJkQ9074KGfV12XOshhXsx4ziyBT04/doj2daid8AwBQ Idcs96VEXHPM+FW2CDuj19E62Oo+fTzl0z+Te4snPFOz0gIDMB4nsbCnro5zdnN4nxhv ihH1YrzzWRoXnBSYk5gMFj+IFANEXOwDIY/r7AavOzVP6D7aNeBuGpdSQCjxSDLOPegv OXUrRsD9oMWWlw8QeTYKN8l9utxCXr2t+r3nZ048kJucpVcPB0hn3stuYb+t7148zqdI n4OnWfaagV5U0rV/i8POtD1RVG+5REEuq6YD6oKTWIVxs8wpNd49hUF8EdWHdeVVITbr dsxA== X-Gm-Message-State: APt69E1eHxSNfljBK7WCv3Hh68Ktn/CMYIUNMrmv9NJPACq6XC5foeTr QVSfXWKhQ4Hsxq7FNoAlppyvaotRp/I= X-Received: by 2002:a63:6d05:: with SMTP id i5-v6mr2825858pgc.321.1529091864036; Fri, 15 Jun 2018 12:44:24 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id 29-v6sm14038360pfj.14.2018.06.15.12.44.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Jun 2018 12:44:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 15 Jun 2018 09:43:48 -1000 Message-Id: <20180615194354.12489-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615194354.12489-1-richard.henderson@linaro.org> References: <20180615194354.12489-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22c Subject: [Qemu-devel] [PULL v2 13/19] translate-all: introduce assert_no_pages_locked X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" The appended adds assertions to make sure we do not longjmp with page locks held. Note that user-mode has nothing to check, since page_locks are !user-mode only. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 8 ++++++++ accel/tcg/cpu-exec.c | 1 + accel/tcg/translate-all.c | 7 +++++++ 3 files changed, 16 insertions(+) -- 2.17.1 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8d92e3cea9..4f07a17052 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -435,6 +435,14 @@ void tb_lock(void); void tb_unlock(void); void tb_lock_reset(void); +#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_DEBUG_TCG) +void assert_no_pages_locked(void); +#else +static inline void assert_no_pages_locked(void) +{ +} +#endif + #if !defined(CONFIG_USER_ONLY) /** diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 7570c59f09..d75c35380a 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -273,6 +273,7 @@ void cpu_exec_step_atomic(CPUState *cpu) tcg_debug_assert(!have_mmap_lock()); #endif tb_lock_reset(); + assert_no_pages_locked(); } if (in_exclusive_region) { diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 8b378586f4..c75298d08a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -658,6 +658,12 @@ do_assert_page_locked(const PageDesc *pd, const char *file, int line) #define assert_page_locked(pd) do_assert_page_locked(pd, __FILE__, __LINE__) +void assert_no_pages_locked(void) +{ + ht_pages_locked_debug_init(); + g_assert(g_hash_table_size(ht_pages_locked_debug) == 0); +} + #else /* !CONFIG_DEBUG_TCG */ #define assert_page_locked(pd) @@ -829,6 +835,7 @@ page_collection_lock(tb_page_addr_t start, tb_page_addr_t end) set->tree = g_tree_new_full(tb_page_addr_cmp, NULL, NULL, page_entry_destroy); set->max = NULL; + assert_no_pages_locked(); retry: g_tree_foreach(set->tree, page_entry_lock, NULL);