From patchwork Thu Jun 14 19:31:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138627 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2535632lji; Thu, 14 Jun 2018 12:48:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIBTju+PbR+nPGccv6f7wdZkUSomC66pV9EEL1a6HINddYTbkYSIByn6iQmKhunLL2IoKoa X-Received: by 2002:a0c:a995:: with SMTP id a21-v6mr3674984qvb.173.1529005705470; Thu, 14 Jun 2018 12:48:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529005705; cv=none; d=google.com; s=arc-20160816; b=Pv77wN8Ah1a7T1MAcY1i2HxLYkiCZerzrvU9j3EBESCwkXbC0CbTmArsQQyh/RBKDW +S2duqSohgdpaCtYYRNT1GB6hXXkahtGjNCa69a075CYOoFmS0T9cTHtMKLheYvVda9G eYtx+u1LpV0Qmvf7agYlJbdie0K3RK4Z+3lStKOjKWLeuCBH2yiIdZhx6dRswUNZBNhq knVlfq+wcSmHkVujDnrpX/2+gYF7QFzxXogD5pSvxkKikBye8iiq3vPEfW0yKXnHDXIS McQ9dgg2c5ROhOlJD/Tdax+4uxSfm6LLfW5jjlDYMyh8QqLO+lTFyDQm3lyrUUU96k1i xTkQ== 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=zLcISsWRZ421wCIGWhD88VN2O5w5GA8j9/OMTA3FiXQ=; b=MjoNrqsktM0G/9rZEX38rQMvpTeDYb22RB+px1Fn/lyeTsWocP3BUuEXP60j6A1dZO qkfne0sKoy9dzqACbAww2GP98haQEkpV+e8rTGYH2UTupX9CVVyqQ31RvrKo+EE1XaTv 8rwt5dgiSV8mTUWLhM5TKb+nvf1z2fvH4KIF/wRgV7P/poL0W3FdSondlGXTyT4RrtoJ K7JZUB1IRguek362JZv7OszTOTfa+C0ppK/wAb9dyeGB6VMs8ELMNhs7dPZsvsIW2ATQ G3FI9cDTeUe4LUkg89XZjtGQXJHsK3Co7rfmrA886CEbmKw0/Ru4W9JBa5g1l4qcZr+F TzAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=EP2IURmY; 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 o34-v6si5142173qve.171.2018.06.14.12.48.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 14 Jun 2018 12:48:25 -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=EP2IURmY; 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]:42439 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTYEK-00038T-RA for patch@linaro.org; Thu, 14 Jun 2018 15:48:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37103) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fTXyk-00077y-E1 for qemu-devel@nongnu.org; Thu, 14 Jun 2018 15:32:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fTXyj-0005x9-AQ for qemu-devel@nongnu.org; Thu, 14 Jun 2018 15:32:18 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:35626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fTXyj-0005wL-4M for qemu-devel@nongnu.org; Thu, 14 Jun 2018 15:32:17 -0400 Received: by mail-pg0-x241.google.com with SMTP id 15-v6so3366657pge.2 for ; Thu, 14 Jun 2018 12:32:17 -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=zLcISsWRZ421wCIGWhD88VN2O5w5GA8j9/OMTA3FiXQ=; b=EP2IURmYz8p1ccyC3YKxK46WtEN7jyJG8/M0x650Pb9OeY6UE5ztWuIXApHkFGH7Ff 9Nl7JUgTCD0zrKC3Yz/yEATTcjv4YIkwwDlqKZ2+gc5l1ukD0PRanLHQqvRUaNDeNszp I8RxLYUzGm6eWGn84recCGqq5FoRg56dETuRw= 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=zLcISsWRZ421wCIGWhD88VN2O5w5GA8j9/OMTA3FiXQ=; b=Xl7ls4iUHUQZxDJcO04F/n86IHoWjrps/WJ33H3WV493TaZYJ+9Q8iwSQuslidLUCf 1aEPaOGMZ0J5HnR55VUE4qLNzFvfOuaVuxLMZhPbCf5nVhzfSmjLNCKgsHvTPDFfRUXK /SFddgLgaeobFCJ1YrxBIYHp9streD5Oubo/TWbe6ENKlaKsrX2bVMLGDrYFkBNAiyGe uY6d0PLkONR5uDgDHZaWzjW09CppyQZzch0CaPu/j/puBuiSrRwNvDEkXJOVI1x8yy+k 0MdFUdYUCOqP1pHnhWqOmdeAySy67k1gHGvk9Tg7Qrvkvc1TcEpaJCuiJSPB/SmGh7mv cOyA== X-Gm-Message-State: APt69E0UEyaYrSd7unjI6EA2XRyZw4XYDN6MKQVybEv+XhUnWhHeTSBJ 6vk9d/ZCkoNDohU2QmG9fl3zQoNLlZw= X-Received: by 2002:a63:6d41:: with SMTP id i62-v6mr3379574pgc.286.1529004735966; Thu, 14 Jun 2018 12:32:15 -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 x24-v6sm11532184pfj.104.2018.06.14.12.32.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jun 2018 12:32:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 14 Jun 2018 09:31:42 -1000 Message-Id: <20180614193147.29680-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180614193147.29680-1-richard.henderson@linaro.org> References: <20180614193147.29680-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::241 Subject: [Qemu-devel] [PULL 13/18] 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 a647cf8841..b9e3018aee 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) struct MemoryRegion *iotlb_to_region(CPUState *cpu, 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);