From nobody Mon Feb 9 10:11:59 2026 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; dkim=fail; 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=1573656859; cv=none; d=zoho.com; s=zohoarc; b=ktmfAdVIOOTy6ikOiVtZ/x+t0J3cjMGwwsC/pHrHzlN/z5TrdwWiDkTuX1esZFcD7DP/dlABxNvUXwSHfrxwbGybVYnNJvH0Y086INWm2Yne5/DzOrN4wBtOv2GMyA8tD8sTT2XPTmjD9kGReRqaQcxufmP+/oqkCwOcS1dNHgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573656859; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=PGYMUDTg2D6rpcuWlf2brnz7lYfBlkB5vPdneLDV4o0=; b=HfRR0Li1Ojv8f20ZelMOZF+S2WnO6CP/sKZGL/yOhWMAJJFhW1Y2thrwsSCTJpBfY5lLsxmuHGOdDVQRcmkFPhL3s6K5hagyP5v2t33rybvX7m5lW3UDN3YZS7nJe07PCMxePZx2n7RjUyE7XtVGgxW0r26QEcfpQUUO2gP1LIM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1573656859592927.5789666565398; Wed, 13 Nov 2019 06:54:19 -0800 (PST) Received: from localhost ([::1]:45916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUu2D-0006jx-Kp for importer@patchew.org; Wed, 13 Nov 2019 09:54:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iUtnn-0005zl-Dw for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iUtnl-0006Mx-LS for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:23 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:42081) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iUtnl-0006MJ-E4 for qemu-devel@nongnu.org; Wed, 13 Nov 2019 09:39:21 -0500 Received: by mail-wr1-x430.google.com with SMTP id a15so2631387wrf.9 for ; Wed, 13 Nov 2019 06:39:21 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s11sm2965823wrr.43.2019.11.13.06.39.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 06:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=PGYMUDTg2D6rpcuWlf2brnz7lYfBlkB5vPdneLDV4o0=; b=PwardcY/zM62i9zeajrD6uIul+k+z+dgZ0AqJ9h7QWp06UqYLNuircOpRpTM1JEoNW lEiQPYg05vpPSvTmTrL1qVNPJP/gqebIeEE0jp9yQelLhlRZrIjEwgIMTn01nB4syPDH nxZuY/u/z6NGswXz9AJbB8sn5q0cwhDEChgjedBw8JswHpTyTImiEL5dR33KWOMI/k+9 +W9nocjVD2NoXDg6NLyFCZTMwh5oZfWekWXAnGSjd39e18G7pqL7pDk82Usy9neS9c1X 1G0zXimDuT5aNtmJkVOlgTkx9Phs2InhzO1R8zw+qTi+GLd3T7tv3Yec8uFES4ZdWEJx 93Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=PGYMUDTg2D6rpcuWlf2brnz7lYfBlkB5vPdneLDV4o0=; b=bOgxuid+eH6D4r8iaCTdaKcI5njAANor067VmXunrSW/Dtta6P90tGyTLIoEKYpCU8 uDLtEdl4QrF2Cz0n3ptEavSwC/cJnF16v5uJNi0F78RFCYE0K1gKzoEXfLUH5C9B9Rl+ 7CoIhtRVN2rw0J6rI5nO5ZO7AicZcut3qkK4FWMnxfpm72pB/1jmH5N2+id2wP+XHIq2 PpeFmIXBapGrox7ojs0Li0/Z8vn9jL0/wfzQjWdSaJzK5pyV0IrGtyeMBRaCGDUuAgpL 3r4I0NaUZ8uNo8387cBgt/RCHdpYIdFJNa846Zyz+TcfDjERAW96rnKmiY7dGzEbPxab lusQ== X-Gm-Message-State: APjAAAU6lyfG6C5kUZBru549X6aV6WlexUZq5nm65Z2/NX6r512k9tSa CA7T5ui2g6LbOEisbMVGPiUq/EZb X-Google-Smtp-Source: APXvYqyPEY2SE8d+ZI00rGKDuA4QxAx6UABo0NsLw0p6sHSrisLxmPCALWuvd91mZgHlZXKeK4Y38g== X-Received: by 2002:adf:c50a:: with SMTP id q10mr3358769wrf.374.1573655959543; Wed, 13 Nov 2019 06:39:19 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/16] kvm: convert "-machine kvm_shadow_mem" to an accelerator property Date: Wed, 13 Nov 2019 15:39:03 +0100 Message-Id: <1573655945-14912-15-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> References: <1573655945-14912-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 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: thuth@redhat.com, armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/core/machine.c | 39 --------------------------------------- include/hw/boards.h | 2 -- qemu-options.hx | 6 +++--- target/i386/kvm.c | 2 +- vl.c | 4 ++++ 6 files changed, 51 insertions(+), 45 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 140b0bd..c016319 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -41,6 +41,7 @@ #include "hw/irq.h" #include "sysemu/sev.h" #include "sysemu/balloon.h" +#include "qapi/visitor.h" =20 #include "hw/boards.h" =20 @@ -92,6 +93,7 @@ struct KVMState int max_nested_state_len; int many_ioeventfds; int intx_set_mask; + int kvm_shadow_mem; bool sync_mmu; bool manual_dirty_log_protect; /* The man page (and posix) say ioctl numbers are signed int, but @@ -2922,6 +2924,40 @@ static bool kvm_accel_has_memory(MachineState *ms, A= ddressSpace *as, return false; } =20 +static void kvm_get_kvm_shadow_mem(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + KVMState *s =3D KVM_STATE(obj); + int64_t value =3D s->kvm_shadow_mem; + + visit_type_int(v, name, &value, errp); +} + +static void kvm_set_kvm_shadow_mem(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + KVMState *s =3D KVM_STATE(obj); + Error *error =3D NULL; + int64_t value; + + visit_type_int(v, name, &value, &error); + if (error) { + error_propagate(errp, error); + return; + } + + s->kvm_shadow_mem =3D value; +} + +static void kvm_accel_instance_init(Object *obj) +{ + KVMState *s =3D KVM_STATE(obj); + + s->kvm_shadow_mem =3D -1; +} + static void kvm_accel_class_init(ObjectClass *oc, void *data) { AccelClass *ac =3D ACCEL_CLASS(oc); @@ -2929,11 +2965,18 @@ static void kvm_accel_class_init(ObjectClass *oc, v= oid *data) ac->init_machine =3D kvm_init; ac->has_memory =3D kvm_accel_has_memory; ac->allowed =3D &kvm_allowed; + + object_class_property_add(oc, "kvm-shadow-mem", "int", + kvm_get_kvm_shadow_mem, kvm_set_kvm_shadow_mem, + NULL, NULL, &error_abort); + object_class_property_set_description(oc, "kvm-shadow-mem", + "KVM shadow MMU size", &error_abort); } =20 static const TypeInfo kvm_accel_type =3D { .name =3D TYPE_KVM_ACCEL, .parent =3D TYPE_ACCEL, + .instance_init =3D kvm_accel_instance_init, .class_init =3D kvm_accel_class_init, .instance_size =3D sizeof(KVMState), }; diff --git a/hw/core/machine.c b/hw/core/machine.c index d7a0356..bfb5f6f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -211,33 +211,6 @@ static void machine_set_kernel_irqchip(Object *obj, Vi= sitor *v, } } =20 -static void machine_get_kvm_shadow_mem(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - int64_t value =3D ms->kvm_shadow_mem; - - visit_type_int(v, name, &value, errp); -} - -static void machine_set_kvm_shadow_mem(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - MachineState *ms =3D MACHINE(obj); - Error *error =3D NULL; - int64_t value; - - visit_type_int(v, name, &value, &error); - if (error) { - error_propagate(errp, error); - return; - } - - ms->kvm_shadow_mem =3D value; -} - static char *machine_get_kernel(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); @@ -785,12 +758,6 @@ static void machine_class_init(ObjectClass *oc, void *= data) object_class_property_set_description(oc, "kernel-irqchip", "Configure KVM in-kernel irqchip", &error_abort); =20 - object_class_property_add(oc, "kvm-shadow-mem", "int", - machine_get_kvm_shadow_mem, machine_set_kvm_shadow_mem, - NULL, NULL, &error_abort); - object_class_property_set_description(oc, "kvm-shadow-mem", - "KVM shadow MMU size", &error_abort); - object_class_property_add_str(oc, "kernel", machine_get_kernel, machine_set_kernel, &error_abort); object_class_property_set_description(oc, "kernel", @@ -892,7 +859,6 @@ static void machine_initfn(Object *obj) =20 ms->kernel_irqchip_allowed =3D true; ms->kernel_irqchip_split =3D mc->default_kernel_irqchip_split; - ms->kvm_shadow_mem =3D -1; ms->dump_guest_core =3D true; ms->mem_merge =3D true; ms->enable_graphics =3D true; @@ -963,11 +929,6 @@ bool machine_kernel_irqchip_split(MachineState *machin= e) return machine->kernel_irqchip_split; } =20 -int machine_kvm_shadow_mem(MachineState *machine) -{ - return machine->kvm_shadow_mem; -} - int machine_phandle_start(MachineState *machine) { return machine->phandle_start; diff --git a/include/hw/boards.h b/include/hw/boards.h index cdcf481..46119eb 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -66,7 +66,6 @@ bool machine_usb(MachineState *machine); bool machine_kernel_irqchip_allowed(MachineState *machine); bool machine_kernel_irqchip_required(MachineState *machine); bool machine_kernel_irqchip_split(MachineState *machine); -int machine_kvm_shadow_mem(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); @@ -278,7 +277,6 @@ struct MachineState { bool kernel_irqchip_allowed; bool kernel_irqchip_required; bool kernel_irqchip_split; - int kvm_shadow_mem; char *dtb; char *dumpdtb; int phandle_start; diff --git a/qemu-options.hx b/qemu-options.hx index 5b43a83..ae56eca 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -34,7 +34,6 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " supported accelerators are kvm, xen, hax, hvf, whpx o= r tcg (default: tcg)\n" " kernel_irqchip=3Don|off|split controls accelerated ir= qchip support (default=3Doff)\n" " vmport=3Don|off|auto controls emulation of vmport (de= fault: auto)\n" - " kvm_shadow_mem=3Dsize of KVM shadow MMU in bytes\n" " dump-guest-core=3Don|off include guest memory in a co= re dump (default=3Don)\n" " mem-merge=3Don|off controls memory merge support (def= ault: on)\n" " aes-key-wrap=3Don|off controls support for AES key wr= apping (default=3Don)\n" @@ -74,8 +73,6 @@ Controls in-kernel irqchip support for the chosen acceler= ator when available. Enables emulation of VMWare IO port, for vmmouse etc. auto says to select = the value based on accel. For accel=3Dxen the default is off otherwise the def= ault is on. -@item kvm_shadow_mem=3Dsize -Defines the size of the KVM shadow MMU. @item dump-guest-core=3Don|off Include guest memory in a core dump. The default is on. @item mem-merge=3Don|off @@ -118,6 +115,7 @@ DEF("accel", HAS_ARG, QEMU_OPTION_accel, "-accel [accel=3D]accelerator[,prop[=3Dvalue][,...]]\n" " select accelerator (kvm, xen, hax, hvf, whpx or tcg; = use 'help' for a list)\n" " igd-passthru=3Don|off (enable Xen integrated Intel gr= aphics passthrough, default=3Doff)\n" + " kvm-shadow-mem=3Dsize of KVM shadow MMU in bytes\n" " tb-size=3Dn (TCG translation block cache size)\n" " thread=3Dsingle|multi (enable multi-threaded TCG)\n",= QEMU_ARCH_ALL) STEXI @@ -131,6 +129,8 @@ fails to initialize. @item igd-passthru=3Don|off When Xen is in use, this option controls whether Intel integrated graphics devices can be passed through to the guest (default=3Doff) +@item kvm-shadow-mem=3Dsize +Defines the size of the KVM shadow MMU. @item tb-size=3D@var{n} Controls the size (in MiB) of the TCG translation block cache. @item thread=3Dsingle|multi diff --git a/target/i386/kvm.c b/target/i386/kvm.c index bfd09bd..7dc05c6 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -2159,7 +2159,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } qemu_register_reset(kvm_unpoison_all, NULL); =20 - shadow_mem =3D machine_kvm_shadow_mem(ms); + shadow_mem =3D object_property_get_int(OBJECT(s), "kvm-shadow-mem", &e= rror_abort); if (shadow_mem !=3D -1) { shadow_mem /=3D 4096; ret =3D kvm_vm_ioctl(s, KVM_SET_NR_MMU_PAGES, shadow_mem); diff --git a/vl.c b/vl.c index 7d8fed1..1d799b6 100644 --- a/vl.c +++ b/vl.c @@ -2642,6 +2642,10 @@ static int machine_set_property(void *opaque, object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, valu= e); return 0; } + if (g_str_equal(qom_name, "kvm-shadow-mem")) { + object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, valu= e); + return 0; + } =20 r =3D object_parse_property_opt(opaque, name, value, "type", errp); g_free(qom_name); --=20 1.8.3.1