From: "Alex Bennée" <alex.bennee@linaro.org>
To: mttcg@listserver.greensocs.com, qemu-devel@nongnu.org,
fred.konrad@greensocs.com, a.rigo@virtualopensystems.com,
serge.fdrv@gmail.com, cota@braap.org, bobby.prani@gmail.com
Cc: mark.burton@greensocs.com, pbonzini@redhat.com,
jan.kiszka@siemens.com, rth@twiddle.net,
peter.maydell@linaro.org, claudio.fontana@huawei.com,
"Alex Bennée" <alex.bennee@linaro.org>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>
Subject: [Qemu-devel] [RFC v3 07/19] translate-all: Add assert_memory_lock annotations
Date: Fri, 3 Jun 2016 21:40:16 +0100 [thread overview]
Message-ID: <1464986428-6739-8-git-send-email-alex.bennee@linaro.org> (raw)
In-Reply-To: <1464986428-6739-1-git-send-email-alex.bennee@linaro.org>
This adds calls to the assert_memory_lock for all public APIs which are
documented as holding the mmap_lock for user-mode.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
linux-user/elfload.c | 4 ++++
translate-all.c | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index bb2558f..f72c275 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -1839,6 +1839,8 @@ static void load_elf_image(const char *image_name, int image_fd,
info->pt_dynamic_addr = 0;
#endif
+ mmap_lock();
+
/* Find the maximum size of the image and allocate an appropriate
amount of memory to handle that. */
loaddr = -1, hiaddr = 0;
@@ -1999,6 +2001,8 @@ static void load_elf_image(const char *image_name, int image_fd,
load_symbols(ehdr, image_fd, load_bias);
}
+ mmap_unlock();
+
close(image_fd);
return;
diff --git a/translate-all.c b/translate-all.c
index 8b162ff..aba6cb6 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -453,6 +453,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));
@@ -819,6 +823,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;
}
@@ -831,6 +837,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. */
@@ -1047,6 +1055,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();
+
/* remove the TB from the hash list */
phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
h = tb_hash_func(phys_pc, tb->pc, tb->flags);
@@ -1125,6 +1135,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;
@@ -1181,6 +1193,8 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,
{
uint32_t h;
+ assert_memory_lock();
+
/* add in the hash table */
h = tb_hash_func(phys_pc, tb->pc, tb->flags);
qht_insert(&tcg_ctx.tb_ctx.htable, tb, h);
@@ -1212,6 +1226,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)) {
@@ -1339,6 +1354,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;
@@ -1375,6 +1392,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;
@@ -1972,6 +1991,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);
--
2.7.4
next prev parent reply other threads:[~2016-06-03 20:40 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 20:40 [Qemu-devel] [RFC v3 00/19] Base enabling patches for MTTCG Alex Bennée
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 01/19] cpus: make all_vcpus_paused() return bool Alex Bennée
2016-06-07 15:05 ` Richard Henderson
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 02/19] translate_all: DEBUG_FLUSH -> DEBUG_TB_FLUSH Alex Bennée
2016-06-07 14:54 ` Richard Henderson
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 03/19] translate-all: add DEBUG_LOCKING asserts Alex Bennée
2016-06-23 14:34 ` Sergey Fedorov
2016-06-23 17:14 ` Alex Bennée
2016-06-23 18:43 ` Sergey Fedorov
2016-07-01 23:21 ` Richard Henderson
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 04/19] docs: new design document multi-thread-tcg.txt (DRAFTING) Alex Bennée
2016-06-23 21:33 ` Sergey Fedorov
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 05/19] exec: add assert_debug_safe and notes on debug structures Alex Bennée
2016-06-24 15:28 ` Sergey Fedorov
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 06/19] tcg: comment on which functions have to be called with tb_lock held Alex Bennée
2016-06-24 15:38 ` Sergey Fedorov
2016-06-03 20:40 ` Alex Bennée [this message]
2016-06-24 15:48 ` [Qemu-devel] [RFC v3 07/19] translate-all: Add assert_memory_lock annotations Sergey Fedorov
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 08/19] tcg: protect TBContext with tb_lock Alex Bennée
2016-07-01 23:40 ` Richard Henderson
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 09/19] target-arm/arm-powerctl: wake up sleeping CPUs Alex Bennée
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 10/19] tcg: cpus rm tcg_exec_all() Alex Bennée
2016-06-24 17:09 ` Sergey Fedorov
2016-07-01 23:50 ` Richard Henderson
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 11/19] tcg: add options for enabling MTTCG Alex Bennée
2016-06-27 21:07 ` Sergey Fedorov
2016-07-22 16:17 ` Alex Bennée
2016-07-01 23:53 ` Richard Henderson
2016-07-02 7:11 ` Alex Bennée
2016-07-02 7:38 ` Sergey Fedorov
2016-07-04 10:10 ` Paolo Bonzini
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 12/19] tcg: add kick timer for single-threaded vCPU emulation Alex Bennée
2016-06-27 21:20 ` Sergey Fedorov
2016-07-02 0:17 ` Richard Henderson
2016-07-02 7:36 ` Sergey Fedorov
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 13/19] tcg: rename tcg_current_cpu to tcg_current_rr_cpu Alex Bennée
2016-06-06 15:30 ` Paolo Bonzini
2016-06-06 16:05 ` Alex Bennée
2016-06-06 17:05 ` Paolo Bonzini
2016-06-06 17:26 ` Alex Bennée
2016-06-06 18:25 ` Paolo Bonzini
2016-06-07 12:59 ` Alex Bennée
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 14/19] tcg: remove global exit_request Alex Bennée
2016-06-28 16:20 ` Sergey Fedorov
2016-08-03 11:42 ` Alex Bennée
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 15/19] tcg: drop global lock during TCG code execution Alex Bennée
2016-06-28 16:54 ` Sergey Fedorov
2016-08-10 13:51 ` Alex Bennée
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 16/19] tcg: move locking for tb_invalidate_phys_page_range up Alex Bennée
2016-06-28 19:43 ` Sergey Fedorov
2016-06-28 19:51 ` Sergey Fedorov
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 17/19] tcg: enable thread-per-vCPU Alex Bennée
2016-06-29 14:09 ` Sergey Fedorov
2016-08-10 14:44 ` Alex Bennée
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 18/19] tcg: Ensure safe TB lookup out of 'tb_lock' Alex Bennée
2016-06-03 20:40 ` [Qemu-devel] [RFC v3 19/19] cpu-exec: remove tb_lock from the hot-path Alex Bennée
2016-06-29 14:35 ` Sergey Fedorov
2016-06-29 14:47 ` Alex Bennée
2016-06-29 14:52 ` Sergey Fedorov
2016-06-29 16:08 ` Alex Bennée
2016-06-30 9:24 ` Sergey Fedorov
2016-06-04 14:40 ` [Qemu-devel] [RFC v3 00/19] Base enabling patches for MTTCG Pranith Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464986428-6739-8-git-send-email-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=a.rigo@virtualopensystems.com \
--cc=bobby.prani@gmail.com \
--cc=claudio.fontana@huawei.com \
--cc=cota@braap.org \
--cc=crosthwaite.peter@gmail.com \
--cc=fred.konrad@greensocs.com \
--cc=jan.kiszka@siemens.com \
--cc=mark.burton@greensocs.com \
--cc=mttcg@listserver.greensocs.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=rth@twiddle.net \
--cc=serge.fdrv@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).