From patchwork Mon Oct 31 14:13:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 80186 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp144084qge; Mon, 31 Oct 2016 07:25:10 -0700 (PDT) X-Received: by 10.55.33.165 with SMTP id f37mr27937211qki.179.1477923910660; Mon, 31 Oct 2016 07:25:10 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id v18si17702578qkb.171.2016.10.31.07.25.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 31 Oct 2016 07:25:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:35950 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1DWQ-0002eE-4Q for patch@linaro.org; Mon, 31 Oct 2016 10:25:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1DLY-0000EW-Jy for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:13:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1DLU-0002uj-IE for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:13:56 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c1DLU-0002uH-As for qemu-devel@nongnu.org; Mon, 31 Oct 2016 10:13:52 -0400 Received: by mail-wm0-x242.google.com with SMTP id 68so11882609wmz.2 for ; Mon, 31 Oct 2016 07:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NkEw2zUS4Y90MT5WYGitzzlcjmo1fin2PwQ8HFpX6vE=; b=Z2JeuB3ZBrLdazzOHuGBphS9WUZyaKIuOwDD03tWr22TIeU7IrAqkAe6+e9CleJOp3 6jBuM2OYGdg338EEn2bEPYqwtmywTUunznPP4q23hVRnqfNUqMsSsIYUGrW+u2NEb3Fj VKf1jWfE3UZEC0g7x6rpvFScmozoQoJ1P1WeII3yRUc+K2FtjJBMly+U918/mIqAVzNU b4h8h0IyJz5Jmvescxh7dcxxTgnGPp8xu0c4sM9CnM9ndItiqGKFzkVt7Ux0ILbSQzSy PbQ4uCkrjbYdEgG2cjS8NaB9Jwbfo9z2RibB6mhpY3S1TG6OtopoHQgyX+KtYSJmJFjS Q1Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=NkEw2zUS4Y90MT5WYGitzzlcjmo1fin2PwQ8HFpX6vE=; b=bhmzZYtoap94EYwPmIfUEP14rMTT7G45bEFUIHomuRAOfuf/9E7W7O3yjS7up1QPP5 /5yf4scwIKiwa0oL6f77ZwW4gtWttqx/2Qr29sxLWmxm2ikqjSSfduInpShgo9xSrINC O6KaKXCRNLKceuaGtqKMeaw6UEgGXbbgbJllPbF8ZvUq/3GY1LepP15pGbL5bz5Yb4y1 NkmPyPomajXkR0igF1p44Gyd32U2rNrYlA53fXcNK8OVRl1MUkfs9H1jZg8Y6vDDEp9D Vog24e+qeLlnkdPYa8n/WJPXqvMFzN0PqYrVKf9CC/qCjZKyhRQ1jpaxlXbxNy91bWJg zDlQ== X-Gm-Message-State: ABUngvf89eYyJ/CfIaI5Bc6QtGoSgvohawiuF4D+u0UYYttzD6qzZmXYfZ6pgoNKeSfAhQ== X-Received: by 10.194.119.162 with SMTP id kv2mr22057340wjb.182.1477923231049; Mon, 31 Oct 2016 07:13:51 -0700 (PDT) Received: from donizetti.lan (dynamic-adsl-78-12-246-178.clienti.tiscali.it. [78.12.246.178]) by smtp.gmail.com with ESMTPSA id p13sm25052133wmd.20.2016.10.31.07.13.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 07:13:50 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 31 Oct 2016 15:13:28 +0100 Message-Id: <1477923215-30323-8-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477923215-30323-1-git-send-email-pbonzini@redhat.com> References: <1477923215-30323-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 Subject: [Qemu-devel] [PULL 07/14] translate-all: Add assert_(memory|tb)_lock annotations 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: =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée This adds calls to the assert_(memory|tb)_lock for all public APIs which are documented as needing them held for linux-user mode. The asserts are NOPs for system-mode although these will be converted when MTTCG is enabled. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20161027151030.20863-9-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- translate-all.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/translate-all.c b/translate-all.c index fad2646..3ff43ec 100644 --- a/translate-all.c +++ b/translate-all.c @@ -473,6 +473,10 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc) void **lp; int i; + if (alloc) { + assert_memory_lock(); + } + /* Level 1. Always allocated. */ lp = l1_map + ((index >> v_l1_shift) & (v_l1_size - 1)); @@ -839,6 +843,8 @@ static TranslationBlock *tb_alloc(target_ulong pc) { TranslationBlock *tb; + assert_tb_lock(); + if (tcg_ctx.tb_ctx.nb_tbs >= tcg_ctx.code_gen_max_blocks) { return NULL; } @@ -852,6 +858,8 @@ static TranslationBlock *tb_alloc(target_ulong pc) /* Called with tb_lock held. */ void tb_free(TranslationBlock *tb) { + assert_tb_lock(); + /* In practice this is mostly used for single use temporary TB Ignore the hard cases and just back up if this TB happens to be the last one generated. */ @@ -1093,6 +1101,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr) uint32_t h; tb_page_addr_t phys_pc; + assert_tb_lock(); + atomic_set(&tb->invalid, true); /* remove the TB from the hash list */ @@ -1150,7 +1160,7 @@ static void build_page_bitmap(PageDesc *p) tb_end = tb_start + tb->size; if (tb_end > TARGET_PAGE_SIZE) { tb_end = TARGET_PAGE_SIZE; - } + } } else { tb_start = 0; tb_end = ((tb->pc + tb->size) & ~TARGET_PAGE_MASK); @@ -1173,6 +1183,8 @@ static inline void tb_alloc_page(TranslationBlock *tb, bool page_already_protected; #endif + assert_memory_lock(); + tb->page_addr[n] = page_addr; p = page_find_alloc(page_addr >> TARGET_PAGE_BITS, 1); tb->page_next[n] = p->first_tb; @@ -1229,6 +1241,8 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc, { uint32_t h; + assert_memory_lock(); + /* add in the page list */ tb_alloc_page(tb, 0, phys_pc & TARGET_PAGE_MASK); if (phys_page2 != -1) { @@ -1260,6 +1274,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, #ifdef CONFIG_PROFILER int64_t ti; #endif + assert_memory_lock(); phys_pc = get_page_addr_code(env, pc); if (use_icount && !(cflags & CF_IGNORE_ICOUNT)) { @@ -1388,6 +1403,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, */ void tb_invalidate_phys_range(tb_page_addr_t start, tb_page_addr_t end) { + assert_memory_lock(); + while (start < end) { tb_invalidate_phys_page_range(start, end, 0); start &= TARGET_PAGE_MASK; @@ -1424,6 +1441,8 @@ void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end, uint32_t current_flags = 0; #endif /* TARGET_HAS_PRECISE_SMC */ + assert_memory_lock(); + p = page_find(start >> TARGET_PAGE_BITS); if (!p) { return; @@ -2031,6 +2050,7 @@ void page_set_flags(target_ulong start, target_ulong end, int flags) assert(end < ((target_ulong)1 << L1_MAP_ADDR_SPACE_BITS)); #endif assert(start < end); + assert_memory_lock(); start = start & TARGET_PAGE_MASK; end = TARGET_PAGE_ALIGN(end);