From nobody Sun Nov 16 20:47:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601911651; cv=none; d=zohomail.com; s=zohoarc; b=WbsC7BR3R9WPLwvmEmARLqH36Y5PaO2o7vBSRA2DS5Mo5l2ShJuaQYYBJpA7lGW9OP3Mp9S2QhoCaBsU/y3EEBvthCtmrG4Nmh27d+6dM0i5dp+zJsBU5IxFJ1PsD9He6ePMQSQYkh4rIdQpt5MTxwt2bRh6p8Sajm20MVRuOgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601911651; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=ThhMUjjLg+/D2yAGmDv83K8pC0Dc18gDxERoM4qHJ1g=; b=Y1+KBaEQcguKA8M6dVOPjiPMkJHqUDpO7J+KxxO8WBWOz+4cqQwW0tKXf6CpVbBLix6GJyYx3Ipak7MLfIstnpzEBN+kJXs5TIQqgvVSrf0LOLSJaZt+Wfa1iYLa1mtl+e8hejEFFmIMuM4g5lwO0ugihZOut8OrVv1ullvUIEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601911651895703.7692786414203; Mon, 5 Oct 2020 08:27:31 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-58-A75CCtJcO8ywiI__owQOaw-1; Mon, 05 Oct 2020 11:27:29 -0400 Received: by mail-wr1-f72.google.com with SMTP id d9so4149358wrv.16 for ; Mon, 05 Oct 2020 08:27:28 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id c4sm84612wme.27.2020.10.05.08.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2020 08:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601911650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ThhMUjjLg+/D2yAGmDv83K8pC0Dc18gDxERoM4qHJ1g=; b=GsuFAH5FrufAMnaW/qtY062BlDKPLHuE1CwCtT88V/c866gbOsx/h4yFnRSgSkR0Z+xrjg YTGex+a0sgE6HiMp2ML1vnr3QY+Sfgvb1l5fkTMhRoGL3dK68zbPSLxaelK99uXvPj98eJ 8ASC8STNBsD+GCOA2VjgPrvj4ZdUm6E= X-MC-Unique: A75CCtJcO8ywiI__owQOaw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ThhMUjjLg+/D2yAGmDv83K8pC0Dc18gDxERoM4qHJ1g=; b=IMOQ7JwzXz4GDd0l1XSk1L9WuB0n16naBU4WIBNefyp8Xm+Yx71NXqDuc7eh+RjZGU dgvCskwiwyh82QhAZw1cJ/9XRmts8AE8KhTJZ2EXJkkHmMxsvb9OYfUNhxCvuEiFx88s VCaIgfaU2uU67qoUkcJAmHJA//+G3Gk6MQB8hkQva+9hI4G+XUR776ic5pj25PLoZLsO V8oljn7qGjFstWhsx2Ki3rN/gJ4XqMeG3BzgONT0wumeZ91Cd6K/fMKNAJFH1B/f5/Zt 99sytlrhaGa5u6KMHSLS9SbDoFhkgDNV3kWBcTyScT2/6n55MZiS0mU9B954XRL3Fg0q Dj/Q== X-Gm-Message-State: AOAM531zLkT2cJPZkAMXx7lBEbB7m1fbk5GMIzgQMaLTfqdgtQU78Bj2 QdffUZQXUKRvPIxml0XsGijDa8CqGD5Zol5XWnb8qxccYLUH2CJJV2OLqwZ8yrkbOi9y0DNCZpS sZon96jLvlM6xHg== X-Received: by 2002:a5d:630a:: with SMTP id i10mr17956439wru.137.1601911647796; Mon, 05 Oct 2020 08:27:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoEDbNmaVqtq4LuuFziMdkP4O4nZd4TYjoG7erWESeywLb1BGqqQcWLru2VufEjnloXdmeNA== X-Received: by 2002:a5d:630a:: with SMTP id i10mr17956419wru.137.1601911647578; Mon, 05 Oct 2020 08:27:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , qemu-trivial@nongnu.org, Peter Maydell , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH] softmmu/memory: Log invalid memory accesses Date: Mon, 5 Oct 2020 17:27:25 +0200 Message-Id: <20201005152725.2143444-1-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Log invalid memory accesses with as GUEST_ERROR. This is particularly useful since commit 5d971f9e67 which reverted ("memory: accept mismatching sizes in memory_region_access_valid"). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin --- softmmu/memory.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/softmmu/memory.c b/softmmu/memory.c index fa280a19f7..403ff3abc9 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -14,6 +14,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" #include "qapi/error.h" #include "cpu.h" #include "exec/memory.h" @@ -1353,10 +1354,18 @@ bool memory_region_access_valid(MemoryRegion *mr, { if (mr->ops->valid.accepts && !mr->ops->valid.accepts(mr->opaque, addr, size, is_write, attrs= )) { + qemu_log_mask(LOG_GUEST_ERROR, "Invalid access at addr " + "0x%" HWADDR_PRIX ", size %u, " + "region '%s', reason: rejected\n", + addr, size, memory_region_name(mr)); return false; } =20 if (!mr->ops->valid.unaligned && (addr & (size - 1))) { + qemu_log_mask(LOG_GUEST_ERROR, "Invalid access at addr " + "0x%" HWADDR_PRIX ", size %u, " + "region '%s', reason: unaligned\n", + addr, size, memory_region_name(mr)); return false; } =20 @@ -1367,6 +1376,13 @@ bool memory_region_access_valid(MemoryRegion *mr, =20 if (size > mr->ops->valid.max_access_size || size < mr->ops->valid.min_access_size) { + qemu_log_mask(LOG_GUEST_ERROR, "Invalid access at addr " + "0x%" HWADDR_PRIX ", size %u, " + "region '%s', reason: invalid size " + "(min:%u max:%u)\n", + addr, size, memory_region_name(mr), + mr->ops->valid.min_access_size, + mr->ops->valid.max_access_size); return false; } return true; --=20 2.26.2