From nobody Fri May 3 21:41:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541639434052297.37286197132744; Wed, 7 Nov 2018 17:10:34 -0800 (PST) Received: from localhost ([::1]:53634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKYpv-0006iE-0T for importer@patchew.org; Wed, 07 Nov 2018 20:10:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKYoy-0006OL-4b for qemu-devel@nongnu.org; Wed, 07 Nov 2018 20:09:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKYot-0000cL-Bi for qemu-devel@nongnu.org; Wed, 07 Nov 2018 20:09:19 -0500 Received: from [107.173.13.209] (port=32786 helo=ozlabs.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKYot-0000bu-66 for qemu-devel@nongnu.org; Wed, 07 Nov 2018 20:09:15 -0500 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id DC6DDAE80015; Wed, 7 Nov 2018 20:02:59 -0500 (EST) From: Alexey Kardashevskiy To: qemu-devel@nongnu.org Date: Thu, 8 Nov 2018 12:02:58 +1100 Message-Id: <20181108010258.27010-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 107.173.13.209 Subject: [Qemu-devel] [PATCH qemu] hmp: Print if memory section is registered in KVM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This adds a "KVM" marker to the "into mtree -f" to tell the user if a particular memory section is registered as a KVM memory slot; useful for debugging purposes. Since it is memory sections which get registered in KVM (rather than memory regions), this only prints "KVM" for flatviews. For example: Root memory region: system 0000000000000000-00000003ffffffff (prio 0, ram): ppc_spapr.ram KVM 0000200000000020-000020000000003f (prio 1, i/o): virtio-pci Signed-off-by: Alexey Kardashevskiy Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- include/sysemu/kvm.h | 1 + accel/kvm/kvm-all.c | 7 +++++++ memory.c | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 97d8d9d0d5..9eab5ac1b1 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -471,6 +471,7 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigm= ask_len); #if !defined(CONFIG_USER_ONLY) int kvm_physical_memory_addr_from_host(KVMState *s, void *ram_addr, hwaddr *phys_addr); +bool is_kvm_memory(hwaddr start_addr, hwaddr size); #endif =20 #endif /* NEED_CPU_H */ diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 4880a05399..d72808aaa6 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -216,6 +216,13 @@ static KVMSlot *kvm_lookup_matching_slot(KVMMemoryList= ener *kml, return NULL; } =20 +bool is_kvm_memory(hwaddr start_addr, hwaddr size) +{ + KVMMemoryListener *kml =3D &kvm_state->memory_listener; + + return NULL !=3D kvm_lookup_matching_slot(kml, start_addr, size); +} + /* * Calculate and align the start address and the size of the section. * Return the size. If the size is 0, the aligned section is empty. diff --git a/memory.c b/memory.c index 51204aa079..56c733c687 100644 --- a/memory.c +++ b/memory.c @@ -2916,6 +2916,7 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, int n =3D view->nr; int i; AddressSpace *as; + bool print_kvm =3D false; =20 p(f, "FlatView #%d\n", fvi->counter); ++fvi->counter; @@ -2927,6 +2928,9 @@ static void mtree_print_flatview(gpointer key, gpoint= er value, p(f, ", alias %s", memory_region_name(as->root->alias)); } p(f, "\n"); + if (as =3D=3D &address_space_memory) { + print_kvm =3D true; + } } =20 p(f, " Root memory region: %s\n", @@ -2960,6 +2964,12 @@ static void mtree_print_flatview(gpointer key, gpoin= ter value, if (fvi->owner) { mtree_print_mr_owner(p, f, mr); } + + if (kvm_enabled() && print_kvm && + is_kvm_memory(int128_get64(range->addr.start), + MR_SIZE(range->addr.size) + 1)) { + p(f, " KVM"); + } p(f, "\n"); range++; } --=20 2.17.1