From nobody Tue Nov 26 16:30:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706544711; cv=none; d=zohomail.com; s=zohoarc; b=FpsJ8s2zOlQqjF68zfRM9QZD8zKmnvPIuYBHRF+CqP87hJCcqLNAXOD31ZHPUkV6FutIVm0xk3RFOCTBUTrktDuzG3OqoMywW5ZvOndG0dn6qZVzoBVpynWkHmCeRKkZI51sJ+bGYpUcE5ykGJ6IAHV8Jo+RvDQ7IVBGK8oek2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706544711; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=W8ts9LydiTk8L1/WhwNtnM7rJn30kmj1TlpmRZR/snA=; b=nbMz9j8K3gGvIKF7FeWK3FyNk5Q/tNshv4zbxJGYySkVk3re+5FU35Zu3mjLTmWp/9kHqrgp3jMhHJHCulr3fmipxFA6zUWt9Jzd3pUGEUlI8fq9RuxZVIkwONYsrM8DgQc/5rWC2//NGBNDyFy0HnZq3Y6fHOUIJ22TeIy79TY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706544711323168.34420060387845; Mon, 29 Jan 2024 08:11:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUUDV-0007sF-Au; Mon, 29 Jan 2024 11:10:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUUDT-0007rA-LB for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:10:35 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUUDQ-0002eL-GH for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:10:35 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-33af6129f3cso149269f8f.2 for ; Mon, 29 Jan 2024 08:10:32 -0800 (PST) Received: from localhost.localdomain (adsl-245.37.6.163.tellas.gr. [37.6.163.245]) by smtp.gmail.com with ESMTPSA id co6-20020a0560000a0600b0033af4df8e1esm1219957wrb.47.2024.01.29.08.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706544630; x=1707149430; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=W8ts9LydiTk8L1/WhwNtnM7rJn30kmj1TlpmRZR/snA=; b=Lz3w/OEtnlfdtZVK/nQOQ0ycOm+q7IBMvzc/Ihl/ixM47CyDSEMPQ1sAGFC1TaO8pG ghGIE4Ad/3lxc26byuFFt8ob1zKYE+40Ie2IPSF6BV53/+LFVlZ3EkfbkGqGCESWxQEG LZ8lFbP8GTTlYWgzKKEdiuMk7Rz/9DGOE20C07OnkRMMYoBn40Jxs+HD8kSlIFPMqbwA 1kjnyUoj44a8r3viwzSV7eQbbVQ0XexxdszUguis5fgrjMsZZpl5CGAug8MWgaH35d/u PBdMnjcEoR9MASK+HVa40nWdzsy/VY3Edmx27zSek8z4tY6heR2BjyaJijpLb+cOCsZO K6PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706544630; x=1707149430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W8ts9LydiTk8L1/WhwNtnM7rJn30kmj1TlpmRZR/snA=; b=clths0T66urTncao8pn+raKp4bgL2JIaC3B+9Nj/Q1szz600NImN10sHIBZlIy7PgW 4NywB0nndW4NsNIn7rZxMlxqRTYaL9ik+qv8X8eL5ZuJJk5Vf6LmkVfGJHdmKYDMBr5W D+HXkrkUkeJ8sH2gZwKMuSdndFVdLJAjRyRIYS3ZqnsI2j1nY37ACFQhd1EIBUaV+G8M Spwx3Wv9kwP/i87LIgnzmaXSfOzvrTRlUKEkfUhM/wHPK+bItEby+ZsSpq7qWJE1G71M sA6hi4HbOiozITUfHveSYW64U+UJd5ZxCkhxEe8ZywPzYZC+6ulCNV/t8MWbUDkB3YLo YOKw== X-Gm-Message-State: AOJu0Yy1lg95zE4QKvRSr/35kFGt2aqQhR8s6b/fkOz6AtFq8zioV9YA jhiJlwuckuQJHqR0rNRfA3ewbC5yd+6brdzNsbgS5UqlgdudYcoRD5ujm7AL7OSVuuRxjA+jaD6 MxZM= X-Google-Smtp-Source: AGHT+IGGV4Zm4671PjUjI3AJyiVZTsWWQyu8wt1CUfZyBnvmPhvhHHwbklSJKmThDd16ZmR8xqdFuA== X-Received: by 2002:a05:6000:890:b0:336:9e8a:6fde with SMTP id cs16-20020a056000089000b003369e8a6fdemr4741514wrb.22.1706544630130; Mon, 29 Jan 2024 08:10:30 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v3 1/6] hw/arm/strongarm.c: convert DPRINTF to trace events and guest errors Date: Mon, 29 Jan 2024 18:09:36 +0200 Message-Id: <39db71dd87bf2007cf7812f3d91dde53887f1f2f.1706544115.git.manos.pitsidianakis@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x434.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=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706544712172100002 Content-Type: text/plain; charset="utf-8" Tracing DPRINTFs to stderr might not be desired. A developer that relies on trace events should be able to opt-in to each trace event and rely on QEMU's log redirection, instead of stderr by default. This commit converts DPRINTFs in this file that are used for tracing into trace events. DPRINTFs that report guest errors are logged with LOG_GUEST_ERROR.# Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e --- hw/arm/strongarm.c | 82 ++++++++++++++++++++++++++++----------------- hw/arm/trace-events | 3 ++ 2 files changed, 55 insertions(+), 30 deletions(-) diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c index 7fd99a0f14..823b4931b0 100644 --- a/hw/arm/strongarm.c +++ b/hw/arm/strongarm.c @@ -46,8 +46,7 @@ #include "qemu/log.h" #include "qom/object.h" #include "target/arm/cpu-qom.h" - -//#define DEBUG +#include "trace.h" =20 /* TODO @@ -66,12 +65,6 @@ - Enhance UART with modem signals */ =20 -#ifdef DEBUG -# define DPRINTF(format, ...) printf(format , ## __VA_ARGS__) -#else -# define DPRINTF(format, ...) do { } while (0) -#endif - static struct { hwaddr io_base; int irq; @@ -151,8 +144,9 @@ static uint64_t strongarm_pic_mem_read(void *opaque, hw= addr offset, case ICPR: return s->pending; default: - printf("%s: Bad register offset 0x" HWADDR_FMT_plx "\n", - __func__, offset); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad register offset 0x"HWADDR_FMT_plx"\n", + __func__, offset); return 0; } } @@ -173,8 +167,9 @@ static void strongarm_pic_mem_write(void *opaque, hwadd= r offset, s->int_idle =3D (value & 1) ? 0 : ~0; break; default: - printf("%s: Bad register offset 0x" HWADDR_FMT_plx "\n", - __func__, offset); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad register offset 0x"HWADDR_FMT_plx"\n", + __func__, offset); break; } strongarm_pic_update(s); @@ -333,7 +328,9 @@ static uint64_t strongarm_rtc_read(void *opaque, hwaddr= addr, ((qemu_clock_get_ms(rtc_clock) - s->last_hz) << 15) / (1000 * ((s->rttr & 0xffff) + 1)); default: - printf("%s: Bad register 0x" HWADDR_FMT_plx "\n", __func__, addr); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad rtc register read 0x"HWADDR_FMT_plx"\n", + __func__, addr); return 0; } } @@ -375,7 +372,9 @@ static void strongarm_rtc_write(void *opaque, hwaddr ad= dr, break; =20 default: - printf("%s: Bad register 0x" HWADDR_FMT_plx "\n", __func__, addr); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad rtc register write 0x"HWADDR_FMT_plx"\n", + __func__, addr); } } =20 @@ -556,12 +555,12 @@ static uint64_t strongarm_gpio_read(void *opaque, hwa= ddr offset, =20 case GPSR: /* GPIO Pin-Output Set registers */ qemu_log_mask(LOG_GUEST_ERROR, - "strongarm GPIO: read from write only register GPSR\= n"); + "%s: read from write only register GPSR\n", __func__= ); return 0; =20 case GPCR: /* GPIO Pin-Output Clear registers */ qemu_log_mask(LOG_GUEST_ERROR, - "strongarm GPIO: read from write only register GPCR\= n"); + "%s: read from write only register GPCR\n", __func__= ); return 0; =20 case GRER: /* GPIO Rising-Edge Detect Enable registers */ @@ -581,7 +580,9 @@ static uint64_t strongarm_gpio_read(void *opaque, hwadd= r offset, return s->status; =20 default: - printf("%s: Bad offset 0x" HWADDR_FMT_plx "\n", __func__, offset); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad gpio read offset 0x"HWADDR_FMT_plx"\n", + __func__, offset); } =20 return 0; @@ -626,7 +627,9 @@ static void strongarm_gpio_write(void *opaque, hwaddr o= ffset, break; =20 default: - printf("%s: Bad offset 0x" HWADDR_FMT_plx "\n", __func__, offset); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad write offset 0x"HWADDR_FMT_plx"\n", + __func__, offset); } } =20 @@ -782,7 +785,9 @@ static uint64_t strongarm_ppc_read(void *opaque, hwaddr= offset, return s->ppfr | ~0x7f001; =20 default: - printf("%s: Bad offset 0x" HWADDR_FMT_plx "\n", __func__, offset); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad ppc read offset 0x"HWADDR_FMT_plx "\n", + __func__, offset); } =20 return 0; @@ -817,7 +822,9 @@ static void strongarm_ppc_write(void *opaque, hwaddr of= fset, break; =20 default: - printf("%s: Bad offset 0x" HWADDR_FMT_plx "\n", __func__, offset); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad ppc write offset 0x"HWADDR_FMT_plx"\n", + __func__, offset); } } =20 @@ -1029,8 +1036,13 @@ static void strongarm_uart_update_parameters(StrongA= RMUARTState *s) s->char_transmit_time =3D (NANOSECONDS_PER_SECOND / speed) * frame_si= ze; qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp); =20 - DPRINTF(stderr, "%s speed=3D%d parity=3D%c data=3D%d stop=3D%d\n", s->= chr->label, - speed, parity, data_bits, stop_bits); + trace_strongarm_uart_update_parameters((s->chr.chr ? + s->chr.chr->label : "NULL") ?: + "NULL", + speed, + parity, + data_bits, + stop_bits); } =20 static void strongarm_uart_rx_to(void *opaque) @@ -1164,7 +1176,9 @@ static uint64_t strongarm_uart_read(void *opaque, hwa= ddr addr, return s->utsr1; =20 default: - printf("%s: Bad register 0x" HWADDR_FMT_plx "\n", __func__, addr); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad uart register read 0x"HWADDR_FMT_plx"\n", + __func__, addr); return 0; } } @@ -1221,7 +1235,9 @@ static void strongarm_uart_write(void *opaque, hwaddr= addr, break; =20 default: - printf("%s: Bad register 0x" HWADDR_FMT_plx "\n", __func__, addr); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad uart register write 0x"HWADDR_FMT_plx"\n", + __func__, addr); } } =20 @@ -1434,7 +1450,7 @@ static uint64_t strongarm_ssp_read(void *opaque, hwad= dr addr, return 0xffffffff; } if (s->rx_level < 1) { - printf("%s: SSP Rx Underrun\n", __func__); + trace_strongarm_ssp_read_underrun(); return 0xffffffff; } s->rx_level--; @@ -1443,7 +1459,9 @@ static uint64_t strongarm_ssp_read(void *opaque, hwad= dr addr, strongarm_ssp_fifo_update(s); return retval; default: - printf("%s: Bad register 0x" HWADDR_FMT_plx "\n", __func__, addr); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad ssp register read 0x"HWADDR_FMT_plx"\n", + __func__, addr); break; } return 0; @@ -1458,8 +1476,8 @@ static void strongarm_ssp_write(void *opaque, hwaddr = addr, case SSCR0: s->sscr[0] =3D value & 0xffbf; if ((s->sscr[0] & SSCR0_SSE) && SSCR0_DSS(value) < 4) { - printf("%s: Wrong data size: %i bits\n", __func__, - (int)SSCR0_DSS(value)); + qemu_log_mask(LOG_GUEST_ERROR, "%s: Wrong data size: %i bits\n= ", + __func__, (int)SSCR0_DSS(value)); } if (!(value & SSCR0_SSE)) { s->sssr =3D 0; @@ -1471,7 +1489,9 @@ static void strongarm_ssp_write(void *opaque, hwaddr = addr, case SSCR1: s->sscr[1] =3D value & 0x2f; if (value & SSCR1_LBM) { - printf("%s: Attempt to use SSP LBM mode\n", __func__); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Attempt to use SSP LBM mode\n", + __func__); } strongarm_ssp_fifo_update(s); break; @@ -1509,7 +1529,9 @@ static void strongarm_ssp_write(void *opaque, hwaddr = addr, break; =20 default: - printf("%s: Bad register 0x" HWADDR_FMT_plx "\n", __func__, addr); + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Bad ssp register write 0x"HWADDR_FMT_plx"\n", + __func__, addr); break; } } diff --git a/hw/arm/trace-events b/hw/arm/trace-events index cdc1ea06a8..7c56943215 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -55,3 +55,6 @@ smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifi= er node for iommu mr=3D%s smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu= mr=3D%s" smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, = uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=3D%s asid=3D%d vmi= d=3D%d iova=3D0x%"PRIx64" tg=3D%d num_pages=3D0x%"PRIx64 =20 +# strongarm.c +strongarm_uart_update_parameters(const char *label, int speed, char parity= , int data_bits, int stop_bits) "%s speed=3D%d parity=3D%c data=3D%d stop= =3D%d" +strongarm_ssp_read_underrun(void) "SSP rx underrun" --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89 From nobody Tue Nov 26 16:30:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706544673; cv=none; d=zohomail.com; s=zohoarc; b=B4DcfDqY90rTqH1r36mZ3LkIdAM80WJjOdLf29X4uVz7OcwW0IEsluzhZx6wwGu1QtePqqNva57t+QuKoHwDMIDo8RSeNmQuZ5WIFuQ06yBXs+m5Z07wk/ts/tj5qtxlP/DRGrpqIw8Hvf7LRT5DBKd5IbewUiVVDnmK27Y3UQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706544673; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jJrBQU8/K6RcUc2wQkGztYkcJD87aocyjGftJaoYKA0=; b=dMBRZPUlPc7R/0KqI0YbbZfXrzWSSXwndSuiHukNcdJEWkQA7LMVKtqaVSMOuRz9F+XVDbWCMtqblD5KfWw/FnXz13ibsDEI9M9Zd9TKPRNuY3TWrnQv3M22MQjca6ZoWgatwEv8diIBiKdVTYy2gGDQD6BKNPbV6sPhrsuLr2Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706544673319208.5201222528542; Mon, 29 Jan 2024 08:11:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUUDX-0007tT-Eg; Mon, 29 Jan 2024 11:10:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUUDW-0007su-Av for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:10:38 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUUDT-0002fC-Rs for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:10:38 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40e76109cdeso39732685e9.0 for ; Mon, 29 Jan 2024 08:10:35 -0800 (PST) Received: from localhost.localdomain (adsl-245.37.6.163.tellas.gr. [37.6.163.245]) by smtp.gmail.com with ESMTPSA id co6-20020a0560000a0600b0033af4df8e1esm1219957wrb.47.2024.01.29.08.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706544633; x=1707149433; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jJrBQU8/K6RcUc2wQkGztYkcJD87aocyjGftJaoYKA0=; b=tPwvBNfjQftF9lSMkLN6yX0x7futwdawheS9hnB5bOF38AymN1dH2I/4Qnp1QqGrNG GKhPEiKV+9BCux3znCoz5npr2JfA359RWdVODSY8yJ36vc+OLxncvMqoyV3ahP8BPmln nhwN1FepkMpwjOlugdSWGKQ33rJmUkmIakExhUujbaIpd2XizrUPvEhXcQW/ij9PNjaR BF6IWrWZbwTWWLZn0K47Y2M37eY0z13vrAy72g4oHY9yBC0PSi7TCFX6VDSU3ykY6VLu Bm81LWoQVKNkAIiVrGWgJ1NDwkh02TNrxHikaYJRJ5yPsiGczntEubGb1S+WgX/b8COZ DOeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706544633; x=1707149433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jJrBQU8/K6RcUc2wQkGztYkcJD87aocyjGftJaoYKA0=; b=j43mMQYGrYX9r+PYI+hfYIQJxd1dkO7RndtXQy/rR1vga3FETvTKRrFueP8HJsWXlY aSn2TL3wGXHCkVyKf3e44QFoKA6UIaG8IBi/qm9n/lxdC2Mmvcw6md2NveyqAmTh0IG2 kv5OAD5c4e/HCe2Tv7+mIhyuzA6rtUXnVnSM2eZMfd7LHGj0vEGkfONRnfFUbJbzvdhm buKIELxK+2uhKliRcNDAI86DR5DmMf7a5dUJniZ7+9R47VcvE2yO4NsY4TPkkQMGc95i f6YSDbh8OF3/RmZmwxo3reQYZov27OYGIDGP6cHfSh+mjCgsnb2PBK5vUeRM0Jx998BR zrZA== X-Gm-Message-State: AOJu0YwhC+j8nDxDd3Temz0UmCNVCKpnr1mH4V+guGdyvw1oujQY6pWT tEW2Uo9Y5gYrv6V3TfANiLzl2IhjNahf1lWarOpFAFygfBwSfTX4IK9u6NQGmtizN5CS23nUBue yWI8= X-Google-Smtp-Source: AGHT+IGXEoIx/U9hfmpuCmgUgsEf0NYzJpBVKS4fOt1eKkdo5k209ufGMqzBoqKCECT5c24IOvKp7A== X-Received: by 2002:a05:600c:4711:b0:40e:f67d:d5f9 with SMTP id v17-20020a05600c471100b0040ef67dd5f9mr2509964wmo.4.1706544633645; Mon, 29 Jan 2024 08:10:33 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v3 2/6] hw/arm/z2: convert DPRINTF to trace events and guest errors Date: Mon, 29 Jan 2024 18:09:37 +0200 Message-Id: <799c5141c5751cf2341e1d095349612e046424a8.1706544115.git.manos.pitsidianakis@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wm1-x32a.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=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706544674061100002 Content-Type: text/plain; charset="utf-8" Tracing DPRINTFs to stderr might not be desired. A developer that relies on trace events should be able to opt-in to each trace event and rely on QEMU's log redirection, instead of stderr by default. This commit converts DPRINTFs in this file that are used for tracing into trace events. DPRINTFs that report guest errors are logged with LOG_GUEST_ERROR. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e --- hw/arm/trace-events | 7 +++++++ hw/arm/z2.c | 27 ++++++++------------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 7c56943215..0ff41e6c78 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -58,3 +58,10 @@ smmuv3_inv_notifiers_iova(const char *name, uint16_t asi= d, uint16_t vmid, uint64 # strongarm.c strongarm_uart_update_parameters(const char *label, int speed, char parity= , int data_bits, int stop_bits) "%s speed=3D%d parity=3D%c data=3D%d stop= =3D%d" strongarm_ssp_read_underrun(void) "SSP rx underrun" + +# z2.c +z2_lcd_reg_update(uint8_t cur, uint8_t i_0, uint8_t i_1, uint8_t i_2, uint= 32_t value) "cur_reg =3D 0x%x, buf =3D [0x%x, 0x%x, 0x%x], value =3D 0x%x" +z2_lcd_enable_disable_result(const char *result) "LCD %s" +z2_aer915_send_too_long(int8_t msg) "message too long (%i bytes)" +z2_aer915_send(uint8_t reg, uint8_t value) "reg %d value 0x%02x" +z2_aer915_event(int8_t event, int8_t len) "i2c event =3D0x%x len=3D%d byte= s" diff --git a/hw/arm/z2.c b/hw/arm/z2.c index a67fba2cfd..eb2ff8dbc8 100644 --- a/hw/arm/z2.c +++ b/hw/arm/z2.c @@ -27,13 +27,7 @@ #include "exec/address-spaces.h" #include "qom/object.h" #include "qapi/error.h" - -#ifdef DEBUG_Z2 -#define DPRINTF(fmt, ...) \ - printf(fmt, ## __VA_ARGS__) -#else -#define DPRINTF(fmt, ...) -#endif +#include "trace.h" =20 static const struct keymap map[0x100] =3D { [0 ... 0xff] =3D { -1, -1 }, @@ -119,6 +113,8 @@ static uint32_t zipit_lcd_transfer(SSIPeripheral *dev, = uint32_t value) { ZipitLCD *z =3D ZIPIT_LCD(dev); uint16_t val; + + trace_z2_lcd_reg_update(z->cur_reg, z->buf[0], z->buf[1], z->buf[2], v= alue); if (z->selected) { z->buf[z->pos] =3D value & 0xff; z->pos++; @@ -126,22 +122,19 @@ static uint32_t zipit_lcd_transfer(SSIPeripheral *dev= , uint32_t value) if (z->pos =3D=3D 3) { switch (z->buf[0]) { case 0x74: - DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]); z->cur_reg =3D z->buf[2]; break; case 0x76: val =3D z->buf[1] << 8 | z->buf[2]; - DPRINTF("%s: value: 0x%.4x\n", __func__, val); if (z->cur_reg =3D=3D 0x22 && val =3D=3D 0x0000) { z->enabled =3D 1; - printf("%s: LCD enabled\n", __func__); + trace_z2_lcd_enable_disable_result("enabled"); } else if (z->cur_reg =3D=3D 0x10 && val =3D=3D 0x0000) { z->enabled =3D 0; - printf("%s: LCD disabled\n", __func__); + trace_z2_lcd_enable_disable_result("disabled"); } break; default: - DPRINTF("%s: unknown command!\n", __func__); break; } z->pos =3D 0; @@ -211,14 +204,12 @@ static int aer915_send(I2CSlave *i2c, uint8_t data) =20 s->buf[s->len] =3D data; if (s->len++ > 2) { - DPRINTF("%s: message too long (%i bytes)\n", - __func__, s->len); + trace_z2_aer915_send_too_long(s->len); return 1; } =20 if (s->len =3D=3D 2) { - DPRINTF("%s: reg %d value 0x%02x\n", __func__, - s->buf[0], s->buf[1]); + trace_z2_aer915_send(s->buf[0], s->buf[1]); } =20 return 0; @@ -228,14 +219,12 @@ static int aer915_event(I2CSlave *i2c, enum i2c_event= event) { AER915State *s =3D AER915(i2c); =20 + trace_z2_aer915_event(s->len, event); switch (event) { case I2C_START_SEND: s->len =3D 0; break; case I2C_START_RECV: - if (s->len !=3D 1) { - DPRINTF("%s: short message!?\n", __func__); - } break; case I2C_FINISH: break; --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89 From nobody Tue Nov 26 16:30:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706544669; cv=none; d=zohomail.com; s=zohoarc; b=lZ3VztzngYu2NlaEXybUsG66Bfy5g6DvgZQ/P3JBjED5hQP2tLx22bkiCRarU5jdf/LD6rvQG6yGC/WLvdBbeNScXuJ1Ae2YslwKpuTjwUxBg6BqYt+4RL047JU1YIL0WN+7hHJX5CyeBYONC4DHelZPLg0eaeDgTZdbVAipNjs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706544669; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mowSEhOgZzKcBJ9VgVtTRlxzjWwdK68BxpCMYQUxiN0=; b=cs9K/WWXgCT0p/4tlF+vu8u+/8UnRgsJibouecBEOL63V1BQViTVIZ5ELzt+icgyE4Nxaw/ko3B6FNVYw5ZyZfvBBPqDe1EoHeL78fSlYbohsaQLDRsELh5OUgQCz6ZUCqjfsSdVV0bQGU5YZktyHDQ257Zp75UO5SDTI615Rn0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706544669075319.04893141348634; Mon, 29 Jan 2024 08:11:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUUDZ-0007uk-Fr; Mon, 29 Jan 2024 11:10:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUUDY-0007tw-3H for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:10:40 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUUDW-0002ft-8l for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:10:39 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-33ae42033e2so1601927f8f.1 for ; Mon, 29 Jan 2024 08:10:37 -0800 (PST) Received: from localhost.localdomain (adsl-245.37.6.163.tellas.gr. [37.6.163.245]) by smtp.gmail.com with ESMTPSA id co6-20020a0560000a0600b0033af4df8e1esm1219957wrb.47.2024.01.29.08.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:10:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706544636; x=1707149436; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mowSEhOgZzKcBJ9VgVtTRlxzjWwdK68BxpCMYQUxiN0=; b=lmcCmhTHDetvdOhRlWjNYi1CZdPAaeTIPyXhq2T2hE+OUX1FY4czayaWTVUbT7hRaw qSNfHuQX6k07s2qFHuoNCqJ1HXPpipIM17/nl3h/mCvhkTir7yBbDDGSRllNilR89v4C ozO7HCnKqx2AurLg42N+1wZGbQzYkD05jCfahdDCuTUi5kqRdg0y9wopa0UBeQo19d6P yXO1+MUAdIsSxfqej9tTuy4jvFaA7NEGRJ9c3UbOoxY2DGFK/Ddjkqy8CiE4XUHsptJ4 RpOofLM4IJAJi2F4THkIClK/mLKsBmKqkJLKT55yomM7EBKzdFigoeJ6m9hr+EHbTi4o wc1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706544636; x=1707149436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mowSEhOgZzKcBJ9VgVtTRlxzjWwdK68BxpCMYQUxiN0=; b=rrouMjA/74+8yEjvT5FY3DTgdAaZRFAhWIw1ecDPhKotxXrn6JkBJfVPB79X8xug9G QKDEOGrfRx1SVpknDkY3Jqx3RVNxKi0b2M0IjlxkGdAOU0Q6NS5AUkrhOrM2ZF12ZrUA fTJuKkxPwuCKxsfdcwmOj3GdkDFhgTl5eCNMBRD+49Y/kueptrkLDIco9IlaRCHj9/Q1 eO5ePIiraNrIF1s+Y8GVHkCym1uynneNiHYrfeh9WU46880pgmt8ecKrV6CCwXoMJjVo wvlghdSH8bSmVINttLK0u8t/Sa6kMAiO4bTj6mYPX6CqFqKSl/PipDCS2LhHHMXuPgEm OiLg== X-Gm-Message-State: AOJu0Yw/1Z8Q8wmvFmbvbJ3VFQlNCXFrzkeC/NqeQUa/ytCn92l23dOk 25vcwpbza/n8RcRxcQLwCzMXY0e40eYFO0KhQWLkSIhjeNu3XAQGf2WhfuhO1wXB/9cRFPNB16z lado= X-Google-Smtp-Source: AGHT+IHJwGRqrJQIzllR5ddrn3Ul9ubdSRjAryKPH1AK1kiGYvbhTuS0azJwZJUfuup1+2wfPCWY3w== X-Received: by 2002:a05:6000:1544:b0:33a:ed19:9f37 with SMTP id 4-20020a056000154400b0033aed199f37mr3033204wry.47.1706544636095; Mon, 29 Jan 2024 08:10:36 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v3 3/6] hw/arm/xen_arm.c: convert DPRINTF to trace events and error/warn reports Date: Mon, 29 Jan 2024 18:09:38 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x431.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=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706544676051100005 Content-Type: text/plain; charset="utf-8" Tracing DPRINTFs to stderr might not be desired. A developer that relies on trace events should be able to opt-in to each trace event and rely on QEMU's log redirection, instead of stderr by default. This commit converts DPRINTFs in this file that are used for tracing into trace events. Errors or warnings are converted to error_report and warn_report calls. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e --- hw/arm/trace-events | 5 +++++ hw/arm/xen_arm.c | 23 +++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/hw/arm/trace-events b/hw/arm/trace-events index 0ff41e6c78..fd0d92762e 100644 --- a/hw/arm/trace-events +++ b/hw/arm/trace-events @@ -65,3 +65,8 @@ z2_lcd_enable_disable_result(const char *result) "LCD %s" z2_aer915_send_too_long(int8_t msg) "message too long (%i bytes)" z2_aer915_send(uint8_t reg, uint8_t value) "reg %d value 0x%02x" z2_aer915_event(int8_t event, int8_t len) "i2c event =3D0x%x len=3D%d byte= s" + +# xen_arm.c +xen_create_virtio_mmio_devices(int i, int irq, uint64_t base) "Created vir= tio-mmio device %d: irq %d base 0x%"PRIx64 +xen_init_ram(uint64_t machine_ram_size) "Initialized xen ram with size 0x%= "PRIx64 +xen_enable_tpm(uint64_t addr) "Connected tpmdev at address 0x%"PRIx64 diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index a5631529d0..32776d94df 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -34,6 +34,7 @@ #include "hw/xen/xen-hvm-common.h" #include "sysemu/tpm.h" #include "hw/xen/arch_hvm.h" +#include "trace.h" =20 #define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) @@ -91,8 +92,9 @@ static void xen_create_virtio_mmio_devices(XenArmState *x= am) =20 sysbus_create_simple("virtio-mmio", base, irq); =20 - DPRINTF("Created virtio-mmio device %d: irq %d base 0x%lx\n", - i, GUEST_VIRTIO_MMIO_SPI_FIRST + i, base); + trace_xen_create_virtio_mmio_devices(i, + GUEST_VIRTIO_MMIO_SPI_FIRST += i, + base); } } =20 @@ -101,6 +103,7 @@ static void xen_init_ram(MachineState *machine) MemoryRegion *sysmem =3D get_system_memory(); ram_addr_t block_len, ram_size[GUEST_RAM_BANKS]; =20 + trace_xen_init_ram(machine->ram_size); if (machine->ram_size <=3D GUEST_RAM0_SIZE) { ram_size[0] =3D machine->ram_size; ram_size[1] =3D 0; @@ -117,15 +120,10 @@ static void xen_init_ram(MachineState *machine) memory_region_init_alias(&ram_lo, NULL, "xen.ram.lo", &ram_memory, GUEST_RAM0_BASE, ram_size[0]); memory_region_add_subregion(sysmem, GUEST_RAM0_BASE, &ram_lo); - DPRINTF("Initialized region xen.ram.lo: base 0x%llx size 0x%lx\n", - GUEST_RAM0_BASE, ram_size[0]); - if (ram_size[1] > 0) { memory_region_init_alias(&ram_hi, NULL, "xen.ram.hi", &ram_memory, GUEST_RAM1_BASE, ram_size[1]); memory_region_add_subregion(sysmem, GUEST_RAM1_BASE, &ram_hi); - DPRINTF("Initialized region xen.ram.hi: base 0x%llx size 0x%lx\n", - GUEST_RAM1_BASE, ram_size[1]); } } =20 @@ -158,7 +156,7 @@ static void xen_enable_tpm(XenArmState *xam) =20 TPMBackend *be =3D qemu_find_tpm_be("tpm0"); if (be =3D=3D NULL) { - DPRINTF("Couldn't fine the backend for tpm0\n"); + error_report("Couldn't find tmp0 backend"); return; } dev =3D qdev_new(TYPE_TPM_TIS_SYSBUS); @@ -168,7 +166,7 @@ static void xen_enable_tpm(XenArmState *xam) sysbus_realize_and_unref(busdev, &error_fatal); sysbus_mmio_map(busdev, 0, xam->cfg.tpm_base_addr); =20 - DPRINTF("Connected tpmdev at address 0x%lx\n", xam->cfg.tpm_base_addr); + trace_xen_enable_tpm(xam->cfg.tpm_base_addr); } #endif =20 @@ -179,8 +177,9 @@ static void xen_arm_init(MachineState *machine) xam->state =3D g_new0(XenIOState, 1); =20 if (machine->ram_size =3D=3D 0) { - DPRINTF("ram_size not specified. QEMU machine started without IORE= Q" - "(no emulated devices including Virtio)\n"); + warn_report("%s non-zero ram size not specified. QEMU machine star= ted" + " without IOREQ (no emulated devices including virtio)= ", + MACHINE_CLASS(object_get_class(OBJECT(machine)))->desc= ); return; } =20 @@ -194,7 +193,7 @@ static void xen_arm_init(MachineState *machine) if (xam->cfg.tpm_base_addr) { xen_enable_tpm(xam); } else { - DPRINTF("tpm-base-addr is not provided. TPM will not be enabled\n"= ); + warn_report("tpm-base-addr is not provided. TPM will not be enable= d"); } #endif } --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89 From nobody Tue Nov 26 16:30:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706544685; cv=none; d=zohomail.com; s=zohoarc; b=dfWSaYSoQUl5zOCexQ/w82VDzb0r1N1SK48MlXQAa2OooDXrFyxNwlrhuTxcCaAppFFRyBQftAnuem8Dm34bSCl2iW2CcQmw/cfRWmZWXEc7csZ3SVPN0UdC53Kidty6Ns7UpYEIDTlU3SJfs9tcu7L8EG4r/AnqbHU2zZ8XTRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706544685; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zPokHMZSaf9YJuvbqyZkKKACp6RuNQ4cINXS/c1TsXk=; b=MvkKaR+3NkaqQviqIbP8hoqYSfByH1Vm2MVFbrpiR6ll5NVvhEJg6o1KjguhsCnh35/WEPb2P1EY/Q0AlrfYFxoX/U6xy/vIG8s30ODNyhaEWvkbMg5Zk3yWEr9ror2BtsUzMrs3q3aaqxZ+BEeCmHv6K/wjf5SET5snujOCYTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1706544685626769.3707589655573; Mon, 29 Jan 2024 08:11:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.673018.1047102 (Exim 4.92) (envelope-from ) id 1rUUDt-0004Xh-6g; Mon, 29 Jan 2024 16:11:01 +0000 Received: by outflank-mailman (output) from mailman id 673018.1047102; Mon, 29 Jan 2024 16:11:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUUDt-0004Xa-3v; Mon, 29 Jan 2024 16:11:01 +0000 Received: by outflank-mailman (input) for mailman id 673018; Mon, 29 Jan 2024 16:11:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUUDs-0004XU-FW for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 16:11:00 +0000 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [2a00:1450:4864:20::334]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id fd751abc-bec0-11ee-8a43-1f161083a0e0; Mon, 29 Jan 2024 17:10:59 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40e76109cdeso39735795e9.0 for ; Mon, 29 Jan 2024 08:10:59 -0800 (PST) Received: from localhost.localdomain (adsl-245.37.6.163.tellas.gr. [37.6.163.245]) by smtp.gmail.com with ESMTPSA id co6-20020a0560000a0600b0033af4df8e1esm1219957wrb.47.2024.01.29.08.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:10:58 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fd751abc-bec0-11ee-8a43-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706544658; x=1707149458; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zPokHMZSaf9YJuvbqyZkKKACp6RuNQ4cINXS/c1TsXk=; b=b2/pc+pvgeoKT7LHfR1RryzKWJ7ZTnQ49AMoS5FrnDgePSUOvO/kwvkUVNZFZkdwDC t0RNPmPVpC0TtDxDf/5zmu9DYXnahSTEWhKoPkoSbslaLQVJD0Rj1zcxPIFEoLWKI7j8 h4gbLcJwO48yY3XKUXOXLdFGx/gL+eetOm6BXhiP6/nGW21eqx2u6BkDvP/b1ecgl2Lh AozLaXH/Y7DdMdaowcqgJ3+IZsR69s+VSIDPFDY+ePv+bJb06AmBODvS4mKydVCdG4VB ZvQddvD+VX3k/NzpMfT/FaZjw8xpUBD2yppQ5W6njVn0nODeSeQI4+tg2t7w0pCAOIVC NJBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706544658; x=1707149458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zPokHMZSaf9YJuvbqyZkKKACp6RuNQ4cINXS/c1TsXk=; b=CLnB0v4rEuG19r2DEwq82WOaSkgHpG/QBhHAIyHJLyOE59WKaApAr7wNnmmX2OYHvq 2G3CGtJ7XX+XNYWPE6YlJmluZyVnxdN8PLwhj0LA0FUCGSCBS58kXV+Rjfei8CSeQisJ W9CvzZtpjzsUe0XiSzrJHZ8ECvFiMa/T7Q8uDE5sKqEC7Ww6xsnuRytbQT5cHZcztnQb y7Y8iZXt5xz7TdLK58ZnDwDWBPkVLwzGHMUMnpf5SI28d3MjIAlvTlOBkB1wVIvQQoZ0 KLtrWxiErd0gPbIDZdHjO3iM3NupnQHyWtMSbuna/TwE5Jy4Fc2yHlug9a35nymh3xwV 7teA== X-Gm-Message-State: AOJu0YwbhdB4Y/9k1ibCAMyLj9QyMdlHJVuR1lXgqZlz92qGz6yIkOXq slQRnW9FQc2bhbH+NMmp99g2XgW69yVCroX5/baaJbZTOCmdr+RGV0QkhKe5iS0= X-Google-Smtp-Source: AGHT+IH2u+X0jHxP0JLWVS3FK/D/Os2n9uQ6Ne/3EkPY/YogM8wr2ifOFRbEXd/GLM5pC/sG/O6R+Q== X-Received: by 2002:a05:600c:3547:b0:40e:f5d0:8517 with SMTP id i7-20020a05600c354700b0040ef5d08517mr3106234wmq.33.1706544658554; Mon, 29 Jan 2024 08:10:58 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v3 4/6] hw/xen/xen-mapcache.c: convert DPRINTF to tracepoints Date: Mon, 29 Jan 2024 18:09:40 +0200 Message-Id: <2fbe1fbc59078e384761c932e97cfa4276a53d75.1706544115.git.manos.pitsidianakis@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706544686165100001 Content-Type: text/plain; charset="utf-8" Tracing DPRINTFs to stderr might not be desired. A developer that relies on tracepoints should be able to opt-in to each tracepoint and rely on QEMU's log redirection, instead of stderr by default. This commit converts DPRINTFs in this file that are used for tracing into tracepoints. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e --- hw/xen/trace-events | 11 +++++++++ hw/xen/xen-mapcache.c | 54 +++++++++++++++++++------------------------ 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/hw/xen/trace-events b/hw/xen/trace-events index 67a6c41926..a65dc0e55f 100644 --- a/hw/xen/trace-events +++ b/hw/xen/trace-events @@ -60,3 +60,14 @@ cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_= t reg, uint32_t size, ui xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 xen_remap_bucket(uint64_t index) "index 0x%"PRIx64 xen_map_cache_return(void* ptr) "%p" +xen_map_cache_init(uint64_t nr_buckets, uint64_t size) "nr_buckets =3D 0x%= "PRIx64" size 0x%"PRIx64 +xen_replace_cache_entry_dummy(uint64_t old_phys_addr, uint64_t new_phys_ad= dr) "Replacing a dummy mapcache entry for 0x%"PRIx64" with 0x%"PRIx64 +xen_invalidate_map_cache_entry_unlocked_not_found(void *p) "could not find= %p" +xen_invalidate_map_cache_entry_unlocked_found(uint64_t addr, void *p) " = 0x%"PRIx64" -> %p is present" +xen_invalidate_map_cache_entry_unlocked_miss(void *buffer) "Trying to unma= p address %p that is not in the mapcache" +xen_replace_cache_entry_unlocked_could_not_update_entry(uint64_t old_phys_= addr) "Unable to update a mapcache entry for 0x%"PRIx64 +xen_ram_addr_from_mapcache_not_found(void *p) "could not find %p" +xen_ram_addr_from_mapcache_found(uint64_t addr, void *p) " 0x%"PRIx64" -= > %p is present" +xen_ram_addr_from_mapcache_not_in_cache(void *p) "Trying to find address %= p that is not in the mapcache" +xen_replace_cache_entry_unlocked(uint64_t old_phys_addr) "Trying to update= an entry for 0x%"PRIx64" that is not in the mapcache" +xen_invalidate_map_cache(uint64_t paddr_index, void *vaddr_req) "Locked DM= A mapping while invalidating mapcache 0x%"PRIx64" -> %p is present" diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index f7d974677d..336c212376 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -22,16 +22,6 @@ #include "trace.h" =20 =20 -//#define MAPCACHE_DEBUG - -#ifdef MAPCACHE_DEBUG -# define DPRINTF(fmt, ...) do { \ - fprintf(stderr, "xen_mapcache: " fmt, ## __VA_ARGS__); \ -} while (0) -#else -# define DPRINTF(fmt, ...) do { } while (0) -#endif - #if HOST_LONG_BITS =3D=3D 32 # define MCACHE_BUCKET_SHIFT 16 # define MCACHE_MAX_SIZE (1UL<<31) /* 2GB Cap */ @@ -145,8 +135,7 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void = *opaque) =20 size =3D mapcache->nr_buckets * sizeof (MapCacheEntry); size =3D (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1); - DPRINTF("%s, nr_buckets =3D %lx size %lu\n", __func__, - mapcache->nr_buckets, size); + trace_xen_map_cache_init(mapcache->nr_buckets, size); mapcache->entry =3D g_malloc0(size); } =20 @@ -286,7 +275,9 @@ tryagain: test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, mapcache->last_entry->valid_mapping)) { - trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + addr= ess_offset); + trace_xen_map_cache_return( + mapcache->last_entry->vaddr_base + address_offset + ); return mapcache->last_entry->vaddr_base + address_offset; } =20 @@ -368,7 +359,9 @@ tryagain: QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } =20 - trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_= offset); + trace_xen_map_cache_return( + mapcache->last_entry->vaddr_base + address_offset + ); return mapcache->last_entry->vaddr_base + address_offset; } =20 @@ -402,10 +395,10 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) } } if (!found) { - fprintf(stderr, "%s, could not find %p\n", __func__, ptr); + trace_xen_ram_addr_from_mapcache_not_found(ptr); QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { - DPRINTF(" "HWADDR_FMT_plx" -> %p is present\n", reventry->pa= ddr_index, - reventry->vaddr_req); + trace_xen_ram_addr_from_mapcache_found(reventry->paddr_index, + reventry->vaddr_req); } abort(); return 0; @@ -416,7 +409,7 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) entry =3D entry->next; } if (!entry) { - DPRINTF("Trying to find address %p that is not in the mapcache!\n"= , ptr); + trace_xen_ram_addr_from_mapcache_not_in_cache(ptr); raddr =3D 0; } else { raddr =3D (reventry->paddr_index << MCACHE_BUCKET_SHIFT) + @@ -443,9 +436,12 @@ static void xen_invalidate_map_cache_entry_unlocked(ui= nt8_t *buffer) } } if (!found) { - DPRINTF("%s, could not find %p\n", __func__, buffer); + trace_xen_invalidate_map_cache_entry_unlocked_not_found(buffer); QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { - DPRINTF(" "HWADDR_FMT_plx" -> %p is present\n", reventry->pa= ddr_index, reventry->vaddr_req); + trace_xen_invalidate_map_cache_entry_unlocked_found( + reventry->paddr_index, + reventry->vaddr_req + ); } return; } @@ -463,7 +459,7 @@ static void xen_invalidate_map_cache_entry_unlocked(uin= t8_t *buffer) entry =3D entry->next; } if (!entry) { - DPRINTF("Trying to unmap address %p that is not in the mapcache!\n= ", buffer); + trace_xen_invalidate_map_cache_entry_unlocked_miss(buffer); return; } entry->lock--; @@ -502,9 +498,8 @@ void xen_invalidate_map_cache(void) if (!reventry->dma) { continue; } - fprintf(stderr, "Locked DMA mapping while invalidating mapcache!" - " "HWADDR_FMT_plx" -> %p is present\n", - reventry->paddr_index, reventry->vaddr_req); + trace_xen_invalidate_map_cache(reventry->paddr_index, + reventry->vaddr_req); } =20 for (i =3D 0; i < mapcache->nr_buckets; i++) { @@ -562,24 +557,23 @@ static uint8_t *xen_replace_cache_entry_unlocked(hwad= dr old_phys_addr, entry =3D entry->next; } if (!entry) { - DPRINTF("Trying to update an entry for "HWADDR_FMT_plx \ - "that is not in the mapcache!\n", old_phys_addr); + trace_xen_replace_cache_entry_unlocked(old_phys_addr); return NULL; } =20 address_index =3D new_phys_addr >> MCACHE_BUCKET_SHIFT; address_offset =3D new_phys_addr & (MCACHE_BUCKET_SIZE - 1); =20 - fprintf(stderr, "Replacing a dummy mapcache entry for "HWADDR_FMT_plx \ - " with "HWADDR_FMT_plx"\n", old_phys_addr, new_phys_addr); + trace_xen_replace_cache_entry_dummy(old_phys_addr, new_phys_addr); =20 xen_remap_bucket(entry, entry->vaddr_base, cache_size, address_index, false); if (!test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { - DPRINTF("Unable to update a mapcache entry for "HWADDR_FMT_plx"!\n= ", - old_phys_addr); + trace_xen_replace_cache_entry_unlocked_could_not_update_entry( + old_phys_addr + ); return NULL; } =20 --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89 From nobody Tue Nov 26 16:30:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706544688; cv=none; d=zohomail.com; s=zohoarc; b=SfIMlMDolO5o0w5Hstb3PKFvrKRE4TbDdeNkJtvbpfG0nh6ykIH48yzWvnilfTUliD+Yqm0yjQWUqo84ckQDwW+NMhnbymFuMj+gSn8TEgq5Knfr6DRpFf/nJJAb8ZPycgm7wQxtmNzJpXHCPFk+8+cIN4HeeSgLuTsXC2hfnoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706544688; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=twCbSHojWsbr5gv/7yE94TkwwcJ8Z3GKHFCgEYch/Mg=; b=cyph4pICd5t0FsktzjsCX0RtLX6dadS2PASAaNxKqApbJ8YQ8u+GOt5JRr5pgsVUmbXKm0KZjGxqCi1E/rmsf6jV+Wj20Om5CGuBhNWhNLrqRRsnRe+90oSZhBdIQ6Y1KuXUzGC2cHbK2WSE7ezspPYJA9PNVtSpbNAPhxTrDBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1706544687983859.2196653868389; Mon, 29 Jan 2024 08:11:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.673020.1047123 (Exim 4.92) (envelope-from ) id 1rUUE1-00052Q-OW; Mon, 29 Jan 2024 16:11:09 +0000 Received: by outflank-mailman (output) from mailman id 673020.1047123; Mon, 29 Jan 2024 16:11:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUUE1-00052D-L4; Mon, 29 Jan 2024 16:11:09 +0000 Received: by outflank-mailman (input) for mailman id 673020; Mon, 29 Jan 2024 16:11:08 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rUUE0-0004my-5q for xen-devel@lists.xenproject.org; Mon, 29 Jan 2024 16:11:08 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ff87d933-bec0-11ee-98f5-efadbce2ee36; Mon, 29 Jan 2024 17:11:02 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3394ca0c874so2610049f8f.2 for ; Mon, 29 Jan 2024 08:11:02 -0800 (PST) Received: from localhost.localdomain (adsl-245.37.6.163.tellas.gr. [37.6.163.245]) by smtp.gmail.com with ESMTPSA id co6-20020a0560000a0600b0033af4df8e1esm1219957wrb.47.2024.01.29.08.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:11:01 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ff87d933-bec0-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706544662; x=1707149462; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=twCbSHojWsbr5gv/7yE94TkwwcJ8Z3GKHFCgEYch/Mg=; b=T8hZ5nGcFg/ZJYc3WUbvNz9rOV1b0jlWCaAzt1CCtgj6lkY7v/niuc9gGQCqO7/zJE vhzbEEIHa5D4mYGH1VKwa2KMdRyhp7bVKJV9kqwj0N2ruHIxjyhXk2i05Rd5YIjv4RjJ 1pivg0mtu5LDAjqFsPgQxpvNO2yJErd+JtifgE4Wgx3iloGtGoYxwY+/ZZg0ayt4G1SM yG4kxfMTC6zE67XPJZcebOwuvNKqwuiDwJvM+gN4b4qDeQha2p/Y3CPXhU8Snuh6FoTJ V/+LI4Kc/PlkkJBYx3rR2zcshpjYXuvsmRL4wzmFG8Enn5M6fTXHL2E7D8itNgjcBjfr Qk4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706544662; x=1707149462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=twCbSHojWsbr5gv/7yE94TkwwcJ8Z3GKHFCgEYch/Mg=; b=CpyBbFhSs5VQbyd+q6h9EcZuJuNgS7MbDdNhoB1p96VPI5R2hBFloUIB8MNQUGXhZ1 WO7pF6cvv5cndF/OSWysCm/TinivpgDdWFMhGlSugDJ0+/hwrc+jMoOlcMLLQChu2/De L4oleJEmNZdFfsHVxPdL+K/+rNBF7yJZfkQ9MFQAj7fH3wVUTefzQCdJMOrrcu4L+JMx BNerlU25QqO1JP+3Jn62dRHBsHIgWHGo7e1pKBTR5DS5HN44QY0t7vjFUivEVEPmP1Hw +4OmpNuYg6bOcPyHoDrnw5U18FQMF8Sac8VPmTiDYUYxMshXD9WYgWBjr18NXh3ANR4L eY4A== X-Gm-Message-State: AOJu0YxA+mBON/1JkpNBgd+/lOMAAvef/S9Yd/G6htVJaeFR8coRyf2k lp6QTLMM5CuFSgysqb0q6BWPfwVJ6ZyM6MHJlPoSDoRBC1v1zR3o4gJm5/s6zYY= X-Google-Smtp-Source: AGHT+IFHfef60/eAVVHH0kuTs/lfrSLJKa6iuHY11S8YaJiIhT6WLh5nB2VDle+t9MxY8DzYa8+KtQ== X-Received: by 2002:adf:e584:0:b0:337:c097:db9f with SMTP id l4-20020adfe584000000b00337c097db9fmr5003853wrm.17.1706544662220; Mon, 29 Jan 2024 08:11:02 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v3 5/6] hw/xen/xen-hvm-common.c: convert DPRINTF to tracepoints Date: Mon, 29 Jan 2024 18:09:41 +0200 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706544690248100001 Content-Type: text/plain; charset="utf-8" Tracing DPRINTFs to stderr might not be desired. A developer that relies on tracepoints should be able to opt-in to each tracepoint and rely on QEMU's log redirection, instead of stderr by default. This commit converts DPRINTFs in this file that are used for tracing into tracepoints. Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e --- hw/xen/trace-events | 10 +++++++++- hw/xen/xen-hvm-common.c | 35 ++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/hw/xen/trace-events b/hw/xen/trace-events index a65dc0e55f..d1b27f6c11 100644 --- a/hw/xen/trace-events +++ b/hw/xen/trace-events @@ -42,7 +42,7 @@ xs_node_vscanf(char *path, char *value) "%s %s" xs_node_watch(char *path) "%s" xs_node_unwatch(char *path) "%s" =20 -# xen-hvm.c +# xen-hvm-common.c xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: 0x%l= x, size 0x%lx" xen_client_set_memory(uint64_t start_addr, unsigned long size, bool log_di= rty) "0x%"PRIx64" size 0x%lx, log_dirty %i" handle_ioreq(void *req, uint32_t type, uint32_t dir, uint32_t df, uint32_t= data_is_ptr, uint64_t addr, uint64_t data, uint32_t count, uint32_t size) = "I/O=3D%p type=3D%d dir=3D%d df=3D%d ptr=3D%d port=3D0x%"PRIx64" data=3D0x%= "PRIx64" count=3D%d size=3D%d" @@ -55,6 +55,14 @@ cpu_ioreq_move(void *req, uint32_t dir, uint32_t df, uin= t32_t data_is_ptr, uint6 xen_map_resource_ioreq(uint32_t id, void *addr) "id: %u addr: %p" cpu_ioreq_config_read(void *req, uint32_t sbdf, uint32_t reg, uint32_t siz= e, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" cpu_ioreq_config_write(void *req, uint32_t sbdf, uint32_t reg, uint32_t si= ze, uint32_t data) "I/O=3D%p sbdf=3D0x%x reg=3D%u size=3D%u data=3D0x%x" +cpu_get_ioreq_from_shared_memory_req_not_ready(int state, int data_is_ptr,= uint64_t addr, uint64_t data, uint32_t count, uint32_t size) "I/O request = not ready: 0x%x, ptr: 0x%x, port: 0x%"PRIx64", data: 0x%"PRIx64", count: %u= , size: %u" +xen_main_loop_prepare_init_cpu(int id, void *cpu) "cpu_by_vcpu_id[%d]=3D%p" +xen_map_ioreq_server_shared_page(long unsigned int ioreq_pfn) "shared page= at pfn 0x%lx" +xen_map_ioreq_server_buffered_io_page(long unsigned int ioreq_pfn) "buffer= ed io page at pfn 0x%lx" +xen_map_ioreq_server_buffered_io_evtchn(int bufioreq_evtchn) "buffered io = evtchn is 0x%x" +destroy_hvm_domain_cannot_acquire_handle(void) "Cannot acquire xenctrl han= dle" +destroy_hvm_domain_failed_action(const char *action, int sts, char *errno_= s) "xc_domain_shutdown failed to issue %s, sts %d, %s" +destroy_hvm_domain_action(int xen_domid, const char *action) "Issued domai= n %d %s" =20 # xen-mapcache.c xen_map_cache(uint64_t phys_addr) "want 0x%"PRIx64 diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 47e6cb1db3..05a29c6f11 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -169,11 +169,12 @@ static ioreq_t *cpu_get_ioreq_from_shared_memory(XenI= OState *state, int vcpu) ioreq_t *req =3D xen_vcpu_ioreq(state->shared_page, vcpu); =20 if (req->state !=3D STATE_IOREQ_READY) { - DPRINTF("I/O request not ready: " - "%x, ptr: %x, port: %"PRIx64", " - "data: %"PRIx64", count: %u, size: %u\n", - req->state, req->data_is_ptr, req->addr, - req->data, req->count, req->size); + trace_cpu_get_ioreq_from_shared_memory_req_not_ready(req->state, + req->data_is_= ptr, + req->addr, + req->data, + req->count, + req->size); return NULL; } =20 @@ -601,10 +602,9 @@ static void xen_main_loop_prepare(XenIOState *state) if (evtchn_fd !=3D -1) { CPUState *cpu_state; =20 - DPRINTF("%s: Init cpu_by_vcpu_id\n", __func__); CPU_FOREACH(cpu_state) { - DPRINTF("%s: cpu_by_vcpu_id[%d]=3D%p\n", - __func__, cpu_state->cpu_index, cpu_state); + trace_xen_main_loop_prepare_init_cpu(cpu_state->cpu_index, + cpu_state); state->cpu_by_vcpu_id[cpu_state->cpu_index] =3D cpu_state; } qemu_set_fd_handler(evtchn_fd, cpu_handle_ioreq, NULL, state); @@ -681,7 +681,7 @@ static int xen_map_ioreq_server(XenIOState *state) } =20 if (state->shared_page =3D=3D NULL) { - DPRINTF("shared page at pfn %lx\n", ioreq_pfn); + trace_xen_map_ioreq_server_shared_page(ioreq_pfn); =20 state->shared_page =3D xenforeignmemory_map(xen_fmem, xen_domid, PROT_READ | PROT_WRITE, @@ -693,7 +693,7 @@ static int xen_map_ioreq_server(XenIOState *state) } =20 if (state->buffered_io_page =3D=3D NULL) { - DPRINTF("buffered io page at pfn %lx\n", bufioreq_pfn); + trace_xen_map_ioreq_server_buffered_io_page(bufioreq_pfn); =20 state->buffered_io_page =3D xenforeignmemory_map(xen_fmem, xen_dom= id, PROT_READ | PROT_WR= ITE, @@ -709,7 +709,7 @@ static int xen_map_ioreq_server(XenIOState *state) return -1; } =20 - DPRINTF("buffered io evtchn is %x\n", bufioreq_evtchn); + trace_xen_map_ioreq_server_buffered_io_evtchn(bufioreq_evtchn); =20 state->bufioreq_remote_port =3D bufioreq_evtchn; =20 @@ -737,16 +737,17 @@ void destroy_hvm_domain(bool reboot) =20 xc_handle =3D xc_interface_open(0, 0, 0); if (xc_handle =3D=3D NULL) { - fprintf(stderr, "Cannot acquire xenctrl handle\n"); + trace_destroy_hvm_domain_cannot_acquire_handle(); } else { sts =3D xc_domain_shutdown(xc_handle, xen_domid, reason); if (sts !=3D 0) { - fprintf(stderr, "xc_domain_shutdown failed to issue %s, " - "sts %d, %s\n", reboot ? "reboot" : "poweroff", - sts, strerror(errno)); + trace_destroy_hvm_domain_failed_action( + reboot ? "reboot" : "poweroff", sts, strerror(errno) + ); } else { - fprintf(stderr, "Issued domain %d %s\n", xen_domid, - reboot ? "reboot" : "poweroff"); + trace_destroy_hvm_domain_action( + xen_domid, reboot ? "reboot" : "poweroff" + ); } xc_interface_close(xc_handle); } --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89 From nobody Tue Nov 26 16:30:27 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1706544731; cv=none; d=zohomail.com; s=zohoarc; b=KnhKBPsrGe6E5rx705+mckJJOm9kTLtfsQpTu8uGJlwCdddHjvyE0cUKmZmp3257BphNKnkAEtaVidFcNLx5gBBgLf6j2ZexeiDzaJQSxFi/9fDX3unBYUH+WuPGsd5V18Gp4Lvkw2jGofWOd/qQZ/A1fnPKBgjZYlbpvhJgNQQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706544731; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q+5SvWKJw3Pcq7y4wFA0yrN1E0wDdYRB5LHPrLR2R5E=; b=ewQsLDPiYv12NrA/x48FXFNwu3Jvix4/jZ8IYIKZk9MCIqiRsr5+XKIjnspYb6UlGNTKvq9Ji+lQoOyXks/GEcy9zVcWho19F9bTyKr3SuT5u6L4q4JZZseCuINIqc9ek+EySfX1uQWOSTg8LJtybKGxOQxg0EHBRr4AZvPvbnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706544731740525.8936737974476; Mon, 29 Jan 2024 08:12:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUUE5-0008OK-2i; Mon, 29 Jan 2024 11:11:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUUE4-0008M4-21 for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:11:12 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rUUE1-0002s3-J6 for qemu-devel@nongnu.org; Mon, 29 Jan 2024 11:11:11 -0500 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-339289fead2so2422206f8f.3 for ; Mon, 29 Jan 2024 08:11:07 -0800 (PST) Received: from localhost.localdomain (adsl-245.37.6.163.tellas.gr. [37.6.163.245]) by smtp.gmail.com with ESMTPSA id co6-20020a0560000a0600b0033af4df8e1esm1219957wrb.47.2024.01.29.08.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 08:11:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706544666; x=1707149466; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q+5SvWKJw3Pcq7y4wFA0yrN1E0wDdYRB5LHPrLR2R5E=; b=VEGoXMxzLsDlP7BfEBye0S4YdQEMbakjMDVJkkJyeO248QTn4VLfRpNfSoHJsfcjiz h+7ejUWgPyNhQOwYsbI71hSEGPERVcPICNLPjQ7jUMla+QvF9XhJE/yAXCatu3keY2rn /KUU2fUWgYkC4KYGBuR0jTzH2ShSpcCJ/aIIZdQ3RPBpCQ1t9hbsvKxImwfu0jGb5Xta FpSPjzBZBs/sIC/iF/jERAhEQYOB79eXGdz5z37X3nLbNGs06LxaxjYFXJv6L+VDnmdI 73LlTeMccWttfsH+CJcmrLBztTgMG4L9ejynC4ZWNfZ2ANbbWVA9z6v+PuHtDfkhqfIZ nlyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706544666; x=1707149466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q+5SvWKJw3Pcq7y4wFA0yrN1E0wDdYRB5LHPrLR2R5E=; b=pJcyVu8cw1SPUXnLeyBD5IhhiTDnsOmJL9i0nYgSNZuqTlwoqIsUVZCeGAx9p4GASc ZHqGStkMFon/OK4pjVjsbOxlamglzMSq6thtSCOAoNah1vUBk5l8yjgQLXWPRiGQaxuL NAk2phQZgoCKESvOI+fcjYGwl6IsYsG0wyEOc+Mrp2Tm/Iozcp75FZW66+l6MVfQMlsR nHpRK25XXJhGWlZXPaUZqcISgOIw051PNlEMuilKfAlOdlkUAWnQ+sC4RDsc2FW/CRS5 Cb+vyi0C21o1ebKiAhUVoXKjkw+uLcfwGFOREjti5y0CpI0rfvtk53WlkzUz5aKeCBzW Pw1w== X-Gm-Message-State: AOJu0Yx4cLCA08TaEcxzluLzmBtdtMQmlh4PqWeTDg065rkkQLLr29ZT sZx0JIAiWBCEnoIMDSTfIfwmW5w+Tj3zvpHiPwzSw8HYvHOzfdMQ4AxidFn4y8T0QxATvc91LSh 1Mpo= X-Google-Smtp-Source: AGHT+IGZtrvB+zkUJjsAVGqIveytOHVyHqI8Q/vjlorX6vfjVFxTfYDnogBdEEvF9xxE2lcmt0PKdw== X-Received: by 2002:adf:cc91:0:b0:33a:f340:d09d with SMTP id p17-20020adfcc91000000b0033af340d09dmr1784015wrj.49.1706544666613; Mon, 29 Jan 2024 08:11:06 -0800 (PST) From: Manos Pitsidianakis To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org Cc: peter.maydell@linaro.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefano Stabellini , Anthony Perard , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v3 6/6] hw/xen: convert stderr prints to error/warn reports Date: Mon, 29 Jan 2024 18:09:42 +0200 Message-Id: <42a8953553cf68e8bacada966f93af4fbce45919.1706544115.git.manos.pitsidianakis@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x433.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=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1706544732212100001 According to the QEMU Coding Style document: > Do not use printf(), fprintf() or monitor_printf(). Instead, use > error_report() or error_vreport() from error-report.h. This ensures the > error is reported in the right place (current monitor or stderr), and in > a uniform format. > Use error_printf() & friends to print additional information. This commit changes fprintfs that report warnings and errors to the appropriate report functions. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Manos Pitsidianakis Reviewed-by: Alex Benn=C3=A9e --- hw/xen/xen-hvm-common.c | 12 ++++++------ hw/xen/xen-mapcache.c | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 05a29c6f11..baa1adb9f2 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -20,8 +20,8 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, = MemoryRegion *mr, =20 if (runstate_check(RUN_STATE_INMIGRATE)) { /* RAM already populated in Xen */ - fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT - " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRAT= E\n", + warn_report("%s: do not alloc "RAM_ADDR_FMT + " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRAT= E", __func__, size, ram_addr); return; } @@ -552,9 +552,9 @@ static void cpu_handle_ioreq(void *opaque) req->data =3D copy.data; =20 if (req->state !=3D STATE_IOREQ_INPROCESS) { - fprintf(stderr, "Badness in I/O request ... not in service?!: " + warn_report("Badness in I/O request ... not in service?!: " "%x, ptr: %x, port: %"PRIx64", " - "data: %"PRIx64", count: %u, size: %u, type: %u\n", + "data: %"PRIx64", count: %u, size: %u, type: %u", req->state, req->data_is_ptr, req->addr, req->data, req->count, req->size, req->type); destroy_hvm_domain(false); @@ -758,9 +758,9 @@ void xen_shutdown_fatal_error(const char *fmt, ...) va_list ap; =20 va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + error_vreport(fmt, ap); va_end(ap); - fprintf(stderr, "Will destroy the domain.\n"); + error_report("Will destroy the domain."); /* destroy the domain */ qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); } diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 336c212376..4f956d048e 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -347,9 +347,8 @@ tryagain: MapCacheRev *reventry =3D g_new0(MapCacheRev, 1); entry->lock++; if (entry->lock =3D=3D 0) { - fprintf(stderr, - "mapcache entry lock overflow: "HWADDR_FMT_plx" -> %p\= n", - entry->paddr_index, entry->vaddr_base); + error_report("mapcache entry lock overflow: "HWADDR_FMT_plx" -= > %p", + entry->paddr_index, entry->vaddr_base); abort(); } reventry->dma =3D dma; --=20 =CE=B3=CE=B1=E1=BF=96=CE=B1 =CF=80=CF=85=CF=81=CE=AF =CE=BC=CE=B9=CF=87=CE= =B8=CE=AE=CF=84=CF=89