From patchwork Wed Apr 20 18:06:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563996 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4414447map; Wed, 20 Apr 2022 11:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztLyIxOFBh6n2bVoe0XtIPA/dyW1y/ejNu+ufAaB7ikne3sQzz5Hv9Fv6I37qdf9e9Id5L X-Received: by 2002:a81:18d7:0:b0:2eb:553e:f3ee with SMTP id 206-20020a8118d7000000b002eb553ef3eemr21809077ywy.393.1650479388933; Wed, 20 Apr 2022 11:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650479388; cv=none; d=google.com; s=arc-20160816; b=TlRsaJUJhVh//CD8bI9y7lQNP2nht8UaVgwYBxy3047n0fLmox3jZ3YTpUeLu10nmX GfAwmDc35cJD/yrZqGpawO5lMCJBCmd6Ww0jZn7uE713JnzzLBqazJDP83aLy3vw37T6 bgrzltfnMhDDqD0nL1KkKAlqX0QLT+m+q1KM09L//F5+rmBaR6+FCdloBsVN+38KUt53 WcdjUYa4y5VCZCO0kOnpzuI65ERKQVA/BgZiQ5E8hsP4UvF4uFC2Ve0xlkPMOC8/hWpO ZvqHrJJ9swuUtxmB2CK1jhcC/xTUU142Hz2JnmFPI8mfRPPMDLLqsi/srcgM3ZT8EORd vE7A== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qOm2StT5IGEkhcpPNeIDDUNyOCcShPcyMnYny7wZFf0=; b=dteajH4g30epxPqg4wjIFjR1jgBH7AOQIbyMmg7XFT/38vw0URRVAhkuYxs6r81jbq 4zRbmnJkQ9EQ7AbO4OWhG3J+bX7wbG/r/wItYwfkk7G3NzB3g2worsb0l4U3drpkdyme CIWlwVPWRpa7IftmUdxiHN+ts1vzBNRbCRreQqZBTTp50nR6yyj4VipXcCNbjwsUNKc0 UuVmKzlT1E5HxfLLaEYogTgQy20YEsKCV4ZDAIWGqgWoaPxcNCn1ejfw+vbHmr5jfrh9 gF9CJdsAIdOKDvqpknhp0GbCY4zXPZ3jszOeO3SuI0z0G2H1KUbukjXBXE5zt88L4XV8 DOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x9gSS7O4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e204-20020a2537d5000000b0064563891097si625483yba.167.2022.04.20.11.29.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x9gSS7O4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhF5I-0003SJ-Dk for patch@linaro.org; Wed, 20 Apr 2022 14:29:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEj0-0005wt-KL for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:46 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:36617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEiy-0001Iz-Sx for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:46 -0400 Received: by mail-pf1-x42e.google.com with SMTP id z16so2690468pfh.3 for ; Wed, 20 Apr 2022 11:06:44 -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 :mime-version:content-transfer-encoding; bh=qOm2StT5IGEkhcpPNeIDDUNyOCcShPcyMnYny7wZFf0=; b=x9gSS7O4VE4vVADiGzqkJKGvkeioIyU3lXeGY1cEOWB6X5CnkbwJ5Rl6DYAi39zusd S3EQumGHKh/GT0j9OLl3nhUl2BKFtMzXpAvxu5OzZ3/k2JUWY5gbPTqx9Oj5hb0L6Lix z9gs4ZRpItGdAyGhnoK2UItGDzuqxrYjZpCHKjqGXMz9J6x6t4P9xih5EEix1dR/7dcF P+DufUcrG9LjTMp6jSKB2c1OY65ZqKnBokuf9Bhw8HQSrULjhelz1m/XpKc5M2knz49+ 5NoNHKe5FjwXI2j1B3RNyxE15p/pDprZua8sUA5HX8yPM9eLT96bsl6BP1A7IY5JxrgM G6Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qOm2StT5IGEkhcpPNeIDDUNyOCcShPcyMnYny7wZFf0=; b=eyUJ7w5cBMspm170GDrnVDCnA/LLll1PlM34XhaY0gK3i7q5PYGIQ1+7BEq+7jv2Bn cGfjeRSmUnZcQfI1na7NaD7VN1wMBJkmQVo7RoRRI+8jxk/9POHF0ANFpM2HVdJzhj8e RbF3ymzErStzFbl7agH57hULs83CBEJigNkoMR3vYs0Pnnm+L3H6hY7tFkAyWiKwmFYY bkrh9hEG7nvpRmyWag1A0RYLp+ye1qDnUs1ERlLWJzLkogUTTZ3Mi4Nrc8OIzvOASRfu F0oLeTYJ7o9NRrVABa6TCtOwEDD3UW9ATkJwZFITsjSUCfNplYV0DgIaaCHKI71u/Nbb 4hIg== X-Gm-Message-State: AOAM531PIHW9fcIITVNoRBsA2o4dIJsdTiT76zR4DDWM79QXzZ9Uao5o /Oz4nKYIx+mD5dcpnJHkq+DvHJVaL9eFwQ== X-Received: by 2002:a05:6a00:170d:b0:50a:858e:2b6e with SMTP id h13-20020a056a00170d00b0050a858e2b6emr14105339pfc.48.1650478003579; Wed, 20 Apr 2022 11:06:43 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 22/39] linux-user: Expand log_page_dump inline Date: Wed, 20 Apr 2022 11:06:01 -0700 Message-Id: <20220420180618.1183855-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have extra stuff to log at the same time. Hoist the qemu_log_lock/unlock to the caller and use fprintf. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-23-richard.henderson@linaro.org> --- include/exec/log.h | 15 --------------- linux-user/main.c | 43 +++++++++++++++++++++++++++++-------------- linux-user/mmap.c | 7 ++++++- 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index 06ab9841ee..ad0a40cfeb 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -42,19 +42,4 @@ static inline void log_cpu_state_mask(int mask, CPUState *cpu, int flags) } } -#ifdef NEED_CPU_H -#if defined(CONFIG_USER_ONLY) -/* page_dump() output to the log file: */ -static inline void log_page_dump(const char *operation) -{ - FILE *logfile = qemu_log_trylock(); - if (logfile) { - fprintf(logfile, "page layout changed following %s\n", operation); - page_dump(logfile); - } - qemu_log_unlock(logfile); -} -#endif -#endif - #endif diff --git a/linux-user/main.c b/linux-user/main.c index 6aed4929ab..d263b2a669 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -857,21 +857,36 @@ int main(int argc, char **argv, char **envp) g_free(target_environ); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - qemu_log("guest_base %p\n", (void *)guest_base); - log_page_dump("binary load"); + FILE *f = qemu_log_trylock(); + if (f) { + fprintf(f, "guest_base %p\n", (void *)guest_base); + fprintf(f, "page layout changed following binary load\n"); + page_dump(f); - qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); - qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); - qemu_log("start_code 0x" TARGET_ABI_FMT_lx "\n", info->start_code); - qemu_log("start_data 0x" TARGET_ABI_FMT_lx "\n", info->start_data); - qemu_log("end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); - qemu_log("start_stack 0x" TARGET_ABI_FMT_lx "\n", info->start_stack); - qemu_log("brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); - qemu_log("entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); - qemu_log("argv_start 0x" TARGET_ABI_FMT_lx "\n", info->arg_start); - qemu_log("env_start 0x" TARGET_ABI_FMT_lx "\n", - info->arg_end + (abi_ulong)sizeof(abi_ulong)); - qemu_log("auxv_start 0x" TARGET_ABI_FMT_lx "\n", info->saved_auxv); + fprintf(f, "start_brk 0x" TARGET_ABI_FMT_lx "\n", + info->start_brk); + fprintf(f, "end_code 0x" TARGET_ABI_FMT_lx "\n", + info->end_code); + fprintf(f, "start_code 0x" TARGET_ABI_FMT_lx "\n", + info->start_code); + fprintf(f, "start_data 0x" TARGET_ABI_FMT_lx "\n", + info->start_data); + fprintf(f, "end_data 0x" TARGET_ABI_FMT_lx "\n", + info->end_data); + fprintf(f, "start_stack 0x" TARGET_ABI_FMT_lx "\n", + info->start_stack); + fprintf(f, "brk 0x" TARGET_ABI_FMT_lx "\n", + info->brk); + fprintf(f, "entry 0x" TARGET_ABI_FMT_lx "\n", + info->entry); + fprintf(f, "argv_start 0x" TARGET_ABI_FMT_lx "\n", + info->arg_start); + fprintf(f, "env_start 0x" TARGET_ABI_FMT_lx "\n", + info->arg_end + (abi_ulong)sizeof(abi_ulong)); + fprintf(f, "auxv_start 0x" TARGET_ABI_FMT_lx "\n", + info->saved_auxv); + qemu_log_unlock(f); + } } target_set_brk(info->brk); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index a861f1e1d1..48e1373796 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -630,7 +630,12 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int target_prot, the_end: trace_target_mmap_complete(start); if (qemu_loglevel_mask(CPU_LOG_PAGE)) { - log_page_dump(__func__); + FILE *f = qemu_log_trylock(); + if (f) { + fprintf(f, "page layout changed following mmap\n"); + page_dump(f); + qemu_log_unlock(f); + } } tb_invalidate_phys_range(start, start + len); mmap_unlock();