From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026053597333.24756187880905; Fri, 4 Feb 2022 17:54:13 -0800 (PST) Received: from localhost ([::1]:53744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAHE-0004NV-Ku for importer@patchew.org; Fri, 04 Feb 2022 20:54:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6C-0003eI-Pm for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48320) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA69-0003Ha-PE for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:47 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-217-OI_pxKtiNACcZ6ckK7FlkA-1; Fri, 04 Feb 2022 20:42:43 -0500 Received: by mail-wr1-f71.google.com with SMTP id k7-20020adfb347000000b001dd761d46c7so2780670wrd.4 for ; Fri, 04 Feb 2022 17:42:43 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id e17sm2584285wme.29.2022.02.04.17.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025364; 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: in-reply-to:in-reply-to:references:references; bh=EU2zPx6JC+R5DZIlP0yKSn9BYb3OIhPFICOQQCHTxuk=; b=hIu49R/5dIxKjJGCpOxF59dmjWfD/Tr4TzmcK2OS9USslj/akaLGoxW5/sJ5YbEsFW0PjV vw345kXM9qQRkig99v23MX5PpqufztpBAW0JfTdaXGCFUCEjAEVkmpcPRsbbdwpCAHw1sB 49d303/jBR9QG7/Fx9e5Ts3Xd94ejz0= X-MC-Unique: OI_pxKtiNACcZ6ckK7FlkA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=EU2zPx6JC+R5DZIlP0yKSn9BYb3OIhPFICOQQCHTxuk=; b=XL/x4YuSCtarhPtUCGLS3QRU/pMFZUTr8SeTSNBY9TfuWFcZoFHWkBsVblCE651X0h gIKXLkCEtlHxwN5nzTjV5Ot6MjA+qq3hRYIjo3JvO39SplE1AJHBCdREpvfByWwzo+j7 +1Eum1RYfDc7C5lqiSs4vHXAF4HDM6LpD42lFOEV+xi++l7KdB/Gxd5OqowlA5xOFNZQ DDCAvKt31vPgnOpmZOMglBvFlaMzgAsWThJObDkyavf/rPrJe17rdo6ZShX0q3uFunTu 5l9JX9LGyBuCGQXUxQI/TrZGGtASaP8/B7DxFkPx1HM0B5w8aagGqigs1JXxV4J6PFrW wDbw== X-Gm-Message-State: AOAM5321hq+s2vBaWpLTPSLeGldtiWXtaWsVyu4bbV/QcCn+a1SvnyJv oXwUsqEOM6CdlPG1UVim02kxlnmfdN3lKhRTt47NSDocmDuYAonINVzgy08XNtumPTnY+cLU5TB F0DWrK/Nvt6FRQK9yvFripEl3oYTCwxW7mJAmvyjR+hZR1U+cs5yFZAfQ2oUw X-Received: by 2002:a5d:6112:: with SMTP id v18mr1185020wrt.713.1644025362087; Fri, 04 Feb 2022 17:42:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUlH3VquMQ0HTCYX8Bhkb9ae0C97Tkhr26hsMi7BXHUZ74wksRSMxh85c+n3yC/dkluv81Qw== X-Received: by 2002:a5d:6112:: with SMTP id v18mr1185003wrt.713.1644025361875; Fri, 04 Feb 2022 17:42:41 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/32] cpuid: use unsigned for max cpuid Message-ID: <20220205014149.1189026-2-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , Richard Henderson , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026054578100001 __get_cpuid_max returns an unsigned value. For consistency, store the result in an unsigned variable. Cc: Paolo Bonzini Cc: Richard Henderson Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- configure | 2 +- util/bufferiszero.c | 2 +- tcg/i386/tcg-target.c.inc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index e6cfc0e4be..dfb9019b24 100755 --- a/configure +++ b/configure @@ -2768,7 +2768,7 @@ cat > $TMPC << EOF #include int main(void) { unsigned a, b, c, d; - int max =3D __get_cpuid_max(0, 0); + unsigned max =3D __get_cpuid_max(0, 0); =20 if (max >=3D 1) { __cpuid(1, a, b, c, d); diff --git a/util/bufferiszero.c b/util/bufferiszero.c index 695bb4ce28..ec3cd4ca15 100644 --- a/util/bufferiszero.c +++ b/util/bufferiszero.c @@ -272,7 +272,7 @@ static void init_accel(unsigned cache) =20 static void __attribute__((constructor)) init_cpuid_cache(void) { - int max =3D __get_cpuid_max(0, NULL); + unsigned max =3D __get_cpuid_max(0, NULL); int a, b, c, d; unsigned cache =3D 0; =20 diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 875311f795..4dab09f265 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -3747,7 +3747,7 @@ static void tcg_target_init(TCGContext *s) { #ifdef CONFIG_CPUID_H unsigned a, b, c, d, b7 =3D 0; - int max =3D __get_cpuid_max(0, 0); + unsigned max =3D __get_cpuid_max(0, 0); =20 if (max >=3D 7) { /* BMI1 is available on AMD Piledriver and Intel Haswell CPUs. */ --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026307404487.581271916309; Fri, 4 Feb 2022 17:58:27 -0800 (PST) Received: from localhost ([::1]:34762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGALK-0002Hp-8t for importer@patchew.org; Fri, 04 Feb 2022 20:58:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6F-0003fa-Sr for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57998) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6D-0003Hw-I3 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:51 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-93-DSbc9QglMLu7WN21s-97ig-1; Fri, 04 Feb 2022 20:42:46 -0500 Received: by mail-wr1-f72.google.com with SMTP id e1-20020adfa741000000b001e2e74c3d4eso1139406wrd.12 for ; Fri, 04 Feb 2022 17:42:46 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id r12sm3519304wrw.73.2022.02.04.17.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025368; 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: in-reply-to:in-reply-to:references:references; bh=djZWuMgvZEcanxSuVKi0jq5sfyl2x4cIrvJR3neBz+A=; b=TXWBZCj1e3Yhb2tpAds6eetsuZKbZGnJ1pTISh5VF2r7dVbx7UEN7kEG/4ZAE5qYSt+zvx PGF4be0nvIZnp9JnKj+GISpq9mD8m+Vvxdqey/PYNLH74IJ9F1yPiAkM01kPGKess8/AVh y+wpX7/cF0qYqheeaH4hNuHnOZ3x+0c= X-MC-Unique: DSbc9QglMLu7WN21s-97ig-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=djZWuMgvZEcanxSuVKi0jq5sfyl2x4cIrvJR3neBz+A=; b=cI/hNGuVKFM1uVthvlCe6cq0y1rjCREnZ8WbnfX1wZIjRj79E4TnS9nGp9cCXm0Eam r/qFD0FAmqgjQqX/c+LsjV6dPfLj0yzqX0myCbTNsLaay8VfbMJOfKsQNliaqsTOA6wX LSroE5pJp1/stQlAoeX6y3M83kSxUaeEQYS/0b4eKoJX3yu01AMZ6rUFwMhSrFWRW2tm zj9ffn12SGqzZcnYVu4ykCQ8F+VmmDjUmHSKDTWw+50Me1Bjk3yNz9iV+j4iKdbheI8b uMl9gDZl92wAm2jc1M3Z/5xHkDqtNEmXaZ8vVXSKmk51F2KJ5FNILVaFrSPpxGXNh773 XUsw== X-Gm-Message-State: AOAM5321u4x+NLUax6bW4aFseyBHgTbTYSeivdyzcb6hNnoS8pgXpoWg uw6POBnRa6iwmNiKTjQ2JbX48A5UPWjy5mob+b9nhoVTmmjEUiXdwXSPVzuLcL9QkRzxkpR8BLf Jd+ERrHWhJnNyJDb9vSw/U3ejjOrmwQI1I15cT65CKOiIOINiC9baWemUy97u X-Received: by 2002:a5d:598c:: with SMTP id n12mr1269322wri.86.1644025364764; Fri, 04 Feb 2022 17:42:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqv/E4l8LDu0uEG6CIckhX6qhjO40D/IECUQmApAnjgV/fiiwZFkPB/+880XYkolsslQ0Fcg== X-Received: by 2002:a5d:598c:: with SMTP id n12mr1269304wri.86.1644025364551; Fri, 04 Feb 2022 17:42:44 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/32] hw/i386: Add the possibility to disable the 'isapc' machine Message-ID: <20220205014149.1189026-3-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Cc: Eduardo Habkost , Peter Maydell , Thomas Huth , qemu-block@nongnu.org, Laurent Vivier , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026309538100001 From: Thomas Huth We already have a CONFIG_ISAPC switch - but we're not using it yet. Add some "#ifdefs" to make it possible to disable this machine now. Signed-off-by: Thomas Huth Message-Id: <20220107160713.235918-1-thuth@redhat.com> Acked-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 5 ++++- tests/qtest/cdrom-test.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 7c7790a5ce..d9b344248d 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -357,10 +357,12 @@ static void pc_compat_1_4_fn(MachineState *machine) pc_compat_1_5_fn(machine); } =20 +#ifdef CONFIG_ISAPC static void pc_init_isa(MachineState *machine) { pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE); } +#endif =20 #ifdef CONFIG_XEN static void pc_xen_hvm_init_pci(MachineState *machine) @@ -916,6 +918,7 @@ void igd_passthrough_isa_bridge_create(PCIBus *bus, uin= t16_t gpu_dev_id) pci_config_set_revision(bridge_dev->config, pch_rev_id); } =20 +#ifdef CONFIG_ISAPC static void isapc_machine_options(MachineClass *m) { PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); @@ -935,7 +938,7 @@ static void isapc_machine_options(MachineClass *m) =20 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, isapc_machine_options); - +#endif =20 #ifdef CONFIG_XEN static void xenfv_4_2_machine_options(MachineClass *m) diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c index cfca24fa94..fdd889a487 100644 --- a/tests/qtest/cdrom-test.c +++ b/tests/qtest/cdrom-test.c @@ -138,7 +138,7 @@ static void add_x86_tests(void) * Unstable CI test under load * See https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg05509.= html */ - if (g_test_slow()) { + if (g_test_slow() && qtest_has_machine("isapc")) { qtest_add_data_func("cdrom/boot/isapc", "-M isapc " "-drive if=3Dide,media=3Dcdrom,file=3D", test_= cdboot); } --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026524105585.8738467451932; Fri, 4 Feb 2022 18:02:04 -0800 (PST) Received: from localhost ([::1]:43328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAOo-0007yL-Mw for importer@patchew.org; Fri, 04 Feb 2022 21:02:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6F-0003fc-TS for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6D-0003I0-Tz for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:51 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-7-ZftfzC0RPqSzNfR1Jr8ACA-1; Fri, 04 Feb 2022 20:42:48 -0500 Received: by mail-wm1-f70.google.com with SMTP id j18-20020a05600c1c1200b0034aeea95dacso8367478wms.8 for ; Fri, 04 Feb 2022 17:42:48 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id k1sm1195396wmh.27.2022.02.04.17.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025369; 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: in-reply-to:in-reply-to:references:references; bh=Cys7fA3V9JqsHSWEFuxYME8lo9Xx2jeY6AGCu56+bB4=; b=GwGW8z9OsgM2zPJf0c3SFfMk9g7FKvMypW3H+jW7MUaOZAniQBwlplZpbIp0k3mst0vsqk WfSRVkkbUNOPUr2924Tf5UeBaSXEYdSZNMTGAJslA0CCRa3ql9trgvi8Y2tESplM/YCm2U V2j6gMlPgL0OE8vqnRUUHpcFAQsLCSY= X-MC-Unique: ZftfzC0RPqSzNfR1Jr8ACA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Cys7fA3V9JqsHSWEFuxYME8lo9Xx2jeY6AGCu56+bB4=; b=HW0h/huwRIeInuYkY4TBAFueLdprA4W/nrRWOjsN/kdX4F6IAiph6M9260smcMIk2O bnH5x7IGkd3IwgEne1bmUjHEuyHYG6MqGjXoN9WVLJc7i6T9CDAczFYGI6GolagufcDj C+HJBqbzgg6NvDd55ZK4OL9yHtyTC0geA6zl2vGv7nDMd3aQJ8l9kajQBUSPMLDZk8bp BJxKX8C/Zro074vReG0If/5VeoaPZ30kDl5RjI7W170vkFBa/JSWRCMvsgsfcB3z/vZo 94CZNWBe1QKV0Xfls4OkY7L0ddtAlD4mLrQu6GMqWjF2SDQaSkxMgyq5kl9VdLwpeq2Z Knzw== X-Gm-Message-State: AOAM5319cEonhvXpA1lFK1Z3hGlKXt0w8FfZMHXnksrdLrnpfO7uQ0H2 yQvXnP1Ru/xP34Ou5YKbG5gcqAwBl9h9+TUSyISmvbtPq6sanGCo733PTK/DJUajXIb4V4mZYjj dfItX39g0O0i4uNba2fWlg7k1kRlhHGEMz22MakdP/ALDAvm6zImo+LGJGvIb X-Received: by 2002:a05:6000:156d:: with SMTP id 13mr1230888wrz.34.1644025366987; Fri, 04 Feb 2022 17:42:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBGrWSwytTAavn3QR2tRkM82rZ+Ufk7noks4l0l9GeZABOSc2O0HEM1EcbnOIPPkhQMh50tA== X-Received: by 2002:a05:6000:156d:: with SMTP id 13mr1230875wrz.34.1644025366755; Fri, 04 Feb 2022 17:42:46 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/32] tests: acpi: manually pad OEM_ID/OEM_TABLE_ID for test_oem_fields() test Message-ID: <20220205014149.1189026-4-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026524673100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov The next commit will revert OEM fields padding with whitespace to padding with '\0' as it was before [1]. As result test_oem_fields() will fail due to unexpectedly smaller ID sizes read from QEMU ACPI tables. Pad OEM_ID/OEM_TABLE_ID manually with spaces so that values the test puts on QEMU CLI and expected values match. 1) 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be changed") Signed-off-by: Igor Mammedov Message-Id: <20220112130332.1648664-2-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index e6b72d9026..90c9f6a0a2 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -71,9 +71,10 @@ =20 #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" =20 -#define OEM_ID "TEST" -#define OEM_TABLE_ID "OEM" -#define OEM_TEST_ARGS "-machine x-oem-id=3D"OEM_ID",x-oem-table-id=3D= "OEM_TABLE_ID +#define OEM_ID "TEST " +#define OEM_TABLE_ID "OEM " +#define OEM_TEST_ARGS "-machine x-oem-id=3D'" OEM_ID "',x-oem-table-i= d=3D'" \ + OEM_TABLE_ID "'" =20 typedef struct { bool tcg_only; @@ -1519,11 +1520,7 @@ static void test_acpi_q35_slic(void) static void test_oem_fields(test_data *data) { int i; - char oem_id[6]; - char oem_table_id[8]; =20 - strpadcpy(oem_id, sizeof oem_id, OEM_ID, ' '); - strpadcpy(oem_table_id, sizeof oem_table_id, OEM_TABLE_ID, ' '); for (i =3D 0; i < data->tables->len; ++i) { AcpiSdtTable *sdt; =20 @@ -1533,8 +1530,8 @@ static void test_oem_fields(test_data *data) continue; } =20 - g_assert(memcmp(sdt->aml + 10, oem_id, 6) =3D=3D 0); - g_assert(memcmp(sdt->aml + 16, oem_table_id, 8) =3D=3D 0); + g_assert(memcmp(sdt->aml + 10, OEM_ID, 6) =3D=3D 0); + g_assert(memcmp(sdt->aml + 16, OEM_TABLE_ID, 8) =3D=3D 0); } } =20 --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644025876772332.71807667614644; Fri, 4 Feb 2022 17:51:16 -0800 (PST) Received: from localhost ([::1]:45254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAEN-00074p-C5 for importer@patchew.org; Fri, 04 Feb 2022 20:51:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6J-0003gj-Ew for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55507) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6G-0003IN-8H for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:54 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-iWIZzhAFPACtLLzhSMSpDA-1; Fri, 04 Feb 2022 20:42:50 -0500 Received: by mail-wm1-f72.google.com with SMTP id j18-20020a05600c1c1200b0034aeea95dacso8367504wms.8 for ; Fri, 04 Feb 2022 17:42:50 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id o2sm11795141wmq.21.2022.02.04.17.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025371; 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: in-reply-to:in-reply-to:references:references; bh=+T8qucJ387ei/9dUQXGMLrCgzMKuOac0iEv5x3VIdi8=; b=SL0LL/OqxElf5Lig7I0xc4MpOGpymQsPnvLB48B/oqtfyLxUkW8tvs8PXEmQwOq1iX2gWh 17S7HoXTPkmMJBs4AM6z0bK2LTocVjGWz2i/YQh1IueaEf964I3hfc+getnpzRtBdphyPe 5IqEr4t8XrgbrmLx0kj1q8HrBhVgx0Y= X-MC-Unique: iWIZzhAFPACtLLzhSMSpDA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+T8qucJ387ei/9dUQXGMLrCgzMKuOac0iEv5x3VIdi8=; b=oZTXvdH1XBXq04m/I/nTgeCorvavqum1UG5n88tqBJZuYlnGCHt70Sb0BVka3bHWwC tqJJl8NZN2PInhNDvDa5fqM4tSBNO+lt+jk3SpICZY+J1XYVKUe8cZLkU3Kk+HU95x86 x3hOohqN51kSTawZVxT0uRhQy6njaa4TeJWeNPtFrH2vJgC7YPhRKWQVFG4n7zly4M5q tUH4Nyax/kBN8trMo+n9Z1bF4BZLHRl9/gUxTgiE11MqY4ZY5HrGpIP9p6wWkYVeYmog CWWidFjl3MmCx5MN0vGSiHthhYmKr+UR8GI7pQh3+r9BxzBog2zdzNNLCzKrPKsIgO0L oD4w== X-Gm-Message-State: AOAM5308bLLWPo6PI2/tBfAM1EppFdfGyWYC/coHMRHETwKUjY27Xhn0 Sc3Kc2ja5sB4D//8vVDia+56kWXXlLEamqja4Zz3kIl7PZLlzyh27ATTE8BGoNbexBMAy7oQz6l uQB/+nBo/FbA1tpncaLqPQXuKFD9wB9q9zqKOIgjLfe4anQpMQFdGLUESVpot X-Received: by 2002:a5d:5552:: with SMTP id g18mr1237324wrw.343.1644025369088; Fri, 04 Feb 2022 17:42:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/1pBw8bz0icJM7fTq2l+yPMXhLdMaXDf6uv57nNMsNvy2sHQ68bZ+wLGk0JZ+QsDN1Hj3Bw== X-Received: by 2002:a5d:5552:: with SMTP id g18mr1237310wrw.343.1644025368838; Fri, 04 Feb 2022 17:42:48 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/32] tests: acpi: whitelist nvdimm's SSDT and FACP.slic expected blobs Message-ID: <20220205014149.1189026-5-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644025879428100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov The next commit will revert OEM fields whitespace padding to padding with '\0' as it was before [1]. That will change OEM Table ID for: * SSDT.*: where it was padded from 6 characters to 8 * FACP.slic: where it was padded from 2 characters to 8 after reverting whitespace padding, it will be replaced with '\0' which effectively will shorten OEM table ID to 6 and 2 characters. Whitelist affected tables before introducing the change. 1) 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be changed") Signed-off-by: Igor Mammedov Message-Id: <20220112130332.1648664-3-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..7faa8f53be 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,5 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/SSDT.memhp", +"tests/data/acpi/pc/SSDT.dimmpxm", +"tests/data/acpi/q35/SSDT.dimmpxm", +"tests/data/acpi/q35/FACP.slic", --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644025878908852.0406794012902; Fri, 4 Feb 2022 17:51:18 -0800 (PST) Received: from localhost ([::1]:45376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAEP-0007Fb-QI for importer@patchew.org; Fri, 04 Feb 2022 20:51:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6L-0003h2-Em for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6I-0003Ij-6Q for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:42:55 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-441-_gSKQnuUOYuxPmK56sn_iQ-1; Fri, 04 Feb 2022 20:42:52 -0500 Received: by mail-wr1-f71.google.com with SMTP id k12-20020adfe3cc000000b001d6806dfde1so2779112wrm.16 for ; Fri, 04 Feb 2022 17:42:52 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id n10sm10780377wmr.25.2022.02.04.17.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025373; 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: in-reply-to:in-reply-to:references:references; bh=7KcsN9wh78ObpWmFzT4JOGjUX5sRs+uFsgg22ySvULc=; b=QHQyRrGB/hK+8+H7N/TxUoYJ0Xg9qA3efmkMzu9iM7ADttu4hxqYYxb82+zfHpeq0atWHr nI1L/LfeKAH1AoPLk3QErDsRgqWYjpfltZF132n60LVs6xaTE7DyktCg0sDBeTV6M9K12d Xky06Px9gVQYB4qCqsSHe74MP6hlaIo= X-MC-Unique: _gSKQnuUOYuxPmK56sn_iQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7KcsN9wh78ObpWmFzT4JOGjUX5sRs+uFsgg22ySvULc=; b=z+Uj3ca45sJcmd6paqP+aOwmxlMrakod7vCRJ2ae5vtcGFhyuYCCaP5a/3Yl3dWbm6 Lgnpoq36kLN6rBBImxk+d/lXwoyhLd7qwxNf/WVA020QvMv1GmPg4HcRbF/RlxMm3GJZ OcUY0xzI7Z94OchhZW7DGH3yD8ZZ6mcCDK6RGXcgJTU7+foDbaA+qrQyoQwiyN2/d1o+ 6JmqCK7ll6tAO4+LbxIWCefPKnhrt4Rtje+iFZoR04KpjrO7zjc8MVnCFuYq2htN3hm8 g+rM8EUhXt76IL0k7epc/QTtRcTl6EOSEun4ylMxCzrKtLrRfGxt2armTGN+HqbQStZe sXiA== X-Gm-Message-State: AOAM530mMwHr/ftlz6NWbQH44Il8Pb+4XP9g9NOT+egPJ7tpQO7hknwI vjUzWd737ltaNxEF/V5Nd93ltZys9XTbMmfvrRkhT9W1ZjsEx2rH9LbaD02//W1hNZI1kn4k2Kg TywWTI8SRkUuaBVlRdswZE0uW/JRS0l5sqO7RqPAOWVXP33K/hMB2mr12KP3c X-Received: by 2002:a05:6000:16cc:: with SMTP id h12mr1225771wrf.408.1644025371365; Fri, 04 Feb 2022 17:42:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/ocJPl+glT3ARTk70LzTFPhYqSyvwrfoOszvcEzUOxTS4vTPoZsN9hEZo1QOVqObA2R2trw== X-Received: by 2002:a05:6000:16cc:: with SMTP id h12mr1225755wrf.408.1644025371180; Fri, 04 Feb 2022 17:42:51 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/32] acpi: fix OEM ID/OEM Table ID padding Message-ID: <20220205014149.1189026-6-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , qemu-stable@nongnu.org, "Dmitry V . Orekhov" , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644025879432100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Commit [2] broke original '\0' padding of OEM ID and OEM Table ID fields in headers of ACPI tables. While it doesn't have impact on default values since QEMU uses 6 and 8 characters long values respectively, it broke usecase where IDs are provided on QEMU CLI. It shouldn't affect guest (but may cause licensing verification issues in guest OS). One of the broken usecases is user supplied SLIC table with IDs shorter than max possible length, where [2] mangles IDs with extra spaces in RSDT and FADT tables whereas guest OS expects those to mirror the respective values of the used SLIC table. Fix it by replacing whitespace padding with '\0' padding in accordance with [1] and expectations of guest OS 1) ACPI spec, v2.0b 17.2 AML Grammar Definition ... //OEM ID of up to 6 characters. If the OEM ID is //shorter than 6 characters, it can be terminated //with a NULL character. 2) Fixes: 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be chang= ed") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/707 Reported-by: Dmitry V. Orekhov Signed-off-by: Igor Mammedov Cc: qemu-stable@nongnu.org Message-Id: <20220112130332.1648664-4-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Ani Sinha Tested-by: Dmitry V. Orekhov dima.orekhov@gmail.com --- hw/acpi/aml-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index bb2cad63b5..8966e16320 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1724,9 +1724,9 @@ void acpi_table_begin(AcpiTable *desc, GArray *array) build_append_int_noprefix(array, 0, 4); /* Length */ build_append_int_noprefix(array, desc->rev, 1); /* Revision */ build_append_int_noprefix(array, 0, 1); /* Checksum */ - build_append_padded_str(array, desc->oem_id, 6, ' '); /* OEMID */ + build_append_padded_str(array, desc->oem_id, 6, '\0'); /* OEMID */ /* OEM Table ID */ - build_append_padded_str(array, desc->oem_table_id, 8, ' '); + build_append_padded_str(array, desc->oem_table_id, 8, '\0'); build_append_int_noprefix(array, 1, 4); /* OEM Revision */ g_array_append_vals(array, ACPI_BUILD_APPNAME8, 4); /* Creator ID */ build_append_int_noprefix(array, 1, 4); /* Creator Revision */ --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026297980354.51076465638187; Fri, 4 Feb 2022 17:58:17 -0800 (PST) Received: from localhost ([::1]:34432 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGALA-00024h-Ml for importer@patchew.org; Fri, 04 Feb 2022 20:58:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sM-HB for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22225) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6n-0003JH-31 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:31 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-g0YOO2rHMa-fhcnxs4oFlg-1; Fri, 04 Feb 2022 20:42:55 -0500 Received: by mail-wm1-f71.google.com with SMTP id j18-20020a05600c1c1200b0034aeea95dacso8367597wms.8 for ; Fri, 04 Feb 2022 17:42:55 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id a1sm3317318wrf.42.2022.02.04.17.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025381; 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: in-reply-to:in-reply-to:references:references; bh=ALRDgS1o8czRYC4IeFcfTwDqPAZgH2apoiLtTHvcCYM=; b=KH9kh0eTQyaOYJb+1yPRIOKffsB2mLvpFU9kY4uFlGJ+iQPGbMtgDz6U81T9nHnpVsTzKc J3kARqE+ib6FYA04VcpSve87IIH1Dk3O7B3hnlIecRnFGC5pKBrrXbVd5wydCFMX424aSI 6naTRCKcXxIdJ32QaOf1PrxFrR37FLg= X-MC-Unique: g0YOO2rHMa-fhcnxs4oFlg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ALRDgS1o8czRYC4IeFcfTwDqPAZgH2apoiLtTHvcCYM=; b=KYkil0u8WveOHLa/NKxS14M528Qrp4fEugHehXIQHZ3fDmzZHCpRRT83PzngxY4XZJ hGrUlP6A8JjWyqa1V6Uj/Rs9Veqxa1muhqbgkog3epPQdm8KlOg68hyzyi6u5mqna0VY B8Ncp9dtc/KS63CMmsIXGTdMwZzQKn2AaryAJ5R+XTuR8+OdmszwIl2UiVV4qP24j2RS gsr+VSvRfD86FsPoRQT1SeHYFExUKTopNajL6GcQdB+hECuRw/0/MeOyTok9z5mj5eMs juTPSUrAaiZYWhU0/4+g8ZmXHSpyQlRckOS4uED5QM7wNlVp3J/IY3YUa7xjIUCt+Hqo 17cw== X-Gm-Message-State: AOAM532df/Cx1j4qqFW+cJsqrGqN3nePb+SEBm8pWhIBJJeInF4uAGoW tRj4fhqeX7Ndt2kJE793X6y8RmZhzOmIpSmHZgRy4+R+30dlYVfR8cVUudIA65TYWBEGojdGQCy yCtd8PS9Q7HE7+ZPJgmdH4WdXBnWr5lSSQgRrPbwJR6qtBBM6y04fkx0vylSG X-Received: by 2002:a05:6000:15ca:: with SMTP id y10mr1237903wry.523.1644025373698; Fri, 04 Feb 2022 17:42:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVcTr85Ji3y6yPjhMremzt6aXmPjxx+FcfPq/PdzRBjC2UpF7zv04Lb3pj8jqsblVdYW7ZNQ== X-Received: by 2002:a05:6000:15ca:: with SMTP id y10mr1237888wry.523.1644025373456; Fri, 04 Feb 2022 17:42:53 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/32] tests: acpi: update expected blobs Message-ID: <20220205014149.1189026-7-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026299513100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Expected changes caused by previous commit: nvdimm ssdt (q35/pc/virt): - * OEM Table ID "NVDIMM " + * OEM Table ID "NVDIMM" SLIC test FADT (tests/data/acpi/q35/FACP.slic): -[010h 0016 8] Oem Table ID : "ME " +[010h 0016 8] Oem Table ID : "ME" Signed-off-by: Igor Mammedov Message-Id: <20220112130332.1648664-5-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- tests/data/acpi/pc/SSDT.dimmpxm | Bin 734 -> 734 bytes tests/data/acpi/q35/FACP.slic | Bin 244 -> 244 bytes tests/data/acpi/q35/SSDT.dimmpxm | Bin 734 -> 734 bytes tests/data/acpi/virt/SSDT.memhp | Bin 736 -> 736 bytes 5 files changed, 4 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 7faa8f53be..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,5 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/virt/SSDT.memhp", -"tests/data/acpi/pc/SSDT.dimmpxm", -"tests/data/acpi/q35/SSDT.dimmpxm", -"tests/data/acpi/q35/FACP.slic", diff --git a/tests/data/acpi/pc/SSDT.dimmpxm b/tests/data/acpi/pc/SSDT.dimm= pxm index a50a961fa1d9b0dd8ea4096d652c83bcf04db20b..ac55387d57e48adb99eb738a102= 308688a262fb8 100644 GIT binary patch delta 33 ocmcb|dXH5iIM^lR9uortW0;e_vq!LkUzm%huP+0`Mu}rg0HzrUKL7v# delta 33 ocmcb|dXH5iIM^lR9uortqnMMwvq!LkUzm%hudjl_Mu}rg0HV1GKL7v# diff --git a/tests/data/acpi/q35/FACP.slic b/tests/data/acpi/q35/FACP.slic index 891fd4b784b7b6b3ea303976db7ecd5b669bc84b..15986e095cf2db7ee92f7ce113c= 1d46d54018c62 100644 GIT binary patch delta 32 lcmeyu_=3DQoz&CxmF3j+fK^CjmX$6yZyUsoUp2qsG00RW!Z2#x>% delta 32 kcmeyu_=3DQoz&CxmF3j+fKvygL;W3Y#Uud4zWOq93-0G2oijsO4v diff --git a/tests/data/acpi/q35/SSDT.dimmpxm b/tests/data/acpi/q35/SSDT.di= mmpxm index 617a1c911c7d6753bcedc8ecc52e3027a5259ad6..98e6f0e3f3bb02dd419e36bdd1d= b9b94c728c406 100644 GIT binary patch delta 33 ocmcb|dXH5iIM^lR9uortqnnezvq!LkUzm%huP+0`Mu}rg0Ho;&F8}}l delta 33 ocmcb|dXH5iIM^lR9uortBb$@Ivq!LkUzm%hudjl_Mu}rg0HKKqF8}}l diff --git a/tests/data/acpi/virt/SSDT.memhp b/tests/data/acpi/virt/SSDT.me= mhp index e8b850ae2239d8f496b12de672c2a1268e2f269d..375d7b6fc85a484f492a26ccd35= 5c205f2c34473 100644 GIT binary patch delta 33 ocmaFB`hZm;IM^lR0TTlQqrH>Avq!LkUzm%huP+0`Mu`(l0HqiSFaQ7m delta 33 ocmaFB`hZm;IM^lR0TTlQ<9{cAXOCb7zc3e1Uta} Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026088310781.385876022166; Fri, 4 Feb 2022 17:54:48 -0800 (PST) Received: from localhost ([::1]:54798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAHn-00057T-A7 for importer@patchew.org; Fri, 04 Feb 2022 20:54:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003km-Ka for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6N-0003J4-Cf for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:00 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-379-iBWZW0DvOMCabgFJPtvH5A-1; Fri, 04 Feb 2022 20:42:57 -0500 Received: by mail-wr1-f71.google.com with SMTP id w7-20020adfbac7000000b001d6f75e4faeso2804183wrg.7 for ; Fri, 04 Feb 2022 17:42:57 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id 5sm3673309wrb.113.2022.02.04.17.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025378; 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: in-reply-to:in-reply-to:references:references; bh=Pdwtg4YsnAYbmN/x8hq/7VP0oKua1VQsoEaxNXs2NSc=; b=XxtDmbpfS9KDyNJzhyX/na1pGzmelKT00PWJ6d39EFjzSUNhnwlMtGPCIr29c0za8fW+Qd mcfWMbVvveqU68ZlH4B59m/kQEShzWjDk5hrMVbuPXaluZducsppmbTWPGjNKps+NQh5Se 3JLyraGoYt9HzWe49AtilVo3Xfv4R60= X-MC-Unique: iBWZW0DvOMCabgFJPtvH5A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Pdwtg4YsnAYbmN/x8hq/7VP0oKua1VQsoEaxNXs2NSc=; b=DADEb35W6JlhadqumeKEPJH5dUonI1DQrzmNnNPJsXR20YEBQgg1U82IjxpEO8ssUE 1ERNjTQsQUjobpRS/7DsFk/zaW/Z94aDnqC/3pTxNVeXzQn45nIDs7ZOqrggzPNFYFyP 8d9QX5+Ow/XDljaSsEzzY15+R3NCYhQ1XHZs2pOOANrV+i4I4TaF1WqEut9tdUxRu/hc SAJV9xug3jXB7saaH3wyIqU4/wL9MNLjLsjlcmGxkWlwDmR8s92Yy4LJol5SBzQkBTWZ 2Co7JRblyTgixqJsJ8Vta07rUzk+64vupARilpf9x2039m4345Snl1KdnN0K9KGFUL9b 4dyQ== X-Gm-Message-State: AOAM532s7jtv9TeKchEZoUWe1xHynO1W3ojvbgtz1cHPaj26qtJUNPPR Tkfo6isNkIhF17osGHUM1xvWiGwenJAOTmWsW8rCleZFnTrCZ/MyTbF3mqVBzonMrIqw/q0I3BM crZB+5GtjYlT/5F1ZudrbWqrk8scoI+bB7gnjb8GdAIrGCaa+G+jYqzsIW6fS X-Received: by 2002:a5d:6c67:: with SMTP id r7mr1214263wrz.514.1644025376085; Fri, 04 Feb 2022 17:42:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPPcx0oYITpHdK/gPYZzROn48FrA+v6vG8Aay7KWXBK5/ERq2oW65bzny0AhKLfjnRnQd9yg== X-Received: by 2002:a5d:6c67:: with SMTP id r7mr1214251wrz.514.1644025375780; Fri, 04 Feb 2022 17:42:55 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/32] tests: acpi: test short OEM_ID/OEM_TABLE_ID values in test_oem_fields() Message-ID: <20220205014149.1189026-8-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026090134100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Previous patch [1] added explicit whitespace padding to OEM_ID/OEM_TABLE_ID values used in test_oem_fields() testcase to avoid false positive and bisection issues when QEMU is switched to \0' padding. As result testcase ceased to test values that were shorter than max possible length values. Update testcase to make sure that it's testing shorter IDs like it used to before [2]. 1) "tests: acpi: manually pad OEM_ID/OEM_TABLE_ID for test_oem_fields() te= st" 2) 602b458201 ("acpi: Permit OEM ID and OEM table ID fields to be changed") Signed-off-by: Igor Mammedov Message-Id: <20220114142641.1727679-1-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 90c9f6a0a2..ad536fd7b1 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -71,10 +71,10 @@ =20 #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML" =20 -#define OEM_ID "TEST " -#define OEM_TABLE_ID "OEM " -#define OEM_TEST_ARGS "-machine x-oem-id=3D'" OEM_ID "',x-oem-table-i= d=3D'" \ - OEM_TABLE_ID "'" +#define OEM_ID "TEST" +#define OEM_TABLE_ID "OEM" +#define OEM_TEST_ARGS "-machine x-oem-id=3D" OEM_ID ",x-oem-table-id= =3D" \ + OEM_TABLE_ID =20 typedef struct { bool tcg_only; @@ -1530,8 +1530,8 @@ static void test_oem_fields(test_data *data) continue; } =20 - g_assert(memcmp(sdt->aml + 10, OEM_ID, 6) =3D=3D 0); - g_assert(memcmp(sdt->aml + 16, OEM_TABLE_ID, 8) =3D=3D 0); + g_assert(strncmp((char *)sdt->aml + 10, OEM_ID, 6) =3D=3D 0); + g_assert(strncmp((char *)sdt->aml + 16, OEM_TABLE_ID, 8) =3D=3D 0); } } =20 --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026516651455.283968069494; Fri, 4 Feb 2022 18:01:56 -0800 (PST) Received: from localhost ([::1]:42930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAOh-0007hq-9b for importer@patchew.org; Fri, 04 Feb 2022 21:01:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sl-LG for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003JG-EA for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:33 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-h4U_40saNfW5Xl41zyLbLw-1; Fri, 04 Feb 2022 20:43:00 -0500 Received: by mail-wr1-f71.google.com with SMTP id g17-20020adfa591000000b001da86c91c22so2799838wrc.5 for ; Fri, 04 Feb 2022 17:43:00 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id g7sm3316797wmq.3.2022.02.04.17.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:42:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025381; 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: in-reply-to:in-reply-to:references:references; bh=FMY8xR93DQQSXRTh9cIog6ZkSuUw4ea/EPUUeaxLWQ8=; b=KPunbfBxY0o+pDFJa8pdrEmi5VGprLNGZ0SmYqnfzUqDU2e4OE8b2HLL13wgPozfavYPJi 1GzGCDJyA+jOmi526aB4OSv6tH+SL33mwBo1EkwSncRawllebxfSTarQoig1y9mMmQH+h/ vgDVT4VTsVHn/swhVtyS/VNzibpaXqw= X-MC-Unique: h4U_40saNfW5Xl41zyLbLw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FMY8xR93DQQSXRTh9cIog6ZkSuUw4ea/EPUUeaxLWQ8=; b=tyTJG5yozzUyWp3MtzVcUBwARqL7J52AyOBFMu7cYBjt5fdOUlIAxfwfX7l02yBvPE LkB4BuXFE3Jzq07n9QeotkwvDmPT7YMSMQTeIeJ9O65o7h/Q5cq7StxRmWUtTW5Nu3Mc d8WFrZJU+zfT0ClYi9i7X8wDt+oahFjp/TpONHlsdjDn6ooh9VDWJ8T5cG0/n8ZWrozB mn7gfKgLvSxs+SGVszFoZAjs7/FPSChK4d0fxqdQlh11oyMSl7Jq3DdV7a9dSmHaJSUj MVDjOsZPujXM6DEmwyWw+VTJWlapUSRgiNnZDX9xfyj6NCBH6jG1xsjmtdtcOJHAQvF0 mH4g== X-Gm-Message-State: AOAM531otJ5JgZ81Gfxaong6Jg6GWlaL75SDPiyDM1a5OhvH7WoB53fl bxtx1ju+QhXrsbHfRlQR8sFo3UExHoFZXwtGcO6ba4YVCY1lLiUYHwHU5G1ypl1C75z0qlfr7Mk oZbjCd5NnrH8ImVw2zXcJcT9wXWjreqUVr0s2vAatYA/2ZZuCuX8SiTw9dWCd X-Received: by 2002:a05:600c:34c2:: with SMTP id d2mr4403607wmq.120.1644025378820; Fri, 04 Feb 2022 17:42:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrfYEbaoiG95C5BLRbnE0gP+Kw9pwUzRpyl166yJtZJAUtD4mpZyBFjXy9FQXZyfotcidyeg== X-Received: by 2002:a05:600c:34c2:: with SMTP id d2mr4403581wmq.120.1644025378482; Fri, 04 Feb 2022 17:42:58 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/32] libvhost-user: Add vu_rem_mem_reg input validation Message-ID: <20220205014149.1189026-9-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , David Hildenbrand , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026517698100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz Today if multiple FDs are sent from the VMM to the backend in a VHOST_USER_REM_MEM_REG message, one FD will be unmapped and the remaining FDs will be leaked. Therefore if multiple FDs are sent we report an error and fail the operation, closing all FDs in the message. Likewise in case the VMM sends a message with a size less than that of a memory region descriptor, we add a check to gracefully report an error and fail the operation rather than crashing. Signed-off-by: Raphael Norwitz Message-Id: <20220117041050.19718-2-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand --- subprojects/libvhost-user/libvhost-user.h | 2 ++ subprojects/libvhost-user/libvhost-user.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.h b/subprojects/libvho= st-user/libvhost-user.h index 3d13dfadde..cde9f07bb3 100644 --- a/subprojects/libvhost-user/libvhost-user.h +++ b/subprojects/libvhost-user/libvhost-user.h @@ -129,6 +129,8 @@ typedef struct VhostUserMemoryRegion { uint64_t mmap_offset; } VhostUserMemoryRegion; =20 +#define VHOST_USER_MEM_REG_SIZE (sizeof(VhostUserMemoryRegion)) + typedef struct VhostUserMemory { uint32_t nregions; uint32_t padding; diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 787f4d2d4f..b09b1c269e 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -801,6 +801,21 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { VuDevRegion shadow_regions[VHOST_USER_MAX_RAM_SLOTS] =3D {}; VhostUserMemoryRegion m =3D vmsg->payload.memreg.region, *msg_region = =3D &m; =20 + if (vmsg->fd_num !=3D 1) { + vmsg_close_fds(vmsg); + vu_panic(dev, "VHOST_USER_REM_MEM_REG received %d fds - only 1 fd " + "should be sent for this message type", vmsg->fd_num= ); + return false; + } + + if (vmsg->size < VHOST_USER_MEM_REG_SIZE) { + close(vmsg->fds[0]); + vu_panic(dev, "VHOST_USER_REM_MEM_REG requires a message size of a= t " + "least %d bytes and only %d bytes were received", + VHOST_USER_MEM_REG_SIZE, vmsg->size); + return false; + } + DPRINT("Removing region:\n"); DPRINT(" guest_phys_addr: 0x%016"PRIx64"\n", msg_region->guest_phys_addr); --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027190433597.4911253114586; Fri, 4 Feb 2022 18:13:10 -0800 (PST) Received: from localhost ([::1]:35122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAZZ-00054D-3g for importer@patchew.org; Fri, 04 Feb 2022 21:13:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sX-IW for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003JQ-AW for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:31 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-gitiwhS3NXCfhjg6-KAYDw-1; Fri, 04 Feb 2022 20:43:02 -0500 Received: by mail-wr1-f71.google.com with SMTP id g16-20020adfa490000000b001e30139d1fbso355439wrb.6 for ; Fri, 04 Feb 2022 17:43:02 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id g9sm3473705wri.95.2022.02.04.17.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025383; 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: in-reply-to:in-reply-to:references:references; bh=PBmM0KuFSdatxXqXavJnWM1XP+AlL96uwaW9+q+ldEs=; b=eWCzLmyezJBsq/pB8KpZLFtQZ2rpdfodIOLKILQUjcLhLZbJ6sXcL9BAWz4ryU2omlUBJI F/fB7PXmvM846EFFJ8LuqFXfyDItRBn9ZBZK6B9Gm0sxvxPn0rn44dTpKhIyTpCCbdV9hs 7wUdyGvU0dOSBw/1S+fH/B48hgk0dR4= X-MC-Unique: gitiwhS3NXCfhjg6-KAYDw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PBmM0KuFSdatxXqXavJnWM1XP+AlL96uwaW9+q+ldEs=; b=wz3S7gkmEUWwo7omPGyVQOE7FcY+zgVip4csOf8Z000mhLNwzg9ldcQoScFitqKJV6 9XcXFBZJ6QI77dUj4i3KumKpiA+0untta2HP1Tm9md/kIs4/0moezsYCu2Hk3WAfAjsH excYhuvuIyXOVvs9E9eVkiC7nlKQ2XwjXSz3l2h3Gp31iuBx6iTJ1HP39pc2CXe247AY 5alKVLUjtYhG3IYSs58KU0FiAoZRYVGNI/Sh6YMcOLPZ1JxtyVrXG0VzKScTvDG61BpF Pn985eBHl47vBQsJp66qx5N1g5R2FegtfL+2p9QW8jChdhqQuK3C0jJgN7VNbZ2R4V9j SJpA== X-Gm-Message-State: AOAM533hAugEWFkJUZq+Uleo/PNPogRC9qsnWjBRQzYu0YacOhURb8my gd/TG+J4LdBDmyemC9adijDhqcBP3smS5AUz3WaYDTt0dh8dh7yQilNe0TPxCy2gtA5Rg9HjEyf MCpYez2kKxFCs2iDqFhuxCQJ5grIETadb8aPwZQBAQSDrnQwbBSbXlaWFjg/A X-Received: by 2002:a5d:6807:: with SMTP id w7mr1213064wru.534.1644025381386; Fri, 04 Feb 2022 17:43:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJycHBpT6Rz612efekjRPA6xOVli0xsFrAZ2IwximNOu6edrm/+H+Zb48U4Lrl4V/r51GOTD5Q== X-Received: by 2002:a5d:6807:: with SMTP id w7mr1213046wru.534.1644025381129; Fri, 04 Feb 2022 17:43:01 -0800 (PST) Date: Fri, 4 Feb 2022 20:42:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/32] libvhost-user: Add vu_add_mem_reg input validation Message-ID: <20220205014149.1189026-10-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , David Hildenbrand , Stefan Hajnoczi , Paolo Bonzini , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027191356100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz Today if multiple FDs are sent from the VMM to the backend in a VHOST_USER_ADD_MEM_REG message, one FD will be mapped and the remaining FDs will be leaked. Therefore if multiple FDs are sent we report an error and fail the operation, closing all FDs in the message. Likewise in case the VMM sends a message with a size less than that of a memory region descriptor, we add a check to gracefully report an error and fail the operation rather than crashing. Signed-off-by: Raphael Norwitz Message-Id: <20220117041050.19718-3-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand --- subprojects/libvhost-user/libvhost-user.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index b09b1c269e..1a8fc9d600 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -690,6 +690,21 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { VuDevRegion *dev_region =3D &dev->regions[dev->nregions]; void *mmap_addr; =20 + if (vmsg->fd_num !=3D 1) { + vmsg_close_fds(vmsg); + vu_panic(dev, "VHOST_USER_ADD_MEM_REG received %d fds - only 1 fd " + "should be sent for this message type", vmsg->fd_num= ); + return false; + } + + if (vmsg->size < VHOST_USER_MEM_REG_SIZE) { + close(vmsg->fds[0]); + vu_panic(dev, "VHOST_USER_ADD_MEM_REG requires a message size of a= t " + "least %d bytes and only %d bytes were received", + VHOST_USER_MEM_REG_SIZE, vmsg->size); + return false; + } + /* * If we are in postcopy mode and we receive a u64 payload with a 0 va= lue * we know all the postcopy client bases have been received, and we --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027461222707.5961122006291; Fri, 4 Feb 2022 18:17:41 -0800 (PST) Received: from localhost ([::1]:44474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAdw-00031B-6I for importer@patchew.org; Fri, 04 Feb 2022 21:17:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sP-Iu for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003JV-Ap for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:31 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631--Bg2VqJENT6s9hpRLtbVcg-1; Fri, 04 Feb 2022 20:43:07 -0500 Received: by mail-wr1-f71.google.com with SMTP id s25-20020adfa299000000b001d8d032255fso2770158wra.14 for ; Fri, 04 Feb 2022 17:43:06 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id v5sm3974909wrx.114.2022.02.04.17.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025387; 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: in-reply-to:in-reply-to:references:references; bh=MGPknzL0C8w670Ju8z58GoLCBmhEaNx8SyVY6OxEVhw=; b=fKtrpHfFvgt3dMsol8AdmJnHnM/ySZGM+ee9hbLBfhktFVp8nsFVBp8d5LL2VrwWas00l7 pgw1YlYo6jieX1rQ7MrjYWcgTC4OAb9Oywdo47ujT86btHiqL48mOLZUAPsvwpAcO4o/9d q4GnjPWgq0wOYqk2SEqgYIlYn3vTn4Q= X-MC-Unique: -Bg2VqJENT6s9hpRLtbVcg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MGPknzL0C8w670Ju8z58GoLCBmhEaNx8SyVY6OxEVhw=; b=vqtitpRQjYCOYXW28syVv385lba+w1wS4CTUqI6ip3aq9IXcuWY/6TxVV0HwZMW3rG roQZXy87FxKces2Sh+Nou1ppHn/qOBbKelE+d1d8yN7MeBJ4ogvXNcnasgWnIc1dT6Me vEJnKP0qUorVba6Auai2JawyBkiCUSEI+5VRDOQ/t8Ayy617L3d6Fqu0CMHwQt9jaTTt wI1qFTXUOzRs58XVVXyWwXvauivPsBIijerRMH0A1fJiR2frDmsnzil/IlC2Wz7yWhAs DSRS+mkNSDS7coDT/yFVXgUwOdZWkRj6iocQgad2dVRzoUW6gY/6EpDI4qIeZApACQdz cnsw== X-Gm-Message-State: AOAM5338ReWjsCqSxBDhKF1XY2MC5ZORFvOiRfEMKP4jaGrZwQ6oQFsR o5K6QECMPoggfm7fvfzs32aoDWqzLtQ4KEDleQVypNfH9OW+CJDLcRCAsZcmDxtdbQC2yd9Ll3Y YxQz++1RWQuKtyjJvRVNgNNkQ/YrYvuMl2bXWeOo+5pAQlsrmI/6G1wU2BNMC X-Received: by 2002:adf:f7d2:: with SMTP id a18mr1252031wrq.685.1644025385410; Fri, 04 Feb 2022 17:43:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwGvfTiwErsbgaRe3zqgqTtpMcwa94u5vY+LvSfeUowogalK9Yua33I45obgANer4OVislbQ== X-Received: by 2002:adf:f7d2:: with SMTP id a18mr1252009wrq.685.1644025385101; Fri, 04 Feb 2022 17:43:05 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/32] libvhost-user: Simplify VHOST_USER_REM_MEM_REG Message-ID: <20220205014149.1189026-11-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , Raphael Norwitz , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Stefan Hajnoczi , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027462722100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Let's avoid having to manually copy all elements. Copy only the ones necessary to close the hole and perform the operation in-place without a second array. Reviewed-by: Stefan Hajnoczi Signed-off-by: David Hildenbrand Signed-off-by: Raphael Norwitz Message-Id: <20220117041050.19718-4-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 30 +++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 1a8fc9d600..7dd8e918b4 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -811,10 +811,8 @@ static inline bool reg_equal(VuDevRegion *vudev_reg, =20 static bool vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { - int i, j; - bool found =3D false; - VuDevRegion shadow_regions[VHOST_USER_MAX_RAM_SLOTS] =3D {}; VhostUserMemoryRegion m =3D vmsg->payload.memreg.region, *msg_region = =3D &m; + int i; =20 if (vmsg->fd_num !=3D 1) { vmsg_close_fds(vmsg); @@ -841,28 +839,28 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { DPRINT(" mmap_offset 0x%016"PRIx64"\n", msg_region->mmap_offset); =20 - for (i =3D 0, j =3D 0; i < dev->nregions; i++) { - if (!reg_equal(&dev->regions[i], msg_region)) { - shadow_regions[j].gpa =3D dev->regions[i].gpa; - shadow_regions[j].size =3D dev->regions[i].size; - shadow_regions[j].qva =3D dev->regions[i].qva; - shadow_regions[j].mmap_addr =3D dev->regions[i].mmap_addr; - shadow_regions[j].mmap_offset =3D dev->regions[i].mmap_offset; - j++; - } else { - found =3D true; + for (i =3D 0; i < dev->nregions; i++) { + if (reg_equal(&dev->regions[i], msg_region)) { VuDevRegion *r =3D &dev->regions[i]; void *m =3D (void *) (uintptr_t) r->mmap_addr; =20 if (m) { munmap(m, r->size + r->mmap_offset); } + + break; } } =20 - if (found) { - memcpy(dev->regions, shadow_regions, - sizeof(VuDevRegion) * VHOST_USER_MAX_RAM_SLOTS); + if (i < dev->nregions) { + /* + * Shift all affected entries by 1 to close the hole at index i and + * zero out the last entry. + */ + memmove(dev->regions + i, dev->regions + i + 1, + sizeof(VuDevRegion) * (dev->nregions - i - 1)); + memset(dev->regions + dev->nregions - 1, 0, + sizeof(VuDevRegion)); DPRINT("Successfully removed a region\n"); dev->nregions--; vmsg_set_reply_u64(vmsg, 0); --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026313404904.8014366163329; Fri, 4 Feb 2022 17:58:33 -0800 (PST) Received: from localhost ([::1]:35116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGALQ-0002Vv-6E for importer@patchew.org; Fri, 04 Feb 2022 20:58:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sU-IE for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003JZ-CV for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:31 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-519-x9nzJLXiNhqPFWqR_FLteA-1; Fri, 04 Feb 2022 20:43:10 -0500 Received: by mail-wr1-f71.google.com with SMTP id q4-20020adfbb84000000b001dd3cfddb2dso2803872wrg.11 for ; Fri, 04 Feb 2022 17:43:10 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id bg23sm3307317wmb.5.2022.02.04.17.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025391; 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: in-reply-to:in-reply-to:references:references; bh=Eumjoy2b3JuV2CT6O4JwajdWx+yglD5Kzegw38RNJ0M=; b=b74TXLrXfK4Zs/Vi8/SMV7CksbpmSUEL8hzyTNnzzOAgmCTaz9gTaIKgyIiEFQA7oqVUmZ BIGKOwMrBJGfbBAxrHnReeIgFicRDwuCEoAz46XbkTq1NjFdewV5vmzjtiMbA9rTj0bCnN f4QNFMG/yyJcAVF5wtEFRNO5Ofqcpww= X-MC-Unique: x9nzJLXiNhqPFWqR_FLteA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Eumjoy2b3JuV2CT6O4JwajdWx+yglD5Kzegw38RNJ0M=; b=7w75A9e551FZ7EE2PvdqboEWJI1eCMgWafnj+y+YoqDL+LBGsLP3Zu0hprYhjoABeP oxa2Glty9u0eyi0023DnaeFRR26wMSSfiYyomznQVAmr2Ib1rtMr8PS+dsDZW2gLlbtE 9hP1LURQYkdwMo8b9SNf5JmUKJKL2g3f45k7g/g0cyKFe/Vh02vOVwHLEIlz8FgX6x8M 0SiINDM2Zrfcp2DtlOPLlMdgAiubmukpNxev6afbMjcWMRHScbicadY9eCIP1UrgP4oS 4CHqetPXuBCp15FWxYKFM0qbNTLtEOZQSE7Qb7YqbfqH8y9UzLqt6hfWn6ATNAcPMoOC sjUQ== X-Gm-Message-State: AOAM530p04qRywy0eg2/I91lEQusKdvGxeiM4SltSvS1zcVg0fAZh2av xaHAQiHExAl9Xto8rPCpA69aS3ZWq4feZN5wv+km8+FipIFg97Fg81JNHmZaVze8QK4uVSwoX10 lPD/NeWmU2gh3JYpFQOb56Wo9jwS5AI5eRcMQG/5kg1orpGVSOXJwgj0Paq9t X-Received: by 2002:a05:6000:85:: with SMTP id m5mr1232771wrx.99.1644025388945; Fri, 04 Feb 2022 17:43:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGbaU4UhrYD6whkHRGVkUdkmilg8eJvQzyY20xB1EcB/3quOSh6tCkLvfPKTXcuxWGGUkxNg== X-Received: by 2002:a05:6000:85:: with SMTP id m5mr1232750wrx.99.1644025388652; Fri, 04 Feb 2022 17:43:08 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/32] libvhost-user: fix VHOST_USER_REM_MEM_REG not closing the fd Message-ID: <20220205014149.1189026-12-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , David Hildenbrand , Coiby Xu , Raphael Norwitz , Stefan Hajnoczi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026313809100001 From: David Hildenbrand We end up not closing the file descriptor, resulting in leaking one file descriptor for each VHOST_USER_REM_MEM_REG message. Fixes: 875b9fd97b34 ("Support individual region unmap in libvhost-user") Cc: Michael S. Tsirkin Cc: Raphael Norwitz Cc: "Marc-Andr=C3=A9 Lureau" Cc: Stefan Hajnoczi Cc: Paolo Bonzini Cc: Coiby Xu Signed-off-by: David Hildenbrand Signed-off-by: Raphael Norwitz Message-Id: <20220117041050.19718-5-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 7dd8e918b4..3f4d7221ca 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -868,6 +868,8 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { vu_panic(dev, "Specified region not found\n"); } =20 + close(vmsg->fds[0]); + return true; } =20 --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026526319632.4452789779011; Fri, 4 Feb 2022 18:02:06 -0800 (PST) Received: from localhost ([::1]:43646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAOr-0008DH-MM for importer@patchew.org; Fri, 04 Feb 2022 21:02:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sO-Hv for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003Je-Dq for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:32 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-440-afTDoptLOBGhpMONJeuDlg-1; Fri, 04 Feb 2022 20:43:12 -0500 Received: by mail-wm1-f69.google.com with SMTP id bg16-20020a05600c3c9000b0034bea12c043so8374457wmb.7 for ; Fri, 04 Feb 2022 17:43:12 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id s9sm3434950wrr.84.2022.02.04.17.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025393; 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: in-reply-to:in-reply-to:references:references; bh=y7OKSfT1V8bnQJ29ZyLRYs/eX2kJnKtsDQ8zfEcJa6g=; b=LSYSfxA9Oeb0D+6yB478TZUbYMfMPUSUcxw8uO0bDrxlB44KqJZUEW7o4hartMSfsGbTWj /kPBBSu0hwVQBWEGvyZv0lisHpbGd66MdCnMCWgra3Pwjy8AuxX9ZrcyOfRAv3aj3v4f/P 8ShQwvXZA27e6Kcz3lx1cC9Y4TnuRxQ= X-MC-Unique: afTDoptLOBGhpMONJeuDlg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=y7OKSfT1V8bnQJ29ZyLRYs/eX2kJnKtsDQ8zfEcJa6g=; b=t/RKnVdumuujmKuNxUcI4OrHO6/1Ci8NOAe3mAK1ZIsLuh12FOcf/ETBQA2VnmAj75 VdyFoeFheJX+xhJYwOGQcZT6UXLjgYd1Y9If5apLquyxTb0+UPcj7O6Dv6tAYjzWyRhT g+CwL8XF7CSR5w3mwD4OwRXTpXIQs4dgLlYxXjtFTx+EpgPopwqcOewM1zzkcFx1eX4z 0UgiBzLGpvYnSxQUqbPpVhhYyooaNo6wmW1NGkcrY7x4aX5JHvE/vG0zWhxe9atUjfSO aHTG54nAXcLiamlwZdkICOnvGkfdZKCKds9K1tdSuOwKXLGrWcuPlDhoF4Ge41UIEUek RPzQ== X-Gm-Message-State: AOAM531Z35jGLvQcn739qVHyCjZ8ah5g7k8NgncRNXlAmrUzIHXbrZkB Ha02h0Ck70Zf22G6OtQgEekV1Uyd+toXDDrLUv+NUBsDnNC/wzsdEIb3Wh7pREloAko13miXOYu Oi1jTI9al1vhcF94gh1Pfnt+jDo4cPXcXtzGe0xGT1crxbW7oDUwdzbuPVrj0 X-Received: by 2002:adf:ffd2:: with SMTP id x18mr845139wrs.188.1644025391268; Fri, 04 Feb 2022 17:43:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXCMw68XsTYlErT6xky3tEjtXr06J7YkNs4E4dSYOYs5VtAsfoG2Zz88uiv7Kts4EVhqMMNg== X-Received: by 2002:adf:ffd2:: with SMTP id x18mr845122wrs.188.1644025391077; Fri, 04 Feb 2022 17:43:11 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/32] libvhost-user: prevent over-running max RAM slots Message-ID: <20220205014149.1189026-13-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , David Hildenbrand , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Raphael Norwitz , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026529080100001 From: Raphael Norwitz When VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS support was added to libvhost-user, no guardrails were added to protect against QEMU attempting to hot-add too many RAM slots to a VM with a libvhost-user based backed attached. This change adds the missing error handling by introducing a check on the number of RAM slots the device has available before proceeding to process the VHOST_USER_ADD_MEM_REG message. Suggested-by: Stefan Hajnoczi Signed-off-by: Raphael Norwitz Message-Id: <20220117041050.19718-6-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- subprojects/libvhost-user/libvhost-user.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 3f4d7221ca..2a1fa00a44 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -705,6 +705,14 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { return false; } =20 + if (dev->nregions =3D=3D VHOST_USER_MAX_RAM_SLOTS) { + close(vmsg->fds[0]); + vu_panic(dev, "failing attempt to hot add memory via " + "VHOST_USER_ADD_MEM_REG message because the backend = has " + "no free ram slots available"); + return false; + } + /* * If we are in postcopy mode and we receive a u64 payload with a 0 va= lue * we know all the postcopy client bases have been received, and we --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026900860922.0317381810986; Fri, 4 Feb 2022 18:08:20 -0800 (PST) Received: from localhost ([::1]:52158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAUt-0005l4-Jn for importer@patchew.org; Fri, 04 Feb 2022 21:08:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sk-LB for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43803) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003Jl-Ax for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:31 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-26-TxkhwJkvMNupIPGiEB_imw-1; Fri, 04 Feb 2022 20:43:15 -0500 Received: by mail-wm1-f72.google.com with SMTP id l20-20020a05600c1d1400b0035153bf34c3so8394618wms.2 for ; Fri, 04 Feb 2022 17:43:14 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id s9sm3434999wrr.84.2022.02.04.17.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025396; 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: in-reply-to:in-reply-to:references:references; bh=WK+YLETmqJAgpCmbHz21EJfyUutFVg3g9CSFBrfdweQ=; b=DDazkILq9damvnAWuDJAbDZZN5Ctgy33m/JPEy6AouIQUBnoTXu/jusTrwzYZO3wTK0Q4U dm7G8dIirvI6FL+avsqfaPYSJPRWDN/0msiHj4xHmN3rtXruQHiLcHN3CUTFWI5xt1OHNe e33U3hAhSmrkpQqbvxa677xbHPKLLoQ= X-MC-Unique: TxkhwJkvMNupIPGiEB_imw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WK+YLETmqJAgpCmbHz21EJfyUutFVg3g9CSFBrfdweQ=; b=7dW3PfbPq3Lx/XsyAD1brOrXQWju/yB3drZnG1XlLfDIZ2YbNYPRdJUE3OWPLhYtk9 AUmO9yemmGESRYmhj6rhfMAddGzQJjnY4vx/lrPR/VqdivCaJR18LcMoEoF80Kp5nukN 0lZx5mZOkYvbBDCjsVSK3ePMO3vr158mlSH4wC9b4+NHCYKNRk1KR77xVlFl79vFoVGH PCGKSlm3r5OSb/Dq2LYINo6MBi6ZxfPsY6dxdj+QrtjOyS2vn7XIMlBz83lzQHW9AKyS HKJ+9s1NphPkEcQbFmHLfTElpur0HNHu0WJmfbFcEwjq6g+L88xyy70N6dRdV39sCVCW KDgw== X-Gm-Message-State: AOAM532iRCURcpthW/rLikUm1yz41VNOUFP2lFThNPS6N6Opz3y2bzlK pd+z4sxX7P4iQ7+1BtlJkrS7xQDvj/BIOfF6DbW5rtepdnHjLFK+eujl8joKxFZtMsezd/zBMU+ pdyidVrXblPUYuZjG4iZgr7xIvksVOUUFHG5fOjopo0wDo2ADmHPViR0fliR3 X-Received: by 2002:a1c:4d0a:: with SMTP id o10mr1180969wmh.57.1644025393448; Fri, 04 Feb 2022 17:43:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwl7AWyVcRT4XYlLtG5ApbboGAg1n6Qso/pAXgpM19cCB+9t/4lvH/PBTmHR2wGvWZqqYjQ5w== X-Received: by 2002:a1c:4d0a:: with SMTP id o10mr1180954wmh.57.1644025393208; Fri, 04 Feb 2022 17:43:13 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/32] libvhost-user: handle removal of identical regions Message-ID: <20220205014149.1189026-14-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , David Hildenbrand , Paolo Bonzini , Stefan Hajnoczi , Raphael Norwitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026903001100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Raphael Norwitz Today if QEMU (or any other VMM) has sent multiple copies of the same region to a libvhost-user based backend and then attempts to remove the region, only one instance of the region will be removed, leaving stale copies of the region in dev->regions[]. This change resolves this by having vu_rem_mem_reg() iterate through all regions in dev->regions[] and delete all matching regions. Suggested-by: Stefan Hajnoczi Signed-off-by: Raphael Norwitz Message-Id: <20220117041050.19718-7-raphael.norwitz@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand --- subprojects/libvhost-user/libvhost-user.c | 28 +++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 2a1fa00a44..0ee43b8e93 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -821,6 +821,7 @@ static bool vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { VhostUserMemoryRegion m =3D vmsg->payload.memreg.region, *msg_region = =3D &m; int i; + bool found =3D false; =20 if (vmsg->fd_num !=3D 1) { vmsg_close_fds(vmsg); @@ -856,21 +857,24 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { munmap(m, r->size + r->mmap_offset); } =20 - break; + /* + * Shift all affected entries by 1 to close the hole at index = i and + * zero out the last entry. + */ + memmove(dev->regions + i, dev->regions + i + 1, + sizeof(VuDevRegion) * (dev->nregions - i - 1)); + memset(dev->regions + dev->nregions - 1, 0, sizeof(VuDevRegion= )); + DPRINT("Successfully removed a region\n"); + dev->nregions--; + i--; + + found =3D true; + + /* Continue the search for eventual duplicates. */ } } =20 - if (i < dev->nregions) { - /* - * Shift all affected entries by 1 to close the hole at index i and - * zero out the last entry. - */ - memmove(dev->regions + i, dev->regions + i + 1, - sizeof(VuDevRegion) * (dev->nregions - i - 1)); - memset(dev->regions + dev->nregions - 1, 0, - sizeof(VuDevRegion)); - DPRINT("Successfully removed a region\n"); - dev->nregions--; + if (found) { vmsg_set_reply_u64(vmsg, 0); } else { vu_panic(dev, "Specified region not found\n"); --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026058704182.97886019033535; Fri, 4 Feb 2022 17:54:18 -0800 (PST) Received: from localhost ([::1]:54064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAHJ-0004bW-La for importer@patchew.org; Fri, 04 Feb 2022 20:54:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003sJ-Fr for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003Kw-Cw for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:32 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-110-HEmMarzWPlWgnvgkoC8YuA-1; Fri, 04 Feb 2022 20:43:17 -0500 Received: by mail-wr1-f69.google.com with SMTP id v28-20020adfa1dc000000b001dd1cb24081so2783970wrv.10 for ; Fri, 04 Feb 2022 17:43:17 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id u8sm2123399wmn.27.2022.02.04.17.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025398; 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: in-reply-to:in-reply-to:references:references; bh=M3jUSaSk62Y68RwsubSnE/d3+Hfgk3zd4sX5M9Po2zk=; b=C1kWpoJmqEbSSyernkBBgwjHQICcJitloWhoJukABaUkq+GuACJgFaPd9qOEjtNyQcEUNO o7em1YFWKYNQJGQFtCtuaHiI0KttDvo77AmSATfHAVn4JXrkxZwplKCH4qfWJ6X5eVqVAc m6zdxH4SWGQyMGqasW/lTQZXGP8BSDQ= X-MC-Unique: HEmMarzWPlWgnvgkoC8YuA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=M3jUSaSk62Y68RwsubSnE/d3+Hfgk3zd4sX5M9Po2zk=; b=ePOaWu4RB41tzotmWZuMSL+0nfA0zu3L0kyAtLddNBa3iX06ah2TabwsJU72PtpTbS YMllcxvpI4hvMaC/CGidE0OD50yAt1bba1lNBk3ehYkCIQxU+8mG4TuwoFFY8GtmLSbY Oalzdj1xPsbuw2F2hQ1liD5l0yuimcb3uIszpbgcGtecvrBZRu8F4DsWFPXq239wrujQ To0ELk1OAeQaXZJaUNDeGgdlwKkhfHN4rF1FTTBL9CRgXVzRD+p/4EGtsWUOv1EPN2Pa uDm/3IiNAvHl1isEBcUGqdvvAluRrqKxWGfZx7ix30SXnzSGsNsqwSn/jBiYZPFWTOax VtBw== X-Gm-Message-State: AOAM532j6YDzeclyDBdI82NfGZSEcEMT/fiGiUKRi4JUUITO+Tprb783 Fb0MgrTRs6XchDBV1rN132Ee4XBMVNmIkMGlH4b8aFH29ZJugdVkKeEQZBnO1oqhv9fcI5/Ec3v 4zhfh0KCBWFKd9lHYqsGRlvYmAT+HLE14t2TILb4ReFCizMudTgtaZbp3jqIy X-Received: by 2002:a05:6000:16cc:: with SMTP id h12mr1226653wrf.408.1644025396017; Fri, 04 Feb 2022 17:43:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRjXw+cHQajUHu6roEQH1s4A9nZuIm5Kp2acLg/I7I0HeNM4y0eKBW5uOx7o/AkKwN6fdkBg== X-Received: by 2002:a05:6000:16cc:: with SMTP id h12mr1226631wrf.408.1644025395781; Fri, 04 Feb 2022 17:43:15 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/32] libvhost-user: Map shared RAM with MAP_NORESERVE to support virtio-mem with hugetlb Message-ID: <20220205014149.1189026-15-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , David Hildenbrand , "Dr . David Alan Gilbert" , Raphael Norwitz , Stefan Hajnoczi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026060757100001 From: David Hildenbrand For fd-based shared memory, MAP_NORESERVE is only effective for hugetlb, otherwise it's ignored. Older Linux versions that didn't support reservation of huge pages ignored MAP_NORESERVE completely. The first client to mmap a hugetlb fd without MAP_NORESERVE will trigger reservation of huge pages for the whole mmapped range. There are two cases to consider: 1) QEMU mapped RAM without MAP_NORESERVE We're not dealing with a sparse mapping, huge pages for the whole range have already been reserved by QEMU. An additional mmap() without MAP_NORESERVE won't have any effect on the reservation. 2) QEMU mapped RAM with MAP_NORESERVE We're delaing with a sparse mapping, no huge pages should be reserved. Further mappings without MAP_NORESERVE should be avoided. For 1), it doesn't matter if we set MAP_NORESERVE or not, so we can simply set it. For 2), we'd be overriding QEMUs decision and trigger reservation of huge pages, which might just fail if there are not sufficient huge pages around. We must map with MAP_NORESERVE. This change is required to support virtio-mem with hugetlb: a virtio-mem device mapped into the guest physical memory corresponds to a sparse memory mapping and QEMU maps this memory with MAP_NORESERVE. Whenever memory in that sparse region will be accessed by the VM, QEMU populates huge pages for the affected range by preallocating memory and handling any preallocation errors gracefully. So let's map shared RAM with MAP_NORESERVE. As libvhost-user only supports Linux, there shouldn't be anything to take care of in regard of other OS support. Without this change, libvhost-user will fail mapping the region if there are currently not enough huge pages to perform the reservation: fv_panic: libvhost-user: region mmap error: Cannot allocate memory Cc: "Marc-Andr=C3=A9 Lureau" Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Raphael Norwitz Cc: Stefan Hajnoczi Cc: Dr. David Alan Gilbert Signed-off-by: David Hildenbrand Message-Id: <20220111123939.132659-1-david@redhat.com> Acked-by: Raphael Norwitz --- subprojects/libvhost-user/libvhost-user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 0ee43b8e93..47d2efc60f 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -751,12 +751,12 @@ vu_add_mem_reg(VuDev *dev, VhostUserMsg *vmsg) { * accessing it before we userfault. */ mmap_addr =3D mmap(0, dev_region->size + dev_region->mmap_offset, - PROT_NONE, MAP_SHARED, + PROT_NONE, MAP_SHARED | MAP_NORESERVE, vmsg->fds[0], 0); } else { mmap_addr =3D mmap(0, dev_region->size + dev_region->mmap_offset, - PROT_READ | PROT_WRITE, MAP_SHARED, vmsg->fds[0], - 0); + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERV= E, + vmsg->fds[0], 0); } =20 if (mmap_addr =3D=3D MAP_FAILED) { @@ -920,7 +920,7 @@ vu_set_mem_table_exec_postcopy(VuDev *dev, VhostUserMsg= *vmsg) * accessing it before we userfault */ mmap_addr =3D mmap(0, dev_region->size + dev_region->mmap_offset, - PROT_NONE, MAP_SHARED, + PROT_NONE, MAP_SHARED | MAP_NORESERVE, vmsg->fds[i], 0); =20 if (mmap_addr =3D=3D MAP_FAILED) { @@ -1007,7 +1007,7 @@ vu_set_mem_table_exec(VuDev *dev, VhostUserMsg *vmsg) * mapped address has to be page aligned, and we use huge * pages. */ mmap_addr =3D mmap(0, dev_region->size + dev_region->mmap_offset, - PROT_READ | PROT_WRITE, MAP_SHARED, + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERV= E, vmsg->fds[i], 0); =20 if (mmap_addr =3D=3D MAP_FAILED) { --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026932677860.3353412113379; Fri, 4 Feb 2022 18:08:52 -0800 (PST) Received: from localhost ([::1]:54686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAVP-0007Yv-BR for importer@patchew.org; Fri, 04 Feb 2022 21:08:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003s8-Ce for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26114) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA6q-0003L5-D3 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:34 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-266-6Dwy7NrDOuyP0kKPxfs_2A-1; Fri, 04 Feb 2022 20:43:21 -0500 Received: by mail-wm1-f70.google.com with SMTP id l5-20020a05600c088500b0037b98300c70so1361889wmp.5 for ; Fri, 04 Feb 2022 17:43:20 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id u8sm2123447wmn.27.2022.02.04.17.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025402; 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: in-reply-to:in-reply-to:references:references; bh=5uauAD0k1H/g/Pkw/+MfLL5RAw4TmAyPKLHODnkW6Sg=; b=d/0mNhSt8XdS8OcFKd3Ropnt2SzNt9vvwJ9nw+xliPRH7nkLnj3Ugmvcqplf05BWEbZdJh 1IKu1fxa4cKbx93gO6W+8K8FJD/nfwoA9QAEjomTfdMiijwlNbLXzyjZZQppyErOrttBiD TYZvut814VE78gRkp0TAffECH8ndQBQ= X-MC-Unique: 6Dwy7NrDOuyP0kKPxfs_2A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5uauAD0k1H/g/Pkw/+MfLL5RAw4TmAyPKLHODnkW6Sg=; b=Fjg4w14qo79t4B8heY7RhdTE71EuOseuD/fu4lhltnqabL0X83IkXeRF2vciN+NgwF TQsuGDIXu7nlGP6WJKmomEe6Cqfd94/bNC46t2rFFjnwmx889s38UOaffYQZJge8ZN98 H7J9EN82AJyN3qADfdNvVSnEqVJwCb9i5qOh6Gbq8OYJEIC6k3YJLQflFERrnn4FmFRW spN9sPS6CEL2KNLjuUn8LogVh8VhCvCPNYvS/UdiN9JBScjIBG8ygOIIOMlCwr6QSIry AEGfI4pzo7S18FiqGyDZOSZ2ZRKu2kZT8SHx+NFUB/9QFHFlLxkwBMuF+5+aD35kP2jg wf1g== X-Gm-Message-State: AOAM531yRVyj4s2xrrGqAfXDBZlblCuNdY4oI9Fa2PLh6+MQ9iu8iRl3 hj1625Y+5P/D7V4ze/8xboMq2Qb/wh6bif/oeWV9Lhvt0eNrwmOqY/HvlJCrRV0bRB7IQUNeo38 cG4xmm3+Dygj9IkQHIiPr7XLUzJb7TuhZN6PwEcwtVFAIgapuaaQnaygdo914 X-Received: by 2002:a05:6000:156d:: with SMTP id 13mr1232006wrz.34.1644025399508; Fri, 04 Feb 2022 17:43:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7FNhKfIkWy41BsFe/6SHVLuypSQJ2lNGUe/2Pr3+BdDsvQXl78F5nZUDsybyNAXYwNW054g== X-Received: by 2002:a05:6000:156d:: with SMTP id 13mr1231968wrz.34.1644025399130; Fri, 04 Feb 2022 17:43:19 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/32] virtio: drop name parameter for virtio_init() Message-ID: <20220205014149.1189026-16-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Fam Zheng , Peter Maydell , David Hildenbrand , Jason Wang , Christian Schoenebeck , Gerd Hoffmann , qemu-block@nongnu.org, "Gonglei \(Arei\)" , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Jonah Palmer , Laurent Vivier , Amit Shah , Greg Kurz , "Dr. David Alan Gilbert" , Eric Auger , Stefan Hajnoczi , Kevin Wolf , Mathieu Poirier , Raphael Norwitz , virtio-fs@redhat.com, Hanna Reitz , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026933571100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonah Palmer This patch drops the name parameter for the virtio_init function. The pair between the numeric device ID and the string device ID (name) of a virtio device already exists, but not in a way that lets us map between them. This patch lets us do this and removes the need for the name parameter in the virtio_init function. [Jonah: added new virtio IDs to virtio device list from rebase]. Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-2-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-vsock-common.h | 2 +- include/hw/virtio/virtio-gpu.h | 3 +- include/hw/virtio/virtio.h | 4 +- hw/9pfs/virtio-9p-device.c | 2 +- hw/block/vhost-user-blk.c | 2 +- hw/block/virtio-blk.c | 2 +- hw/char/virtio-serial-bus.c | 3 +- hw/display/virtio-gpu-base.c | 2 +- hw/input/virtio-input.c | 3 +- hw/net/virtio-net.c | 2 +- hw/scsi/virtio-scsi.c | 3 +- hw/virtio/vhost-user-fs.c | 3 +- hw/virtio/vhost-user-i2c.c | 7 +--- hw/virtio/vhost-user-rng.c | 2 +- hw/virtio/vhost-user-vsock.c | 2 +- hw/virtio/vhost-vsock-common.c | 5 +-- hw/virtio/vhost-vsock.c | 2 +- hw/virtio/virtio-balloon.c | 3 +- hw/virtio/virtio-crypto.c | 2 +- hw/virtio/virtio-iommu.c | 3 +- hw/virtio/virtio-mem.c | 3 +- hw/virtio/virtio-pmem.c | 3 +- hw/virtio/virtio-rng.c | 2 +- hw/virtio/virtio.c | 55 ++++++++++++++++++++++++-- 24 files changed, 77 insertions(+), 43 deletions(-) diff --git a/include/hw/virtio/vhost-vsock-common.h b/include/hw/virtio/vho= st-vsock-common.h index d8b565b4da..076b7ab779 100644 --- a/include/hw/virtio/vhost-vsock-common.h +++ b/include/hw/virtio/vhost-vsock-common.h @@ -44,7 +44,7 @@ int vhost_vsock_common_start(VirtIODevice *vdev); void vhost_vsock_common_stop(VirtIODevice *vdev); int vhost_vsock_common_pre_save(void *opaque); int vhost_vsock_common_post_load(void *opaque, int version_id); -void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name); +void vhost_vsock_common_realize(VirtIODevice *vdev); void vhost_vsock_common_unrealize(VirtIODevice *vdev); uint64_t vhost_vsock_common_get_features(VirtIODevice *vdev, uint64_t feat= ures, Error **errp); diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2179b75703..afff9e158e 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -22,6 +22,7 @@ #include "sysemu/vhost-user-backend.h" =20 #include "standard-headers/linux/virtio_gpu.h" +#include "standard-headers/linux/virtio_ids.h" #include "qom/object.h" =20 #define TYPE_VIRTIO_GPU_BASE "virtio-gpu-base" @@ -37,8 +38,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL) #define TYPE_VHOST_USER_GPU "vhost-user-gpu" OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU) =20 -#define VIRTIO_ID_GPU 16 - struct virtio_gpu_simple_resource { uint32_t resource_id; uint32_t width; diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index f095637058..2a0be70ec6 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -165,8 +165,8 @@ struct VirtioDeviceClass { void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); =20 -void virtio_init(VirtIODevice *vdev, const char *name, - uint16_t device_id, size_t config_size); +void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_siz= e); + void virtio_cleanup(VirtIODevice *vdev); =20 void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2= , 3); diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 54ee93b71f..5f522e68e9 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -216,7 +216,7 @@ static void virtio_9p_device_realize(DeviceState *dev, = Error **errp) } =20 v->config_size =3D sizeof(struct virtio_9p_config) + strlen(s->fsconf.= tag); - virtio_init(vdev, "virtio-9p", VIRTIO_ID_9P, v->config_size); + virtio_init(vdev, VIRTIO_ID_9P, v->config_size); v->vq =3D virtio_add_queue(vdev, MAX_REQ, handle_9p_output); } =20 diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 1a42ae9187..e8cb170032 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -491,7 +491,7 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) return; } =20 - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, + virtio_init(vdev, VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); =20 s->virtqs =3D g_new(VirtQueue *, s->num_queues); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 82676cdd01..2e3809dafa 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1205,7 +1205,7 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) =20 virtio_blk_set_config_size(s, s->host_features); =20 - virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, s->config_size); + virtio_init(vdev, VIRTIO_ID_BLOCK, s->config_size); =20 s->blk =3D conf->conf.blk; s->rq =3D NULL; diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index f01ec2137c..9f19fd0672 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1044,8 +1044,7 @@ static void virtio_serial_device_realize(DeviceState = *dev, Error **errp) VIRTIO_CONSOLE_F_EMERG_WRITE)) { config_size =3D offsetof(struct virtio_console_config, emerg_wr); } - virtio_init(vdev, "virtio-serial", VIRTIO_ID_CONSOLE, - config_size); + virtio_init(vdev, VIRTIO_ID_CONSOLE, config_size); =20 /* Spawn a new virtio-serial bus on which the ports will ride as devic= es */ qbus_init(&vser->bus, sizeof(vser->bus), TYPE_VIRTIO_SERIAL_BUS, diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index fff0fb4a82..8ba5da4312 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -173,7 +173,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, } =20 g->virtio_config.num_scanouts =3D cpu_to_le32(g->conf.max_outputs); - virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, + virtio_init(VIRTIO_DEVICE(g), VIRTIO_ID_GPU, sizeof(struct virtio_gpu_config)); =20 if (virtio_gpu_virgl_enabled(g->conf)) { diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 54bcb46c74..5b5398b3ca 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -257,8 +257,7 @@ static void virtio_input_device_realize(DeviceState *de= v, Error **errp) vinput->cfg_size +=3D 8; assert(vinput->cfg_size <=3D sizeof(virtio_input_config)); =20 - virtio_init(vdev, "virtio-input", VIRTIO_ID_INPUT, - vinput->cfg_size); + virtio_init(vdev, VIRTIO_ID_INPUT, vinput->cfg_size); vinput->evt =3D virtio_add_queue(vdev, 64, virtio_input_handle_evt); vinput->sts =3D virtio_add_queue(vdev, 64, virtio_input_handle_sts); } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index cf8ab0f8af..25f494ca3b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3388,7 +3388,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) } =20 virtio_net_set_config_size(n, n->host_features); - virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size); + virtio_init(vdev, VIRTIO_ID_NET, n->config_size); =20 /* * We set a lower limit on RX queue size to what it always was. diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 34a968ecfb..2a6141d081 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -972,8 +972,7 @@ void virtio_scsi_common_realize(DeviceState *dev, VirtIOSCSICommon *s =3D VIRTIO_SCSI_COMMON(dev); int i; =20 - virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, - sizeof(VirtIOSCSIConfig)); + virtio_init(vdev, VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig)); =20 if (s->conf.num_queues =3D=3D VIRTIO_SCSI_AUTO_NUM_QUEUES) { s->conf.num_queues =3D 1; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index c595957983..b875640147 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -219,8 +219,7 @@ static void vuf_device_realize(DeviceState *dev, Error = **errp) return; } =20 - virtio_init(vdev, "vhost-user-fs", VIRTIO_ID_FS, - sizeof(struct virtio_fs_config)); + virtio_init(vdev, VIRTIO_ID_FS, sizeof(struct virtio_fs_config)); =20 /* Hiprio queue */ fs->hiprio_vq =3D virtio_add_queue(vdev, fs->conf.queue_size, vuf_hand= le_output); diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index d172632bb0..58fd7290ce 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -14,11 +14,6 @@ #include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" =20 -/* Remove this once the header is updated in Linux kernel */ -#ifndef VIRTIO_ID_I2C_ADAPTER -#define VIRTIO_ID_I2C_ADAPTER 34 -#endif - static void vu_i2c_start(VirtIODevice *vdev) { BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -220,7 +215,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Err= or **errp) return; } =20 - virtio_init(vdev, "vhost-user-i2c", VIRTIO_ID_I2C_ADAPTER, 0); + virtio_init(vdev, VIRTIO_ID_I2C_ADAPTER, 0); =20 i2c->vhost_dev.nvqs =3D 1; i2c->vq =3D virtio_add_queue(vdev, 4, vu_i2c_handle_output); diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 209ee5bf9a..08bccba9dc 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -203,7 +203,7 @@ static void vu_rng_device_realize(DeviceState *dev, Err= or **errp) return; } =20 - virtio_init(vdev, "vhost-user-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); =20 rng->req_vq =3D virtio_add_queue(vdev, 4, vu_rng_handle_output); if (!rng->req_vq) { diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 52bd682c34..0f8ff99f85 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -107,7 +107,7 @@ static void vuv_device_realize(DeviceState *dev, Error = **errp) return; } =20 - vhost_vsock_common_realize(vdev, "vhost-user-vsock"); + vhost_vsock_common_realize(vdev); =20 vhost_dev_set_config_notifier(&vvc->vhost_dev, &vsock_ops); =20 diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 3f3771274e..6146d258d3 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -220,12 +220,11 @@ int vhost_vsock_common_post_load(void *opaque, int ve= rsion_id) return 0; } =20 -void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name) +void vhost_vsock_common_realize(VirtIODevice *vdev) { VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); =20 - virtio_init(vdev, name, VIRTIO_ID_VSOCK, - sizeof(struct virtio_vsock_config)); + virtio_init(vdev, VIRTIO_ID_VSOCK, sizeof(struct virtio_vsock_config)); =20 /* Receive and transmit queues belong to vhost */ vvc->recv_vq =3D virtio_add_queue(vdev, VHOST_VSOCK_QUEUE_SIZE, diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 433d42d897..696635b1f7 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -166,7 +166,7 @@ static void vhost_vsock_device_realize(DeviceState *dev= , Error **errp) qemu_set_nonblock(vhostfd); } =20 - vhost_vsock_common_realize(vdev, "vhost-vsock"); + vhost_vsock_common_realize(vdev); =20 ret =3D vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, VHOST_BACKEND_TYPE_KERNEL, 0, errp); diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 9a4f491b54..236542fb53 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -888,8 +888,7 @@ static void virtio_balloon_device_realize(DeviceState *= dev, Error **errp) VirtIOBalloon *s =3D VIRTIO_BALLOON(dev); int ret; =20 - virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON, - virtio_balloon_config_size(s)); + virtio_init(vdev, VIRTIO_ID_BALLOON, virtio_balloon_config_size(s)); =20 ret =3D qemu_add_balloon_handler(virtio_balloon_to_target, virtio_balloon_stat, s); diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 54f9bbb789..cca5237afa 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -810,7 +810,7 @@ static void virtio_crypto_device_realize(DeviceState *d= ev, Error **errp) return; } =20 - virtio_init(vdev, "virtio-crypto", VIRTIO_ID_CRYPTO, vcrypto->config_s= ize); + virtio_init(vdev, VIRTIO_ID_CRYPTO, vcrypto->config_size); vcrypto->curr_queues =3D 1; vcrypto->vqs =3D g_malloc0(sizeof(VirtIOCryptoQueue) * vcrypto->max_qu= eues); for (i =3D 0; i < vcrypto->max_queues; i++) { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index aa9c16a17b..15b3fa05de 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -968,8 +968,7 @@ static void virtio_iommu_device_realize(DeviceState *de= v, Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOIOMMU *s =3D VIRTIO_IOMMU(dev); =20 - virtio_init(vdev, "virtio-iommu", VIRTIO_ID_IOMMU, - sizeof(struct virtio_iommu_config)); + virtio_init(vdev, VIRTIO_ID_IOMMU, sizeof(struct virtio_iommu_config)); =20 memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_nu= m)); =20 diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index f55dcf61f2..465a996214 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -868,8 +868,7 @@ static void virtio_mem_device_realize(DeviceState *dev,= Error **errp) vmem->block_size; vmem->bitmap =3D bitmap_new(vmem->bitmap_size); =20 - virtio_init(vdev, TYPE_VIRTIO_MEM, VIRTIO_ID_MEM, - sizeof(struct virtio_mem_config)); + virtio_init(vdev, VIRTIO_ID_MEM, sizeof(struct virtio_mem_config)); vmem->vq =3D virtio_add_queue(vdev, 128, virtio_mem_handle_request); =20 host_memory_backend_set_mapped(vmem->memdev, true); diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c index d1aeb90a31..8cbbd78c34 100644 --- a/hw/virtio/virtio-pmem.c +++ b/hw/virtio/virtio-pmem.c @@ -123,8 +123,7 @@ static void virtio_pmem_realize(DeviceState *dev, Error= **errp) } =20 host_memory_backend_set_mapped(pmem->memdev, true); - virtio_init(vdev, TYPE_VIRTIO_PMEM, VIRTIO_ID_PMEM, - sizeof(struct virtio_pmem_config)); + virtio_init(vdev, VIRTIO_ID_PMEM, sizeof(struct virtio_pmem_config)); pmem->rq_vq =3D virtio_add_queue(vdev, 128, virtio_pmem_flush); } =20 diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index cc8e9f775d..7e12fc03bf 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -215,7 +215,7 @@ static void virtio_rng_device_realize(DeviceState *dev,= Error **errp) return; } =20 - virtio_init(vdev, "virtio-rng", VIRTIO_ID_RNG, 0); + virtio_init(vdev, VIRTIO_ID_RNG, 0); =20 vrng->vq =3D virtio_add_queue(vdev, 8, handle_input); vrng->quota_remaining =3D vrng->conf.max_bytes; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 9e8f51dfb0..500f15ee9b 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -132,6 +132,56 @@ struct VirtQueue QLIST_ENTRY(VirtQueue) node; }; =20 +const char *virtio_device_names[] =3D { + [VIRTIO_ID_NET] =3D "virtio-net", + [VIRTIO_ID_BLOCK] =3D "virtio-blk", + [VIRTIO_ID_CONSOLE] =3D "virtio-serial", + [VIRTIO_ID_RNG] =3D "virtio-rng", + [VIRTIO_ID_BALLOON] =3D "virtio-balloon", + [VIRTIO_ID_IOMEM] =3D "virtio-iomem", + [VIRTIO_ID_RPMSG] =3D "virtio-rpmsg", + [VIRTIO_ID_SCSI] =3D "virtio-scsi", + [VIRTIO_ID_9P] =3D "virtio-9p", + [VIRTIO_ID_MAC80211_WLAN] =3D "virtio-mac-wlan", + [VIRTIO_ID_RPROC_SERIAL] =3D "virtio-rproc-serial", + [VIRTIO_ID_CAIF] =3D "virtio-caif", + [VIRTIO_ID_MEMORY_BALLOON] =3D "virtio-mem-balloon", + [VIRTIO_ID_GPU] =3D "virtio-gpu", + [VIRTIO_ID_CLOCK] =3D "virtio-clk", + [VIRTIO_ID_INPUT] =3D "virtio-input", + [VIRTIO_ID_VSOCK] =3D "vhost-vsock", + [VIRTIO_ID_CRYPTO] =3D "virtio-crypto", + [VIRTIO_ID_SIGNAL_DIST] =3D "virtio-signal", + [VIRTIO_ID_PSTORE] =3D "virtio-pstore", + [VIRTIO_ID_IOMMU] =3D "virtio-iommu", + [VIRTIO_ID_MEM] =3D "virtio-mem", + [VIRTIO_ID_SOUND] =3D "virtio-sound", + [VIRTIO_ID_FS] =3D "virtio-user-fs", + [VIRTIO_ID_PMEM] =3D "virtio-pmem", + [VIRTIO_ID_RPMB] =3D "virtio-rpmb", + [VIRTIO_ID_MAC80211_HWSIM] =3D "virtio-mac-hwsim", + [VIRTIO_ID_VIDEO_ENCODER] =3D "virtio-vid-encoder", + [VIRTIO_ID_VIDEO_DECODER] =3D "virtio-vid-decoder", + [VIRTIO_ID_SCMI] =3D "virtio-scmi", + [VIRTIO_ID_NITRO_SEC_MOD] =3D "virtio-nitro-sec-mod", + [VIRTIO_ID_I2C_ADAPTER] =3D "vhost-user-i2c", + [VIRTIO_ID_WATCHDOG] =3D "virtio-watchdog", + [VIRTIO_ID_CAN] =3D "virtio-can", + [VIRTIO_ID_DMABUF] =3D "virtio-dmabuf", + [VIRTIO_ID_PARAM_SERV] =3D "virtio-param-serv", + [VIRTIO_ID_AUDIO_POLICY] =3D "virtio-audio-pol", + [VIRTIO_ID_BT] =3D "virtio-bluetooth", + [VIRTIO_ID_GPIO] =3D "virtio-gpio" +}; + +static const char *virtio_id_to_name(uint16_t device_id) +{ + assert(device_id < G_N_ELEMENTS(virtio_device_names)); + const char *name =3D virtio_device_names[device_id]; + assert(name !=3D NULL); + return name; +} + /* Called within call_rcu(). */ static void virtio_free_region_cache(VRingMemoryRegionCaches *caches) { @@ -3208,8 +3258,7 @@ void virtio_instance_init_common(Object *proxy_obj, v= oid *data, qdev_alias_all_properties(vdev, proxy_obj); } =20 -void virtio_init(VirtIODevice *vdev, const char *name, - uint16_t device_id, size_t config_size) +void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_siz= e) { BusState *qbus =3D qdev_get_parent_bus(DEVICE(vdev)); VirtioBusClass *k =3D VIRTIO_BUS_GET_CLASS(qbus); @@ -3238,7 +3287,7 @@ void virtio_init(VirtIODevice *vdev, const char *name, vdev->vq[i].host_notifier_enabled =3D false; } =20 - vdev->name =3D name; + vdev->name =3D virtio_id_to_name(device_id); vdev->config_len =3D config_size; if (vdev->config_len) { vdev->config =3D g_malloc0(config_size); --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026126184746.0273813717189; Fri, 4 Feb 2022 17:55:26 -0800 (PST) Received: from localhost ([::1]:55408 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAIO-0005Wc-Or for importer@patchew.org; Fri, 04 Feb 2022 20:55:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7H-0003u7-BJ for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45886) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7E-0003N4-RS for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:55 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-537-vWkQGuYlP1iW8V3GUP0C8w-1; Fri, 04 Feb 2022 20:43:27 -0500 Received: by mail-wr1-f71.google.com with SMTP id s25-20020adfa299000000b001d8d032255fso2770497wra.14 for ; Fri, 04 Feb 2022 17:43:27 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id a26sm12688598wmj.18.2022.02.04.17.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025413; 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: in-reply-to:in-reply-to:references:references; bh=eMPARU8YJ4Hs9L2YzNbfIXIQ9DYVVBD2zClIkPnKJ4s=; b=iSBaDnQPoZjDZDgXKQjxaDIQ3leVRdthweqSzIQEYniO1HdCyNVpkl+J4EAc/OQcnoMtFE /0kkuJ+GTTNRHHKARNZTRlayu200MpqIiG2OvhMk5qUvxHl/SjnEKvSKqzFdzwqsfczD4n 5kOWVCw6qn9M6MeGnmFyY3njRvQwoM0= X-MC-Unique: vWkQGuYlP1iW8V3GUP0C8w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eMPARU8YJ4Hs9L2YzNbfIXIQ9DYVVBD2zClIkPnKJ4s=; b=3kgXK69V9Oo68ipo663vZsiERXWtzn5Y7Ln+8ll2HgmIOGX+FTzArdgxplLUzusALa IEahjAZYKBiSZzVb+MPgN07X0MM42uKQtUwosSYywhk7H1h9RuhS60tpnM6hWXA2XNDg GDjOhG52uVEy88ZG6tsQfdu3RUmau/4D8OAXdfR49sCN6q94E8D56Jmo4egzJmbmrsJ3 NoaE0EuzRUhAnTR0OfRd6ib/ttHYavholi6fgcF6Zstmjhn2YDmmOmrRP6c/TRQZjqJg erWPRfwin0lKezDdnMIzYLV1zqi3Xl59NMV7LNLslM1aRkTYGK1u6Awu/X6rb155ltlO h5Zg== X-Gm-Message-State: AOAM532QQyvJBMB8iq9BoIxe+i7inGNqPTMa6u15tyerJ9BdwjcCih09 /u81KphHVsaetlqcZ+Qj6X5BF2QZqjITNrR6jLpDA8txTfKE3wYwHvalRavXl/jRWFMEj2NHIZT FqAr6SrbUmyYkN/9+4LrItbozRpyW3dMENSzYeEOdChbDO47EY8Ivcp/YLpmV X-Received: by 2002:a05:600c:4f47:: with SMTP id m7mr4457531wmq.132.1644025404134; Fri, 04 Feb 2022 17:43:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsx0jzi8ZbWMQTMZemtrdI8HhKliH7o3aGVX/TOCPMGDN7wgD0WSwlRbZaJlMyozRoFj2lHg== X-Received: by 2002:a05:600c:4f47:: with SMTP id m7mr4457497wmq.132.1644025403773; Fri, 04 Feb 2022 17:43:23 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 16/32] virtio: add vhost support for virtio devices Message-ID: <20220205014149.1189026-17-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Cc: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Mathieu Poirier , Jason Wang , "Dr. David Alan Gilbert" , Raphael Norwitz , virtio-fs@redhat.com, Hanna Reitz , "Gonglei \(Arei\)" , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Fam Zheng , Jonah Palmer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026128569100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonah Palmer This patch adds a get_vhost() callback function for VirtIODevices that returns the device's corresponding vhost_dev structure, if the vhost device is running. This patch also adds a vhost_started flag for VirtIODevices. Previously, a VirtIODevice wouldn't be able to tell if its corresponding vhost device was active or not. Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-3-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 3 +++ hw/block/vhost-user-blk.c | 7 +++++++ hw/display/vhost-user-gpu.c | 7 +++++++ hw/input/vhost-user-input.c | 7 +++++++ hw/net/virtio-net.c | 9 +++++++++ hw/scsi/vhost-scsi.c | 8 ++++++++ hw/virtio/vhost-user-fs.c | 7 +++++++ hw/virtio/vhost-user-rng.c | 7 +++++++ hw/virtio/vhost-vsock-common.c | 7 +++++++ hw/virtio/vhost.c | 4 +++- hw/virtio/virtio-crypto.c | 10 ++++++++++ hw/virtio/virtio.c | 1 + 12 files changed, 76 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 2a0be70ec6..90e6080890 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -22,6 +22,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" +#include "hw/virtio/vhost.h" =20 /* A guest should never accept this. It implies negotiation is broken. */ #define VIRTIO_F_BAD_FEATURE 30 @@ -102,6 +103,7 @@ struct VirtIODevice bool started; bool start_on_kick; /* when virtio 1.0 feature has not been negotiated= */ bool disable_legacy_check; + bool vhost_started; VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; @@ -160,6 +162,7 @@ struct VirtioDeviceClass { int (*post_load)(VirtIODevice *vdev); const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); + struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); }; =20 void virtio_instance_init_common(Object *proxy_obj, void *data, diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index e8cb170032..5dca4eab09 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -569,6 +569,12 @@ static void vhost_user_blk_instance_init(Object *obj) "/disk@0,0", DEVICE(obj)); } =20 +static struct vhost_dev *vhost_user_blk_get_vhost(VirtIODevice *vdev) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + return &s->dev; +} + static const VMStateDescription vmstate_vhost_user_blk =3D { .name =3D "vhost-user-blk", .minimum_version_id =3D 1, @@ -603,6 +609,7 @@ static void vhost_user_blk_class_init(ObjectClass *klas= s, void *data) vdc->get_features =3D vhost_user_blk_get_features; vdc->set_status =3D vhost_user_blk_set_status; vdc->reset =3D vhost_user_blk_reset; + vdc->get_vhost =3D vhost_user_blk_get_vhost; } =20 static const TypeInfo vhost_user_blk_info =3D { diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 09818231bd..96e56c4467 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -565,6 +565,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error= **errp) g->vhost_gpu_fd =3D -1; } =20 +static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) +{ + VhostUserGPU *g =3D VHOST_USER_GPU(vdev); + return &g->vhost->dev; +} + static Property vhost_user_gpu_properties[] =3D { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), DEFINE_PROP_END_OF_LIST(), @@ -586,6 +592,7 @@ vhost_user_gpu_class_init(ObjectClass *klass, void *dat= a) vdc->guest_notifier_pending =3D vhost_user_gpu_guest_notifier_pending; vdc->get_config =3D vhost_user_gpu_get_config; vdc->set_config =3D vhost_user_gpu_set_config; + vdc->get_vhost =3D vhost_user_gpu_get_vhost; =20 device_class_set_props(dc, vhost_user_gpu_properties); } diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c index 273e96a7b1..43d2ff3816 100644 --- a/hw/input/vhost-user-input.c +++ b/hw/input/vhost-user-input.c @@ -79,6 +79,12 @@ static void vhost_input_set_config(VirtIODevice *vdev, virtio_notify_config(vdev); } =20 +static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) +{ + VHostUserInput *vhi =3D VHOST_USER_INPUT(vdev); + return &vhi->vhost->dev; +} + static const VMStateDescription vmstate_vhost_input =3D { .name =3D "vhost-user-input", .unmigratable =3D 1, @@ -93,6 +99,7 @@ static void vhost_input_class_init(ObjectClass *klass, vo= id *data) dc->vmsd =3D &vmstate_vhost_input; vdc->get_config =3D vhost_input_get_config; vdc->set_config =3D vhost_input_set_config; + vdc->get_vhost =3D vhost_input_get_vhost; vic->realize =3D vhost_input_realize; vic->change_active =3D vhost_input_change_active; } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 25f494ca3b..21328dc547 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3615,6 +3615,14 @@ static bool dev_unplug_pending(void *opaque) return vdc->primary_unplug_pending(dev); } =20 +static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev) +{ + VirtIONet *n =3D VIRTIO_NET(vdev); + NetClientState *nc =3D qemu_get_queue(n->nic); + struct vhost_net *net =3D get_vhost_net(nc->peer); + return &net->dev; +} + static const VMStateDescription vmstate_virtio_net =3D { .name =3D "virtio-net", .minimum_version_id =3D VIRTIO_NET_VM_VERSION, @@ -3717,6 +3725,7 @@ static void virtio_net_class_init(ObjectClass *klass,= void *data) vdc->post_load =3D virtio_net_post_load_virtio; vdc->vmsd =3D &vmstate_virtio_net_device; vdc->primary_unplug_pending =3D primary_unplug_pending; + vdc->get_vhost =3D virtio_net_get_vhost; } =20 static const TypeInfo virtio_net_info =3D { diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 778f43e4c1..3059068175 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -273,6 +273,13 @@ static void vhost_scsi_unrealize(DeviceState *dev) virtio_scsi_common_unrealize(dev); } =20 +static struct vhost_dev *vhost_scsi_get_vhost(VirtIODevice *vdev) +{ + VHostSCSI *s =3D VHOST_SCSI(vdev); + VHostSCSICommon *vsc =3D VHOST_SCSI_COMMON(s); + return &vsc->dev; +} + static Property vhost_scsi_properties[] =3D { DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd), DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn), @@ -307,6 +314,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, v= oid *data) vdc->get_features =3D vhost_scsi_common_get_features; vdc->set_config =3D vhost_scsi_common_set_config; vdc->set_status =3D vhost_scsi_set_status; + vdc->get_vhost =3D vhost_scsi_get_vhost; fwc->get_dev_path =3D vhost_scsi_common_get_fw_dev_path; } =20 diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index b875640147..e513e4fdda 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -276,6 +276,12 @@ static void vuf_device_unrealize(DeviceState *dev) fs->vhost_dev.vqs =3D NULL; } =20 +static struct vhost_dev *vuf_get_vhost(VirtIODevice *vdev) +{ + VHostUserFS *fs =3D VHOST_USER_FS(vdev); + return &fs->vhost_dev; +} + static const VMStateDescription vuf_vmstate =3D { .name =3D "vhost-user-fs", .unmigratable =3D 1, @@ -313,6 +319,7 @@ static void vuf_class_init(ObjectClass *klass, void *da= ta) vdc->set_status =3D vuf_set_status; vdc->guest_notifier_mask =3D vuf_guest_notifier_mask; vdc->guest_notifier_pending =3D vuf_guest_notifier_pending; + vdc->get_vhost =3D vuf_get_vhost; } =20 static const TypeInfo vuf_info =3D { diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 08bccba9dc..3a7bf8e32d 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -247,6 +247,12 @@ static void vu_rng_device_unrealize(DeviceState *dev) vhost_user_cleanup(&rng->vhost_user); } =20 +static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) +{ + VHostUserRNG *rng =3D VHOST_USER_RNG(vdev); + return &rng->vhost_dev; +} + static const VMStateDescription vu_rng_vmstate =3D { .name =3D "vhost-user-rng", .unmigratable =3D 1, @@ -272,6 +278,7 @@ static void vu_rng_class_init(ObjectClass *klass, void = *data) vdc->set_status =3D vu_rng_set_status; vdc->guest_notifier_mask =3D vu_rng_guest_notifier_mask; vdc->guest_notifier_pending =3D vu_rng_guest_notifier_pending; + vdc->get_vhost =3D vu_rng_get_vhost; } =20 static const TypeInfo vu_rng_info =3D { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 6146d258d3..416daf8554 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -254,6 +254,12 @@ void vhost_vsock_common_unrealize(VirtIODevice *vdev) virtio_cleanup(vdev); } =20 +static struct vhost_dev *vhost_vsock_common_get_vhost(VirtIODevice *vdev) +{ + VHostVSockCommon *vvc =3D VHOST_VSOCK_COMMON(vdev); + return &vvc->vhost_dev; +} + static Property vhost_vsock_common_properties[] =3D { DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSockCommon, seqpacket, ON_OFF_AUTO_AUTO), @@ -269,6 +275,7 @@ static void vhost_vsock_common_class_init(ObjectClass *= klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); vdc->guest_notifier_mask =3D vhost_vsock_common_guest_notifier_mask; vdc->guest_notifier_pending =3D vhost_vsock_common_guest_notifier_pend= ing; + vdc->get_vhost =3D vhost_vsock_common_get_vhost; } =20 static const TypeInfo vhost_vsock_common_info =3D { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 7b03efccec..34f8c123d8 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1739,6 +1739,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODev= ice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); =20 + vdev->vhost_started =3D true; hdev->started =3D true; hdev->vdev =3D vdev; =20 @@ -1811,7 +1812,7 @@ fail_vq: =20 fail_mem: fail_features: - + vdev->vhost_started =3D false; hdev->started =3D false; return r; } @@ -1842,6 +1843,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODev= ice *vdev) } vhost_log_put(hdev, true); hdev->started =3D false; + vdev->vhost_started =3D false; hdev->vdev =3D NULL; } =20 diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index cca5237afa..7d63b8c9a8 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -961,6 +961,15 @@ static bool virtio_crypto_guest_notifier_pending(VirtI= ODevice *vdev, int idx) return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } =20 +static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev) +{ + VirtIOCrypto *vcrypto =3D VIRTIO_CRYPTO(vdev); + CryptoDevBackend *b =3D vcrypto->cryptodev; + CryptoDevBackendClient *cc =3D b->conf.peers.ccs[0]; + CryptoDevBackendVhost *vhost_crypto =3D cryptodev_get_vhost(cc, b, 0); + return &vhost_crypto->dev; +} + static void virtio_crypto_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -977,6 +986,7 @@ static void virtio_crypto_class_init(ObjectClass *klass= , void *data) vdc->set_status =3D virtio_crypto_set_status; vdc->guest_notifier_mask =3D virtio_crypto_guest_notifier_mask; vdc->guest_notifier_pending =3D virtio_crypto_guest_notifier_pending; + vdc->get_vhost =3D virtio_crypto_get_vhost; } =20 static void virtio_crypto_instance_init(Object *obj) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 500f15ee9b..443475bb60 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3272,6 +3272,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_= id, size_t config_size) =20 vdev->start_on_kick =3D false; vdev->started =3D false; + vdev->vhost_started =3D false; vdev->device_id =3D device_id; vdev->status =3D 0; qatomic_set(&vdev->isr, 0); --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027366807118.79049453154596; Fri, 4 Feb 2022 18:16:06 -0800 (PST) Received: from localhost ([::1]:40630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAcM-0000Je-Q1 for importer@patchew.org; Fri, 04 Feb 2022 21:16:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA8N-00057X-2Q for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:45:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA8K-0003Uz-M9 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:45:02 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-UrnvOKscMHq80BhVLUYyhA-1; Fri, 04 Feb 2022 20:44:54 -0500 Received: by mail-wm1-f71.google.com with SMTP id j18-20020a05600c1c1200b0034aeea95dacso8369463wms.8 for ; Fri, 04 Feb 2022 17:44:53 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id a14sm4346824wri.25.2022.02.04.17.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:44:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025500; 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: in-reply-to:in-reply-to:references:references; bh=gviKguSxEHikAtlBS3CuKkyMlXe+IXrF/wF7dwoEBqg=; b=LyTFsqFPxI9SM03p9qZeYeB9J/PVUDXHT5PPoHcrIPtNmLL9vIRK28lunJEDPWgJAszBqC cN6cYtij0NG/EwCQcGn93eidbOBXEspDtwbSpf8zrJgtjQ5BkQQRWFgBvi78sX3Ngc8T4S FFuV7ljMJ7McfKA/o7n5xMpv0jljkXc= X-MC-Unique: UrnvOKscMHq80BhVLUYyhA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gviKguSxEHikAtlBS3CuKkyMlXe+IXrF/wF7dwoEBqg=; b=vSZgFP3uijAx8kpKQABNIqnQL5Hu6YRBdlbyBMtezluwdcUm27PIXeRdZc5KbFCDC+ kydyt4u2P3uTnS54p37cO6hdsWqrITMcjOrXDmbmHAHygEGYLuF1iITlbraPmc91O7Rr 27c0cR43Ou4pK4S67KSpUEPkYld6oz2heaQ28XyHNW6a0pNkCHXHf1WLJAaFq9iE7J59 BA5/yU2Nk2N0Z84b4QH2mye6hdUOBjlbpHt/J83yQKYDvKIS8Mr921T440zAO1wUieV/ 0UGfSZSG9OlXATe5jqbNRpB782UlP0FzMKaNUxjVEM+7rzDp5EiIMuTQUGIOWBYT5CgC 4p7g== X-Gm-Message-State: AOAM530VRtRwySwLu4Jb2oNHys49ztnomB/cWY9jcPlKvCKrgG4vPGKE XteVB1w/jrwrJ5CQ5PcmKTXkU7I/yU2zVQHkSBYCdEaiWI/no97kov32hqtLBfzH6rjorSFlJ8e DFaY82ACTZIqoQoYg+kMTUm43xCwUoy1b8hULP4eqjXRw3PweGePUjfCDJ/Dq X-Received: by 2002:adf:9d8b:: with SMTP id p11mr1206937wre.185.1644025492389; Fri, 04 Feb 2022 17:44:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOpLPDxgYOyEq6WGZ0+TXUfKXZDR6H7qcYQt2Jx2/TXGD2y7DI70pmlnTpo9UqQGdtO0MotA== X-Received: by 2002:adf:9d8b:: with SMTP id p11mr1206926wre.185.1644025492107; Fri, 04 Feb 2022 17:44:52 -0800 (PST) Date: Fri, 4 Feb 2022 20:44:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 17/32] qmp: add QMP command x-query-virtio Message-ID: <20220205014149.1189026-18-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Michael Roth , Markus Armbruster , Paolo Bonzini , Eric Blake , Jonah Palmer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027368891100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command lists all the instances of VirtIODevices with their canonical QOM path and name. [Jonah: @virtio_list duplicates information that already exists in the QOM composition tree. However, extracting necessary information from this tree seems to be a bit convoluted. Instead, we still create our own list of realized virtio devices but use @qmp_qom_get with the device's canonical QOM path to confirm that the device exists and is realized. If the device exists but is actually not realized, then we remove it from our list (for synchronicity to the QOM composition tree). Also, the QMP command @x-query-virtio is redundant as @qom-list and @qom-get are sufficient to search '/machine/' for realized virtio devices. However, @x-query-virtio is much more convenient in listing realized virtio devices.] Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-4-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/qapi-schema.json | 1 + qapi/virtio.json | 68 ++++++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 1 + hw/virtio/virtio-stub.c | 14 ++++++++ hw/virtio/virtio.c | 44 ++++++++++++++++++++++++ tests/qtest/qmp-cmd-test.c | 1 + hw/virtio/meson.build | 2 ++ qapi/meson.build | 1 + 8 files changed, 132 insertions(+) create mode 100644 qapi/virtio.json create mode 100644 hw/virtio/virtio-stub.c diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 4912b9744e..1512adaf92 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -93,3 +93,4 @@ { 'include': 'audio.json' } { 'include': 'acpi.json' } { 'include': 'pci.json' } +{ 'include': 'virtio.json' } diff --git a/qapi/virtio.json b/qapi/virtio.json new file mode 100644 index 0000000000..aee0e40daa --- /dev/null +++ b/qapi/virtio.json @@ -0,0 +1,68 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython +# + +## +# =3D Virtio devices +## + +## +# @VirtioInfo: +# +# Basic information about a given VirtIODevice +# +# @path: The VirtIODevice's canonical QOM path +# +# @name: Name of the VirtIODevice +# +# Since: 7.0 +# +## +{ 'struct': 'VirtioInfo', + 'data': { 'path': 'str', + 'name': 'str' } } + +## +# @x-query-virtio: +# +# Returns a list of all realized VirtIODevices +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: List of gathered VirtIODevices +# +# Since: 7.0 +# +# Example: +# +# -> { "execute": "x-query-virtio" } +# <- { "return": [ +# { +# "path": "/machine/peripheral-anon/device[4]/virtio-backend", +# "name": "virtio-input" +# }, +# { +# "path": "/machine/peripheral/crypto0/virtio-backend", +# "name": "virtio-crypto" +# }, +# { +# "path": "/machine/peripheral-anon/device[2]/virtio-backend", +# "name": "virtio-scsi" +# }, +# { +# "path": "/machine/peripheral-anon/device[1]/virtio-backend", +# "name": "virtio-net" +# }, +# { +# "path": "/machine/peripheral-anon/device[0]/virtio-backend", +# "name": "virtio-serial" +# } +# ] +# } +# +## + +{ 'command': 'x-query-virtio', + 'returns': [ 'VirtioInfo' ], + 'features': [ 'unstable' ] } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 90e6080890..8f4e4c12a6 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -110,6 +110,7 @@ struct VirtIODevice bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; + QTAILQ_ENTRY(VirtIODevice) next; }; =20 struct VirtioDeviceClass { diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c new file mode 100644 index 0000000000..05a81edc92 --- /dev/null +++ b/hw/virtio/virtio-stub.c @@ -0,0 +1,14 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-virtio.h" + +static void *qmp_virtio_unsupported(Error **errp) +{ + error_setg(errp, "Virtio is disabled"); + return NULL; +} + +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 443475bb60..dd02909c70 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -13,12 +13,18 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-commands-qom.h" +#include "qapi/qapi-visit-virtio.h" +#include "qapi/qmp/qjson.h" #include "cpu.h" #include "trace.h" #include "qemu/error-report.h" #include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" +#include "qom/object_interfaces.h" #include "hw/virtio/virtio.h" #include "migration/qemu-file-types.h" #include "qemu/atomic.h" @@ -29,6 +35,9 @@ #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" =20 +/* QAPI list of realized VirtIODevices */ +static QTAILQ_HEAD(, VirtIODevice) virtio_list; + /* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI @@ -3686,6 +3695,7 @@ static void virtio_device_realize(DeviceState *dev, E= rror **errp) vdev->listener.commit =3D virtio_memory_listener_commit; vdev->listener.name =3D "virtio"; memory_listener_register(&vdev->listener, vdev->dma_as); + QTAILQ_INSERT_TAIL(&virtio_list, vdev, next); } =20 static void virtio_device_unrealize(DeviceState *dev) @@ -3700,6 +3710,7 @@ static void virtio_device_unrealize(DeviceState *dev) vdc->unrealize(dev); } =20 + QTAILQ_REMOVE(&virtio_list, vdev, next); g_free(vdev->bus_name); vdev->bus_name =3D NULL; } @@ -3873,6 +3884,8 @@ static void virtio_device_class_init(ObjectClass *kla= ss, void *data) vdc->stop_ioeventfd =3D virtio_device_stop_ioeventfd_impl; =20 vdc->legacy_features |=3D VIRTIO_LEGACY_FEATURES; + + QTAILQ_INIT(&virtio_list); } =20 bool virtio_device_ioeventfd_enabled(VirtIODevice *vdev) @@ -3883,6 +3896,37 @@ bool virtio_device_ioeventfd_enabled(VirtIODevice *v= dev) return virtio_bus_ioeventfd_enabled(vbus); } =20 +VirtioInfoList *qmp_x_query_virtio(Error **errp) +{ + VirtioInfoList *list =3D NULL; + VirtioInfoList *node; + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + Error *err =3D NULL; + QObject *obj =3D qmp_qom_get(dev->canonical_path, "realized", &err= ); + + if (err =3D=3D NULL) { + GString *is_realized =3D qobject_to_json_pretty(obj, true); + /* virtio device is NOT realized, remove it from list */ + if (!strncmp(is_realized->str, "false", 4)) { + QTAILQ_REMOVE(&virtio_list, vdev, next); + } else { + node =3D g_new0(VirtioInfoList, 1); + node->value =3D g_new(VirtioInfo, 1); + node->value->path =3D g_strdup(dev->canonical_path); + node->value->name =3D g_strdup(vdev->name); + QAPI_LIST_PREPEND(list, node->value); + } + g_string_free(is_realized, true); + } + qobject_unref(obj); + } + + return list; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 7f103ea3fd..fd00ee2777 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -103,6 +103,7 @@ static bool query_is_ignored(const char *cmd) "query-gic-capabilities", /* arm */ /* Success depends on target-specific build configuration: */ "query-pci", /* CONFIG_PCI */ + "x-query-virtio", /* CONFIG_VIRTIO */ /* Success depends on launching SEV guest */ "query-sev-launch-measure", /* Success depends on Host or Hypervisor SEV support */ diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 521f7d64a8..d893f5f074 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -6,8 +6,10 @@ softmmu_virtio_ss.add(when: 'CONFIG_VHOST', if_false: file= s('vhost-stub.c')) =20 softmmu_ss.add_all(when: 'CONFIG_VIRTIO', if_true: softmmu_virtio_ss) softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_VIRTIO', if_false: files('virtio-stub.c')) =20 softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('vhost-stub.c')) +softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-stub.c')) =20 virtio_ss =3D ss.source_set() virtio_ss.add(files('virtio.c')) diff --git a/qapi/meson.build b/qapi/meson.build index 656ef0e039..10c54d68e5 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -48,6 +48,7 @@ qapi_all_modules =3D [ 'sockets', 'trace', 'transaction', + 'virtio', 'yank', ] if have_system --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644025893463219.21546621024606; Fri, 4 Feb 2022 17:51:33 -0800 (PST) Received: from localhost ([::1]:46696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAEe-00086f-CV for importer@patchew.org; Fri, 04 Feb 2022 20:51:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7H-0003u8-Ih for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7D-0003Mx-Nd for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:55 -0500 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-Ca7DSsMZPQGyl0T8G3gtkw-1; Fri, 04 Feb 2022 20:43:31 -0500 Received: by mail-wr1-f69.google.com with SMTP id k20-20020adfc714000000b001e305cd1597so133665wrg.19 for ; Fri, 04 Feb 2022 17:43:31 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id j13sm3392309wrw.116.2022.02.04.17.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025412; 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: in-reply-to:in-reply-to:references:references; bh=MIQgajsP48Ue+zLusBwN9/ZjEx4q08BpkiTtp4+IU+A=; b=RhqODu19k8fUbcgb4YvIeW/pAakWH1b0DFJv5lwwRGV+TRPAodOQDveXj0r3dpOBkCK9tD mqOwmIXf36OVTQljTL4jwYU8jx9E2DqNoVzDOP1r+hcb+cN/lPczK2bdTDwKpJn6jxdaqG y+FsIWB+kX7Lr/UJX5xH7TBZI7/Blg0= X-MC-Unique: Ca7DSsMZPQGyl0T8G3gtkw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MIQgajsP48Ue+zLusBwN9/ZjEx4q08BpkiTtp4+IU+A=; b=QiSvr6pNyfzyBFXn7zSqXA7M/XIS+RoTTTe8OzoeYq4jvFk/M+rMQhhCmeU/uO1XXP 3DAfZYfZPMjpIMzV6qRaRstma0VdzmMTohEUpcZUcJDuAt7bqF0/WCLHBrxEtVeOrZzP 6ZdIz4GLZCpKjY8vQPGCdbYAiwbEmJK6JU2d6PfMKw3TVv0EFkje3Mc7BM9Zb+U76poP QO6dfTdeF39Pt1odZUaunt01bXGA16jiicP+FLR4aFiHN9+2aqIFMFw4sgSZ0HqpYOCD Gr/G90rIGkWzVRk1rJRthMwZLVG1IpvGK8l7L1S1m3pO8PcskunToqhlRu0UbUwOn13C OIJA== X-Gm-Message-State: AOAM532Nf0zrGrsGN2jB+j0cYH4ctg+VttgAZ7TZWbr8xJU0nF+esETq TjsfqrS7Mw6WwmEdANNYhjNIkSgF12LgAjra2h3jXFGkk4pZnDOb/7eu+HJ+86S1M02NhNKEGri Ot2rCBB19mUlW1L3SqrJ1559dKwosifyBgSTsyFQFsls1V3wg9NlYZi47Mb6H X-Received: by 2002:adf:e18c:: with SMTP id az12mr1227777wrb.322.1644025409185; Fri, 04 Feb 2022 17:43:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTKUvTwmChWN81hmDzVN//zX0lLVpMTJleDfM94jHXKzQ/2LYMFQeGtDs9nVeNlpR9sBJqaQ== X-Received: by 2002:adf:e18c:: with SMTP id az12mr1227758wrb.322.1644025408798; Fri, 04 Feb 2022 17:43:28 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 18/32] qmp: add QMP command x-query-virtio-status Message-ID: <20220205014149.1189026-19-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Laurent Vivier , Peter Maydell , Eric Blake , Markus Armbruster , Jonah Palmer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644025894356100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the status of a VirtIODevice, including its corresponding vhost device's status (if active). Next patch will improve output by decoding feature bits, including vhost device's feature bits (backend, protocol, acked, and features). Also will decode status bits of a VirtIODevice. [Jonah: Similar to previous patch, added a check to @virtio_device_find to ensure synchronicity between @virtio_list and the devices in the QOM composition tree.] Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-5-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/virtio.json | 222 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-stub.c | 5 + hw/virtio/virtio.c | 104 +++++++++++++++++++ 3 files changed, 331 insertions(+) diff --git a/qapi/virtio.json b/qapi/virtio.json index aee0e40daa..ba61d83df7 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -66,3 +66,225 @@ { 'command': 'x-query-virtio', 'returns': [ 'VirtioInfo' ], 'features': [ 'unstable' ] } + +## +# @VhostStatus: +# +# Information about a vhost device. This information will only be +# displayed if the vhost device is active. +# +# @n-mem-sections: vhost_dev n_mem_sections +# +# @n-tmp-sections: vhost_dev n_tmp_sections +# +# @nvqs: vhost_dev nvqs (number of virtqueues being used) +# +# @vq-index: vhost_dev vq_index +# +# @features: vhost_dev features +# +# @acked-features: vhost_dev acked_features +# +# @backend-features: vhost_dev backend_features +# +# @protocol-features: vhost_dev protocol_features +# +# @max-queues: vhost_dev max_queues +# +# @backend-cap: vhost_dev backend_cap +# +# @log-enabled: vhost_dev log_enabled flag +# +# @log-size: vhost_dev log_size +# +# Since: 7.0 +# +## + +{ 'struct': 'VhostStatus', + 'data': { 'n-mem-sections': 'int', + 'n-tmp-sections': 'int', + 'nvqs': 'uint32', + 'vq-index': 'int', + 'features': 'uint64', + 'acked-features': 'uint64', + 'backend-features': 'uint64', + 'protocol-features': 'uint64', + 'max-queues': 'uint64', + 'backend-cap': 'uint64', + 'log-enabled': 'bool', + 'log-size': 'uint64' } } + +## +# @VirtioStatus: +# +# Full status of the virtio device with most VirtIODevice members. +# Also includes the full status of the corresponding vhost device +# if the vhost device is active. +# +# @name: VirtIODevice name +# +# @device-id: VirtIODevice ID +# +# @vhost-started: VirtIODevice vhost_started flag +# +# @guest-features: VirtIODevice guest_features +# +# @host-features: VirtIODevice host_features +# +# @backend-features: VirtIODevice backend_features +# +# @device-endian: VirtIODevice device_endian +# +# @num-vqs: VirtIODevice virtqueue count. This is the number of active +# virtqueues being used by the VirtIODevice. +# +# @status: VirtIODevice configuration status (VirtioDeviceStatus) +# +# @isr: VirtIODevice ISR +# +# @queue-sel: VirtIODevice queue_sel +# +# @vm-running: VirtIODevice vm_running flag +# +# @broken: VirtIODevice broken flag +# +# @disabled: VirtIODevice disabled flag +# +# @use-started: VirtIODevice use_started flag +# +# @started: VirtIODevice started flag +# +# @start-on-kick: VirtIODevice start_on_kick flag +# +# @disable-legacy-check: VirtIODevice disabled_legacy_check flag +# +# @bus-name: VirtIODevice bus_name +# +# @use-guest-notifier-mask: VirtIODevice use_guest_notifier_mask flag +# +# @vhost-dev: Corresponding vhost device info for a given VirtIODevice. +# Present if the given VirtIODevice has an active vhost +# device. +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioStatus', + 'data': { 'name': 'str', + 'device-id': 'uint16', + 'vhost-started': 'bool', + 'device-endian': 'str', + 'guest-features': 'uint64', + 'host-features': 'uint64', + 'backend-features': 'uint64', + 'num-vqs': 'int', + 'status': 'uint8', + 'isr': 'uint8', + 'queue-sel': 'uint16', + 'vm-running': 'bool', + 'broken': 'bool', + 'disabled': 'bool', + 'use-started': 'bool', + 'started': 'bool', + 'start-on-kick': 'bool', + 'disable-legacy-check': 'bool', + 'bus-name': 'str', + 'use-guest-notifier-mask': 'bool', + '*vhost-dev': 'VhostStatus' } } + +## +# @x-query-virtio-status: +# +# Poll for a comprehensive status of a given virtio device +# +# @path: Canonical QOM path of the VirtIODevice +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioStatus of the virtio device +# +# Since: 7.0 +# +# Examples: +# +# 1. Poll for the status of virtio-crypto (no vhost-crypto active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend"= } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disable-legacy-check": false, +# "name": "virtio-crypto", +# "started": true, +# "device-id": 20, +# "backend-features": 0, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 2, +# "guest-features": 5100273664, +# "host-features": 6325010432, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 1, +# "disabled": false, +# "vhost-started": false, +# "use-started": true +# } +# } +# +# 2. Poll for the status of virtio-net (vhost-net is active) +# +# -> { "execute": "x-query-virtio-status", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-b= ackend" } +# } +# <- { "return": { +# "device-endian": "little", +# "bus-name": "", +# "disabled-legacy-check": false, +# "name": "virtio-net", +# "started": true, +# "device-id": 1, +# "vhost-dev": { +# "n-tmp-sections": 4, +# "n-mem-sections": 4, +# "max-queues": 1, +# "backend-cap": 2, +# "log-size": 0, +# "backend-features": 0, +# "nvqs": 2, +# "protocol-features": 0, +# "vq-index": 0, +# "log-enabled": false, +# "acked-features": 5100306432, +# "features": 13908344832 +# }, +# "backend-features": 6337593319, +# "start-on-kick": false, +# "isr": 1, +# "broken": false, +# "status": 15, +# "num-vqs": 3, +# "guest-features": 5111807911, +# "host-features": 6337593319, +# "use-guest-notifier-mask": true, +# "vm-running": true, +# "queue-sel": 2, +# "disabled": false, +# "vhost-started": true, +# "use-started": true +# } +# } +# +## + +{ 'command': 'x-query-virtio-status', + 'data': { 'path': 'str' }, + 'returns': 'VirtioStatus', + 'features': [ 'unstable' ] } diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 05a81edc92..0b432e8de7 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -12,3 +12,8 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index dd02909c70..59665f7d62 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3927,6 +3927,110 @@ VirtioInfoList *qmp_x_query_virtio(Error **errp) return list; } =20 +static VirtIODevice *virtio_device_find(const char *path) +{ + VirtIODevice *vdev; + + QTAILQ_FOREACH(vdev, &virtio_list, next) { + DeviceState *dev =3D DEVICE(vdev); + + if (strcmp(dev->canonical_path, path) !=3D 0) { + continue; + } + + Error *err =3D NULL; + QObject *obj =3D qmp_qom_get(dev->canonical_path, "realized", &err= ); + if (err =3D=3D NULL) { + GString *is_realized =3D qobject_to_json_pretty(obj, true); + /* virtio device is NOT realized, remove it from list */ + if (!strncmp(is_realized->str, "false", 4)) { + g_string_free(is_realized, true); + qobject_unref(obj); + QTAILQ_REMOVE(&virtio_list, vdev, next); + return NULL; + } + g_string_free(is_realized, true); + } else { + /* virtio device doesn't exist in QOM tree */ + QTAILQ_REMOVE(&virtio_list, vdev, next); + qobject_unref(obj); + return NULL; + } + /* device exists in QOM tree & is realized */ + qobject_unref(obj); + return vdev; + } + return NULL; +} + +VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) +{ + VirtIODevice *vdev; + VirtioStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + status =3D g_new0(VirtioStatus, 1); + status->name =3D g_strdup(vdev->name); + status->device_id =3D vdev->device_id; + status->vhost_started =3D vdev->vhost_started; + status->guest_features =3D vdev->guest_features; + status->host_features =3D vdev->host_features; + status->backend_features =3D vdev->backend_features; + + switch (vdev->device_endian) { + case VIRTIO_DEVICE_ENDIAN_LITTLE: + status->device_endian =3D g_strdup("little"); + break; + case VIRTIO_DEVICE_ENDIAN_BIG: + status->device_endian =3D g_strdup("big"); + break; + default: + status->device_endian =3D g_strdup("unknown"); + break; + } + + status->num_vqs =3D virtio_get_num_queues(vdev); + status->status =3D vdev->status; + status->isr =3D vdev->isr; + status->queue_sel =3D vdev->queue_sel; + status->vm_running =3D vdev->vm_running; + status->broken =3D vdev->broken; + status->disabled =3D vdev->disabled; + status->use_started =3D vdev->use_started; + status->started =3D vdev->started; + status->start_on_kick =3D vdev->start_on_kick; + status->disable_legacy_check =3D vdev->disable_legacy_check; + status->bus_name =3D g_strdup(vdev->bus_name); + status->use_guest_notifier_mask =3D vdev->use_guest_notifier_mask; + status->has_vhost_dev =3D vdev->vhost_started; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev =3D vdc->get_vhost(vdev); + + status->vhost_dev =3D g_new0(VhostStatus, 1); + status->vhost_dev->n_mem_sections =3D hdev->n_mem_sections; + status->vhost_dev->n_tmp_sections =3D hdev->n_tmp_sections; + status->vhost_dev->nvqs =3D hdev->nvqs; + status->vhost_dev->vq_index =3D hdev->vq_index; + status->vhost_dev->features =3D hdev->features; + status->vhost_dev->acked_features =3D hdev->acked_features; + status->vhost_dev->backend_features =3D hdev->backend_features; + status->vhost_dev->protocol_features =3D hdev->protocol_features; + status->vhost_dev->max_queues =3D hdev->max_queues; + status->vhost_dev->backend_cap =3D hdev->backend_cap; + status->vhost_dev->log_enabled =3D hdev->log_enabled; + status->vhost_dev->log_size =3D hdev->log_size; + } + + return status; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026551180560.4122530874125; Fri, 4 Feb 2022 18:02:31 -0800 (PST) Received: from localhost ([::1]:45338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAPG-00016E-1H for importer@patchew.org; Fri, 04 Feb 2022 21:02:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7M-0003xW-VP for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7G-0003NH-Ab for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:00 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-1XhxEM83Ozi0Qyk0kVRDUA-1; Fri, 04 Feb 2022 20:43:36 -0500 Received: by mail-wm1-f71.google.com with SMTP id i64-20020a1c3b43000000b00352cf8b74dcso1187543wma.0 for ; Fri, 04 Feb 2022 17:43:35 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id u8sm2123707wmn.27.2022.02.04.17.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025420; 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: in-reply-to:in-reply-to:references:references; bh=onX0oWn2urT5ceS9BAfB1xovYXZVn5i3QQkIHB8aKkE=; b=RevTMM9JpOxTmY5EAyZQMhHsKVycgiOAT2vd71iGGQsBCiOggUdylnfSTULTR2xUkmH2zF zCRm9hYHNd5yxKg4pNALx0D+H07kDov3yIInujgTUUeB7VwcJQ0YrsKVSlYZ+5BveJXBTJ H1EgYfwTGvOm9eMlbCm3N457zgohkb4= X-MC-Unique: 1XhxEM83Ozi0Qyk0kVRDUA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=onX0oWn2urT5ceS9BAfB1xovYXZVn5i3QQkIHB8aKkE=; b=C8HbZurf0exQuKCqIKaOdHcQghqZJ0qPpR2uULsQbtgQmL8/UOmMP5Q1HYTAclvQ5W 55wEOU+b+sGp3wBV4QDGJFcNBhYOqUPeh1hqkvFG4IcHR6bsXCYZi7RoacuS8DYImAD1 W7kt++NYLDLiAC7WFHGaPfcBmeYILU0YZmPow762inwnuYDLPBDF7DolS7i7OTnQtuXS j7Vf8p3j4No0uPlzRvp7Wy9Wl5gptPLr8Zx3G6q+/B4n1MqOk7b2a4p0Odwj26XC0Dgw pwbGZ31aIEvaRC3XVAspmo22O+TtpMvVhVCrwtt7myax3I64QUzebyMjflNPVQ1SVWrv EuXQ== X-Gm-Message-State: AOAM530vqzi5S7M9Rmr/RhBy2hcpmALS3efKz0U48nwSBO9kS7kqERih 7pBVfusOkpslT36IgYoqN1m60HKZKfohFByZenlMNEdZn66TFUHlwdAC1rt3hYsNC5MPIxQ1G1E nZx9P7WanXS3ZMGYQ+LntXHkTNsRSpg3EV0ZkYsJn3QT5Unzmh9lpcn01ezoO X-Received: by 2002:a05:600c:414a:: with SMTP id h10mr1145832wmm.89.1644025412827; Fri, 04 Feb 2022 17:43:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJxP3EXf5bvF9ATjuZxvagmpjGvLm8o28uCG8SbdcH5gJCRKnBd6aPHuPQadWJzfW8y+oezgAA== X-Received: by 2002:a05:600c:414a:: with SMTP id h10mr1145790wmm.89.1644025412266; Fri, 04 Feb 2022 17:43:32 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 19/32] qmp: decode feature & status bits in virtio-status Message-ID: <20220205014149.1189026-20-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Cc: Laurent Vivier , Peter Maydell , "Gonglei \(Arei\)" , qemu-block@nongnu.org, Amit Shah , Jason Wang , David Hildenbrand , "Dr. David Alan Gilbert" , Markus Armbruster , virtio-fs@redhat.com, Eric Auger , Hanna Reitz , Paolo Bonzini , Gerd Hoffmann , Stefan Hajnoczi , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Kevin Wolf , Fam Zheng , Eric Blake , Jonah Palmer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026552402100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier Display feature names instead of bitmaps for host, guest, and backend for VirtIODevices. Display status names instead of bitmaps for VirtIODevices. Display feature names instead of bitmaps for backend, protocol, acked, and features (hdev->features) for vhost devices. Decode features according to device ID. Decode statuses according to configuration status bitmap (config_status_map). Decode vhost user protocol features according to vhost user protocol bitmap (vhost_user_protocol_map). Transport features are on the first line. Undecoded bits (if any) are stored in a separate field. Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-6-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/virtio.json | 156 ++++++++++++++--- include/hw/virtio/vhost.h | 3 + include/hw/virtio/virtio.h | 18 ++ hw/block/virtio-blk.c | 29 ++++ hw/char/virtio-serial-bus.c | 11 ++ hw/display/virtio-gpu-base.c | 18 +- hw/input/virtio-input.c | 10 ++ hw/net/virtio-net.c | 47 ++++++ hw/scsi/virtio-scsi.c | 17 ++ hw/virtio/vhost-user-fs.c | 10 ++ hw/virtio/vhost-vsock-common.c | 10 ++ hw/virtio/virtio-balloon.c | 14 ++ hw/virtio/virtio-crypto.c | 10 ++ hw/virtio/virtio-iommu.c | 14 ++ hw/virtio/virtio-mem.c | 11 ++ hw/virtio/virtio.c | 297 ++++++++++++++++++++++++++++++++- 16 files changed, 646 insertions(+), 29 deletions(-) diff --git a/qapi/virtio.json b/qapi/virtio.json index ba61d83df7..474a8bd64e 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -106,10 +106,10 @@ 'n-tmp-sections': 'int', 'nvqs': 'uint32', 'vq-index': 'int', - 'features': 'uint64', - 'acked-features': 'uint64', - 'backend-features': 'uint64', - 'protocol-features': 'uint64', + 'features': 'VirtioDeviceFeatures', + 'acked-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', + 'protocol-features': 'VhostDeviceProtocols', 'max-queues': 'uint64', 'backend-cap': 'uint64', 'log-enabled': 'bool', @@ -176,11 +176,11 @@ 'device-id': 'uint16', 'vhost-started': 'bool', 'device-endian': 'str', - 'guest-features': 'uint64', - 'host-features': 'uint64', - 'backend-features': 'uint64', + 'guest-features': 'VirtioDeviceFeatures', + 'host-features': 'VirtioDeviceFeatures', + 'backend-features': 'VirtioDeviceFeatures', 'num-vqs': 'int', - 'status': 'uint8', + 'status': 'VirtioDeviceStatus', 'isr': 'uint8', 'queue-sel': 'uint16', 'vm-running': 'bool', @@ -222,14 +222,28 @@ # "name": "virtio-crypto", # "started": true, # "device-id": 20, -# "backend-features": 0, +# "backend-features": { +# "transports": [], +# "dev-features": [] +# }, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "statuses": ["ACKNOWLEDGE", "DRIVER", "FEATURES_OK", +# "DRIVER_OK"] +# }, # "num-vqs": 2, -# "guest-features": 5100273664, -# "host-features": 6325010432, +# "guest-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1"], +# "dev-features": [] +# }, +# "host-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", +# "INDIRECT_DESC", "VERSION_1", "ANY_LAYOUT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": [] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 1, @@ -257,22 +271,65 @@ # "max-queues": 1, # "backend-cap": 2, # "log-size": 0, -# "backend-features": 0, +# "backend-features": { +# "transports": [], +# "dev-features": [] +# }, # "nvqs": 2, -# "protocol-features": 0, +# "protocol-features": { +# "protocols": [] +# }, # "vq-index": 0, # "log-enabled": false, -# "acked-features": 5100306432, -# "features": 13908344832 +# "acked-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1= ", +# "ANY_LAYOUT", "NOTIFY_ON_EMPTY"], +# "dev-features": ["MRG_RXBUF"] +# }, +# "features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", +# "IOMMU_PLATFORM", "VERSION_1", "ANY_LAYO= UT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": ["LOG_ALL", "MRG_RXBUF"] +# } +# }, +# "backend-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", "INDIRECT= _DESC", +# "VERSION_1", "ANY_LAYOUT", "NOTIFY_ON_EMPTY= "], +# "dev-features": ["GSO", "CTRL_MAC_ADDR", "GUEST_ANNOUNCE",= "CTRL_RX_EXTRA", +# "CTRL_VLAN", "CTRL_RX", "CTRL_VQ", "STATU= S", "MRG_RXBUF", +# "HOST_UFO", "HOST_ECN", "HOST_TSO6", "HOS= T_TSO4", +# "GUEST_UFO", "GUEST_ECN", "GUEST_TSO6", "= GUEST_TSO4", +# "MAC", "CTRL_GUEST_OFFLOADS", "GUEST_CSUM= ", "CSUM"] # }, -# "backend-features": 6337593319, # "start-on-kick": false, # "isr": 1, # "broken": false, -# "status": 15, +# "status": { +# "statuses": ["ACKNOWLEDGE", "DRIVER", "FEATURES_OK", "DRIV= ER_OK"] +# }, # "num-vqs": 3, -# "guest-features": 5111807911, -# "host-features": 6337593319, +# "guest-features": { +# "transports": ["EVENT_IDX", "INDIRECT_DESC", "VERSION_1"], +# "dev-features": ["CTRL_MAC_ADDR", "GUEST_ANNOUNCE", "CTRL_= VLAN", +# "CTRL_RX", "CTRL_VQ", "STATUS", "MRG_RXBU= F", +# "HOST_UFO", "HOST_ECN", "HOST_TSO6", +# "HOST_TSO4", "GUEST_UFO", "GUEST_ECN", +# "GUEST_TSO6", "GUEST_TSO4", "MAC", +# "CTRL_GUEST_OFFLOADS", "GUEST_CSUM", "CSU= M"] +# }, +# "host-features": { +# "transports": ["PROTOCOL_FEATURES", "EVENT_IDX", +# "INDIRECT_DESC", "VERSION_1", "ANY_LAYOUT", +# "NOTIFY_ON_EMPTY"], +# "dev-features": ["GSO", "CTRL_MAC_ADDR", "GUEST_ANNOUNCE", +# "CTRL_RX_EXTRA", "CTRL_VLAN", "CTRL_RX", +# "CTRL_VQ", "STATUS", "MRG_RXBUF", "HOST_U= FO", +# "HOST_ECN", "HOST_TSO4", "HOST_TSO4", +# "GUEST_UFO", "GUEST_ECN", "GUEST_TSO6", +# "GUEST_TSO4", "MAC", "CTRL_GUEST_OFFLOADS= ", +# "GUEST_CSUM", "CSUM"] +# }, # "use-guest-notifier-mask": true, # "vm-running": true, # "queue-sel": 2, @@ -288,3 +345,62 @@ 'data': { 'path': 'str' }, 'returns': 'VirtioStatus', 'features': [ 'unstable' ] } + +## +# @VirtioDeviceStatus: +# +# A structure defined to list the configuration statuses of a virtio +# device +# +# @statuses: List of decoded configuration statuses of the virtio +# device +# +# @unknown-statuses: Virtio device statuses bitmap that have not been deco= ded +# +# Since: 7.0 +## + +{ 'struct': 'VirtioDeviceStatus', + 'data': { 'statuses': [ 'str' ], + '*unknown-statuses': 'uint8' } } + +## +# @VhostDeviceProtocols: +# +# A structure defined to list the vhost user protocol features of a +# Vhost User device +# +# @protocols: List of decoded vhost user protocol features of a vhost +# user device +# +# @unknown-protocols: Vhost user device protocol features bitmap that +# have not been decoded +# +# Since: 7.0 +## + +{ 'struct': 'VhostDeviceProtocols', + 'data': { 'protocols': [ 'str' ], + '*unknown-protocols': 'uint64' } } + +## +# @VirtioDeviceFeatures: +# +# The common fields that apply to most Virtio devices. Some devices +# may not have their own device-specific features (e.g. virtio-rng). +# +# @transports: List of transport features of the virtio device +# +# @dev-features: List of device-specific features (if the device has +# unique features) +# +# @unknown-dev-features: Virtio device features bitmap that have not +# been decoded +# +# Since: 7.0 +## + +{ 'struct': 'VirtioDeviceFeatures', + 'data': { 'transports': [ 'str' ], + '*dev-features': [ 'str' ], + '*unknown-dev-features': 'uint64' } } diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 58a73e7b7a..4aaa21faf6 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -5,6 +5,9 @@ #include "hw/virtio/virtio.h" #include "exec/memory.h" =20 +#define VHOST_F_DEVICE_IOTLB 63 +#define VHOST_USER_F_PROTOCOL_FEATURES 30 + /* Generic structures common for any vhost based device. */ =20 struct vhost_inflight { diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 8f4e4c12a6..183d431b5a 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -71,6 +71,24 @@ typedef struct VirtQueueElement #define TYPE_VIRTIO_DEVICE "virtio-device" OBJECT_DECLARE_TYPE(VirtIODevice, VirtioDeviceClass, VIRTIO_DEVICE) =20 +typedef struct { + int virtio_bit; + const char *feature_name; +} qmp_virtio_feature_map_t; + +extern qmp_virtio_feature_map_t serial_map[]; +extern qmp_virtio_feature_map_t blk_map[]; +extern qmp_virtio_feature_map_t gpu_map[]; +extern qmp_virtio_feature_map_t net_map[]; +extern qmp_virtio_feature_map_t scsi_map[]; +extern qmp_virtio_feature_map_t balloon_map[]; +extern qmp_virtio_feature_map_t iommu_map[]; +extern qmp_virtio_feature_map_t input_map[]; +extern qmp_virtio_feature_map_t fs_map[]; +extern qmp_virtio_feature_map_t vsock_map[]; +extern qmp_virtio_feature_map_t crypto_map[]; +extern qmp_virtio_feature_map_t mem_map[]; + enum virtio_device_endian { VIRTIO_DEVICE_ENDIAN_UNKNOWN, VIRTIO_DEVICE_ENDIAN_LITTLE, diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 2e3809dafa..55d291ed7a 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -13,6 +13,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "qemu/error-report.h" @@ -32,10 +33,38 @@ #include "hw/virtio/virtio-bus.h" #include "migration/qemu-file-types.h" #include "hw/virtio/virtio-access.h" +#include "standard-headers/linux/vhost_types.h" =20 /* Config size before the discard support (hide associated config fields) = */ #define VIRTIO_BLK_CFG_SIZE offsetof(struct virtio_blk_config, \ max_discard_sectors) + +qmp_virtio_feature_map_t blk_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BLK_F_##name, #name } + FEATURE_ENTRY(SIZE_MAX), + FEATURE_ENTRY(SEG_MAX), + FEATURE_ENTRY(GEOMETRY), + FEATURE_ENTRY(RO), + FEATURE_ENTRY(BLK_SIZE), + FEATURE_ENTRY(TOPOLOGY), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(DISCARD), + FEATURE_ENTRY(WRITE_ZEROES), +#ifndef VIRTIO_BLK_NO_LEGACY + FEATURE_ENTRY(BARRIER), + FEATURE_ENTRY(SCSI), + FEATURE_ENTRY(FLUSH), + FEATURE_ENTRY(CONFIG_WCE), +#endif /* !VIRTIO_BLK_NO_LEGACY */ +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * Starting from the discard feature, we can use this array to properly * set the config size depending on the features enabled. diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 9f19fd0672..9de257541d 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -32,6 +33,16 @@ #include "hw/virtio/virtio-serial.h" #include "hw/virtio/virtio-access.h" =20 +qmp_virtio_feature_map_t serial_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_CONSOLE_F_##name, #name } + FEATURE_ENTRY(SIZE), + FEATURE_ENTRY(MULTIPORT), + FEATURE_ENTRY(EMERG_WRITE), +#undef FEATURE_ENTRY + { -1, "" } +}; + static struct VirtIOSerialDevices { QLIST_HEAD(, VirtIOSerial) devices; } vserdevices; diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 8ba5da4312..796786ab40 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -12,13 +12,29 @@ */ =20 #include "qemu/osdep.h" - +#include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-gpu.h" #include "migration/blocker.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" =20 +qmp_virtio_feature_map_t gpu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_GPU_F_##name, #name } + FEATURE_ENTRY(VIRGL), + FEATURE_ENTRY(EDID), + FEATURE_ENTRY(RESOURCE_UUID), + FEATURE_ENTRY(RESOURCE_BLOB), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + void virtio_gpu_base_reset(VirtIOGPUBase *g) { diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c index 5b5398b3ca..fe0ed6d5b4 100644 --- a/hw/input/virtio-input.c +++ b/hw/input/virtio-input.c @@ -6,6 +6,7 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/iov.h" #include "qemu/module.h" #include "trace.h" @@ -14,10 +15,19 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-input.h" =20 +#include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/input.h" =20 #define VIRTIO_INPUT_VM_VERSION 1 =20 +qmp_virtio_feature_map_t input_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* ----------------------------------------------------------------- */ =20 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 21328dc547..db3d4a0e0b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -35,9 +35,11 @@ #include "hw/qdev-properties.h" #include "qapi/qapi-types-migration.h" #include "qapi/qapi-events-migration.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/virtio/virtio-access.h" #include "migration/misc.h" #include "standard-headers/linux/ethtool.h" +#include "standard-headers/linux/vhost_types.h" #include "sysemu/sysemu.h" #include "trace.h" #include "monitor/qdev.h" @@ -90,6 +92,51 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) =20 +qmp_virtio_feature_map_t net_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_NET_F_##name, #name } + FEATURE_ENTRY(CSUM), + FEATURE_ENTRY(GUEST_CSUM), + FEATURE_ENTRY(CTRL_GUEST_OFFLOADS), + FEATURE_ENTRY(MTU), + FEATURE_ENTRY(MAC), + FEATURE_ENTRY(GUEST_TSO4), + FEATURE_ENTRY(GUEST_TSO6), + FEATURE_ENTRY(GUEST_ECN), + FEATURE_ENTRY(GUEST_UFO), + FEATURE_ENTRY(HOST_TSO4), + FEATURE_ENTRY(HOST_TSO6), + FEATURE_ENTRY(HOST_ECN), + FEATURE_ENTRY(HOST_UFO), + FEATURE_ENTRY(MRG_RXBUF), + FEATURE_ENTRY(STATUS), + FEATURE_ENTRY(CTRL_VQ), + FEATURE_ENTRY(CTRL_RX), + FEATURE_ENTRY(CTRL_VLAN), + FEATURE_ENTRY(CTRL_RX_EXTRA), + FEATURE_ENTRY(GUEST_ANNOUNCE), + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(CTRL_MAC_ADDR), + FEATURE_ENTRY(HASH_REPORT), + FEATURE_ENTRY(RSS), + FEATURE_ENTRY(RSC_EXT), + FEATURE_ENTRY(STANDBY), + FEATURE_ENTRY(SPEED_DUPLEX), +#ifndef VIRTIO_NET_NO_LEGACY + FEATURE_ENTRY(GSO), +#endif /* VIRTIO_NET_NO_LEGACY */ +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_NET_F_##name, #name } + FEATURE_ENTRY(VIRTIO_NET_HDR), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + static const VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 2a6141d081..9ca8faa40e 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -15,7 +15,9 @@ =20 #include "qemu/osdep.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" #include "hw/virtio/virtio-scsi.h" #include "migration/qemu-file-types.h" #include "qemu/error-report.h" @@ -29,6 +31,21 @@ #include "hw/virtio/virtio-access.h" #include "trace.h" =20 +qmp_virtio_feature_map_t scsi_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_SCSI_F_##name, #name } + FEATURE_ENTRY(INOUT), + FEATURE_ENTRY(HOTPLUG), + FEATURE_ENTRY(CHANGE), + FEATURE_ENTRY(T10_PI), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + static inline int virtio_scsi_get_lun(uint8_t *lun) { return ((lun[2] << 8) | lun[3]) & 0x3FFF; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index e513e4fdda..096cc07c44 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -15,6 +15,7 @@ #include #include "standard-headers/linux/virtio_fs.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "hw/virtio/virtio-bus.h" @@ -23,6 +24,15 @@ #include "hw/virtio/vhost-user-fs.h" #include "monitor/monitor.h" #include "sysemu/sysemu.h" +#include "standard-headers/linux/vhost_types.h" + +qmp_virtio_feature_map_t fs_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; =20 static const int user_feature_bits[] =3D { VIRTIO_F_VERSION_1, diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 416daf8554..047ebb7bd2 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -11,12 +11,22 @@ #include "qemu/osdep.h" #include "standard-headers/linux/virtio_vsock.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "hw/virtio/virtio-access.h" #include "qemu/error-report.h" #include "hw/qdev-properties.h" #include "hw/virtio/vhost-vsock.h" #include "qemu/iov.h" #include "monitor/monitor.h" +#include "standard-headers/linux/vhost_types.h" + +qmp_virtio_feature_map_t vsock_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; =20 const int feature_bits[] =3D { VIRTIO_VSOCK_F_SEQPACKET, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 236542fb53..6705314fd8 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -27,6 +27,7 @@ #include "qapi/error.h" #include "qapi/qapi-events-machine.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "trace.h" #include "qemu/error-report.h" #include "migration/misc.h" @@ -37,6 +38,19 @@ =20 #define BALLOON_PAGE_SIZE (1 << VIRTIO_BALLOON_PFN_SHIFT) =20 +qmp_virtio_feature_map_t balloon_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_BALLOON_F_##name, #name } + FEATURE_ENTRY(MUST_TELL_HOST), + FEATURE_ENTRY(STATS_VQ), + FEATURE_ENTRY(DEFLATE_ON_OOM), + FEATURE_ENTRY(FREE_PAGE_HINT), + FEATURE_ENTRY(PAGE_POISON), + FEATURE_ENTRY(REPORTING), +#undef FEATURE_ENTRY + { -1, "" } +}; + typedef struct PartiallyBalloonedPage { ram_addr_t base_gpa; unsigned long *bitmap; diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 7d63b8c9a8..b938bd8964 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -16,6 +16,7 @@ #include "qemu/main-loop.h" #include "qemu/module.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" =20 #include "hw/virtio/virtio.h" @@ -23,10 +24,19 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-access.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" #include "sysemu/cryptodev-vhost.h" =20 #define VIRTIO_CRYPTO_VM_VERSION 1 =20 +qmp_virtio_feature_map_t crypto_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_F_##name, #name } + FEATURE_ENTRY(LOG_ALL), +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * Transfer virtqueue index to crypto queue index. * The control virtqueue is after the data virtqueues diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 15b3fa05de..bbb738201f 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" #include "qapi/error.h" +#include "qapi/qapi-visit-virtio.h" #include "qemu/error-report.h" #include "trace.h" =20 @@ -40,6 +41,19 @@ #define VIOMMU_DEFAULT_QUEUE_SIZE 256 #define VIOMMU_PROBE_SIZE 512 =20 +qmp_virtio_feature_map_t iommu_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_IOMMU_F_##name, #name } + FEATURE_ENTRY(INPUT_RANGE), + FEATURE_ENTRY(DOMAIN_RANGE), + FEATURE_ENTRY(MAP_UNMAP), + FEATURE_ENTRY(BYPASS), + FEATURE_ENTRY(PROBE), + FEATURE_ENTRY(MMIO), +#undef FEATURE_ENTRY + { -1, "" } +}; + typedef struct VirtIOIOMMUDomain { uint32_t id; GTree *mappings; diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 465a996214..31e7af834e 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio-mem.h" #include "qapi/error.h" #include "qapi/visitor.h" +#include "qapi/qapi-visit-virtio.h" #include "exec/ram_addr.h" #include "migration/misc.h" #include "hw/boards.h" @@ -32,6 +33,16 @@ #include CONFIG_DEVICES #include "trace.h" =20 +qmp_virtio_feature_map_t mem_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_MEM_F_##name, #name } +#ifndef CONFIG_ACPI + FEATURE_ENTRY(ACPI_PXM), +#endif /* CONFIG_ACPI */ +#undef FEATURE_ENTRY + { -1, "" } +}; + /* * We only had legacy x86 guests that did not support * VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE. Other targets don't have legacy gu= ests. diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 59665f7d62..ccb5e2bd9e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -34,10 +34,99 @@ #include "sysemu/dma.h" #include "sysemu/runstate.h" #include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/vhost_types.h" +#include CONFIG_DEVICES =20 /* QAPI list of realized VirtIODevices */ static QTAILQ_HEAD(, VirtIODevice) virtio_list; =20 +/* + * Maximum size of virtio device config space + */ +#define VHOST_USER_MAX_CONFIG_SIZE 256 + +enum VhostUserProtocolFeature { + VHOST_USER_PROTOCOL_F_MQ =3D 0, + VHOST_USER_PROTOCOL_F_LOG_SHMFD =3D 1, + VHOST_USER_PROTOCOL_F_RARP =3D 2, + VHOST_USER_PROTOCOL_F_REPLY_ACK =3D 3, + VHOST_USER_PROTOCOL_F_NET_MTU =3D 4, + VHOST_USER_PROTOCOL_F_SLAVE_REQ =3D 5, + VHOST_USER_PROTOCOL_F_CROSS_ENDIAN =3D 6, + VHOST_USER_PROTOCOL_F_CRYPTO_SESSION =3D 7, + VHOST_USER_PROTOCOL_F_PAGEFAULT =3D 8, + VHOST_USER_PROTOCOL_F_CONFIG =3D 9, + VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD =3D 10, + VHOST_USER_PROTOCOL_F_HOST_NOTIFIER =3D 11, + VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD =3D 12, + VHOST_USER_PROTOCOL_F_RESET_DEVICE =3D 13, + VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS =3D 14, + VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS =3D 15, + VHOST_USER_PROTOCOL_F_MAX +}; + +static qmp_virtio_feature_map_t transport_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VIRTIO_F_##name, #name } +#ifndef VIRTIO_CONFIG_NO_LEGACY + FEATURE_ENTRY(NOTIFY_ON_EMPTY), + FEATURE_ENTRY(ANY_LAYOUT), +#endif /* VIRTIO_CONFIG_NO_LEGACY */ + FEATURE_ENTRY(VERSION_1), + FEATURE_ENTRY(IOMMU_PLATFORM), + FEATURE_ENTRY(RING_PACKED), + FEATURE_ENTRY(ORDER_PLATFORM), + FEATURE_ENTRY(SR_IOV), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VIRTIO_RING_F_##name, #name } + FEATURE_ENTRY(INDIRECT_DESC), + FEATURE_ENTRY(EVENT_IDX), +#undef FEATURE_ENTRY +#define FEATURE_ENTRY(name) \ + { VHOST_USER_F_##name, #name } + FEATURE_ENTRY(PROTOCOL_FEATURES), +#undef FEATURE_ENTRY + { -1, "" } +}; + +static qmp_virtio_feature_map_t vhost_user_protocol_map[] =3D { +#define FEATURE_ENTRY(name) \ + { VHOST_USER_PROTOCOL_F_##name, #name } + FEATURE_ENTRY(MQ), + FEATURE_ENTRY(LOG_SHMFD), + FEATURE_ENTRY(RARP), + FEATURE_ENTRY(REPLY_ACK), + FEATURE_ENTRY(NET_MTU), + FEATURE_ENTRY(SLAVE_REQ), + FEATURE_ENTRY(CROSS_ENDIAN), + FEATURE_ENTRY(CRYPTO_SESSION), + FEATURE_ENTRY(PAGEFAULT), + FEATURE_ENTRY(CONFIG), + FEATURE_ENTRY(SLAVE_SEND_FD), + FEATURE_ENTRY(HOST_NOTIFIER), + FEATURE_ENTRY(INFLIGHT_SHMFD), + FEATURE_ENTRY(RESET_DEVICE), + FEATURE_ENTRY(INBAND_NOTIFICATIONS), + FEATURE_ENTRY(CONFIGURE_MEM_SLOTS), +#undef FEATURE_ENTRY + { -1, "" } +}; + +/* virtio device configuration statuses */ +static qmp_virtio_feature_map_t config_status_map[] =3D { +#define STATUS_ENTRY(name) \ + { VIRTIO_CONFIG_S_##name, #name } + STATUS_ENTRY(DRIVER_OK), + STATUS_ENTRY(FEATURES_OK), + STATUS_ENTRY(DRIVER), + STATUS_ENTRY(NEEDS_RESET), + STATUS_ENTRY(FAILED), + STATUS_ENTRY(ACKNOWLEDGE), +#undef STATUS_ENTRY + { -1, "" } +}; + /* * The alignment to use between consumer and producer parts of vring. * x86 pagesize again. This is the default, used by transports like PCI @@ -3963,6 +4052,191 @@ static VirtIODevice *virtio_device_find(const char = *path) return NULL; } =20 +#define CONVERT_FEATURES(type, map, is_status, bitmap) \ + ({ \ + type *list =3D NULL; \ + type *node; \ + for (i =3D 0; map[i].virtio_bit !=3D -1; i++) { \ + if (is_status) { \ + bit =3D map[i].virtio_bit; \ + } \ + else { \ + bit =3D 1ULL << map[i].virtio_bit; \ + } \ + if ((bitmap & bit) =3D=3D 0) { \ + continue; \ + } \ + node =3D g_new0(type, 1); \ + node->value =3D g_strdup(map[i].feature_name); \ + node->next =3D list; \ + list =3D node; \ + bitmap ^=3D bit; \ + } \ + list; \ + }) + +static VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap) +{ + VirtioDeviceStatus *status; + uint8_t bit; + int i; + + status =3D g_new0(VirtioDeviceStatus, 1); + status->statuses =3D CONVERT_FEATURES(strList, config_status_map, 1, b= itmap); + status->has_unknown_statuses =3D bitmap !=3D 0; + if (status->has_unknown_statuses) { + status->unknown_statuses =3D bitmap; + } + + return status; +} + +static VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap) +{ + VhostDeviceProtocols *vhu_protocols; + uint64_t bit; + int i; + + vhu_protocols =3D g_new0(VhostDeviceProtocols, 1); + vhu_protocols->protocols =3D + CONVERT_FEATURES(strList, + vhost_user_protocol_map, 0, bitmap); + vhu_protocols->has_unknown_protocols =3D bitmap !=3D 0; + if (vhu_protocols->has_unknown_protocols) { + vhu_protocols->unknown_protocols =3D bitmap; + } + + return vhu_protocols; +} + +static VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, + uint64_t bitmap) +{ + VirtioDeviceFeatures *features; + uint64_t bit; + int i; + + features =3D g_new0(VirtioDeviceFeatures, 1); + features->has_dev_features =3D true; + + /* transport features */ + features->transports =3D CONVERT_FEATURES(strList, transport_map, 0, b= itmap); + + /* device features */ + switch (device_id) { +#ifdef CONFIG_VIRTIO_SERIAL + case VIRTIO_ID_CONSOLE: + features->dev_features =3D + CONVERT_FEATURES(strList, serial_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_BLK + case VIRTIO_ID_BLOCK: + features->dev_features =3D + CONVERT_FEATURES(strList, blk_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_GPU + case VIRTIO_ID_GPU: + features->dev_features =3D + CONVERT_FEATURES(strList, gpu_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_NET + case VIRTIO_ID_NET: + features->dev_features =3D + CONVERT_FEATURES(strList, net_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_SCSI + case VIRTIO_ID_SCSI: + features->dev_features =3D + CONVERT_FEATURES(strList, scsi_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_BALLOON + case VIRTIO_ID_BALLOON: + features->dev_features =3D + CONVERT_FEATURES(strList, balloon_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_IOMMU + case VIRTIO_ID_IOMMU: + features->dev_features =3D + CONVERT_FEATURES(strList, iommu_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_INPUT + case VIRTIO_ID_INPUT: + features->dev_features =3D + CONVERT_FEATURES(strList, input_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VHOST_USER_FS + case VIRTIO_ID_FS: + features->dev_features =3D + CONVERT_FEATURES(strList, fs_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VHOST_VSOCK + case VIRTIO_ID_VSOCK: + features->dev_features =3D + CONVERT_FEATURES(strList, vsock_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_CRYPTO + case VIRTIO_ID_CRYPTO: + features->dev_features =3D + CONVERT_FEATURES(strList, crypto_map, 0, bitmap); + break; +#endif +#ifdef CONFIG_VIRTIO_MEM + case VIRTIO_ID_MEM: + features->dev_features =3D + CONVERT_FEATURES(strList, mem_map, 0, bitmap); + break; +#endif + /* No features */ + case VIRTIO_ID_9P: + case VIRTIO_ID_PMEM: + case VIRTIO_ID_RNG: + case VIRTIO_ID_IOMEM: + case VIRTIO_ID_RPMSG: + case VIRTIO_ID_CLOCK: + case VIRTIO_ID_MAC80211_WLAN: + case VIRTIO_ID_MAC80211_HWSIM: + case VIRTIO_ID_RPROC_SERIAL: + case VIRTIO_ID_MEMORY_BALLOON: + case VIRTIO_ID_CAIF: + case VIRTIO_ID_SIGNAL_DIST: + case VIRTIO_ID_PSTORE: + case VIRTIO_ID_SOUND: + case VIRTIO_ID_BT: + case VIRTIO_ID_I2C_ADAPTER: + case VIRTIO_ID_RPMB: + case VIRTIO_ID_VIDEO_ENCODER: + case VIRTIO_ID_VIDEO_DECODER: + case VIRTIO_ID_SCMI: + case VIRTIO_ID_NITRO_SEC_MOD: + case VIRTIO_ID_WATCHDOG: + case VIRTIO_ID_CAN: + case VIRTIO_ID_DMABUF: + case VIRTIO_ID_PARAM_SERV: + case VIRTIO_ID_AUDIO_POLICY: + case VIRTIO_ID_GPIO: + break; + default: + g_assert_not_reached(); + } + + features->has_unknown_dev_features =3D bitmap !=3D 0; + if (features->has_unknown_dev_features) { + features->unknown_dev_features =3D bitmap; + } + + return features; +} + VirtioStatus *qmp_x_query_virtio_status(const char *path, Error **errp) { VirtIODevice *vdev; @@ -3978,9 +4252,12 @@ VirtioStatus *qmp_x_query_virtio_status(const char *= path, Error **errp) status->name =3D g_strdup(vdev->name); status->device_id =3D vdev->device_id; status->vhost_started =3D vdev->vhost_started; - status->guest_features =3D vdev->guest_features; - status->host_features =3D vdev->host_features; - status->backend_features =3D vdev->backend_features; + status->guest_features =3D qmp_decode_features(vdev->device_id, + vdev->guest_features); + status->host_features =3D qmp_decode_features(vdev->device_id, + vdev->host_features); + status->backend_features =3D qmp_decode_features(vdev->device_id, + vdev->backend_features); =20 switch (vdev->device_endian) { case VIRTIO_DEVICE_ENDIAN_LITTLE: @@ -3995,7 +4272,7 @@ VirtioStatus *qmp_x_query_virtio_status(const char *p= ath, Error **errp) } =20 status->num_vqs =3D virtio_get_num_queues(vdev); - status->status =3D vdev->status; + status->status =3D qmp_decode_status(vdev->status); status->isr =3D vdev->isr; status->queue_sel =3D vdev->queue_sel; status->vm_running =3D vdev->vm_running; @@ -4018,10 +4295,14 @@ VirtioStatus *qmp_x_query_virtio_status(const char = *path, Error **errp) status->vhost_dev->n_tmp_sections =3D hdev->n_tmp_sections; status->vhost_dev->nvqs =3D hdev->nvqs; status->vhost_dev->vq_index =3D hdev->vq_index; - status->vhost_dev->features =3D hdev->features; - status->vhost_dev->acked_features =3D hdev->acked_features; - status->vhost_dev->backend_features =3D hdev->backend_features; - status->vhost_dev->protocol_features =3D hdev->protocol_features; + status->vhost_dev->features =3D + qmp_decode_features(vdev->device_id, hdev->features); + status->vhost_dev->acked_features =3D + qmp_decode_features(vdev->device_id, hdev->acked_features); + status->vhost_dev->backend_features =3D + qmp_decode_features(vdev->device_id, hdev->backend_features); + status->vhost_dev->protocol_features =3D + qmp_decode_protocols(hdev->protocol_features); status->vhost_dev->max_queues =3D hdev->max_queues; status->vhost_dev->backend_cap =3D hdev->backend_cap; status->vhost_dev->log_enabled =3D hdev->log_enabled; --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026999181339.08927852993577; Fri, 4 Feb 2022 18:09:59 -0800 (PST) Received: from localhost ([::1]:58146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAWU-0001S9-3z for importer@patchew.org; Fri, 04 Feb 2022 21:09:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA8O-00058B-BS for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:45:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA8K-0003V2-TK for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:45:03 -0500 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-zDop1zxhO0i_tWhPVK5bDA-1; Fri, 04 Feb 2022 20:44:59 -0500 Received: by mail-wm1-f72.google.com with SMTP id h82-20020a1c2155000000b003552c13626cso4010477wmh.3 for ; Fri, 04 Feb 2022 17:44:59 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id x6sm4048114wrn.18.2022.02.04.17.44.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:44:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025500; 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: in-reply-to:in-reply-to:references:references; bh=/f/W4jxON+Bfi2dMMHUbDDt+ACs7fcd46TTHm0ivXtU=; b=ht/DA1UXrFvj3iLPKVtCArlnVwnY5j0LqQ5GqsIsvshmX5ssHXB+kQ2Ipd6NYTE+KZHVdd JkPpJP2lw8kyuFQZIPpOvdJU04xl90jq//94OG4JzNxxPT6X7oCV+IvmI0ao+qtQnQeXqy 8CSXZh1TJyGZqM3zjc+zB2Sgp25OYI8= X-MC-Unique: zDop1zxhO0i_tWhPVK5bDA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/f/W4jxON+Bfi2dMMHUbDDt+ACs7fcd46TTHm0ivXtU=; b=xY+FxC9nl8prVg2Iq0N2qzIlZohYpPNc/LMBcpwCmjzA+Yr5u7ypfFUmXzzDSQ4Tvi fahbsWCN6uRM9VtXNKNJ9jpJMHMG+lHxz4VZTIixPdbsjxXmUaFner8A7vb+kdKpycWK oFIGhzjGjkG0BWNi+uMOz6Tt5NhBnyRyhCHrsVagbtwyQmJX27pN7o23F4F6BjuPSzAM ANli7aZKTDiBiJwxtluovZQEjfbITmFdsc7Rx02QnEQGugzjTvdp3orHusIltna+YwlW RlSgN2ZvqzrGnePoIdgLTjmdbDqw4dvPG5CPXtgIwbKJNsB7IhJSAv5jCrmSKyfXCbi9 Mwug== X-Gm-Message-State: AOAM532XYhWkTntgkWkJv7iooKbGN7vpE6k1n6dI7KmberKuGwMadiUX o6NEcUGOY7f+x6aRt2yKr5EB/A1sGHAt2eqfdiJFIVY/Iy/JUlh79H0ncOgPs3CdvIcwyq+usRt zeAFQagy4hEsIyQFj6OfFWw02sS6jnHAgdnwtIy5JtRMDDTFjX0rBJboZWUdx X-Received: by 2002:a5d:51d0:: with SMTP id n16mr1198705wrv.464.1644025497127; Fri, 04 Feb 2022 17:44:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7+Y1GanRD99irNuYZDSXTnYabC4X6zVlVXnoIeUEKVpNZjIOsu5Z4pxUiFd10cwda2HRmJg== X-Received: by 2002:a5d:51d0:: with SMTP id n16mr1198693wrv.464.1644025496856; Fri, 04 Feb 2022 17:44:56 -0800 (PST) Date: Fri, 4 Feb 2022 20:44:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 20/32] qmp: add QMP commands for virtio/vhost queue-status Message-ID: <20220205014149.1189026-21-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Laurent Vivier , Peter Maydell , Eric Blake , Markus Armbruster , Jonah Palmer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027001184100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier These new commands show the internal status of a VirtIODevice's VirtQueue and a vhost device's vhost_virtqueue (if active). Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-7-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/virtio.json | 252 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-stub.c | 14 +++ hw/virtio/virtio.c | 103 ++++++++++++++++ 3 files changed, 369 insertions(+) diff --git a/qapi/virtio.json b/qapi/virtio.json index 474a8bd64e..44cc05ceeb 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -404,3 +404,255 @@ 'data': { 'transports': [ 'str' ], '*dev-features': [ 'str' ], '*unknown-dev-features': 'uint64' } } + +## +# @VirtQueueStatus: +# +# Information of a VirtIODevice VirtQueue, including most members of +# the VirtQueue data structure. +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @queue-index: VirtQueue queue_index +# +# @inuse: VirtQueue inuse +# +# @vring-num: VirtQueue vring.num +# +# @vring-num-default: VirtQueue vring.num_default +# +# @vring-align: VirtQueue vring.align +# +# @vring-desc: VirtQueue vring.desc (descriptor area) +# +# @vring-avail: VirtQueue vring.avail (driver area) +# +# @vring-used: VirtQueue vring.used (device area) +# +# @last-avail-idx: VirtQueue last_avail_idx or return of vhost_dev +# vhost_get_vring_base (if vhost active) +# +# @shadow-avail-idx: VirtQueue shadow_avail_idx +# +# @used-idx: VirtQueue used_idx +# +# @signalled-used: VirtQueue signalled_used +# +# @signalled-used-valid: VirtQueue signalled_used_valid flag +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtQueueStatus', + 'data': { 'name': 'str', + 'queue-index': 'uint16', + 'inuse': 'uint32', + 'vring-num': 'uint32', + 'vring-num-default': 'uint32', + 'vring-align': 'uint32', + 'vring-desc': 'uint64', + 'vring-avail': 'uint64', + 'vring-used': 'uint64', + '*last-avail-idx': 'uint16', + '*shadow-avail-idx': 'uint16', + 'used-idx': 'uint16', + 'signalled-used': 'uint16', + 'signalled-used-valid': 'bool' } } + +## +# @x-query-virtio-queue-status: +# +# Return the status of a given VirtIODevice's VirtQueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtQueueStatus of the VirtQueue +# +# Notes: last_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device and +# the VirtIODevice VirtQueue index (queue) does not exist for +# the corresponding vhost device vhost_virtqueue. Also, +# shadow_avail_idx will not be displayed in the case where +# the selected VirtIODevice has a running vhost device. +# +# Since: 7.0 +# +# Examples: +# +# 1. Get VirtQueueStatus for virtio-vsock (vhost-vsock running) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "signalled-used": 0, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 5217370112, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5217372160, +# "queue-index": 1, +# "last-avail-idx": 0, +# "vring-used": 5217372480, +# "used-idx": 0, +# "name": "vhost-vsock", +# "vring-num": 128 } +# } +# +# 2. Get VirtQueueStatus for virtio-serial (no vhost) +# +# -> { "execute": "x-query-virtio-queue-status", +# "arguments": { "path": "/machine/peripheral-anon/device[0]/virtio-b= ackend", +# "queue": 20 } +# } +# <- { "return": { +# "signalled-used": 0, +# "inuse": 0, +# "vring-align": 4096, +# "vring-desc": 5182074880, +# "signalled-used-valid": false, +# "vring-num-default": 128, +# "vring-avail": 5182076928, +# "queue-index": 20, +# "last-avail-idx": 0, +# "vring-used": 5182077248, +# "used-idx": 0, +# "name": "virtio-serial", +# "shadow-avail-idx": 0, +# "vring-num": 128 } +# } +# +## + +{ 'command': 'x-query-virtio-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtQueueStatus', + 'features': [ 'unstable' ] } + +## +# @VirtVhostQueueStatus: +# +# Information of a vhost device's vhost_virtqueue, including most +# members of the vhost_dev vhost_virtqueue data structure. +# +# @name: Name of the VirtIODevice that uses this vhost_virtqueue +# +# @kick: vhost_virtqueue kick +# +# @call: vhost_virtqueue call +# +# @desc: vhost_virtqueue desc +# +# @avail: vhost_virtqueue avail +# +# @used: vhost_virtqueue used +# +# @num: vhost_virtqueue num +# +# @desc-phys: vhost_virtqueue desc_phys (descriptor area phys. addr.) +# +# @desc-size: vhost_virtqueue desc_size +# +# @avail-phys: vhost_virtqueue avail_phys (driver area phys. addr.) +# +# @avail-size: vhost_virtqueue avail_size +# +# @used-phys: vhost_virtqueue used_phys (device area phys. addr.) +# +# @used-size: vhost_virtqueue used_size +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtVhostQueueStatus', + 'data': { 'name': 'str', + 'kick': 'int', + 'call': 'int', + 'desc': 'uint64', + 'avail': 'uint64', + 'used': 'uint64', + 'num': 'int', + 'desc-phys': 'uint64', + 'desc-size': 'uint32', + 'avail-phys': 'uint64', + 'avail-size': 'uint32', + 'used-phys': 'uint64', + 'used-size': 'uint32' } } + +## +# @x-query-virtio-vhost-queue-status: +# +# Return information of a given vhost device's vhost_virtqueue +# +# @path: VirtIODevice canonical QOM path +# +# @queue: vhost_virtqueue index to examine +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtVhostQueueStatus of the vhost_virtqueue +# +# Since: 7.0 +# +# Examples: +# +# 1. Get vhost_virtqueue status for vhost-crypto +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5216124928, +# "used-phys": 5216127040, +# "avail-size": 2054, +# "desc-size": 16384, +# "used-size": 8198, +# "desc": 140141447430144, +# "num": 1024, +# "name": "virtio-crypto", +# "call": 0, +# "avail": 140141447446528, +# "desc-phys": 5216108544, +# "used": 140141447448640, +# "kick": 0 } +# } +# +# 2. Get vhost_virtqueue status for vhost-vsock +# +# -> { "execute": "x-query-virtio-vhost-queue-status", +# "arguments": { "path": "/machine/peripheral/vsock0/virtio-backend", +# "queue": 0 } +# } +# <- { "return": { +# "avail-phys": 5182261248, +# "used-phys": 5182261568, +# "avail-size": 262, +# "desc-size": 2048, +# "used-size": 1030, +# "desc": 140141413580800, +# "num": 128, +# "name": "vhost-vsock", +# "call": 0, +# "avail": 140141413582848, +# "desc-phys": 5182259200, +# "used": 140141413583168, +# "kick": 0 } +# } +# +## + +{ 'command': 'x-query-virtio-vhost-queue-status', + 'data': { 'path': 'str', 'queue': 'uint16' }, + 'returns': 'VirtVhostQueueStatus', + 'features': [ 'unstable' ] } diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 0b432e8de7..13e5f93652 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -17,3 +17,17 @@ VirtioStatus *qmp_x_query_virtio_status(const char *path= , Error **errp) { return qmp_virtio_unsupported(errp); } + +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *pa= th, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ccb5e2bd9e..8723a53b68 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4312,6 +4312,109 @@ VirtioStatus *qmp_x_query_virtio_status(const char = *path, Error **errp) return status; } =20 +VirtVhostQueueStatus *qmp_x_query_virtio_vhost_queue_status(const char *pa= th, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtVhostQueueStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (!vdev->vhost_started) { + error_setg(errp, "Error: vhost device has not started yet"); + return NULL; + } + + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev =3D vdc->get_vhost(vdev); + + if (queue < hdev->vq_index || queue >=3D hdev->vq_index + hdev->nvqs) { + error_setg(errp, "Invalid vhost virtqueue number %d", queue); + return NULL; + } + + status =3D g_new0(VirtVhostQueueStatus, 1); + status->name =3D g_strdup(vdev->name); + status->kick =3D hdev->vqs[queue].kick; + status->call =3D hdev->vqs[queue].call; + status->desc =3D (uint64_t)(unsigned long)hdev->vqs[queue].desc; + status->avail =3D (uint64_t)(unsigned long)hdev->vqs[queue].avail; + status->used =3D (uint64_t)(unsigned long)hdev->vqs[queue].used; + status->num =3D hdev->vqs[queue].num; + status->desc_phys =3D hdev->vqs[queue].desc_phys; + status->desc_size =3D hdev->vqs[queue].desc_size; + status->avail_phys =3D hdev->vqs[queue].avail_phys; + status->avail_size =3D hdev->vqs[queue].avail_size; + status->used_phys =3D hdev->vqs[queue].used_phys; + status->used_size =3D hdev->vqs[queue].used_size; + + return status; +} + +VirtQueueStatus *qmp_x_query_virtio_queue_status(const char *path, + uint16_t queue, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueueStatus *status; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIODevice", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + + status =3D g_new0(VirtQueueStatus, 1); + status->name =3D g_strdup(vdev->name); + status->queue_index =3D vdev->vq[queue].queue_index; + status->inuse =3D vdev->vq[queue].inuse; + status->vring_num =3D vdev->vq[queue].vring.num; + status->vring_num_default =3D vdev->vq[queue].vring.num_default; + status->vring_align =3D vdev->vq[queue].vring.align; + status->vring_desc =3D vdev->vq[queue].vring.desc; + status->vring_avail =3D vdev->vq[queue].vring.avail; + status->vring_used =3D vdev->vq[queue].vring.used; + status->used_idx =3D vdev->vq[queue].used_idx; + status->signalled_used =3D vdev->vq[queue].signalled_used; + status->signalled_used_valid =3D vdev->vq[queue].signalled_used_valid; + + if (vdev->vhost_started) { + VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *hdev =3D vdc->get_vhost(vdev); + + /* check if vq index exists for vhost as well */ + if (queue >=3D hdev->vq_index && queue < hdev->vq_index + hdev->nv= qs) { + status->has_last_avail_idx =3D true; + + int vhost_vq_index =3D + hdev->vhost_ops->vhost_get_vq_index(hdev, queue); + struct vhost_vring_state state =3D { + .index =3D vhost_vq_index, + }; + + status->last_avail_idx =3D + hdev->vhost_ops->vhost_get_vring_base(hdev, &state); + } + } else { + status->has_shadow_avail_idx =3D true; + status->has_last_avail_idx =3D true; + status->last_avail_idx =3D vdev->vq[queue].last_avail_idx; + status->shadow_avail_idx =3D vdev->vq[queue].shadow_avail_idx; + } + + return status; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027708848179.48692600156608; Fri, 4 Feb 2022 18:21:48 -0800 (PST) Received: from localhost ([::1]:55166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAhw-0001mG-43 for importer@patchew.org; Fri, 04 Feb 2022 21:21:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA8i-0005AS-MP for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:45:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA8V-0003h5-C6 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:45:13 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-248-gyKF-hQGPKmpQt2PiVQFzw-1; Fri, 04 Feb 2022 20:45:09 -0500 Received: by mail-wr1-f70.google.com with SMTP id d14-20020adfa34e000000b001e306be1ec8so69299wrb.17 for ; Fri, 04 Feb 2022 17:45:09 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id h6sm11323689wmq.26.2022.02.04.17.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025510; 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: in-reply-to:in-reply-to:references:references; bh=7oHwf0NYiJCKp5HOBO9BRKY/iEUjv1oAWKV79Qa6iUA=; b=ML7oQpW1MwksFCd21gm/MVkpLDDxj2DVe1QKvk8lto9bwL8rDXvVbc71h68FxKF6qb6p0X DIW7V4W7RinpZF4i48cqffd8D8NHRLDzIX86daEBMSAjJWib+0XRxPg+jAyzl3P4JZbReR Hq067iqAJP7IeSdp+VbwoHG0temG9kQ= X-MC-Unique: gyKF-hQGPKmpQt2PiVQFzw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7oHwf0NYiJCKp5HOBO9BRKY/iEUjv1oAWKV79Qa6iUA=; b=3jhbOw2Q7aIOrqMQoZOnJP2BHcQ92wTliBWov32jk5C7R2jz9ic1aXJk+C13OQGOOA W/Q9ES68k+gpSdhwK4Gctuyf53hCi7MJxnu1I/E8WjsclQfiF8ybqG17exSgrcuNewbn irYEFe52oEJlPWHNqWGewacjCByx80NIEv5fGD5aAJ5A2AylUhUhttOTAZUSY/v1mA5W MEYsPCW4NKw9clNxLh4aSlVA+VXffciKQKLens9tVxBJfQ8p3vicju6pqFM2TBB9/6my ydhI6nay+lbhSbXH4Fgmn5/7qMbpH5WIDMitz3YNPSyHqJViUxHTkwkssJxW18V7QBMB j6JA== X-Gm-Message-State: AOAM532YlBqZwMsaciJ3ujCrsfviHZ47GmYCWlxzDAVhywGdOr4P6OQx cyYHmeJ2QYezsaqYwlUckhQc7103N/5e3CvZwkYWrp3Gchy7sD8q6a8YMXIXgovGLZGuKRqDxIB PYLi/KXfZ/lhoaAGMmy8O/G7o9VywRT9ZrJVqEKko5xwAssdbjDwrXIZK4GgR X-Received: by 2002:adf:fa48:: with SMTP id y8mr1219142wrr.646.1644025507801; Fri, 04 Feb 2022 17:45:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfcqDZBjjYH8qGRChWk//avs2UC2b1cR8usacGjWA/V0pkD34UbGyxPVudjohJ8N/PuK7tLQ== X-Received: by 2002:adf:fa48:: with SMTP id y8mr1219119wrr.646.1644025507490; Fri, 04 Feb 2022 17:45:07 -0800 (PST) Date: Fri, 4 Feb 2022 20:45:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 21/32] qmp: add QMP command x-query-virtio-queue-element Message-ID: <20220205014149.1189026-22-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Laurent Vivier , Peter Maydell , Eric Blake , Markus Armbruster , Jonah Palmer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027710606100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This new command shows the information of a VirtQueue element. [Note: Up until v10 of this patch series, virtio.json had many (15+) enums defined (e.g. decoded device features, statuses, etc.). In v10 most of these enums were removed and replaced with string literals. By doing this we get (1) simpler schema, (2) smaller generated code, and (3) less maintenance burden for when new things are added (e.g. devices, device features, etc.).] Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-8-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/virtio.json | 183 ++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio-stub.c | 9 ++ hw/virtio/virtio.c | 154 +++++++++++++++++++++++++++++++++ 3 files changed, 346 insertions(+) diff --git a/qapi/virtio.json b/qapi/virtio.json index 44cc05ceeb..bb93d6df93 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -656,3 +656,186 @@ 'data': { 'path': 'str', 'queue': 'uint16' }, 'returns': 'VirtVhostQueueStatus', 'features': [ 'unstable' ] } + +## +# @VirtioRingDesc: +# +# Information regarding the vring descriptor area +# +# @addr: Guest physical address of the descriptor area +# +# @len: Length of the descriptor area +# +# @flags: List of descriptor flags +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingDesc', + 'data': { 'addr': 'uint64', + 'len': 'uint32', + 'flags': [ 'str' ] } } + +## +# @VirtioRingAvail: +# +# Information regarding the avail vring (a.k.a. driver area) +# +# @flags: VRingAvail flags +# +# @idx: VRingAvail index +# +# @ring: VRingAvail ring[] entry at provided index +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingAvail', + 'data': { 'flags': 'uint16', + 'idx': 'uint16', + 'ring': 'uint16' } } + +## +# @VirtioRingUsed: +# +# Information regarding the used vring (a.k.a. device area) +# +# @flags: VRingUsed flags +# +# @idx: VRingUsed index +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioRingUsed', + 'data': { 'flags': 'uint16', + 'idx': 'uint16' } } + +## +# @VirtioQueueElement: +# +# Information regarding a VirtQueue's VirtQueueElement including +# descriptor, driver, and device areas +# +# @name: Name of the VirtIODevice that uses this VirtQueue +# +# @index: Index of the element in the queue +# +# @descs: List of descriptors (VirtioRingDesc) +# +# @avail: VRingAvail info +# +# @used: VRingUsed info +# +# Since: 7.0 +# +## + +{ 'struct': 'VirtioQueueElement', + 'data': { 'name': 'str', + 'index': 'uint32', + 'descs': [ 'VirtioRingDesc' ], + 'avail': 'VirtioRingAvail', + 'used': 'VirtioRingUsed' } } + +## +# @x-query-virtio-queue-element: +# +# Return the information about a VirtQueue's VirtQueueElement +# (default: head of the queue) +# +# @path: VirtIODevice canonical QOM path +# +# @queue: VirtQueue index to examine +# +# @index: Index of the element in the queue +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: VirtioQueueElement information +# +# Since: 7.0 +# +# Examples: +# +# 1. Introspect on virtio-net's VirtQueue 0 at index 5 +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[1]/virtio-b= ackend", +# "queue": 0, +# "index": 5 } +# } +# <- { "return": { +# "index": 5, +# "name": "virtio-net", +# "descs": [ +# { "flags": ["write"], "len": 1536, "addr": 5257305600 } +# ], +# "avail": { +# "idx": 256, +# "flags": 0, +# "ring": 5 +# }, +# "used": { +# "idx": 13, +# "flags": 0 +# }, +# } +# +# 2. Introspect on virtio-crypto's VirtQueue 1 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral/crypto0/virtio-backend", +# "queue": 1 } +# } +# <- { "return": { +# "index": 0, +# "name": "virtio-crypto", +# "descs": [ +# { "flags": [], "len": 0, "addr": 8080268923184214134 } +# ], +# "avail": { +# "idx": 280, +# "flags": 0, +# "ring": 0 +# }, +# "used": { +# "idx": 280, +# "flags": 0 +# } +# } +# +# 3. Introspect on virtio-scsi's VirtQueue 2 at head +# +# -> { "execute": "x-query-virtio-queue-element", +# "arguments": { "path": "/machine/peripheral-anon/device[2]/virtio-b= ackend", +# "queue": 2 } +# } +# <- { "return": { +# "index": 19, +# "name": "virtio-scsi", +# "descs": [ +# { "flags": ["used", "indirect", "write"], "len": 409932794= 4, +# "addr": 12055409292258155293 } +# ], +# "avail": { +# "idx": 1147, +# "flags": 0, +# "ring": 19 +# }, +# "used": { +# "idx": 280, +# "flags": 0 +# } +# } +# +## + +{ 'command': 'x-query-virtio-queue-element', + 'data': { 'path': 'str', 'queue': 'uint16', '*index': 'uint16' }, + 'returns': 'VirtioQueueElement', + 'features': [ 'unstable' ] } diff --git a/hw/virtio/virtio-stub.c b/hw/virtio/virtio-stub.c index 13e5f93652..7ddb22cc5e 100644 --- a/hw/virtio/virtio-stub.c +++ b/hw/virtio/virtio-stub.c @@ -31,3 +31,12 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(const c= har *path, { return qmp_virtio_unsupported(errp); } + +VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + return qmp_virtio_unsupported(errp); +} diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 8723a53b68..d45b8dd040 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -489,6 +489,19 @@ static inline void vring_used_write(VirtQueue *vq, VRi= ngUsedElem *uelem, address_space_cache_invalidate(&caches->used, pa, sizeof(VRingUsedElem= )); } =20 +/* Called within rcu_read_lock(). */ +static inline uint16_t vring_used_flags(VirtQueue *vq) +{ + VRingMemoryRegionCaches *caches =3D vring_get_region_caches(vq); + hwaddr pa =3D offsetof(VRingUsed, flags); + + if (!caches) { + return 0; + } + + return virtio_lduw_phys_cached(vq->vdev, &caches->used, pa); +} + /* Called within rcu_read_lock(). */ static uint16_t vring_used_idx(VirtQueue *vq) { @@ -4415,6 +4428,147 @@ VirtQueueStatus *qmp_x_query_virtio_queue_status(co= nst char *path, return status; } =20 +static strList *qmp_decode_vring_desc_flags(uint16_t flags) +{ + strList *list =3D NULL; + strList *node; + int i; + + struct { + uint16_t flag; + const char *value; + } map[] =3D { + { VRING_DESC_F_NEXT, "next" }, + { VRING_DESC_F_WRITE, "write" }, + { VRING_DESC_F_INDIRECT, "indirect" }, + { 1 << VRING_PACKED_DESC_F_AVAIL, "avail" }, + { 1 << VRING_PACKED_DESC_F_USED, "used" }, + { 0, "" } + }; + + for (i =3D 0; map[i].flag; i++) { + if ((map[i].flag & flags) =3D=3D 0) { + continue; + } + node =3D g_malloc0(sizeof(strList)); + node->value =3D g_strdup(map[i].value); + node->next =3D list; + list =3D node; + } + + return list; +} + +VirtioQueueElement *qmp_x_query_virtio_queue_element(const char *path, + uint16_t queue, + bool has_index, + uint16_t index, + Error **errp) +{ + VirtIODevice *vdev; + VirtQueue *vq; + VirtioQueueElement *element =3D NULL; + + vdev =3D virtio_device_find(path); + if (vdev =3D=3D NULL) { + error_setg(errp, "Path %s is not a VirtIO device", path); + return NULL; + } + + if (queue >=3D VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, queue))= { + error_setg(errp, "Invalid virtqueue number %d", queue); + return NULL; + } + vq =3D &vdev->vq[queue]; + + if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) { + error_setg(errp, "Packed ring not supported"); + return NULL; + } else { + unsigned int head, i, max; + VRingMemoryRegionCaches *caches; + MemoryRegionCache indirect_desc_cache =3D MEMORY_REGION_CACHE_INVA= LID; + MemoryRegionCache *desc_cache; + VRingDesc desc; + VirtioRingDescList *list =3D NULL; + VirtioRingDescList *node; + int rc; int ndescs; + + RCU_READ_LOCK_GUARD(); + + max =3D vq->vring.num; + + if (!has_index) { + head =3D vring_avail_ring(vq, vq->last_avail_idx % vq->vring.n= um); + } else { + head =3D vring_avail_ring(vq, index % vq->vring.num); + } + i =3D head; + + caches =3D vring_get_region_caches(vq); + if (!caches) { + error_setg(errp, "Region caches not initialized"); + return NULL; + } + if (caches->desc.len < max * sizeof(VRingDesc)) { + error_setg(errp, "Cannot map descriptor ring"); + return NULL; + } + + desc_cache =3D &caches->desc; + vring_split_desc_read(vdev, &desc, desc_cache, i); + if (desc.flags & VRING_DESC_F_INDIRECT) { + int64_t len; + len =3D address_space_cache_init(&indirect_desc_cache, vdev->d= ma_as, + desc.addr, desc.len, false); + desc_cache =3D &indirect_desc_cache; + if (len < desc.len) { + error_setg(errp, "Cannot map indirect buffer"); + goto done; + } + + max =3D desc.len / sizeof(VRingDesc); + i =3D 0; + vring_split_desc_read(vdev, &desc, desc_cache, i); + } + + element =3D g_new0(VirtioQueueElement, 1); + element->avail =3D g_new0(VirtioRingAvail, 1); + element->used =3D g_new0(VirtioRingUsed, 1); + element->name =3D g_strdup(vdev->name); + element->index =3D head; + element->avail->flags =3D vring_avail_flags(vq); + element->avail->idx =3D vring_avail_idx(vq); + element->avail->ring =3D head; + element->used->flags =3D vring_used_flags(vq); + element->used->idx =3D vring_used_idx(vq); + ndescs =3D 0; + + do { + /* A buggy driver may produce an infinite loop */ + if (ndescs >=3D max) { + break; + } + node =3D g_new0(VirtioRingDescList, 1); + node->value =3D g_new0(VirtioRingDesc, 1); + node->value->addr =3D desc.addr; + node->value->len =3D desc.len; + node->value->flags =3D qmp_decode_vring_desc_flags(desc.flags); + node->next =3D list; + list =3D node; + + ndescs++; + rc =3D virtqueue_split_read_next_desc(vdev, &desc, desc_cache, + max, &i); + } while (rc =3D=3D VIRTQUEUE_READ_DESC_MORE); + element->descs =3D list; +done: + address_space_cache_destroy(&indirect_desc_cache); + } + + return element; +} + static const TypeInfo virtio_device_info =3D { .name =3D TYPE_VIRTIO_DEVICE, .parent =3D TYPE_DEVICE, --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027113405451.8853687949097; Fri, 4 Feb 2022 18:11:53 -0800 (PST) Received: from localhost ([::1]:60898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAYK-0003PT-GL for importer@patchew.org; Fri, 04 Feb 2022 21:11:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7J-0003wg-VT for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003NS-2O for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:57 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-480-XJQbhFlMOPiyBkuSuhnDzg-1; Fri, 04 Feb 2022 20:43:44 -0500 Received: by mail-wm1-f71.google.com with SMTP id j18-20020a05600c1c1200b0034aeea95dacso8368457wms.8 for ; Fri, 04 Feb 2022 17:43:43 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id a14sm2588103wmj.11.2022.02.04.17.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025424; 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: in-reply-to:in-reply-to:references:references; bh=UiMDG4BSWSIDOue4ATPPzF7xGlbSJDOiHVPpzK2dAmY=; b=Pv7eY9NiGX4nHp+HYrGOwFsnpYiL+koL4mZwoiOv992Zpi9IuWsKaQqTS5iRaNtf0tQxwg 7eAt05AICb8f1N1KNqZJXxRJ65w6xFJpxppb+v8fAkI4juHDiBodxGcGV9mQRezECLgCK0 3vJjP1vOogZbSvnmUZFB9KLKaiRhTbI= X-MC-Unique: XJQbhFlMOPiyBkuSuhnDzg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UiMDG4BSWSIDOue4ATPPzF7xGlbSJDOiHVPpzK2dAmY=; b=OFi1Ez1VqqXQvU6OOHrU0BwL0FGOVEeOOTAmvke7UJ3QKmvmMeoN5wq0BbmDEFFEpi v29LQD4dV4uRT/G8r3QJRjj7C3y7RRjoIftDSD7UmF61MhqewEer7j/LYlySrna9V+e5 yx90ZXJafU3tKKN0819OaqW/WJntl2jumiQAhrlsxhU4K1qeIaUYpoTL93qr4bD+f28e Yjul7fUlCfva7Di7GoMeiEo7OaQ86gaLlcE9RaJ0I3v2v+hlLriTqYura4qxWAtkLTzx QZgFBYNQ/F0tD9+dq3ooUHVl1azRuqtuTgkI4F73aB4qXvcSf3W3+wpcK4fffzfnYxHS tJ7Q== X-Gm-Message-State: AOAM533KXWExehd6IUhjcd7baTVb7uLNCxNKC48nb97VRizyGWo/w3Ox RDcpa61KpbmEMkXOc+qkInWHrODXLbYX6H42sec6ADq6mYi+o/5DWOrYWDm6eFRNYn/9RDkRTFL 2JZlfMrFoxFnM6qqrTHeHkY9QdAOE2e3RTHzKJJlkU3PfOX15Nl0iPecpMYY7 X-Received: by 2002:adf:bad4:: with SMTP id w20mr1215643wrg.457.1644025422201; Fri, 04 Feb 2022 17:43:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyc0/lWVOgoR0cmaz+541R4J7Rs7WztzY0/AhxJHx9a5EnevoNFBAuoyj6OtZsCvshZLAMTWw== X-Received: by 2002:adf:bad4:: with SMTP id w20mr1215628wrg.457.1644025421917; Fri, 04 Feb 2022 17:43:41 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 22/32] hmp: add virtio commands Message-ID: <20220205014149.1189026-23-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Laurent Vivier , Peter Maydell , "Dr. David Alan Gilbert" , Jonah Palmer Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027114667100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier This patch implements the HMP versions of the virtio QMP commands. Signed-off-by: Jonah Palmer Message-Id: <1642678168-20447-9-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/monitor/hmp.h | 5 + monitor/hmp-cmds.c | 311 ++++++++++++++++++++++++++++++++++++++++++ hmp-commands-info.hx | 70 ++++++++++ 3 files changed, 386 insertions(+) diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 96d014826a..47446d8257 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -95,6 +95,11 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict); void hmp_qom_get(Monitor *mon, const QDict *qdict); void hmp_qom_set(Monitor *mon, const QDict *qdict); void hmp_info_qom_tree(Monitor *mon, const QDict *dict); +void hmp_virtio_query(Monitor *mon, const QDict *qdict); +void hmp_virtio_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict); +void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict); +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict); void object_add_completion(ReadLineState *rs, int nb_args, const char *str= ); void object_del_completion(ReadLineState *rs, int nb_args, const char *str= ); void device_add_completion(ReadLineState *rs, int nb_args, const char *str= ); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8c384dc1b2..6000da7a47 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -42,6 +42,8 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-virtio.h" +#include "qapi/qapi-visit-virtio.h" #include "qapi/qapi-visit-net.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" @@ -2178,3 +2180,312 @@ void hmp_info_memory_size_summary(Monitor *mon, con= st QDict *qdict) } hmp_handle_error(mon, err); } + +static void hmp_virtio_dump_protocols(Monitor *mon, + VhostDeviceProtocols *pcol) +{ + strList *pcol_list =3D pcol->protocols; + while (pcol_list) { + monitor_printf(mon, "%s", pcol_list->value); + pcol_list =3D pcol_list->next; + if (pcol_list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + if (pcol->has_unknown_protocols) { + monitor_printf(mon, " unknown-protocols(0x%016"PRIx64")\n", + pcol->unknown_protocols); + } +} + +static void hmp_virtio_dump_status(Monitor *mon, + VirtioDeviceStatus *status) +{ + strList *status_list =3D status->statuses; + while (status_list) { + monitor_printf(mon, "%s", status_list->value); + status_list =3D status_list->next; + if (status_list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + if (status->has_unknown_statuses) { + monitor_printf(mon, " unknown-statuses(0x%016"PRIx32")\n", + status->unknown_statuses); + } +} + +static void hmp_virtio_dump_features(Monitor *mon, + VirtioDeviceFeatures *features) +{ + strList *transport_list =3D features->transports; + while (transport_list) { + monitor_printf(mon, "%s", transport_list->value); + transport_list =3D transport_list->next; + if (transport_list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + + monitor_printf(mon, "\n"); + strList *list =3D features->dev_features; + if (list) { + monitor_printf(mon, " "); + while (list) { + monitor_printf(mon, "%s", list->value); + list =3D list->next; + if (list !=3D NULL) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + } + + if (features->has_unknown_dev_features) { + monitor_printf(mon, " unknown-features(0x%016"PRIx64")\n", + features->unknown_dev_features); + } +} + +void hmp_virtio_query(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + VirtioInfoList *list =3D qmp_x_query_virtio(&err); + VirtioInfoList *node; + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + if (list =3D=3D NULL) { + monitor_printf(mon, "No VirtIO devices\n"); + return; + } + + node =3D list; + while (node) { + monitor_printf(mon, "%s [%s]\n", node->value->path, + node->value->name); + node =3D node->next; + } + qapi_free_VirtioInfoList(list); +} + +void hmp_virtio_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + VirtioStatus *s =3D qmp_x_query_virtio_status(path, &err); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s %s\n", + s->name, s->has_vhost_dev ? "(vhost)" : ""); + monitor_printf(mon, " device_id: %d\n", s->device_id); + monitor_printf(mon, " vhost_started: %s\n", + s->vhost_started ? "true" : "false"); + monitor_printf(mon, " bus_name: %s\n", s->bus_name); + monitor_printf(mon, " broken: %s\n", + s->broken ? "true" : "false"); + monitor_printf(mon, " disabled: %s\n", + s->disabled ? "true" : "false"); + monitor_printf(mon, " disable_legacy_check: %s\n", + s->disable_legacy_check ? "true" : "false"); + monitor_printf(mon, " started: %s\n", + s->started ? "true" : "false"); + monitor_printf(mon, " use_started: %s\n", + s->use_started ? "true" : "false"); + monitor_printf(mon, " start_on_kick: %s\n", + s->start_on_kick ? "true" : "false"); + monitor_printf(mon, " use_guest_notifier_mask: %s\n", + s->use_guest_notifier_mask ? "true" : "false"); + monitor_printf(mon, " vm_running: %s\n", + s->vm_running ? "true" : "false"); + monitor_printf(mon, " num_vqs: %ld\n", s->num_vqs); + monitor_printf(mon, " queue_sel: %d\n", + s->queue_sel); + monitor_printf(mon, " isr: %d\n", s->isr); + monitor_printf(mon, " endianness: %s\n", + s->device_endian); + monitor_printf(mon, " status: "); + hmp_virtio_dump_status(mon, s->status); + monitor_printf(mon, " Guest features: "); + hmp_virtio_dump_features(mon, s->guest_features); + monitor_printf(mon, " Host features: "); + hmp_virtio_dump_features(mon, s->host_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->backend_features); + + if (s->has_vhost_dev) { + monitor_printf(mon, " VHost:\n"); + monitor_printf(mon, " nvqs: %d\n", + s->vhost_dev->nvqs); + monitor_printf(mon, " vq_index: %ld\n", + s->vhost_dev->vq_index); + monitor_printf(mon, " max_queues: %lu\n", + s->vhost_dev->max_queues); + monitor_printf(mon, " n_mem_sections: %ld\n", + s->vhost_dev->n_mem_sections); + monitor_printf(mon, " n_tmp_sections: %ld\n", + s->vhost_dev->n_tmp_sections); + monitor_printf(mon, " backend_cap: %lu\n", + s->vhost_dev->backend_cap); + monitor_printf(mon, " log_enabled: %s\n", + s->vhost_dev->log_enabled ? "true" : "false"); + monitor_printf(mon, " log_size: %lu\n", + s->vhost_dev->log_size); + monitor_printf(mon, " Features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->features); + monitor_printf(mon, " Acked features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->acked_features); + monitor_printf(mon, " Backend features: "); + hmp_virtio_dump_features(mon, s->vhost_dev->backend_features); + monitor_printf(mon, " Protocol features: "); + hmp_virtio_dump_protocols(mon, s->vhost_dev->protocol_features); + } + + qapi_free_VirtioStatus(s); +} + +void hmp_vhost_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + VirtVhostQueueStatus *s =3D + qmp_x_query_virtio_vhost_queue_status(path, queue, &err); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s (vhost)\n", + s->name); + monitor_printf(mon, " kick: %ld\n", s->kick); + monitor_printf(mon, " call: %ld\n", s->call); + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %ld\n", s->num); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", s->desc); + monitor_printf(mon, " desc_phys: 0x%016"PRIx64"\n", + s->desc_phys); + monitor_printf(mon, " desc_size: %"PRId32"\n", s->desc_size); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", s->avail); + monitor_printf(mon, " avail_phys: 0x%016"PRIx64"\n", + s->avail_phys); + monitor_printf(mon, " avail_size: %"PRId32"\n", s->avail_size); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", s->used); + monitor_printf(mon, " used_phys: 0x%016"PRIx64"\n", + s->used_phys); + monitor_printf(mon, " used_size: %"PRId32"\n", s->used_size); + + qapi_free_VirtVhostQueueStatus(s); +} + +void hmp_virtio_queue_status(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + VirtQueueStatus *s =3D qmp_x_query_virtio_queue_status(path, queue, &e= rr); + + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", s->name); + monitor_printf(mon, " queue_index: %d\n", s->queue_index); + monitor_printf(mon, " inuse: %d\n", s->inuse); + monitor_printf(mon, " used_idx: %d\n", s->used_idx); + monitor_printf(mon, " signalled_used: %d\n", + s->signalled_used); + monitor_printf(mon, " signalled_used_valid: %s\n", + s->signalled_used_valid ? "true" : "false"); + if (s->has_last_avail_idx) { + monitor_printf(mon, " last_avail_idx: %d\n", + s->last_avail_idx); + } + if (s->has_shadow_avail_idx) { + monitor_printf(mon, " shadow_avail_idx: %d\n", + s->shadow_avail_idx); + } + monitor_printf(mon, " VRing:\n"); + monitor_printf(mon, " num: %"PRId32"\n", s->vring_num); + monitor_printf(mon, " num_default: %"PRId32"\n", + s->vring_num_default); + monitor_printf(mon, " align: %"PRId32"\n", + s->vring_align); + monitor_printf(mon, " desc: 0x%016"PRIx64"\n", + s->vring_desc); + monitor_printf(mon, " avail: 0x%016"PRIx64"\n", + s->vring_avail); + monitor_printf(mon, " used: 0x%016"PRIx64"\n", + s->vring_used); + + qapi_free_VirtQueueStatus(s); +} + +void hmp_virtio_queue_element(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + const char *path =3D qdict_get_try_str(qdict, "path"); + int queue =3D qdict_get_int(qdict, "queue"); + int index =3D qdict_get_try_int(qdict, "index", -1); + VirtioQueueElement *e; + VirtioRingDescList *list; + + e =3D qmp_x_query_virtio_queue_element(path, queue, index !=3D -1, + index, &err); + if (err !=3D NULL) { + hmp_handle_error(mon, err); + return; + } + + monitor_printf(mon, "%s:\n", path); + monitor_printf(mon, " device_name: %s\n", e->name); + monitor_printf(mon, " index: %d\n", e->index); + monitor_printf(mon, " desc:\n"); + monitor_printf(mon, " descs: "); + + list =3D e->descs; + while (list) { + monitor_printf(mon, "addr 0x%"PRIx64" len %d", list->value->addr, + list->value->len); + if (list->value->flags) { + strList *flag =3D list->value->flags; + monitor_printf(mon, " ("); + while (flag) { + monitor_printf(mon, "%s", flag->value); + flag =3D flag->next; + if (flag) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, ")"); + } + list =3D list->next; + if (list) { + monitor_printf(mon, ", "); + } + } + monitor_printf(mon, "\n"); + monitor_printf(mon, " avail:\n"); + monitor_printf(mon, " flags: %d\n", e->avail->flags); + monitor_printf(mon, " idx: %d\n", e->avail->idx); + monitor_printf(mon, " ring: %d\n", e->avail->ring); + monitor_printf(mon, " used:\n"); + monitor_printf(mon, " flags: %d\n", e->used->flags); + monitor_printf(mon, " idx: %d\n", e->used->idx); + + qapi_free_VirtioQueueElement(e); +} diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index e90f20a107..9bd1ba54f5 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -879,3 +879,73 @@ SRST ``info sgx`` Show intel SGX information. ERST + + { + .name =3D "virtio", + .args_type =3D "", + .params =3D "", + .help =3D "List all available virtio devices", + .cmd =3D hmp_virtio_query, + .flags =3D "p", + }, + +SRST + ``info virtio`` + List all available virtio devices +ERST + + { + .name =3D "virtio-status", + .args_type =3D "path:s", + .params =3D "path", + .help =3D "Display status of a given virtio device", + .cmd =3D hmp_virtio_status, + .flags =3D "p", + }, + +SRST + ``info virtio-status`` *path* + Display status of a given virtio device +ERST + + { + .name =3D "virtio-queue-status", + .args_type =3D "path:s,queue:i", + .params =3D "path queue", + .help =3D "Display status of a given virtio queue", + .cmd =3D hmp_virtio_queue_status, + .flags =3D "p", + }, + +SRST + ``info virtio-queue-status`` *path* *queue* + Display status of a given virtio queue +ERST + + { + .name =3D "virtio-vhost-queue-status", + .args_type =3D "path:s,queue:i", + .params =3D "path queue", + .help =3D "Display status of a given vhost queue", + .cmd =3D hmp_vhost_queue_status, + .flags =3D "p", + }, + +SRST + ``info virtio-vhost-queue-status`` *path* *queue* + Display status of a given vhost queue +ERST + + { + .name =3D "virtio-queue-element", + .args_type =3D "path:s,queue:i,index:i?", + .params =3D "path queue [index]", + .help =3D "Display element of a given virtio queue", + .cmd =3D hmp_virtio_queue_element, + .flags =3D "p", + }, + +SRST + ``info virtio-queue-element`` *path* *queue* [*index*] + Display element of a given virtio queue +ERST --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026892369874.1736056640277; Fri, 4 Feb 2022 18:08:12 -0800 (PST) Received: from localhost ([::1]:51472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAUk-0005Gn-R3 for importer@patchew.org; Fri, 04 Feb 2022 21:08:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7L-0003xS-Ac for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7G-0003NX-31 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:58 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-354-kG7zUz51NEmCaYVYzY_tOA-1; Fri, 04 Feb 2022 20:43:46 -0500 Received: by mail-wr1-f71.google.com with SMTP id g17-20020adfa591000000b001da86c91c22so2800695wrc.5 for ; Fri, 04 Feb 2022 17:43:46 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id s78sm550336wme.16.2022.02.04.17.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025427; 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: in-reply-to:in-reply-to:references:references; bh=9SAeYk6Qwn6EXatjRomDHKxEpW2B7uuJLKwuu/8IMtM=; b=YMuAJonMh/TdzXaToxXNMEo9DwVuQch1oZheYUozTSf9HzfP+deY9KewVAV8TFnjTxJUoQ gBNFcxezQmxv1t00jpKqP4bluE6TEHVqjjylNSGj3lMEQ0wGoQW1XS1fB5l4zJuh/b67KU NWYbvKzB25eqrB88SE/HyIdAAaTuKNY= X-MC-Unique: kG7zUz51NEmCaYVYzY_tOA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9SAeYk6Qwn6EXatjRomDHKxEpW2B7uuJLKwuu/8IMtM=; b=Veg43FL378ytjH0qa+vwXeI84HR73F0G8jiWfIK8aQSJKJTMQzQtsE4f6jCBwhkaLM p4akVrlhu78OvaLt9xDogLn61t54e2Y9JrQJlA7J+jWs3AdY1502Ybp5B3XTe4z/zhz/ COWkidwXK9/2jY5iPkIRrRgoIHcvYUYeVozrNfzzXa3kvKb84XCvml/fiUTA0N9kMjUb 8qUBaVBD4VAuM9d+KHNIHRreegeyKysVrVD2rWEmFnZJgJKUHi7ZSBzdLKTVGZrigBDN /Bh5unNJFCwqrVeE+woTv/VMcticPM59MSG1oAfMvSJwlp3aCwNB7FiUcmYOiuA3g79X 1Rig== X-Gm-Message-State: AOAM531z/vYv+4baEJ6bxh8RXKwEw83RM8xGRG7L/wZc4AoL4OAmFGJG WMnaGStzsyO3hMZ1vDvhWH844/mfipU5aF7LvLfR8DW5tOGuCgDAkA4K4PPhpF360/aawTXSaNG 2rUiB9ItrLHC2R6RzZRF7CA4CRpYI+4A0yPG+mAyRMq3qa1hxzzusmpg3WTJO X-Received: by 2002:a05:600c:38a:: with SMTP id w10mr4516797wmd.12.1644025424579; Fri, 04 Feb 2022 17:43:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4dXgEwNpQTRUD9bVaD+xUzm836e/CqksROYUPU4zr8cKpB3G3k3/wRcYbhvHWYw4T6TaW5A== X-Received: by 2002:a05:600c:38a:: with SMTP id w10mr4516774wmd.12.1644025424257; Fri, 04 Feb 2022 17:43:44 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 23/32] ACPI ERST: bios-tables-test.c steps 1 and 2 Message-ID: <20220205014149.1189026-24-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Eric DeVolder , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026894438100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder Following the guidelines in tests/qtest/bios-tables-test.c, this change adds empty placeholder files per step 1 for the new ERST table, and excludes resulting changed files in bios-tables-test-allowed-dif= f.h per step 2. Signed-off-by: Eric DeVolder Acked-by: Igor Mammedov Message-Id: <1643402289-22216-2-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++ tests/data/acpi/microvm/ERST.pcie | 0 tests/data/acpi/pc/DSDT.acpierst | 0 tests/data/acpi/pc/ERST.acpierst | 0 tests/data/acpi/q35/DSDT.acpierst | 0 tests/data/acpi/q35/ERST.acpierst | 0 6 files changed, 5 insertions(+) create mode 100644 tests/data/acpi/microvm/ERST.pcie create mode 100644 tests/data/acpi/pc/DSDT.acpierst create mode 100644 tests/data/acpi/pc/ERST.acpierst create mode 100644 tests/data/acpi/q35/DSDT.acpierst create mode 100644 tests/data/acpi/q35/ERST.acpierst diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..603db07711 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,6 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/pc/DSDT.acpierst", +"tests/data/acpi/pc/ERST.acpierst", +"tests/data/acpi/q35/DSDT.acpierst", +"tests/data/acpi/q35/ERST.acpierst", +"tests/data/acpi/microvm/ERST.pcie", diff --git a/tests/data/acpi/microvm/ERST.pcie b/tests/data/acpi/microvm/ER= ST.pcie new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/DSDT.acpierst b/tests/data/acpi/pc/DSDT.acp= ierst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/pc/ERST.acpierst b/tests/data/acpi/pc/ERST.acp= ierst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/DSDT.acpierst b/tests/data/acpi/q35/DSDT.a= cpierst new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/data/acpi/q35/ERST.acpierst b/tests/data/acpi/q35/ERST.a= cpierst new file mode 100644 index 0000000000..e69de29bb2 --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027648543842.3291238859508; Fri, 4 Feb 2022 18:20:48 -0800 (PST) Received: from localhost ([::1]:51336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAgx-0007aj-54 for importer@patchew.org; Fri, 04 Feb 2022 21:20:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7J-0003wf-HO for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7F-0003Nc-27 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:43:56 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-2HURcZN8M9qmAmEa8dO1PA-1; Fri, 04 Feb 2022 20:43:48 -0500 Received: by mail-wr1-f71.google.com with SMTP id q4-20020adfbb84000000b001dd3cfddb2dso2804503wrg.11 for ; Fri, 04 Feb 2022 17:43:48 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id t4sm3181912wro.71.2022.02.04.17.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025429; 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: in-reply-to:in-reply-to:references:references; bh=DiaDZ6Jg6Wr7fQiD4I2/sd6NrZXyOewN/eKa4S/4RBc=; b=GBvG1zYXVXoTh+00iiBRm1uDMQ5aOQpOB40Gdbn8d2JH8Y8kj7ayCxoe+QIbqOSPH+0iwC +252sUe2zKdS5mGGnaLjrSh44Q2BPfxGP2SlEsPdQjaxjQXB1Te14K9NDWsTx3F4wnrUwx J8pv9ImHh+lE8AdzQ0ksntxelzkpzk0= X-MC-Unique: 2HURcZN8M9qmAmEa8dO1PA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DiaDZ6Jg6Wr7fQiD4I2/sd6NrZXyOewN/eKa4S/4RBc=; b=WoyYOio9rzGrc484OmJb8Yd8MhIIKUIzkKDEe1CQsoAthqaHtja7Xkp4OupX1RUVkO VSRYtHZyy7CNkmgem4eMl+fELKkeoJrp+H9wK3cruj7UrmZS4dFcML1ckM/gXesD0x/l qx8BKnmEZYtUmvO7hkKCwKG0Ry1et4YQT3mb9E46V863+X+qaqUEJTNkj/MpX3i8wKOf +YgXd1o3/XCYeFaIPX8rdA4AldF35qFnZ2a1/HqlTAwoGuy0xCj5OVMrLMUysOQpxYRo 2AXM9Il9BcPUbicuHmhgtlrZxxc6Bhj16/Z8mVa+DP2QecKqc3vNjJkn4SX71v4PATav KgjA== X-Gm-Message-State: AOAM533WTggx6HiMP574SpxZDfPqrPiw1oZKsy4SPo2N4OxptbJBH5IB 2VXaxesTost7eXXf3tPN634+incHuqGPg/EHHaHJV4F6/W6EZ/H6hhwRwXNxVlDNgBCyhKreYQQ 5VR6L3kCC8QG41hm7bPjo2o9tM0kK8HSkBOZB7J8JxbZkTX8gJpm8Sc92q5KE X-Received: by 2002:a05:600c:17d5:: with SMTP id y21mr1181993wmo.102.1644025426790; Fri, 04 Feb 2022 17:43:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwY+bXvL57BeQfLNdN7F13X7b577eKuJ812XZ4sVFGhfyKJD2ngnBGod0JFgmTQzth3V819PA== X-Received: by 2002:a05:600c:17d5:: with SMTP id y21mr1181976wmo.102.1644025426542; Fri, 04 Feb 2022 17:43:46 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 24/32] ACPI ERST: PCI device_id for ERST Message-ID: <20220205014149.1189026-25-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Eric DeVolder , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027649424100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder This change reserves the PCI device_id for the new ACPI ERST device. Signed-off-by: Eric DeVolder Acked-by: Igor Mammedov Acked-by: Ani Sinha Message-Id: <1643402289-22216-4-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 023abc0f79..c3f3c90473 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -108,6 +108,7 @@ extern bool pci_available; #define PCI_DEVICE_ID_REDHAT_MDPY 0x000f #define PCI_DEVICE_ID_REDHAT_NVME 0x0010 #define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011 +#define PCI_DEVICE_ID_REDHAT_ACPI_ERST 0x0012 #define PCI_DEVICE_ID_REDHAT_QXL 0x0100 =20 #define FMT_PCIBUS PRIx64 --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027264318640.8018667030555; Fri, 4 Feb 2022 18:14:24 -0800 (PST) Received: from localhost ([::1]:38280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAal-0007BM-6Z for importer@patchew.org; Fri, 04 Feb 2022 21:14:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGABI-0006Ex-Od for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:48:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGABG-0003yO-6U for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:48:03 -0500 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-63-fBqt1BIVNiylS8a-q-LbQg-1; Fri, 04 Feb 2022 20:43:50 -0500 Received: by mail-wr1-f71.google.com with SMTP id w7-20020adfbac7000000b001d6f75e4faeso2805058wrg.7 for ; Fri, 04 Feb 2022 17:43:50 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id 21sm9507617wmv.11.2022.02.04.17.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025681; 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: in-reply-to:in-reply-to:references:references; bh=dqIW4HOXDQJl70JpvdUs1dPT+8Qw8RjLjhx0buPuD7M=; b=ZWHYuoVl+/d0K8QKvhNZ4G+5b+ANI6rnT2SfCZtZe2RMzMY2opuUB2MAr8VKTCrriy1qEQ br5nXbxeK785YDyocyZqFUQWiAHgnl9QEKURcGXS5n/3FaJcR9rq+lv93Na0fTQk6Q0MH4 Xc9qmipBKEFnS9tr0kwwBE9JdPv3dho= X-MC-Unique: fBqt1BIVNiylS8a-q-LbQg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dqIW4HOXDQJl70JpvdUs1dPT+8Qw8RjLjhx0buPuD7M=; b=h9dDl4AOv9+y0fpfa+1lbWWRpEs/iFeaCg6XjWiZ8VEM42z6WTznYxRnxhGFVL6+tx Dj8g3ax0ltHqvFcoY1RE9qJH+34AdD2XpKkozNnWsEFPvZg7Or9nEF6bazT/KcD96W/8 Jpd20saJB4WXDdtQooQquotEhXj2UXt9WbuEMvNpXAoY14SGAzv3IlbDE41CvWbUdtiW 6g5TCaS3TpFKZ9GcPiAaCtxyr843zRrH6rcnqC8ayQ/W/ZaYUl2zaghpSRf028BsBKBV w4Rcj0c9l1LH0x+uSLGbDMme4YHQ83oDuzqw8quishryEWlZCR01JbQM9CwBAPYYC8O/ ev3Q== X-Gm-Message-State: AOAM531Z5jNkGg1CTmqmIkgisfkAVFoFvdFPMqMWp0zszbIYxkrlRZG9 bG+VV7kAqZVF5Ky5q6PuFc5168tHm6VaBoWgGwnDgb30FLAUbH1vjEGEl/xjqdg+qDR7geJ/Mv8 ZrfobuCRimqEq5KAfVPjlCxKK6mFe4ZAZ8bG79G+hrAsTQBFwZzTCegykKp6V X-Received: by 2002:a1c:4604:: with SMTP id t4mr1125487wma.191.1644025429316; Fri, 04 Feb 2022 17:43:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5zFYeLKN8PWfkgB+J/ljBs+2gU2p07KvweAv6WRN280IcrPAQYs/OyofQ9oJJlaRYEh3LbA== X-Received: by 2002:a1c:4604:: with SMTP id t4mr1125472wma.191.1644025429007; Fri, 04 Feb 2022 17:43:49 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 25/32] ACPI ERST: header file for ERST Message-ID: <20220205014149.1189026-26-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Eric DeVolder , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027266480100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder This change introduces the public defintions for ACPI ERST. Signed-off-by: Eric DeVolder Reviewed-by: Ani Sinha Message-Id: <1643402289-22216-5-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/erst.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 include/hw/acpi/erst.h diff --git a/include/hw/acpi/erst.h b/include/hw/acpi/erst.h new file mode 100644 index 0000000000..9d637179fe --- /dev/null +++ b/include/hw/acpi/erst.h @@ -0,0 +1,19 @@ +/* + * ACPI Error Record Serialization Table, ERST, Implementation + * + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. + * ACPI Platform Error Interfaces : Error Serialization + * + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef HW_ACPI_ERST_H +#define HW_ACPI_ERST_H + +void build_erst(GArray *table_data, BIOSLinker *linker, Object *erst_dev, + const char *oem_id, const char *oem_table_id); + +#define TYPE_ACPI_ERST "acpi-erst" + +#endif --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027077222113.23808133071464; Fri, 4 Feb 2022 18:11:17 -0800 (PST) Received: from localhost ([::1]:60060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAXj-0002ki-Vd for importer@patchew.org; Fri, 04 Feb 2022 21:11:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7O-0003xc-3y for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34301) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7I-0003PQ-2b for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:01 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-4hZPU3cBNQik0yVfqiu-lQ-1; Fri, 04 Feb 2022 20:43:53 -0500 Received: by mail-wr1-f70.google.com with SMTP id g17-20020adfa591000000b001da86c91c22so2800793wrc.5 for ; Fri, 04 Feb 2022 17:43:53 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id i13sm4110189wrf.3.2022.02.04.17.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025435; 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: in-reply-to:in-reply-to:references:references; bh=md+0x/hL3eI2WJAyKsSmYY0vg8hYC+rd2o6i0IUdA18=; b=bfl6hdLxQJm0uvSwYBMYoEr/gltghKDslEum4T3512KAIwhjdJqTs2n1BM4nSYzVHRCMgB CPSN2UrqReETVz8d44HBeJGzrCN/6R5ZiDVQIMD73cifFc0ZkzCPM8ZeuH2+RVjvWcjaYV iinSJKRQpoaImfxZW1qcC0u/Wzob+0w= X-MC-Unique: 4hZPU3cBNQik0yVfqiu-lQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=md+0x/hL3eI2WJAyKsSmYY0vg8hYC+rd2o6i0IUdA18=; b=S4IGl5kyzCJOgyvVK/xwNPMJ2HfjE52N4OmWom0+7icScrbAxm81uqSnquwdvi6VM+ 9yeAKz9F5fPs15SJLvUsrixuoMYlknDW+UwB0pvwfnxbKiHtVrpFlPgBb/xs0udPyFfD 431pYljvtDfWjYRO/rNRNlnaN2Ygsybz1Qq3r6j6+IgWimQjWpLCFj8VOu45EYOVB8nZ usQ1An/MnZhVX/rF4nvW8FvIGROPNXDvFfcYKaYwU5RX62Dtwemqsv/ByISsqUcrhq4z NbTCSjfHNVnaI8CEqKymtG0JQHa6J5zdNz2ajqdkR3kGnd2N+7pMkCdyZXKvCBegRHc3 AArA== X-Gm-Message-State: AOAM531wGj1yLl/9pbRAVsY7d/XaiqyRJ+DeGVfsfUR7gE79u0gFVbY/ +kbpQ4ZmwJ+BfbPGqsT6Bx+rioqDgSMqEwMiwMmJruazJK4ZVD56b5P3cw+ylbA3JdlHuJM73Fh ItTs1VT3zCSqczkQcV9K5iHMFspaNMUWjCPwY+pPnm95NVy2k2tTX21Hh/Uyx X-Received: by 2002:a5d:548a:: with SMTP id h10mr1230667wrv.221.1644025431670; Fri, 04 Feb 2022 17:43:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkmfucGkdhuUpnku3kFNvBhUFWuQy/NZ3L+huYGqwdiIIk8x05I9V/WQbWqbGIdk4XtxF38A== X-Received: by 2002:a5d:548a:: with SMTP id h10mr1230650wrv.221.1644025431194; Fri, 04 Feb 2022 17:43:51 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 26/32] ACPI ERST: support for ACPI ERST feature Message-ID: <20220205014149.1189026-27-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Eric DeVolder , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027078468100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder This implements a PCI device for ACPI ERST. This implements the non-NVRAM "mode" of operation for ERST as it is supported by Linux and Windows. Signed-off-by: Eric DeVolder Reviewed-by: Ani Sinha Message-Id: <1643402289-22216-6-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/erst.c | 844 +++++++++++++++++++++++++++++++++++++++++++ hw/acpi/Kconfig | 6 + hw/acpi/meson.build | 1 + hw/acpi/trace-events | 15 + 4 files changed, 866 insertions(+) create mode 100644 hw/acpi/erst.c diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c new file mode 100644 index 0000000000..fe9ba51de7 --- /dev/null +++ b/hw/acpi/erst.c @@ -0,0 +1,844 @@ +/* + * ACPI Error Record Serialization Table, ERST, Implementation + * + * ACPI ERST introduced in ACPI 4.0, June 16, 2009. + * ACPI Platform Error Interfaces : Error Serialization + * + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include +#include +#include + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-core.h" +#include "exec/memory.h" +#include "qom/object.h" +#include "hw/pci/pci.h" +#include "qom/object_interfaces.h" +#include "qemu/error-report.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/acpi-defs.h" +#include "hw/acpi/aml-build.h" +#include "hw/acpi/bios-linker-loader.h" +#include "exec/address-spaces.h" +#include "sysemu/hostmem.h" +#include "hw/acpi/erst.h" +#include "trace.h" + +/* ACPI 4.0: Table 17-16 Serialization Actions */ +#define ACTION_BEGIN_WRITE_OPERATION 0x0 +#define ACTION_BEGIN_READ_OPERATION 0x1 +#define ACTION_BEGIN_CLEAR_OPERATION 0x2 +#define ACTION_END_OPERATION 0x3 +#define ACTION_SET_RECORD_OFFSET 0x4 +#define ACTION_EXECUTE_OPERATION 0x5 +#define ACTION_CHECK_BUSY_STATUS 0x6 +#define ACTION_GET_COMMAND_STATUS 0x7 +#define ACTION_GET_RECORD_IDENTIFIER 0x8 +#define ACTION_SET_RECORD_IDENTIFIER 0x9 +#define ACTION_GET_RECORD_COUNT 0xA +#define ACTION_BEGIN_DUMMY_WRITE_OPERATION 0xB +#define ACTION_RESERVED 0xC +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE 0xD +#define ACTION_GET_ERROR_LOG_ADDRESS_LENGTH 0xE +#define ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES 0xF +#define ACTION_GET_EXECUTE_OPERATION_TIMINGS 0x10 /* ACPI 6.3 */ + +/* ACPI 4.0: Table 17-17 Command Status Definitions */ +#define STATUS_SUCCESS 0x00 +#define STATUS_NOT_ENOUGH_SPACE 0x01 +#define STATUS_HARDWARE_NOT_AVAILABLE 0x02 +#define STATUS_FAILED 0x03 +#define STATUS_RECORD_STORE_EMPTY 0x04 +#define STATUS_RECORD_NOT_FOUND 0x05 + +/* UEFI 2.1: Appendix N Common Platform Error Record */ +#define UEFI_CPER_RECORD_MIN_SIZE 128U +#define UEFI_CPER_RECORD_LENGTH_OFFSET 20U +#define UEFI_CPER_RECORD_ID_OFFSET 96U +#define IS_UEFI_CPER_RECORD(ptr) \ + (((ptr)[0] =3D=3D 'C') && \ + ((ptr)[1] =3D=3D 'P') && \ + ((ptr)[2] =3D=3D 'E') && \ + ((ptr)[3] =3D=3D 'R')) + +/* + * NOTE that when accessing CPER fields within a record, memcpy() + * is utilized to avoid a possible misaligned access on the host. + */ + +/* + * This implementation is an ACTION (cmd) and VALUE (data) + * interface consisting of just two 64-bit registers. + */ +#define ERST_REG_SIZE (16UL) +#define ERST_ACTION_OFFSET (0UL) /* action (cmd) */ +#define ERST_VALUE_OFFSET (8UL) /* argument/value (data) */ + +/* + * ERST_RECORD_SIZE is the buffer size for exchanging ERST + * record contents. Thus, it defines the maximum record size. + * As this is mapped through a PCI BAR, it must be a power of + * two and larger than UEFI_CPER_RECORD_MIN_SIZE. + * The backing storage is divided into fixed size "slots", + * each ERST_RECORD_SIZE in length, and each "slot" + * storing a single record. No attempt at optimizing storage + * through compression, compaction, etc is attempted. + * NOTE that slot 0 is reserved for the backing storage header. + * Depending upon the size of the backing storage, additional + * slots will be part of the slot 0 header in order to account + * for a record_id for each available remaining slot. + */ +/* 8KiB records, not too small, not too big */ +#define ERST_RECORD_SIZE (8192UL) + +#define ACPI_ERST_MEMDEV_PROP "memdev" +#define ACPI_ERST_RECORD_SIZE_PROP "record_size" + +/* + * From the ACPI ERST spec sections: + * A record id of all 0s is used to indicate 'unspecified' record id. + * A record id of all 1s is used to indicate empty or end. + */ +#define ERST_UNSPECIFIED_RECORD_ID (0UL) +#define ERST_EMPTY_END_RECORD_ID (~0UL) + +#define ERST_IS_VALID_RECORD_ID(rid) \ + ((rid !=3D ERST_UNSPECIFIED_RECORD_ID) && \ + (rid !=3D ERST_EMPTY_END_RECORD_ID)) + +/* + * Implementation-specific definitions and types. + * Values are arbitrary and chosen for this implementation. + * See erst.rst documentation for details. + */ +#define ERST_EXECUTE_OPERATION_MAGIC 0x9CUL +#define ERST_STORE_MAGIC 0x524F545354535245UL /* ERSTSTOR */ +typedef struct { + uint64_t magic; + uint32_t record_size; + uint32_t storage_offset; /* offset to record storage beyond header */ + uint16_t version; + uint16_t reserved; + uint32_t record_count; + uint64_t map[]; /* contains record_ids, and position indicates index */ +} __attribute__((packed)) ERSTStorageHeader; + +/* + * Object cast macro + */ +#define ACPIERST(obj) \ + OBJECT_CHECK(ERSTDeviceState, (obj), TYPE_ACPI_ERST) + +/* + * Main ERST device state structure + */ +typedef struct { + PCIDevice parent_obj; + + /* Backend storage */ + HostMemoryBackend *hostmem; + MemoryRegion *hostmem_mr; + uint32_t storage_size; + uint32_t default_record_size; + + /* Programming registers */ + MemoryRegion iomem_mr; + + /* Exchange buffer */ + MemoryRegion exchange_mr; + + /* Interface state */ + uint8_t operation; + uint8_t busy_status; + uint8_t command_status; + uint32_t record_offset; + uint64_t reg_action; + uint64_t reg_value; + uint64_t record_identifier; + ERSTStorageHeader *header; + unsigned first_record_index; + unsigned last_record_index; + unsigned next_record_index; + +} ERSTDeviceState; + +/*******************************************************************/ +/*******************************************************************/ +static uint8_t *get_nvram_ptr_by_index(ERSTDeviceState *s, unsigned index) +{ + uint8_t *rc =3D NULL; + off_t offset =3D (index * le32_to_cpu(s->header->record_size)); + + g_assert(offset < s->storage_size); + + rc =3D memory_region_get_ram_ptr(s->hostmem_mr); + rc +=3D offset; + + return rc; +} + +static void make_erst_storage_header(ERSTDeviceState *s) +{ + ERSTStorageHeader *header =3D s->header; + unsigned mapsz, headersz; + + header->magic =3D cpu_to_le64(ERST_STORE_MAGIC); + header->record_size =3D cpu_to_le32(s->default_record_size); + header->version =3D cpu_to_le16(0x0100); + header->reserved =3D cpu_to_le16(0x0000); + + /* Compute mapsize */ + mapsz =3D s->storage_size / s->default_record_size; + mapsz *=3D sizeof(uint64_t); + /* Compute header+map size */ + headersz =3D sizeof(ERSTStorageHeader) + mapsz; + /* Round up to nearest integer multiple of ERST_RECORD_SIZE */ + headersz =3D QEMU_ALIGN_UP(headersz, s->default_record_size); + header->storage_offset =3D cpu_to_le32(headersz); + + /* + * The HostMemoryBackend initializes contents to zero, + * so all record_ids stashed in the map are zero'd. + * As well the record_count is zero. Properly initialized. + */ +} + +static void check_erst_backend_storage(ERSTDeviceState *s, Error **errp) +{ + ERSTStorageHeader *header; + uint32_t record_size; + + header =3D memory_region_get_ram_ptr(s->hostmem_mr); + s->header =3D header; + + /* Ensure pointer to header is 64-bit aligned */ + g_assert(QEMU_PTR_IS_ALIGNED(header, sizeof(uint64_t))); + + /* + * Check if header is uninitialized; HostMemoryBackend inits to 0 + */ + if (le64_to_cpu(header->magic) =3D=3D 0UL) { + make_erst_storage_header(s); + } + + /* Validity check record_size */ + record_size =3D le32_to_cpu(header->record_size); + if (!( + (record_size) && /* non zero */ + (record_size >=3D UEFI_CPER_RECORD_MIN_SIZE) && + (((record_size - 1) & record_size) =3D=3D 0) && /* is power of 2 */ + (record_size >=3D 4096) /* PAGE_SIZE */ + )) { + error_setg(errp, "ERST record_size %u is invalid", record_size); + } + + /* Validity check header */ + if (!( + (le64_to_cpu(header->magic) =3D=3D ERST_STORE_MAGIC) && + ((le32_to_cpu(header->storage_offset) % record_size) =3D=3D 0) && + (le16_to_cpu(header->version) =3D=3D 0x0100) && + (le16_to_cpu(header->reserved) =3D=3D 0) + )) { + error_setg(errp, "ERST backend storage header is invalid"); + } + + /* Check storage_size against record_size */ + if (((s->storage_size % record_size) !=3D 0) || + (record_size > s->storage_size)) { + error_setg(errp, "ACPI ERST requires storage size be multiple of " + "record size (%uKiB)", record_size); + } + + /* Compute offset of first and last record storage slot */ + s->first_record_index =3D le32_to_cpu(header->storage_offset) + / record_size; + s->last_record_index =3D (s->storage_size / record_size); +} + +static void update_map_entry(ERSTDeviceState *s, unsigned index, + uint64_t record_id) +{ + if (index < s->last_record_index) { + s->header->map[index] =3D cpu_to_le64(record_id); + } +} + +static unsigned find_next_empty_record_index(ERSTDeviceState *s) +{ + unsigned rc =3D 0; /* 0 not a valid index */ + unsigned index =3D s->first_record_index; + + for (; index < s->last_record_index; ++index) { + if (le64_to_cpu(s->header->map[index]) =3D=3D ERST_UNSPECIFIED_REC= ORD_ID) { + rc =3D index; + break; + } + } + + return rc; +} + +static unsigned lookup_erst_record(ERSTDeviceState *s, + uint64_t record_identifier) +{ + unsigned rc =3D 0; /* 0 not a valid index */ + + /* Find the record_identifier in the map */ + if (record_identifier !=3D ERST_UNSPECIFIED_RECORD_ID) { + /* + * Count number of valid records encountered, and + * short-circuit the loop if identifier not found + */ + uint32_t record_count =3D le32_to_cpu(s->header->record_count); + unsigned count =3D 0; + unsigned index; + for (index =3D s->first_record_index; index < s->last_record_index= && + count < record_count; ++index) { + if (le64_to_cpu(s->header->map[index]) =3D=3D record_identifie= r) { + rc =3D index; + break; + } + if (le64_to_cpu(s->header->map[index]) !=3D + ERST_UNSPECIFIED_RECORD_ID) { + ++count; + } + } + } + + return rc; +} + +/* + * ACPI 4.0: 17.4.1.1 Serialization Actions, also see + * ACPI 4.0: 17.4.2.2 Operations - Reading 6.c and 2.c + */ +static unsigned get_next_record_identifier(ERSTDeviceState *s, + uint64_t *record_identifier, bool first) +{ + unsigned found =3D 0; + unsigned index; + + /* For operations needing to return 'first' record identifier */ + if (first) { + /* Reset initial index to beginning */ + s->next_record_index =3D s->first_record_index; + } + index =3D s->next_record_index; + + *record_identifier =3D ERST_EMPTY_END_RECORD_ID; + + if (le32_to_cpu(s->header->record_count)) { + for (; index < s->last_record_index; ++index) { + if (le64_to_cpu(s->header->map[index]) !=3D + ERST_UNSPECIFIED_RECORD_ID) { + /* where to start next time */ + s->next_record_index =3D index + 1; + *record_identifier =3D le64_to_cpu(s->header->map[inde= x]); + found =3D 1; + break; + } + } + } + if (!found) { + /* at end (ie scan complete), reset */ + s->next_record_index =3D s->first_record_index; + } + + return STATUS_SUCCESS; +} + +/* ACPI 4.0: 17.4.2.3 Operations - Clearing */ +static unsigned clear_erst_record(ERSTDeviceState *s) +{ + unsigned rc =3D STATUS_RECORD_NOT_FOUND; + unsigned index; + + /* Check for valid record identifier */ + if (!ERST_IS_VALID_RECORD_ID(s->record_identifier)) { + return STATUS_FAILED; + } + + index =3D lookup_erst_record(s, s->record_identifier); + if (index) { + /* No need to wipe record, just invalidate its map entry */ + uint32_t record_count; + update_map_entry(s, index, ERST_UNSPECIFIED_RECORD_ID); + record_count =3D le32_to_cpu(s->header->record_count); + record_count -=3D 1; + s->header->record_count =3D cpu_to_le32(record_count); + rc =3D STATUS_SUCCESS; + } + + return rc; +} + +/* ACPI 4.0: 17.4.2.2 Operations - Reading */ +static unsigned read_erst_record(ERSTDeviceState *s) +{ + unsigned rc =3D STATUS_RECORD_NOT_FOUND; + unsigned exchange_length; + unsigned index; + + /* Check if backend storage is empty */ + if (le32_to_cpu(s->header->record_count) =3D=3D 0) { + return STATUS_RECORD_STORE_EMPTY; + } + + exchange_length =3D memory_region_size(&s->exchange_mr); + + /* Check for record identifier of all 0s */ + if (s->record_identifier =3D=3D ERST_UNSPECIFIED_RECORD_ID) { + /* Set to 'first' record in storage */ + get_next_record_identifier(s, &s->record_identifier, true); + /* record_identifier is now a valid id, or all 1s */ + } + + /* Check for record identifier of all 1s */ + if (s->record_identifier =3D=3D ERST_EMPTY_END_RECORD_ID) { + return STATUS_FAILED; + } + + /* Validate record_offset */ + if (s->record_offset > (exchange_length - UEFI_CPER_RECORD_MIN_SIZE)) { + return STATUS_FAILED; + } + + index =3D lookup_erst_record(s, s->record_identifier); + if (index) { + uint8_t *nvram; + uint8_t *exchange; + uint32_t record_length; + + /* Obtain pointer to the exchange buffer */ + exchange =3D memory_region_get_ram_ptr(&s->exchange_mr); + exchange +=3D s->record_offset; + /* Obtain pointer to slot in storage */ + nvram =3D get_nvram_ptr_by_index(s, index); + /* Validate CPER record_length */ + memcpy((uint8_t *)&record_length, + &nvram[UEFI_CPER_RECORD_LENGTH_OFFSET], + sizeof(uint32_t)); + record_length =3D le32_to_cpu(record_length); + if (record_length < UEFI_CPER_RECORD_MIN_SIZE) { + rc =3D STATUS_FAILED; + } + if ((s->record_offset + record_length) > exchange_length) { + rc =3D STATUS_FAILED; + } + /* If all is ok, copy the record to the exchange buffer */ + if (rc !=3D STATUS_FAILED) { + memcpy(exchange, nvram, record_length); + rc =3D STATUS_SUCCESS; + } + } else { + /* + * See "Reading : 'The steps performed by the platform ...' 2.c" + * Set to 'first' record in storage + */ + get_next_record_identifier(s, &s->record_identifier, true); + } + + return rc; +} + +/* ACPI 4.0: 17.4.2.1 Operations - Writing */ +static unsigned write_erst_record(ERSTDeviceState *s) +{ + unsigned rc =3D STATUS_FAILED; + unsigned exchange_length; + unsigned index; + uint64_t record_identifier; + uint32_t record_length; + uint8_t *exchange; + uint8_t *nvram =3D NULL; + bool record_found =3D false; + + exchange_length =3D memory_region_size(&s->exchange_mr); + + /* Validate record_offset */ + if (s->record_offset > (exchange_length - UEFI_CPER_RECORD_MIN_SIZE)) { + return STATUS_FAILED; + } + + /* Obtain pointer to record in the exchange buffer */ + exchange =3D memory_region_get_ram_ptr(&s->exchange_mr); + exchange +=3D s->record_offset; + + /* Validate CPER record_length */ + memcpy((uint8_t *)&record_length, &exchange[UEFI_CPER_RECORD_LENGTH_OF= FSET], + sizeof(uint32_t)); + record_length =3D le32_to_cpu(record_length); + if (record_length < UEFI_CPER_RECORD_MIN_SIZE) { + return STATUS_FAILED; + } + if ((s->record_offset + record_length) > exchange_length) { + return STATUS_FAILED; + } + + /* Extract record identifier */ + memcpy((uint8_t *)&record_identifier, &exchange[UEFI_CPER_RECORD_ID_OF= FSET], + sizeof(uint64_t)); + record_identifier =3D le64_to_cpu(record_identifier); + + /* Check for valid record identifier */ + if (!ERST_IS_VALID_RECORD_ID(record_identifier)) { + return STATUS_FAILED; + } + + index =3D lookup_erst_record(s, record_identifier); + if (index) { + /* Record found, overwrite existing record */ + nvram =3D get_nvram_ptr_by_index(s, index); + record_found =3D true; + } else { + /* Record not found, not an overwrite, allocate for write */ + index =3D find_next_empty_record_index(s); + if (index) { + nvram =3D get_nvram_ptr_by_index(s, index); + } else { + /* All slots are occupied */ + rc =3D STATUS_NOT_ENOUGH_SPACE; + } + } + if (nvram) { + /* Write the record into the slot */ + memcpy(nvram, exchange, record_length); + memset(nvram + record_length, exchange_length - record_length, 0xF= F); + /* If a new record, increment the record_count */ + if (!record_found) { + uint32_t record_count; + record_count =3D le32_to_cpu(s->header->record_count); + record_count +=3D 1; /* writing new record */ + s->header->record_count =3D cpu_to_le32(record_count); + } + update_map_entry(s, index, record_identifier); + rc =3D STATUS_SUCCESS; + } + + return rc; +} + +/*******************************************************************/ + +static uint64_t erst_rd_reg64(hwaddr addr, + uint64_t reg, unsigned size) +{ + uint64_t rdval; + uint64_t mask; + unsigned shift; + + if (size =3D=3D sizeof(uint64_t)) { + /* 64b access */ + mask =3D 0xFFFFFFFFFFFFFFFFUL; + shift =3D 0; + } else { + /* 32b access */ + mask =3D 0x00000000FFFFFFFFUL; + shift =3D ((addr & 0x4) =3D=3D 0x4) ? 32 : 0; + } + + rdval =3D reg; + rdval >>=3D shift; + rdval &=3D mask; + + return rdval; +} + +static uint64_t erst_wr_reg64(hwaddr addr, + uint64_t reg, uint64_t val, unsigned size) +{ + uint64_t wrval; + uint64_t mask; + unsigned shift; + + if (size =3D=3D sizeof(uint64_t)) { + /* 64b access */ + mask =3D 0xFFFFFFFFFFFFFFFFUL; + shift =3D 0; + } else { + /* 32b access */ + mask =3D 0x00000000FFFFFFFFUL; + shift =3D ((addr & 0x4) =3D=3D 0x4) ? 32 : 0; + } + + val &=3D mask; + val <<=3D shift; + mask <<=3D shift; + wrval =3D reg; + wrval &=3D ~mask; + wrval |=3D val; + + return wrval; +} + +static void erst_reg_write(void *opaque, hwaddr addr, + uint64_t val, unsigned size) +{ + ERSTDeviceState *s =3D (ERSTDeviceState *)opaque; + + /* + * NOTE: All actions/operations/side effects happen on the WRITE, + * by this implementation's design. The READs simply return the + * reg_value contents. + */ + trace_acpi_erst_reg_write(addr, val, size); + + switch (addr) { + case ERST_VALUE_OFFSET + 0: + case ERST_VALUE_OFFSET + 4: + s->reg_value =3D erst_wr_reg64(addr, s->reg_value, val, size); + break; + case ERST_ACTION_OFFSET + 0: + /* + * NOTE: all valid values written to this register are of the + * ACTION_* variety. Thus there is no need to make this a 64-bit + * register, 32-bits is appropriate. As such ERST_ACTION_OFFSET+4 + * is not needed. + */ + switch (val) { + case ACTION_BEGIN_WRITE_OPERATION: + case ACTION_BEGIN_READ_OPERATION: + case ACTION_BEGIN_CLEAR_OPERATION: + case ACTION_BEGIN_DUMMY_WRITE_OPERATION: + case ACTION_END_OPERATION: + s->operation =3D val; + break; + case ACTION_SET_RECORD_OFFSET: + s->record_offset =3D s->reg_value; + break; + case ACTION_EXECUTE_OPERATION: + if ((uint8_t)s->reg_value =3D=3D ERST_EXECUTE_OPERATION_MAGIC)= { + s->busy_status =3D 1; + switch (s->operation) { + case ACTION_BEGIN_WRITE_OPERATION: + s->command_status =3D write_erst_record(s); + break; + case ACTION_BEGIN_READ_OPERATION: + s->command_status =3D read_erst_record(s); + break; + case ACTION_BEGIN_CLEAR_OPERATION: + s->command_status =3D clear_erst_record(s); + break; + case ACTION_BEGIN_DUMMY_WRITE_OPERATION: + s->command_status =3D STATUS_SUCCESS; + break; + case ACTION_END_OPERATION: + s->command_status =3D STATUS_SUCCESS; + break; + default: + s->command_status =3D STATUS_FAILED; + break; + } + s->busy_status =3D 0; + } + break; + case ACTION_CHECK_BUSY_STATUS: + s->reg_value =3D s->busy_status; + break; + case ACTION_GET_COMMAND_STATUS: + s->reg_value =3D s->command_status; + break; + case ACTION_GET_RECORD_IDENTIFIER: + s->command_status =3D get_next_record_identifier(s, + &s->reg_value, false); + break; + case ACTION_SET_RECORD_IDENTIFIER: + s->record_identifier =3D s->reg_value; + break; + case ACTION_GET_RECORD_COUNT: + s->reg_value =3D le32_to_cpu(s->header->record_count); + break; + case ACTION_GET_ERROR_LOG_ADDRESS_RANGE: + s->reg_value =3D (hwaddr)pci_get_bar_addr(PCI_DEVICE(s), 1); + break; + case ACTION_GET_ERROR_LOG_ADDRESS_LENGTH: + s->reg_value =3D le32_to_cpu(s->header->record_size); + break; + case ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES: + s->reg_value =3D 0x0; /* intentional, not NVRAM mode */ + break; + case ACTION_GET_EXECUTE_OPERATION_TIMINGS: + s->reg_value =3D + (100ULL << 32) | /* 100us max time */ + (10ULL << 0) ; /* 10us min time */ + break; + default: + /* Unknown action/command, NOP */ + break; + } + break; + default: + /* This should not happen, but if it does, NOP */ + break; + } +} + +static uint64_t erst_reg_read(void *opaque, hwaddr addr, + unsigned size) +{ + ERSTDeviceState *s =3D (ERSTDeviceState *)opaque; + uint64_t val =3D 0; + + switch (addr) { + case ERST_ACTION_OFFSET + 0: + case ERST_ACTION_OFFSET + 4: + val =3D erst_rd_reg64(addr, s->reg_action, size); + break; + case ERST_VALUE_OFFSET + 0: + case ERST_VALUE_OFFSET + 4: + val =3D erst_rd_reg64(addr, s->reg_value, size); + break; + default: + break; + } + trace_acpi_erst_reg_read(addr, val, size); + return val; +} + +static const MemoryRegionOps erst_reg_ops =3D { + .read =3D erst_reg_read, + .write =3D erst_reg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, +}; + +/*******************************************************************/ +/*******************************************************************/ +static int erst_post_load(void *opaque, int version_id) +{ + ERSTDeviceState *s =3D opaque; + + /* Recompute pointer to header */ + s->header =3D (ERSTStorageHeader *)get_nvram_ptr_by_index(s, 0); + trace_acpi_erst_post_load(s->header, le32_to_cpu(s->header->record_siz= e)); + + return 0; +} + +static const VMStateDescription erst_vmstate =3D { + .name =3D "acpi-erst", + .version_id =3D 1, + .minimum_version_id =3D 1, + .post_load =3D erst_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(operation, ERSTDeviceState), + VMSTATE_UINT8(busy_status, ERSTDeviceState), + VMSTATE_UINT8(command_status, ERSTDeviceState), + VMSTATE_UINT32(record_offset, ERSTDeviceState), + VMSTATE_UINT64(reg_action, ERSTDeviceState), + VMSTATE_UINT64(reg_value, ERSTDeviceState), + VMSTATE_UINT64(record_identifier, ERSTDeviceState), + VMSTATE_UINT32(next_record_index, ERSTDeviceState), + VMSTATE_END_OF_LIST() + } +}; + +static void erst_realizefn(PCIDevice *pci_dev, Error **errp) +{ + ERSTDeviceState *s =3D ACPIERST(pci_dev); + + trace_acpi_erst_realizefn_in(); + + if (!s->hostmem) { + error_setg(errp, "'" ACPI_ERST_MEMDEV_PROP "' property is not set"= ); + return; + } else if (host_memory_backend_is_mapped(s->hostmem)) { + error_setg(errp, "can't use already busy memdev: %s", + object_get_canonical_path_component(OBJECT(s->hostmem))= ); + return; + } + + s->hostmem_mr =3D host_memory_backend_get_memory(s->hostmem); + + /* HostMemoryBackend size will be multiple of PAGE_SIZE */ + s->storage_size =3D object_property_get_int(OBJECT(s->hostmem), "size"= , errp); + + /* Initialize backend storage and record_count */ + check_erst_backend_storage(s, errp); + + /* BAR 0: Programming registers */ + memory_region_init_io(&s->iomem_mr, OBJECT(pci_dev), &erst_reg_ops, s, + TYPE_ACPI_ERST, ERST_REG_SIZE); + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->iomem_= mr); + + /* BAR 1: Exchange buffer memory */ + memory_region_init_ram(&s->exchange_mr, OBJECT(pci_dev), + "erst.exchange", + le32_to_cpu(s->header->record_size), errp); + pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, + &s->exchange_mr); + + /* Include the backend storage in the migration stream */ + vmstate_register_ram_global(s->hostmem_mr); + + trace_acpi_erst_realizefn_out(s->storage_size); +} + +static void erst_reset(DeviceState *dev) +{ + ERSTDeviceState *s =3D ACPIERST(dev); + + trace_acpi_erst_reset_in(le32_to_cpu(s->header->record_count)); + s->operation =3D 0; + s->busy_status =3D 0; + s->command_status =3D STATUS_SUCCESS; + s->record_identifier =3D ERST_UNSPECIFIED_RECORD_ID; + s->record_offset =3D 0; + s->next_record_index =3D s->first_record_index; + /* NOTE: first/last_record_index are computed only once */ + trace_acpi_erst_reset_out(le32_to_cpu(s->header->record_count)); +} + +static Property erst_properties[] =3D { + DEFINE_PROP_LINK(ACPI_ERST_MEMDEV_PROP, ERSTDeviceState, hostmem, + TYPE_MEMORY_BACKEND, HostMemoryBackend *), + DEFINE_PROP_UINT32(ACPI_ERST_RECORD_SIZE_PROP, ERSTDeviceState, + default_record_size, ERST_RECORD_SIZE), + DEFINE_PROP_END_OF_LIST(), +}; + +static void erst_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + trace_acpi_erst_class_init_in(); + k->realize =3D erst_realizefn; + k->vendor_id =3D PCI_VENDOR_ID_REDHAT; + k->device_id =3D PCI_DEVICE_ID_REDHAT_ACPI_ERST; + k->revision =3D 0x00; + k->class_id =3D PCI_CLASS_OTHERS; + dc->reset =3D erst_reset; + dc->vmsd =3D &erst_vmstate; + dc->user_creatable =3D true; + dc->hotpluggable =3D false; + device_class_set_props(dc, erst_properties); + dc->desc =3D "ACPI Error Record Serialization Table (ERST) device"; + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + trace_acpi_erst_class_init_out(); +} + +static const TypeInfo erst_type_info =3D { + .name =3D TYPE_ACPI_ERST, + .parent =3D TYPE_PCI_DEVICE, + .class_init =3D erst_class_init, + .instance_size =3D sizeof(ERSTDeviceState), + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { } + } +}; + +static void erst_register_types(void) +{ + type_register_static(&erst_type_info); +} + +type_init(erst_register_types) diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 622b0b50b7..19caebde6c 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -10,6 +10,7 @@ config ACPI_X86 select ACPI_HMAT select ACPI_PIIX4 select ACPI_PCIHP + select ACPI_ERST =20 config ACPI_X86_ICH bool @@ -60,3 +61,8 @@ config ACPI_HW_REDUCED select ACPI select ACPI_MEMORY_HOTPLUG select ACPI_NVDIMM + +config ACPI_ERST + bool + default y + depends on ACPI && PCI diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build index adf6347bc4..f5b22983bb 100644 --- a/hw/acpi/meson.build +++ b/hw/acpi/meson.build @@ -22,6 +22,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_true: files('pc= ihp.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_false: files('acpi-pci-hotplug-s= tub.c')) acpi_ss.add(when: 'CONFIG_ACPI_VIOT', if_true: files('viot.c')) acpi_ss.add(when: 'CONFIG_ACPI_X86_ICH', if_true: files('ich9.c', 'tco.c')) +acpi_ss.add(when: 'CONFIG_ACPI_ERST', if_true: files('erst.c')) acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'), if_false: files= ('ipmi-stub.c')) acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c')) acpi_ss.add(when: 'CONFIG_TPM', if_true: files('tpm.c')) diff --git a/hw/acpi/trace-events b/hw/acpi/trace-events index 974d770e8b..2250126a22 100644 --- a/hw/acpi/trace-events +++ b/hw/acpi/trace-events @@ -55,3 +55,18 @@ piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t= val) "addr: 0x%" PRIx64 # tco.c tco_timer_reload(int ticks, int msec) "ticks=3D%d (%d ms)" tco_timer_expired(int timeouts_no, bool strap, bool no_reboot) "timeouts_n= o=3D%d no_reboot=3D%d/%d" + +# erst.c +acpi_erst_reg_write(uint64_t addr, uint64_t val, unsigned size) "addr: 0x%= 04" PRIx64 " <=3D=3D 0x%016" PRIx64 " (size: %u)" +acpi_erst_reg_read(uint64_t addr, uint64_t val, unsigned size) " addr: 0x%= 04" PRIx64 " =3D=3D> 0x%016" PRIx64 " (size: %u)" +acpi_erst_mem_write(uint64_t addr, uint64_t val, unsigned size) "addr: 0x%= 06" PRIx64 " <=3D=3D 0x%016" PRIx64 " (size: %u)" +acpi_erst_mem_read(uint64_t addr, uint64_t val, unsigned size) " addr: 0x%= 06" PRIx64 " =3D=3D> 0x%016" PRIx64 " (size: %u)" +acpi_erst_pci_bar_0(uint64_t addr) "BAR0: 0x%016" PRIx64 +acpi_erst_pci_bar_1(uint64_t addr) "BAR1: 0x%016" PRIx64 +acpi_erst_realizefn_in(void) +acpi_erst_realizefn_out(unsigned size) "total nvram size %u bytes" +acpi_erst_reset_in(unsigned record_count) "record_count %u" +acpi_erst_reset_out(unsigned record_count) "record_count %u" +acpi_erst_post_load(void *header, unsigned slot_size) "header: 0x%p slot_s= ize %u" +acpi_erst_class_init_in(void) +acpi_erst_class_init_out(void) --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644026334415829.2624863326749; Fri, 4 Feb 2022 17:58:54 -0800 (PST) Received: from localhost ([::1]:36614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGALl-0003Vh-BV for importer@patchew.org; Fri, 04 Feb 2022 20:58:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7M-0003xV-SF for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33941) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7K-0003Pp-72 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:00 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605-nYUuqedrPZ-eKU-KJBE4mQ-1; Fri, 04 Feb 2022 20:43:56 -0500 Received: by mail-wm1-f71.google.com with SMTP id n22-20020a05600c3b9600b00352d3f6a850so1218932wms.3 for ; Fri, 04 Feb 2022 17:43:56 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id s9sm3435810wrr.84.2022.02.04.17.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025437; 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: in-reply-to:in-reply-to:references:references; bh=khQalQB6Tn2bzPaF1TcsZBjtnToq63R/r1Y7j7Hsluw=; b=AqK9O0PHM4C3El7/NUl7UGvp2eTeI19N/1PoWGXFasRCRikxSRFO8p7uEtdAePYGBMMwUO vN7BTI5QaQ7kTAX3QE0Q9xZ1b6vp4tqpCWHz2+N/kTGHJRbEMg5IOopmR6wvd0k5on2dRC xgjIdNLXbPz0kEztbe9CGW9J6Xsf6dk= X-MC-Unique: nYUuqedrPZ-eKU-KJBE4mQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=khQalQB6Tn2bzPaF1TcsZBjtnToq63R/r1Y7j7Hsluw=; b=U6YtQM7ZU1Yz8MqoV4N/KQBciNULk6OFJNv8eXV/XaeyKmtogxju+2/kKU6pi+favp Z0xMsyPmdZogrCGIoiclW0SLVPfE9N09rDDphODbYDOXuANVYHb8WyBjjHbNALhFWLc9 JwX9KqsUJryBBHlwzBR9sscMqQoj3o4EyNS17TcyTY19Dw/KYEoqsngzAVMkMRidzmxM 8Nj6sQ/tEEBkwnRkUn1oqDhWJKcii5/Civ5dm44bpKA+dBePTvbDw65t75honV23xwS5 Nx8ljPVL++h3LUYRihdqhE9oFzpToLAaxvFaNQl+ODI4SgkvESUce1CmVSZomH9FeRl3 l7Mg== X-Gm-Message-State: AOAM532vvHjil2tRkff1n41h5PYUBMEkG7+d4oAvizYIlABGkAPUqUAZ Zq3uO8hnk7t0uNif4PEBfTMd9zwilY3LmLv6gsXeOBblwjunv3pKeF8rv/84es8OsDJ5nPsEwiR bKggt+RgtieW/7fEgJBd7/m4LiA4APrgVfEu+WMb9CioJeI61igyqs53xzHw2 X-Received: by 2002:a1c:6a14:: with SMTP id f20mr4382794wmc.177.1644025435389; Fri, 04 Feb 2022 17:43:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtUOOLBJnF2zXv2zAj5RmbXeduo/Kvpp3VFqi5M4S7yX9UARPjBFkfMPh72QzAyDsWxIvbsA== X-Received: by 2002:a1c:6a14:: with SMTP id f20mr4382784wmc.177.1644025435061; Fri, 04 Feb 2022 17:43:55 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 27/32] ACPI ERST: build the ACPI ERST table Message-ID: <20220205014149.1189026-28-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Eric DeVolder , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644026334744100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder This builds the ACPI ERST table to inform OSPM how to communicate with the acpi-erst device. Signed-off-by: Eric DeVolder Reviewed-by: Ani Sinha Message-Id: <1643402289-22216-7-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/erst.c | 211 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c index fe9ba51de7..cd32aa7d4f 100644 --- a/hw/acpi/erst.c +++ b/hw/acpi/erst.c @@ -59,6 +59,27 @@ #define STATUS_RECORD_STORE_EMPTY 0x04 #define STATUS_RECORD_NOT_FOUND 0x05 =20 +/* ACPI 4.0: Table 17-19 Serialization Instructions */ +#define INST_READ_REGISTER 0x00 +#define INST_READ_REGISTER_VALUE 0x01 +#define INST_WRITE_REGISTER 0x02 +#define INST_WRITE_REGISTER_VALUE 0x03 +#define INST_NOOP 0x04 +#define INST_LOAD_VAR1 0x05 +#define INST_LOAD_VAR2 0x06 +#define INST_STORE_VAR1 0x07 +#define INST_ADD 0x08 +#define INST_SUBTRACT 0x09 +#define INST_ADD_VALUE 0x0A +#define INST_SUBTRACT_VALUE 0x0B +#define INST_STALL 0x0C +#define INST_STALL_WHILE_TRUE 0x0D +#define INST_SKIP_NEXT_INSTRUCTION_IF_TRUE 0x0E +#define INST_GOTO 0x0F +#define INST_SET_SRC_ADDRESS_BASE 0x10 +#define INST_SET_DST_ADDRESS_BASE 0x11 +#define INST_MOVE_DATA 0x12 + /* UEFI 2.1: Appendix N Common Platform Error Record */ #define UEFI_CPER_RECORD_MIN_SIZE 128U #define UEFI_CPER_RECORD_LENGTH_OFFSET 20U @@ -170,6 +191,196 @@ typedef struct { =20 } ERSTDeviceState; =20 +/*******************************************************************/ +/*******************************************************************/ +typedef struct { + GArray *table_data; + pcibus_t bar; + uint8_t instruction; + uint8_t flags; + uint8_t register_bit_width; + pcibus_t register_offset; +} BuildSerializationInstructionEntry; + +/* ACPI 4.0: 17.4.1.2 Serialization Instruction Entries */ +static void build_serialization_instruction( + BuildSerializationInstructionEntry *e, + uint8_t serialization_action, + uint64_t value) +{ + /* ACPI 4.0: Table 17-18 Serialization Instruction Entry */ + struct AcpiGenericAddress gas; + uint64_t mask; + + /* Serialization Action */ + build_append_int_noprefix(e->table_data, serialization_action, 1); + /* Instruction */ + build_append_int_noprefix(e->table_data, e->instruction, 1); + /* Flags */ + build_append_int_noprefix(e->table_data, e->flags, 1); + /* Reserved */ + build_append_int_noprefix(e->table_data, 0, 1); + /* Register Region */ + gas.space_id =3D AML_SYSTEM_MEMORY; + gas.bit_width =3D e->register_bit_width; + gas.bit_offset =3D 0; + gas.access_width =3D (uint8_t)ctz32(e->register_bit_width) - 2; + gas.address =3D (uint64_t)(e->bar + e->register_offset); + build_append_gas_from_struct(e->table_data, &gas); + /* Value */ + build_append_int_noprefix(e->table_data, value, 8); + /* Mask */ + mask =3D (1ULL << (e->register_bit_width - 1) << 1) - 1; + build_append_int_noprefix(e->table_data, mask, 8); +} + +/* ACPI 4.0: 17.4.1 Serialization Action Table */ +void build_erst(GArray *table_data, BIOSLinker *linker, Object *erst_dev, + const char *oem_id, const char *oem_table_id) +{ + /* + * Serialization Action Table + * The serialization action table must be generated first + * so that its size can be known in order to populate the + * Instruction Entry Count field. + */ + unsigned action; + GArray *table_instruction_data =3D g_array_new(FALSE, FALSE, sizeof(ch= ar)); + pcibus_t bar0 =3D pci_get_bar_addr(PCI_DEVICE(erst_dev), 0); + AcpiTable table =3D { .sig =3D "ERST", .rev =3D 1, .oem_id =3D oem_id, + .oem_table_id =3D oem_table_id }; + /* Contexts for the different ways ACTION and VALUE are accessed */ + BuildSerializationInstructionEntry rd_value_32_val =3D { + .table_data =3D table_instruction_data, .bar =3D bar0, .flags =3D = 0, + .instruction =3D INST_READ_REGISTER_VALUE, + .register_bit_width =3D 32, + .register_offset =3D ERST_VALUE_OFFSET, + }; + BuildSerializationInstructionEntry rd_value_32 =3D { + .table_data =3D table_instruction_data, .bar =3D bar0, .flags =3D = 0, + .instruction =3D INST_READ_REGISTER, + .register_bit_width =3D 32, + .register_offset =3D ERST_VALUE_OFFSET, + }; + BuildSerializationInstructionEntry rd_value_64 =3D { + .table_data =3D table_instruction_data, .bar =3D bar0, .flags =3D = 0, + .instruction =3D INST_READ_REGISTER, + .register_bit_width =3D 64, + .register_offset =3D ERST_VALUE_OFFSET, + }; + BuildSerializationInstructionEntry wr_value_32_val =3D { + .table_data =3D table_instruction_data, .bar =3D bar0, .flags =3D = 0, + .instruction =3D INST_WRITE_REGISTER_VALUE, + .register_bit_width =3D 32, + .register_offset =3D ERST_VALUE_OFFSET, + }; + BuildSerializationInstructionEntry wr_value_32 =3D { + .table_data =3D table_instruction_data, .bar =3D bar0, .flags =3D = 0, + .instruction =3D INST_WRITE_REGISTER, + .register_bit_width =3D 32, + .register_offset =3D ERST_VALUE_OFFSET, + }; + BuildSerializationInstructionEntry wr_value_64 =3D { + .table_data =3D table_instruction_data, .bar =3D bar0, .flags =3D = 0, + .instruction =3D INST_WRITE_REGISTER, + .register_bit_width =3D 64, + .register_offset =3D ERST_VALUE_OFFSET, + }; + BuildSerializationInstructionEntry wr_action =3D { + .table_data =3D table_instruction_data, .bar =3D bar0, .flags =3D = 0, + .instruction =3D INST_WRITE_REGISTER_VALUE, + .register_bit_width =3D 32, + .register_offset =3D ERST_ACTION_OFFSET, + }; + + trace_acpi_erst_pci_bar_0(bar0); + + /* Serialization Instruction Entries */ + action =3D ACTION_BEGIN_WRITE_OPERATION; + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_BEGIN_READ_OPERATION; + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_BEGIN_CLEAR_OPERATION; + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_END_OPERATION; + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_SET_RECORD_OFFSET; + build_serialization_instruction(&wr_value_32, action, 0); + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_EXECUTE_OPERATION; + build_serialization_instruction(&wr_value_32_val, action, + ERST_EXECUTE_OPERATION_MAGIC); + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_CHECK_BUSY_STATUS; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_32_val, action, 0x01); + + action =3D ACTION_GET_COMMAND_STATUS; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_32, action, 0); + + action =3D ACTION_GET_RECORD_IDENTIFIER; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_64, action, 0); + + action =3D ACTION_SET_RECORD_IDENTIFIER; + build_serialization_instruction(&wr_value_64, action, 0); + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_GET_RECORD_COUNT; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_32, action, 0); + + action =3D ACTION_BEGIN_DUMMY_WRITE_OPERATION; + build_serialization_instruction(&wr_action, action, action); + + action =3D ACTION_GET_ERROR_LOG_ADDRESS_RANGE; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_64, action, 0); + + action =3D ACTION_GET_ERROR_LOG_ADDRESS_LENGTH; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_64, action, 0); + + action =3D ACTION_GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_32, action, 0); + + action =3D ACTION_GET_EXECUTE_OPERATION_TIMINGS; + build_serialization_instruction(&wr_action, action, action); + build_serialization_instruction(&rd_value_64, action, 0); + + /* Serialization Header */ + acpi_table_begin(&table, table_data); + + /* Serialization Header Size */ + build_append_int_noprefix(table_data, 48, 4); + + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); + + /* + * Instruction Entry Count + * Each instruction entry is 32 bytes + */ + g_assert((table_instruction_data->len) % 32 =3D=3D 0); + build_append_int_noprefix(table_data, + (table_instruction_data->len / 32), 4); + + /* Serialization Instruction Entries */ + g_array_append_vals(table_data, table_instruction_data->data, + table_instruction_data->len); + g_array_free(table_instruction_data, TRUE); + + acpi_table_end(linker, &table); +} + /*******************************************************************/ /*******************************************************************/ static uint8_t *get_nvram_ptr_by_index(ERSTDeviceState *s, unsigned index) --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644027854858626.0340362452341; Fri, 4 Feb 2022 18:24:14 -0800 (PST) Received: from localhost ([::1]:34536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAkH-0006rZ-Ms for importer@patchew.org; Fri, 04 Feb 2022 21:24:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7P-0003yf-RL for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7N-0003Qm-RQ for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:03 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-314--6n7n7FoNaOtu9ujD5JgEQ-1; Fri, 04 Feb 2022 20:44:00 -0500 Received: by mail-wm1-f69.google.com with SMTP id ay8-20020a05600c1e0800b00350de81da56so1209178wmb.9 for ; Fri, 04 Feb 2022 17:43:59 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id n13sm3078734wrv.94.2022.02.04.17.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025441; 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: in-reply-to:in-reply-to:references:references; bh=Xdn3hH7GYkmOyJreuMxMec/MdQOpS7XbSzRxBzQ41Cg=; b=Pwtl86AjaWv8Vdg7Px7qKxatj1t7uT4LUMCf8Af9dTojeOJyBA4hn2xxeRRbfhbDq3yuA7 3JO4SBTB1AhZynAD5k/FuULockCRjrC1sDptCs43WzdcZRbJ0T2suR0F6ddIopRfoUKSgD 7NiP7xrflr0PhNv/AU2tgmMY2cjlx8U= X-MC-Unique: -6n7n7FoNaOtu9ujD5JgEQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Xdn3hH7GYkmOyJreuMxMec/MdQOpS7XbSzRxBzQ41Cg=; b=qURClf4/DbX/Ls6vXFEFQSELZpCXTNDvW3GuSlDrq5M5jK5siY6cEiImW7sd+npJqa wwzAr73lqxRS7EhRW7S3d0ETiPJOznCARoPUC4k13pqe7SzeI/bmF2j3l8NVilXwt71S vovSZH4gYJlAnJXjYS2PlHZ512gM0mbIUnYroDAEgTqYGN1Wbm3+to5uLLWdQmA/TIR+ KYOO0kQBy9ZWcxa0dcHYOaQGs5aEHkYWdZqGw7ZRoxXLVAUx1W/PiGNizu0osp8b8rxh O/uh0tl4lorgb1LTBMogOpvz3/gB49tHjBbD5AaTCdghnJqIuuHcFYZXVzBkYwu027hz CHlw== X-Gm-Message-State: AOAM530Ym6geDgYQSWU19GcCm7yfzJJZOxaKpBBjhR32Ig6EnXuDTkOw UI/ZxrFAb7O1Q+KDjIJb9QIvbC5QxSUKceb6ivrYxTIC0FamzqomOMCOUNCKtktD80qy1yT/gOj V5wh3CEDRHQPrHng053pCx92ve4I8jvbho9xuzhgmdJjP/AISLrw6yNPk5Kn2 X-Received: by 2002:a5d:448b:: with SMTP id j11mr1281885wrq.172.1644025437591; Fri, 04 Feb 2022 17:43:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyjJNORkxY9vSkK33YfIOkNNFvNd3xfbHlHSMTzw0NuVwK7NuXJb9DoKFB48n1kd7dwoOhgQ== X-Received: by 2002:a5d:448b:: with SMTP id j11mr1281866wrq.172.1644025437343; Fri, 04 Feb 2022 17:43:57 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 28/32] ACPI ERST: create ACPI ERST table for pc/x86 machines Message-ID: <20220205014149.1189026-29-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Eduardo Habkost , Peter Maydell , Richard Henderson , Igor Mammedov , Ani Sinha , Paolo Bonzini , Eric DeVolder Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644027856743100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder This change exposes ACPI ERST support for x86 guests. Signed-off-by: Eric DeVolder Reviewed-by: Ani Sinha Message-Id: <1643402289-22216-8-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/erst.h | 5 +++++ hw/i386/acpi-build.c | 15 +++++++++++++++ hw/i386/acpi-microvm.c | 15 +++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/include/hw/acpi/erst.h b/include/hw/acpi/erst.h index 9d637179fe..b747fe7739 100644 --- a/include/hw/acpi/erst.h +++ b/include/hw/acpi/erst.h @@ -16,4 +16,9 @@ void build_erst(GArray *table_data, BIOSLinker *linker, O= bject *erst_dev, =20 #define TYPE_ACPI_ERST "acpi-erst" =20 +/* returns NULL unless there is exactly one device */ +static inline Object *find_erst_dev(void) +{ + return object_resolve_path_type("", TYPE_ACPI_ERST, NULL); +} #endif diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index ce823e8fcb..ebd47aa26f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -43,6 +43,7 @@ #include "sysemu/tpm.h" #include "hw/acpi/tpm.h" #include "hw/acpi/vmgenid.h" +#include "hw/acpi/erst.h" #include "sysemu/tpm_backend.h" #include "hw/rtc/mc146818rtc_regs.h" #include "migration/vmstate.h" @@ -74,6 +75,8 @@ #include "hw/acpi/hmat.h" #include "hw/acpi/viot.h" =20 +#include CONFIG_DEVICES + /* These are used to size the ACPI tables for -M pc-i440fx-1.7 and * -M pc-i440fx-2.0. Even if the actual amount of AML generated grows * a little bit, there should be plenty of free space since the DSDT @@ -2575,6 +2578,18 @@ void acpi_build(AcpiBuildTables *tables, MachineStat= e *machine) ACPI_DEVICE_IF(x86ms->acpi_dev), x86ms->oem_id, x86ms->oem_table_id); =20 +#ifdef CONFIG_ACPI_ERST + { + Object *erst_dev; + erst_dev =3D find_erst_dev(); + if (erst_dev) { + acpi_add_table(table_offsets, tables_blob); + build_erst(tables_blob, tables->linker, erst_dev, + x86ms->oem_id, x86ms->oem_table_id); + } + } +#endif + vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { acpi_add_table(table_offsets, tables_blob); diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 196d318499..68ca7e7fc2 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -30,6 +30,7 @@ #include "hw/acpi/bios-linker-loader.h" #include "hw/acpi/generic_event_device.h" #include "hw/acpi/utils.h" +#include "hw/acpi/erst.h" #include "hw/i386/fw_cfg.h" #include "hw/i386/microvm.h" #include "hw/pci/pci.h" @@ -40,6 +41,8 @@ #include "acpi-common.h" #include "acpi-microvm.h" =20 +#include CONFIG_DEVICES + static void acpi_dsdt_add_virtio(Aml *scope, MicrovmMachineState *mms) { @@ -207,6 +210,18 @@ static void acpi_build_microvm(AcpiBuildTables *tables, ACPI_DEVICE_IF(x86ms->acpi_dev), x86ms->oem_id, x86ms->oem_table_id); =20 +#ifdef CONFIG_ACPI_ERST + { + Object *erst_dev; + erst_dev =3D find_erst_dev(); + if (erst_dev) { + acpi_add_table(table_offsets, tables_blob); + build_erst(tables_blob, tables->linker, erst_dev, + x86ms->oem_id, x86ms->oem_table_id); + } + } +#endif + xsdt =3D tables_blob->len; build_xsdt(tables_blob, tables->linker, table_offsets, x86ms->oem_id, x86ms->oem_table_id); --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644028013636978.858594744665; Fri, 4 Feb 2022 18:26:53 -0800 (PST) Received: from localhost ([::1]:38362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAmq-0001Ab-Du for importer@patchew.org; Fri, 04 Feb 2022 21:26:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7S-000406-0U for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7Q-0003R5-04 for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:05 -0500 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-61-vWrPKc7QMPmksb5d5NxmbA-1; Fri, 04 Feb 2022 20:44:02 -0500 Received: by mail-wm1-f69.google.com with SMTP id c7-20020a1c3507000000b0034a0dfc86aaso8377526wma.6 for ; Fri, 04 Feb 2022 17:44:01 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id n13sm11563812wms.8.2022.02.04.17.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:43:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025443; 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: in-reply-to:in-reply-to:references:references; bh=NQmg5nnOvdPqu5UUH5XFDDk9od1J9XmC5j3kASvo2Do=; b=DN9ovvj7EdgiUv+Ma2ncYiPczYnb9Tqrsrigsh7m5DQOriAMf84po5pggakYWl2+bvG28b ebeR6zWbWzhuSLxQO3zx14Cx7IXkx9I+KgMWGHc2HHz3Shx3G/s7UK9eB4Zu8IerIlr9YC MNb4jWz7hOpw2pVXZyNXjbjrv8r/xfk= X-MC-Unique: vWrPKc7QMPmksb5d5NxmbA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NQmg5nnOvdPqu5UUH5XFDDk9od1J9XmC5j3kASvo2Do=; b=kFeDjDhmUovxDQ9NdECzgGbZizqwYZFval/B+bHSTGf437eheYxOn6a5W3pzsgvYes UCAejSzCC6471xvx5+g9jKHydxFM4bo+6AHEoKOqDK2J8jF40nLmkV9a8cUfx4izhc57 V/xiFXounNpb+wRLeyRBElN48hLa7uNfgK5rq4bIwNWQVDTeVVFl2oNY2PGMo7ki9Wjw tnkAIpDrFK1e9kpCt9pUY8oi3mM9ug2Q6IK5sNv147jXx8P/RA7I8sXVqs999y+xyk25 UeSabC51LU++svs4JACTrcXkU78dbhOoyCSh6mgd3TlAlSwqbG6qSGHIHHbecB15Hx+B fzuw== X-Gm-Message-State: AOAM533jXch4Ks4n5onKNerqIqphRttWU4nnGL+Kart5vS2S7NNCvpPK 5BbrxXxBMTxcaqwxBipwRjeEQuJEPP2O4UU7XqfNaaEFfH1kq03XogtJZJl2oX55HRiKr1ZD+FC xsHdZyCXIF/ihr+ev9X018HVJGRtj8UHqIOpWpWETK7/3yrOphvIgbJACk9bT X-Received: by 2002:a05:600c:4186:: with SMTP id p6mr1173073wmh.12.1644025440524; Fri, 04 Feb 2022 17:44:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJw9HhOWgLiB6oo2RKArck5JCjelmkwV8A9sOR760j/e36V91k0GBddjXr1a92DDkXqKdxeYaA== X-Received: by 2002:a05:600c:4186:: with SMTP id p6mr1173056wmh.12.1644025440255; Fri, 04 Feb 2022 17:44:00 -0800 (PST) Date: Fri, 4 Feb 2022 20:43:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 29/32] ACPI ERST: qtest for ERST Message-ID: <20220205014149.1189026-30-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Ani Sinha , Paolo Bonzini , Eric DeVolder Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644028015186100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder This change provides a qtest that locates and then does a simple interrogation of the ERST feature within the guest. Signed-off-by: Eric DeVolder Reviewed-by: Ani Sinha Message-Id: <1643402289-22216-9-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/erst-test.c | 172 ++++++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 + 2 files changed, 174 insertions(+) create mode 100644 tests/qtest/erst-test.c diff --git a/tests/qtest/erst-test.c b/tests/qtest/erst-test.c new file mode 100644 index 0000000000..f9ad3c9352 --- /dev/null +++ b/tests/qtest/erst-test.c @@ -0,0 +1,172 @@ +/* + * QTest testcase for acpi-erst + * + * Copyright (c) 2021 Oracle + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include +#include "libqos/libqos-pc.h" +#include "libqos/libqtest.h" +#include "qemu-common.h" + +#include "hw/pci/pci.h" + +static void save_fn(QPCIDevice *dev, int devfn, void *data) +{ + QPCIDevice **pdev =3D (QPCIDevice **) data; + + *pdev =3D dev; +} + +static QPCIDevice *get_erst_device(QPCIBus *pcibus) +{ + QPCIDevice *dev; + + dev =3D NULL; + qpci_device_foreach(pcibus, + PCI_VENDOR_ID_REDHAT, + PCI_DEVICE_ID_REDHAT_ACPI_ERST, + save_fn, &dev); + g_assert(dev !=3D NULL); + + return dev; +} + +typedef struct _ERSTState { + QOSState *qs; + QPCIBar reg_bar, mem_bar; + uint64_t reg_barsize, mem_barsize; + QPCIDevice *dev; +} ERSTState; + +#define ACTION 0 +#define VALUE 8 + +static const char *reg2str(unsigned reg) +{ + switch (reg) { + case 0: + return "ACTION"; + case 8: + return "VALUE"; + default: + return NULL; + } +} + +static inline uint32_t in_reg32(ERSTState *s, unsigned reg) +{ + const char *name =3D reg2str(reg); + uint32_t res; + + res =3D qpci_io_readl(s->dev, s->reg_bar, reg); + g_test_message("*%s -> %08x", name, res); + + return res; +} + +static inline uint64_t in_reg64(ERSTState *s, unsigned reg) +{ + const char *name =3D reg2str(reg); + uint64_t res; + + res =3D qpci_io_readq(s->dev, s->reg_bar, reg); + g_test_message("*%s -> %016llx", name, (unsigned long long)res); + + return res; +} + +static inline void out_reg32(ERSTState *s, unsigned reg, uint32_t v) +{ + const char *name =3D reg2str(reg); + + g_test_message("%08x -> *%s", v, name); + qpci_io_writel(s->dev, s->reg_bar, reg, v); +} + +static inline void out_reg64(ERSTState *s, unsigned reg, uint64_t v) +{ + const char *name =3D reg2str(reg); + + g_test_message("%016llx -> *%s", (unsigned long long)v, name); + qpci_io_writeq(s->dev, s->reg_bar, reg, v); +} + +static void cleanup_vm(ERSTState *s) +{ + g_free(s->dev); + qtest_shutdown(s->qs); +} + +static void setup_vm_cmd(ERSTState *s, const char *cmd) +{ + const char *arch =3D qtest_get_arch(); + + if (strcmp(arch, "i386") =3D=3D 0 || strcmp(arch, "x86_64") =3D=3D 0) { + s->qs =3D qtest_pc_boot(cmd); + } else { + g_printerr("erst-test tests are only available on x86\n"); + exit(EXIT_FAILURE); + } + s->dev =3D get_erst_device(s->qs->pcibus); + + s->reg_bar =3D qpci_iomap(s->dev, 0, &s->reg_barsize); + g_assert_cmpuint(s->reg_barsize, =3D=3D, 16); + + s->mem_bar =3D qpci_iomap(s->dev, 1, &s->mem_barsize); + g_assert_cmpuint(s->mem_barsize, =3D=3D, 0x2000); + + qpci_device_enable(s->dev); +} + +static void test_acpi_erst_basic(void) +{ + ERSTState state; + uint64_t log_address_range; + uint64_t log_address_length; + uint32_t log_address_attr; + + setup_vm_cmd(&state, + "-object memory-backend-file," + "mem-path=3Dacpi-erst.XXXXXX," + "size=3D64K," + "share=3Don," + "id=3Dnvram " + "-device acpi-erst," + "memdev=3Dnvram"); + + out_reg32(&state, ACTION, 0xD); + log_address_range =3D in_reg64(&state, VALUE); + out_reg32(&state, ACTION, 0xE); + log_address_length =3D in_reg64(&state, VALUE); + out_reg32(&state, ACTION, 0xF); + log_address_attr =3D in_reg32(&state, VALUE); + + /* Check log_address_range is not 0, ~0 or base */ + g_assert_cmpuint(log_address_range, !=3D, 0ULL); + g_assert_cmpuint(log_address_range, !=3D, ~0ULL); + g_assert_cmpuint(log_address_range, !=3D, state.reg_bar.addr); + g_assert_cmpuint(log_address_range, =3D=3D, state.mem_bar.addr); + + /* Check log_address_length is bar1_size */ + g_assert_cmpuint(log_address_length, =3D=3D, state.mem_barsize); + + /* Check log_address_attr is 0 */ + g_assert_cmpuint(log_address_attr, =3D=3D, 0); + + cleanup_vm(&state); +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/acpi-erst/basic", test_acpi_erst_basic); + ret =3D g_test_run(); + return ret; +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 842b1df420..762f6adcd5 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -68,6 +68,7 @@ qtests_i386 =3D \ (config_all_devices.has_key('CONFIG_RTL8139_PCI') ? ['rtl8139-test'] : [= ]) + \ (config_all_devices.has_key('CONFIG_E1000E_PCI_EXPRESS') ? ['fuzz-e1000e= -test'] : []) + \ (config_all_devices.has_key('CONFIG_ESP_PCI') ? ['am53c974-test'] : []) = + \ + (config_all_devices.has_key('CONFIG_ACPI_ERST') ? ['erst-test'] : []) + = \ (config_all_devices.has_key('CONFIG_VIRTIO_NET') and = \ config_all_devices.has_key('CONFIG_Q35') and = \ config_all_devices.has_key('CONFIG_VIRTIO_PCI') and = \ @@ -278,6 +279,7 @@ qtests =3D { 'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'], 'cdrom-test': files('boot-sector.c'), 'dbus-vmstate-test': files('migration-helpers.c') + dbus_vmstate1, + 'erst-test': files('erst-test.c'), 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'], 'migration-test': files('migration-helpers.c'), 'pxe-test': files('boot-sector.c'), --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 164402808926758.26458257458944; Fri, 4 Feb 2022 18:28:09 -0800 (PST) Received: from localhost ([::1]:40470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAo4-0002bt-AJ for importer@patchew.org; Fri, 04 Feb 2022 21:28:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7V-000497-QQ for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7U-0003Rl-2w for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:09 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-xJ2vnJTvOt23-yZW8O-KwQ-1; Fri, 04 Feb 2022 20:44:05 -0500 Received: by mail-wm1-f70.google.com with SMTP id 203-20020a1c02d4000000b0037b9ff5678cso1140045wmc.4 for ; Fri, 04 Feb 2022 17:44:05 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id k6sm1705107wms.14.2022.02.04.17.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:44:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025447; 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: in-reply-to:in-reply-to:references:references; bh=UMs3Bqr7ndxy424fwUSUxAviE1013bB9zLk/9skNKHQ=; b=earPUV9QyjRTgfUqrD5aUsa99IclqD/j7xjy1jxBJakmwkH+JO9CQIbjSeWfBG1oYWfah8 93/GuAXbESOb4MdZm1Dh6iVGN3jLx99v9hw42nkG/E8hthK6U56nRt0Vaq6DDeuTxfuVFk DYQ3B1jvssb0O2b9kQI5OkmxMvAa7po= X-MC-Unique: xJ2vnJTvOt23-yZW8O-KwQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UMs3Bqr7ndxy424fwUSUxAviE1013bB9zLk/9skNKHQ=; b=3mHfgAbRJ7q9Xu5kpEOgjoXpGvQi1DXn9er/F0da7TV1ShbeHYip/rphnupGVZh6DJ bY0f6m+ZyKnnmzrvvfxd/Cdxtc6bdTzOPwP83+a/Hfm7UVjeBm7tsUcCoFQElaUwqU9+ LdBv2D32Js/o0bqFDmgoG7XxYWKqBwek4rOY/AVmF8c9kPDEK/L3BtxPDGDZ2RXnDGzE ocI+ynIdC5WWVT7I31I9fBN/L75t8V7O0NrNof/x1IG5fv7lYn+lXWcCcYQoGN8YJ3Ih tNLcP/6Sh0QhK7HiZyARP4HMsMixehZkii/osMiAPtFGz6fLyCQtGMtH2n9p3q8UfEwn uRaw== X-Gm-Message-State: AOAM531nRkJJJcB8+dm1atg13x/Go9/0TjxNd47fmkA4J8RSsUlNY1+B YJ1ueJzz5LqwHV49KKLhkgwJqHNEEGf7Tqh7BIQyAR4UD7i7kfEmO/dMk0kOTFfLICFV9Avs9JQ peUjHEWRQHNHmJ7JN8CO0V7pntRUHx8XijBrdELW1dAGuNzsOQ7SgQfygdXCR X-Received: by 2002:a05:600c:3d8a:: with SMTP id bi10mr1186240wmb.62.1644025444207; Fri, 04 Feb 2022 17:44:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzM5wjMJUYE3dQs/jVjS2Pf5/FxnitYerLxg/+8OYNh6MaRFgKL5BowA+BRWwSm3VnBEKG0zQ== X-Received: by 2002:a05:600c:3d8a:: with SMTP id bi10mr1186220wmb.62.1644025443980; Fri, 04 Feb 2022 17:44:03 -0800 (PST) Date: Fri, 4 Feb 2022 20:44:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 30/32] ACPI ERST: bios-tables-test testcase Message-ID: <20220205014149.1189026-31-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Eric DeVolder , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644028091421100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder This change implements the test suite checks for the ERST table. Signed-off-by: Eric DeVolder Reviewed-by: Ani Sinha Message-Id: <1643402289-22216-10-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index ad536fd7b1..c4a2d1e166 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1447,6 +1447,57 @@ static void test_acpi_piix4_tcg_acpi_hmat(void) test_acpi_tcg_acpi_hmat(MACHINE_PC); } =20 +static void test_acpi_erst(const char *machine) +{ + gchar *tmp_path =3D g_dir_make_tmp("qemu-test-erst.XXXXXX", NULL); + gchar *params; + test_data data; + + memset(&data, 0, sizeof(data)); + data.machine =3D machine; + data.variant =3D ".acpierst"; + params =3D g_strdup_printf( + " -object memory-backend-file,id=3Derstnvram," + "mem-path=3D%s,size=3D0x10000,share=3Don" + " -device acpi-erst,memdev=3Derstnvram", tmp_path); + test_acpi_one(params, &data); + free_test_data(&data); + g_free(params); + g_assert(g_rmdir(tmp_path) =3D=3D 0); + g_free(tmp_path); +} + +static void test_acpi_piix4_acpi_erst(void) +{ + test_acpi_erst(MACHINE_PC); +} + +static void test_acpi_q35_acpi_erst(void) +{ + test_acpi_erst(MACHINE_Q35); +} + +static void test_acpi_microvm_acpi_erst(void) +{ + gchar *tmp_path =3D g_dir_make_tmp("qemu-test-erst.XXXXXX", NULL); + gchar *params; + test_data data; + + test_acpi_microvm_prepare(&data); + data.variant =3D ".pcie"; + data.tcg_only =3D true; /* need constant host-phys-bits */ + params =3D g_strdup_printf(" -machine microvm," + "acpi=3Don,ioapic2=3Doff,rtc=3Doff,pcie=3Don" + " -object memory-backend-file,id=3Derstnvram," + "mem-path=3D%s,size=3D0x10000,share=3Don" + " -device acpi-erst,memdev=3Derstnvram", tmp_path); + test_acpi_one(params, &data); + g_free(params); + g_assert(g_rmdir(tmp_path) =3D=3D 0); + g_free(tmp_path); + free_test_data(&data); +} + static void test_acpi_virt_tcg(void) { test_data data =3D { @@ -1672,6 +1723,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm); qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hma= t); qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_tcg_acpi_hmat); + qtest_add_func("acpi/piix4/acpierst", test_acpi_piix4_acpi_erst); + qtest_add_func("acpi/q35/acpierst", test_acpi_q35_acpi_erst); qtest_add_func("acpi/microvm", test_acpi_microvm_tcg); qtest_add_func("acpi/microvm/usb", test_acpi_microvm_usb_tcg); qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc_tcg); @@ -1681,6 +1734,7 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/ivrs", test_acpi_q35_tcg_ivrs); if (strcmp(arch, "x86_64") =3D=3D 0) { qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie= _tcg); + qtest_add_func("acpi/microvm/acpierst", test_acpi_microvm_= acpi_erst); } } if (has_kvm) { --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644028157968587.242673274933; Fri, 4 Feb 2022 18:29:17 -0800 (PST) Received: from localhost ([::1]:42682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGApA-00049b-OM for importer@patchew.org; Fri, 04 Feb 2022 21:29:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7b-0004G4-OP for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7W-0003S2-Cb for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:15 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-13-P0FAPCIHOM-nvwWnCDAg8g-1; Fri, 04 Feb 2022 20:44:08 -0500 Received: by mail-wr1-f70.google.com with SMTP id e1-20020adfa741000000b001e2e74c3d4eso1140787wrd.12 for ; Fri, 04 Feb 2022 17:44:08 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id o8sm2579917wmc.46.2022.02.04.17.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025449; 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: in-reply-to:in-reply-to:references:references; bh=i4ThjWuKIu1CMrgXakalQlwzWxwSWoat70hXPufy2EA=; b=LnY1mV7ZpOYqRM0gN9uS68mN19GAaIGi9QkEkKZG5jpY8kHd9akiMzlJ1gKGn0Pr+ojMME 0MsOJWj6nd/Jj3n3c7Qm0/QAKkUKIxpCXbqHIPHUZVhgpQ/QuYixwSk8zfppL7s5lK4zWd bCvJWj2ktU+Xwpj/hVRb3QnvW5Wf008= X-MC-Unique: P0FAPCIHOM-nvwWnCDAg8g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=i4ThjWuKIu1CMrgXakalQlwzWxwSWoat70hXPufy2EA=; b=OjAtnLR5Pp4/rJAnROGXgStxuYPNX1P6+jPejcGpKZEUQmu58GkdqEpjsYCaXqiDc2 IRtc5Tq+Ufo/tSTkYE+vDjoMMFEi+hkbrWRam2/AVWjKofmh4Z+UH8+pKeV5rOfRhJkr f5PPq5gzSuJlW22KHzoIKsDE+ssAapTpPXyMrsnQeOi5mbocjgUZqMaqJRLouwWdU6ES yxMIYBvhs6GkhJpFvoAsz4H4J3yDqAF+/gHtSDOAU+Utdj1aUvq5S8fTlzS4Q2P8YKbY DsEUzH9o26t4cejIkZJNg1PAYwjRLazukei3kujD8RaDPLKQ5FxBZl/8b4DQv3r5majL bg4Q== X-Gm-Message-State: AOAM5335co814CIB6Is5EhJhLQMmpQu7g4RdMOsDzkuz4hsxnk5INFoJ LRD/bQ81dvVp6DnlP8G6xkjentstCqFpBUKjZRsS/Df//sBl+OE1AcaddLvaB9gAQLLdCWDcCet iL075huhulpDhUp/Rptoa+FPTjcPdtbnh/87pLjCuo4mFhjRq7//uHmihoMMK X-Received: by 2002:a1c:35c9:: with SMTP id c192mr119509wma.168.1644025447049; Fri, 04 Feb 2022 17:44:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyjH/Nm5nWi9CR2H/HsL1oyvgYrhr/RZXinDH/CIjmzQPSOY9GPv2imrtVe+meqcCmwmPCqEg== X-Received: by 2002:a1c:35c9:: with SMTP id c192mr119468wma.168.1644025446344; Fri, 04 Feb 2022 17:44:06 -0800 (PST) Date: Fri, 4 Feb 2022 20:44:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 31/32] ACPI ERST: step 6 of bios-tables-test.c Message-ID: <20220205014149.1189026-32-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Ani Sinha , Peter Maydell , Eric DeVolder , Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644028159700100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder Following the guidelines in tests/qtest/bios-tables-test.c, this is step 6. Below is the disassembly of tests/data/acpi/pc/ERST.acpierst. /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20180508 (64-bit version) * Copyright (c) 2000 - 2018 Intel Corporation * * Disassembly of tests/data/acpi/pc/ERST.acpierst, Thu Dec 2 13:32:07 20= 21 * * ACPI Data Table [ERST] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue */ [000h 0000 4] Signature : "ERST" [Error Record Ser= ialization Table] [004h 0004 4] Table Length : 00000390 [008h 0008 1] Revision : 01 [009h 0009 1] Checksum : D6 [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001 [024h 0036 4] Serialization Header Length : 00000030 [028h 0040 4] Reserved : 00000000 [02Ch 0044 4] Instruction Entry Count : 0000001B [030h 0048 1] Action : 00 [Begin Write Operation] [031h 0049 1] Instruction : 03 [Write Register Value] [032h 0050 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [033h 0051 1] Reserved : 00 [034h 0052 12] Register Region : [Generic Address Structure] [034h 0052 1] Space ID : 00 [SystemMemory] [035h 0053 1] Bit Width : 20 [036h 0054 1] Bit Offset : 00 [037h 0055 1] Encoded Access Width : 03 [DWord Access:32] [038h 0056 8] Address : 00000000FEBF3000 [040h 0064 8] Value : 0000000000000000 [048h 0072 8] Mask : 00000000000000FF [050h 0080 1] Action : 01 [Begin Read Operation] [051h 0081 1] Instruction : 03 [Write Register Value] [052h 0082 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [053h 0083 1] Reserved : 00 [054h 0084 12] Register Region : [Generic Address Structure] [054h 0084 1] Space ID : 00 [SystemMemory] [055h 0085 1] Bit Width : 20 [056h 0086 1] Bit Offset : 00 [057h 0087 1] Encoded Access Width : 03 [DWord Access:32] [058h 0088 8] Address : 00000000FEBF3000 [060h 0096 8] Value : 0000000000000001 [068h 0104 8] Mask : 00000000000000FF [070h 0112 1] Action : 02 [Begin Clear Operation] [071h 0113 1] Instruction : 03 [Write Register Value] [072h 0114 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [073h 0115 1] Reserved : 00 [074h 0116 12] Register Region : [Generic Address Structure] [074h 0116 1] Space ID : 00 [SystemMemory] [075h 0117 1] Bit Width : 20 [076h 0118 1] Bit Offset : 00 [077h 0119 1] Encoded Access Width : 03 [DWord Access:32] [078h 0120 8] Address : 00000000FEBF3000 [080h 0128 8] Value : 0000000000000002 [088h 0136 8] Mask : 00000000000000FF [090h 0144 1] Action : 03 [End Operation] [091h 0145 1] Instruction : 03 [Write Register Value] [092h 0146 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [093h 0147 1] Reserved : 00 [094h 0148 12] Register Region : [Generic Address Structure] [094h 0148 1] Space ID : 00 [SystemMemory] [095h 0149 1] Bit Width : 20 [096h 0150 1] Bit Offset : 00 [097h 0151 1] Encoded Access Width : 03 [DWord Access:32] [098h 0152 8] Address : 00000000FEBF3000 [0A0h 0160 8] Value : 0000000000000003 [0A8h 0168 8] Mask : 00000000000000FF [0B0h 0176 1] Action : 04 [Set Record Offset] [0B1h 0177 1] Instruction : 02 [Write Register] [0B2h 0178 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [0B3h 0179 1] Reserved : 00 [0B4h 0180 12] Register Region : [Generic Address Structure] [0B4h 0180 1] Space ID : 00 [SystemMemory] [0B5h 0181 1] Bit Width : 20 [0B6h 0182 1] Bit Offset : 00 [0B7h 0183 1] Encoded Access Width : 03 [DWord Access:32] [0B8h 0184 8] Address : 00000000FEBF3008 [0C0h 0192 8] Value : 0000000000000000 [0C8h 0200 8] Mask : 00000000FFFFFFFF [0D0h 0208 1] Action : 04 [Set Record Offset] [0D1h 0209 1] Instruction : 03 [Write Register Value] [0D2h 0210 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [0D3h 0211 1] Reserved : 00 [0D4h 0212 12] Register Region : [Generic Address Structure] [0D4h 0212 1] Space ID : 00 [SystemMemory] [0D5h 0213 1] Bit Width : 20 [0D6h 0214 1] Bit Offset : 00 [0D7h 0215 1] Encoded Access Width : 03 [DWord Access:32] [0D8h 0216 8] Address : 00000000FEBF3000 [0E0h 0224 8] Value : 0000000000000004 [0E8h 0232 8] Mask : 00000000000000FF [0F0h 0240 1] Action : 05 [Execute Operation] [0F1h 0241 1] Instruction : 03 [Write Register Value] [0F2h 0242 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [0F3h 0243 1] Reserved : 00 [0F4h 0244 12] Register Region : [Generic Address Structure] [0F4h 0244 1] Space ID : 00 [SystemMemory] [0F5h 0245 1] Bit Width : 20 [0F6h 0246 1] Bit Offset : 00 [0F7h 0247 1] Encoded Access Width : 03 [DWord Access:32] [0F8h 0248 8] Address : 00000000FEBF3008 [100h 0256 8] Value : 000000000000009C [108h 0264 8] Mask : 00000000000000FF [110h 0272 1] Action : 05 [Execute Operation] [111h 0273 1] Instruction : 03 [Write Register Value] [112h 0274 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [113h 0275 1] Reserved : 00 [114h 0276 12] Register Region : [Generic Address Structure] [114h 0276 1] Space ID : 00 [SystemMemory] [115h 0277 1] Bit Width : 20 [116h 0278 1] Bit Offset : 00 [117h 0279 1] Encoded Access Width : 03 [DWord Access:32] [118h 0280 8] Address : 00000000FEBF3000 [120h 0288 8] Value : 0000000000000005 [128h 0296 8] Mask : 00000000000000FF [130h 0304 1] Action : 06 [Check Busy Status] [131h 0305 1] Instruction : 03 [Write Register Value] [132h 0306 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [133h 0307 1] Reserved : 00 [134h 0308 12] Register Region : [Generic Address Structure] [134h 0308 1] Space ID : 00 [SystemMemory] [135h 0309 1] Bit Width : 20 [136h 0310 1] Bit Offset : 00 [137h 0311 1] Encoded Access Width : 03 [DWord Access:32] [138h 0312 8] Address : 00000000FEBF3000 [140h 0320 8] Value : 0000000000000006 [148h 0328 8] Mask : 00000000000000FF [150h 0336 1] Action : 06 [Check Busy Status] [151h 0337 1] Instruction : 01 [Read Register Value] [152h 0338 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [153h 0339 1] Reserved : 00 [154h 0340 12] Register Region : [Generic Address Structure] [154h 0340 1] Space ID : 00 [SystemMemory] [155h 0341 1] Bit Width : 20 [156h 0342 1] Bit Offset : 00 [157h 0343 1] Encoded Access Width : 03 [DWord Access:32] [158h 0344 8] Address : 00000000FEBF3008 [160h 0352 8] Value : 0000000000000001 [168h 0360 8] Mask : 00000000000000FF [170h 0368 1] Action : 07 [Get Command Status] [171h 0369 1] Instruction : 03 [Write Register Value] [172h 0370 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [173h 0371 1] Reserved : 00 [174h 0372 12] Register Region : [Generic Address Structure] [174h 0372 1] Space ID : 00 [SystemMemory] [175h 0373 1] Bit Width : 20 [176h 0374 1] Bit Offset : 00 [177h 0375 1] Encoded Access Width : 03 [DWord Access:32] [178h 0376 8] Address : 00000000FEBF3000 [180h 0384 8] Value : 0000000000000007 [188h 0392 8] Mask : 00000000000000FF [190h 0400 1] Action : 07 [Get Command Status] [191h 0401 1] Instruction : 00 [Read Register] [192h 0402 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [193h 0403 1] Reserved : 00 [194h 0404 12] Register Region : [Generic Address Structure] [194h 0404 1] Space ID : 00 [SystemMemory] [195h 0405 1] Bit Width : 20 [196h 0406 1] Bit Offset : 00 [197h 0407 1] Encoded Access Width : 03 [DWord Access:32] [198h 0408 8] Address : 00000000FEBF3008 [1A0h 0416 8] Value : 0000000000000000 [1A8h 0424 8] Mask : 00000000000000FF [1B0h 0432 1] Action : 08 [Get Record Identifier] [1B1h 0433 1] Instruction : 03 [Write Register Value] [1B2h 0434 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [1B3h 0435 1] Reserved : 00 [1B4h 0436 12] Register Region : [Generic Address Structure] [1B4h 0436 1] Space ID : 00 [SystemMemory] [1B5h 0437 1] Bit Width : 20 [1B6h 0438 1] Bit Offset : 00 [1B7h 0439 1] Encoded Access Width : 03 [DWord Access:32] [1B8h 0440 8] Address : 00000000FEBF3000 [1C0h 0448 8] Value : 0000000000000008 [1C8h 0456 8] Mask : 00000000000000FF [1D0h 0464 1] Action : 08 [Get Record Identifier] [1D1h 0465 1] Instruction : 00 [Read Register] [1D2h 0466 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [1D3h 0467 1] Reserved : 00 [1D4h 0468 12] Register Region : [Generic Address Structure] [1D4h 0468 1] Space ID : 00 [SystemMemory] [1D5h 0469 1] Bit Width : 40 [1D6h 0470 1] Bit Offset : 00 [1D7h 0471 1] Encoded Access Width : 04 [QWord Access:64] [1D8h 0472 8] Address : 00000000FEBF3008 [1E0h 0480 8] Value : 0000000000000000 [1E8h 0488 8] Mask : FFFFFFFFFFFFFFFF [1F0h 0496 1] Action : 09 [Set Record Identifier] [1F1h 0497 1] Instruction : 02 [Write Register] [1F2h 0498 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [1F3h 0499 1] Reserved : 00 [1F4h 0500 12] Register Region : [Generic Address Structure] [1F4h 0500 1] Space ID : 00 [SystemMemory] [1F5h 0501 1] Bit Width : 40 [1F6h 0502 1] Bit Offset : 00 [1F7h 0503 1] Encoded Access Width : 04 [QWord Access:64] [1F8h 0504 8] Address : 00000000FEBF3008 [200h 0512 8] Value : 0000000000000000 [208h 0520 8] Mask : FFFFFFFFFFFFFFFF [210h 0528 1] Action : 09 [Set Record Identifier] [211h 0529 1] Instruction : 03 [Write Register Value] [212h 0530 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [213h 0531 1] Reserved : 00 [214h 0532 12] Register Region : [Generic Address Structure] [214h 0532 1] Space ID : 00 [SystemMemory] [215h 0533 1] Bit Width : 20 [216h 0534 1] Bit Offset : 00 [217h 0535 1] Encoded Access Width : 03 [DWord Access:32] [218h 0536 8] Address : 00000000FEBF3000 [220h 0544 8] Value : 0000000000000009 [228h 0552 8] Mask : 00000000000000FF [230h 0560 1] Action : 0A [Get Record Count] [231h 0561 1] Instruction : 03 [Write Register Value] [232h 0562 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [233h 0563 1] Reserved : 00 [234h 0564 12] Register Region : [Generic Address Structure] [234h 0564 1] Space ID : 00 [SystemMemory] [235h 0565 1] Bit Width : 20 [236h 0566 1] Bit Offset : 00 [237h 0567 1] Encoded Access Width : 03 [DWord Access:32] [238h 0568 8] Address : 00000000FEBF3000 [240h 0576 8] Value : 000000000000000A [248h 0584 8] Mask : 00000000000000FF [250h 0592 1] Action : 0A [Get Record Count] [251h 0593 1] Instruction : 00 [Read Register] [252h 0594 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [253h 0595 1] Reserved : 00 [254h 0596 12] Register Region : [Generic Address Structure] [254h 0596 1] Space ID : 00 [SystemMemory] [255h 0597 1] Bit Width : 20 [256h 0598 1] Bit Offset : 00 [257h 0599 1] Encoded Access Width : 03 [DWord Access:32] [258h 0600 8] Address : 00000000FEBF3008 [260h 0608 8] Value : 0000000000000000 [268h 0616 8] Mask : 00000000FFFFFFFF [270h 0624 1] Action : 0B [Begin Dummy Write] [271h 0625 1] Instruction : 03 [Write Register Value] [272h 0626 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [273h 0627 1] Reserved : 00 [274h 0628 12] Register Region : [Generic Address Structure] [274h 0628 1] Space ID : 00 [SystemMemory] [275h 0629 1] Bit Width : 20 [276h 0630 1] Bit Offset : 00 [277h 0631 1] Encoded Access Width : 03 [DWord Access:32] [278h 0632 8] Address : 00000000FEBF3000 [280h 0640 8] Value : 000000000000000B [288h 0648 8] Mask : 00000000000000FF [290h 0656 1] Action : 0D [Get Error Address Range] [291h 0657 1] Instruction : 03 [Write Register Value] [292h 0658 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [293h 0659 1] Reserved : 00 [294h 0660 12] Register Region : [Generic Address Structure] [294h 0660 1] Space ID : 00 [SystemMemory] [295h 0661 1] Bit Width : 20 [296h 0662 1] Bit Offset : 00 [297h 0663 1] Encoded Access Width : 03 [DWord Access:32] [298h 0664 8] Address : 00000000FEBF3000 [2A0h 0672 8] Value : 000000000000000D [2A8h 0680 8] Mask : 00000000000000FF [2B0h 0688 1] Action : 0D [Get Error Address Range] [2B1h 0689 1] Instruction : 00 [Read Register] [2B2h 0690 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [2B3h 0691 1] Reserved : 00 [2B4h 0692 12] Register Region : [Generic Address Structure] [2B4h 0692 1] Space ID : 00 [SystemMemory] [2B5h 0693 1] Bit Width : 40 [2B6h 0694 1] Bit Offset : 00 [2B7h 0695 1] Encoded Access Width : 04 [QWord Access:64] [2B8h 0696 8] Address : 00000000FEBF3008 [2C0h 0704 8] Value : 0000000000000000 [2C8h 0712 8] Mask : FFFFFFFFFFFFFFFF [2D0h 0720 1] Action : 0E [Get Error Address Lengt= h] [2D1h 0721 1] Instruction : 03 [Write Register Value] [2D2h 0722 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [2D3h 0723 1] Reserved : 00 [2D4h 0724 12] Register Region : [Generic Address Structure] [2D4h 0724 1] Space ID : 00 [SystemMemory] [2D5h 0725 1] Bit Width : 20 [2D6h 0726 1] Bit Offset : 00 [2D7h 0727 1] Encoded Access Width : 03 [DWord Access:32] [2D8h 0728 8] Address : 00000000FEBF3000 [2E0h 0736 8] Value : 000000000000000E [2E8h 0744 8] Mask : 00000000000000FF [2F0h 0752 1] Action : 0E [Get Error Address Lengt= h] [2F1h 0753 1] Instruction : 00 [Read Register] [2F2h 0754 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [2F3h 0755 1] Reserved : 00 [2F4h 0756 12] Register Region : [Generic Address Structure] [2F4h 0756 1] Space ID : 00 [SystemMemory] [2F5h 0757 1] Bit Width : 40 [2F6h 0758 1] Bit Offset : 00 [2F7h 0759 1] Encoded Access Width : 04 [QWord Access:64] [2F8h 0760 8] Address : 00000000FEBF3008 [300h 0768 8] Value : 0000000000000000 [308h 0776 8] Mask : 00000000FFFFFFFF [310h 0784 1] Action : 0F [Get Error Attributes] [311h 0785 1] Instruction : 03 [Write Register Value] [312h 0786 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [313h 0787 1] Reserved : 00 [314h 0788 12] Register Region : [Generic Address Structure] [314h 0788 1] Space ID : 00 [SystemMemory] [315h 0789 1] Bit Width : 20 [316h 0790 1] Bit Offset : 00 [317h 0791 1] Encoded Access Width : 03 [DWord Access:32] [318h 0792 8] Address : 00000000FEBF3000 [320h 0800 8] Value : 000000000000000F [328h 0808 8] Mask : 00000000000000FF [330h 0816 1] Action : 0F [Get Error Attributes] [331h 0817 1] Instruction : 00 [Read Register] [332h 0818 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [333h 0819 1] Reserved : 00 [334h 0820 12] Register Region : [Generic Address Structure] [334h 0820 1] Space ID : 00 [SystemMemory] [335h 0821 1] Bit Width : 20 [336h 0822 1] Bit Offset : 00 [337h 0823 1] Encoded Access Width : 03 [DWord Access:32] [338h 0824 8] Address : 00000000FEBF3008 [340h 0832 8] Value : 0000000000000000 [348h 0840 8] Mask : 00000000FFFFFFFF [350h 0848 1] Action : 10 [Execute Timings] [351h 0849 1] Instruction : 03 [Write Register Value] [352h 0850 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [353h 0851 1] Reserved : 00 [354h 0852 12] Register Region : [Generic Address Structure] [354h 0852 1] Space ID : 00 [SystemMemory] [355h 0853 1] Bit Width : 20 [356h 0854 1] Bit Offset : 00 [357h 0855 1] Encoded Access Width : 03 [DWord Access:32] [358h 0856 8] Address : 00000000FEBF3000 [360h 0864 8] Value : 0000000000000010 [368h 0872 8] Mask : 00000000000000FF [370h 0880 1] Action : 10 [Execute Timings] [371h 0881 1] Instruction : 00 [Read Register] [372h 0882 1] Flags (decoded below) : 00 Preserve Register Bits : 0 [373h 0883 1] Reserved : 00 [374h 0884 12] Register Region : [Generic Address Structure] [374h 0884 1] Space ID : 00 [SystemMemory] [375h 0885 1] Bit Width : 40 [376h 0886 1] Bit Offset : 00 [377h 0887 1] Encoded Access Width : 04 [QWord Access:64] [378h 0888 8] Address : 00000000FEBF3008 [380h 0896 8] Value : 0000000000000000 [388h 0904 8] Mask : FFFFFFFFFFFFFFFF Raw Table Data: Length 912 (0x390) Note that the contents of tests/data/q35/ERST.acpierst and tests/data/microvm/ERST.pcie are the same except for differences due to assigned base address. Files tests/data/pc/DSDT.acpierst and tests/data/acpi/q35/DSDT.acpierst are new files (and are included as a result of 'make check' process). Rather than provide the entire content, I am providing the differences between pc/DSDT and pc/DSDT.acpierst, and the difference between q35/DSDT and q35/DSDT.acpierst, with an explanation to follow. diff pc/DSDT pc/DSDT.acpierst: @@ -5,13 +5,13 @@ * * Disassembling to symbolic ASL+ operators * - * Disassembly of tests/data/acpi/pc/DSDT, Thu Dec 2 10:10:13 2021 + * Disassembly of tests/data/acpi/pc/DSDT.acpierst, Thu Dec 2 12:59:36 2= 021 * * Original Table Header: * Signature "DSDT" - * Length 0x00001772 (6002) + * Length 0x00001751 (5969) * Revision 0x01 **** 32-bit table (V1), no 64-bit math suppo= rt - * Checksum 0x9E + * Checksum 0x95 * OEM ID "BOCHS " * OEM Table ID "BXPC " * OEM Revision 0x00000001 (1) @@ -964,16 +964,11 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS " Device (S18) { - Name (_SUN, 0x03) // _SUN: Slot User Number Name (_ADR, 0x00030000) // _ADR: Address - Method (_EJ0, 1, NotSerialized) // _EJx: Eject Device - { - PCEJ (BSEL, _SUN) - } - + Name (ASUN, 0x03) Method (_DSM, 4, Serialized) // _DSM: Device-Specific Me= thod { - Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, _SUN)) + Return (PDSM (Arg0, Arg1, Arg2, Arg3, BSEL, ASUN)) } } @@ -1399,11 +1394,6 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS " Method (DVNT, 2, NotSerialized) { - If ((Arg0 & 0x08)) - { - Notify (S18, Arg1) - } - If ((Arg0 & 0x10)) { Notify (S20, Arg1) diff q35/DSDT and q35/DSDT.acpierst: @@ -5,13 +5,13 @@ * * Disassembling to symbolic ASL+ operators * - * Disassembly of tests/data/acpi/q35/DSDT, Thu Dec 2 10:10:13 2021 + * Disassembly of tests/data/acpi/q35/DSDT.acpierst, Thu Dec 2 12:59:36 = 2021 * * Original Table Header: * Signature "DSDT" - * Length 0x00002061 (8289) + * Length 0x00002072 (8306) * Revision 0x01 **** 32-bit table (V1), no 64-bit math suppo= rt - * Checksum 0xFA + * Checksum 0x9A * OEM ID "BOCHS " * OEM Table ID "BXPC " * OEM Revision 0x00000001 (1) @@ -3278,6 +3278,11 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS " } } + Device (S10) + { + Name (_ADR, 0x00020000) // _ADR: Address + } + Method (PCNT, 0, NotSerialized) { } For both pc and q35, there is but a small difference between this DSDT.acpierst and the corresponding DSDT. In both cases, the changes occur under the hiearchy: Scope (\_SB) { Scope (PCI0) { which leads me to believe that the change to the DSDT was needed due to the introduction of the ERST PCI device. And is explained in detail by Ani Sinha: I have convinced myself of the changes we see in the DSDT tables. On i440fx side, we are adding a non-hotpluggable pci device on slot 3. So the changes we see are basically replacing an empty hotpluggable slot on the pci root port with a non-hotplugggable device. On q35, bsel on pcie root bus is not set (its not hotpluggable bus), so the change basically adds the address enumeration for the device. Signed-off-by: Eric DeVolder Acked-by: Ani Sinha Message-Id: <1643402289-22216-11-git-send-email-eric.devolder@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 5 ----- tests/data/acpi/microvm/ERST.pcie | Bin 0 -> 912 bytes tests/data/acpi/pc/DSDT.acpierst | Bin 0 -> 5969 bytes tests/data/acpi/pc/ERST.acpierst | Bin 0 -> 912 bytes tests/data/acpi/q35/DSDT.acpierst | Bin 0 -> 8306 bytes tests/data/acpi/q35/ERST.acpierst | Bin 0 -> 912 bytes 6 files changed, 5 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 603db07711..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,6 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/pc/DSDT.acpierst", -"tests/data/acpi/pc/ERST.acpierst", -"tests/data/acpi/q35/DSDT.acpierst", -"tests/data/acpi/q35/ERST.acpierst", -"tests/data/acpi/microvm/ERST.pcie", diff --git a/tests/data/acpi/microvm/ERST.pcie b/tests/data/acpi/microvm/ER= ST.pcie index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a6d0cb783831ebc18972ec57bb6= c624438ff150d 100644 GIT binary patch literal 912 zcmaKoTMmLS5Jd;doACJehb6cK12OSWBYwCn7ocm^-rA|;CUz1YmosPDa=3Dfm$hY?9$ z^LaU~(|o@yldVKV@Q&x+UZ@>zwpS)GZ(sO?Lc}v64j-jFC7yn9;D$INO8pFiUB7f+ zf49KN&wPvW+;jDxe>nP4Iq`z#7tC?s&HniOCHcA!tc6i7Z+t&KoWCN!@(t>{e2`4% zZhiFB_p5lnFb*Ui&1&BGpsO$pT3_)pk?J?$-jLiezjJ$6`=3Dr)uYry0Rn7KuJIp&j)|! zckaizM=3D~sYzU*-I~PkUtAn>Dr`~u=3D;o(_O$t$PK8~R}U#&P6`{0u*{ zz`m8fl|Wu#ucTKJu-TjNQ`rN~%rBccG0yWwF_}_zQl+X71|-_g)Pr`x1*Xgb!&xdP4yUPQ>QealcAR5Lj8F@vR~&d_hFrfVBOumUtb3< zL8GI#8|W0leXv|!GGL=3D~vE5*uM7z%Af!czNXYqlQL#IT$!9xR0zORu68XY#=3DM-SGy z3b+$tZv(*Hu4BBt4F>MUo>Padde^ZZU%V_4TiQ&t&6ruaomTLcp<9-2bBZ=3Dqyp40+ ziEQ&$6L)c>%cI)0;%&VWL5E5@F~Or>jX}g)!VlmH>3A6L#ZGj;i8(jvxl3w$XL%gc z#4Y0Q*ces>sy7Obm6bTnr@oqih!n=3DP&+!w*&jZjVy;9R95=3D2i+)QqA9kLa1VJk2ES zOh6C4;>puBt75SyO`ippr%I9Z{pk6j=3D(st4aP-WP=3Dov412KgP0p3z1}&)7R9%3U9d z&O-shXOD!>df~G};j<@%&-TL`!{M=3DJ{^0EAj)b4{!p{wbpF1J^oV~LmWA@f?c-apx zmJl5aIOP$4%5j~Id6TV0{V^u0sG`|bSAOB2V2gb1@Ki7>g+T~D<}I$cZmy;lKl#kP zxAm*k{f|HWWb1z8<4?h6y1Bg6FLiOw7Z@DC0gGYf$3^AUwgVosAOD1e9Hex!P-c3u zY%#r3y2G$SrRg@$K+^S+fmJX`o|0}AmQ(0%hN|GcJ*{Ry{RpZVR_9(>4G!#sMm9K*-Kb2oqvI?7dL24<1WVww+F6k zrAwi@3blP`ov2|RQA!4yn|HMt+&l|rp;ky|p}*s4Bhi{tS7b7IwWYtO z($_%y0DUt+12O0t{g&d0!qm$i(>FX+UGsM;osE9mca!r!@5Ld6Jt2$-nabyyC?4*zT@l2 z4LgzF3U^-%E&8T*RhMxH{B|{Nmd$hyhrlm@q(4&m{QfcO=3DjBztZw|gWU^0Q+lFdc4 z;t%ATAUG5ws_1bncmXfi8SEC{UBmF!TrD{!GvtiVS87Q`#ts;JTa>Png~+QvKOAg( z=3Dl%H)^?9Gb?Lui47fY7Bv8_MKSPiRTs@3YkU)Q{@YvnKAT;;J8U>fgQ>9qeF0+gJ! zS_V9pumOy9sSU)%^lS1X17&Pw`o1`MA>W^ePI^H@E*S%`|HOx^c$lLHVkhwcpCba771jDZ#SdZmhM`3K=3Dq{% zNdudV5*`|Tn?lmSM!~R<_iYsI+Q3HPu(0YhlR~GImZVAKI~h z+O@D02|KpVC?DEYlCeYxd&-j!?Kerrtt;#;Pd>DJ8RM1`cI=3DOKE&Yg{vc{!8uv6Z~ u5j$m$OK@OMk$l8{6J=3DZ)1AB{Pv}@<7F~|QN>AydkHSF$IS^vS{(*FTuhT2R3 literal 0 HcmV?d00001 diff --git a/tests/data/acpi/pc/ERST.acpierst b/tests/data/acpi/pc/ERST.acp= ierst index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7965ac2562e7b23bf1dc2caaf00= ef66453c4f47a 100644 GIT binary patch literal 912 zcmaKoOAdlC6h$9Upg{N}4xO+BmS7+z&NSk{Ww`+N;?C6GO0l^KeF>#Er>E`f@jBlg ziAb~?&(mq{$NOdKO+_MtIsSwBP(BS` zh6Ua)#A*M6_AiN-%#j24ugI^+uZh>pkpuT{$ZyEEIpDYCx8&O#=3D&vKcBj4u0`Con^ B!2tjO literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/DSDT.acpierst b/tests/data/acpi/q35/DSDT.a= cpierst index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..cad26e3f0c27a40a33101155a52= 82ed9bcb1d441 100644 GIT binary patch literal 8306 zcmb7JOKcm*8J^`!tL0K!Qk3OaY{E(UN|8`@UTx8!W+{ zr+@MJrMD_~fBw&3-hS0e0dO9FP5iwO(II>Q|7$G zoVF=3Dc*370~>q(Ucw2`X*UeoWjna$X}Z?i1bzv)oC^kS{!mHe(ZC>5U_1icE2s3nZ3 zY5U#Ka>9}Q$uMNYFgqR}u+hRN!)^AvZJYi3f9V5uU@eNi<*kJe=3DczCEzGW%K(3|f) zNxh-*?(d&$1(g9GVw69NuK2C)X2J?B+gV$DDk*`4>hC|jR`mcD_b7?pqgS%bacj9@ zge+u+(J-#EtN42^folEz$J!fPhpfdVjb&Qtb2LKz{qyU7Z&l__iTiD6SjWmWjJK0- zCr$I*9?yK<-Dn?j(m-Q0XK?N(?n{28O7Ue=3DtUS zz8mz6>|NV3acd}WF?L%e9K2G0FQ{F_Ecm-^;l^btaI59oMO>(M+Fc`iPtYiEtDUWO z$!~ctmHI|?-CbkF$9=3DbUG0}gNqVYJ|B}DX&ag9-q{`aZ*fEAypfHMn4xgt7*F*YoE z8Q%-q3#0XTYTSG7AO8uSdAI$^%Gd1^e{CtL5V)tERpa9(Exo7$}ef`$x|2%4;rOQ9c_Ndgx~!~$?ZT;n`I zWk^iq=3Dhy^i0vkufl+Xm@Oh7pkAu-V#j!kl=3D>_L(dQ$mx12`FbGB&Mu_c_pwsPl_`o zG$oj_^9WU)X-#LEGbJ=3DFn6mQ-Rh=3D14XNEH+G^6W8sOp^4bk1oy=3DX9M2Rh_1$)6{gD zx=3Dw_uPP~DXk)GFd&g(i6syZ!Ar=3D{t%be#xQomow1R@0f)bs|)C;$5iRPg~Pz>pBst zI&+%NoTf9U>qMyPT+nnbXgU{kod{K(i<-_wP3NMn6QQcp(R4bRPDj^?P}P~&bmldk zd0i($RcArdSiBQ#f zOw)Nx(|JtSiBQ#vF9|$-@;$Vo>0HruB2;xA*K{7&bRO4rB2;yr;LJ+=3DCOpBJ)%az1 zLNMJ2Au+ueds1Vb)R-rACPI~YN@JeVn5T3mLX~-1W1iNSr*$SmmHCLqd_-eDqB9Yy z%rl%RUFHmD%6I%3!IUp2Z%2?G^a&V+#~P%=3D;f zu&LjgxD0RX>1(q{mpbC@>R6seC3>2Z%2?G^a&V+#~P%=3D;f=3D3{*fllMEE0)CmI> zSk8ojDo`>|0p(0GP=3Drz^3{+q_69%e4$v_2^Gs!>^N}VuJf#pmXr~)Me6;RG314Srx z!axOM_lrzad z5lWpfP=3DV!47^ngz0~JutBm+e#b;3XemNQ|X3X}{~Ksl2P6rt1!0~J`#gn=3DqhGEf2K zOfpb}QYQ>lU^x>8szAv=3D1(Y+%KoLrvFi=3DE_fg(~36rpOM2o(cWm@rUrJ|DqSSTCWL;la|0sTXICqsWK z{hL31DoOvP(y9incNl(mvjWH6tkS`ygJ&|Vy=3D>O#yiSJ(9hzowskMpKfYJPW*4{1_ zS>_L{Z1L&VrrVtdpj*x_SlN#=3DY@V+Ky~A!(o0Z0~6}`7>EiyVoC%RaAS)aocbd=3Dl=3D)@cw3a6JzzFxX9Om4yX(0O{JJ0c&&iFPv_PiZ&{@E zC&pkx>rc%Di%Qq*=3DH;*XaMEMlG$|lP@qP%>0;IjhLU98{gZN&_q^7upZI!-q^ zjjg<%4&NG6=3D|tPibW`)Ppr^wJ$W%JfHZ$GSJi`(&%`+(sUnNuNMBB`CQ}d>%r^Bbp zR65Z%Gu_lYSk}|w`(-MfXq%aC>bX9qr^83hR65Z%Gu_m4x}vAUm(El=3D(Wa+!PCZ!9 z-d_ybRcy6jTg6Ud&EMI0LF`U6t;-Kq{QYh%kWZXv#f^kmHm}%*jUwvC(+XRSGHyMZ~lOS3M;vOtz)>YPGGp* z_KOAptfED+^h6TSZi)|T4uzk5l{Vv%UlmSBs!U^xPGf# zUM*8M#Kuv&n0I^imlGpvxXV6t%jNR5Vl#u)`^tR((aTSz}YjKG}?75er8r zhm#jbLS!vs*?sED`r1KQY^O=3Dq!xb_nQz665{Kfh)H*h=3DV5i(4-Q@d11j3c%a8CSpX z3d5^L#I8n07_sdy*6rU8L*ug@G=3D6ym-#}Cs3&$W3#Pd8>jyVA>NEt6rjfxbhF3)nR6Wl0R%y>`8L3X`Yd*9Nunc^1!j znn?6aIU6au#3z0{r^?T=3D;!l8GWi$|nJAz`zN@?)j4)3XkaN5gart(c8zE^rNYyIU` zjwP@}fZv!7*fG3s-?t4D?FQaS_wL6`E~j%9*^m>n0^VSZNHk> z#`=3D@E!v3gTxr=3D?-Z^f0nFWi0tTefjF(MF?1dtewi?ME?fQo1P&j@YHn(=3D;}&UM$mYa7S0P5HyiC?8xH z6f!9TeaHFJgMyi|5*8Nm5IsXzNQv{a2e+ZW|787=3DD||1vS!-|MF*;9ZZ04#xcG6Co z-r~+i`ZC|zYozHe_V=3D?vxh(dKF(f|<%Fl}ccg$cg<6zZe*tEpSd3kbyPWmvO)tCru Lf)z9L%&`9h*%QBN literal 0 HcmV?d00001 diff --git a/tests/data/acpi/q35/ERST.acpierst b/tests/data/acpi/q35/ERST.a= cpierst index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7965ac2562e7b23bf1dc2caaf00= ef66453c4f47a 100644 GIT binary patch literal 912 zcmaKoOAdlC6h$9Upg{N}4xO+BmS7+z&NSk{Ww`+N;?C6GO0l^KeF>#Er>E`f@jBlg ziAb~?&(mq{$NOdKO+_MtIsSwBP(BS` zh6Ua)#A*M6_AiN-%#j24ugI^+uZh>pkpuT{$ZyEEIpDYCx8&O#=3D&vKcBj4u0`Con^ B!2tjO literal 0 HcmV?d00001 --=20 MST From nobody Sun Feb 8 12:31:28 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644028346476707.7735905844231; Fri, 4 Feb 2022 18:32:26 -0800 (PST) Received: from localhost ([::1]:44838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGAsD-0005l9-5b for importer@patchew.org; Fri, 04 Feb 2022 21:32:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7d-0004JA-JB for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGA7b-0003SA-VX for qemu-devel@nongnu.org; Fri, 04 Feb 2022 20:44:17 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-286-TtYRAFTuPs6d-s81LBDo_g-1; Fri, 04 Feb 2022 20:44:14 -0500 Received: by mail-wm1-f70.google.com with SMTP id i64-20020a1c3b43000000b00352cf8b74dcso1188105wma.0 for ; Fri, 04 Feb 2022 17:44:14 -0800 (PST) Received: from redhat.com ([2a10:8005:331d:0:5c51:c095:613e:277c]) by smtp.gmail.com with ESMTPSA id n11sm6445671wms.3.2022.02.04.17.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Feb 2022 17:44:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644025455; 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: in-reply-to:in-reply-to:references:references; bh=oz2e6MHHl60kdDpnLZXoNoUL3IzInDDXRSJJeB+BbMA=; b=NcaTVKnUccCEc0XQhuXIhJumKpk+o5MSb/0qV8LoacA+tMHwmBPUfDvxxHvuu4nZdYbG1/ bwVYxD9ZWPTCXFNG3f2ISgEfrOL8TFC45s5WAlt7zp45OsSSmvNf0JStFpN9uHAcn/OCeI 2BN9tOdSVchTxH325ZOd4R/CqyVAKIs= X-MC-Unique: TtYRAFTuPs6d-s81LBDo_g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=oz2e6MHHl60kdDpnLZXoNoUL3IzInDDXRSJJeB+BbMA=; b=2gaBUMPwL4TgM6U6LwNIPcablIh5WcK4G0gST+UeUe1VPSpbRE7tN3pspHmj+n70o0 CaLBWtbQZDofe2/C9TlV5K+4y6ep4i8Uq1g6amXOLsAuXepdzRof4X0Rh/NViD0q1IYz f0T3//mlWoh6f/GIsEaD+zSSRnrf4CNiW3CV8DTY7GSJQUn4I+yw7XTwHUv8rFeJoQBh gvQs7noKWvZbAEb+C08S89FssdZD9vcmukMXzjiTo5+J/hqPQtmXnT8D5MOA2WmQ6zZM TktZ7p6YbXzzRmpuyuG2HQahtKVqKMlajsODBxwnwXdXyco4W5VGUhecKjP9vhTIW1Ec BOVw== X-Gm-Message-State: AOAM531qFEdPq0ENPn1Md4LYwbvNwhnxl4PhFJrSI742wl0/3P288u6h Ydn/OUmOsG6VB6ueXWbCC0X9xiDH0+NIAuGcPj7IDsB86c8J7XzpmbAc9RdtjMUADov88V0KdVp IHmjqnzkuh76VxkX6A1qCFgs2LRf9DVHtjUTUFQpBuODpm0c7n42af5dD6dGr X-Received: by 2002:adf:c74f:: with SMTP id b15mr1266127wrh.307.1644025452999; Fri, 04 Feb 2022 17:44:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7AXyrVLjxKjDbToNfUSPN50xp3G60gwEatdYDY66JYrte5k0UzGK2ldNa3tDf3HdnH7sxeA== X-Received: by 2002:adf:c74f:: with SMTP id b15mr1266000wrh.307.1644025450326; Fri, 04 Feb 2022 17:44:10 -0800 (PST) Date: Fri, 4 Feb 2022 20:44:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 32/32] util/oslib-posix: Fix missing unlock in the error path of os_mem_prealloc() Message-ID: <20220205014149.1189026-33-mst@redhat.com> References: <20220205014149.1189026-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220205014149.1189026-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Disposition: inline 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.092, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Cc: Peter Maydell , Daniel P =?utf-8?B?LiBCZXJyYW5nw6k=?= , David Hildenbrand , Michal Privoznik , Pankaj Gupta , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644028347455100001 From: David Hildenbrand We're missing an unlock in case installing the signal handler failed. Fortunately, we barely see this error in real life. Fixes: a960d6642d39 ("util/oslib-posix: Support concurrent os_mem_prealloc(= ) invocation") Fixes: CID 1468941 Cc: Paolo Bonzini Cc: Michael S. Tsirkin Cc: Pankaj Gupta Cc: Daniel P. Berrang=C3=A9 Cc: Michal Privoznik Signed-off-by: David Hildenbrand Message-Id: <20220111120830.119912-1-david@redhat.com> Reviewed-by: Pankaj Gupta Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- util/oslib-posix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 9efdc74bba..ac0dbc2adc 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -683,6 +683,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory,= int smp_cpus, =20 ret =3D sigaction(SIGBUS, &act, &sigbus_oldact); if (ret) { + qemu_mutex_unlock(&sigbus_mutex); error_setg_errno(errp, errno, "os_mem_prealloc: failed to install signal handler"); return; --=20 MST