From nobody Mon Apr 29 16:01:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1568989159; cv=none; d=zoho.com; s=zohoarc; b=Xtyv8edWQamx2Q+vDW3k7pE4GrcsD27rFiqz66Ug5fS4FCXO8e+Y0YphvMcnUFrHGz3VjnE1a7UpU/bYv/sLiG3W7uV6tkiXLxVuSvf2W7SVVQrc9LAX3mcPskVazQEfq3gYzv8CuCQwEqi+cS+VwV2KP+aRgZaGmqsbf2id4r0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568989159; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=L86LhRqHoADzpY+DQDbF53Y8igvmDZI3XCgB1mBYo8k=; b=RXT0/SIoWRQB+tlFIRZVkVMLqjTUzlYoqaCA3GQbzHP/yMkv+qE0o327qR0KIhjC6mMUb2VJYuTAnQuqetnK6xEtPXPpOv2CufseQpB4J8YrvEkwwyxVzggAqWKPTRgoePSSdjIbTri0+FrcC1I+CKguly8oR71AdSW2ewteqis= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568989159236515.6373116591723; Fri, 20 Sep 2019 07:19:19 -0700 (PDT) Received: from localhost ([::1]:60032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBJkZ-0001TU-0W for importer@patchew.org; Fri, 20 Sep 2019 10:19:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59743) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBJed-0006oN-4Z for qemu-devel@nongnu.org; Fri, 20 Sep 2019 10:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBJeZ-00051Z-QO for qemu-devel@nongnu.org; Fri, 20 Sep 2019 10:12:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iBJeZ-00051E-HT for qemu-devel@nongnu.org; Fri, 20 Sep 2019 10:12:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 40ADD18C8919; Fri, 20 Sep 2019 14:12:54 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A24CC60C18; Fri, 20 Sep 2019 14:12:51 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH] memory: Replace DEBUG_UNASSIGNED printf calls by trace events Date: Fri, 20 Sep 2019 16:12:48 +0200 Message-Id: <20190920141248.12887-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Fri, 20 Sep 2019 14:12:54 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Desnogues , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Now that the unassigned_access CPU hooks have been removed, the unassigned_mem_read/write functions are only used for debugging purpose. Simplify by converting them to in-place trace events. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Paolo Bonzini --- Based-on: <20190920125008.13604-1-peter.maydell@linaro.org> https://lists.gnu.org/archive/html/qemu-devel/2019-09/msg04668.html https://lists.gnu.org/archive/html/qemu-devel/2019-09/msg03705.html I first wrote: These functions are declared using the CPUReadMemoryFunc/ CPUWriteMemoryFunc prototypes. Since it is confusing to have such prototype only use for debugging, convert them to in-place trace events. But it doesn't provide helpful information and is rather confusing. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- memory.c | 24 +++--------------------- trace-events | 2 ++ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/memory.c b/memory.c index 93a05395cf..07e80a637a 100644 --- a/memory.c +++ b/memory.c @@ -35,8 +35,6 @@ #include "hw/boards.h" #include "migration/vmstate.h" =20 -//#define DEBUG_UNASSIGNED - static unsigned memory_region_transaction_depth; static bool memory_region_update_pending; static bool ioeventfd_update_pending; @@ -1272,23 +1270,6 @@ static void iommu_memory_region_initfn(Object *obj) mr->is_iommu =3D true; } =20 -static uint64_t unassigned_mem_read(void *opaque, hwaddr addr, - unsigned size) -{ -#ifdef DEBUG_UNASSIGNED - printf("Unassigned mem read " TARGET_FMT_plx "\n", addr); -#endif - return 0; -} - -static void unassigned_mem_write(void *opaque, hwaddr addr, - uint64_t val, unsigned size) -{ -#ifdef DEBUG_UNASSIGNED - printf("Unassigned mem write " TARGET_FMT_plx " =3D 0x%"PRIx64"\n", ad= dr, val); -#endif -} - static bool unassigned_mem_accepts(void *opaque, hwaddr addr, unsigned size, bool is_write, MemTxAttrs attrs) @@ -1437,7 +1418,8 @@ MemTxResult memory_region_dispatch_read(MemoryRegion = *mr, MemTxResult r; =20 if (!memory_region_access_valid(mr, addr, size, false, attrs)) { - *pval =3D unassigned_mem_read(mr, addr, size); + trace_memory_region_invalid_read(size, addr); + *pval =3D 0; /* FIXME now this value shouldn't be accessed in gues= t */ return MEMTX_DECODE_ERROR; } =20 @@ -1481,7 +1463,7 @@ MemTxResult memory_region_dispatch_write(MemoryRegion= *mr, unsigned size =3D memop_size(op); =20 if (!memory_region_access_valid(mr, addr, size, true, attrs)) { - unassigned_mem_write(mr, addr, data, size); + trace_memory_region_invalid_write(size, addr, size << 1, data); return MEMTX_DECODE_ERROR; } =20 diff --git a/trace-events b/trace-events index 823a4ae64e..83dbeb4b46 100644 --- a/trace-events +++ b/trace-events @@ -62,6 +62,8 @@ memory_region_tb_read(int cpu_index, uint64_t addr, uint6= 4_t value, unsigned siz memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsig= ned size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_ram_device_read(int cpu_index, void *mr, uint64_t addr, uint= 64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64"= size %u" memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uin= t64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64= " size %u" +memory_region_invalid_read(unsigned size, uint64_t addr) "invalid read siz= e %u addr 0x%"PRIx64 +memory_region_invalid_write(unsigned size, uint64_t addr, int fmt_width, u= int64_t value) "invalid write size %u addr 0x%"PRIx64" value 0x%0*"PRIx64 flatview_new(void *view, void *root) "%p (root %p)" flatview_destroy(void *view, void *root) "%p (root %p)" flatview_destroy_rcu(void *view, void *root) "%p (root %p)" --=20 2.20.1