From nobody Tue May 14 12:10:45 2024 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 1646402875065763.9291578035953; Fri, 4 Mar 2022 06:07:55 -0800 (PST) Received: from localhost ([::1]:35044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8b4-0005Hu-CH for importer@patchew.org; Fri, 04 Mar 2022 09:07:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ87V-0006xw-A4 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58078) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ87T-0000HU-6X for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:20 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-315-qQlbR6FbMO-Waa_aHGNrVQ-1; Fri, 04 Mar 2022 08:37:17 -0500 Received: by mail-ed1-f71.google.com with SMTP id f9-20020a0564021e8900b00412d0a6ef0dso4589619edf.11 for ; Fri, 04 Mar 2022 05:37:17 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id f6-20020a50fc86000000b0040f614e0906sm2072299edq.46.2022.03.04.05.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401038; 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=t4EYi98Ftt5LJhR9VhEfDFIVBGMtEa4o0BZ3KdoQjXY=; b=ci8V0gLkMrj0Pe9qxJwzH2EVdEBMUOKxlGyDJYOiBXeQTKDRn5dVNy5fIRqouKkzPcOuK1 OPIpPD6MgIYsbjhux22wuFuCQHEFnddCdIFrr4Qj13yLRyyW0hkTMABU1BYWQU28d64HUu haDcltcBCWRQrIpDxkvqYIyU0uZPUrY= X-MC-Unique: qQlbR6FbMO-Waa_aHGNrVQ-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=t4EYi98Ftt5LJhR9VhEfDFIVBGMtEa4o0BZ3KdoQjXY=; b=Ik8stclaqeTuKZN+rpkOM+NGN0t3nXPJCO93KKbn7b2TKos3/dG6NDS+o294NI+U+G sICJuW6ICSZRxc8t45UlMTQXh33z05tvbV2l2oS/xaA6N7ABfBGtr6WqeWRgudnLSvZG AqrTz9yQU/e+jVdHDgOdRw/fGUEtOB3gUFCQ7Co4VZD8kKYI5InYQIkRjL6e0sGye5FE oo1JsgAG/Kkr6XheRh2QWiztK9Qn181aDM4QFvRqy1GdD/9FUQF78aud+7bkgaiS7sR4 f+Y5LVQR95E7Cc6zq0tLvNrTJRc5Rvz0xxWUpbfuBRRfyWCM9eEcX4zqbA5ny9lR5X9S skvA== X-Gm-Message-State: AOAM5335zf3a/uBAw0157hro3gMlnxXAUAN81LJg9KcXsCnDo8oeTXNC Rq+iWcVRO3LX7frXB6cBxrgZX9Sm2FwgD7FwYDesqfiDD1M+Y2F42v/kvIfE7U5NaLKdDpkajDR 0AI6jNT/kOYIDBkqSMggYskAF6MBQW0CE0KvJFubbbW4VsUCtgwD8TCV9GCv8 X-Received: by 2002:a17:906:154c:b0:6ce:21d7:2826 with SMTP id c12-20020a170906154c00b006ce21d72826mr31546206ejd.9.1646401035714; Fri, 04 Mar 2022 05:37:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzVxyTGld6UZpShB6KPXGAuDYfPHONDJ2gPnKkLBdRZrUSe9cB/no9LyVT3HnAhxSEman5G8w== X-Received: by 2002:a17:906:154c:b0:6ce:21d7:2826 with SMTP id c12-20020a170906154c00b006ce21d72826mr31546188ejd.9.1646401035408; Fri, 04 Mar 2022 05:37:15 -0800 (PST) Date: Fri, 4 Mar 2022 08:37:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 01/45] qom: assert integer does not overflow Message-ID: <20220304133556.233983-2-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , 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: 1646402877335100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" QOM reference counting is not designed with an infinite amount of references in mind, trying to take a reference in a loop without dropping a reference will overflow the integer. It is generally a symptom of a reference leak (a missing deref, commonly as part of error handling - such as one fixed here: https://lore.kernel.org/r/20220228095058.27899-1-sgarzare%40redhat.com ). All this can lead to either freeing the object too early (memory corruption) or never freeing it (memory leak). If we happen to dereference at just the right time (when it's wrapping around to 0), we might eventually assert when dereferencing, but the real problem is an extra object_ref so let's assert there to make such issues cleaner and easier to debug. Some micro-benchmarking shows using fetch and add this is essentially free on x86. Since multiple threads could be incrementing in parallel, we assert around INT_MAX to make sure none of these approach the wrap around point: this way we get a memory leak and not a memory corruption, the former is generally easier to debug. Signed-off-by: Michael S. Tsirkin --- qom/object.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qom/object.c b/qom/object.c index 9f7a33139d..a27532a6ba 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1167,10 +1167,14 @@ GSList *object_class_get_list_sorted(const char *im= plements_type, Object *object_ref(void *objptr) { Object *obj =3D OBJECT(objptr); + uint32_t ref; + if (!obj) { return NULL; } - qatomic_inc(&obj->ref); + ref =3D qatomic_fetch_inc(&obj->ref); + /* Assert waaay before the integer overflows */ + g_assert(ref < INT_MAX); return obj; } =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646402605674116.71392934088533; Fri, 4 Mar 2022 06:03:25 -0800 (PST) Received: from localhost ([::1]:50416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8Wi-0004uw-Cz for importer@patchew.org; Fri, 04 Mar 2022 09:03:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ87g-00075P-Ke for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ87e-0000Jf-LF for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:32 -0500 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-tQ6fm_9rOheNK6IYkZxvJA-1; Fri, 04 Mar 2022 08:37:29 -0500 Received: by mail-ed1-f71.google.com with SMTP id y10-20020a056402358a00b00410deddea4cso4574691edc.16 for ; Fri, 04 Mar 2022 05:37:29 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id z10-20020aa7cf8a000000b004160af67840sm365700edx.66.2022.03.04.05.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401050; 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=XeQBcgSTA77UnPuO7PlkD0Xr2iB/iyYJplo2PFCvlMQ=; b=Ncqw8/coz6eSPW9LocijlPfhS47jJNgC6hqWRIYTJdt2FEw1j1l1BN/169czh/wBUVHiBj bNyEHl/D8rWNSPzRAkbFOGwFPNc5uOH1Bk8V1TSwZZbHJnuX0zW4RW46nY+9JtFEW8RIS6 fhWB8cfJRYvwVUbReF68GkqvVm5Jnk0= X-MC-Unique: tQ6fm_9rOheNK6IYkZxvJA-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=XeQBcgSTA77UnPuO7PlkD0Xr2iB/iyYJplo2PFCvlMQ=; b=t6N70jiYF4PVM60ydyRUi7tdWYv7/OlXxiotZs+YhFMvYg0NfEbVGuRQDteOlZtNUk ZXxVWEr6HGaarUBC9g75/UqFMbQBC6b45mdk3vD5Ph8qrOlNjWOGMRSY+YMN4qCVjOFT ZNC/fSrohEHsHFkS3+XhWZJqrVE0Yoetz7M6TtiyaRY7AzMCAfVME8A/Pv8hgBIagZ56 j4SDRhPUvCEeqTq9F7lQeuJ+5UuJTTYSKeLqAmj5h6LiL/dlr5wj8lppQmkoEYY7apAM siDBAp7CLjhUsQgEE5V2SmhlmbASBjfcjDZHNPqLSD0MjmpMhO3V5vu9wGgpfUmwahjg iD7Q== X-Gm-Message-State: AOAM531bTs4SQHGXxlnsT+HCWfsU62tu4ySLOfJN5S+mhDkUKiZDT+3r xbc/cu1wAEFaJmQ3O1EbAX0NMxRPtRyV9+Y1Z2Vf4UFv0ivYrylB4fbIlsaSPm2cguA0+N6AD+2 TKeA4gNKn6QOiAjemm6XbTEfPrslEdf5P27hYvTm+0vrrOuZaZCcTj6CKRBe6 X-Received: by 2002:aa7:c401:0:b0:415:ce8a:9397 with SMTP id j1-20020aa7c401000000b00415ce8a9397mr9844839edq.389.1646401047568; Fri, 04 Mar 2022 05:37:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVpVUg2tuUBncACgXcr6CwdFvr3G2ucAxeoWCAzgGU3jVP5hF87pz8I9UWRgg+P8K9+pt5RQ== X-Received: by 2002:aa7:c401:0:b0:415:ce8a:9397 with SMTP id j1-20020aa7c401000000b00415ce8a9397mr9844805edq.389.1646401047155; Fri, 04 Mar 2022 05:37:27 -0800 (PST) Date: Fri, 4 Mar 2022 08:37:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 02/45] ACPI ERST: specification for ERST support Message-ID: <20220304133556.233983-3-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 =?utf-8?B?UC4gQmVycmFuZ8Op?= , Markus Armbruster , Ani Sinha , Igor Mammedov , 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: 1646402607691100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric DeVolder Information on the implementation of the ACPI ERST support. Signed-off-by: Eric DeVolder Acked-by: Ani Sinha Message-Id: <20220223143322.927136-2-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/specs/acpi_erst.rst | 200 +++++++++++++++++++++++++++++++++++++++ docs/specs/index.rst | 1 + 2 files changed, 201 insertions(+) create mode 100644 docs/specs/acpi_erst.rst diff --git a/docs/specs/acpi_erst.rst b/docs/specs/acpi_erst.rst new file mode 100644 index 0000000000..a8a9d22d25 --- /dev/null +++ b/docs/specs/acpi_erst.rst @@ -0,0 +1,200 @@ +ACPI ERST DEVICE +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The ACPI ERST device is utilized to support the ACPI Error Record +Serialization Table, ERST, functionality. This feature is designed for +storing error records in persistent storage for future reference +and/or debugging. + +The ACPI specification[1], in Chapter "ACPI Platform Error Interfaces +(APEI)", and specifically subsection "Error Serialization", outlines a +method for storing error records into persistent storage. + +The format of error records is described in the UEFI specification[2], +in Appendix N "Common Platform Error Record". + +While the ACPI specification allows for an NVRAM "mode" (see +GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES) where non-volatile RAM is +directly exposed for direct access by the OS/guest, this device +implements the non-NVRAM "mode". This non-NVRAM "mode" is what is +implemented by most BIOS (since flash memory requires programming +operations in order to update its contents). Furthermore, as of the +time of this writing, Linux only supports the non-NVRAM "mode". + + +Background/Motivation +--------------------- + +Linux uses the persistent storage filesystem, pstore, to record +information (eg. dmesg tail) upon panics and shutdowns. Pstore is +independent of, and runs before, kdump. In certain scenarios (ie. +hosts/guests with root filesystems on NFS/iSCSI where networking +software and/or hardware fails, and thus kdump fails), pstore may +contain information available for post-mortem debugging. + +Two common storage backends for the pstore filesystem are ACPI ERST +and UEFI. Most BIOS implement ACPI ERST. UEFI is not utilized in all +guests. With QEMU supporting ACPI ERST, it becomes a viable pstore +storage backend for virtual machines (as it is now for bare metal +machines). + +Enabling support for ACPI ERST facilitates a consistent method to +capture kernel panic information in a wide range of guests: from +resource-constrained microvms to very large guests, and in particular, +in direct-boot environments (which would lack UEFI run-time services). + +Note that Microsoft Windows also utilizes the ACPI ERST for certain +crash information, if available[3]. + + +Configuration|Usage +------------------- + +To use ACPI ERST, a memory-backend-file object and acpi-erst device +can be created, for example: + + qemu ... + -object memory-backend-file,id=3Derstnvram,mem-path=3Dacpi-erst.backing,s= ize=3D0x10000,share=3Don \ + -device acpi-erst,memdev=3Derstnvram + +For proper operation, the ACPI ERST device needs a memory-backend-file +object with the following parameters: + + - id: The id of the memory-backend-file object is used to associate + this memory with the acpi-erst device. + - size: The size of the ACPI ERST backing storage. This parameter is + required. + - mem-path: The location of the ACPI ERST backing storage file. This + parameter is also required. + - share: The share=3Don parameter is required so that updates to the + ERST backing store are written to the file. + +and ERST device: + + - memdev: Is the object id of the memory-backend-file. + - record_size: Specifies the size of the records (or slots) in the + backend storage. Must be a power of two value greater than or + equal to 4096 (PAGE_SIZE). + + +PCI Interface +------------- + +The ERST device is a PCI device with two BARs, one for accessing the +programming registers, and the other for accessing the record exchange +buffer. + +BAR0 contains the programming interface consisting of ACTION and VALUE +64-bit registers. All ERST actions/operations/side effects happen on +the write to the ACTION, by design. Any data needed by the action must +be placed into VALUE prior to writing ACTION. Reading the VALUE +simply returns the register contents, which can be updated by a +previous ACTION. + +BAR1 contains the 8KiB record exchange buffer, which is the +implemented maximum record size. + + +Backend Storage Format +---------------------- + +The backend storage is divided into fixed size "slots", 8KiB in +length, with each slot storing a single record. Not all slots need to +be occupied, and they need not be occupied in a contiguous fashion. +The ability to clear/erase specific records allows for the formation +of unoccupied slots. + +Slot 0 contains a backend storage header that identifies the contents +as ERST and also facilitates efficient access to the records. +Depending upon the size of the backend storage, additional slots will +be designated to be a part of the slot 0 header. For example, at 8KiB, +the slot 0 header can accomodate 1021 records. Thus a storage size +of 8MiB (8KiB * 1024) requires an additional slot for use by the +header. In this scenario, slot 0 and slot 1 form the backend storage +header, and records can be stored starting at slot 2. + +Below is an example layout of the backend storage format (for storage +size less than 8MiB). The size of the storage is a multiple of 8KiB, +and contains N number of slots to store records. The example below +shows two records (in CPER format) in the backend storage, while the +remaining slots are empty/available. + +:: + + Slot Record + <------------------ 8KiB --------------------> + +--------------------------------------------+ + 0 | storage header | + +--------------------------------------------+ + 1 | empty/available | + +--------------------------------------------+ + 2 | CPER | + +--------------------------------------------+ + 3 | CPER | + +--------------------------------------------+ + ... | | + +--------------------------------------------+ + N | empty/available | + +--------------------------------------------+ + +The storage header consists of some basic information and an array +of CPER record_id's to efficiently access records in the backend +storage. + +All fields in the header are stored in little endian format. + +:: + + +--------------------------------------------+ + | magic | 0x0000 + +--------------------------------------------+ + | record_offset | record_size | 0x0008 + +--------------------------------------------+ + | record_count | reserved | version | 0x0010 + +--------------------------------------------+ + | record_id[0] | 0x0018 + +--------------------------------------------+ + | record_id[1] | 0x0020 + +--------------------------------------------+ + | record_id[...] | + +--------------------------------------------+ + | record_id[N] | 0x1FF8 + +--------------------------------------------+ + +The 'magic' field contains the value 0x524F545354535245. + +The 'record_size' field contains the value 0x2000, 8KiB. + +The 'record_offset' field points to the first record_id in the array, +0x0018. + +The 'version' field contains 0x0100, the first version. + +The 'record_count' field contains the number of valid records in the +backend storage. + +The 'record_id' array fields are the 64-bit record identifiers of the +CPER record in the corresponding slot. Stated differently, the +location of a CPER record_id in the record_id[] array provides the +slot index for the corresponding record in the backend storage. + +Note that, for example, with a backend storage less than 8MiB, slot 0 +contains the header, so the record_id[0] will never contain a valid +CPER record_id. Instead slot 1 is the first available slot and thus +record_id_[1] may contain a CPER. + +A 'record_id' of all 0s or all 1s indicates an invalid record (ie. the +slot is available). + + +References +---------- + +[1] "Advanced Configuration and Power Interface Specification", + version 4.0, June 2009. + +[2] "Unified Extensible Firmware Interface Specification", + version 2.1, October 2008. + +[3] "Windows Hardware Error Architecture", specfically + "Error Record Persistence Mechanism". diff --git a/docs/specs/index.rst b/docs/specs/index.rst index ecc43896bb..32863b4aa5 100644 --- a/docs/specs/index.rst +++ b/docs/specs/index.rst @@ -18,3 +18,4 @@ guest hardware that is specific to QEMU. acpi_mem_hotplug acpi_pci_hotplug acpi_nvdimm + acpi_erst --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646402780109357.3790316493971; Fri, 4 Mar 2022 06:06:20 -0800 (PST) Received: from localhost ([::1]:59012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8ZX-0002Fc-7m for importer@patchew.org; Fri, 04 Mar 2022 09:06:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ87p-0007P9-GY for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49238) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ87o-0000KQ-09 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:41 -0500 Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-530-YmVI26ILPHWsNcu3fYbksA-1; Fri, 04 Mar 2022 08:37:38 -0500 Received: by mail-ej1-f72.google.com with SMTP id y5-20020a1709060a8500b006da9258a34cso2637464ejf.21 for ; Fri, 04 Mar 2022 05:37:38 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id y20-20020a17090668d400b006da951cbb74sm1528169ejr.211.2022.03.04.05.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401059; 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=TYa/f3CO+AQEfD01xoN40acPIyF1N0ddSlAR4JbVXkw=; b=gv8vBqT5oYFoxNFSKThyvSpH73M/yvC80mV9Fk3V+vAN4hIGIGVnl+I9HPg0ACuvBgWO6O WVS/UT4y6yd8sPwf/7GHWMyo3h8Xk1DE/eBUujFRuNLsFp9aY9GhivJwaJdWpqQYNSnMOE O4PM1pX/pjlfwmwo+U7rshnzKbZ5B9Q= X-MC-Unique: YmVI26ILPHWsNcu3fYbksA-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=TYa/f3CO+AQEfD01xoN40acPIyF1N0ddSlAR4JbVXkw=; b=5agsewB+a0Ae9UY851L/t9IMCGPjG5M03BLITxeHT1ElyFFuRVycbXWKn74iUcm5rU MzfJHUJh4WCVmsWP8ZPTpLuIqWfLdm9zdlJ6UuRlB66p+4sgJ2MZRLp3VrmGSrEq2uas rAl7bYntgT0l0LnoH7c7UrleufcBlsQxs5t5xLam3OfFK/fNl30Jn2J4iEuzBIlkTqUN nZR47IcnVyurdM8hbWhOPaaAKOzC/Hod9Yfg9vazABI0JC+6L62RiKXnIVkubTEvcI6S gQO4nKtcLFt9mQj1NnNl+qSp3eWZTKQFVtmp2DBPH5lJGbeT7RkIJJoLf/2OcJ6Is4iq Q0Tw== X-Gm-Message-State: AOAM533QfGJTZd7vUs/hcevNDBnpVI0IJQhiTAgyPZgFjIkc89IcsuLF +CY48BemU2E9sR8hXSjoa1R59fa+oIld8bJU9K0yfFpJQpzs2f2FVVc5T8tRwRTXvkOPjt06g/L vNKCnz2EXaUUZYqiyVqlzfrYDwHyWv3+VdloEJS4nubQGLjTivBYgXuUTASo8 X-Received: by 2002:a17:907:da6:b0:6da:8f3f:d563 with SMTP id go38-20020a1709070da600b006da8f3fd563mr6425561ejc.112.1646401056938; Fri, 04 Mar 2022 05:37:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3pLx360nz+51i5kcc0K8FU1MGAax8BxOaPDGETpL1qIdx1JZ9FSRDHMOotabNe+AgFtXBkg== X-Received: by 2002:a17:907:da6:b0:6da:8f3f:d563 with SMTP id go38-20020a1709070da600b006da8f3fd563mr6425542ejc.112.1646401056634; Fri, 04 Mar 2022 05:37:36 -0800 (PST) Date: Fri, 4 Mar 2022 08:37:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 03/45] MAINTAINERS: no need to add my name explicitly as a reviewer for VIOT tables Message-ID: <20220304133556.233983-4-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Thomas Huth , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Ani Sinha , Alex =?utf-8?Q?Benn=C3=A9e?= 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: 1646402781503100001 From: Ani Sinha I am already listed as a reviewer for ACPI/SMBIOS subsystem. There is no ne= ed to again add me as a reviewer for ACPI/VIOT. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Ani Sinha Message-Id: <20220223143322.927136-3-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 68adaac373..83a9f79c1c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1819,7 +1819,6 @@ F: docs/specs/acpi_hw_reduced_hotplug.rst =20 ACPI/VIOT M: Jean-Philippe Brucker -R: Ani Sinha S: Supported F: hw/acpi/viot.c F: hw/acpi/viot.h --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646402110919327.3722257750154; Fri, 4 Mar 2022 05:55:10 -0800 (PST) Received: from localhost ([::1]:33730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8Oj-00010Z-RR for importer@patchew.org; Fri, 04 Mar 2022 08:55:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ880-0007eJ-Cv for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ87y-0000Ku-4E for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:37:51 -0500 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-489-rz5y6_nPPQ-Lo21-jsQjQw-1; Fri, 04 Mar 2022 08:37:47 -0500 Received: by mail-ed1-f72.google.com with SMTP id i17-20020aa7c711000000b00415ecaefd07so2210553edq.21 for ; Fri, 04 Mar 2022 05:37:47 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id a1-20020a1709063e8100b006ce06ed8aa7sm1775848ejj.142.2022.03.04.05.37.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:37:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401068; 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=ma9iWGjH8QtszJxbcW9JyMpOmAV16xFQyYJbaD6EIFc=; b=I1HPLLctESZlzYbxfCdmUGou3zDO+35WzQmmCdiBAgPgdEyBCqcHMK2w1tH8cpjTLHPu2s mWEjq7aLvENBkGg+q+bvNCIr7RWpiaInBYhVbouuyFQmwWEnKboabdMvEeixgqdRcypkPq YEAPeuhfmZ5xuWrCIcj7DGlz0zPFYjA= X-MC-Unique: rz5y6_nPPQ-Lo21-jsQjQw-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=ma9iWGjH8QtszJxbcW9JyMpOmAV16xFQyYJbaD6EIFc=; b=gXUyi0K23IXkqPFBhnRVWifZxbn6vsW3A9O7C66GuL4Tnc09wV16l6IV/5YhUV6J1W 2R7IGQfGAF8axnafTU1JbHUaHx/tRT4PM2DQ/GcUqIDkmI7MQQNjrKxZ0uI9ix/wk0d3 6yM07UhVMw8KZAovNKtn1e4F2wTyOuANTju/OHyGB+b5gjesEq6K0LgPc+Kk7i84sUa2 AKm6KEB78MF5P2m9Gx3O0Qg2DOYAhRn8sJ2OCT/xi+vyklmfzkvZDrNaLhQpwcN2+T8h llWM/kFbGANAEDOLX7fgdKpWebuDUeN7zHqV0zRf3nRjCmfOi+knsVXfB4pfRk6TgtHn HJWQ== X-Gm-Message-State: AOAM530CUqclPhdxDvXsT6mPNxumCkUk+tBhbFsQhh3JvpcnWQAigdqt iFS+K0nXvNB9nsRxFMpR45dmcfe5kWmtFjdQOVsYcaH7KUsfmHsotn0c789ATi33ZZLhBPpusgW daKU7enzaVTSbyU65UjBNHycyrxy62nvvf+syqYeAzs5LLRxftemCwbEs+Wbn X-Received: by 2002:a05:6402:2549:b0:415:c31c:f9c2 with SMTP id l9-20020a056402254900b00415c31cf9c2mr11739691edb.335.1646401066182; Fri, 04 Mar 2022 05:37:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwelQyG4xTWiU/Qo9YrtCkByEvxzFAgGj2Zg6cfKP/S5XqJCV/4vVZmIWY/5CP/xBsmu5GmtQ== X-Received: by 2002:a05:6402:2549:b0:415:c31c:f9c2 with SMTP id l9-20020a056402254900b00415c31cf9c2mr11739640edb.335.1646401065937; Fri, 04 Mar 2022 05:37:45 -0800 (PST) Date: Fri, 4 Mar 2022 08:37:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 04/45] docs/acpi/erst: add device id for ACPI ERST device in pci-ids.txt Message-ID: <20220304133556.233983-5-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 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: 1646402113074100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha Adding device ID for ERST device in pci-ids.txt. It was missed when ERST related patches were reviewed. CC: Eric DeVolder Reviewed-by: Eric DeVolder Signed-off-by: Ani Sinha Message-Id: <20220223143322.927136-4-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/specs/pci-ids.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt index 5e407a6f32..dd6859d039 100644 --- a/docs/specs/pci-ids.txt +++ b/docs/specs/pci-ids.txt @@ -65,6 +65,7 @@ PCI devices (other than virtio): 1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c 1b36:0010 PCIe NVMe device (-device nvme) 1b36:0011 PCI PVPanic device (-device pvpanic-pci) +1b36:0012 PCI ACPI ERST device (-device acpi-erst) =20 All these devices are documented in docs/specs. =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 164640269802889.52389120261512; Fri, 4 Mar 2022 06:04:58 -0800 (PST) Received: from localhost ([::1]:55642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8YC-0008P1-W7 for importer@patchew.org; Fri, 04 Mar 2022 09:04:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88A-0007ip-CI for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ886-0000Lf-9i for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:00 -0500 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-436-yEZRji4pPLmL0SwMW5NigQ-1; Fri, 04 Mar 2022 08:37:55 -0500 Received: by mail-ej1-f69.google.com with SMTP id nb1-20020a1709071c8100b006d03c250b6fso4410693ejc.11 for ; Fri, 04 Mar 2022 05:37:55 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id g11-20020a056402424b00b00415c69b46b2sm2090159edb.24.2022.03.04.05.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401076; 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=1o/co5SzJ3afQc19M+6XwM/OcyfK5XPAzn/pSwX2qvQ=; b=MN7Dh48eQkAavl4ESWylX7g8B+j+bVQq9xaCl8TIhi6EWg6sEdp6FEe8kf4PZD1ngEDn95 KUobvuOMFb8R0MM2h5poz699jDGmCPN7JVR/2Hfgl/tYFJWWV2tNtJjczgfhPhYBHZl+98 HuynYGQ1Er0S4GO0RQF6rFMR64s146Y= X-MC-Unique: yEZRji4pPLmL0SwMW5NigQ-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=1o/co5SzJ3afQc19M+6XwM/OcyfK5XPAzn/pSwX2qvQ=; b=ksv4K3lXrgNuFgUWabbg5qZ1vrMiRQkB5cGaObVhN/VRq6QqLcvJuiwaB68O9DPByO UjLMatohcLYrdbegsw8oY1aiMnwwPML3cSZon10P5OpCdVPqLNYowvnETGrzI/CLIHTI zuP2SZ3bAdSewjWhCaDKli/Z8gUYfIBttLBGU6yjpYuhmk90gREkKdlS8ZTmnaY2lEgm JzDuH08KLbWMInnqH1m9aS32jZ0lIuG5o63w3DKGONj6VnGwauBmHXI0/glc+fftERkq rGaYfejmHdirMt9WIypyY2+xp0RzDCGFZZ3K82fV89nNCNXzp9+duANYESZGgbJs1zc3 MlHw== X-Gm-Message-State: AOAM531zOgUm7fKDL3ZbwOgsgylGqn4411fd8GthFmgAgj9tEvmF5wVR W5MR/d+d1qa29ulWrqBmlKvvW7+nbvOcvNVyITpbvM75ag3rPs9cGpV/WI96MudOxZ/o2fSwLo8 eSje2e3XAiAQvC1S8X/Z1ffxYLARUkyX7ZdVDDLoYL9Iy7gvzi7tlyIKd4lfa X-Received: by 2002:a05:6402:1d52:b0:415:bf04:28b4 with SMTP id dz18-20020a0564021d5200b00415bf0428b4mr12077194edb.83.1646401074345; Fri, 04 Mar 2022 05:37:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJznaoEZTBpvVpjaXRoOH2F50v8Vst5jjyGCgQ5+HW0gJXZ2T92BfbuuU+qCbwXCl7rm3hydmw== X-Received: by 2002:a05:6402:1d52:b0:415:bf04:28b4 with SMTP id dz18-20020a0564021d5200b00415bf0428b4mr12077166edb.83.1646401074016; Fri, 04 Mar 2022 05:37:54 -0800 (PST) Date: Fri, 4 Mar 2022 08:37:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 05/45] hw/acpi/erst: clean up unused IS_UEFI_CPER_RECORD macro Message-ID: <20220304133556.233983-6-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1646402701347100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha This change is cosmetic. IS_UEFI_CPER_RECORD macro definition that was added as a part of the ERST implementation seems to be unused. Remove it. CC: Eric DeVolder Reviewed-by: Eric DeVolder Signed-off-by: Ani Sinha Message-Id: <20220223143322.927136-5-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/erst.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/hw/acpi/erst.c b/hw/acpi/erst.c index c0a23cf467..de509c2b48 100644 --- a/hw/acpi/erst.c +++ b/hw/acpi/erst.c @@ -80,11 +80,6 @@ #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')) =20 /* * NOTE that when accessing CPER fields within a record, memcpy() --=20 MST From nobody Tue May 14 12:10:45 2024 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 164640234780765.84075821354065; Fri, 4 Mar 2022 05:59:07 -0800 (PST) Received: from localhost ([::1]:42478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8SY-0007MZ-LC for importer@patchew.org; Fri, 04 Mar 2022 08:59:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88H-0007lg-36 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88F-0000MX-1b for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:08 -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-462-BLKPC9MXN0qvSraRP23aOQ-1; Fri, 04 Mar 2022 08:38:05 -0500 Received: by mail-wm1-f69.google.com with SMTP id 187-20020a1c19c4000000b0037cc0d56524so4164264wmz.2 for ; Fri, 04 Mar 2022 05:38:04 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id p5-20020a05600c358500b0038167e239a2sm5626692wmq.19.2022.03.04.05.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:37:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401086; 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=UdCEFmroOMq8HjIXyQ0uo/r5UiIIhp1W/Xv1KnE50ho=; b=LF/G6tEF2Xtq33zMRqyFC+zdss31WPdKJBQRPLp3lp++Pco5TbekQOXQPLSJflxZpqvORy pxLDzavw9zGjeZBIaAmnSofHKnURS5T3Jj1vg+NPICrulMIPuG4NoNllQSPhPrxYzo41yZ LnhN9GT95B6MxZn966s39+YxuhkDUFM= X-MC-Unique: BLKPC9MXN0qvSraRP23aOQ-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=UdCEFmroOMq8HjIXyQ0uo/r5UiIIhp1W/Xv1KnE50ho=; b=RmVjC4RnvKAX2lYTUD+6AliIj3813RXjXVPldgAwGDvvMu9CXHWcEY915qhsmjtYK+ LvoX5I3ExSLv4+788b0WLu9vFt7m5Munb0cp9Utnz3cZL1D+CHdUP147g9Avq/TH31lO MLynQn4NQOfHvOrhM2KCmKwg9pZpgXTzL33afJmTRoJdzoeegnhS4pdM/KYN6qwPp1fb zh0l9y1uxZ9B/B69hKSHr/oVpAh0Ec2IngJ2XpdGZERnq+TotMlSHa8ppJzun93dVNyj zYejDwjlHYuKf79tWmrf++RnfkCpInJ6JoCuuKwFuxZdFNnbJW5ruOCKwMjioZODoMug UGQw== X-Gm-Message-State: AOAM53351QDJvcfCAx0XJTgDCXq0QEyNh4orTnRKDkQXHwccDS3Yl8Yw nLOaT6PbfxSkL8PWJqCDk9iJT5ndrPmFOH1NG0167LSdPXE1pbEJN3Eq9hL52hA5k5m9lh2BLky QuyEYhh1FDg8DpjH4TQOEe4ypMOzfwUncQEHpLD5fLld79FmUq8InSK8gMo8T X-Received: by 2002:a05:6000:18c8:b0:1e4:b8f4:da8f with SMTP id w8-20020a05600018c800b001e4b8f4da8fmr31210827wrq.199.1646401082778; Fri, 04 Mar 2022 05:38:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJze4MtubsbQbyYxDvfVpuby8cCZEkQeA0oxfMT52ooWHCwVncBYln+aoP74sn5QvNWNLB/GWw== X-Received: by 2002:a05:6000:18c8:b0:1e4:b8f4:da8f with SMTP id w8-20020a05600018c800b001e4b8f4da8fmr31210806wrq.199.1646401082455; Fri, 04 Mar 2022 05:38:02 -0800 (PST) Date: Fri, 4 Mar 2022 08:37:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 06/45] hw/smbios: code cleanup - use macro definitions for table header handles Message-ID: <20220304133556.233983-7-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , 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: 1646402349654100001 From: Ani Sinha This is a minor cleanup. Using macro definitions makes the code more readable. It is at once clear which tables use which handle numbers in their header. It also makes it easy to calculate the gaps between the numbers and update them if needed. Reviewed-by: Igor Mammedov Signed-off-by: Ani Sinha Message-Id: <20220223143322.927136-6-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/smbios/smbios.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 6013df1698..56b412ce35 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -549,9 +549,23 @@ bool smbios_skip_table(uint8_t type, bool required_tab= le) return true; } =20 +#define T0_BASE 0x000 +#define T1_BASE 0x100 +#define T2_BASE 0x200 +#define T3_BASE 0x300 +#define T4_BASE 0x400 +#define T11_BASE 0xe00 + +#define T16_BASE 0x1000 +#define T17_BASE 0x1100 +#define T19_BASE 0x1300 +#define T32_BASE 0x2000 +#define T41_BASE 0x2900 +#define T127_BASE 0x7F00 + static void smbios_build_type_0_table(void) { - SMBIOS_BUILD_TABLE_PRE(0, 0x000, false); /* optional, leave up to BIOS= */ + SMBIOS_BUILD_TABLE_PRE(0, T0_BASE, false); /* optional, leave up to BI= OS */ =20 SMBIOS_TABLE_SET_STR(0, vendor_str, type0.vendor); SMBIOS_TABLE_SET_STR(0, bios_version_str, type0.version); @@ -599,7 +613,7 @@ static void smbios_encode_uuid(struct smbios_uuid *uuid= , QemuUUID *in) =20 static void smbios_build_type_1_table(void) { - SMBIOS_BUILD_TABLE_PRE(1, 0x100, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(1, T1_BASE, true); /* required */ =20 SMBIOS_TABLE_SET_STR(1, manufacturer_str, type1.manufacturer); SMBIOS_TABLE_SET_STR(1, product_name_str, type1.product); @@ -619,7 +633,7 @@ static void smbios_build_type_1_table(void) =20 static void smbios_build_type_2_table(void) { - SMBIOS_BUILD_TABLE_PRE(2, 0x200, false); /* optional */ + SMBIOS_BUILD_TABLE_PRE(2, T2_BASE, false); /* optional */ =20 SMBIOS_TABLE_SET_STR(2, manufacturer_str, type2.manufacturer); SMBIOS_TABLE_SET_STR(2, product_str, type2.product); @@ -637,7 +651,7 @@ static void smbios_build_type_2_table(void) =20 static void smbios_build_type_3_table(void) { - SMBIOS_BUILD_TABLE_PRE(3, 0x300, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(3, T3_BASE, true); /* required */ =20 SMBIOS_TABLE_SET_STR(3, manufacturer_str, type3.manufacturer); t->type =3D 0x01; /* Other */ @@ -662,7 +676,7 @@ static void smbios_build_type_4_table(MachineState *ms,= unsigned instance) { char sock_str[128]; =20 - SMBIOS_BUILD_TABLE_PRE(4, 0x400 + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(4, T4_BASE + instance, true); /* required */ =20 snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance= ); SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str); @@ -702,7 +716,7 @@ static void smbios_build_type_11_table(void) return; } =20 - SMBIOS_BUILD_TABLE_PRE(11, 0xe00, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(11, T11_BASE, true); /* required */ =20 snprintf(count_str, sizeof(count_str), "%zu", type11.nvalues); t->count =3D type11.nvalues; @@ -722,7 +736,7 @@ static void smbios_build_type_16_table(unsigned dimm_cn= t) { uint64_t size_kb; =20 - SMBIOS_BUILD_TABLE_PRE(16, 0x1000, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(16, T16_BASE, true); /* required */ =20 t->location =3D 0x01; /* Other */ t->use =3D 0x03; /* System memory */ @@ -749,7 +763,7 @@ static void smbios_build_type_17_table(unsigned instanc= e, uint64_t size) char loc_str[128]; uint64_t size_mb; =20 - SMBIOS_BUILD_TABLE_PRE(17, 0x1100 + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(17, T17_BASE + instance, true); /* required */ =20 t->physical_memory_array_handle =3D cpu_to_le16(0x1000); /* Type 16 ab= ove */ t->memory_error_information_handle =3D cpu_to_le16(0xFFFE); /* Not pro= vided */ @@ -790,7 +804,7 @@ static void smbios_build_type_19_table(unsigned instanc= e, { uint64_t end, start_kb, end_kb; =20 - SMBIOS_BUILD_TABLE_PRE(19, 0x1300 + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + instance, true); /* required */ =20 end =3D start + size - 1; assert(end > start); @@ -814,7 +828,7 @@ static void smbios_build_type_19_table(unsigned instanc= e, =20 static void smbios_build_type_32_table(void) { - SMBIOS_BUILD_TABLE_PRE(32, 0x2000, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(32, T32_BASE, true); /* required */ =20 memset(t->reserved, 0, 6); t->boot_status =3D 0; /* No errors detected */ @@ -828,7 +842,7 @@ static void smbios_build_type_41_table(Error **errp) struct type41_instance *t41; =20 QTAILQ_FOREACH(t41, &type41, next) { - SMBIOS_BUILD_TABLE_PRE(41, 0x2900 + instance, true); + SMBIOS_BUILD_TABLE_PRE(41, T41_BASE + instance, true); =20 SMBIOS_TABLE_SET_STR(41, reference_designation_str, t41->designati= on); t->device_type =3D t41->kind; @@ -871,7 +885,7 @@ static void smbios_build_type_41_table(Error **errp) =20 static void smbios_build_type_127_table(void) { - SMBIOS_BUILD_TABLE_PRE(127, 0x7F00, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(127, T127_BASE, true); /* required */ SMBIOS_BUILD_TABLE_POST; } =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 164640310224856.09381930607924; Fri, 4 Mar 2022 06:11:42 -0800 (PST) Received: from localhost ([::1]:43534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8ej-0002jZ-CU for importer@patchew.org; Fri, 04 Mar 2022 09:11:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88R-0007oV-HJ for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23139) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88P-0000NW-03 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:18 -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-586-0vCpuANkNl6GaW0nejbREg-1; Fri, 04 Mar 2022 08:38:14 -0500 Received: by mail-wr1-f72.google.com with SMTP id p18-20020adfba92000000b001e8f7697cc7so3379050wrg.20 for ; Fri, 04 Mar 2022 05:38:14 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id f10-20020a05600c154a00b0037bbbc15ca7sm23741660wmg.36.2022.03.04.05.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:38:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401095; 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=vqmzhFEM37dr6U0Ojjhlq+BZMQJdriqtIDbTT9ZpStw=; b=FDen2sR/pM9TL3rsEvEOehNHlnpRhm/tF0UmxzBDG6fqNgbvEEC94XMbDikf2AXmqRJefG 4cMyCqLLn2PcybAsAupmrrG7/XDPUDT2o51LiBbviOVL977+VX35Fqn5M+S0r713i///M8 NggA8mIi04I0CM/0S7sygX6ttAp5iNQ= X-MC-Unique: 0vCpuANkNl6GaW0nejbREg-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=vqmzhFEM37dr6U0Ojjhlq+BZMQJdriqtIDbTT9ZpStw=; b=wURSN82zy2Ekh5QgrNBjfHne6TG1s7tLaWbO52ZkuvzHW1slg8ULhdkAd8SwhWvWqv UxCtcRLqi48LNWgC1OW4GJBfNbsMaNSVavLez49ePQ4Y4Com19S6CIQ9w1pc4pAR8g85 EZMlS0/JLGUSHZsUqUhSwznOiujomLPEINCS66TS0CaToHsu1kqf9dhLQXwc1S+TjddK xIwx9fAWu2uRM7G53JX1fZBN0Yx0J6VUp3Wwzz039zUqZMCCaaOxwsWfahTG2iPGv6/l 4qNXtnnfSfYO3w0XOgiwaLfuK8q88Bmiq5RZae32bAfmM7Q//2/iQrzxwAJADCitNdzf 84dw== X-Gm-Message-State: AOAM531BA0fpp0Ahy8S+f5unPfm7xzF+mv4nv3YS2jv1r+/ioRoSJhv7 Ama1o1S0vks2LUYqTqU7fi25Dq0WppmHkludLzVtkdmfU9XsC3jen66yfYs08RiPQbm7u2uXaBQ cT6VxPJcreE9h5eUz/wd18kQtW6w5BoalD3Iz2jWJoy3l53UbJoa994jmsPq4 X-Received: by 2002:a05:600c:14c2:b0:381:80db:c3b2 with SMTP id i2-20020a05600c14c200b0038180dbc3b2mr7963313wmh.56.1646401092905; Fri, 04 Mar 2022 05:38:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJxNWxVe8QkueDfLDKgt8kCQgzc6onrzpx0r3pWUpgof3BHYTkoe0Z5KRGuSHKZ1ebPdJDMBQQ== X-Received: by 2002:a05:600c:14c2:b0:381:80db:c3b2 with SMTP id i2-20020a05600c14c200b0038180dbc3b2mr7963283wmh.56.1646401092573; Fri, 04 Mar 2022 05:38:12 -0800 (PST) Date: Fri, 4 Mar 2022 08:38:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 07/45] hw/smbios: fix overlapping table handle numbers with large memory vms Message-ID: <20220304133556.233983-8-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1646403122663100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha The current smbios table implementation splits the main memory in 16 GiB (DIMM like) chunks. With the current smbios table assignment code, we can h= ave only 512 such chunks before the 16 bit handle numbers in the header for tab= les 17 and 19 conflict. A guest with more than 8 TiB of memory will hit this limitation and would fail with the following assertion in isa-debugcon: ASSERT_EFI_ERROR (Status =3D Already started) ASSERT /builddir/build/BUILD/edk2-ca407c7246bf/OvmfPkg/SmbiosPlatformDxe/Sm= biosPlatformDxe.c(125): !EFI_ERROR (Status) This change adds an additional offset between tables 17 and 19 handle numbe= rs when configuring VMs larger than 8 TiB of memory. The value of the offset is calculated to be equal to the additional space required to be reserved in order to accomodate more DIMM entries without the table handles collidin= g. In normal cases where the VM memory is smaller or equal to 8 TiB, this offs= et value is 0. Hence in this case, no additional handle numbers are reserved a= nd table handle values remain as before. Since smbios memory is not transmitted over the wire during migration, this change can break migration for large memory vms if the guest is in the middle of generating the tables during migration. However, in those situations, qemu generates invalid table handles anyway with or without this fix. Hence, we do not preserve the old bug by introducing compat knobs/mach= ine types. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2023977 Signed-off-by: Ani Sinha Reviewed-by: Igor Mammedov Message-Id: <20220223143322.927136-7-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 56b412ce35..44c53797a4 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -799,12 +799,13 @@ static void smbios_build_type_17_table(unsigned insta= nce, uint64_t size) SMBIOS_BUILD_TABLE_POST; } =20 -static void smbios_build_type_19_table(unsigned instance, +static void smbios_build_type_19_table(unsigned instance, unsigned offset, uint64_t start, uint64_t size) { uint64_t end, start_kb, end_kb; =20 - SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + instance, true); /* required */ + SMBIOS_BUILD_TABLE_PRE(19, T19_BASE + offset + instance, + true); /* required */ =20 end =3D start + size - 1; assert(end > start); @@ -996,7 +997,7 @@ void smbios_get_tables(MachineState *ms, uint8_t **anchor, size_t *anchor_len, Error **errp) { - unsigned i, dimm_cnt; + unsigned i, dimm_cnt, offset; =20 if (smbios_legacy) { *tables =3D *anchor =3D NULL; @@ -1026,6 +1027,16 @@ void smbios_get_tables(MachineState *ms, =20 dimm_cnt =3D QEMU_ALIGN_UP(current_machine->ram_size, MAX_DIMM_SZ)= / MAX_DIMM_SZ; =20 + /* + * The offset determines if we need to keep additional space betwe= een + * table 17 and table 19 header handle numbers so that they do + * not overlap. For example, for a VM with larger than 8 TB guest + * memory and DIMM like chunks of 16 GiB, the default space between + * the two tables (T19_BASE - T17_BASE =3D 512) is not enough. + */ + offset =3D (dimm_cnt > (T19_BASE - T17_BASE)) ? \ + dimm_cnt - (T19_BASE - T17_BASE) : 0; + smbios_build_type_16_table(dimm_cnt); =20 for (i =3D 0; i < dimm_cnt; i++) { @@ -1033,7 +1044,7 @@ void smbios_get_tables(MachineState *ms, } =20 for (i =3D 0; i < mem_array_size; i++) { - smbios_build_type_19_table(i, mem_array[i].address, + smbios_build_type_19_table(i, offset, mem_array[i].address, mem_array[i].length); } =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646402922354847.6407203850347; Fri, 4 Mar 2022 06:08:42 -0800 (PST) Received: from localhost ([::1]:35892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8bp-0005sc-Hn for importer@patchew.org; Fri, 04 Mar 2022 09:08:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88W-0007p8-7G for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88U-0000O1-RR for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:23 -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-563-jXJi8RiOM5eODbARWh584g-1; Fri, 04 Mar 2022 08:38:20 -0500 Received: by mail-wr1-f69.google.com with SMTP id q12-20020adfbb8c000000b001ea938f79e9so3363276wrg.23 for ; Fri, 04 Mar 2022 05:38:20 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id g20-20020a05600c4ed400b003811fab7f3esm5806785wmq.30.2022.03.04.05.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:38:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401101; 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=5n/FHmC/Dor0xLSEuoyybbuicDeG0aqX5h3Rj+dixSE=; b=Rs+LARxk2vJQuT28EOMo0w4ZfBt8mT7jvG2VEMEvSlUKHCH91jYAxUaGpRjdyMHa7qpFuB X9gQdLf0AMOGWyfPGzUOgELZ2vZlMn4eLda2cwJVotyhTy0UJRmeA0hGo6IKq/wCWFpJUT RKFTlO/daqVCHvvDh+kMjz+nqrMZDIQ= X-MC-Unique: jXJi8RiOM5eODbARWh584g-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=5n/FHmC/Dor0xLSEuoyybbuicDeG0aqX5h3Rj+dixSE=; b=09WpYQ0CJvFkU6koh6Z/TdbQGFXmW4FWv42rVQgSApDTDpUbXz+qtgvVeOQ4SZQD+c 3XzaL7WtIFwcpLbVLAfwSZjCw7019izo/0PVk6LMdLXVEhEgFHZ8CsF70uA5fwxn0wQb wiUBS7Op8sTvVVXs4vrLQUGQGV1uNswtCY8B73xEjnctRUyxS4PL2gfVs0kIDWmCpXg+ hLHQfXojSIDYqtZZ9EzMM/gambLkRMIqcxyDoY4BLKd5lZwcVnfCTOr05LeClcnOHmZ4 Y8MmG88ChAhUhchqW2rMCbGWCvxSBi635uo/8oblmGzt6EbPetL5VWQoobPfYX2GVcmC kiYg== X-Gm-Message-State: AOAM532M07zrewvWzmdCtNOTdch/4XbcfZRy+G6c6UCDVWJUkaRTnSqH jd3aaW3D99t/xDGeIEb9NkrbhWzZ65G2f7YIRpl0q2Az0sw+/jzCfCreUXzM902fFn0W7QBAiue 0IhJRWQCpbjLacfzNDRaD4Efi7RF8gEAX0//lji6p2w2dqOUihNp8eYhNAKMh X-Received: by 2002:adf:b64c:0:b0:1e3:16d0:3504 with SMTP id i12-20020adfb64c000000b001e316d03504mr30533686wre.333.1646401099413; Fri, 04 Mar 2022 05:38:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNfY9pJzFnPEFQ5rvuMXnyT6GRDcDCzVVICBf898eOezSpYhWPkeTAWNJZiNL7b5Qjii8CuA== X-Received: by 2002:adf:b64c:0:b0:1e3:16d0:3504 with SMTP id i12-20020adfb64c000000b001e316d03504mr30533669wre.333.1646401099159; Fri, 04 Mar 2022 05:38:19 -0800 (PST) Date: Fri, 4 Mar 2022 08:38:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 08/45] hw/smbios: add assertion to ensure handles of tables 19 and 32 do not collide Message-ID: <20220304133556.233983-9-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1646402925329100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha Since change dcf359832eec02 ("hw/smbios: fix table memory corruption with l= arge memory vms") we reserve additional space between handle numbers of tables 17 and 19 for large VMs. This may cause table 19 to collide with table 32 in their handle numbers for those large VMs. This change adds an assertion to ensure numbers do not collide. If they do, qemu crashes with useful debug information for taking additional steps. Signed-off-by: Ani Sinha Reviewed-by: Igor Mammedov Message-Id: <20220223143322.927136-8-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 44c53797a4..1f8d5c252f 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1048,6 +1048,12 @@ void smbios_get_tables(MachineState *ms, mem_array[i].length); } =20 + /* + * make sure 16 bit handle numbers in the headers of tables 19 + * and 32 do not overlap. + */ + assert((mem_array_size + offset) < (T32_BASE - T19_BASE)); + smbios_build_type_32_table(); smbios_build_type_38_table(); smbios_build_type_41_table(errp); --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646402612529763.544685606306; Fri, 4 Mar 2022 06:03:32 -0800 (PST) Received: from localhost ([::1]:51138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8Wq-0005Oi-41 for importer@patchew.org; Fri, 04 Mar 2022 09:03:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88n-0007tc-EM for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39026) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88l-0000R2-TZ for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:41 -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-649-DwWCQo3oOwCSu_8eGeXS_Q-1; Fri, 04 Mar 2022 08:38:36 -0500 Received: by mail-wr1-f70.google.com with SMTP id t8-20020adfa2c8000000b001e8f6889404so3386792wra.0 for ; Fri, 04 Mar 2022 05:38:36 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id c124-20020a1c3582000000b00384d42a9638sm5285111wma.2.2022.03.04.05.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:38:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401117; 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=tZpSULKN+Xln7Ddi4XAIsi4Ma9E+7GOx9U1W/EkBGEQ=; b=TUnGrje+buD12o28nqqv9CLgY4c/rUdwJpjL0Zl0m1yhi3E8DNBnOsdXR0FqzOsx0VXjbI VukkswXT9BLBRFqBeO399mcITmPUJCAQaO5Lii6VyDk8wFbv7svTfFHSyz9h0RKh+5bF0W y4QZRNqcm1jTw7LSGcfwStW351JonlU= X-MC-Unique: DwWCQo3oOwCSu_8eGeXS_Q-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=tZpSULKN+Xln7Ddi4XAIsi4Ma9E+7GOx9U1W/EkBGEQ=; b=sXcibVtPocm3NO3jEQv3qqD180f8ulHaq8nS70s4l7icebMM8QAUUU1X6a+yI6Ma80 HULK26AIowd/LRk7hcIQ/d/WU5WHjpCPOfn0JsdjT3Feh47Fm1HVWprLU9e22OeT6Wnz +Zjc8+fN/mBPfodVPPPi4dgXk39JS0LBW9k6fIodT+MugAT1SLLgHBTg41XcacXrfeTU AcuKuTct6fGchUNpdxMr4/7PZ/ad5Jv0kGpBefSCnf0PmJIDLSoWp7Qs5+qiy5wCJ7Zh j0XVDvOH6QPzi8i2iwuJ/cX7yU4RJ/jfERpeMEY0IDv6TB51J+iN6Muixmwe0516UFLY 8OOw== X-Gm-Message-State: AOAM530BXpbDEKGPUX9h8UcjmrQ95zgQG/vDy5cba7jyfdmMksRpNnri zKLv0pOls/X5HnzkBWUFh3cv3VpZD+6QbDzu058qKL1piS21XfNgXek4rtwyTrYwceWwGrjqZA4 QnB4iZhCEJtrk6HT0G1Kmg9dNx+NZyp+4OYJBteoxiTepapCzkceDxShKbAjk X-Received: by 2002:a05:6000:18c3:b0:1e5:82d3:e4e2 with SMTP id w3-20020a05600018c300b001e582d3e4e2mr29986069wrq.575.1646401112127; Fri, 04 Mar 2022 05:38:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJ8VHiOqfnXZcmYg3wFm5gvAmPJRBxjO7vv4QOBunpGg3uXnbv2FNZq2PT8dak0H4IPuT+Vg== X-Received: by 2002:a05:6000:18c3:b0:1e5:82d3:e4e2 with SMTP id w3-20020a05600018c300b001e582d3e4e2mr29986048wrq.575.1646401111878; Fri, 04 Mar 2022 05:38:31 -0800 (PST) Date: Fri, 4 Mar 2022 08:38:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 09/45] vhost-user: remove VirtQ notifier restore Message-ID: <20220304133556.233983-10-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Peter Maydell , qemu-stable@nongnu.org, Xueming Li 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: 1646402613485100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xueming Li Notifier set when vhost-user backend asks qemu to mmap an FD and offset. When vhost-user backend restart or getting killed, VQ notifier FD and mmap addresses become invalid. After backend restart, MR contains the invalid address will be restored and fail on notifier access. On the other hand, qemu should munmap the notifier, release underlying hardware resources to enable backend restart and allocate hardware notifier resources correctly. Qemu shouldn't reference and use resources of disconnected backend. This patch removes VQ notifier restore, uses the default vhost-user notifier to avoid invalid address access. After backend restart, the backend should ask qemu to install a hardware notifier if needed. Fixes: 44866521bd6e ("vhost-user: support registering external host notifie= rs") Cc: qemu-stable@nongnu.org Signed-off-by: Xueming Li Message-Id: <20220207071929.527149-2-xuemingl@nvidia.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 1 - hw/virtio/vhost-user.c | 19 +------------------ 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index a9abca3288..f6012b2078 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -14,7 +14,6 @@ typedef struct VhostUserHostNotifier { MemoryRegion mr; void *addr; - bool set; } VhostUserHostNotifier; =20 typedef struct VhostUserState { diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 662853513e..ebe9bd58d0 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1162,19 +1162,6 @@ static int vhost_user_set_vring_num(struct vhost_dev= *dev, return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring); } =20 -static void vhost_user_host_notifier_restore(struct vhost_dev *dev, - int queue_idx) -{ - struct vhost_user *u =3D dev->opaque; - VhostUserHostNotifier *n =3D &u->user->notifier[queue_idx]; - VirtIODevice *vdev =3D dev->vdev; - - if (n->addr && !n->set) { - virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true); - n->set =3D true; - } -} - static void vhost_user_host_notifier_remove(struct vhost_dev *dev, int queue_idx) { @@ -1182,17 +1169,14 @@ static void vhost_user_host_notifier_remove(struct = vhost_dev *dev, VhostUserHostNotifier *n =3D &u->user->notifier[queue_idx]; VirtIODevice *vdev =3D dev->vdev; =20 - if (n->addr && n->set) { + if (n->addr) { virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false); - n->set =3D false; } } =20 static int vhost_user_set_vring_base(struct vhost_dev *dev, struct vhost_vring_state *ring) { - vhost_user_host_notifier_restore(dev, ring->index); - return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring); } =20 @@ -1558,7 +1542,6 @@ static int vhost_user_slave_handle_vring_host_notifie= r(struct vhost_dev *dev, } =20 n->addr =3D addr; - n->set =3D true; =20 return 0; } --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403040912656.0976470290746; Fri, 4 Mar 2022 06:10:40 -0800 (PST) Received: from localhost ([::1]:40358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8de-0000Sl-S8 for importer@patchew.org; Fri, 04 Mar 2022 09:10:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88q-0007uf-IQ for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57474) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ88o-0000RV-C6 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:43 -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-159-dgBe0wGNMRqDchD3MYlUxQ-1; Fri, 04 Mar 2022 08:38:41 -0500 Received: by mail-wr1-f69.google.com with SMTP id e6-20020a5d4e86000000b001f045d4a962so3185997wru.21 for ; Fri, 04 Mar 2022 05:38:40 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id 9-20020a1c0209000000b003868897278asm7668597wmc.23.2022.03.04.05.38.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401121; 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=OvugmdpxhIxwfz2HUJRV04yMbqV2en4XJ2MBN9Lfiv4=; b=NlR1CCnclpgD7qLiwCBL8yGBahFZQSab9HpMgeUtLabXw4PEZ1gUKxxpZhdiaP2t3B3DP4 x9inBtwAXCpemZLmnFc3jsmYk3gATdWxzokivNdjIArUPKtcjoVclT/XMmBnXEEwks35MO MX8ke1IjepnKFUbkb1Lq9/OWmJM/AWE= X-MC-Unique: dgBe0wGNMRqDchD3MYlUxQ-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=OvugmdpxhIxwfz2HUJRV04yMbqV2en4XJ2MBN9Lfiv4=; b=svQf2l9HH75rwOtZ2roXdrFVQEuSx40Dt6MXPAyxNvQDjP488LrGc8D2mmdhAF/gEM W+q9GADyIsWmd/hMroMGe6ec6gu2RLAmHph0AwnZwxS/xMBsYoZIQuOG9H35DdvKGjoJ mLsBj2eIxh1HShcdduZX2ZrphQ2a2DHwX4ZgK6oYUWqF+93DWEDrmTwnu8ISotkVlXG6 o8iNKqU08IgXisxQEBmq/ZAPGBW0Pc+foZBcxE1HLpcJK+paJcylIbj4Ja475U6+leRb 9cSKrD4x/+gEFIUM8dCgo//BC2HfPv8P6tNHlo8w1HJjLV54wZjRFHk5n1PIbZg5Il0x l8EQ== X-Gm-Message-State: AOAM531auRdYA2kECwKctzSjyxb82crADlPgUvCri/fAWX1njs48cylx VdvWiggS8usHSi8+xpDEFZo5DvzeFWXE0jk5BCUaHn371peMm3LNVOTbJ6HJ+ZATmJe/1K4SQ/e sumBo6Q7uOm+ljoLs/RcJ5TC7G1zQ+Ij3BYkQCTPYcxdoJHmm5oRzPiaLLdEl X-Received: by 2002:a5d:678a:0:b0:1ef:8e97:363c with SMTP id v10-20020a5d678a000000b001ef8e97363cmr22464424wru.617.1646401119342; Fri, 04 Mar 2022 05:38:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDgYCBrEUG2KrlY/kAWNt/vg6OyjIQgcCxkc4E7umdB5moRN1S7ET4OA2dk/adJ7FVa+te1w== X-Received: by 2002:a5d:678a:0:b0:1ef:8e97:363c with SMTP id v10-20020a5d678a000000b001ef8e97363cmr22464405wru.617.1646401119069; Fri, 04 Mar 2022 05:38:39 -0800 (PST) Date: Fri, 4 Mar 2022 08:38:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 10/45] vhost-user: fix VirtQ notifier cleanup Message-ID: <20220304133556.233983-11-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , qemu-stable@nongnu.org, Xueming Li 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: 1646403043962100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Xueming Li When vhost-user device cleanup, remove notifier MR and munmaps notifier address in the event-handling thread, VM CPU thread writing the notifier in concurrent fails with an error of accessing invalid address. It happens because MR is still being referenced and accessed in another thread while the underlying notifier mmap address is being freed and becomes invalid. This patch calls RCU and munmap notifiers in the callback after the memory flatview update finish. Fixes: 44866521bd6e ("vhost-user: support registering external host notifie= rs") Cc: qemu-stable@nongnu.org Signed-off-by: Xueming Li Message-Id: <20220207071929.527149-3-xuemingl@nvidia.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 2 ++ hw/virtio/vhost-user.c | 48 ++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index f6012b2078..e44a41bb70 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -12,8 +12,10 @@ #include "hw/virtio/virtio.h" =20 typedef struct VhostUserHostNotifier { + struct rcu_head rcu; MemoryRegion mr; void *addr; + void *unmap_addr; } VhostUserHostNotifier; =20 typedef struct VhostUserState { diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index ebe9bd58d0..6abbc9da32 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -25,6 +25,7 @@ #include "migration/migration.h" #include "migration/postcopy-ram.h" #include "trace.h" +#include "exec/ramblock.h" =20 #include #include @@ -1162,15 +1163,26 @@ static int vhost_user_set_vring_num(struct vhost_de= v *dev, return vhost_set_vring(dev, VHOST_USER_SET_VRING_NUM, ring); } =20 -static void vhost_user_host_notifier_remove(struct vhost_dev *dev, - int queue_idx) +static void vhost_user_host_notifier_free(VhostUserHostNotifier *n) { - struct vhost_user *u =3D dev->opaque; - VhostUserHostNotifier *n =3D &u->user->notifier[queue_idx]; - VirtIODevice *vdev =3D dev->vdev; + assert(n && n->unmap_addr); + munmap(n->unmap_addr, qemu_real_host_page_size); + n->unmap_addr =3D NULL; +} + +static void vhost_user_host_notifier_remove(VhostUserState *user, + VirtIODevice *vdev, int queue_= idx) +{ + VhostUserHostNotifier *n =3D &user->notifier[queue_idx]; =20 if (n->addr) { - virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false); + if (vdev) { + virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, fal= se); + } + assert(!n->unmap_addr); + n->unmap_addr =3D n->addr; + n->addr =3D NULL; + call_rcu(n, vhost_user_host_notifier_free, rcu); } } =20 @@ -1219,8 +1231,9 @@ static int vhost_user_get_vring_base(struct vhost_dev= *dev, .payload.state =3D *ring, .hdr.size =3D sizeof(msg.payload.state), }; + struct vhost_user *u =3D dev->opaque; =20 - vhost_user_host_notifier_remove(dev, ring->index); + vhost_user_host_notifier_remove(u->user, dev->vdev, ring->index); =20 ret =3D vhost_user_write(dev, &msg, NULL, 0); if (ret < 0) { @@ -1506,12 +1519,7 @@ static int vhost_user_slave_handle_vring_host_notifi= er(struct vhost_dev *dev, =20 n =3D &user->notifier[queue_idx]; =20 - if (n->addr) { - virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, false); - object_unparent(OBJECT(&n->mr)); - munmap(n->addr, page_size); - n->addr =3D NULL; - } + vhost_user_host_notifier_remove(user, vdev, queue_idx); =20 if (area->u64 & VHOST_USER_VRING_NOFD_MASK) { return 0; @@ -1530,9 +1538,12 @@ static int vhost_user_slave_handle_vring_host_notifi= er(struct vhost_dev *dev, =20 name =3D g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]", user, queue_idx); - if (!n->mr.ram) /* Don't init again after suspend. */ + if (!n->mr.ram) { /* Don't init again after suspend. */ memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name, page_size, addr); + } else { + n->mr.ram_block->host =3D addr; + } g_free(name); =20 if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) { @@ -2505,17 +2516,16 @@ bool vhost_user_init(VhostUserState *user, CharBack= end *chr, Error **errp) void vhost_user_cleanup(VhostUserState *user) { int i; + VhostUserHostNotifier *n; =20 if (!user->chr) { return; } memory_region_transaction_begin(); for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { - if (user->notifier[i].addr) { - object_unparent(OBJECT(&user->notifier[i].mr)); - munmap(user->notifier[i].addr, qemu_real_host_page_size); - user->notifier[i].addr =3D NULL; - } + n =3D &user->notifier[i]; + vhost_user_host_notifier_remove(user, NULL, i); + object_unparent(OBJECT(&n->mr)); } memory_region_transaction_commit(); user->chr =3D NULL; --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403110925833.0078899470751; Fri, 4 Mar 2022 06:11:50 -0800 (PST) Received: from localhost ([::1]:44352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8es-0003J1-0O for importer@patchew.org; Fri, 04 Mar 2022 09:11:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ893-0008Vy-04 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36090) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ891-0000TS-7t for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:38:56 -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-278-6CpwZDKmPNeQWeJ6UGuYwQ-1; Fri, 04 Mar 2022 08:38:53 -0500 Received: by mail-wr1-f70.google.com with SMTP id k20-20020adfc714000000b001e305cd1597so3378234wrg.19 for ; Fri, 04 Mar 2022 05:38:53 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id l16-20020a05600c4f1000b0033383cdeea1sm5053280wmq.10.2022.03.04.05.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:38:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401134; 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=TX6EjlT2hSkO078tNRAKGmtPlKuyy6GjReGhr8QOnJA=; b=a0Ji2ciLKpfQIZKoH0X95LjuaSiAoO0rwXvHYE5JbnT04u2ZyrFZ61f12LWmKedfRE5Dpt /ghfTZCAPrYr9/OdX7YmtoiPj4V8k/BfyHZ5U8px/5GHVbLV1pvUPuBfklDehY4/GaF/bS L1tNDciM6Bsz8m/VytEhbb9Ff8x2kuw= X-MC-Unique: 6CpwZDKmPNeQWeJ6UGuYwQ-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=TX6EjlT2hSkO078tNRAKGmtPlKuyy6GjReGhr8QOnJA=; b=jFt+I1zU8RdJ2aPFhRL28cPSmpFlO6CI3RAkBj5jLXBYMKgfY0yQbMimtcrQaE5UUA yQMF+YYs0EDp+leGNLvdPMAahZdJEJ9QbbkO06N5aq5tDwkdB/6z+LBUyFHTeKvYwB+R yOT7ua1fdhMu7NK9cx1zSceCxBT1jatp/kgwj++2XhHT2zqcdHhjFbHkh4eUk9ixnNyh K7xglg8PBkNpF/Nr2lWdbG/HDO4LiET0ZoJlwEaRabfpcajUsVQv4LLSL/z5ArpXQYty +tO5KXkwsRBdMTNO8TGUau21EOYwQwtGGDm6vXlScDCORNvp7m1SfjeBr1Qttk92r96Q al5A== X-Gm-Message-State: AOAM5312gwKiyDvQAUaj7U449hxfsCuHrO/seiH69aX/pL5pL4EltcgO y4BFBZBEq6YegG+pQ0bvgugpWv8VtvC+zNOw8vWb5HoP4xPTXdW27W1rbJiV0a4Tpu3oRM3spau 9WvtaxdrKAVT8epkFFVC8px+Mdpgvo3GZrBVn6WQtmLfHSnuTP3bWfLnsTdod X-Received: by 2002:a05:6000:2c9:b0:1f0:49aa:d347 with SMTP id o9-20020a05600002c900b001f049aad347mr7170163wry.453.1646401132134; Fri, 04 Mar 2022 05:38:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJytlPK94FMGJmr9vD96Y/1WAwbk7Cg6AMNLOlSbNzIzAulXA3gGxPXNJWOS5ZECFe/t+9LciQ== X-Received: by 2002:a05:6000:2c9:b0:1f0:49aa:d347 with SMTP id o9-20020a05600002c900b001f049aad347mr7170133wry.453.1646401131856; Fri, 04 Mar 2022 05:38:51 -0800 (PST) Date: Fri, 4 Mar 2022 08:38:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 11/45] virtio: fix the condition for iommu_platform not supported Message-ID: <20220304133556.233983-12-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Kevin Wolf , Peter Maydell , Daniel Henrique Barboza , Jason Wang , Cornelia Huck , qemu-stable@nongnu.org, Halil Pasic , Jakob Naucke 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: 1646403113143100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Halil Pasic The commit 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but unsupported") claims to fail the device hotplug when iommu_platform is requested, but not supported by the (vhost) device. On the first glance the condition for detecting that situation looks perfect, but because a certain peculiarity of virtio_platform it ain't. In fact the aforementioned commit introduces a regression. It breaks virtio-fs support for Secure Execution, and most likely also for AMD SEV or any other confidential guest scenario that relies encrypted guest memory. The same also applies to any other vhost device that does not support _F_ACCESS_PLATFORM. The peculiarity is that iommu_platform and _F_ACCESS_PLATFORM collates "device can not access all of the guest RAM" and "iova !=3D gpa, thus device needs to translate iova". Confidential guest technologies currently rely on the device/hypervisor offering _F_ACCESS_PLATFORM, so that, after the feature has been negotiated, the guest grants access to the portions of memory the device needs to see. So in for confidential guests, generally, _F_ACCESS_PLATFORM is about the restricted access to memory, but not about the addresses used being something else than guest physical addresses. This is the very reason for which commit f7ef7e6e3b ("vhost: correctly turn on VIRTIO_F_IOMMU_PLATFORM") fences _F_ACCESS_PLATFORM from the vhost device that does not need it, because on the vhost interface it only means "I/O address translation is needed". This patch takes inspiration from f7ef7e6e3b ("vhost: correctly turn on VIRTIO_F_IOMMU_PLATFORM"), and uses the same condition for detecting the situation when _F_ACCESS_PLATFORM is requested, but no I/O translation by the device, and thus no device capability is needed. In this situation claiming that the device does not support iommu_plattform=3Don is counter-productive. So let us stop doing that! Signed-off-by: Halil Pasic Reported-by: Jakob Naucke Fixes: 04ceb61a40 ("virtio: Fail if iommu_platform is requested, but unsupported") Acked-by: Cornelia Huck Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza Cc: Kevin Wolf Cc: qemu-stable@nongnu.org Message-Id: <20220207112857.607829-1-pasic@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- hw/virtio/virtio-bus.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index d23db98c56..0f69d1c742 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -48,6 +48,7 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error = **errp) VirtioBusClass *klass =3D VIRTIO_BUS_GET_CLASS(bus); VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); bool has_iommu =3D virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFO= RM); + bool vdev_has_iommu; Error *local_err =3D NULL; =20 DPRINTF("%s: plug device.\n", qbus->name); @@ -69,11 +70,6 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error= **errp) return; } =20 - if (has_iommu && !virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFOR= M)) { - error_setg(errp, "iommu_platform=3Dtrue is not supported by the de= vice"); - return; - } - if (klass->device_plugged !=3D NULL) { klass->device_plugged(qbus->parent, &local_err); } @@ -82,9 +78,15 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error= **errp) return; } =20 + vdev_has_iommu =3D virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFO= RM); if (klass->get_dma_as !=3D NULL && has_iommu) { virtio_add_feature(&vdev->host_features, VIRTIO_F_IOMMU_PLATFORM); vdev->dma_as =3D klass->get_dma_as(qbus->parent); + if (!vdev_has_iommu && vdev->dma_as !=3D &address_space_memory) { + error_setg(errp, + "iommu_platform=3Dtrue is not supported by the devi= ce"); + return; + } } else { vdev->dma_as =3D &address_space_memory; } --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646402814248589.6946286218016; Fri, 4 Mar 2022 06:06:54 -0800 (PST) Received: from localhost ([::1]:60840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8a5-0003ZO-El for importer@patchew.org; Fri, 04 Mar 2022 09:06:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89B-0000VH-OH for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89A-0000Uw-9K for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:05 -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-311-AmOPkJl3MW2DIABbqANX3Q-1; Fri, 04 Mar 2022 08:39:03 -0500 Received: by mail-wr1-f69.google.com with SMTP id h11-20020a5d430b000000b001f01a35a86fso3366577wrq.4 for ; Fri, 04 Mar 2022 05:39:02 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id a3-20020a7bc1c3000000b00380e493660esm11183768wmj.42.2022.03.04.05.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:38:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401143; 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=xYUjGCjqDKAb5NDT97RnxRdsQlEA2CnL9zsqzwpbiAQ=; b=CNAeKk+teapYSwQqCFbPfWFXPhqPfVL27dJr6E6q7I6VQmpvzcV35W5+9hix6YoH6uBy3+ TBGkIgR46xq6QGiDS0/f6GZpDrCPy0xfNKMJa/wjh09OHc+udUUHTAQZVqjpvG4MHrIvT4 lr9qDxjOWlzYNl9GHKKsnupthooheM4= X-MC-Unique: AmOPkJl3MW2DIABbqANX3Q-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=xYUjGCjqDKAb5NDT97RnxRdsQlEA2CnL9zsqzwpbiAQ=; b=Cm5bwOWU6WxTXIr/CosAdbJYtE/MmEvoWeMX8BVew6o/bGKkO7bx68fRfBxQkbCIOW Hm5vtYYIDXgDJf+m/7s/zjG5UjyI6L/DhJlJzTPQvDBT6uG50zEuONmo09ghk2iEH/z7 DATTocsHjCExt46PmGL9nAsZsjMdA85haFKVA9H8T6i4vdTN/AKBIcqP83CpSwERwqBM 72eIAc+FJY5ioWuAK3sC9rc+WwT5zTw7WWKsVv4kQBmU7J8qUhE2QxEFSHC7noQhjzWw f7042Z+taiSQl1s4U3hYd3rrhxiwhnEpXenZT22+MP/HYdX3CPYwR9g2FYwwbZZqC1C4 e/DQ== X-Gm-Message-State: AOAM531S58VX8scoogTjOwRsTwTloi98hkHR4TH9X6nG8z3ASFmJgiwX AsVEGFsV+qoSWfRbFnznwk2XF6d1km/ifAgmf9HS8+B85PxhqNdH7Cnsm8/SfgToauLQ1BuUpdN 50RJM3d4j2SzxmQZ+0cah4OzEQUu0fWnaMDHVcP7JdKejPNIR83P8+5EmufN+ X-Received: by 2002:a05:600c:4982:b0:380:e458:dbd9 with SMTP id h2-20020a05600c498200b00380e458dbd9mr7732761wmp.49.1646401141385; Fri, 04 Mar 2022 05:39:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwt+admyhqKKOBjOKp/Z0pGp+BebFUpYRYGN629SPNLs18f1lPMK/okFMOUm+hqeD4WVBRkyA== X-Received: by 2002:a05:600c:4982:b0:380:e458:dbd9 with SMTP id h2-20020a05600c498200b00380e458dbd9mr7732742wmp.49.1646401141080; Fri, 04 Mar 2022 05:39:01 -0800 (PST) Date: Fri, 4 Mar 2022 08:38:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 12/45] hw/vhost-user-i2c: Add support for VIRTIO_I2C_F_ZERO_LENGTH_REQUEST Message-ID: <20220304133556.233983-13-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Alex =?utf-8?Q?Benn=C3=A9e?= , Viresh Kumar 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: 1646402815149100001 From: Viresh Kumar VIRTIO_I2C_F_ZERO_LENGTH_REQUEST is a mandatory feature, that must be implemented by everyone. Add its support. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Viresh Kumar Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-i2c.h | 3 +++ hw/virtio/vhost-user-i2c.c | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/vhost-user-i2c.h b/include/hw/virtio/vhost-u= ser-i2c.h index deae47a76d..d8372f3b43 100644 --- a/include/hw/virtio/vhost-user-i2c.h +++ b/include/hw/virtio/vhost-user-i2c.h @@ -25,4 +25,7 @@ struct VHostUserI2C { bool connected; }; =20 +/* Virtio Feature bits */ +#define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST 0 + #endif /* _QEMU_VHOST_USER_I2C_H */ diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index d172632bb0..42c7f6d9e5 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -19,6 +19,11 @@ #define VIRTIO_ID_I2C_ADAPTER 34 #endif =20 +static const int feature_bits[] =3D { + VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, + VHOST_INVALID_FEATURE_BIT +}; + static void vu_i2c_start(VirtIODevice *vdev) { BusState *qbus =3D BUS(qdev_get_parent_bus(DEVICE(vdev))); @@ -113,8 +118,10 @@ static void vu_i2c_set_status(VirtIODevice *vdev, uint= 8_t status) static uint64_t vu_i2c_get_features(VirtIODevice *vdev, uint64_t requested_features, Error **e= rrp) { - /* No feature bits used yet */ - return requested_features; + VHostUserI2C *i2c =3D VHOST_USER_I2C(vdev); + + virtio_add_feature(&requested_features, VIRTIO_I2C_F_ZERO_LENGTH_REQUE= ST); + return vhost_get_features(&i2c->vhost_dev, feature_bits, requested_fea= tures); } =20 static void vu_i2c_handle_output(VirtIODevice *vdev, VirtQueue *vq) --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403232364263.9639794942715; Fri, 4 Mar 2022 06:13:52 -0800 (PST) Received: from localhost ([::1]:48958 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8gp-0006Pe-JB for importer@patchew.org; Fri, 04 Mar 2022 09:13:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89L-00015d-Ny for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89J-0000WP-If for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:15 -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-590-le-Sw3OiOH2joDMhKYgPJw-1; Fri, 04 Mar 2022 08:39:12 -0500 Received: by mail-wr1-f69.google.com with SMTP id w2-20020adfbac2000000b001ea99ca4c50so3400238wrg.11 for ; Fri, 04 Mar 2022 05:39:11 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id w2-20020adfbac2000000b001f00a723202sm7988864wrg.72.2022.03.04.05.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401153; 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=2c9S+S6IpsBoCVea/PfI2CEqwPpLfLPV5fPeo9+uWlA=; b=UM1R9yS6eQcRuUoGDp+vLxkm0yI8JrPD6aPPMKSnrxPPiGfeRevmf+Rr4e7BWCRMorrWX2 qXTn42RLnd2Le8oBa8NVozqq1IFJ1vGI/AB7z+udxM2OuT8IaleFCOD835ziIE0O6Wr8eT bxwAOg2m1T2OfSHzxe5Nj/aMX6w5d60= X-MC-Unique: le-Sw3OiOH2joDMhKYgPJw-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=2c9S+S6IpsBoCVea/PfI2CEqwPpLfLPV5fPeo9+uWlA=; b=UFLGcAuxNXw062YdXFpZEpxUqEubLZda/RyRx8MVbYJgzrT4n22Wxe07tpNacq/x3r JoYtprUfKTxQQ3LqxqBJouN/Ifu9WwGMTulhfeHTUSoq8mV5NIEeHMxWKEtskc+10bYy Lmb5P8PzQQELxQPNHLsaP+pGLW0Q+A1+riSxC/8PmQuQu4jrGjmZqV3EXZeWNkXI1o5p mMl11fO0EtESmZKI3yAwXefUmufRapLE2lBQDY3Qn9RTeEUVrrDgSBobEB75nFRY31dx RcP2zogfLCJmPgbg3BRm9daLHPhhu7/mj48ZA2tXgt0iWx8jZzvhXSRWxGKuofahKfjh hsPA== X-Gm-Message-State: AOAM531pjHI//Kn9DU+Pzb84ptl+MORnTz05AkczFRj7z+0bWoRPqYXh ilSJs14wt7u8dTb3PA0nsOaJUQR/NUHSrN1jPpg6DvbqCY1BXh7kOm1KcuiItRVlnM37hqr4tGP R76uscqugbMBDhRAMGu/54Gi3iRDP2TToZrB9T6xwVuvH8m2LkyNMB1sYlb0i X-Received: by 2002:a1c:f211:0:b0:381:6c60:742f with SMTP id s17-20020a1cf211000000b003816c60742fmr7785674wmc.130.1646401149002; Fri, 04 Mar 2022 05:39:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzi4doI9IPoHCLSmsRqD7QeC9oQD3wk0zia3gWYxEO4KEDpkLL93mptWS7MwG1VDBSqdCrq/A== X-Received: by 2002:a1c:f211:0:b0:381:6c60:742f with SMTP id s17-20020a1cf211000000b003816c60742fmr7785644wmc.130.1646401148656; Fri, 04 Mar 2022 05:39:08 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 13/45] tests/qtest/libqos/pci: Introduce pio_limit Message-ID: <20220304133556.233983-14-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Thomas Huth , Daniel Henrique Barboza , Greg Kurz , Eric Auger , qemu-ppc@nongnu.org, =?utf-8?Q?C=C3=A9dric?= Le Goater , Paolo Bonzini , David Gibson 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: 1646403234270100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Auger At the moment the IO space limit is hardcoded to QPCI_PIO_LIMIT =3D 0x10000. When accesses are performed to a bar, the base address of this latter is compared against the limit to decide whether we perform an IO or a memory access. On ARM, we cannot keep this PIO limit as the arm-virt machine uses [0x3eff0000, 0x3f000000 ] for the IO space map and we are mandated to allocate at 0x0. Add a new flag in QPCIBar indicating whether it is an IO bar or a memory bar. This flag is set on QPCIBar allocation and provisionned based on the BAR configuration. Then the new flag is used in access functions and in iomap() function. Signed-off-by: Eric Auger Reviewed-by: Thomas Huth Message-Id: <20220210145254.157790-3-eric.auger@redhat.com> Signed-off-by: Eric Auger Reviewed-by: Thomas Huth --- tests/qtest/libqos/pci.h | 5 +-- tests/qtest/libqos/pci-pc.c | 1 + tests/qtest/libqos/pci-spapr.c | 1 + tests/qtest/libqos/pci.c | 78 ++++++++++++++++++++++------------ 4 files changed, 54 insertions(+), 31 deletions(-) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index becb800f9e..44f6806fe4 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -16,8 +16,6 @@ #include "libqtest.h" #include "qgraph.h" =20 -#define QPCI_PIO_LIMIT 0x10000 - #define QPCI_DEVFN(dev, fn) (((dev) << 3) | (fn)) =20 typedef struct QPCIDevice QPCIDevice; @@ -51,7 +49,7 @@ struct QPCIBus { uint8_t offset, uint32_t value); =20 QTestState *qts; - uint16_t pio_alloc_ptr; + uint64_t pio_alloc_ptr, pio_limit; uint64_t mmio_alloc_ptr, mmio_limit; bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */ =20 @@ -59,6 +57,7 @@ struct QPCIBus { =20 struct QPCIBar { uint64_t addr; + bool is_io; }; =20 struct QPCIDevice diff --git a/tests/qtest/libqos/pci-pc.c b/tests/qtest/libqos/pci-pc.c index f97844289f..8051a0881a 100644 --- a/tests/qtest/libqos/pci-pc.c +++ b/tests/qtest/libqos/pci-pc.c @@ -150,6 +150,7 @@ void qpci_init_pc(QPCIBusPC *qpci, QTestState *qts, QGu= estAllocator *alloc) =20 qpci->bus.qts =3D qts; qpci->bus.pio_alloc_ptr =3D 0xc000; + qpci->bus.pio_limit =3D 0x10000; qpci->bus.mmio_alloc_ptr =3D 0xE0000000; qpci->bus.mmio_limit =3D 0x100000000ULL; =20 diff --git a/tests/qtest/libqos/pci-spapr.c b/tests/qtest/libqos/pci-spapr.c index 262226985f..870ffdd8b5 100644 --- a/tests/qtest/libqos/pci-spapr.c +++ b/tests/qtest/libqos/pci-spapr.c @@ -197,6 +197,7 @@ void qpci_init_spapr(QPCIBusSPAPR *qpci, QTestState *qt= s, =20 qpci->bus.qts =3D qts; qpci->bus.pio_alloc_ptr =3D 0xc000; + qpci->bus.pio_limit =3D 0x10000; qpci->bus.mmio_alloc_ptr =3D qpci->mmio32.pci_base; qpci->bus.mmio_limit =3D qpci->mmio32.pci_base + qpci->mmio32.size; =20 diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index 3a9076ae58..b23d72346b 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -398,44 +398,56 @@ void qpci_config_writel(QPCIDevice *dev, uint8_t offs= et, uint32_t value) =20 uint8_t qpci_io_readb(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readb(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readb(bus, token.addr + off); } else { uint8_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); return val; } } =20 uint16_t qpci_io_readw(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readw(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readw(bus, token.addr + off); } else { uint16_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(bus, token.addr + off, &val, sizeof(val)); return le16_to_cpu(val); } } =20 uint32_t qpci_io_readl(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readl(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readl(bus, token.addr + off); } else { uint32_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); return le32_to_cpu(val); } } =20 uint64_t qpci_io_readq(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readq(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readq(bus, token.addr + off); } else { uint64_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(bus, token.addr + off, &val, sizeof(val)); return le64_to_cpu(val); } } @@ -443,57 +455,65 @@ uint64_t qpci_io_readq(QPCIDevice *dev, QPCIBar token= , uint64_t off) void qpci_io_writeb(QPCIDevice *dev, QPCIBar token, uint64_t off, uint8_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writeb(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writeb(bus, token.addr + off, value); } else { - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_io_writew(QPCIDevice *dev, QPCIBar token, uint64_t off, uint16_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writew(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writew(bus, token.addr + off, value); } else { value =3D cpu_to_le16(value); - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_io_writel(QPCIDevice *dev, QPCIBar token, uint64_t off, uint32_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writel(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writel(bus, token.addr + off, value); } else { value =3D cpu_to_le32(value); - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_io_writeq(QPCIDevice *dev, QPCIBar token, uint64_t off, uint64_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writeq(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writeq(bus, token.addr + off, value); } else { value =3D cpu_to_le64(value); - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_memread(QPCIDevice *dev, QPCIBar token, uint64_t off, void *buf, size_t len) { - g_assert(token.addr >=3D QPCI_PIO_LIMIT); + g_assert(!token.is_io); dev->bus->memread(dev->bus, token.addr + off, buf, len); } =20 void qpci_memwrite(QPCIDevice *dev, QPCIBar token, uint64_t off, const void *buf, size_t len) { - g_assert(token.addr >=3D QPCI_PIO_LIMIT); + g_assert(!token.is_io); dev->bus->memwrite(dev->bus, token.addr + off, buf, len); } =20 @@ -534,9 +554,10 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_= t *sizeptr) loc =3D QEMU_ALIGN_UP(bus->pio_alloc_ptr, size); =20 g_assert(loc >=3D bus->pio_alloc_ptr); - g_assert(loc + size <=3D QPCI_PIO_LIMIT); /* Keep PIO below 64kiB = */ + g_assert(loc + size <=3D bus->pio_limit); =20 bus->pio_alloc_ptr =3D loc + size; + bar.is_io =3D true; =20 qpci_config_writel(dev, bar_reg, loc | PCI_BASE_ADDRESS_SPACE_IO); } else { @@ -547,6 +568,7 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t= *sizeptr) g_assert(loc + size <=3D bus->mmio_limit); =20 bus->mmio_alloc_ptr =3D loc + size; + bar.is_io =3D false; =20 qpci_config_writel(dev, bar_reg, loc); } @@ -562,7 +584,7 @@ void qpci_iounmap(QPCIDevice *dev, QPCIBar bar) =20 QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr) { - QPCIBar bar =3D { .addr =3D addr }; + QPCIBar bar =3D { .addr =3D addr, .is_io =3D true }; return bar; } =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403332196402.9225360392969; Fri, 4 Mar 2022 06:15:32 -0800 (PST) Received: from localhost ([::1]:54082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8iR-0001X8-HU for importer@patchew.org; Fri, 04 Mar 2022 09:15:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89Y-0001hX-CN for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30203) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89W-0000Xo-Ah for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:27 -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-288-Mew5bO6kNuOlSzYIaSFq0A-1; Fri, 04 Mar 2022 08:39:24 -0500 Received: by mail-wr1-f72.google.com with SMTP id w2-20020adfbac2000000b001ea99ca4c50so3400458wrg.11 for ; Fri, 04 Mar 2022 05:39:24 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id o22-20020a05600c4fd600b0038133076dcesm5507228wmq.16.2022.03.04.05.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401165; 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=lIN0r7Tzi8KrQtJyX7X8jpPXvsBirmYREU9z5w5uvvo=; b=HFqMVS8phE7JDubyRTJ57DjSb3fWNsEqE0LH9FYZXRCe+xJpd29JA67N9a3wv1uaCmxEAc nB+FylMqgsv8neGzs0SsSNAVWk5ND9EShHlkJ7ZvzcBesuuAvcKHJhq9aCSjo6o2wl8dK0 Qy7Bs31yaYLlF3jmq2Sc57I40tMfmfQ= X-MC-Unique: Mew5bO6kNuOlSzYIaSFq0A-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=lIN0r7Tzi8KrQtJyX7X8jpPXvsBirmYREU9z5w5uvvo=; b=rx/grrmSmbDcQ35dm2Z3naXAutxlKAOJgXDiEcn7n6HPPd4hUUCedsQ2wxjBarESqd TkLBlowiwBquKCr1BPBObhjL13saB5KlAlEyiE4bhyCdf2UX3JgM28BnMhTQy1AFiUZS uJ3On0e+cAcZdoZK5ZX4EQA7gSVj52P3XzeVyfOi/RR1TxeQDkEiWmval7BV1R0ab+ii HjPsnuEBh4yXvBQN8VJwNYJ5BC4RqpnfLlBx6f6KQpg9UeJN4fxBAVBCN+uCIdgbONT1 MVyxjNhzwcdbf4DjWJdNm1NbZCgojRUeayq9PaXA2h7Xj6P+gPb6UF8deMJth3C4cUjE QUZA== X-Gm-Message-State: AOAM530NlWuUxygytIxy823eWXlnhk/Vflw9gTeRLfZgQo8UoCyiBgsd /v8p9pbby7Gh96aqpF6sEVf0mBBnbyv6D582sO2r096I8u/j5dUBHHkCUmGXKGpnHpCHIUuHeSR 7n0AKMbn7SRoJr53ZLr7wUp0X4v5Bka4Dv++hyuc/JWm55kJabhh7mR49WgOo X-Received: by 2002:a05:6000:15cc:b0:1f0:21f8:c99c with SMTP id y12-20020a05600015cc00b001f021f8c99cmr12689411wry.339.1646401163281; Fri, 04 Mar 2022 05:39:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwndblTirB+C0l2wi11gj3XrC/1PY2roJ2VZonerYXt6r5lDkYsxlbfEhOWSzr+hqm7CzyGqQ== X-Received: by 2002:a05:6000:15cc:b0:1f0:21f8:c99c with SMTP id y12-20020a05600015cc00b001f021f8c99cmr12689385wry.339.1646401163001; Fri, 04 Mar 2022 05:39:23 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 14/45] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable Message-ID: <20220304133556.233983-15-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , qemu-block@nongnu.org, Amit Shah , Jason Wang , Coiby Xu , Eric Auger , 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: 1646403334008100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Auger ARM does not not support hotplug on pcie.0. Add a flag on the bus which tells if devices can be hotplugged and skip hotplug tests if the bus cannot be hotplugged. This is a temporary solution to enable the other pci tests on aarch64. Signed-off-by: Eric Auger Acked-by: Thomas Huth Message-Id: <20220210145254.157790-4-eric.auger@redhat.com> Signed-off-by: Eric Auger Acked-by: Thomas Huth --- tests/qtest/libqos/pci.h | 1 + tests/qtest/e1000e-test.c | 6 ++++++ tests/qtest/vhost-user-blk-test.c | 10 ++++++++++ tests/qtest/virtio-blk-test.c | 5 +++++ tests/qtest/virtio-net-test.c | 5 +++++ tests/qtest/virtio-rng-test.c | 5 +++++ 6 files changed, 32 insertions(+) diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index 44f6806fe4..6a28b40522 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -52,6 +52,7 @@ struct QPCIBus { uint64_t pio_alloc_ptr, pio_limit; uint64_t mmio_alloc_ptr, mmio_limit; bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */ + bool not_hotpluggable; /* TRUE if devices cannot be hotplugged */ =20 }; =20 diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c index 0273fe4c15..48f3dbb0fd 100644 --- a/tests/qtest/e1000e-test.c +++ b/tests/qtest/e1000e-test.c @@ -235,6 +235,12 @@ static void test_e1000e_multiple_transfers(void *obj, = void *data, static void test_e1000e_hotplug(void *obj, void *data, QGuestAllocator * a= lloc) { QTestState *qts =3D global_qtest; /* TODO: get rid of global_qtest he= re */ + QE1000E_PCI *dev =3D obj; + + if (dev->pci_dev.bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } =20 qtest_qmp_device_add(qts, "e1000e", "e1000e_net", "{'addr': '0x06'}"); qpci_unplug_acpi_device_test(qts, "e1000e_net", 0x06); diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 62e670f39b..1316aae0fa 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -676,6 +676,11 @@ static void pci_hotplug(void *obj, void *data, QGuestA= llocator *t_alloc) QVirtioPCIDevice *dev; QTestState *qts =3D dev1->pdev->bus->qts; =20 + if (dev1->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + /* plug secondary disk */ qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", "{'addr': %s, 'chardev': 'char2'}", @@ -703,6 +708,11 @@ static void multiqueue(void *obj, void *data, QGuestAl= locator *t_alloc) uint64_t features; uint16_t num_queues; =20 + if (pdev1->pdev->bus->not_hotpluggable) { + g_test_skip("bus pci.0 does not support hotplug"); + return; + } + /* * The primary device has 1 queue and VIRTIO_BLK_F_MQ is not enabled. = The * VIRTIO specification allows VIRTIO_BLK_F_MQ to be enabled when ther= e is diff --git a/tests/qtest/virtio-blk-test.c b/tests/qtest/virtio-blk-test.c index 2a23698211..acb44c9fb8 100644 --- a/tests/qtest/virtio-blk-test.c +++ b/tests/qtest/virtio-blk-test.c @@ -701,6 +701,11 @@ static void pci_hotplug(void *obj, void *data, QGuestA= llocator *t_alloc) QVirtioPCIDevice *dev; QTestState *qts =3D dev1->pdev->bus->qts; =20 + if (dev1->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + /* plug secondary disk */ qtest_qmp_device_add(qts, "virtio-blk-pci", "drv1", "{'addr': %s, 'drive': 'drive1'}", diff --git a/tests/qtest/virtio-net-test.c b/tests/qtest/virtio-net-test.c index 8bf74e516c..af3027144f 100644 --- a/tests/qtest/virtio-net-test.c +++ b/tests/qtest/virtio-net-test.c @@ -174,6 +174,11 @@ static void hotplug(void *obj, void *data, QGuestAlloc= ator *t_alloc) QTestState *qts =3D dev->pdev->bus->qts; const char *arch =3D qtest_get_arch(); =20 + if (dev->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + qtest_qmp_device_add(qts, "virtio-net-pci", "net1", "{'addr': %s}", stringify(PCI_SLOT_HP)); =20 diff --git a/tests/qtest/virtio-rng-test.c b/tests/qtest/virtio-rng-test.c index e6b8cd8e0c..5ce444ad72 100644 --- a/tests/qtest/virtio-rng-test.c +++ b/tests/qtest/virtio-rng-test.c @@ -20,6 +20,11 @@ static void rng_hotplug(void *obj, void *data, QGuestAll= ocator *alloc) QVirtioPCIDevice *dev =3D obj; QTestState *qts =3D dev->pdev->bus->qts; =20 + if (dev->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + const char *arch =3D qtest_get_arch(); =20 qtest_qmp_device_add(qts, "virtio-rng-pci", "rng1", --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403373933567.6911665510618; Fri, 4 Mar 2022 06:16:13 -0800 (PST) Received: from localhost ([::1]:57590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8j7-00043Q-8z for importer@patchew.org; Fri, 04 Mar 2022 09:16:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89f-0001io-Hy for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89d-0000Zy-OM for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:35 -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-246-9siUJH5UMJyyr-i68ihoKw-1; Fri, 04 Mar 2022 08:39:31 -0500 Received: by mail-wr1-f72.google.com with SMTP id g17-20020adfa591000000b001da86c91c22so3387346wrc.5 for ; Fri, 04 Mar 2022 05:39:31 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id o204-20020a1ca5d5000000b0038331f2f951sm14452069wme.0.2022.03.04.05.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401172; 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=IvAnaTG272DSMOFPtKaNzK5eYvV0ma+gLMupIObSFrM=; b=Ll7kcHaXqrNBNkYYqZiPpRD9IR0h/74aJJMhOfQb5Zvmmf4L8gjQKyWP/kUvUCGC10wGwC JzvKz1UvxPnxKRAwNE3Cllj59E4ZlKeXLyLzHStj5y3FTLoBtXkwoQYvQg2Stlq8kyzBG4 ysM8DT7kfMZ67INvrkS+mZqJKmB5cCs= X-MC-Unique: 9siUJH5UMJyyr-i68ihoKw-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=IvAnaTG272DSMOFPtKaNzK5eYvV0ma+gLMupIObSFrM=; b=FO6KZrkkbyFbDiD+BIukNOCYjobEA13jDTgl5BtBqKLwvDJs6d0w6StUJqd/7rZ0p1 JYjbtnKFip9+tnnsEFQqJzQJzcuIHHc5QnP+3Fwe4q6uQHcKfSMJrAgVuxMRZclQLmnc gbLUJktzP1xKc971fs1ZiXBd1skZtATbsTmNItS5GBth5yeT2K3VqYOa+rhjCHlqAr5N Zywo/UAkah3Hv1m9zG5OjYX92556M6E75zOeb+eAtyUOIrLi0cJ7KyLDoLU5iS18Wi+K uEufCGDqvv+vhpmlhv2RZIog8LggSpGN33TLRETVwtC49KdTLBSCyzF2nZDFHKeOf0mn zq2g== X-Gm-Message-State: AOAM5338acCor7l/NHrmiksr2f7YdVBBMfMUOtXm8+2jn0RpKSyRE5Oq dPvUgu355pi5tB3G6V/lEvqZjw6hIDLpqHuJDuAc9Z/E3I5oMmhxf6vVash4IvtRK7faiIOKNUq p8bAieImJt5aRelmsziiAyUfKQ8YsXWjGm+xn8bnS1HYNdhhVrDZx46dYsTHB X-Received: by 2002:adf:df0a:0:b0:1f0:2140:1b41 with SMTP id y10-20020adfdf0a000000b001f021401b41mr11546406wrl.94.1646401169557; Fri, 04 Mar 2022 05:39:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0ujo+P8QVfWpVuNifc50MO51uPkdUHJaZKLPVCZVDBM6VjunjMSwi9rTjM9OrTYHWd1AT9A== X-Received: by 2002:adf:df0a:0:b0:1f0:2140:1b41 with SMTP id y10-20020adfdf0a000000b001f021401b41mr11546388wrl.94.1646401169330; Fri, 04 Mar 2022 05:39:29 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:23 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 15/45] tests/qtest/vhost-user-blk-test: Temporary hack to get tests passing on aarch64 Message-ID: <20220304133556.233983-16-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Coiby Xu , Eric Auger , 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: 1646403376093100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Auger When run on ARM, basic and indirect tests currently fail with the following error: ERROR:../tests/qtest/libqos/virtio.c:224:qvirtio_wait_used_elem: assertion failed (got_desc_idx =3D=3D desc_idx): (50331648 =3D=3D 0) Bail out! ERROR:../tests/qtest/libqos/virtio.c:224: qvirtio_wait_used_elem: assertion failed (got_desc_idx =3D=3D desc_idx): (50331648 =3D=3D 0) I noticed it worked when I set up MSI and I further reduced the code to a simple guest_alloc() that removes the error. At the moment I am not able to identify where ths issue is and this blocks the whole pci/aarch64 enablement. Signed-off-by: Eric Auger Message-Id: <20220210145254.157790-5-eric.auger@redhat.com> Signed-off-by: Eric Auger --- tests/qtest/vhost-user-blk-test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 1316aae0fa..cf8057fb57 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -225,6 +225,9 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGues= tAllocator *alloc) QTestState *qts =3D global_qtest; QVirtQueue *vq; =20 + /* temporary hack to let the test pass on aarch64 */ + guest_alloc(alloc, 4); + features =3D qvirtio_get_features(dev); features =3D features & ~(QVIRTIO_F_BAD_FEATURE | (1u << VIRTIO_RING_F_INDIRECT_DESC) | @@ -469,6 +472,9 @@ static void indirect(void *obj, void *u_data, QGuestAll= ocator *t_alloc) char *data; QTestState *qts =3D global_qtest; =20 + /* temporary hack to let the test pass on aarch64 */ + guest_alloc(t_alloc, 4); + features =3D qvirtio_get_features(dev); g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=3D, = 0); features =3D features & ~(QVIRTIO_F_BAD_FEATURE | --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403600096724.9284800333351; Fri, 4 Mar 2022 06:20:00 -0800 (PST) Received: from localhost ([::1]:38030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8mk-0001jf-Vz for importer@patchew.org; Fri, 04 Mar 2022 09:19:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89m-0001kl-Jn for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20279) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89j-0000aV-Ja for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:42 -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-544-FS6QZXlEPjqFnp_p3Xc6NQ-1; Fri, 04 Mar 2022 08:39:38 -0500 Received: by mail-wm1-f69.google.com with SMTP id j42-20020a05600c1c2a00b00381febe402eso3728855wms.0 for ; Fri, 04 Mar 2022 05:39:37 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id l12-20020a5d6d8c000000b001efd2c071dbsm4904873wrs.20.2022.03.04.05.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401179; 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=sczVSDISAAvrQnMOQiJIwbNl9wG3gcRmRpIhjc6Z3lk=; b=gCfW5LzE4+03DKs3HByCFUNigY7OieLl/l3Knoi4sK50tVrc3NYGupJSF9RmoChsPYm8+e mEk122JPp/uMr+bl49B6/AcVi9r1h+9Vov/EzEsNM+kV0uG6nmzaNKspDKOvQiSzzBdDIU v4WtiwDqtg15sSZ6ZPqfEq+yTEbx9h8= X-MC-Unique: FS6QZXlEPjqFnp_p3Xc6NQ-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=sczVSDISAAvrQnMOQiJIwbNl9wG3gcRmRpIhjc6Z3lk=; b=RhFTuzVgDQUrGuLncLuTUka6XdDezsHZ1+TyhsKLXI6W6UJvOtL+UDRIdkrrS1/1Xf pq6Tdu+lVBRRJrRQgR6LiMnS38dgk2CkqJo+kWDPgmjNXkPFhNVJVIBf3Ob03n1hi/cj AFDOLTpmi3NcU/NaV/dBOx3E7rAzgTgORvQOAvIKmWm1Z672TkhbJgy4id6t6zuZirfJ N8/9JFy1QQxLLaTvAwupYyIwZ+Ss0dVZg7wPl6rJIEF/HrNJpRn+s+/Lm8xT77NSX4eI LdscLqMwNGAmRV2TxDBp3rzKtg/PZXSONc1i/5BXbr/HWPRzi8kC5fjXcNv84B9hfR7q KyPw== X-Gm-Message-State: AOAM532T1k5WuKXc5RMLgjsqWl87lL4FHLOGLiXk0JF7cVvjsOxO+D0h 7MU1zVm4/1Kfa4+4x8F9uF6/jlkQqNHy6oO7PzvYRGSKPTZE13k5mwMZa9ZiEcyJ2HwbAggJZ12 VepPvEbLCF5VSjId6Cnjdrz2NBmWq00yhJQPc+u60mphdVNSPUYI2APEYRNfM X-Received: by 2002:a05:600c:1f1b:b0:389:81eb:fb77 with SMTP id bd27-20020a05600c1f1b00b0038981ebfb77mr2073646wmb.36.1646401176398; Fri, 04 Mar 2022 05:39:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQx5xOk4kEQ6NTLwh8wT0dMnpRRODRc6wXETYGkaXsdvexjD0zCAF8LDQXbW8xEr4YXhUPzQ== X-Received: by 2002:a05:600c:1f1b:b0:389:81eb:fb77 with SMTP id bd27-20020a05600c1f1b00b0038981ebfb77mr2073624wmb.36.1646401176019; Fri, 04 Mar 2022 05:39:36 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 16/45] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine Message-ID: <20220304133556.233983-17-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Paolo Bonzini , Eric Auger 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: 1646403601055100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Auger Up to now the virt-machine node contains a virtio-mmio node. However no driver produces any PCI interface node. Hence, PCI tests cannot be run with aarch64 binary. Add a GPEX driver node that produces a pci interface node. This latter then can be consumed by all the pci tests. One of the first motivation was to be able to run the virtio-iommu-pci tests. We still face an issue with pci hotplug tests as hotplug cannot happen on the pcie root bus and require a generic root port. This will be addressed later on. We force cpu=3Dmax along with aarch64/virt machine as some PCI tests require high MMIO regions to be available. Signed-off-by: Eric Auger Message-Id: <20220210145254.157790-6-eric.auger@redhat.com> Signed-off-by: Eric Auger --- tests/qtest/libqos/generic-pcihost.h | 54 ++++++ tests/qtest/libqos/arm-virt-machine.c | 19 ++- tests/qtest/libqos/generic-pcihost.c | 231 ++++++++++++++++++++++++++ tests/qtest/libqos/meson.build | 1 + 4 files changed, 301 insertions(+), 4 deletions(-) create mode 100644 tests/qtest/libqos/generic-pcihost.h create mode 100644 tests/qtest/libqos/generic-pcihost.c diff --git a/tests/qtest/libqos/generic-pcihost.h b/tests/qtest/libqos/gene= ric-pcihost.h new file mode 100644 index 0000000000..c693c769df --- /dev/null +++ b/tests/qtest/libqos/generic-pcihost.h @@ -0,0 +1,54 @@ +/* + * libqos Generic PCI bindings and generic pci host bridge + * + * Copyright Red Hat Inc., 2022 + * + * Authors: + * Eric Auger + * + * 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. + */ + +#ifndef LIBQOS_GENERIC_PCIHOST_H +#define LIBQOS_GENERIC_PCIHOST_H + +#include "pci.h" +#include "malloc.h" +#include "qgraph.h" + +typedef struct QGenericPCIBus { + QOSGraphObject obj; + QPCIBus bus; + uint64_t gpex_pio_base; + uint64_t ecam_alloc_ptr; +} QGenericPCIBus; + +/* + * qpci_init_generic(): + * @ret: A valid QGenericPCIBus * pointer + * @qts: The %QTestState + * @alloc: A previously initialized @alloc providing memory for @qts + * @bool: devices can be hotplugged on this bus + * + * This function initializes an already allocated + * QGenericPCIBus object. + */ +void qpci_init_generic(QGenericPCIBus *ret, QTestState *qts, + QGuestAllocator *alloc, bool hotpluggable); + +/* QGenericPCIHost */ + +typedef struct QGenericPCIHost QGenericPCIHost; + +struct QGenericPCIHost { + QOSGraphObject obj; + QGenericPCIBus pci; +}; + +QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device); +void qos_create_generic_pcihost(QGenericPCIHost *host, + QTestState *qts, + QGuestAllocator *alloc); + +#endif diff --git a/tests/qtest/libqos/arm-virt-machine.c b/tests/qtest/libqos/arm= -virt-machine.c index e0f5932284..96da0dde54 100644 --- a/tests/qtest/libqos/arm-virt-machine.c +++ b/tests/qtest/libqos/arm-virt-machine.c @@ -22,6 +22,8 @@ #include "malloc.h" #include "qgraph.h" #include "virtio-mmio.h" +#include "generic-pcihost.h" +#include "hw/pci/pci_regs.h" =20 #define ARM_PAGE_SIZE 4096 #define VIRTIO_MMIO_BASE_ADDR 0x0A003E00 @@ -35,6 +37,7 @@ struct QVirtMachine { QOSGraphObject obj; QGuestAllocator alloc; QVirtioMMIODevice virtio_mmio; + QGenericPCIHost bridge; }; =20 static void virt_destructor(QOSGraphObject *obj) @@ -57,11 +60,13 @@ static void *virt_get_driver(void *object, const char *= interface) static QOSGraphObject *virt_get_device(void *obj, const char *device) { QVirtMachine *machine =3D obj; - if (!g_strcmp0(device, "virtio-mmio")) { + if (!g_strcmp0(device, "generic-pcihost")) { + return &machine->bridge.obj; + } else if (!g_strcmp0(device, "virtio-mmio")) { return &machine->virtio_mmio.obj; } =20 - fprintf(stderr, "%s not present in arm/virtio\n", device); + fprintf(stderr, "%s not present in arm/virt\n", device); g_assert_not_reached(); } =20 @@ -76,16 +81,22 @@ static void *qos_create_machine_arm_virt(QTestState *qt= s) qvirtio_mmio_init_device(&machine->virtio_mmio, qts, VIRTIO_MMIO_BASE_= ADDR, VIRTIO_MMIO_SIZE); =20 + qos_create_generic_pcihost(&machine->bridge, qts, &machine->alloc); + machine->obj.get_device =3D virt_get_device; machine->obj.get_driver =3D virt_get_driver; machine->obj.destructor =3D virt_destructor; return machine; } =20 -static void virtio_mmio_register_nodes(void) +static void virt_machine_register_nodes(void) { qos_node_create_machine("arm/virt", qos_create_machine_arm_virt); qos_node_contains("arm/virt", "virtio-mmio", NULL); + + qos_node_create_machine_args("aarch64/virt", qos_create_machine_arm_vi= rt, + " -cpu max"); + qos_node_contains("aarch64/virt", "generic-pcihost", NULL); } =20 -libqos_init(virtio_mmio_register_nodes); +libqos_init(virt_machine_register_nodes); diff --git a/tests/qtest/libqos/generic-pcihost.c b/tests/qtest/libqos/gene= ric-pcihost.c new file mode 100644 index 0000000000..704bbc3473 --- /dev/null +++ b/tests/qtest/libqos/generic-pcihost.c @@ -0,0 +1,231 @@ +/* + * libqos PCI bindings for generic PCI + * + * Copyright Red Hat Inc., 2022 + * + * Authors: + * Eric Auger + * + * 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 "libqtest.h" +#include "generic-pcihost.h" +#include "qapi/qmp/qdict.h" +#include "hw/pci/pci_regs.h" + +#include "qemu/module.h" + +/* QGenericPCIHost */ + +QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device) +{ + QGenericPCIHost *host =3D obj; + if (!g_strcmp0(device, "pci-bus-generic")) { + return &host->pci.obj; + } + fprintf(stderr, "%s not present in generic-pcihost\n", device); + g_assert_not_reached(); +} + +void qos_create_generic_pcihost(QGenericPCIHost *host, + QTestState *qts, + QGuestAllocator *alloc) +{ + host->obj.get_device =3D generic_pcihost_get_device; + qpci_init_generic(&host->pci, qts, alloc, false); +} + +static uint8_t qpci_generic_pio_readb(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readb(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t v= al) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writeb(bus->qts, s->gpex_pio_base + addr, val); +} + +static uint16_t qpci_generic_pio_readw(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readw(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t = val) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writew(bus->qts, s->gpex_pio_base + addr, val); +} + +static uint32_t qpci_generic_pio_readl(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readl(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t = val) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writel(bus->qts, s->gpex_pio_base + addr, val); +} + +static uint64_t qpci_generic_pio_readq(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readq(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t = val) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writeq(bus->qts, s->gpex_pio_base + addr, val); +} + +static void qpci_generic_memread(QPCIBus *bus, uint32_t addr, void *buf, s= ize_t len) +{ + qtest_memread(bus->qts, addr, buf, len); +} + +static void qpci_generic_memwrite(QPCIBus *bus, uint32_t addr, + const void *buf, size_t len) +{ + qtest_memwrite(bus->qts, addr, buf, len); +} + +static uint8_t qpci_generic_config_readb(QPCIBus *bus, int devfn, uint8_t = offset) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint8_t val; + + qtest_memread(bus->qts, addr, &val, 1); + return val; +} + +static uint16_t qpci_generic_config_readw(QPCIBus *bus, int devfn, uint8_t= offset) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint16_t val; + + qtest_memread(bus->qts, addr, &val, 2); + return val; +} + +static uint32_t qpci_generic_config_readl(QPCIBus *bus, int devfn, uint8_t= offset) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val; + + qtest_memread(bus->qts, addr, &val, 4); + return val; +} + +static void +qpci_generic_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_= t value) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val =3D value; + + qtest_memwrite(bus->qts, addr, &val, 1); +} + +static void +qpci_generic_config_writew(QPCIBus *bus, int devfn, uint8_t offset, uint16= _t value) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val =3D value; + + qtest_memwrite(bus->qts, addr, &val, 2); +} + +static void +qpci_generic_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint32= _t value) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val =3D value; + + qtest_memwrite(bus->qts, addr, &val, 4); +} + +static void *qpci_generic_get_driver(void *obj, const char *interface) +{ + QGenericPCIBus *qpci =3D obj; + if (!g_strcmp0(interface, "pci-bus")) { + return &qpci->bus; + } + fprintf(stderr, "%s not present in pci-bus-generic\n", interface); + g_assert_not_reached(); +} + +void qpci_init_generic(QGenericPCIBus *qpci, QTestState *qts, + QGuestAllocator *alloc, bool hotpluggable) +{ + assert(qts); + + qpci->gpex_pio_base =3D 0x3eff0000; + qpci->bus.not_hotpluggable =3D !hotpluggable; + qpci->bus.has_buggy_msi =3D false; + + qpci->bus.pio_readb =3D qpci_generic_pio_readb; + qpci->bus.pio_readw =3D qpci_generic_pio_readw; + qpci->bus.pio_readl =3D qpci_generic_pio_readl; + qpci->bus.pio_readq =3D qpci_generic_pio_readq; + + qpci->bus.pio_writeb =3D qpci_generic_pio_writeb; + qpci->bus.pio_writew =3D qpci_generic_pio_writew; + qpci->bus.pio_writel =3D qpci_generic_pio_writel; + qpci->bus.pio_writeq =3D qpci_generic_pio_writeq; + + qpci->bus.memread =3D qpci_generic_memread; + qpci->bus.memwrite =3D qpci_generic_memwrite; + + qpci->bus.config_readb =3D qpci_generic_config_readb; + qpci->bus.config_readw =3D qpci_generic_config_readw; + qpci->bus.config_readl =3D qpci_generic_config_readl; + + qpci->bus.config_writeb =3D qpci_generic_config_writeb; + qpci->bus.config_writew =3D qpci_generic_config_writew; + qpci->bus.config_writel =3D qpci_generic_config_writel; + + qpci->bus.qts =3D qts; + qpci->bus.pio_alloc_ptr =3D 0x0000; + qpci->bus.pio_limit =3D 0x10000; + qpci->bus.mmio_alloc_ptr =3D 0x10000000; + qpci->bus.mmio_limit =3D 0x2eff0000; + qpci->ecam_alloc_ptr =3D 0x4010000000; + + qpci->obj.get_driver =3D qpci_generic_get_driver; +} + +static void qpci_generic_register_nodes(void) +{ + qos_node_create_driver("pci-bus-generic", NULL); + qos_node_produces("pci-bus-generic", "pci-bus"); +} + +static void qpci_generic_pci_register_nodes(void) +{ + qos_node_create_driver("generic-pcihost", NULL); + qos_node_contains("generic-pcihost", "pci-bus-generic", NULL); +} + +libqos_init(qpci_generic_register_nodes); +libqos_init(qpci_generic_pci_register_nodes); diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index e988d15791..8c8ee15553 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -42,6 +42,7 @@ libqos_srcs =3D files('../libqtest.c', 'virtio-scsi.c', 'virtio-serial.c', 'virtio-iommu.c', + 'generic-pcihost.c', =20 # qgraph machines: 'aarch64-xlnx-zcu102-machine.c', --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403138447580.8984662568647; Fri, 4 Mar 2022 06:12:18 -0800 (PST) Received: from localhost ([::1]:45658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8fJ-0004BP-Nh for importer@patchew.org; Fri, 04 Mar 2022 09:12:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89r-0001ml-Ql for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89p-0000b5-EA for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:46 -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-116-n1WABH6vMlaEhkbeFUnZEw-1; Fri, 04 Mar 2022 08:39:43 -0500 Received: by mail-wm1-f70.google.com with SMTP id v125-20020a1cac83000000b0037e3d70e7e1so4172113wme.1 for ; Fri, 04 Mar 2022 05:39:43 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id h188-20020a1c21c5000000b00385699a8993sm5418041wmh.11.2022.03.04.05.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401184; 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=2MmbtRN8dUw8oStDJevhrQCWdjKFEsw6VGH8lAmLmm4=; b=K8P6HDWCxncmjlwKBaZjXJU3QDCvHBUUFMp9x8I27BSqb2obN/PLr7QkeduJMNK6/6jeUh Ldx4GYIO0Xde4cwwXmGnwkrzhUV9ffRX0KqNJ1/9TzA7UfOMCmLowJlHv5gtp9YUlR3Dr4 HzgBo6R3UBbEci+GriYVL7V4d66hoLE= X-MC-Unique: n1WABH6vMlaEhkbeFUnZEw-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=2MmbtRN8dUw8oStDJevhrQCWdjKFEsw6VGH8lAmLmm4=; b=nuj05/KoUnlSOcEZP8YDiNedl9vohebeHn2rz4tYeSH+yj2NjqZWPUjNH0ChzHwCB6 b8z4mjDQlit0kUH4g7o9qpAgUVnLms+8o4QgkHKoTn0dk1y0JP62h08VNxST2YXLHJF9 gHdLJss2pJ/VeqS4sRvUpuQBzxpjkv06B9uwJ/dsm2++rpr38vscVk3vgOxtxnZnknh7 JCBda1OPyAsK2XTIYufHLH5354q7uCj1+XzYNTuuzosAPluC0Ft1bQqICSSmtPrqJq3Q ynuaKzd9Lg1CptxiBJliRgjZZrjaiuyylHaG7obAbbDKTzPJOJALEiK8hiHktncMuF7v WMcQ== X-Gm-Message-State: AOAM533W3PIfYZ0yRMQESO4gJzR9suprZhxGYN0afZC8pKRXo9HfMoSJ wWfD+liFu2/hyKBHji6DCHSARI4wJyMB40Ulto+vjE1JAgWlayHgVl43Rew30yUzUvnCOfa4Egy ypQ498QLprCIeA8syIXdVlwuSn0IeuMOgAKR760xvH9aC+ZBEig288julDBvn X-Received: by 2002:adf:df0a:0:b0:1f0:2140:1b41 with SMTP id y10-20020adfdf0a000000b001f021401b41mr11546978wrl.94.1646401182134; Fri, 04 Mar 2022 05:39:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxR5Le5DdBLqZZ/FMTnXXejhN72QuaczGtklV44igio/vB3rgtjpD1wQt17n3uE/l4TUybGqw== X-Received: by 2002:adf:df0a:0:b0:1f0:2140:1b41 with SMTP id y10-20020adfdf0a000000b001f021401b41mr11546963wrl.94.1646401181911; Fri, 04 Mar 2022 05:39:41 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 17/45] hw/virtio: vdpa: Fix leak of host-notifier memory-region Message-ID: <20220304133556.233983-18-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , jasowang@redhat.com, qemu-stable@nongnu.org, Stefano Garzarella 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: 1646403141112100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier If call virtio_queue_set_host_notifier_mr fails, should free host-notifier memory-region. This problem can trigger a coredump with some vDPA drivers (mlx5, but not with the vdpasim), if we unplug the virtio-net card from the guest after a stop/start. The same fix has been done for vhost-user: 1f89d3b91e3e ("hw/virtio: Fix leak of host-notifier memory-region") Fixes: d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possib= le") Cc: jasowang@redhat.com Resolves: https://bugzilla.redhat.com/2027208 Signed-off-by: Laurent Vivier Message-Id: <20220211170259.1388734-1-lvivier@redhat.com> Cc: qemu-stable@nongnu.org Acked-by: Jason Wang Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 04ea43704f..11f696468d 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -431,6 +431,7 @@ static int vhost_vdpa_host_notifier_init(struct vhost_d= ev *dev, int queue_index) g_free(name); =20 if (virtio_queue_set_host_notifier_mr(vdev, queue_index, &n->mr, true)= ) { + object_unparent(OBJECT(&n->mr)); munmap(addr, page_size); goto err; } --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403736006965.296189737048; Fri, 4 Mar 2022 06:22:16 -0800 (PST) Received: from localhost ([::1]:46602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8ox-0007YU-H4 for importer@patchew.org; Fri, 04 Mar 2022 09:22:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89w-0001zi-Ch for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36310) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ89u-0000bg-LR for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:39:51 -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-443-So7H2Y8-Nvi66QHCt-sJsA-1; Fri, 04 Mar 2022 08:39:49 -0500 Received: by mail-wm1-f69.google.com with SMTP id l2-20020a1ced02000000b0038482a47e7eso2823995wmh.5 for ; Fri, 04 Mar 2022 05:39:48 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id r10-20020a05600c35ca00b0038981d85ae8sm1594052wmq.33.2022.03.04.05.39.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401190; 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=XiwXEThr1SLQJqLQ68T7zcCUyaMzcHqcL8oJCLXsU/A=; b=J1ARAOsEvVziw0CHwCTn8nZ2Dopzi25T0Xq9xBlP4ME6FYUNYePQYDy5lFCIH+r/aE9Nju WK17qAJiJHG5cHMaglPD1dcqDj81jRlSFq2AqWAyPw46vUuBIHr1VkAMpmiMFAZ57r+sds IJpFJbDhFcf2nYb/s9CzZgU/SuKIHSA= X-MC-Unique: So7H2Y8-Nvi66QHCt-sJsA-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=XiwXEThr1SLQJqLQ68T7zcCUyaMzcHqcL8oJCLXsU/A=; b=aQ5NMdiviNlFSQcNdfwR2SKTd/xYWOcCDzFtvRcVJUF51teheI2+kvFNOvT/FRC6D0 ONYru88P+l7kdEzCshbdGM+cpm2CQlbfesXXRP3MIv0qojotmrDG16blSXYxoQWsvQqG 8gk6DInz7haSynzT/EswVIeJsyWEC9fcYv+eDGDxSwmg9gvOCVpwhAHorqydDNX37QzF 5OkcToVZYfPkl2J9Mg7VPRJmpKYsHzmuYe+S6YKIYxDLBSTQI839p+AgClUFJWHLQqI5 X286nSrGgLZZ9NAhijFAmBk+OmIP56d4xYQa9KSZgeKVNqf0x4GG6sSWiaKnjP94FgW5 4cOA== X-Gm-Message-State: AOAM530wwoPWwWWnySTzsm6mIgiEaUy1qZz0AmrOuvIZIg1ocyP3EQJe RYzrpbtyGg8PjYkx0HjlNyGAIKJXVDz7q4l1k8u/p3kIWxyVFyA029/hOZY4XoHewC7+4e6Z7lz Vm79J+rcoUYrQq2Eb5FtI4+8YC4udggf3XQkIq/+4xNYHb85YGZjmjUt3QolV X-Received: by 2002:a5d:5981:0:b0:1ef:8304:d9c1 with SMTP id n1-20020a5d5981000000b001ef8304d9c1mr22496468wri.43.1646401187422; Fri, 04 Mar 2022 05:39:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTjV1L6XDYVJKyO4kw95BVlvP/ImkrqEPK3rZw/OWHDPv3APntCKrpTCgGLlbEUF1PEtkyZQ== X-Received: by 2002:a5d:5981:0:b0:1ef:8304:d9c1 with SMTP id n1-20020a5d5981000000b001ef8304d9c1mr22496450wri.43.1646401187164; Fri, 04 Mar 2022 05:39:47 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 18/45] vhost-vdpa: make notifiers _init()/_uninit() symmetric Message-ID: <20220304133556.233983-19-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , jasowang@redhat.com, Stefano Garzarella 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: 1646403737999100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Laurent Vivier vhost_vdpa_host_notifiers_init() initializes queue notifiers for queues "dev->vq_index" to queue "dev->vq_index + dev->nvqs", whereas vhost_vdpa_host_notifiers_uninit() uninitializes the same notifiers for queue "0" to queue "dev->nvqs". This asymmetry seems buggy, fix that by using dev->vq_index as the base for both. Fixes: d0416d487bd5 ("vhost-vdpa: map virtqueue notification area if possib= le") Cc: jasowang@redhat.com Signed-off-by: Laurent Vivier Message-Id: <20220211161309.1385839-1-lvivier@redhat.com> Acked-by: Jason Wang Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 11f696468d..6c67d5f034 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -395,15 +395,6 @@ static void vhost_vdpa_host_notifier_uninit(struct vho= st_dev *dev, } } =20 -static void vhost_vdpa_host_notifiers_uninit(struct vhost_dev *dev, int n) -{ - int i; - - for (i =3D 0; i < n; i++) { - vhost_vdpa_host_notifier_uninit(dev, i); - } -} - static int vhost_vdpa_host_notifier_init(struct vhost_dev *dev, int queue_= index) { size_t page_size =3D qemu_real_host_page_size; @@ -443,6 +434,15 @@ err: return -1; } =20 +static void vhost_vdpa_host_notifiers_uninit(struct vhost_dev *dev, int n) +{ + int i; + + for (i =3D dev->vq_index; i < dev->vq_index + n; i++) { + vhost_vdpa_host_notifier_uninit(dev, i); + } +} + static void vhost_vdpa_host_notifiers_init(struct vhost_dev *dev) { int i; @@ -456,7 +456,7 @@ static void vhost_vdpa_host_notifiers_init(struct vhost= _dev *dev) return; =20 err: - vhost_vdpa_host_notifiers_uninit(dev, i); + vhost_vdpa_host_notifiers_uninit(dev, i - dev->vq_index); return; } =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 164640351217494.94871458454361; Fri, 4 Mar 2022 06:18:32 -0800 (PST) Received: from localhost ([::1]:35700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8lK-00006m-JL for importer@patchew.org; Fri, 04 Mar 2022 09:18:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8A7-0002UH-MQ for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25678) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8A2-0000cX-9F for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:03 -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-39-I9fI4385PDWOXyX_pX2irw-1; Fri, 04 Mar 2022 08:39:56 -0500 Received: by mail-wm1-f71.google.com with SMTP id h206-20020a1c21d7000000b003552c13626cso4160677wmh.3 for ; Fri, 04 Mar 2022 05:39:56 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id l7-20020adfe9c7000000b001f06f8ec92dsm2115310wrn.30.2022.03.04.05.39.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401197; 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=0lVkB02NxWofYSS4as/4ncAO6TZl7kf9saq/7ls1Nww=; b=RESvClL4ssFcuv2qs/UzD7XQQL95J2Y3Z5EOb5RCzgGCJzLyeOlPM+bOsmyQPcC5EBlLsg A66T0PTJnPldY7sOCewDhtAhFhfLh6qmGMbRYb5m+ny+9/JlJAafD8pty0r983ZMcKfmd/ k3grXh5ubMljjBq7z5n4GqAMdYoO/eM= X-MC-Unique: I9fI4385PDWOXyX_pX2irw-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=0lVkB02NxWofYSS4as/4ncAO6TZl7kf9saq/7ls1Nww=; b=3aK3E+nZnFAU0cZ1S/p6EquL/QcWAG2KCnLorFV4WxuKPUbMn1danPkK0m8maDTV4t yTgRG3g9Sc04KSHTjSF5SPLlrZZC60BbNUJ/igQJj3O9L14mG5hEJ9vJm/7LIpcOCBNk 0xM3pAGOEzUQd7J4GTsUiyxXnRIZV6Sxoh+gc2Npj7NkxG6xGlirMHjniFoydUhQc9WO BulJorfJoAknPONjXyGu6GzWg6osGv820PFWaEZs0UO2jNY2rsUP9oaLdnDPD5X2Pvth 8VjfhDq1NUM+vvyt8wpIIis4cp82lzTeFoFWYYlK57jtF9yrZA1cpUwxBh+rIfTkmkIz 18hw== X-Gm-Message-State: AOAM530WIEPlMkUC2f26Py41M/N5mmDD5l8fjVzTqXnI/zoaK291HpLc NVhdhLdhDsSam+pqN/LtqIR/K0t2fIaAQZUyFt6Dqpwj9C7c+ReGVtP3UzgF40eXUD+AaS1Ivrz KFqFANkKzywdY6QQN/kc1458gZWmBFup+RfRp+CV1Xt65FhxPWN+Nf3b6DQ3f X-Received: by 2002:a7b:c383:0:b0:381:1b50:a9d with SMTP id s3-20020a7bc383000000b003811b500a9dmr7856637wmj.90.1646401194471; Fri, 04 Mar 2022 05:39:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJylMzhO32zoG/SFG+pAlqL970e44F33m9F4bxun5svvcL8NZmBU3qVV90c55CrdY8qmdkPmTg== X-Received: by 2002:a7b:c383:0:b0:381:1b50:a9d with SMTP id s3-20020a7bc383000000b003811b500a9dmr7856614wmj.90.1646401194149; Fri, 04 Mar 2022 05:39:54 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 19/45] intel_iommu: support snoop control Message-ID: <20220304133556.233983-20-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Jason Wang , Richard Henderson , Peter Xu , 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: 1646403514322100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jason Wang SC is required for some kernel features like vhost-vDPA. So this patch implements basic SC feature. The idea is pretty simple, for software emulated DMA it would be always coherent. In this case we can simple advertise ECAP_SC bit. For VFIO and vhost, thing will be more much complicated, so this patch simply fail the IOMMU notifier registration. In the future, we may want to have a dedicated notifiers flag or similar mechanism to demonstrate the coherency so VFIO could advertise that if it has VFIO_DMA_CC_IOMMU, for vhost kernel backend we don't need that since it's a software backend. Signed-off-by: Jason Wang Message-Id: <20220214060346.72455-1-jasowang@redhat.com> Reviewed-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 1 + include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index a6c788049b..1ff13b40f9 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -188,6 +188,7 @@ #define VTD_ECAP_IR (1ULL << 3) #define VTD_ECAP_EIM (1ULL << 4) #define VTD_ECAP_PT (1ULL << 6) +#define VTD_ECAP_SC (1ULL << 7) #define VTD_ECAP_MHMV (15ULL << 20) #define VTD_ECAP_SRS (1ULL << 31) #define VTD_ECAP_SMTS (1ULL << 43) diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 41783ee46d..3b5ac869db 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -228,6 +228,7 @@ struct IntelIOMMUState { =20 bool caching_mode; /* RO - is cap CM enabled? */ bool scalable_mode; /* RO - is Scalable Mode supported? */ + bool snoop_control; /* RO - is SNP filed supported? */ =20 dma_addr_t root; /* Current root table pointer */ bool root_scalable; /* Type of root table (scalable or not= ) */ diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 4c6c016388..32471a44cb 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3030,6 +3030,13 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemory= Region *iommu, VTDAddressSpace *vtd_as =3D container_of(iommu, VTDAddressSpace, iommu= ); IntelIOMMUState *s =3D vtd_as->iommu_state; =20 + /* TODO: add support for VFIO and vhost users */ + if (s->snoop_control) { + error_setg_errno(errp, -ENOTSUP, + "Snoop Control with vhost or VFIO is not supporte= d"); + return -ENOTSUP; + } + /* Update per-address-space notifier flags */ vtd_as->notifier_flags =3D new; =20 @@ -3113,6 +3120,7 @@ static Property vtd_properties[] =3D { VTD_HOST_ADDRESS_WIDTH), DEFINE_PROP_BOOL("caching-mode", IntelIOMMUState, caching_mode, FALSE), DEFINE_PROP_BOOL("x-scalable-mode", IntelIOMMUState, scalable_mode, FA= LSE), + DEFINE_PROP_BOOL("snoop-control", IntelIOMMUState, snoop_control, fals= e), DEFINE_PROP_BOOL("dma-drain", IntelIOMMUState, dma_drain, true), DEFINE_PROP_END_OF_LIST(), }; @@ -3643,7 +3651,7 @@ static void vtd_init(IntelIOMMUState *s) vtd_spte_rsvd_large[3] =3D VTD_SPTE_LPAGE_L3_RSVD_MASK(s->aw_bits, x86_iommu->dt_sup= ported); =20 - if (s->scalable_mode) { + if (s->scalable_mode || s->snoop_control) { vtd_spte_rsvd[1] &=3D ~VTD_SPTE_SNP; vtd_spte_rsvd_large[2] &=3D ~VTD_SPTE_SNP; vtd_spte_rsvd_large[3] &=3D ~VTD_SPTE_SNP; @@ -3674,6 +3682,10 @@ static void vtd_init(IntelIOMMUState *s) s->ecap |=3D VTD_ECAP_SMTS | VTD_ECAP_SRS | VTD_ECAP_SLTS; } =20 + if (s->snoop_control) { + s->ecap |=3D VTD_ECAP_SC; + } + vtd_reset_caches(s); =20 /* Define registers with default values and bit semantics */ --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403346799179.63961588853113; Fri, 4 Mar 2022 06:15:46 -0800 (PST) Received: from localhost ([::1]:55252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8if-0002OP-T7 for importer@patchew.org; Fri, 04 Mar 2022 09:15:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8A9-0002Vp-0T for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8A7-0000g5-5w for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:04 -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-400-k9hmETqkNHOziMM8upNzqw-1; Fri, 04 Mar 2022 08:40:01 -0500 Received: by mail-wm1-f70.google.com with SMTP id l13-20020a7bcf0d000000b0038982c6bf8fso405124wmg.7 for ; Fri, 04 Mar 2022 05:40:01 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id r20-20020adfa154000000b001f0326a23e1sm4584138wrr.88.2022.03.04.05.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:39:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401202; 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=hG63fk2e7vwNR105jMKcH2PAlFDWHa3moRydXJnnvuY=; b=d8tx+L4NO8LKo0BcRuIVJQy58ONptNscFPaBW+dAoS8MJ6itSwcXkFSDVV1vaT3ilPBliY J7hWDOLaCrgAGKo/qZmghxitcWIfDmzeYax+dB4wC8IK+bjidzUKKI8VrqURW6dG5MFLl9 tMFPVh0siWfh6YCBgUG+yk1nUI83/3k= X-MC-Unique: k9hmETqkNHOziMM8upNzqw-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=hG63fk2e7vwNR105jMKcH2PAlFDWHa3moRydXJnnvuY=; b=5U+nwkOY0MLNSgQFmriB0z0Sn0eWiGM8fdLT1B5lTFMtDwR3oalP3D5EsFUtEzcd4z NaZWf8rBuTlXGXA0HJvjMV+hElKTfAdcR1V8I0SWIXd4cJnTYns8E9piPPCUp4HSakGd Wn2W39kw2qoJXzY1RbC5AuyHQ1StmjmLS3jZErwKHgayGilUtzqGL9YcFuY//4a+g1JW vKTvovUnAy/Sh88N0jK6lbs5WbcGH+LcbzUUEfOpRzoRC/TROZP5iwpaETTxoIoFcb6Q 7hKEzqUw53wvFeSyErT8DPV59DLLN/EWebhJMt/wi53cv33o7xalTswMrFA+hvmnQodE i0BQ== X-Gm-Message-State: AOAM530wae6TqcVQcA3VbW4E64OzuK7MUN3aaMvqDwqps72a+aHV2Mel qpZRakQ9ZBRCweN9ERvWp9eX5Fx7RYOaAFxCBmXcXFa1ZpD6sbJ50KLXuju0rqa6wAx2+ZgpkGB H/I8nQy5iMX24hq066VIVVllzaEAiJ6o3A67gnbPrnwrQ79dAM8KZ2/SlYrsh X-Received: by 2002:adf:912f:0:b0:1e3:909:a6b6 with SMTP id j44-20020adf912f000000b001e30909a6b6mr30349935wrj.684.1646401200166; Fri, 04 Mar 2022 05:40:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUWSSliWsH8On+30xQK9D8r/wwZAQRYIfiYL9qIUzA5vdcDSl2upQv4yV3osq0VqfFQxZVsw== X-Received: by 2002:adf:912f:0:b0:1e3:909:a6b6 with SMTP id j44-20020adf912f000000b001e30909a6b6mr30349906wrj.684.1646401199835; Fri, 04 Mar 2022 05:39:59 -0800 (PST) Date: Fri, 4 Mar 2022 08:39:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 20/45] hw/i386: Improve bounds checking in OVMF table parsing Message-ID: <20220304133556.233983-21-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Daniel P =?utf-8?B?LiBCZXJyYW5nw6k=?= , Richard Henderson , "Dr . David Alan Gilbert" , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Dov Murik , Gerd Hoffmann , 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: 1646403348121100003 From: Dov Murik When pc_system_parse_ovmf_flash() parses the optional GUIDed table in the end of the OVMF flash memory area, the table length field is checked for sizes that are too small, but doesn't error on sizes that are too big (bigger than the flash content itself). Add a check for maximal size of the OVMF table, and add an error report in case the size is invalid. In such a case, an error like this will be displayed during launch: qemu-system-x86_64: OVMF table has invalid size 4047 and the table parsing is skipped. Signed-off-by: Dov Murik Message-Id: <20220222071906.2632426-2-dovmurik@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Dr. David Alan Gilbert --- hw/i386/pc_sysfw_ovmf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc_sysfw_ovmf.c b/hw/i386/pc_sysfw_ovmf.c index f4dd92c588..df15c9737b 100644 --- a/hw/i386/pc_sysfw_ovmf.c +++ b/hw/i386/pc_sysfw_ovmf.c @@ -24,6 +24,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "hw/i386/pc.h" #include "cpu.h" =20 @@ -66,7 +67,13 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size= _t flash_size) ptr -=3D sizeof(uint16_t); tot_len =3D le16_to_cpu(*(uint16_t *)ptr) - sizeof(guid) - sizeof(uint= 16_t); =20 - if (tot_len <=3D 0) { + if (tot_len < 0 || tot_len > (ptr - flash_ptr)) { + error_report("OVMF table has invalid size %d", tot_len); + return; + } + + if (tot_len =3D=3D 0) { + /* no entries in the OVMF table */ return; } =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403352912825.4370061373979; Fri, 4 Mar 2022 06:15:52 -0800 (PST) Received: from localhost ([::1]:55770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8im-0002jq-5p for importer@patchew.org; Fri, 04 Mar 2022 09:15:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AF-0002aq-AX for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AD-0000pA-Qj for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:11 -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-92-ES0K21uRO2aTVimzzlo5nQ-1; Fri, 04 Mar 2022 08:40:08 -0500 Received: by mail-wm1-f71.google.com with SMTP id v125-20020a1cac83000000b0037e3d70e7e1so4172570wme.1 for ; Fri, 04 Mar 2022 05:40:07 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id v124-20020a1cac82000000b0037c3d08e0e7sm11749494wme.29.2022.03.04.05.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401208; 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=xIYTx9xMPVdCirDAB9Y8FCSD6kEXvGl7DGfbZeP6K2A=; b=LVNvZ1STfU2LAP9Lw4voBUV5KoOvQnNcOdj5rK5q/IdgVXidb7eletzb97jRofvD0nT7GG 0jSNkjef0t4FijpaIOINjziOk5Vf99lZr2Q5gqp6C7awOqV2OOJs4D/GFp11G2xuUYa395 xyofD/IBvUVhOEc4g3CM7VtVmQoD5Ak= X-MC-Unique: ES0K21uRO2aTVimzzlo5nQ-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=xIYTx9xMPVdCirDAB9Y8FCSD6kEXvGl7DGfbZeP6K2A=; b=vflyF6HuQp2IAK8ossmHs0Cim+tHb8suERscz6sE8e7tWWsBXpJtil9tOcXbS5kCQp WBgk6HmoT/ABQ6bPaBxX9spiNkRtEoALih1iTA9cPALFV7Y5uyqAxt7CCbAt6haN8S+q eqpWsWK9XacxAFUNFN/WmaEngk9HnLt1Fs4/AMJuYf0GwkQRt44Brp0qKZnyzv9Y7RA4 S1kCF8rKxSftWInSyQ5AFwvsz+FQzn35yvwHaTjbRh9g69rvZXc+itPgOvChCb2bqntr 3/1l9lKCNq7R/d7oD51+9mfzocNjq22qSgDBnCkFfYgqEuIuFFJt7P8IE0ONTZAqSmzg XOtw== X-Gm-Message-State: AOAM5335BLy1spptzWxtPeKiaDqzxaHz/JSjZLWza1EuWcds2OYEscDt klXDApTUt6RhzabWjWBTT6nJYTUrOTutCyvtGDqQ7V/6UPJm40qy0CeGqeRq3kA23lEs+w4SMkf /9BsbIqV58YwbvIawDTEJpvRXyWWgQDCWMqAPP1S9NfM9bzsSMgdqd9S6cx3p X-Received: by 2002:adf:fa48:0:b0:1f0:d71:f9a with SMTP id y8-20020adffa48000000b001f00d710f9amr12541233wrr.50.1646401206503; Fri, 04 Mar 2022 05:40:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJxu9V4c1xFsmpIACsTVMgvmDUeC9RZN4LNi5L98FJ0edM9zVEekf6LaEDW5RqsHGm440ZPDnA== X-Received: by 2002:adf:fa48:0:b0:1f0:d71:f9a with SMTP id y8-20020adffa48000000b001f00d710f9amr12541210wrr.50.1646401206212; Fri, 04 Mar 2022 05:40:06 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 21/45] hw/i386: Replace magic number with field length calculation Message-ID: <20220304133556.233983-22-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Daniel P =?utf-8?B?LiBCZXJyYW5nw6k=?= , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Dov Murik , Gerd Hoffmann , 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: 1646403354083100001 From: Dov Murik Replce the literal magic number 48 with length calculation (32 bytes at the end of the firmware after the table footer + 16 bytes of the OVMF table footer GUID). No functional change intended. Signed-off-by: Dov Murik Message-Id: <20220222071906.2632426-3-dovmurik@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Daniel P. Berrang=C3=A9 --- hw/i386/pc_sysfw_ovmf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc_sysfw_ovmf.c b/hw/i386/pc_sysfw_ovmf.c index df15c9737b..07a4c267fa 100644 --- a/hw/i386/pc_sysfw_ovmf.c +++ b/hw/i386/pc_sysfw_ovmf.c @@ -30,6 +30,8 @@ =20 #define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d" =20 +static const int bytes_after_table_footer =3D 32; + static bool ovmf_flash_parsed; static uint8_t *ovmf_table; static int ovmf_table_len; @@ -53,12 +55,13 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, siz= e_t flash_size) =20 /* * if this is OVMF there will be a table footer - * guid 48 bytes before the end of the flash file. If it's - * not found, silently abort the flash parsing. + * guid 48 bytes before the end of the flash file + * (=3D 32 bytes after the table + 16 bytes the GUID itself). + * If it's not found, silently abort the flash parsing. */ qemu_uuid_parse(OVMF_TABLE_FOOTER_GUID, &guid); guid =3D qemu_uuid_bswap(guid); /* guids are LE */ - ptr =3D flash_ptr + flash_size - 48; + ptr =3D flash_ptr + flash_size - (bytes_after_table_footer + sizeof(gu= id)); if (!qemu_uuid_is_equal((QemuUUID *)ptr, &guid)) { return; } --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403955491879.383044103088; Fri, 4 Mar 2022 06:25:55 -0800 (PST) Received: from localhost ([::1]:55276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8sU-00058p-2o for importer@patchew.org; Fri, 04 Mar 2022 09:25:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AM-0002gs-6C for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AK-0000q4-6g for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:17 -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-267-99UM-9KNPlulnWpbKaaZPg-1; Fri, 04 Mar 2022 08:40:14 -0500 Received: by mail-wr1-f72.google.com with SMTP id ay18-20020a5d6f12000000b001efe36eb038so3401233wrb.17 for ; Fri, 04 Mar 2022 05:40:14 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id u4-20020adfdb84000000b001e8d8ac5394sm5134678wri.110.2022.03.04.05.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401215; 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=AvJNwnWWD1CymBBhgu2K/AQWWIjBAXRCR+0fK9AzI+o=; b=cdkRmmXZoiocBO1anX8gvgYmCYrBHNIY11o9ZzwHpLPdDzpSilG0EHiWh7SGOZQrzzx0Jx cwmS/+UJ3qKSmslbxMGKfd35oxUGZ41WxQBVRL+2sF4BKK/8v5ruU0irqyJAaC3JW7vG7J IQc6xEoM1pqGPWsAjKRRj42CjiF49F8= X-MC-Unique: 99UM-9KNPlulnWpbKaaZPg-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=AvJNwnWWD1CymBBhgu2K/AQWWIjBAXRCR+0fK9AzI+o=; b=NaFbOazMTht9q5omsue66tL5j8iaGrURDAxbSkswOsVWSd8G6oun17xt1XbuejSPnb EJ7ERxOoNAZfZ/0UwyDkc/ycfn1c8P4m3ciBOjKdwLb4vLqQmkRNHHsK2YfXGEW5WxHh 6v8wqedeJgFOm5JXjOyezya5v9SHS6wbnd4FghOJkCf9x3tXqOdi+IyAhZBt7bf0Mm/u +Jm6xlnPR4calyHlb8PSnsZE0braLvRPAhv9LR7fYeYv4hJQwIg40xmU/HNKCiwiGFxR xYOXb3chEi1MqXFZPM5Gmz2U74qN6MxExg5qO+jD5pmd13DtAGhsWQFZT56N7ryzSRsV sHtg== X-Gm-Message-State: AOAM533zuT/pKPngm3HupkpXhHYvhB3QuyjxNzkF4GTp+zgW88qw09P0 qtKzphJJhQWbm9BBtiR1qrlUyh9CgLpiEWMD4q08C0UhUwK2pobBtI7houo7N626kjMCfgd0PHN J634DFwyKTqu0PpW/0YP8XStYQcRFeXY8eJbCwG1F45+oHqg8QZ4gSK5KH2CC X-Received: by 2002:a5d:6f0f:0:b0:1ef:f983:3887 with SMTP id ay15-20020a5d6f0f000000b001eff9833887mr15137664wrb.526.1646401212614; Fri, 04 Mar 2022 05:40:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJywKWW0xVJxWQpaWUjAeYZheFpTKFEKzhebsrMaCxFExIqNoVOPN2WnH0f0qzS4B7+BB+0ANQ== X-Received: by 2002:a5d:6f0f:0:b0:1ef:f983:3887 with SMTP id ay15-20020a5d6f0f000000b001eff9833887mr15137648wrb.526.1646401212342; Fri, 04 Mar 2022 05:40:12 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 22/45] virtio-iommu: Default to bypass during boot Message-ID: <20220304133556.233983-23-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Cornelia Huck , Eric Auger , Jean-Philippe Brucker 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: 1646403956742100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker Currently the virtio-iommu device must be programmed before it allows DMA from any PCI device. This can make the VM entirely unusable when a virtio-iommu driver isn't present, for example in a bootloader that loads the OS from storage. Similarly to the other vIOMMU implementations, default to DMA bypassing the IOMMU during boot. Add a "boot-bypass" property, defaulting to true, that lets users change this behavior. Replace the VIRTIO_IOMMU_F_BYPASS feature, which didn't support bypass before feature negotiation, with VIRTIO_IOMMU_F_BYPASS_CONFIG. We add the bypass field to the migration stream without introducing subsections, based on the assumption that this virtio-iommu device isn't being used in production enough to require cross-version migration at the moment (all previous version required workarounds since they didn't support ACPI and boot-bypass). Reviewed-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20220214124356.872985-3-jean-philippe@linaro.org> Acked-by: Cornelia Huck Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 60 +++++++++++++++++++++++++++----- hw/virtio/trace-events | 4 ++- 3 files changed, 56 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-io= mmu.h index e2339e5b72..84391f8448 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -58,6 +58,7 @@ struct VirtIOIOMMU { GTree *domains; QemuMutex mutex; GTree *endpoints; + bool boot_bypass; }; =20 #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index aa9c16a17b..4ca36db4ac 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -24,6 +24,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" +#include "sysemu/reset.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "trace.h" @@ -728,8 +729,7 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemory= Region *mr, hwaddr addr, .perm =3D IOMMU_NONE, }; =20 - bypass_allowed =3D virtio_vdev_has_feature(&s->parent_obj, - VIRTIO_IOMMU_F_BYPASS); + bypass_allowed =3D s->config.bypass; =20 sid =3D virtio_iommu_get_bdf(sdev); =20 @@ -831,13 +831,37 @@ static void virtio_iommu_get_config(VirtIODevice *vde= v, uint8_t *config_data) out_config->domain_range.start =3D cpu_to_le32(dev_config->domain_rang= e.start); out_config->domain_range.end =3D cpu_to_le32(dev_config->domain_range.= end); out_config->probe_size =3D cpu_to_le32(dev_config->probe_size); + out_config->bypass =3D dev_config->bypass; =20 trace_virtio_iommu_get_config(dev_config->page_size_mask, dev_config->input_range.start, dev_config->input_range.end, dev_config->domain_range.start, dev_config->domain_range.end, - dev_config->probe_size); + dev_config->probe_size, + dev_config->bypass); +} + +static void virtio_iommu_set_config(VirtIODevice *vdev, + const uint8_t *config_data) +{ + VirtIOIOMMU *dev =3D VIRTIO_IOMMU(vdev); + struct virtio_iommu_config *dev_config =3D &dev->config; + const struct virtio_iommu_config *in_config =3D (void *)config_data; + + if (in_config->bypass !=3D dev_config->bypass) { + if (!virtio_vdev_has_feature(vdev, VIRTIO_IOMMU_F_BYPASS_CONFIG)) { + virtio_error(vdev, "cannot set config.bypass"); + return; + } else if (in_config->bypass !=3D 0 && in_config->bypass !=3D 1) { + virtio_error(vdev, "invalid config.bypass value '%u'", + in_config->bypass); + return; + } + dev_config->bypass =3D in_config->bypass; + } + + trace_virtio_iommu_set_config(in_config->bypass); } =20 static uint64_t virtio_iommu_get_features(VirtIODevice *vdev, uint64_t f, @@ -963,6 +987,19 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemory= Region *mr, return 0; } =20 +static void virtio_iommu_system_reset(void *opaque) +{ + VirtIOIOMMU *s =3D opaque; + + trace_virtio_iommu_system_reset(); + + /* + * config.bypass is sticky across device reset, but should be restored= on + * system reset + */ + s->config.bypass =3D s->boot_bypass; +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -988,9 +1025,9 @@ static void virtio_iommu_device_realize(DeviceState *d= ev, Error **errp) virtio_add_feature(&s->features, VIRTIO_IOMMU_F_INPUT_RANGE); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_DOMAIN_RANGE); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MAP_UNMAP); - virtio_add_feature(&s->features, VIRTIO_IOMMU_F_BYPASS); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_MMIO); virtio_add_feature(&s->features, VIRTIO_IOMMU_F_PROBE); + virtio_add_feature(&s->features, VIRTIO_IOMMU_F_BYPASS_CONFIG); =20 qemu_mutex_init(&s->mutex); =20 @@ -1001,6 +1038,8 @@ static void virtio_iommu_device_realize(DeviceState *= dev, Error **errp) } else { error_setg(errp, "VIRTIO-IOMMU is not attached to any PCI bus!"); } + + qemu_register_reset(virtio_iommu_system_reset, s); } =20 static void virtio_iommu_device_unrealize(DeviceState *dev) @@ -1008,6 +1047,8 @@ static void virtio_iommu_device_unrealize(DeviceState= *dev) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOIOMMU *s =3D VIRTIO_IOMMU(dev); =20 + qemu_unregister_reset(virtio_iommu_system_reset, s); + g_hash_table_destroy(s->as_by_busptr); if (s->domains) { g_tree_destroy(s->domains); @@ -1141,21 +1182,22 @@ static int iommu_post_load(void *opaque, int versio= n_id) =20 static const VMStateDescription vmstate_virtio_iommu_device =3D { .name =3D "virtio-iommu-device", - .minimum_version_id =3D 1, - .version_id =3D 1, + .minimum_version_id =3D 2, + .version_id =3D 2, .post_load =3D iommu_post_load, .fields =3D (VMStateField[]) { VMSTATE_GTREE_DIRECT_KEY_V(domains, VirtIOIOMMU, 1, &vmstate_domain, VirtIOIOMMUDomain), + VMSTATE_UINT8_V(config.bypass, VirtIOIOMMU, 2), VMSTATE_END_OF_LIST() }, }; =20 static const VMStateDescription vmstate_virtio_iommu =3D { .name =3D "virtio-iommu", - .minimum_version_id =3D 1, + .minimum_version_id =3D 2, .priority =3D MIG_PRI_IOMMU, - .version_id =3D 1, + .version_id =3D 2, .fields =3D (VMStateField[]) { VMSTATE_VIRTIO_DEVICE, VMSTATE_END_OF_LIST() @@ -1164,6 +1206,7 @@ static const VMStateDescription vmstate_virtio_iommu = =3D { =20 static Property virtio_iommu_properties[] =3D { DEFINE_PROP_LINK("primary-bus", VirtIOIOMMU, primary_bus, "PCI", PCIBu= s *), + DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -1180,6 +1223,7 @@ static void virtio_iommu_class_init(ObjectClass *klas= s, void *data) vdc->unrealize =3D virtio_iommu_device_unrealize; vdc->reset =3D virtio_iommu_device_reset; vdc->get_config =3D virtio_iommu_get_config; + vdc->set_config =3D virtio_iommu_set_config; vdc->get_features =3D virtio_iommu_get_features; vdc->set_status =3D virtio_iommu_set_status; vdc->vmsd =3D &vmstate_virtio_iommu_device; diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index f7ad6be5fb..a5102eac9e 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -89,9 +89,11 @@ virtio_mmio_setting_irq(int level) "virtio_mmio setting = IRQ %d" =20 # virtio-iommu.c virtio_iommu_device_reset(void) "reset!" +virtio_iommu_system_reset(void) "system reset!" virtio_iommu_get_features(uint64_t features) "device supports features=3D0= x%"PRIx64 virtio_iommu_device_status(uint8_t status) "driver status =3D %d" -virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_start, uint32_t domain_end, uint32_t probe_size) "page= _size_mask=3D0x%"PRIx64" input range start=3D0x%"PRIx64" input range end=3D= 0x%"PRIx64" domain range start=3D%d domain range end=3D%d probe_size=3D0x%x" +virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_start, uint32_t domain_end, uint32_t probe_size, uint8= _t bypass) "page_size_mask=3D0x%"PRIx64" input range start=3D0x%"PRIx64" in= put range end=3D0x%"PRIx64" domain range start=3D%d domain range end=3D%d p= robe_size=3D0x%x bypass=3D0x%x" +virtio_iommu_set_config(uint8_t bypass) "bypass=3D0x%x" virtio_iommu_attach(uint32_t domain_id, uint32_t ep_id) "domain=3D%d endpo= int=3D%d" virtio_iommu_detach(uint32_t domain_id, uint32_t ep_id) "domain=3D%d endpo= int=3D%d" virtio_iommu_map(uint32_t domain_id, uint64_t virt_start, uint64_t virt_en= d, uint64_t phys_start, uint32_t flags) "domain=3D%d virt_start=3D0x%"PRIx6= 4" virt_end=3D0x%"PRIx64 " phys_start=3D0x%"PRIx64" flags=3D%d" --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403499406114.17375744114929; Fri, 4 Mar 2022 06:18:19 -0800 (PST) Received: from localhost ([::1]:34968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8l8-0007yV-3r for importer@patchew.org; Fri, 04 Mar 2022 09:18:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AQ-0002lD-77 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39965) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AO-0000rO-EC for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:21 -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-641-ySDVolVUOjKLng1n6Faycg-1; Fri, 04 Mar 2022 08:40:19 -0500 Received: by mail-wm1-f69.google.com with SMTP id o207-20020a1ca5d8000000b0038977354e75so803002wme.1 for ; Fri, 04 Mar 2022 05:40:18 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id r1-20020a5d4941000000b001ed89dcacbbsm4598790wrs.23.2022.03.04.05.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401219; 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=JMuvtu5n6lVU0KTov6tttqgUMeVGZs5d6LsC2M1zLP4=; b=EavHM9Ty3hdmkRuT8a6z5d6mxPhD4GdrY0l3543qJiD6cAHUb8tQfnGGMVyr4YCoaHAJdr HWiCQOQ+nN71QvDma7/ZyVCo5HRLrbvLe/gWCUKUus5ucHh7f/FCYWDEIFZEKASsu+Bu61 GxwbGCwYLszipWV3STRT5rBx0+XKLy0= X-MC-Unique: ySDVolVUOjKLng1n6Faycg-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=JMuvtu5n6lVU0KTov6tttqgUMeVGZs5d6LsC2M1zLP4=; b=5scSBoKAeWx2/XRbAXUOhokxq+x1ztDVu8AtrERf3ED1Hj2VhOtozIMwLiq5P2wXCY BoVUsJwvsT6znBPBJUBYX85m6m4u3GilDIzkAcqiUDfN4lpuK/9RmL4OBn+Gh3DrBVRx 5pMXi0HgPMsMa0ADKLMCicBaLOM06Jrw/0QbybmqhFBLZ4vrrdxiQCzts4rD5VfFK5EF RwNppKgLiQDfd10ZzFmgU2dsYVuGgI7UJT1JOseAhTEdrFgYjtiWgJwS6bbh7OmfbO/c Qa8PiBwp9rRlWhMRLhFvi3Ybm3YR5WXRlY6D6Vnh8FmnwqkJGnB8hK2YXFjW4fjWvPou RdLw== X-Gm-Message-State: AOAM5333Xi/SYEPMreJydR6hYYs4rIXwdDzUtSftvGvHwpUb876NHn/V RNsBTwvQGcwMYjQLvZwj/67ew57M6iNFX6+YgCMGq9PD6NoOltYM+nJZsRxkbeLNAWq0dFHeJQz z2Y33WRLUnTyiPa5T7OlGuk9Cl5N4f8wp8UDngn+Ld0UaI2EoILKE2o+dqrlG X-Received: by 2002:adf:dcc2:0:b0:1f0:4c38:d6be with SMTP id x2-20020adfdcc2000000b001f04c38d6bemr6312408wrm.79.1646401217217; Fri, 04 Mar 2022 05:40:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyia2OmWpG9F9/9geucx930yD5x93em/O8xL5P332HKB8quo8c6zdpcQHND9qGhyAgzXiqUbw== X-Received: by 2002:adf:dcc2:0:b0:1f0:4c38:d6be with SMTP id x2-20020adfdcc2000000b001f04c38d6bemr6312387wrm.79.1646401216913; Fri, 04 Mar 2022 05:40:16 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 23/45] virtio-iommu: Support bypass domain Message-ID: <20220304133556.233983-24-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Cornelia Huck , Eric Auger , Jean-Philippe Brucker 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: 1646403500422100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker The driver can create a bypass domain by passing the VIRTIO_IOMMU_ATTACH_F_BYPASS flag on the ATTACH request. Bypass domains perform slightly better than domains with identity mappings since they skip translation. Signed-off-by: Jean-Philippe Brucker Message-Id: <20220214124356.872985-4-jean-philippe@linaro.org> Acked-by: Cornelia Huck Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4ca36db4ac..239fe97b12 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -43,6 +43,7 @@ =20 typedef struct VirtIOIOMMUDomain { uint32_t id; + bool bypass; GTree *mappings; QLIST_HEAD(, VirtIOIOMMUEndpoint) endpoint_list; } VirtIOIOMMUDomain; @@ -258,12 +259,16 @@ static void virtio_iommu_put_endpoint(gpointer data) } =20 static VirtIOIOMMUDomain *virtio_iommu_get_domain(VirtIOIOMMU *s, - uint32_t domain_id) + uint32_t domain_id, + bool bypass) { VirtIOIOMMUDomain *domain; =20 domain =3D g_tree_lookup(s->domains, GUINT_TO_POINTER(domain_id)); if (domain) { + if (domain->bypass !=3D bypass) { + return NULL; + } return domain; } domain =3D g_malloc0(sizeof(*domain)); @@ -271,6 +276,7 @@ static VirtIOIOMMUDomain *virtio_iommu_get_domain(VirtI= OIOMMU *s, domain->mappings =3D g_tree_new_full((GCompareDataFunc)interval_cmp, NULL, (GDestroyNotify)g_free, (GDestroyNotify)g_free); + domain->bypass =3D bypass; g_tree_insert(s->domains, GUINT_TO_POINTER(domain_id), domain); QLIST_INIT(&domain->endpoint_list); trace_virtio_iommu_get_domain(domain_id); @@ -334,11 +340,16 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, { uint32_t domain_id =3D le32_to_cpu(req->domain); uint32_t ep_id =3D le32_to_cpu(req->endpoint); + uint32_t flags =3D le32_to_cpu(req->flags); VirtIOIOMMUDomain *domain; VirtIOIOMMUEndpoint *ep; =20 trace_virtio_iommu_attach(domain_id, ep_id); =20 + if (flags & ~VIRTIO_IOMMU_ATTACH_F_BYPASS) { + return VIRTIO_IOMMU_S_INVAL; + } + ep =3D virtio_iommu_get_endpoint(s, ep_id); if (!ep) { return VIRTIO_IOMMU_S_NOENT; @@ -356,7 +367,12 @@ static int virtio_iommu_attach(VirtIOIOMMU *s, } } =20 - domain =3D virtio_iommu_get_domain(s, domain_id); + domain =3D virtio_iommu_get_domain(s, domain_id, + flags & VIRTIO_IOMMU_ATTACH_F_BYPASS); + if (!domain) { + /* Incompatible bypass flag */ + return VIRTIO_IOMMU_S_INVAL; + } QLIST_INSERT_HEAD(&domain->endpoint_list, ep, next); =20 ep->domain =3D domain; @@ -419,6 +435,10 @@ static int virtio_iommu_map(VirtIOIOMMU *s, return VIRTIO_IOMMU_S_NOENT; } =20 + if (domain->bypass) { + return VIRTIO_IOMMU_S_INVAL; + } + interval =3D g_malloc0(sizeof(*interval)); =20 interval->low =3D virt_start; @@ -464,6 +484,11 @@ static int virtio_iommu_unmap(VirtIOIOMMU *s, if (!domain) { return VIRTIO_IOMMU_S_NOENT; } + + if (domain->bypass) { + return VIRTIO_IOMMU_S_INVAL; + } + interval.low =3D virt_start; interval.high =3D virt_end; =20 @@ -780,6 +805,9 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemory= Region *mr, hwaddr addr, entry.perm =3D flag; } goto unlock; + } else if (ep->domain->bypass) { + entry.perm =3D flag; + goto unlock; } =20 found =3D g_tree_lookup_extended(ep->domain->mappings, (gpointer)(&int= erval), @@ -1139,8 +1167,8 @@ static const VMStateDescription vmstate_endpoint =3D { =20 static const VMStateDescription vmstate_domain =3D { .name =3D "domain", - .version_id =3D 1, - .minimum_version_id =3D 1, + .version_id =3D 2, + .minimum_version_id =3D 2, .pre_load =3D domain_preload, .fields =3D (VMStateField[]) { VMSTATE_UINT32(id, VirtIOIOMMUDomain), @@ -1149,6 +1177,7 @@ static const VMStateDescription vmstate_domain =3D { VirtIOIOMMUInterval, VirtIOIOMMUMapping), VMSTATE_QLIST_V(endpoint_list, VirtIOIOMMUDomain, 1, vmstate_endpoint, VirtIOIOMMUEndpoint, next), + VMSTATE_BOOL_V(bypass, VirtIOIOMMUDomain, 2), VMSTATE_END_OF_LIST() } }; @@ -1186,7 +1215,7 @@ static const VMStateDescription vmstate_virtio_iommu_= device =3D { .version_id =3D 2, .post_load =3D iommu_post_load, .fields =3D (VMStateField[]) { - VMSTATE_GTREE_DIRECT_KEY_V(domains, VirtIOIOMMU, 1, + VMSTATE_GTREE_DIRECT_KEY_V(domains, VirtIOIOMMU, 2, &vmstate_domain, VirtIOIOMMUDomain), VMSTATE_UINT8_V(config.bypass, VirtIOIOMMU, 2), VMSTATE_END_OF_LIST() --=20 MST From nobody Tue May 14 12:10:45 2024 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 164640368723080.32341162500222; Fri, 4 Mar 2022 06:21:27 -0800 (PST) Received: from localhost ([::1]:43516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8o9-0005V5-V6 for importer@patchew.org; Fri, 04 Mar 2022 09:21:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AX-0002sm-S6 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8AW-0000vj-9F for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:29 -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-424-bGopWifKNZKn-Inm9pKhqQ-1; Fri, 04 Mar 2022 08:40:26 -0500 Received: by mail-wr1-f70.google.com with SMTP id z16-20020adff1d0000000b001ef7dc78b23so3371545wro.12 for ; Fri, 04 Mar 2022 05:40:26 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id s17-20020adfbc11000000b001f023d197b8sm4614847wrg.68.2022.03.04.05.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401227; 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=wqPGtWFCVDPRGhVgRp/c/kDyoLIXiZZqdrhcBaAKsjU=; b=JT+J2VJZxIsYuaooEigUjycdSWnbOwMzOF57Pdx2da1ZzjWu2Ue6+9pWSfXGXeTUuVe6wy sHl6qyd80vVmTN1d+8nSvx9jwevhv6w4oFbzkpJ8LwA8nIbZj6nS5zVKQaKOGzBBV/Y4Pi ij+JZ50QXzl7aLySRaw41zAfk7E0r10= X-MC-Unique: bGopWifKNZKn-Inm9pKhqQ-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=wqPGtWFCVDPRGhVgRp/c/kDyoLIXiZZqdrhcBaAKsjU=; b=ibd19zB4/iwjnc2HGl2i/LnqULBA39VtdNJPO4cJeeuUyC0oQ/Oh7WSVMCWEp2kWQB H0ad/Q2LUZd46UpG83OycLzuebv7UTKHWpJlEN25OyAnb6mjmJIBgqKApFIKiSOHHWAh jqZrrYLrp5cGUGt2Fi33psUYQLl/JcvjAXT+OBzvxZsX//zS4iIyKW4MI9MON+NY6jh1 OwwefgiiVKM4Vv8DH6qCY674G2FMMSVbcNeJ3FpgqrH1K3Vq6hET6rhwslP8o1IM/vm3 EIfz6VflsHOJLjNQpZfgXn4vHtg2ZD+M3RyNq46X7BoVFIVga25VMU9zJAOD2sq5sd9Y ylbQ== X-Gm-Message-State: AOAM533MUouvc08ezDH+RAf4CTGVCt8H5fW9KMsBe0+Gk5ukQnlyFWpj e0iRZP00HZ02xuIwH9sxdEfK6Bab7/6K1jjvTF9Jadw0IdOFSzMu4gF9M6miC8K0SjedwT+q2xA 6kyDnG0No13rJZLlREH/4enJOG/HBXznfijxB2Yoto8Kv8AV2zNL+yhCjiGRq X-Received: by 2002:a5d:6d8e:0:b0:1f0:3594:c3e with SMTP id l14-20020a5d6d8e000000b001f035940c3emr9401239wrs.44.1646401225238; Fri, 04 Mar 2022 05:40:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6xoWAtNCxVRPx4XYKP2blsCaZb1H27Us8mPQEDtdeUN0PVQ8WTShLTIk6qQ2nT2ZT19USGw== X-Received: by 2002:a5d:6d8e:0:b0:1f0:3594:c3e with SMTP id l14-20020a5d6d8e000000b001f035940c3emr9401219wrs.44.1646401225013; Fri, 04 Mar 2022 05:40:25 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 24/45] tests/qtest/virtio-iommu-test: Check bypass config Message-ID: <20220304133556.233983-25-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Jean-Philippe Brucker , Cornelia Huck , Eric Auger , 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: 1646403687813100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jean-Philippe Brucker The bypass config field should be initialized to 1 by default. Reviewed-by: Eric Auger Signed-off-by: Jean-Philippe Brucker Message-Id: <20220214124356.872985-5-jean-philippe@linaro.org> Acked-by: Cornelia Huck Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Thomas Huth --- tests/qtest/virtio-iommu-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/qtest/virtio-iommu-test.c b/tests/qtest/virtio-iommu-tes= t.c index 47e68388a0..068e7a9e6c 100644 --- a/tests/qtest/virtio-iommu-test.c +++ b/tests/qtest/virtio-iommu-test.c @@ -31,11 +31,13 @@ static void pci_config(void *obj, void *data, QGuestAll= ocator *t_alloc) uint64_t input_range_end =3D qvirtio_config_readq(dev, 16); uint32_t domain_range_start =3D qvirtio_config_readl(dev, 24); uint32_t domain_range_end =3D qvirtio_config_readl(dev, 28); + uint8_t bypass =3D qvirtio_config_readb(dev, 36); =20 g_assert_cmpint(input_range_start, =3D=3D, 0); g_assert_cmphex(input_range_end, =3D=3D, UINT64_MAX); g_assert_cmpint(domain_range_start, =3D=3D, 0); g_assert_cmpint(domain_range_end, =3D=3D, UINT32_MAX); + g_assert_cmpint(bypass, =3D=3D, 1); } =20 static int read_tail_status(struct virtio_iommu_req_tail *buffer) --=20 MST From nobody Tue May 14 12:10:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646401253; cv=none; d=zohomail.com; s=zohoarc; b=XMNi4sv2+QvjodWmEWIQjBZMKUdwqY5/qyw6zPvp5APsVYGw8sbPDY3usATOYWSCzlZGLijms5oOzxRJJoC6AhkR+9+pCh/J/4jdZiWkyzDa4+hpm6fvaWPOWuwy8J9fsuVS5wsTizY/UyzmDj58l2ZVIrD5iQhbCkvXNV9k//s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646401253; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ezHczUZNer51n68XHQRo+8Gd2wahCXeNyLSEi3/WKiI=; b=OcjjB+tW0XEj/PEqmFt+Y6n2UdD1J9lRdcb0nuVnOfquPXDvhV7keMwKDvBty/XPcnAOSWFkfVBbm8M5GJrlz/rhA304wekUoWKLu2NBNUW0cmpBW6BM7rw7sGb0jxV9e+nvAFaGxPoIWkP0B5kPQNfUtIl+9nM/8NNIUKLuJaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646401253260377.96186434053595; Fri, 4 Mar 2022 05:40:53 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-rJlrlQrFP9-MiCbgTo2J0A-1; Fri, 04 Mar 2022 08:40:49 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA7521006AA5; Fri, 4 Mar 2022 13:40:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 024A97BE5B; Fri, 4 Mar 2022 13:40:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7863A4ED66; Fri, 4 Mar 2022 13:40:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 224Dea52005143 for ; Fri, 4 Mar 2022 08:40:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id D9F614021D8; Fri, 4 Mar 2022 13:40:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D62FA40146E for ; Fri, 4 Mar 2022 13:40:36 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BBF4885A5BC for ; Fri, 4 Mar 2022 13:40:36 +0000 (UTC) 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-264-Hst10ePcMZuMeuBhzlzRQw-1; Fri, 04 Mar 2022 08:40:35 -0500 Received: by mail-wr1-f69.google.com with SMTP id p9-20020adf9589000000b001e333885ac1so3367613wrp.10 for ; Fri, 04 Mar 2022 05:40:33 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id u23-20020a7bcb17000000b0037bdfa1665asm15841152wmj.18.2022.03.04.05.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401252; h=from:from:sender:sender: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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=ezHczUZNer51n68XHQRo+8Gd2wahCXeNyLSEi3/WKiI=; b=HmdMi1zdQ4u6yGSDokASWue3vwh6Pav3sdlA9kTtMEAe6D4wpJEKcIUXNGKB2c90AfLFir YL3kYM9aVCFZqo0adPQGPOsbTmWkoqLXIabH4zkBQmyi7mVyKbocvtOr7t7/DyiKFh/Qzf FdnDp6RiD4OW4YRzzSKgdp5HWWf8Kt4= X-MC-Unique: rJlrlQrFP9-MiCbgTo2J0A-1 X-MC-Unique: Hst10ePcMZuMeuBhzlzRQw-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=ezHczUZNer51n68XHQRo+8Gd2wahCXeNyLSEi3/WKiI=; b=ujzf0+93T3KVixzdgyNgFGI1dg0d8GReyfaf8u56pylPWJXt/KCQsgFCFYHCn6wr+Y dm66UWorSOrjd3Gt2k2mHogUn59Qkg/z867fj6On2akOcbTvy3b0hamunbxYQMB47buK HqVDmvwY+A40+3xWkR1PTyP8nFK6ehoW7Tz7lcCVFD4xbUOOmXGsh3u4OEa+ggMl/xLV 34uN1VTj0I9z0l5krgyQJYvAMTwSqaPphMQzN7ketiaH5nJDTrcf+u87t5esEI90jcIO d64spG1xpy/8/E1giOLnf/6MTra6aM5tmKhvALXdWTP4GgB3FbcuBgJTShPHgM2GHG7w gSSw== X-Gm-Message-State: AOAM533dU8FrzTJzzdYUcKO5IhZu8BiKjJo5F6d/SnL1q1j9iSgaDAR0 /ki+rqgJvBj/GMQMRRxi6nCLKVxLAvqZT49jUSIfg/QaE8SON2Z3xhNLTgYzdDKyfAvVq/ZF94K 5TS0V8GV7XlUhCHCUPOk= X-Received: by 2002:a05:6000:1c15:b0:1f0:216:1c64 with SMTP id ba21-20020a0560001c1500b001f002161c64mr13327683wrb.366.1646401232495; Fri, 04 Mar 2022 05:40:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjeRfVv5vOPzuKRgxfRbOYtwQeWF5F+R0PTcXGwzFOELMNOHnpzJcXRuPaKtcVm29wobGO6w== X-Received: by 2002:a05:6000:1c15:b0:1f0:216:1c64 with SMTP id ba21-20020a0560001c1500b001f002161c64mr13327668wrb.366.1646401232286; Fri, 04 Mar 2022 05:40:32 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 25/45] hw/i386/pc_piix: Mark the machine types from version 1.4 to 1.7 as deprecated Message-ID: <20220304133556.233983-26-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-1-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-loop: libvir-list@redhat.com Cc: Eduardo Habkost , Peter Maydell , Thomas Huth , libvir-list@redhat.com, Richard Henderson , Marcel Apfelbaum , Paolo Bonzini X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646401255450100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Thomas Huth The list of machine types grows larger and larger each release ... and it is unlikely that many people still use the very old ones for live migration. QEMU v1.7 has been released more than 8 years ago, so most people should have updated their machines to a newer version in those 8 years at least once. Thus let's mark the very old 1.x machine types as deprecated now. Signed-off-by: Thomas Huth Message-Id: <20220117191639.278497-1-thuth@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 1 + docs/about/deprecated.rst | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 8d33cf689d..b72c03d0a6 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -757,6 +757,7 @@ static void pc_i440fx_1_7_machine_options(MachineClass = *m) m->hw_version =3D "1.7.0"; m->default_machine_opts =3D NULL; m->option_rom_has_mr =3D true; + m->deprecation_reason =3D "old and unattended - use a newer version in= stead"; compat_props_add(m->compat_props, pc_compat_1_7, pc_compat_1_7_len); pcmc->smbios_defaults =3D false; pcmc->gigabyte_align =3D false; diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 85773db631..cf02ef6821 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -324,6 +324,14 @@ machine is hardly emulated at all (e.g. neither the LC= D nor the USB part had been implemented), so there is not much value added by this board. Use the ``ref405ep`` machine instead. =20 +``pc-i440fx-1.4`` up to ``pc-i440fx-1.7`` (since 7.0) +''''''''''''''''''''''''''''''''''''''''''''''''''''' + +These old machine types are quite neglected nowadays and thus might have +various pitfalls with regards to live migration. Use a newer machine type +instead. + + Backend options --------------- =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404103314631.1445950384277; Fri, 4 Mar 2022 06:28:23 -0800 (PST) Received: from localhost ([::1]:35658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8us-0002iS-9L for importer@patchew.org; Fri, 04 Mar 2022 09:28:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Am-00036z-4J for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29079) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Aj-00012y-HF for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:43 -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-672-IVlmFqPINoy_Q0PpSkmZvg-1; Fri, 04 Mar 2022 08:40:39 -0500 Received: by mail-wm1-f69.google.com with SMTP id 26-20020a05600c22da00b00388307f3503so1070396wmg.1 for ; Fri, 04 Mar 2022 05:40:39 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id r188-20020a1c2bc5000000b00387c81c32e7sm5253444wmr.8.2022.03.04.05.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401240; 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=gahauiWtzKVRJbmFnIa2BytU7N4O8wddJUnc6uKh6Qk=; b=axVKmAazC4Qf3K1NDgKyKYmWbA7Z9werA+dAYUdMMARPUKkAC5OatY9yGl1FYWrei2P/4J g8XjhLc22R/bm2YaYlOtmzYbM6X23O42w/dkYsxtAOohpKrlU/wJmmRnyCjXD12+foEi+d H10nHGQhyoT4vgwVK6UGpyB2IEysHBk= X-MC-Unique: IVlmFqPINoy_Q0PpSkmZvg-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=gahauiWtzKVRJbmFnIa2BytU7N4O8wddJUnc6uKh6Qk=; b=ZjPozgaL+jE2FRTnQZbgu17Rlxr9cw7lsdwf9EmBoqI5R1DUx9VxccTev5dm5RNuxA GYmNGR1ZYOWGyd7Ljn6nN7jWuQw1O33pZzc0JdbX3wTICHCSzwFKa7lFFDRuG5Io6Ify b22Vz8bzkYhIh+MtSFQszpRRO0dHU854yq9GynmbcaL1mdCl8HX1c05U6C1muJiRKseC vhXl2aBU1JgBXEJFnS4loWY8VyktrehRdj05UaAjDdN1kVhm8yJ3Ym/gCfYw03esihdx XBA6FaQcKxKHZ0xeOxlJeZKLqAirft/DcKaXnZfsgrFh4XiZYQ7H7aKJKGIj+ZWSIQWR WTtw== X-Gm-Message-State: AOAM531tVutjf77q8orTsklmEcuVX1bSQV6svV2sHNkogRLhu8YAWmDz H77icGoAHwdS5ypTx2OCAMOa8rVP4Dm/t7dj8KZxMs+h5j3VVEA3wez1JBExDt8RmbaSJzWvRbi zv8/Jo3rwZu/dEhjEycGx/BuRxybTCCG2zbu7St7f10k+cwLoxEBOE6lEl/a/ X-Received: by 2002:a7b:c30a:0:b0:389:81d2:b608 with SMTP id k10-20020a7bc30a000000b0038981d2b608mr2163025wmj.147.1646401237813; Fri, 04 Mar 2022 05:40:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPk3HtNixyricsg5hk7oqAP6aBlo9zbet9pTI/uLx8DWCXc/DmyNPhr4BF1e4g02dMFQT4gA== X-Received: by 2002:a7b:c30a:0:b0:389:81d2:b608 with SMTP id k10-20020a7bc30a000000b0038981d2b608mr2163005wmj.147.1646401237506; Fri, 04 Mar 2022 05:40:37 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 26/45] hw/pci-bridge/pxb: Fix missing swizzle Message-ID: <20220304133556.233983-27-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Jonathan Cameron 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: 1646404104234100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron pxb_map_irq_fn() handled the necessary removal of the swizzle applied to the PXB interrupts by the bus to which it was attached but neglected to apply the normal swizzle for PCI root ports on the expander bridge. Result of this was on ARM virt, the PME interrupts for a second RP on a PXB instance were miss-routed to #45 rather than #46. Tested with a selection of different configurations with 1 to 5 RP per PXB instance. Note on my x86 test setup the PME interrupts are not triggered so I haven't been able to test this. Signed-off-by: Jonathan Cameron Cc: Michael S. Tsirkin Cc: Marcel Apfelbaum Message-Id: <20220118174855.19325-1-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/pci_expander_bridge.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index 10e6e7c2ab..de932286b5 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -192,6 +192,12 @@ static int pxb_map_irq_fn(PCIDevice *pci_dev, int pin) { PCIDevice *pxb =3D pci_get_bus(pci_dev)->parent_dev; =20 + /* + * First carry out normal swizzle to handle + * multple root ports on a pxb instance. + */ + pin =3D pci_swizzle_map_irq_fn(pci_dev, pin); + /* * The bios does not index the pxb slot number when * it computes the IRQ because it resides on bus 0 --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403525036868.2608012470907; Fri, 4 Mar 2022 06:18:45 -0800 (PST) Received: from localhost ([::1]:36006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8lY-0000NS-5k for importer@patchew.org; Fri, 04 Mar 2022 09:18:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Ar-0003Ai-Uh for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Ao-000154-Mo for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:48 -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-332-zewQfvQFNH2SJKR8tKsSPw-1; Fri, 04 Mar 2022 08:40:44 -0500 Received: by mail-wr1-f70.google.com with SMTP id g17-20020adfa591000000b001da86c91c22so3388510wrc.5 for ; Fri, 04 Mar 2022 05:40:44 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id k13-20020a7bc40d000000b00381890032dfsm10723896wmi.1.2022.03.04.05.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401245; 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=SoEIyJ3M3ZHGIXoolRVwuQOGPFG25A4XAUBq+1r+Ueo=; b=JWDPTGuOHVc2mtQ9NYUd1vY7k704CMQqYuh31sfjtIUdiJUR9S0GidHrsacL5vtb0A0G5v 437VnkJMYIgAIcO/rYlYoXGpam6aTDgmHEiO9QptnDxwLd4KahoRbxJQxBaHPmiwMMhK9I UYFzuMbQ/KuCZz5mBunTioALLeo4vL0= X-MC-Unique: zewQfvQFNH2SJKR8tKsSPw-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=SoEIyJ3M3ZHGIXoolRVwuQOGPFG25A4XAUBq+1r+Ueo=; b=zYaFX5GgsSs5wVXKDE2ByDZno9cQzM9RoRWpEBtudxZoNZcHVBK7QFVqbSw5YTtI7v PEvPrlO3XmG9/S/+A/7eED9/Hc48vZajuXeInO0KCTY/FR6AwyMMKI9varwVknTwLC90 PtKzsvMo+zOJN8L3fvzlVU5hqshFqVRMvw8VEYGrW7WGXOagluXz2qMb4XR80GTqmE5S 3Rg/Yq5E1LAkIBDzuKCc5W/dEHJ31gJlQIp0/FVnckpcQGlP6L4IqQSO8q0DPY8A0c9F dW0fkFRGiHEWsmiG/Wvj9+36hDueer+cZapkYqPHwaox6TBjNSm8ArvGLkDZJIGcPM9v GrAw== X-Gm-Message-State: AOAM533N16LOk19UhQNdjV4EKCrPrxOFAEMqCtVcEBW4DGroAU2KDoPG wxSewPYv+qfDbjnEjkBrVkMwAHyq5gCnZqVFdjCIsNGO/G4msHbitWiFPILRTRByuHEplyV5oM8 U9rJgbamzKLZVXbxohX9ddzRJOKupVitcCyFlyf0Sa0Lq0hD5zbpWGN4BEaPJ X-Received: by 2002:a05:6000:1a85:b0:1f0:61dc:83e0 with SMTP id f5-20020a0560001a8500b001f061dc83e0mr5131322wry.409.1646401243205; Fri, 04 Mar 2022 05:40:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9KIsEg59Qs5cmyCLaL9AZOiazwepWfOQoW8KO7QGnVIldG5Y7ycUjqzMPJ9PH0YCtikW/Ug== X-Received: by 2002:a05:6000:1a85:b0:1f0:61dc:83e0 with SMTP id f5-20020a0560001a8500b001f061dc83e0mr5131306wry.409.1646401242966; Fri, 04 Mar 2022 05:40:42 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 27/45] virtio-net: Unlimit tx queue size if peer is vdpa Message-ID: <20220304133556.233983-28-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Jason Wang , Eugenio =?utf-8?B?UMOpcmV6?= 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: 1646403526347100003 From: Eugenio P=C3=A9rez The code used to limit the maximum size of tx queue for others backends than vhost_user since the introduction of configurable tx queue size in 9b02e1618cf2 ("virtio-net: enable configurable tx queue size"). As vhost_user, vhost_vdpa devices should deal with memory region crosses already, so let's use the full tx size. Signed-off-by: Eugenio P=C3=A9rez Message-Id: <20220217175029.2517071-1-eperezma@redhat.com> Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index cf8ab0f8af..b02a0632df 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -628,17 +628,20 @@ static int virtio_net_max_tx_queue_size(VirtIONet *n) NetClientState *peer =3D n->nic_conf.peers.ncs[0]; =20 /* - * Backends other than vhost-user don't support max queue size. + * Backends other than vhost-user or vhost-vdpa don't support max queue + * size. */ if (!peer) { return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE; } =20 - if (peer->info->type !=3D NET_CLIENT_DRIVER_VHOST_USER) { + switch(peer->info->type) { + case NET_CLIENT_DRIVER_VHOST_USER: + case NET_CLIENT_DRIVER_VHOST_VDPA: + return VIRTQUEUE_MAX_SIZE; + default: return VIRTIO_NET_TX_QUEUE_DEFAULT_SIZE; - } - - return VIRTQUEUE_MAX_SIZE; + }; } =20 static int peer_attach(VirtIONet *n, int index) --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403696257630.3963278311646; Fri, 4 Mar 2022 06:21:36 -0800 (PST) Received: from localhost ([::1]:44298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8oJ-00062p-51 for importer@patchew.org; Fri, 04 Mar 2022 09:21:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8B0-0003N4-8X for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Aw-00015e-8k for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:40:57 -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-119-I1Xp7TnRNeuy46qKve50VA-1; Fri, 04 Mar 2022 08:40:52 -0500 Received: by mail-wm1-f70.google.com with SMTP id n62-20020a1ca441000000b0038124c99ebcso2453911wme.9 for ; Fri, 04 Mar 2022 05:40:51 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm6702670wmq.35.2022.03.04.05.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401253; 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=fQd6WVFr9I1K2svJa1cXoPH2fq/JdR0GG570pqzR9U8=; b=ddShdPq6CyJX2X7n5ajQWh/t0Fajtt7H1JCyLF2LUAD5wMQ1lDjdhXIzYrZEalxJ35rWdP s7bBFSl4sC/NNugUhggGjms5hQCQHSt+Me7BV/lJo37jFOU3b1XTd4N2WG3SkPZnlzNDCg oZsAlqasgOhYizWGY0fwDigf3HHqDRk= X-MC-Unique: I1Xp7TnRNeuy46qKve50VA-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=fQd6WVFr9I1K2svJa1cXoPH2fq/JdR0GG570pqzR9U8=; b=Pb2HGQ5s0RobYoR/7dmhDb1IO8u3RngaSKRN2Kv6gFTV61rG4zgZ8NCRXOTx1CzjDP dea6bk9Dpm3UFRu1qwCuueVDl832lMvd6kYJ2+j/5i4ebH8PqyOTTmcb+UrNFkBb27lA cLKFjwhI+0GnIvrVVqodH7KOnHy4Pvqm54m51Mg74QJgjGPQTDNhInEKbsUJxsx+cwf0 rh0rjHCYbwBt6JlbyuUE6PDMAQqP3EvQb/JVv26WI1Bjk7Mv8BATvcxbnT2JRvB91lGX 5C7F2UCc6h5E1jiAHjclRmw4bgt/ZvOsNlnFtU7x0uW6D+W2/xZkmKBmX49PyudYNnrZ TaPw== X-Gm-Message-State: AOAM530kCXAHORZF7PePW4CXskccIOgHUvwq31HBoRxuXzL1poT7GKqn mDkg92w1jB506Yl3TwF3VAbtHPGu9DekPB49S0kVe8vI73DuIXgmq9O0k4xFki1Gz/vi03M7Qh/ EM++FN/vAp/oS5PcPJycRFo4HPrK8Dqfv6KwZQeFMaKDI4lIYTKioYtL3nggG X-Received: by 2002:a05:600c:22c9:b0:381:3b27:89be with SMTP id 9-20020a05600c22c900b003813b2789bemr7745214wmg.83.1646401250166; Fri, 04 Mar 2022 05:40:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJykr4/fPy7e8bBdh3TJXMFel8b4/boHUrPOvrgTZkR/JSDkVJ1cgZdd2ZBEcJ8A1h5ZkLerTA== X-Received: by 2002:a05:600c:22c9:b0:381:3b27:89be with SMTP id 9-20020a05600c22c900b003813b2789bemr7745179wmg.83.1646401249577; Fri, 04 Mar 2022 05:40:49 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 28/45] pcie: Add support for Single Root I/O Virtualization (SR/IOV) Message-ID: <20220304133556.233983-29-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Knut Omang , Knut Omang 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: 1646403698096100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Knut Omang This patch provides the building blocks for creating an SR/IOV PCIe Extended Capability header and register/unregister SR/IOV Virtual Functions. Signed-off-by: Knut Omang Message-Id: <20220217174504.1051716-2-lukasz.maniak@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 12 +- include/hw/pci/pcie.h | 6 + include/hw/pci/pcie_sriov.h | 71 +++++++++ include/qemu/typedefs.h | 2 + hw/pci/pci.c | 100 +++++++++--- hw/pci/pcie.c | 5 + hw/pci/pcie_sriov.c | 294 ++++++++++++++++++++++++++++++++++++ hw/pci/meson.build | 1 + hw/pci/trace-events | 5 + 9 files changed, 470 insertions(+), 26 deletions(-) create mode 100644 include/hw/pci/pcie_sriov.h create mode 100644 hw/pci/pcie_sriov.c diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index c3f3c90473..3a32b8dd40 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -7,9 +7,6 @@ /* PCI includes legacy ISA access. */ #include "hw/isa/isa.h" =20 -#include "hw/pci/pcie.h" -#include "qom/object.h" - extern bool pci_available; =20 /* PCI bus */ @@ -157,6 +154,7 @@ enum { #define QEMU_PCI_VGA_IO_HI_SIZE 0x20 =20 #include "hw/pci/pci_regs.h" +#include "hw/pci/pcie.h" =20 /* PCI HEADER_TYPE */ #define PCI_HEADER_TYPE_MULTI_FUNCTION 0x80 @@ -499,6 +497,9 @@ typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *,= int); AddressSpace *pci_device_iommu_address_space(PCIDevice *dev); void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque); =20 +pcibus_t pci_bar_address(PCIDevice *d, + int reg, uint8_t type, pcibus_t size); + static inline void pci_set_byte(uint8_t *config, uint8_t val) { @@ -779,6 +780,11 @@ static inline int pci_is_express_downstream_port(const= PCIDevice *d) return type =3D=3D PCI_EXP_TYPE_DOWNSTREAM || type =3D=3D PCI_EXP_TYPE= _ROOT_PORT; } =20 +static inline int pci_is_vf(const PCIDevice *d) +{ + return d->exp.sriov_vf.pf !=3D NULL; +} + static inline uint32_t pci_config_size(const PCIDevice *d) { return pci_is_express(d) ? PCIE_CONFIG_SPACE_SIZE : PCI_CONFIG_SPACE_S= IZE; diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 6063bee0ec..168950a83b 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -24,6 +24,7 @@ #include "hw/pci/pci_regs.h" #include "hw/pci/pcie_regs.h" #include "hw/pci/pcie_aer.h" +#include "hw/pci/pcie_sriov.h" #include "hw/hotplug.h" =20 typedef enum { @@ -81,6 +82,11 @@ struct PCIExpressDevice { =20 /* ACS */ uint16_t acs_cap; + + /* SR/IOV */ + uint16_t sriov_cap; + PCIESriovPF sriov_pf; + PCIESriovVF sriov_vf; }; =20 #define COMPAT_PROP_PCP "power_controller_present" diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h new file mode 100644 index 0000000000..990cff0a1c --- /dev/null +++ b/include/hw/pci/pcie_sriov.h @@ -0,0 +1,71 @@ +/* + * pcie_sriov.h: + * + * Implementation of SR/IOV emulation support. + * + * Copyright (c) 2015 Knut Omang + * + * 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. + * + */ + +#ifndef QEMU_PCIE_SRIOV_H +#define QEMU_PCIE_SRIOV_H + +struct PCIESriovPF { + uint16_t num_vfs; /* Number of virtual functions created */ + uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar = */ + const char *vfname; /* Reference to the device type used for the VFs */ + PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ +}; + +struct PCIESriovVF { + PCIDevice *pf; /* Pointer back to owner physical function */ + uint16_t vf_number; /* Logical VF number of this function */ +}; + +void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, + const char *vfname, uint16_t vf_dev_id, + uint16_t init_vfs, uint16_t total_vfs, + uint16_t vf_offset, uint16_t vf_stride); +void pcie_sriov_pf_exit(PCIDevice *dev); + +/* Set up a VF bar in the SR/IOV bar area */ +void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, + uint8_t type, dma_addr_t size); + +/* Instantiate a bar for a VF */ +void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, + MemoryRegion *memory); + +/* + * Default (minimal) page size support values + * as required by the SR/IOV standard: + * 0x553 << 12 =3D 0x553000 =3D 4K + 8K + 64K + 256K + 1M + 4M + */ +#define SRIOV_SUP_PGSIZE_MINREQ 0x553 + +/* + * Optionally add supported page sizes to the mask of supported page sizes + * Page size values are interpreted as opt_sup_pgsize << 12. + */ +void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_t opt_sup_pgsize); + +/* SR/IOV capability config write handler */ +void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, + uint32_t val, int len); + +/* Reset SR/IOV VF Enable bit to unregister all VFs */ +void pcie_sriov_pf_disable_vfs(PCIDevice *dev); + +/* Get logical VF number of a VF - only valid for VFs */ +uint16_t pcie_sriov_vf_number(PCIDevice *dev); + +/* + * Get the physical function that owns this VF. + * Returns NULL if dev is not a virtual function + */ +PCIDevice *pcie_sriov_get_pf(PCIDevice *dev); + +#endif /* QEMU_PCIE_SRIOV_H */ diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index ee60eb3de4..5b302cb214 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -86,6 +86,8 @@ typedef struct PCIDevice PCIDevice; typedef struct PCIEAERErr PCIEAERErr; typedef struct PCIEAERLog PCIEAERLog; typedef struct PCIEAERMsg PCIEAERMsg; +typedef struct PCIESriovPF PCIESriovPF; +typedef struct PCIESriovVF PCIESriovVF; typedef struct PCIEPort PCIEPort; typedef struct PCIESlot PCIESlot; typedef struct PCIExpressDevice PCIExpressDevice; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5d30f9ca60..ba8fb92efc 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -239,6 +239,9 @@ int pci_bar(PCIDevice *d, int reg) { uint8_t type; =20 + /* PCIe virtual functions do not have their own BARs */ + assert(!pci_is_vf(d)); + if (reg !=3D PCI_ROM_SLOT) return PCI_BASE_ADDRESS_0 + reg * 4; =20 @@ -304,10 +307,30 @@ void pci_device_deassert_intx(PCIDevice *dev) } } =20 -static void pci_do_device_reset(PCIDevice *dev) +static void pci_reset_regions(PCIDevice *dev) { int r; + if (pci_is_vf(dev)) { + return; + } =20 + for (r =3D 0; r < PCI_NUM_REGIONS; ++r) { + PCIIORegion *region =3D &dev->io_regions[r]; + if (!region->size) { + continue; + } + + if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) && + region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) { + pci_set_quad(dev->config + pci_bar(dev, r), region->type); + } else { + pci_set_long(dev->config + pci_bar(dev, r), region->type); + } + } +} + +static void pci_do_device_reset(PCIDevice *dev) +{ pci_device_deassert_intx(dev); assert(dev->irq_state =3D=3D 0); =20 @@ -323,19 +346,7 @@ static void pci_do_device_reset(PCIDevice *dev) pci_get_word(dev->wmask + PCI_INTERRUPT_LINE= ) | pci_get_word(dev->w1cmask + PCI_INTERRUPT_LI= NE)); dev->config[PCI_CACHE_LINE_SIZE] =3D 0x0; - for (r =3D 0; r < PCI_NUM_REGIONS; ++r) { - PCIIORegion *region =3D &dev->io_regions[r]; - if (!region->size) { - continue; - } - - if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) && - region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) { - pci_set_quad(dev->config + pci_bar(dev, r), region->type); - } else { - pci_set_long(dev->config + pci_bar(dev, r), region->type); - } - } + pci_reset_regions(dev); pci_update_mappings(dev); =20 msi_reset(dev); @@ -884,6 +895,16 @@ static void pci_init_multifunction(PCIBus *bus, PCIDev= ice *dev, Error **errp) dev->config[PCI_HEADER_TYPE] |=3D PCI_HEADER_TYPE_MULTI_FUNCTION; } =20 + /* + * With SR/IOV and ARI, a device at function 0 need not be a multifunc= tion + * device, as it may just be a VF that ended up with function 0 in + * the legacy PCI interpretation. Avoid failing in such cases: + */ + if (pci_is_vf(dev) && + dev->exp.sriov_vf.pf->cap_present & QEMU_PCI_CAP_MULTIFUNCTION) { + return; + } + /* * multifunction bit is interpreted in two ways as follows. * - all functions must set the bit to 1. @@ -1083,6 +1104,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, bus->devices[devfn]->name); return NULL; } else if (dev->hotplugged && + !pci_is_vf(pci_dev) && pci_get_function_0(pci_dev)) { error_setg(errp, "PCI: slot %d function 0 already occupied by %s," " new func %s cannot be exposed to guest.", @@ -1191,6 +1213,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_= num, pcibus_t size =3D memory_region_size(memory); uint8_t hdr_type; =20 + assert(!pci_is_vf(pci_dev)); /* VFs must use pcie_sriov_vf_register_ba= r */ assert(region_num >=3D 0); assert(region_num < PCI_NUM_REGIONS); assert(is_power_of_2(size)); @@ -1294,11 +1317,45 @@ pcibus_t pci_get_bar_addr(PCIDevice *pci_dev, int r= egion_num) return pci_dev->io_regions[region_num].addr; } =20 -static pcibus_t pci_bar_address(PCIDevice *d, - int reg, uint8_t type, pcibus_t size) +static pcibus_t pci_config_get_bar_addr(PCIDevice *d, int reg, + uint8_t type, pcibus_t size) +{ + pcibus_t new_addr; + if (!pci_is_vf(d)) { + int bar =3D pci_bar(d, reg); + if (type & PCI_BASE_ADDRESS_MEM_TYPE_64) { + new_addr =3D pci_get_quad(d->config + bar); + } else { + new_addr =3D pci_get_long(d->config + bar); + } + } else { + PCIDevice *pf =3D d->exp.sriov_vf.pf; + uint16_t sriov_cap =3D pf->exp.sriov_cap; + int bar =3D sriov_cap + PCI_SRIOV_BAR + reg * 4; + uint16_t vf_offset =3D + pci_get_word(pf->config + sriov_cap + PCI_SRIOV_VF_OFFSET); + uint16_t vf_stride =3D + pci_get_word(pf->config + sriov_cap + PCI_SRIOV_VF_STRIDE); + uint32_t vf_num =3D (d->devfn - (pf->devfn + vf_offset)) / vf_stri= de; + + if (type & PCI_BASE_ADDRESS_MEM_TYPE_64) { + new_addr =3D pci_get_quad(pf->config + bar); + } else { + new_addr =3D pci_get_long(pf->config + bar); + } + new_addr +=3D vf_num * size; + } + /* The ROM slot has a specific enable bit, keep it intact */ + if (reg !=3D PCI_ROM_SLOT) { + new_addr &=3D ~(size - 1); + } + return new_addr; +} + +pcibus_t pci_bar_address(PCIDevice *d, + int reg, uint8_t type, pcibus_t size) { pcibus_t new_addr, last_addr; - int bar =3D pci_bar(d, reg); uint16_t cmd =3D pci_get_word(d->config + PCI_COMMAND); Object *machine =3D qdev_get_machine(); ObjectClass *oc =3D object_get_class(machine); @@ -1309,7 +1366,7 @@ static pcibus_t pci_bar_address(PCIDevice *d, if (!(cmd & PCI_COMMAND_IO)) { return PCI_BAR_UNMAPPED; } - new_addr =3D pci_get_long(d->config + bar) & ~(size - 1); + new_addr =3D pci_config_get_bar_addr(d, reg, type, size); last_addr =3D new_addr + size - 1; /* Check if 32 bit BAR wraps around explicitly. * TODO: make priorities correct and remove this work around. @@ -1324,11 +1381,7 @@ static pcibus_t pci_bar_address(PCIDevice *d, if (!(cmd & PCI_COMMAND_MEMORY)) { return PCI_BAR_UNMAPPED; } - if (type & PCI_BASE_ADDRESS_MEM_TYPE_64) { - new_addr =3D pci_get_quad(d->config + bar); - } else { - new_addr =3D pci_get_long(d->config + bar); - } + new_addr =3D pci_config_get_bar_addr(d, reg, type, size); /* the ROM slot has a specific enable bit */ if (reg =3D=3D PCI_ROM_SLOT && !(new_addr & PCI_ROM_ADDRESS_ENABLE)) { return PCI_BAR_UNMAPPED; @@ -1473,6 +1526,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t = addr, uint32_t val_in, int =20 msi_write_config(d, addr, val_in, l); msix_write_config(d, addr, val_in, l); + pcie_sriov_config_write(d, addr, val_in, l); } =20 /***********************************************************/ diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index d7d73a31e4..3c44204cf3 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -446,6 +446,11 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev= , DeviceState *dev, PCIDevice *pci_dev =3D PCI_DEVICE(dev); uint32_t lnkcap =3D pci_get_long(exp_cap + PCI_EXP_LNKCAP); =20 + if (pci_is_vf(pci_dev)) { + /* Virtual function cannot be physically disconnected */ + return; + } + /* Don't send event when device is enabled during qemu machine creatio= n: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c new file mode 100644 index 0000000000..3f256d483f --- /dev/null +++ b/hw/pci/pcie_sriov.c @@ -0,0 +1,294 @@ +/* + * pcie_sriov.c: + * + * Implementation of SR/IOV emulation support. + * + * Copyright (c) 2015-2017 Knut Omang + * + * 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 "hw/pci/pci.h" +#include "hw/pci/pcie.h" +#include "hw/pci/pci_bus.h" +#include "hw/qdev-properties.h" +#include "qemu/error-report.h" +#include "qemu/range.h" +#include "qapi/error.h" +#include "trace.h" + +static PCIDevice *register_vf(PCIDevice *pf, int devfn, + const char *name, uint16_t vf_num); +static void unregister_vfs(PCIDevice *dev); + +void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, + const char *vfname, uint16_t vf_dev_id, + uint16_t init_vfs, uint16_t total_vfs, + uint16_t vf_offset, uint16_t vf_stride) +{ + uint8_t *cfg =3D dev->config + offset; + uint8_t *wmask; + + pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1, + offset, PCI_EXT_CAP_SRIOV_SIZEOF); + dev->exp.sriov_cap =3D offset; + dev->exp.sriov_pf.num_vfs =3D 0; + dev->exp.sriov_pf.vfname =3D g_strdup(vfname); + dev->exp.sriov_pf.vf =3D NULL; + + pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); + pci_set_word(cfg + PCI_SRIOV_VF_STRIDE, vf_stride); + + /* + * Mandatory page sizes to support. + * Device implementations can call pcie_sriov_pf_add_sup_pgsize() + * to set more bits: + */ + pci_set_word(cfg + PCI_SRIOV_SUP_PGSIZE, SRIOV_SUP_PGSIZE_MINREQ); + + /* + * Default is to use 4K pages, software can modify it + * to any of the supported bits + */ + pci_set_word(cfg + PCI_SRIOV_SYS_PGSIZE, 0x1); + + /* Set up device ID and initial/total number of VFs available */ + pci_set_word(cfg + PCI_SRIOV_VF_DID, vf_dev_id); + pci_set_word(cfg + PCI_SRIOV_INITIAL_VF, init_vfs); + pci_set_word(cfg + PCI_SRIOV_TOTAL_VF, total_vfs); + pci_set_word(cfg + PCI_SRIOV_NUM_VF, 0); + + /* Write enable control bits */ + wmask =3D dev->wmask + offset; + pci_set_word(wmask + PCI_SRIOV_CTRL, + PCI_SRIOV_CTRL_VFE | PCI_SRIOV_CTRL_MSE | PCI_SRIOV_CTRL_= ARI); + pci_set_word(wmask + PCI_SRIOV_NUM_VF, 0xffff); + pci_set_word(wmask + PCI_SRIOV_SYS_PGSIZE, 0x553); + + qdev_prop_set_bit(&dev->qdev, "multifunction", true); +} + +void pcie_sriov_pf_exit(PCIDevice *dev) +{ + unregister_vfs(dev); + g_free((char *)dev->exp.sriov_pf.vfname); + dev->exp.sriov_pf.vfname =3D NULL; +} + +void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, + uint8_t type, dma_addr_t size) +{ + uint32_t addr; + uint64_t wmask; + uint16_t sriov_cap =3D dev->exp.sriov_cap; + + assert(sriov_cap > 0); + assert(region_num >=3D 0); + assert(region_num < PCI_NUM_REGIONS); + assert(region_num !=3D PCI_ROM_SLOT); + + wmask =3D ~(size - 1); + addr =3D sriov_cap + PCI_SRIOV_BAR + region_num * 4; + + pci_set_long(dev->config + addr, type); + if (!(type & PCI_BASE_ADDRESS_SPACE_IO) && + type & PCI_BASE_ADDRESS_MEM_TYPE_64) { + pci_set_quad(dev->wmask + addr, wmask); + pci_set_quad(dev->cmask + addr, ~0ULL); + } else { + pci_set_long(dev->wmask + addr, wmask & 0xffffffff); + pci_set_long(dev->cmask + addr, 0xffffffff); + } + dev->exp.sriov_pf.vf_bar_type[region_num] =3D type; +} + +void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, + MemoryRegion *memory) +{ + PCIIORegion *r; + PCIBus *bus =3D pci_get_bus(dev); + uint8_t type; + pcibus_t size =3D memory_region_size(memory); + + assert(pci_is_vf(dev)); /* PFs must use pci_register_bar */ + assert(region_num >=3D 0); + assert(region_num < PCI_NUM_REGIONS); + type =3D dev->exp.sriov_vf.pf->exp.sriov_pf.vf_bar_type[region_num]; + + if (!is_power_of_2(size)) { + error_report("%s: PCI region size must be a power" + " of two - type=3D0x%x, size=3D0x%"FMT_PCIBUS, + __func__, type, size); + exit(1); + } + + r =3D &dev->io_regions[region_num]; + r->memory =3D memory; + r->address_space =3D + type & PCI_BASE_ADDRESS_SPACE_IO + ? bus->address_space_io + : bus->address_space_mem; + r->size =3D size; + r->type =3D type; + + r->addr =3D pci_bar_address(dev, region_num, r->type, r->size); + if (r->addr !=3D PCI_BAR_UNMAPPED) { + memory_region_add_subregion_overlap(r->address_space, + r->addr, r->memory, 1); + } +} + +static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, + uint16_t vf_num) +{ + PCIDevice *dev =3D pci_new(devfn, name); + dev->exp.sriov_vf.pf =3D pf; + dev->exp.sriov_vf.vf_number =3D vf_num; + PCIBus *bus =3D pci_get_bus(pf); + Error *local_err =3D NULL; + + qdev_realize(&dev->qdev, &bus->qbus, &local_err); + if (local_err) { + error_report_err(local_err); + return NULL; + } + + /* set vid/did according to sr/iov spec - they are not used */ + pci_config_set_vendor_id(dev->config, 0xffff); + pci_config_set_device_id(dev->config, 0xffff); + + return dev; +} + +static void register_vfs(PCIDevice *dev) +{ + uint16_t num_vfs; + uint16_t i; + uint16_t sriov_cap =3D dev->exp.sriov_cap; + uint16_t vf_offset =3D + pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_OFFSET); + uint16_t vf_stride =3D + pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_STRIDE); + int32_t devfn =3D dev->devfn + vf_offset; + + assert(sriov_cap > 0); + num_vfs =3D pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); + + dev->exp.sriov_pf.vf =3D g_malloc(sizeof(PCIDevice *) * num_vfs); + assert(dev->exp.sriov_pf.vf); + + trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), + PCI_FUNC(dev->devfn), num_vfs); + for (i =3D 0; i < num_vfs; i++) { + dev->exp.sriov_pf.vf[i] =3D register_vf(dev, devfn, + dev->exp.sriov_pf.vfname, i); + if (!dev->exp.sriov_pf.vf[i]) { + num_vfs =3D i; + break; + } + devfn +=3D vf_stride; + } + dev->exp.sriov_pf.num_vfs =3D num_vfs; +} + +static void unregister_vfs(PCIDevice *dev) +{ + Error *local_err =3D NULL; + uint16_t num_vfs =3D dev->exp.sriov_pf.num_vfs; + uint16_t i; + + trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), + PCI_FUNC(dev->devfn), num_vfs); + for (i =3D 0; i < num_vfs; i++) { + PCIDevice *vf =3D dev->exp.sriov_pf.vf[i]; + object_property_set_bool(OBJECT(vf), "realized", false, &local_err= ); + if (local_err) { + fprintf(stderr, "Failed to unplug: %s\n", + error_get_pretty(local_err)); + error_free(local_err); + } + object_unparent(OBJECT(vf)); + } + g_free(dev->exp.sriov_pf.vf); + dev->exp.sriov_pf.vf =3D NULL; + dev->exp.sriov_pf.num_vfs =3D 0; + pci_set_word(dev->config + dev->exp.sriov_cap + PCI_SRIOV_NUM_VF, 0); +} + +void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, + uint32_t val, int len) +{ + uint32_t off; + uint16_t sriov_cap =3D dev->exp.sriov_cap; + + if (!sriov_cap || address < sriov_cap) { + return; + } + off =3D address - sriov_cap; + if (off >=3D PCI_EXT_CAP_SRIOV_SIZEOF) { + return; + } + + trace_sriov_config_write(dev->name, PCI_SLOT(dev->devfn), + PCI_FUNC(dev->devfn), off, val, len); + + if (range_covers_byte(off, len, PCI_SRIOV_CTRL)) { + if (dev->exp.sriov_pf.num_vfs) { + if (!(val & PCI_SRIOV_CTRL_VFE)) { + unregister_vfs(dev); + } + } else { + if (val & PCI_SRIOV_CTRL_VFE) { + register_vfs(dev); + } + } + } +} + + +/* Reset SR/IOV VF Enable bit to trigger an unregister of all VFs */ +void pcie_sriov_pf_disable_vfs(PCIDevice *dev) +{ + uint16_t sriov_cap =3D dev->exp.sriov_cap; + if (sriov_cap) { + uint32_t val =3D pci_get_byte(dev->config + sriov_cap + PCI_SRIOV_= CTRL); + if (val & PCI_SRIOV_CTRL_VFE) { + val &=3D ~PCI_SRIOV_CTRL_VFE; + pcie_sriov_config_write(dev, sriov_cap + PCI_SRIOV_CTRL, val, = 1); + } + } +} + +/* Add optional supported page sizes to the mask of supported page sizes */ +void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_t opt_sup_pgsize) +{ + uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; + uint8_t *wmask =3D dev->wmask + dev->exp.sriov_cap; + + uint16_t sup_pgsize =3D pci_get_word(cfg + PCI_SRIOV_SUP_PGSIZE); + + sup_pgsize |=3D opt_sup_pgsize; + + /* + * Make sure the new bits are set, and that system page size + * also can be set to any of the new values according to spec: + */ + pci_set_word(cfg + PCI_SRIOV_SUP_PGSIZE, sup_pgsize); + pci_set_word(wmask + PCI_SRIOV_SYS_PGSIZE, sup_pgsize); +} + + +uint16_t pcie_sriov_vf_number(PCIDevice *dev) +{ + assert(pci_is_vf(dev)); + return dev->exp.sriov_vf.vf_number; +} + + +PCIDevice *pcie_sriov_get_pf(PCIDevice *dev) +{ + return dev->exp.sriov_vf.pf; +} diff --git a/hw/pci/meson.build b/hw/pci/meson.build index 5c4bbac817..bcc9c75919 100644 --- a/hw/pci/meson.build +++ b/hw/pci/meson.build @@ -5,6 +5,7 @@ pci_ss.add(files( 'pci.c', 'pci_bridge.c', 'pci_host.c', + 'pcie_sriov.c', 'shpc.c', 'slotid_cap.c' )) diff --git a/hw/pci/trace-events b/hw/pci/trace-events index 7570752c40..aaf46bc92d 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -10,3 +10,8 @@ pci_cfg_write(const char *dev, uint32_t bus, uint32_t slo= t, uint32_t func, unsig =20 # msix.c msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %= d masked %d" + +# hw/pci/pcie_sriov.c +sriov_register_vfs(const char *name, int slot, int function, int num_vfs) = "%s %02x:%x: creating %d vf devs" +sriov_unregister_vfs(const char *name, int slot, int function, int num_vfs= ) "%s %02x:%x: Unregistering %d vf devs" +sriov_config_write(const char *name, int slot, int fun, uint32_t offset, u= int32_t val, uint32_t len) "%s %02x:%x: sriov offset 0x%x val 0x%x len %d" --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403698239273.88901483417453; Fri, 4 Mar 2022 06:21:38 -0800 (PST) Received: from localhost ([::1]:44494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8oL-0006Ad-6u for importer@patchew.org; Fri, 04 Mar 2022 09:21:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8B4-0003WE-Bd for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8B1-00016l-Id for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:01 -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-224-1EVUoaSiMBarA7LOgoEWmw-1; Fri, 04 Mar 2022 08:40:57 -0500 Received: by mail-wm1-f70.google.com with SMTP id 3-20020a05600c230300b00384e15ceae4so2709311wmo.7 for ; Fri, 04 Mar 2022 05:40:56 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id c5-20020a5d4f05000000b001f05fd59776sm3766699wru.28.2022.03.04.05.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401258; 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=DkfRe+4XN2ej+2g6vgbi6qb5c1d4eupHyNI5HdgNhQg=; b=FG8vywXOOsAP1392/GhHOcLRdZn9gElWdC3PQqhd8/2AXKmsdA0HaI/GvIRpwEypwXOGR1 PSybR6UCZheVG3yC8+YOreMIxEw5yZXUql8U7ufQbPuMnmYlvvKViOVvyLfgLRnb97AGhR SUTF+Q3pQ+1KiQqijTvAWz+edi8JJNU= X-MC-Unique: 1EVUoaSiMBarA7LOgoEWmw-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=DkfRe+4XN2ej+2g6vgbi6qb5c1d4eupHyNI5HdgNhQg=; b=YzVOeSvakt9HMJxiflG3EpagHhYHmwUZvY8sFvLYnLQu/nSj1dSTegVcUEMwqxhEYK qHc2xB7m/6pEWKUmF065GzGwnsCjcooP1KWn2IwaszhSyrVp6mlJ8YrCRtGi3MXydA3+ 936bqls6Coe9ldYj+WaKZ8lzvWID+pnmX33GExfTNARZgnjr3jf5pBiuvRyoCNAIBrQ+ rXx7lS3ADD3MXgg/3lRdtSeaxKgUtWSNP7x0flHwjzFY0YmPJLLtphvHaYLOaFzyIPPr DDG1VoEBermXro5Rn0jR8kfqyWzeOjs5wwWXD847zVMNe6QIs9DOpH2OGJPgvCp2EteR OK3A== X-Gm-Message-State: AOAM533rK8WhHXntcqH/QjUr/hbULq8JVmqdye42h6/SEZVFBscvA6s5 oJzDMonRnbObIGUKZOs58J+eoruNjyHkPpzldgYlGftXQWeFuV5ER1M4z81gOCBDqSv7hyp0+Vo prxSOa25PJbOn+P0ainNrGWoPqmc5oNl48Yt3uAojVWIDtdzg6vVo9B67QyUo X-Received: by 2002:a5d:6046:0:b0:1f0:4973:142f with SMTP id j6-20020a5d6046000000b001f04973142fmr7021105wrt.538.1646401255419; Fri, 04 Mar 2022 05:40:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxeqNd5yxCurJkeFe5EMbVhLFHdd/KUa/U0O1hRd8zSfALxtxjlTCU5h2nMtr1qaFzJ2UR+jA== X-Received: by 2002:a5d:6046:0:b0:1f0:4973:142f with SMTP id j6-20020a5d6046000000b001f04973142fmr7021081wrt.538.1646401255026; Fri, 04 Mar 2022 05:40:55 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 29/45] pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt Message-ID: <20220304133556.233983-30-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Knut Omang , Knut Omang 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: 1646403699819100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Knut Omang Add a small intro + minimal documentation for how to implement SR/IOV support for an emulated device. Signed-off-by: Knut Omang Message-Id: <20220217174504.1051716-3-lukasz.maniak@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/pcie_sriov.txt | 115 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 docs/pcie_sriov.txt diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt new file mode 100644 index 0000000000..f5e891e1d4 --- /dev/null +++ b/docs/pcie_sriov.txt @@ -0,0 +1,115 @@ +PCI SR/IOV EMULATION SUPPORT +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D + +Description +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +SR/IOV (Single Root I/O Virtualization) is an optional extended capability +of a PCI Express device. It allows a single physical function (PF) to appe= ar as multiple +virtual functions (VFs) for the main purpose of eliminating software +overhead in I/O from virtual machines. + +Qemu now implements the basic common functionality to enable an emulated d= evice +to support SR/IOV. Yet no fully implemented devices exists in Qemu, but a +proof-of-concept hack of the Intel igb can be found here: + +git://github.com/knuto/qemu.git sriov_patches_v5 + +Implementation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Implementing emulation of an SR/IOV capable device typically consists of +implementing support for two types of device classes; the "normal" physica= l device +(PF) and the virtual device (VF). From Qemu's perspective, the VFs are just +like other devices, except that some of their properties are derived from +the PF. + +A virtual function is different from a physical function in that the BAR +space for all VFs are defined by the BAR registers in the PFs SR/IOV +capability. All VFs have the same BARs and BAR sizes. + +Accesses to these virtual BARs then is computed as + + + * + + +From our emulation perspective this means that there is a separate call for +setting up a BAR for a VF. + +1) To enable SR/IOV support in the PF, it must be a PCI Express device so + you would need to add a PCI Express capability in the normal PCI + capability list. You might also want to add an ARI (Alternative + Routing-ID Interpretation) capability to indicate that your device + supports functions beyond it's "own" function space (0-7), + which is necessary to support more than 7 functions, or + if functions extends beyond offset 7 because they are placed at an + offset > 1 or have stride > 1. + + ... + #include "hw/pci/pcie.h" + #include "hw/pci/pcie_sriov.h" + + pci_your_pf_dev_realize( ... ) + { + ... + int ret =3D pcie_endpoint_cap_init(d, 0x70); + ... + pcie_ari_init(d, 0x100, 1); + ... + + /* Add and initialize the SR/IOV capability */ + pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", + vf_devid, initial_vfs, total_vfs, + fun_offset, stride); + + /* Set up individual VF BARs (parameters as for normal BARs) */ + pcie_sriov_pf_init_vf_bar( ... ) + ... + } + + For cleanup, you simply call: + + pcie_sriov_pf_exit(device); + + which will delete all the virtual functions and associated resources. + +2) Similarly in the implementation of the virtual function, you need to + make it a PCI Express device and add a similar set of capabilities + except for the SR/IOV capability. Then you need to set up the VF BARs as + subregions of the PFs SR/IOV VF BARs by calling + pcie_sriov_vf_register_bar() instead of the normal pci_register_bar() c= all: + + pci_your_vf_dev_realize( ... ) + { + ... + int ret =3D pcie_endpoint_cap_init(d, 0x60); + ... + pcie_ari_init(d, 0x100, 1); + ... + memory_region_init(mr, ... ) + pcie_sriov_vf_register_bar(d, bar_nr, mr); + ... + } + +Testing on Linux guest +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The easiest is if your device driver supports sysfs based SR/IOV +enabling. Support for this was added in kernel v.3.8, so not all drivers +support it yet. + +To enable 4 VFs for a device at 01:00.0: + + modprobe yourdriver + echo 4 > /sys/bus/pci/devices/0000:01:00.0/sriov_numvfs + +You should now see 4 VFs with lspci. +To turn SR/IOV off again - the standard requires you to turn it off before= you can enable +another VF count, and the emulation enforces this: + + echo 0 > /sys/bus/pci/devices/0000:01:00.0/sriov_numvfs + +Older drivers typically provide a max_vfs module parameter +to enable it at load time: + + modprobe yourdriver max_vfs=3D4 + +To disable the VFs again then, you simply have to unload the driver: + + rmmod yourdriver --=20 MST From nobody Tue May 14 12:10:45 2024 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 164640385648258.47372445479175; Fri, 4 Mar 2022 06:24:16 -0800 (PST) Received: from localhost ([::1]:53052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8qt-0003bi-D9 for importer@patchew.org; Fri, 04 Mar 2022 09:24:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8BB-0003cu-2e for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8B7-00017S-Dc for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:08 -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-588-nJJtTMSWNeGyhyBRGDP4nQ-1; Fri, 04 Mar 2022 08:41:03 -0500 Received: by mail-wr1-f69.google.com with SMTP id f14-20020adfc98e000000b001e8593b40b0so3363811wrh.14 for ; Fri, 04 Mar 2022 05:41:03 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id g17-20020a5d4891000000b001e74e998bf9sm4586836wrq.33.2022.03.04.05.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:40:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401264; 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=Nfa7HHR2REoaTfd34g0WHMW6eNj0XG3k8vtXlnv0J3Q=; b=Xt2Rj/lqiuuHVIT8V0yYNMhyYKG3W6EEwpjK4/1OlYGMzRchPfF6cE+elpq8ObNa0PfPzI MKrESiw2HwuhQfTqPGADkL49JJOuKhD1K7mo0KYvtcMwGGuk6ZTLHFMObPfAxGbql0AISY MU9UTDhIEZa/ZTEGeKrWsDbrwY6m5t0= X-MC-Unique: nJJtTMSWNeGyhyBRGDP4nQ-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=Nfa7HHR2REoaTfd34g0WHMW6eNj0XG3k8vtXlnv0J3Q=; b=g2RbsT9rEJgGm5O94hXhEw2iH4iNnfCEE9rOO6b4gQQu8vm7bQeiAe3OpsKKDc4iiN zKOCTZIVvgDZhlzakTf3e/9DEJTkyMao+swnf/v0XVaVLJeVCgcWYBWEJ0ObrtzSgxXC VnIF+LErtQ1aVd7uvk9EppkEjxgsKVwZm1NDWE9WOWHeU09RiTAoh1gO9EQ992K+r/yK igC2olCMDBAvMubFeuuQxRz4snXfOqYEfm29HufVfBSSY5p1N23FjFmpy3BD1rtUsGF2 t9JZ0hy8tMoSL0ZAL6Gw7h7VQiHxc/sf1V/d9yH+oDoPEwivyElFK1ZUkSo+dHG9u43i +x4Q== X-Gm-Message-State: AOAM5302t6CYetL4tPsyw7LRXbfMqvdg1BSEyiRLUVoi/hS/WjQIKj0O ubqdEwNVKM4FegkPyOWRIITr/W+jS/cXbevV+oBTM5jOFj+HAo+JPlaGd15zGteK+oWEI2FG2gF 7UhQB55W74osVovpnIwociYnAKLxQ71lYMnqupNRgPUpDz5b+cGOR+tUh1DLT X-Received: by 2002:a5d:678a:0:b0:1ef:8e97:363c with SMTP id v10-20020a5d678a000000b001ef8e97363cmr22471848wru.617.1646401262035; Fri, 04 Mar 2022 05:41:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnTCkbb1qdMdjn4gpDmR6rErN56Ls12L76k++zVR2tgyYDv0fQGgkg/3ogSqLo9SGjMEiYeQ== X-Received: by 2002:a5d:678a:0:b0:1ef:8e97:363c with SMTP id v10-20020a5d678a000000b001ef8e97363cmr22471828wru.617.1646401261772; Fri, 04 Mar 2022 05:41:01 -0800 (PST) Date: Fri, 4 Mar 2022 08:40:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 30/45] pcie: Add a helper to the SR/IOV API Message-ID: <20220304133556.233983-31-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Knut Omang , =?utf-8?Q?=C5=81ukasz?= Gieryk 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: 1646403858316100003 From: =C5=81ukasz Gieryk Convenience function for retrieving the PCIDevice object of the N-th VF. Signed-off-by: =C5=81ukasz Gieryk Reviewed-by: Knut Omang Message-Id: <20220217174504.1051716-4-lukasz.maniak@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie_sriov.h | 6 ++++++ hw/pci/pcie_sriov.c | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 990cff0a1c..80f5c84e75 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -68,4 +68,10 @@ uint16_t pcie_sriov_vf_number(PCIDevice *dev); */ PCIDevice *pcie_sriov_get_pf(PCIDevice *dev); =20 +/* + * Get the n-th VF of this physical function - only valid for PF. + * Returns NULL if index is invalid + */ +PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n); + #endif /* QEMU_PCIE_SRIOV_H */ diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 3f256d483f..87abad6ac8 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -287,8 +287,16 @@ uint16_t pcie_sriov_vf_number(PCIDevice *dev) return dev->exp.sriov_vf.vf_number; } =20 - PCIDevice *pcie_sriov_get_pf(PCIDevice *dev) { return dev->exp.sriov_vf.pf; } + +PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n) +{ + assert(!pci_is_vf(dev)); + if (n < dev->exp.sriov_pf.num_vfs) { + return dev->exp.sriov_pf.vf[n]; + } + return NULL; +} --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646403855171515.4334900934425; Fri, 4 Mar 2022 06:24:15 -0800 (PST) Received: from localhost ([::1]:52962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8qs-0003YI-29 for importer@patchew.org; Fri, 04 Mar 2022 09:24:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8BG-0003e5-Pb for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8BE-000189-KH for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:13 -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-208-sNrB0LBzMte7t8YuX6h10A-1; Fri, 04 Mar 2022 08:41:11 -0500 Received: by mail-wr1-f72.google.com with SMTP id k20-20020adfc714000000b001e305cd1597so3380493wrg.19 for ; Fri, 04 Mar 2022 05:41:10 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id l1-20020a05600c4f0100b00387369f380bsm5562882wmq.41.2022.03.04.05.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401272; 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=IjGfq51R1V+EiuJTNpSRpX5c6IUrfGMgpNpMM4jK+NE=; b=NmhZkKIK+FdZXE9AXLvuGkbd9SEH/p8wff8hCUmImtvsPxrJXwPPkmNhUzXqocPa8SZie4 oc5R7HDBGNi4b2KcDWMpRA/ota+L0XzckrfZAsteQlYSIMYXilXFqyJSiBSzi75U0/MRue xr/aFAZjd6BzJKCByvyG5BW/6olT04s= X-MC-Unique: sNrB0LBzMte7t8YuX6h10A-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=IjGfq51R1V+EiuJTNpSRpX5c6IUrfGMgpNpMM4jK+NE=; b=A3O0ENmbTFW3NMsNgVXQq1u5ImpFfPrcdHs1yKMBdOVeKdcZR6a3mYmizi9aXc/Rc6 IwahAsw4huJw9TZzwNDkWU5jgbDKdEO6CX5bOYo9iP47uXEvq24kTuUU40I3QfqvzPHi y6CH/Bubx9NdXg6O2X8x5wc7v1GgRIFG1l2JiLBKfEw5jn6l/Ddf9HhzvjRg60NUZzoH BumgGdoVc5SpLT50b3hdkEHy9iH3r0njkBzYLSRgqyzWWgirrOSzqeuwlRvMgxVOaseh 9xF0ZAOJJAG7NLt0wOIA7uD1WrL5g/6VbrCnu5c7/lAPraa2t3eeT1k0ckB04Wair15A vNhQ== X-Gm-Message-State: AOAM530KaKzl7NqJDZ49ELzYbzsHBZ2pxoiZ+vPcDT71zrAsDbHQfdyN kBHbCZrUFdq3XIIz0k5Dk7MqNcqoNBqKYhAXwXh3aTLCb22RdJA2gmhkempqeEDBEBnjTEABDrj b61Q7eCwFUbrJPu41vaBXUTAzKmeSnlKZiiEKXEIIrgbYy3P+6RScUCOhG6rS X-Received: by 2002:a5d:49c9:0:b0:1f0:16b2:584f with SMTP id t9-20020a5d49c9000000b001f016b2584fmr12786168wrs.710.1646401269435; Fri, 04 Mar 2022 05:41:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvGi8Kj34zlRu0108In8y75wMRsVmnGZ7fZ04ArfhjN4EA7K2hvqi6uWNWhgJXSCExVaSVww== X-Received: by 2002:a5d:49c9:0:b0:1f0:16b2:584f with SMTP id t9-20020a5d49c9000000b001f016b2584fmr12786143wrs.710.1646401269149; Fri, 04 Mar 2022 05:41:09 -0800 (PST) Date: Fri, 4 Mar 2022 08:41:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 31/45] pcie: Add 1.2 version token for the Power Management Capability Message-ID: <20220304133556.233983-32-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , =?utf-8?Q?=C5=81ukasz?= Gieryk 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: 1646403856036100001 From: =C5=81ukasz Gieryk Signed-off-by: =C5=81ukasz Gieryk Message-Id: <20220217174504.1051716-5-lukasz.maniak@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_regs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hw/pci/pci_regs.h b/include/hw/pci/pci_regs.h index 77ba64b931..a590140962 100644 --- a/include/hw/pci/pci_regs.h +++ b/include/hw/pci/pci_regs.h @@ -4,5 +4,6 @@ #include "standard-headers/linux/pci_regs.h" =20 #define PCI_PM_CAP_VER_1_1 0x0002 /* PCI PM spec ver. 1.1 */ +#define PCI_PM_CAP_VER_1_2 0x0003 /* PCI PM spec ver. 1.2 */ =20 #endif --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404030756393.4348823231617; Fri, 4 Mar 2022 06:27:10 -0800 (PST) Received: from localhost ([::1]:60760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8ti-0000YN-1C for importer@patchew.org; Fri, 04 Mar 2022 09:27:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8BP-0003jw-Lx for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8BM-00018r-7J for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:22 -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-344-FYBwalFnPQ2DluIUzRvz6g-1; Fri, 04 Mar 2022 08:41:18 -0500 Received: by mail-wm1-f72.google.com with SMTP id f24-20020a1c6a18000000b00388874b17a8so1034893wmc.3 for ; Fri, 04 Mar 2022 05:41:17 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id l15-20020a05600c4f0f00b0037d62a899b1sm4974710wmq.6.2022.03.04.05.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:41:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401278; 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=5b8reuTHyuhMIH4vmrxET5yF+Z8FE8Jp8knp1f17Abw=; b=E0GSCZRyPCSFNII7awrOtj/wAwfcVCF7C+wO8fqXPwBErXtQWP9xfs7xtLLI3fdUaQ938R DVxdciZNlZaJ3MPqelOkQlJUUTjg5nf6hOynjad0/aEfD+YHjl9XaZEmjynEOi3RPe5eM3 Y6xCtML6qRTKesJP5AbUbR6lzqtBCyk= X-MC-Unique: FYBwalFnPQ2DluIUzRvz6g-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=5b8reuTHyuhMIH4vmrxET5yF+Z8FE8Jp8knp1f17Abw=; b=1GoU5DwDm7FrD5zkeO7Pb0s2UhFNNjbDxL13Nc9MD0t+AxobHeEEA0q9jbo7rJnqQx CIO4g/qNaJH19Pvu2FExYdmhG0pg5ESC3xTwE4nxSdZc86i3eWWAj6sf4OWovgGz90QG AFXoFuqLxdB6llQcNheyEXV0sqN8DDj4AhzkFvh4IwRwSDYfUZpmIptr+lc9oSn/jZcL ZUm1RmCdwNq7xcI79JnMrBiZIwCH26QvHt6IghBohR1R6gg2wNUDQWZdQwKm7KnAx7n+ 5E8wFb5Wi81gnalB8zJc9U6UB1jDsMgH2H6D6f6zMyrcNQSKzkcc/7H7D4pNpyHhA4U/ bQOg== X-Gm-Message-State: AOAM531bgnOd2Jew8Tbh3PBtZ16bIYJ8kAydb10LYhMl2VgEg5eOWUR6 upbBGbPqqai/NBW8DtBs53tLH1u+b4YEYopvDkRZ3sMR9nwUMsgRak7OwJ+DMTCYreO8mL89zOQ Y/5Ha0FCkYCSfO3SJNAHp9CK8KyoZV5PERZLMQ/MonbO+5yDZyViBRPKI8WnY X-Received: by 2002:a5d:6481:0:b0:1f0:46c3:e6f with SMTP id o1-20020a5d6481000000b001f046c30e6fmr8270180wri.692.1646401276539; Fri, 04 Mar 2022 05:41:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8XMvLd/36w2Vh04XqP4XSvPBzInan/xFjLPWCX6b5anm6lrvB5ix88Letq4JXX3Lg3FMg2g== X-Received: by 2002:a5d:6481:0:b0:1f0:46c3:e6f with SMTP id o1-20020a5d6481000000b001f046c30e6fmr8270166wri.692.1646401276310; Fri, 04 Mar 2022 05:41:16 -0800 (PST) Date: Fri, 4 Mar 2022 08:41:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 32/45] pci-bridge/xio3130_upstream: Fix error handling Message-ID: <20220304133556.233983-33-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Jonathan Cameron 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: 1646404048795100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Goto label is incorrect so msi cleanup would not occur if there is an error in the ssvid initialization. Signed-off-by: Jonathan Cameron Message-Id: <20220218102303.7061-1-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/xio3130_upstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstr= eam.c index 5cd3af4fbc..5ff46ef050 100644 --- a/hw/pci-bridge/xio3130_upstream.c +++ b/hw/pci-bridge/xio3130_upstream.c @@ -75,7 +75,7 @@ static void xio3130_upstream_realize(PCIDevice *d, Error = **errp) XIO3130_SSVID_SVID, XIO3130_SSVID_SSID, errp); if (rc < 0) { - goto err_bridge; + goto err_msi; } =20 rc =3D pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_UPSTREAM, --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404039874345.892110490595; Fri, 4 Mar 2022 06:27:19 -0800 (PST) Received: from localhost ([::1]:33416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8tr-0001CG-Ft for importer@patchew.org; Fri, 04 Mar 2022 09:27:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Bb-0003pc-TD for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Ba-0001BC-Hx for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:35 -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-326-jIYsY0XYMfWXRv-FClUVuQ-1; Fri, 04 Mar 2022 08:41:33 -0500 Received: by mail-wr1-f71.google.com with SMTP id t15-20020adfdc0f000000b001ef93643476so3375332wri.2 for ; Fri, 04 Mar 2022 05:41:32 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id u18-20020adfdd52000000b001f04e9f215fsm4392617wrm.53.2022.03.04.05.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401294; 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=0SLrr2pzwbz8DMCaGa52u4y7YRyNCIg4T/EysVR8B14=; b=PwhnroneBvG65zK6mcFTOP+6ZWzrskVBYHSMRnB4WepARWtNXPgdemAtNtfQ1WUkn7w4KB CCZTUcqp+MHrpUNdZvy68bZ9Imy2N8V4MswDLgnFQpnlWlAwC2vsAC6P3nb7PSSdaA3T00 kb/FXqHxmhZAAZyAdE1OQxh4DcoVxeQ= X-MC-Unique: jIYsY0XYMfWXRv-FClUVuQ-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=0SLrr2pzwbz8DMCaGa52u4y7YRyNCIg4T/EysVR8B14=; b=zDFVjI+W/GDV/Xpa6GVqKOF8+fzf4bjO9mFnYjIrnV7PxQb0Axpy8y8kVXkrw0anbK nUkd9GzTSIHPUSvUQNe7tPGtO4Jl5r6R0LKOpOuQ+bFrY1IpF/uUZsrN5Lz1CS1Fip67 +xDmuDngQeKa0NHrQCuT1vbyhL1IzijMirus1QiTe5WBehHcuSn2AVwvaZW/gj8csxj6 0dp7NcnqPON9EdQDJwTrPkwaJjbaKCcVW8brJF7LdoJoAuelFo58/twEf7FJOKz2HdXb +9zI/MK+X+6XGN9BDutHz8fZS9OEzadMc9AyEaH21+Y0IHCe1wlexdsRbCiC808a+Y1F o6wQ== X-Gm-Message-State: AOAM532w7YlR+7xTfnk/Ouc6zPDI7HPr/o4TCteOMJFXl/g4ZQXsYSvD /TFyAwVW28sI0sIaYTGYdNwf/3nVkLU37Ib2+WTrm/CC6wPtJV88pcoIPtwguVDxJZvaEyOeafP QD/B78x9/lrs0JM/G9CG8TZDFQhm3lZGZE2yyfeOIJ3Lt68LXTB7V2ZLA+zUn X-Received: by 2002:a05:6000:18a4:b0:1f0:5f19:152c with SMTP id b4-20020a05600018a400b001f05f19152cmr5348981wri.414.1646401291350; Fri, 04 Mar 2022 05:41:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9uQ36AU+WEuSdNez5i/gd52jNdy544mwNHa8433RNHbFqnXWX2kJYXllO0UkEBMUcXt+yyQ== X-Received: by 2002:a05:6000:18a4:b0:1f0:5f19:152c with SMTP id b4-20020a05600018a400b001f05f19152cmr5348960wri.414.1646401291059; Fri, 04 Mar 2022 05:41:31 -0800 (PST) Date: Fri, 4 Mar 2022 08:41:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 33/45] pci-bridge/xio3130_downstream: Fix error handling Message-ID: <20220304133556.233983-34-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Jonathan Cameron 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: 1646404041739100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Wrong goto label, so msi cleanup would not occur if there is an error in the ssvid initialization. Signed-off-by: Jonathan Cameron Message-Id: <20220218102303.7061-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/xio3130_downstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_dow= nstream.c index 04aae72cd6..080a6613fe 100644 --- a/hw/pci-bridge/xio3130_downstream.c +++ b/hw/pci-bridge/xio3130_downstream.c @@ -84,7 +84,7 @@ static void xio3130_downstream_realize(PCIDevice *d, Erro= r **errp) XIO3130_SSVID_SVID, XIO3130_SSVID_SSID, errp); if (rc < 0) { - goto err_bridge; + goto err_msi; } =20 rc =3D pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_DOWNSTREAM, --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404396847341.65381221106236; Fri, 4 Mar 2022 06:33:16 -0800 (PST) Received: from localhost ([::1]:47200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8zb-000290-K2 for importer@patchew.org; Fri, 04 Mar 2022 09:33:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Bo-00045D-Tj for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Bn-0001CX-Bf for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:48 -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-344-9g4rs4-CO9qSGRjSyFxzVg-1; Fri, 04 Mar 2022 08:41:45 -0500 Received: by mail-wm1-f70.google.com with SMTP id l2-20020a1ced02000000b0038482a47e7eso2825901wmh.5 for ; Fri, 04 Mar 2022 05:41:45 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id f17-20020adffcd1000000b001edbf438d83sm4441885wrs.32.2022.03.04.05.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:41:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401306; 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=KRo1oLzj8z655SYF1zAVR80J4AJJ+nuqJ/mStJU6s7s=; b=YH3vaNGwnRT4tl8v75X6XOG5QZ9usZwS3Ks/lik8w5uv0zgnasdnb+qADarAxmoqjsm7cy 2FHGsSZgT5iG2F7HSHgs1sDof7cd0w8LdcPmWTQe0j3CioumPV/K+Wy/L7BidMQmnlbNxc ciS+krbl6Po9C8YIEI1A0ZdGoj9z0u4= X-MC-Unique: 9g4rs4-CO9qSGRjSyFxzVg-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=KRo1oLzj8z655SYF1zAVR80J4AJJ+nuqJ/mStJU6s7s=; b=YykJZCAzxYPiZGNpT8E4xPSQGVSg0ir0QoPstbj4sZW+Mc9RfHmtXnzFJQVf2zBEw5 TAqINioomnLd2FSO0GQ/dUgk6SpIGphFp/vtTEbF3oyj/zgR8OnO6Ta7Xg9elalhPzaQ zVjqPguubjbSyB9EtWmfI8D1v5+80BcDBU1V8pXsJLr7s5GmzPMMo0Nf5gskTkqMOzCi JYnSKKP387kfUTG16ppi0LFv8DOu7VMh09FLP1cCLt+S5HZbHuN4m5fWVnm35bEAjePH NrLiaDsrpHNNSXpmH1NLtmCCCfhMl0KpmKYV1u7kPrW+4cmBayfGwkry4hPeO50Jms5G Zfyw== X-Gm-Message-State: AOAM532Je5ZoHwlWw+VL52ZjjFY7ZQztD+nusw9YZU6gYJAb6e331KHA czMT3wvRJ976y2TS6aNMvjQZP5gw0UpQ7bNSA80OiLQC1Pg++DNBWwsCbtVcGKvDO7U2NISvRzP 8kpZwVkqX2dWOEB6yaZz0gtOKgWnqVaIIhaGUNqf4isMVlBTh06eYYinqaTK1 X-Received: by 2002:a05:6000:101:b0:1f0:2381:7feb with SMTP id o1-20020a056000010100b001f023817febmr11341565wrx.10.1646401303979; Fri, 04 Mar 2022 05:41:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy11lLVbxwP7056+U/QeHtd5cRAT3ZOIH9YBsx0ZVis+TvzJppWpX2v6qJj7awPluy83lwb1Q== X-Received: by 2002:a05:6000:101:b0:1f0:2381:7feb with SMTP id o1-20020a056000010100b001f023817febmr11341547wrx.10.1646401303739; Fri, 04 Mar 2022 05:41:43 -0800 (PST) Date: Fri, 4 Mar 2022 08:41:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 34/45] headers: Add pvpanic.h Message-ID: <20220304133556.233983-35-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Cornelia Huck , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , zhenwei pi , 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: 1646404398454100001 From: zhenwei pi Since 2020, linux kernel started to export pvpanic.h. Import the latest version from linux into QEMU. Signed-off-by: zhenwei pi Message-Id: <20220221122717.1371010-1-pizhenwei@bytedance.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/standard-headers/linux/pvpanic.h | 9 +++++++++ scripts/update-linux-headers.sh | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 include/standard-headers/linux/pvpanic.h diff --git a/include/standard-headers/linux/pvpanic.h b/include/standard-he= aders/linux/pvpanic.h new file mode 100644 index 0000000000..54b7485390 --- /dev/null +++ b/include/standard-headers/linux/pvpanic.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +#ifndef __PVPANIC_H__ +#define __PVPANIC_H__ + +#define PVPANIC_PANICKED (1 << 0) +#define PVPANIC_CRASH_LOADED (1 << 1) + +#endif /* __PVPANIC_H__ */ diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers= .sh index fe850763c5..839a5ec614 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -214,7 +214,8 @@ for i in "$tmpdir"/include/linux/*virtio*.h \ "$tmpdir/include/linux/const.h" \ "$tmpdir/include/linux/kernel.h" \ "$tmpdir/include/linux/vhost_types.h" \ - "$tmpdir/include/linux/sysinfo.h"; do + "$tmpdir/include/linux/sysinfo.h" \ + "$tmpdir/include/misc/pvpanic.h"; do cp_portable "$i" "$output/include/standard-headers/linux" done mkdir -p "$output/include/standard-headers/drm" --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404558458801.2665173595359; Fri, 4 Mar 2022 06:35:58 -0800 (PST) Received: from localhost ([::1]:55856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ92D-0007yj-E7 for importer@patchew.org; Fri, 04 Mar 2022 09:35:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Bu-0004Js-Sw for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Bs-0001Dj-HK for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:41:53 -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-602-d5IZAKMANnWn3SBhNCEhRQ-1; Fri, 04 Mar 2022 08:41:50 -0500 Received: by mail-wm1-f72.google.com with SMTP id 26-20020a05600c22da00b00388307f3503so1071610wmg.1 for ; Fri, 04 Mar 2022 05:41:50 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id l12-20020a5d6d8c000000b001efd2c071dbsm4909827wrs.20.2022.03.04.05.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:41:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401312; 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=k3FB3bferdbl03k+KFKWByjScfRpd+RvVcbGHdUp8Wc=; b=g7zyz4fSZ6RNBH/rYj8qKmRKOGW/sBvSnMo1k4n8KuUmueAgWkqmiRtG27ohXlrcRo4S4U YK2MymW0qJr/lBtdohkYXfIDPhFBLYU8vBl9fMidFGzk0IxoJvTkFapa5vmuXBWaX3sgEY ZTL0HCbz10vWDv+wx2nOVN4k0014bpc= X-MC-Unique: d5IZAKMANnWn3SBhNCEhRQ-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=k3FB3bferdbl03k+KFKWByjScfRpd+RvVcbGHdUp8Wc=; b=tvnJqg3FAoVZuX8TAbFm9XeB0bGZTzswZ8V8fkbIomxP2iP7H9hcyClLTpytBll0dN ONazhljH/OXjKnRmsjEigVtkRgDW2B0RzwBdoQ5NVt/vA2v7JMHj1qS4aYntjDXv4X0G HNH8hpkOdjyrvWeYIQJXXGtr2NOK2L/g1sr220K0RCxmqb2q35cQOnk80x0EasuZYHP4 tN2sPUpkfstjBJSWCC4rbX0jLM/w4arGAh7MI3yZfcgeT3DI8HfuBusrzDuLz2JomzZr pOXlmuPTTzEo+xL/LRZQb5NzGg0DhmgDBt9yzg1T1vIv62P7JtVTxkJtXWlN2kFyr4a5 7+4Q== X-Gm-Message-State: AOAM531uzrVUfbEcd7Ghk7Y1AxOx652Lx0pMwxVE6OBmeB16BYYYzYZ6 YVpTU/+de5/Sdv51J7XmIxiUHDzRVLIF/1Z4YtmCe5QIGrgA6jimO2D5LAMGPo7WfLr/FFGkJLW vu2TzTN1GcW3aFt1XBBdw/c2/JzUJDaqflUfooI3swAuUm/jxhtHYC4e6hPDK X-Received: by 2002:a5d:534a:0:b0:1f0:5c4b:cec8 with SMTP id t10-20020a5d534a000000b001f05c4bcec8mr5774071wrv.115.1646401309177; Fri, 04 Mar 2022 05:41:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZtuAcK/bje/+bmjJrgk4ULmjTMpqHJtVB2iKvzOy88HfZ8LGE1SU3SuyRpskJxgVXdguLDQ== X-Received: by 2002:a5d:534a:0:b0:1f0:5c4b:cec8 with SMTP id t10-20020a5d534a000000b001f05c4bcec8mr5774046wrv.115.1646401308847; Fri, 04 Mar 2022 05:41:48 -0800 (PST) Date: Fri, 4 Mar 2022 08:41:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 35/45] hw/misc/pvpanic: Use standard headers instead Message-ID: <20220304133556.233983-36-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Thomas Huth , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , zhenwei pi , Laurent Vivier , Alistair Francis , Bernhard Beschow 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: 1646404558979100001 From: zhenwei pi QEMU side has already imported pvpanic.h from linux, remove bit definitions from include/hw/misc/pvpanic.h, and use include/standard-headers/linux/pvpanic.h instead. Also minor changes for PVPANIC_CRASHLOADED -> PVPANIC_CRASH_LOADED. Signed-off-by: zhenwei pi Message-Id: <20220221122717.1371010-2-pizhenwei@bytedance.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/misc/pvpanic.h | 8 -------- hw/misc/pvpanic-isa.c | 4 +++- hw/misc/pvpanic-pci.c | 4 +++- hw/misc/pvpanic.c | 5 +++-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index ca3c5bb533..7f16cc9b16 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -22,14 +22,6 @@ =20 #define PVPANIC_IOPORT_PROP "ioport" =20 -/* The bit of supported pv event, TODO: include uapi header and remove thi= s */ -#define PVPANIC_F_PANICKED 0 -#define PVPANIC_F_CRASHLOADED 1 - -/* The pv event value */ -#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) -#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) - /* * PVPanicState for any device type */ diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c index a39fcdd1fc..b84d4d458d 100644 --- a/hw/misc/pvpanic-isa.c +++ b/hw/misc/pvpanic-isa.c @@ -21,6 +21,7 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/isa/isa.h" +#include "standard-headers/linux/pvpanic.h" =20 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE) =20 @@ -64,7 +65,8 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error= **errp) =20 static Property pvpanic_isa_properties[] =3D { DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505= ), - DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_P= ANICKED | PVPANIC_CRASHLOADED), + DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, + PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c index 62e1be68c1..99cf7e2041 100644 --- a/hw/misc/pvpanic-pci.c +++ b/hw/misc/pvpanic-pci.c @@ -21,6 +21,7 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/pci/pci.h" +#include "standard-headers/linux/pvpanic.h" =20 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE) =20 @@ -53,7 +54,8 @@ static void pvpanic_pci_realizefn(PCIDevice *dev, Error *= *errp) } =20 static Property pvpanic_pci_properties[] =3D { - DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, PVPANIC_P= ANICKED | PVPANIC_CRASHLOADED), + DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, + PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index e2cb4a5d28..1540e9091a 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -21,12 +21,13 @@ #include "hw/qdev-properties.h" #include "hw/misc/pvpanic.h" #include "qom/object.h" +#include "standard-headers/linux/pvpanic.h" =20 static void handle_event(int event) { static bool logged; =20 - if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASHLOADED) && !logged) { + if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", ev= ent); logged =3D true; } @@ -36,7 +37,7 @@ static void handle_event(int event) return; } =20 - if (event & PVPANIC_CRASHLOADED) { + if (event & PVPANIC_CRASH_LOADED) { qemu_system_guest_crashloaded(NULL); return; } --=20 MST From nobody Tue May 14 12:10:45 2024 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 164640404032377.64106698335252; Fri, 4 Mar 2022 06:27:20 -0800 (PST) Received: from localhost ([::1]:33350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8tr-000195-52 for importer@patchew.org; Fri, 04 Mar 2022 09:27:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8C6-0004YL-Vm for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8C5-0001FA-DJ for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:06 -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-15-DKEj8tTDNbmp-J8mzJ589A-1; Fri, 04 Mar 2022 08:42:02 -0500 Received: by mail-wm1-f70.google.com with SMTP id l2-20020a1ced02000000b0038482a47e7eso2826126wmh.5 for ; Fri, 04 Mar 2022 05:42:02 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id c4-20020adfed84000000b001e5b8d5b8dasm6333988wro.36.2022.03.04.05.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401324; 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=Q5Qs0Ta30Dp0mubfWgDTgHCOBS4dk+VOqy8LKgXc+bc=; b=PkuExdsdOy6tabKlOehM+aCTSBSTot3BWvJX8IIOApfBFW1u8oyeM1yhlUJ3GSXSPq60Wj sksLTZR5RciVrpg1cwPsDd381EP3Ws86W0XEMIwIDwNnE38iqerxvln/bUjaFH7mdy2niU HWwh80DOyCqv4APsDGbJdYN7zsVEosc= X-MC-Unique: DKEj8tTDNbmp-J8mzJ589A-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=Q5Qs0Ta30Dp0mubfWgDTgHCOBS4dk+VOqy8LKgXc+bc=; b=jcFm4WcTcjR67gh/21A3175nUETRv6070CxCdtUHCpZ4nz19g8FmY3rzsAAAMthCBv 7CPOEU84Yu3yBNpJTtWit3LXAoaT2KGT0F6zsip3jP5ZPbbR6XIInUKKseedTcWLODFu yyJzBzv8wkiHyYw4f3gdCQpe0dlNQlkkPJvhLxrwWlJ0k24mChnPHh/JLU8qwg8kIs/o YsmGeSR3T/IiycDeXmmQOysX6WeMxdACFIY3fj/cC7BmURUKCYBYZeujvBFhEnTqJeqY 8zvZHZ3ZHmP+TPJFTLw8lPRuL3mcQbNiSaKttWjTWO+Cwrb2tP1WYakhbG6W+3V1639D 8Itg== X-Gm-Message-State: AOAM532DXZCraYMC5lUqPuzadNYzRTChoPIGHQozQH52Z3GhMjFA8tc5 2Hxs/wdWwW7t/9DOHcdx556LeTFcb21VfMCs15t2r/fcTi9nI2uRwhDrg0ogmeC+wncRYV54soj 8qe4CBNUREF1K7ably3X/zIUrPSNHoEGfcueAIHHvPhyCCBDObGupR/W738om X-Received: by 2002:adf:a399:0:b0:1f0:2478:242d with SMTP id l25-20020adfa399000000b001f02478242dmr10789287wrb.234.1646401321150; Fri, 04 Mar 2022 05:42:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxilMuS3bxOncxz++u21kZOgNdbnY/wQEG7gP9fXrryvPTcgLz8QUiI8TUqpLwg/zGmaG2dgQ== X-Received: by 2002:adf:a399:0:b0:1f0:2478:242d with SMTP id l25-20020adfa399000000b001f02478242dmr10789275wrb.234.1646401320909; Fri, 04 Mar 2022 05:42:00 -0800 (PST) Date: Fri, 4 Mar 2022 08:41:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 36/45] pci: show id info when pci BDF conflict Message-ID: <20220304133556.233983-37-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Zhenzhong Duan 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: 1646404041607100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhenzhong Duan During qemu init stage, when there is pci BDF conflicts, qemu print a warning but not showing which device the BDF is occupied by. E.x: "PCI: slot 2 function 0 not available for virtio-scsi-pci, in use by virtio= -scsi-pci" To facilitate user knowing the offending device and fixing it, showing the id info in the warning. Signed-off-by: Zhenzhong Duan Message-Id: <20220223094435.64495-1-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index ba8fb92efc..5cb1232e27 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1099,9 +1099,9 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, return NULL; } else if (!pci_bus_devfn_available(bus, devfn)) { error_setg(errp, "PCI: slot %d function %d not available for %s," - " in use by %s", + " in use by %s,id=3D%s", PCI_SLOT(devfn), PCI_FUNC(devfn), name, - bus->devices[devfn]->name); + bus->devices[devfn]->name, bus->devices[devfn]->qdev.id= ); return NULL; } else if (dev->hotplugged && !pci_is_vf(pci_dev) && --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404823355729.7434465960756; Fri, 4 Mar 2022 06:40:23 -0800 (PST) Received: from localhost ([::1]:36330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ96U-0005Ri-Ay for importer@patchew.org; Fri, 04 Mar 2022 09:40:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CE-0004jC-7v for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60203) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CC-0001Fy-NL for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:13 -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-448-9dXmRQ_4MfGz2DQ9ypKrfA-1; Fri, 04 Mar 2022 08:42:11 -0500 Received: by mail-wr1-f69.google.com with SMTP id t8-20020adfa2c8000000b001e8f6889404so3390371wra.0 for ; Fri, 04 Mar 2022 05:42:11 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id b3-20020a5d4d83000000b001f1d72a6f97sm450450wru.50.2022.03.04.05.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401332; 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=2BxKih/Yy0qiS5QUDi7wjAqw2GnHJ/nwONeXDCjAw2o=; b=aUFB4mLnUVlJ8Uj0fJ81ZETrvtFx8E8CPhGK3VexqDpYfnrBK3RA2m8jPuEmMt+jaUEVdn s5dy8CRo7GdoAPHO6bBztxoKmIQrNvN8cZF05EQWBJJj5uxeNfaKTfgWbt4PV+R/QR31AK ZXgmT0mZSxR3gAo8Dc+ES0S8NKDK1CM= X-MC-Unique: 9dXmRQ_4MfGz2DQ9ypKrfA-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=2BxKih/Yy0qiS5QUDi7wjAqw2GnHJ/nwONeXDCjAw2o=; b=htJ/YmFt0Zwmh/tkKNSxyVULi3J+Y+POunlhzzsIC6+c67Bqd08QuaHed4tiK6kVAZ rUmlg9WT98bobetvApnSf6fKWc36CNXkvtkttZlC4M5KT6UPb+kCmEDR8GWEQPJG2pIZ PX3i/j/ZkcDRJO3+H4YfK8nZN9kCd8Nv9GuXon0ejEC4kajqKqBkyHYe0pQNvFphlA4/ Brcuor+SIOmirm/fhlGlBgyjzjuj1oD9GRG/EjNNWsp89a4KteZXUuKyjxZHp5LZNfhR KCBbdc8jBikaZmpdvwSymWuKkj09ssD63s+nIx07n6ia7IQIjha5/mxfxfgzUG1NR9sB dlXw== X-Gm-Message-State: AOAM530cHpQ4qPJYyGupTpClaKrvpuFkqI5pEi7GnuttwYBScq8vLJFx S+AhWMfrskwiuloCMkzykqvPdhdAa5/U9xtvPSjvgvauVJ+NPHkVpoVcAFqUi8JkFxpze7+EjuX HXaX3/NmDJxHphmX6LJkdLDSns11EvP+0wqUbgE7UduW3vm7vrA+zyXFkgA03 X-Received: by 2002:a7b:ca52:0:b0:381:278d:c5a8 with SMTP id m18-20020a7bca52000000b00381278dc5a8mr7878028wml.136.1646401329809; Fri, 04 Mar 2022 05:42:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuwcUIV5yo/miwd9AxAB4ZWpxzUobHOfvj76JGWHjnRgVHa9Y8vHlln2GXB/5uDa/r6W8AFA== X-Received: by 2002:a7b:ca52:0:b0:381:278d:c5a8 with SMTP id m18-20020a7bca52000000b00381278dc5a8mr7878008wml.136.1646401329549; Fri, 04 Mar 2022 05:42:09 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 37/45] pci: expose TYPE_XIO3130_DOWNSTREAM name Message-ID: <20220304133556.233983-38-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , 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: 1646404825321100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Type name will be used in followup patch for cast check in pcihp code. Signed-off-by: Igor Mammedov Message-Id: <20220301151200.3507298-2-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci-bridge/xio3130_downstream.h | 15 +++++++++++++++ hw/pci-bridge/xio3130_downstream.c | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 include/hw/pci-bridge/xio3130_downstream.h diff --git a/include/hw/pci-bridge/xio3130_downstream.h b/include/hw/pci-br= idge/xio3130_downstream.h new file mode 100644 index 0000000000..1d10139aea --- /dev/null +++ b/include/hw/pci-bridge/xio3130_downstream.h @@ -0,0 +1,15 @@ +/* + * TI X3130 pci express downstream port switch + * + * Copyright (C) 2022 Igor Mammedov + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_PCI_BRIDGE_XIO3130_DOWNSTREAM_H +#define HW_PCI_BRIDGE_XIO3130_DOWNSTREAM_H + +#define TYPE_XIO3130_DOWNSTREAM "xio3130-downstream" + +#endif + diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_dow= nstream.c index 080a6613fe..05e2b06c0c 100644 --- a/hw/pci-bridge/xio3130_downstream.c +++ b/hw/pci-bridge/xio3130_downstream.c @@ -28,6 +28,7 @@ #include "migration/vmstate.h" #include "qapi/error.h" #include "qemu/module.h" +#include "hw/pci-bridge/xio3130_downstream.h" =20 #define PCI_DEVICE_ID_TI_XIO3130D 0x8233 /* downstream port */ #define XIO3130_REVISION 0x1 @@ -173,7 +174,7 @@ static void xio3130_downstream_class_init(ObjectClass *= klass, void *data) } =20 static const TypeInfo xio3130_downstream_info =3D { - .name =3D "xio3130-downstream", + .name =3D TYPE_XIO3130_DOWNSTREAM, .parent =3D TYPE_PCIE_SLOT, .class_init =3D xio3130_downstream_class_init, .interfaces =3D (InterfaceInfo[]) { --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404220424911.2880129020048; Fri, 4 Mar 2022 06:30:20 -0800 (PST) Received: from localhost ([::1]:42008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8wl-0006wJ-6v for importer@patchew.org; Fri, 04 Mar 2022 09:30:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CL-0005BN-HN for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CJ-0001GI-N3 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:21 -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-503-ZnGgRR0hOlGjCKbMRHSaOQ-1; Fri, 04 Mar 2022 08:42:18 -0500 Received: by mail-wr1-f69.google.com with SMTP id ba15-20020a0560001c0f00b001f01822f821so3402468wrb.7 for ; Fri, 04 Mar 2022 05:42:17 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id w9-20020a5d6089000000b001f0256761b9sm6468726wrt.45.2022.03.04.05.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401339; 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=SQth6lOfktpVOUsr0klqFIRbAjmvm/XtYoxQErUCb0c=; b=PJKO3x14InZd3bOR+cfLbyHknHUhzkUWq97iP2Tzlytr/NJVSWF96ed2FazepRvhRkbWZm VPOS+VtL4FfvoS1+HioiqXcNWsGHxYWY3AUfcL4Rcf3Telcb7bG1xCgvxEmtpZYorOtAmM U8+/jIwnSV9f9dHNj/aqBDF+HXDe/00= X-MC-Unique: ZnGgRR0hOlGjCKbMRHSaOQ-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=SQth6lOfktpVOUsr0klqFIRbAjmvm/XtYoxQErUCb0c=; b=qM99z2aWABXQ/NKeF8/NX9aSnWmvmOLg8pkX7HBnWhRCC31smuQvL4AbF9GwADaZin o4Mn3zFtWj+nuPwKnj/U66XEtFIBLXzBU6pLTUfyFvaaRQVAZ8odvqUG7e5v4Ey76+3n jWEKpitV/MJ+unHL5AxcMno/FbKg2zHLHLTWR4hZ8ReMycBAsEO9Hu6QE7lRY0uw7+iy bfp0PNXSoGmX+9w/xaurxn+zJeoeAXBRffAehfP4xNcrmzxJ1ORvJYURmRDwcv1BhsfL xVPePxCG15k97DNDt9N1JteLbRnom/jKgrpX/++0Q8lFdpGexJeisZ4yJtCOzj61xwVU z+Mw== X-Gm-Message-State: AOAM530JlUqqUa8nbvYAwDxQPz5iAEzf08eiMMacuDOBRClzsyu0EtFV zbhF4nP7OC4nW5YE0wkqTI6SMVWHN4nE7oh0Ix2fhQr88v/x8m8abwMon/1GYj81B47O+nEsWNL n9zXw3PZQ+FmrErc4LreD0NBFkZFyMYSpb0/k3+//rs3mA5ce09hGNzIktKLw X-Received: by 2002:a05:600c:35cc:b0:382:441f:897e with SMTP id r12-20020a05600c35cc00b00382441f897emr7951461wmq.127.1646401336459; Fri, 04 Mar 2022 05:42:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyy+f8IWbEMBUzuy4igQQ40LAWgd5x8fjlSNp7ZHBS+d6tJG1NAU602RZ1VQQInQUckAf+FOA== X-Received: by 2002:a05:600c:35cc:b0:382:441f:897e with SMTP id r12-20020a05600c35cc00b00382441f897emr7951432wmq.127.1646401336162; Fri, 04 Mar 2022 05:42:16 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 38/45] acpi: pcihp: pcie: set power on cap on parent slot Message-ID: <20220304133556.233983-39-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1646404221157100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov on creation a PCIDevice has power turned on at the end of pci_qdev_realize() however later on if PCIe slot isn't populated with any children it's power is turned off. It's fine if native hotplug is used as plug callback will power slot on among other things. However when ACPI hotplug is enabled it replaces native PCIe plug callbacks with ACPI specific ones (acpi_pcihp_device_*plug_cb) and as result slot stays powered off. It works fine as ACPI hotplug on guest side takes care of enumerating/initializing hotplugged device. But when later guest is migrated, call chain introduced by] commit d5daff7d312 (pcie: implement slot power control for pcie root ports) pcie_cap_slot_post_load() -> pcie_cap_update_power() -> pcie_set_power_device() -> pci_set_power() -> pci_update_mappings() will disable earlier initialized BARs for the hotplugged device in powered off slot due to commit 23786d13441 (pci: implement power state) which disables BARs if power is off. Fix it by setting PCI_EXP_SLTCTL_PCC to PCI_EXP_SLTCTL_PWR_ON on slot (root port/downstream port) at the time a device hotplugged into it. As result PCI_EXP_SLTCTL_PWR_ON is migrated to target and above call chain keeps device plugged into it powered on. Fixes: d5daff7d312 ("pcie: implement slot power control for pcie root ports= ") Fixes: 23786d13441 ("pci: implement power state") Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D2053584 Suggested-by: "Michael S. Tsirkin" Signed-off-by: Igor Mammedov Message-Id: <20220301151200.3507298-3-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie.h | 1 + hw/acpi/pcihp.c | 12 +++++++++++- hw/pci/pcie.c | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 168950a83b..798a262a0a 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -118,6 +118,7 @@ void pcie_cap_slot_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len); int pcie_cap_slot_post_load(void *opaque, int version_id); void pcie_cap_slot_push_attention_button(PCIDevice *dev); +void pcie_cap_slot_enable_power(PCIDevice *dev); =20 void pcie_cap_root_init(PCIDevice *dev); void pcie_cap_root_reset(PCIDevice *dev); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 6befd23e16..6351bd3424 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -32,6 +32,7 @@ #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_host.h" #include "hw/pci/pcie_port.h" +#include "hw/pci-bridge/xio3130_downstream.h" #include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" #include "hw/pci/pci_bus.h" @@ -336,6 +337,8 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_= dev, AcpiPciHpState *s, { PCIDevice *pdev =3D PCI_DEVICE(dev); int slot =3D PCI_SLOT(pdev->devfn); + PCIDevice *bridge; + PCIBus *bus; int bsel; =20 /* Don't send event when device is enabled during qemu machine creatio= n: @@ -365,7 +368,14 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug= _dev, AcpiPciHpState *s, return; } =20 - bsel =3D acpi_pcihp_get_bsel(pci_get_bus(pdev)); + bus =3D pci_get_bus(pdev); + bridge =3D pci_bridge_get_device(bus); + if (object_dynamic_cast(OBJECT(bridge), TYPE_PCIE_ROOT_PORT) || + object_dynamic_cast(OBJECT(bridge), TYPE_XIO3130_DOWNSTREAM)) { + pcie_cap_slot_enable_power(bridge); + } + + bsel =3D acpi_pcihp_get_bsel(bus); g_assert(bsel >=3D 0); s->acpi_pcihp_pci_status[bsel].up |=3D (1U << slot); acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS); diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 3c44204cf3..67a5d67372 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -366,6 +366,17 @@ static void hotplug_event_clear(PCIDevice *dev) } } =20 +void pcie_cap_slot_enable_power(PCIDevice *dev) +{ + uint8_t *exp_cap =3D dev->config + dev->exp.exp_cap; + uint32_t sltcap =3D pci_get_long(exp_cap + PCI_EXP_SLTCAP); + + if (sltcap & PCI_EXP_SLTCAP_PCP) { + pci_set_word_by_mask(exp_cap + PCI_EXP_SLTCTL, + PCI_EXP_SLTCTL_PCC, PCI_EXP_SLTCTL_PWR_ON); + } +} + static void pcie_set_power_device(PCIBus *bus, PCIDevice *dev, void *opaqu= e) { bool *power =3D opaque; --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404200023100.00564196141704; Fri, 4 Mar 2022 06:30:00 -0800 (PST) Received: from localhost ([::1]:41086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ8wR-0006Lf-ML for importer@patchew.org; Fri, 04 Mar 2022 09:29:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CR-0005XM-AQ for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29180) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CP-0001H9-Gh for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:26 -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-237-wkYLkuGtOEOIWnJZ0LrvsA-1; Fri, 04 Mar 2022 08:42:23 -0500 Received: by mail-wr1-f69.google.com with SMTP id w2-20020adfbac2000000b001ea99ca4c50so3403338wrg.11 for ; Fri, 04 Mar 2022 05:42:23 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id i9-20020adffdc9000000b001f046861795sm4463747wrs.19.2022.03.04.05.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401344; 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=C+16yrqZp55TwfaBLxhPraAA/6nWa+yRsPNvd15Z0zY=; b=KXzi8WkGTBJz+1rKnjc4l4CNKlWR3cRsyPxTQaCdLxA2nOozDG/S6nGY7XPO7qERWqXccs ezvvzzttbtWue4cL2vLaRDzSDxrOJGxc9wQ+AsYGu6J0Wr0bnZPeVp+I6ayTglGqf3YKAC 8c9b9TzwsPRu2FhaEuepB9LLBIJy4k0= X-MC-Unique: wkYLkuGtOEOIWnJZ0LrvsA-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=C+16yrqZp55TwfaBLxhPraAA/6nWa+yRsPNvd15Z0zY=; b=kj+g4nMMRKGkEt6UFqqLd1A81rk7MWQA4mOQDEfTX9gnjjtazRcRzaVI/rtdqWh1Ly 2xGN7nwc52bDu4K+v40CLdzan0m8bb1OV/WYi5dS0367xnmhGLi1/cmoEYQG/fIUI48n e+miOWTVcvMCelEcCsTSGLdoesgltvLIIQMm3wioRYhbKJOg5pfnq8iFpU49bhVEALYp VL9tOC9ZeMSeak9TOzyvcu/mVNWznRE/ZyX+YA8mz9tvph0TQpvG3p+5/MibHNtuFD1m FycwrpsSi0r93c8pGxh1IQj5ot4VZybHdeVcXr3KAoVtv3vbudaxDIVQX90cUQxrvkcs mOcQ== X-Gm-Message-State: AOAM530zj+ycZmfkrNSGl1ce9vhiwwHymlYkpvxebz3EH2iFdJ5ClH+A V1W0kEoR1h6HgXNiDo8L5owST4yhL/w2N4dvp7LFw07/uMH8et7Wqw08BMprAwWfuNseJB9xKbD uSN29l3HNItkpo3XiU4c/yPMsdfsKZqCnL/7QCK8292Og6ixFP5nXocgXpV3V X-Received: by 2002:adf:f849:0:b0:1ef:5d80:c68a with SMTP id d9-20020adff849000000b001ef5d80c68amr26065745wrq.280.1646401342174; Fri, 04 Mar 2022 05:42:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpMP0ZG8/1hibTweaWRDec3ZPo3MkcshTlDyOD1xyszQpvKeaHPC+pFp8xdADgAW7NRnCR4Q== X-Received: by 2002:adf:f849:0:b0:1ef:5d80:c68a with SMTP id d9-20020adff849000000b001ef5d80c68amr26065720wrq.280.1646401341862; Fri, 04 Mar 2022 05:42:21 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 39/45] pc: add option to disable PS/2 mouse/keyboard Message-ID: <20220304133556.233983-40-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Joelle van Dyne , 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: 1646404230141100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Joelle van Dyne On some older software like Windows 7 installer, having both a PS/2 mouse and USB mouse results in only one device working property (which might be a different device each boot). While the workaround to not use a USB mouse with such software is valid, it creates an inconsistent experience if the user wishes to always use a USB mouse. This introduces a new machine property to inhibit the creation of the i8042 PS/2 controller. Signed-off-by: Joelle van Dyne Message-Id: <20220227210655.45592-1-j@getutm.app> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 2 ++ hw/i386/pc.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 9c9f4ac748..1a27de9c8b 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -48,6 +48,7 @@ typedef struct PCMachineState { bool sata_enabled; bool pit_enabled; bool hpet_enabled; + bool i8042_enabled; bool default_bus_bypass_iommu; uint64_t max_fw_size; =20 @@ -64,6 +65,7 @@ typedef struct PCMachineState { #define PC_MACHINE_SMBUS "smbus" #define PC_MACHINE_SATA "sata" #define PC_MACHINE_PIT "pit" +#define PC_MACHINE_I8042 "i8042" #define PC_MACHINE_MAX_FW_SIZE "max-fw-size" #define PC_MACHINE_SMBIOS_EP "smbios-entry-point-type" =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c8696ac01e..32bf12421e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1014,7 +1014,8 @@ static const MemoryRegionOps ioportF0_io_ops =3D { }, }; =20 -static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, bool no_v= mport) +static void pc_superio_init(ISABus *isa_bus, bool create_fdctrl, + bool create_i8042, bool no_vmport) { int i; DriveInfo *fd[MAX_FD]; @@ -1036,6 +1037,10 @@ static void pc_superio_init(ISABus *isa_bus, bool cr= eate_fdctrl, bool no_vmport) } } =20 + if (!create_i8042) { + return; + } + i8042 =3D isa_create_simple(isa_bus, "i8042"); if (!no_vmport) { isa_create_simple(isa_bus, TYPE_VMPORT); @@ -1131,7 +1136,8 @@ void pc_basic_device_init(struct PCMachineState *pcms, i8257_dma_init(isa_bus, 0); =20 /* Super I/O */ - pc_superio_init(isa_bus, create_fdctrl, pcms->vmport !=3D ON_OFF_AUTO_= ON); + pc_superio_init(isa_bus, create_fdctrl, pcms->i8042_enabled, + pcms->vmport !=3D ON_OFF_AUTO_ON); } =20 void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus, PCIBus *pci_bus) @@ -1512,6 +1518,20 @@ static void pc_machine_set_hpet(Object *obj, bool va= lue, Error **errp) pcms->hpet_enabled =3D value; } =20 +static bool pc_machine_get_i8042(Object *obj, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + return pcms->i8042_enabled; +} + +static void pc_machine_set_i8042(Object *obj, bool value, Error **errp) +{ + PCMachineState *pcms =3D PC_MACHINE(obj); + + pcms->i8042_enabled =3D value; +} + static bool pc_machine_get_default_bus_bypass_iommu(Object *obj, Error **e= rrp) { PCMachineState *pcms =3D PC_MACHINE(obj); @@ -1641,6 +1661,7 @@ static void pc_machine_initfn(Object *obj) pcms->smbus_enabled =3D true; pcms->sata_enabled =3D true; pcms->pit_enabled =3D true; + pcms->i8042_enabled =3D true; pcms->max_fw_size =3D 8 * MiB; #ifdef CONFIG_HPET pcms->hpet_enabled =3D true; @@ -1777,6 +1798,9 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) object_class_property_set_description(oc, "hpet", "Enable/disable high precision event timer emulation"); =20 + object_class_property_add_bool(oc, PC_MACHINE_I8042, + pc_machine_get_i8042, pc_machine_set_i8042); + object_class_property_add_bool(oc, "default-bus-bypass-iommu", pc_machine_get_default_bus_bypass_iommu, pc_machine_set_default_bus_bypass_iommu); --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646405011081710.6414998090698; Fri, 4 Mar 2022 06:43:31 -0800 (PST) Received: from localhost ([::1]:44880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ99V-0002tp-Vc for importer@patchew.org; Fri, 04 Mar 2022 09:43:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CZ-0005zm-NV for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8CX-0001J6-Eo for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:35 -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-442-mLd1cRtnMvCNgtb9hk8frw-1; Fri, 04 Mar 2022 08:42:32 -0500 Received: by mail-wm1-f71.google.com with SMTP id h206-20020a1c21d7000000b003552c13626cso4163166wmh.3 for ; Fri, 04 Mar 2022 05:42:31 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id f13-20020adff8cd000000b001f03439743fsm4712911wrq.75.2022.03.04.05.42.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401352; 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=9/XoSsKmPEouICygtljc84b9npXxSXtesafLfFcgh0k=; b=Ivlz2XY/55EseVecEemshW/f4MX+Lv5/KeJXOU4V+6+NAwH1JQSbc39dr8KxK1SSSEoCFh +FG5a+UqXyBA2q6HjjU5aLqhSscR0LNbBxxsvUec1rmdok2gSFG8XNJ+vhtcmkE3cIKVCe 0Gmou8EqvyHTbxYgAWe8Y9wCkkPBwq4= X-MC-Unique: mLd1cRtnMvCNgtb9hk8frw-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=9/XoSsKmPEouICygtljc84b9npXxSXtesafLfFcgh0k=; b=sx1CkA8SUWPnJPiPPcuInDZuv7cnr8+eI/GpKTWsufA0qDzH4sFO4r/WzVqn/nvBcD /Sb+sLCd0Qs7N9yVVVTQuh3qdtKvI0/BEGhjBr7hwHUHPE/DTOFe17K9sdGTiNAUHE6G Wy+2GivCDjgd3sMgcdP0GTj/pjc27W9rc0R9+BhGLzfFmsLvwHXnnXQ/vpLJBk6E27rf qyl6OvSnS8u0TicyRDN5dVvQP8Yu2Sqj2ccEje9QklQXkezTOkiILRxxnvhPdj1DmJmv woHhezEesKITPBPTXVmvamFP4kjj5r4p6YowXZLBNPKA6Ki/ZzsfKJ0byXa6gcsOq94d ZLFw== X-Gm-Message-State: AOAM532LIHFgUZ4QT/jy4ZUrrEUfR3vs4N+wrWPvFTZBNHBP1v8y1+Tk gP12icQ+P0kChNcqUUICBA6LXETErydNc8gqTXdSmDHj+X0ubNz6DakMrH5rBnIjBU7AV9nwVFM Dnxv7yegHu3QcvbudF8Fvi/F69m/WAowm56iqofHVrGDva+NeX3S3GXxysPlR X-Received: by 2002:adf:f50b:0:b0:1f1:d713:34a1 with SMTP id q11-20020adff50b000000b001f1d71334a1mr837006wro.506.1646401350450; Fri, 04 Mar 2022 05:42:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2joQYA8cSC8pMBetEeuEI7Q7SZn5fSGuXAEmv/uosBL0WTLjsSQmmjJrU9uOILAnROpaW9g== X-Received: by 2002:adf:f50b:0:b0:1f1:d713:34a1 with SMTP id q11-20020adff50b000000b001f1d71334a1mr836975wro.506.1646401350133; Fri, 04 Mar 2022 05:42:30 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 40/45] vhost-vsock: detach the virqueue element in case of error Message-ID: <20220304133556.233983-41-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: VictorV , Peter Maydell , qemu-stable@nongnu.org, Stefan Hajnoczi , Stefano Garzarella 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: 1646405012740100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella In vhost_vsock_common_send_transport_reset(), if an element popped from the virtqueue is invalid, we should call virtqueue_detach_element() to detach it from the virtqueue before freeing its memory. Fixes: fc0b9b0e1c ("vhost-vsock: add virtio sockets device") Fixes: CVE-2022-26354 Cc: qemu-stable@nongnu.org Reported-by: VictorV Signed-off-by: Stefano Garzarella Message-Id: <20220228095058.27899-1-sgarzare@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock-common.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 3f3771274e..ed706681ac 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -153,19 +153,23 @@ static void vhost_vsock_common_send_transport_reset(V= HostVSockCommon *vvc) if (elem->out_num) { error_report("invalid vhost-vsock event virtqueue element with " "out buffers"); - goto out; + goto err; } =20 if (iov_from_buf(elem->in_sg, elem->in_num, 0, &event, sizeof(event)) !=3D sizeof(event)) { error_report("vhost-vsock event virtqueue element is too short"); - goto out; + goto err; } =20 virtqueue_push(vq, elem, sizeof(event)); virtio_notify(VIRTIO_DEVICE(vvc), vq); =20 -out: + g_free(elem); + return; + +err: + virtqueue_detach_element(vq, elem, 0); g_free(elem); } =20 --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646405201686904.4859671653202; Fri, 4 Mar 2022 06:46:41 -0800 (PST) Received: from localhost ([::1]:52450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9Ca-0007yI-LY for importer@patchew.org; Fri, 04 Mar 2022 09:46:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Ch-00066X-Vu for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Cf-0001KY-O6 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:43 -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-329-UolcBa-KPTOGNk5X0bwjSw-1; Fri, 04 Mar 2022 08:42:40 -0500 Received: by mail-wr1-f70.google.com with SMTP id p9-20020adf9589000000b001e333885ac1so3369712wrp.10 for ; Fri, 04 Mar 2022 05:42:39 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id e6-20020a5d5006000000b001e75916a7c2sm4618234wrt.84.2022.03.04.05.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401361; 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=pYeaIUsJ9p0JJMezYpclW6q507JeS1XFz2MM26g4c9M=; b=ZHEiqzgQY0FHJ9d/8xVXJReckS40nssz1jFI+Bt7K9kn1UqOIhBd60TMU7K1lgk9To+JJE h3wQcM15+4bDVhxW7dLlvT+LLNvlRPXwuu9xRuulZjMjL7pwIQzEGyuaXSgpAL98FiqD21 L/LmY+u3pLHdllgTFnvQj8vWOtZ0jUI= X-MC-Unique: UolcBa-KPTOGNk5X0bwjSw-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=pYeaIUsJ9p0JJMezYpclW6q507JeS1XFz2MM26g4c9M=; b=zpY9D6LAoRgwPSH7eGg5uFhiCerVUn5+YaiVWyU8IJwItbcU7+riZvIapgvY6NszwB Ug4E63WU+PRCX0W0c7Gw2lCY55TUcgyKnaXEa47hqSDGYiFqCtrZ9Wq2FSLwmKR+X6kM VkefgvGU2DYXl9XJLQFsDO/jl+DiMxjsK5m0uQeCBqaKqfLnCP+vYodSCzanyMidgRrP vmkjLu0OM8QugQEEOKznH6nqA9BkRf4ttGqmYijrE6pobPIqnevd4ruRxY6ntEJGUf18 VC8YT0XR1HVK7ByYzCopZsXbrZSh0vF5bywmYZT41gq8i8IoJZReu5NkDlV0CBoJO+y/ cHQg== X-Gm-Message-State: AOAM533A+IqboeqtGRX/jzCBBJJYwlaMSF11GEAjo9jN0OVaBMygFZQp b5FK2f/WGyGh+Ln9GECMTILWSsiiRdktqg/PmSKLJy/USirWnGNIU4ySuLuQ1HAINLllt6vqfY1 ZfyLe6ZbU5+hTaShhFQGrit4vEQgRbP4lyXdo1tkHhaL9oZXvqevt1qM7QzTK X-Received: by 2002:a5d:638b:0:b0:1ef:e601:e7c9 with SMTP id p11-20020a5d638b000000b001efe601e7c9mr16543082wru.439.1646401358577; Fri, 04 Mar 2022 05:42:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGY6K1j2J200z7b7bnGBCyWa5C4CwwgWOxUNlrEp9fcWFmy8MqGRIfUXKpDa9sgYhQUqxXAg== X-Received: by 2002:a5d:638b:0:b0:1ef:e601:e7c9 with SMTP id p11-20020a5d638b000000b001efe601e7c9mr16543065wru.439.1646401358342; Fri, 04 Mar 2022 05:42:38 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:30 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 41/45] x86: cleanup unused compat_apic_id_mode Message-ID: <20220304133556.233983-42-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Thomas Huth , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , 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: 1646405202119100005 From: Igor Mammedov commit f862ddbb1a4 (hw/i386: Remove the deprecated pc-1.x machine types) removed the last user of broken APIC ID compat knob, but compat_apic_id_mode itself was forgotten. Clean it up and simplify x86_cpu_apic_id_from_index() Signed-off-by: Igor Mammedov Message-Id: <20220228131634.3389805-1-imammedo@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/x86.h | 2 -- hw/i386/x86.c | 16 +--------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h index a145a30370..916cc325ee 100644 --- a/include/hw/i386/x86.h +++ b/include/hw/i386/x86.h @@ -35,8 +35,6 @@ struct X86MachineClass { =20 /* TSC rate migration: */ bool save_tsc_khz; - /* Enables contiguous-apic-ID mode */ - bool compat_apic_id_mode; /* use DMA capable linuxboot option rom */ bool fwcfg_dma_enabled; }; diff --git a/hw/i386/x86.c b/hw/i386/x86.c index b84840a1bb..4cf107baea 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -83,24 +83,11 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info, uint32_t x86_cpu_apic_id_from_index(X86MachineState *x86ms, unsigned int cpu_index) { - X86MachineClass *x86mc =3D X86_MACHINE_GET_CLASS(x86ms); X86CPUTopoInfo topo_info; - uint32_t correct_id; - static bool warned; =20 init_topo_info(&topo_info, x86ms); =20 - correct_id =3D x86_apicid_from_cpu_idx(&topo_info, cpu_index); - if (x86mc->compat_apic_id_mode) { - if (cpu_index !=3D correct_id && !warned && !qtest_enabled()) { - error_report("APIC IDs set in compatibility mode, " - "CPU topology won't match the configuration"); - warned =3D true; - } - return cpu_index; - } else { - return correct_id; - } + return x86_apicid_from_cpu_idx(&topo_info, cpu_index); } =20 =20 @@ -1330,7 +1317,6 @@ static void x86_machine_class_init(ObjectClass *oc, v= oid *data) mc->cpu_index_to_instance_props =3D x86_cpu_index_to_props; mc->get_default_cpu_node_id =3D x86_get_default_cpu_node_id; mc->possible_cpu_arch_ids =3D x86_possible_cpu_arch_ids; - x86mc->compat_apic_id_mode =3D false; x86mc->save_tsc_khz =3D true; x86mc->fwcfg_dma_enabled =3D true; nc->nmi_monitor_handler =3D x86_nmi; --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646405434712684.1220902315839; Fri, 4 Mar 2022 06:50:34 -0800 (PST) Received: from localhost ([::1]:60282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ9GM-0004we-9v for importer@patchew.org; Fri, 04 Mar 2022 09:50:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Co-0006DP-E1 for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26097) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Cm-0001L8-St for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:50 -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-377-xlEq9hlwNOikpg4lXsLItQ-1; Fri, 04 Mar 2022 08:42:47 -0500 Received: by mail-wr1-f70.google.com with SMTP id k20-20020adfc714000000b001e305cd1597so3382110wrg.19 for ; Fri, 04 Mar 2022 05:42:47 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id m12-20020adfe0cc000000b001ede2dd604esm4502903wri.106.2022.03.04.05.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401368; 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=Oz/pT6RHRd21r93UDxWq5uxTXK9PW2uGHjqtboSYYd0=; b=bZl8oMU5DzB5dpQc6hYZsTA+P1WYeVcmx7aGuXXAzzj8DraH6xcUXyl+arrfih7o+8qHCQ GxbQU+jRR+Nvld8ptYr9XFpaXJ3bwpwt3eZW76v/wgwHg316n2//iWif9BWXwuk0EzmSiA GjUTRV8NptEhCulk2iUqxCRkAFgOjoU= X-MC-Unique: xlEq9hlwNOikpg4lXsLItQ-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=Oz/pT6RHRd21r93UDxWq5uxTXK9PW2uGHjqtboSYYd0=; b=z3mSXXKKKKlb7AWak3fpkQAXbllpVj1mcRI12O9ZhNimPU5YKveN+1BZcRv20K7Vnu lH91AaeX+TEswkOLAxuyrM0KxOoRcZrTGs82l7RhxqIGGESV8uPraYanGKmjuhZrrhL/ F43ubzUi/oau42CNH0fs6OOZ2fCmu1dmFD48ENI/0U3egKLKpCQqJufvjtU6sBmCPkWo aYGVMWS1f0rhmKD1SRn0DWE1Wwr82p6gsdAi4IMDzgYtFlSVse0weNPFlcgdB2qgwZT1 LCT/Ba4EP0iu/feyO6xTITKt3Hvq4EEuDBMQxtN3syZ5O8x4MF6yQf/sHrYEiYVIDB8J LO1Q== X-Gm-Message-State: AOAM531Lnj4l2n+G5TjmLeUYrJsF3UzsqqZ+ep8wzaNgPHVseTyFn1Yq oz41LdjjTo3UrMr2xsB+8RQRtHnQp6pyEojkrrmj2nlXCRqGNhZRgyEaZ+QCjjw/sA1Kv76yVBb GBMBsqftLz5lU0ctGqqFAckpZJcGQohBEGQy/mS9h9XsVpWqU4KH9Bre7GzNk X-Received: by 2002:a1c:7518:0:b0:381:c77:ceec with SMTP id o24-20020a1c7518000000b003810c77ceecmr7930187wmc.57.1646401365949; Fri, 04 Mar 2022 05:42:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyISDMi0Og+5cEZNiudGRWUpB4gdwqeGbq3utK59Qgp26eH9aer2OThi7pM3sq5LTEieYfzDw== X-Received: by 2002:a1c:7518:0:b0:381:c77:ceec with SMTP id o24-20020a1c7518000000b003810c77ceecmr7930165wmc.57.1646401365634; Fri, 04 Mar 2022 05:42:45 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 42/45] event_notifier: add event_notifier_get_wfd() Message-ID: <20220304133556.233983-43-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Stefan Hajnoczi , Sergio Lopez , 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: 1646405437468100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sergio Lopez event_notifier_get_fd(const EventNotifier *e) always returns EventNotifier's read file descriptor (rfd). This is not a problem when the EventNotifier is backed by a an eventfd, as a single file descriptor is used both for reading and triggering events (rfd =3D=3D wfd). But, when EventNotifier is backed by a pipe pair, we have two file descriptors, one that can only be used for reads (rfd), and the other only for writes (wfd). There's, at least, one known situation in which we need to obtain wfd instead of rfd, which is when setting up the file that's going to be sent to the peer in vhost's SET_VRING_CALL. Add a new event_notifier_get_wfd(const EventNotifier *e) that can be used to obtain wfd where needed. Signed-off-by: Sergio Lopez Message-Id: <20220303115911.20962-2-slp@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/qemu/event_notifier.h | 1 + util/event_notifier-posix.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/qemu/event_notifier.h b/include/qemu/event_notifier.h index b79add035d..8a4ff308e1 100644 --- a/include/qemu/event_notifier.h +++ b/include/qemu/event_notifier.h @@ -38,6 +38,7 @@ int event_notifier_test_and_clear(EventNotifier *); #ifdef CONFIG_POSIX void event_notifier_init_fd(EventNotifier *, int fd); int event_notifier_get_fd(const EventNotifier *); +int event_notifier_get_wfd(const EventNotifier *); #else HANDLE event_notifier_get_handle(EventNotifier *); #endif diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c index 8307013c5d..16294e98d4 100644 --- a/util/event_notifier-posix.c +++ b/util/event_notifier-posix.c @@ -99,6 +99,11 @@ int event_notifier_get_fd(const EventNotifier *e) return e->rfd; } =20 +int event_notifier_get_wfd(const EventNotifier *e) +{ + return e->wfd; +} + int event_notifier_set(EventNotifier *e) { static const uint64_t value =3D 1; --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404436792698.803403689113; Fri, 4 Mar 2022 06:33:56 -0800 (PST) Received: from localhost ([::1]:50716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ90F-0004Vk-Jt for importer@patchew.org; Fri, 04 Mar 2022 09:33:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Ct-0006FQ-3E for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Cr-0001LZ-KC for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:42:54 -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-509-hPCkZOPAOVq7p44FdrQr2A-1; Fri, 04 Mar 2022 08:42:52 -0500 Received: by mail-wm1-f71.google.com with SMTP id f189-20020a1c38c6000000b0037d1bee4847so4143634wma.9 for ; Fri, 04 Mar 2022 05:42:52 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id z6-20020a1cf406000000b0037c4e2d3baesm11719232wma.19.2022.03.04.05.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401373; 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=/ZxXlOj3fAgvkjAX4A6KwV8H+KbKN1xHiKgMxaMfuzk=; b=XAst3OhQQXSru0Vqw3i80jxF0HchAn9jiqyevtli2TYk83YsSfBTGMKRiuourjLVEYFZZD Zt4ny9sk5RR/m8P5hsr8+DHdPEgyOOz+iBTuIr6r830iFfPxE5XsORk+6LFI4aIpR95RV7 7cbprtCXgsatcdtl/q9gTvlk8J5GCVU= X-MC-Unique: hPCkZOPAOVq7p44FdrQr2A-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=/ZxXlOj3fAgvkjAX4A6KwV8H+KbKN1xHiKgMxaMfuzk=; b=RHXrwMMkmnTvjMt7oS/Th2smAyW3RjgFtlTDv9NQ40uipPiw6dWGDDCUcF7OaIcRft +O7LlFaCFJjd7WN/7s2NArnenRF/Wg/vPbpHSYKzgHgrxMIZWFVtjosc4PJ9iZZrcM5W DuViNZqWJD+Lb59bgfHah8wV2Wr2AgPcI00FEnWkWsMEA+avkjFpoBqDQR4s9Wi53cCy /jIWezYID9tOjkXCFUYNBAjszbtk+FX6mwGXqpSoBTiUWOqMrSYJ33ZgGClgupXbPYmO lBB5zQqMT05HZfMiaSu35tKvOb99AD5rWLvVM9GHxJUiV7HAge3s/915VdXiDCw7+f2I gQFw== X-Gm-Message-State: AOAM5338K8U6wZHUTtsU3sP9/13Bb5rPwm3zDpMHn0O4yxUqeFr6x/yD KUDLAgC1QOIHDS/geSYGSyCD4UEnRy92PNZjs/HGLCkgrtXUQTCL2+IUP+d7w7DZKYoojczfxCN xc24af75Saz1q/2gIwZeStXSNPTrUHLbEBYi4xxaFQMGviRQU5f7NhuMBV4bH X-Received: by 2002:a1c:e908:0:b0:37c:3d08:e0d3 with SMTP id q8-20020a1ce908000000b0037c3d08e0d3mr7732263wmc.97.1646401370580; Fri, 04 Mar 2022 05:42:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzi9Nf7HZG+J2/jekPnAL5h+Qv2phV9WaZIK3tIJvJLPaZ2lJC3Nv9Up8inbzlMsuUwMf/dKw== X-Received: by 2002:a1c:e908:0:b0:37c:3d08:e0d3 with SMTP id q8-20020a1ce908000000b0037c3d08e0d3mr7732247wmc.97.1646401370228; Fri, 04 Mar 2022 05:42:50 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 43/45] vhost: use wfd on functions setting vring call fd Message-ID: <20220304133556.233983-44-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Stefan Hajnoczi , Sergio Lopez 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: 1646404438730100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sergio Lopez When ioeventfd is emulated using qemu_pipe(), only EventNotifier's wfd can be used for writing. Use the recently introduced event_notifier_get_wfd() function to obtain the fd that our peer must use to signal the vring. Signed-off-by: Sergio Lopez Message-Id: <20220303115911.20962-3-slp@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 7b03efccec..b643f42ea4 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1287,7 +1287,7 @@ static int vhost_virtqueue_init(struct vhost_dev *dev, return r; } =20 - file.fd =3D event_notifier_get_fd(&vq->masked_notifier); + file.fd =3D event_notifier_get_wfd(&vq->masked_notifier); r =3D dev->vhost_ops->vhost_set_vring_call(dev, &file); if (r) { VHOST_OPS_DEBUG(r, "vhost_set_vring_call failed"); @@ -1542,9 +1542,9 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Vir= tIODevice *vdev, int n, =20 if (mask) { assert(vdev->use_guest_notifier_mask); - file.fd =3D event_notifier_get_fd(&hdev->vqs[index].masked_notifie= r); + file.fd =3D event_notifier_get_wfd(&hdev->vqs[index].masked_notifi= er); } else { - file.fd =3D event_notifier_get_fd(virtio_queue_get_guest_notifier(= vvq)); + file.fd =3D event_notifier_get_wfd(virtio_queue_get_guest_notifier= (vvq)); } =20 file.index =3D hdev->vhost_ops->vhost_get_vq_index(hdev, n); --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404447535374.5771755579999; Fri, 4 Mar 2022 06:34:07 -0800 (PST) Received: from localhost ([::1]:51676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ90Q-00058j-Fc for importer@patchew.org; Fri, 04 Mar 2022 09:34:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Cy-0006Ra-JH for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:43:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8Cx-0001MK-1R for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:43:00 -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-359-7UVCjXHMNRurHV4AFo_hHw-1; Fri, 04 Mar 2022 08:42:57 -0500 Received: by mail-wm1-f69.google.com with SMTP id h206-20020a1c21d7000000b003552c13626cso4163540wmh.3 for ; Fri, 04 Mar 2022 05:42:57 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id g2-20020a5d46c2000000b001f079ba0158sm1435444wrs.60.2022.03.04.05.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401378; 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=Ii8iFMMNk7vrBv2yovLnxm6+gZzwrn+OMxMvDtJQUf8=; b=A8zEQMbyaJMNjH10h5AMRX9cdrMh+F8HqXZ+/i/JRrcqoFLUksCxFqaGrbYIIdcxzbwED/ d2yiTwHr/u9GnZYPu/AgIBxK6AGFFm/BaF8qzQDnoxl/w5hWFZ0OX7eaYOWZxenDD/rDzP 9GiO/sUK7NWKVS0QcjEisX7sJJ7TMlE= X-MC-Unique: 7UVCjXHMNRurHV4AFo_hHw-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=Ii8iFMMNk7vrBv2yovLnxm6+gZzwrn+OMxMvDtJQUf8=; b=1uV7k2tyeYe0NDCJKzmDzj9233/+mGlsr+bqmtC0NIi9E4Zk/e6PVQM9nAd4ODoJE7 V82u6cDCEXvGfleEtOUYWkyV/gVZLu5UicXGwfHE3YbVKjZhroQV+aOoRoD4WGU1xTUv gWKWPxyKI/8eYnNuH3sV09m24yhzN40/vyEAxI/0tpzWHgTLIIo8JoTdcwz8jpHaVi0/ h8cPmqdACdBuIow5ucl1334ShrI5EcMQwZzglbjZheS4GmD9iaJ1l5A187IpVKppKemk HU8fljhgYwHuAvqonAiGhQombub4UhS7HEtQnY+3UdpcTDJZHpfJ7FBmGS4mbrn4GK3I 3fwg== X-Gm-Message-State: AOAM531uFOV/cZHPDHK1tfADai1V9DhWLmEhcfIJGwoA5LjFQTWnWix1 ayBZ67Mzp3sEWm/6RqoG0WWjqezHmUPLWTiwlj62hzGXm8xFLFAbbwruj5plJ1L8QbVOJ+VUgY5 EExWbNIjT2dTeFdGJMULvRu2znPRcMSy/EGO7Ve9ak+/ndmDDcUEddPaw62NW X-Received: by 2002:a5d:64c3:0:b0:1e5:94d3:5bf2 with SMTP id f3-20020a5d64c3000000b001e594d35bf2mr30202467wri.488.1646401376246; Fri, 04 Mar 2022 05:42:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW6BXjrknuE3ar7zW8Ld9scQsFhwCXO9xapF+r4JuWAfHoqjfvrd8IZMM/IpgW8Wx94e9ioQ== X-Received: by 2002:a5d:64c3:0:b0:1e5:94d3:5bf2 with SMTP id f3-20020a5d64c3000000b001e594d35bf2mr30202439wri.488.1646401375849; Fri, 04 Mar 2022 05:42:55 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 44/45] configure, meson: allow enabling vhost-user on all POSIX systems Message-ID: <20220304133556.233983-45-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Thomas Huth , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , Sergio Lopez , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , 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: 1646404448819100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sergio Lopez With the possibility of using a pipe pair via qemu_pipe() as a replacement on operating systems that doesn't support eventfd, vhost-user can also work on all POSIX systems. This change allows enabling vhost-user on all non-Windows platforms and makes libvhost_user (which still depends on eventfd) a linux-only feature. Signed-off-by: Sergio Lopez Reviewed-by: Stefan Hajnoczi Message-Id: <20220304100854.14829-4-slp@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- configure | 4 ++-- meson.build | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index c56ed53ee3..daccf4be7c 100755 --- a/configure +++ b/configure @@ -1659,8 +1659,8 @@ fi # vhost interdependencies and host support =20 # vhost backends -if test "$vhost_user" =3D "yes" && test "$linux" !=3D "yes"; then - error_exit "vhost-user is only available on Linux" +if test "$vhost_user" =3D "yes" && test "$mingw32" =3D "yes"; then + error_exit "vhost-user is not available on Windows" fi test "$vhost_vdpa" =3D "" && vhost_vdpa=3D$linux if test "$vhost_vdpa" =3D "yes" && test "$linux" !=3D "yes"; then diff --git a/meson.build b/meson.build index a5b63e62cd..28612fca36 100644 --- a/meson.build +++ b/meson.build @@ -2714,7 +2714,7 @@ if have_system or have_user endif =20 vhost_user =3D not_found -if 'CONFIG_VHOST_USER' in config_host +if targetos =3D=3D 'linux' and 'CONFIG_VHOST_USER' in config_host libvhost_user =3D subproject('libvhost-user') vhost_user =3D libvhost_user.get_variable('vhost_user_dep') endif --=20 MST From nobody Tue May 14 12:10:45 2024 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 1646404710059824.1992872754488; Fri, 4 Mar 2022 06:38:30 -0800 (PST) Received: from localhost ([::1]:60338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nQ94f-0002bs-27 for importer@patchew.org; Fri, 04 Mar 2022 09:38:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8D3-0006l5-RR for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:43:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:34849) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nQ8D2-0001Ma-7l for qemu-devel@nongnu.org; Fri, 04 Mar 2022 08:43:05 -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-645-0kusxn2XMFuU-KNXIhr_NA-1; Fri, 04 Mar 2022 08:43:02 -0500 Received: by mail-wr1-f71.google.com with SMTP id z16-20020adff1d0000000b001ef7dc78b23so3374101wro.12 for ; Fri, 04 Mar 2022 05:43:02 -0800 (PST) Received: from redhat.com ([2.52.16.157]) by smtp.gmail.com with ESMTPSA id bi6-20020a05600c3d8600b00381590dbb25sm17511657wmb.3.2022.03.04.05.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:42:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646401383; 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=u98pZphtEuNO4dhvyopEU2A+hxzxAEs+t90wrkCxxYA=; b=fryeqqq+OgFhWqiXkF5ito5i1UGUzcZd4/j53c0Ow+kPsumeVD59GL2ROYOiKM1isT6L1X 8bp7qVCI6Zihm6WDAUE3pjGOUK1V/lcU6bpoc5Q33LwNt1pqQFLR8Gi+HT2ul3+yNHLLaR yVohmwD5vfwuVQ9YkEVV5cAi1b+vclI= X-MC-Unique: 0kusxn2XMFuU-KNXIhr_NA-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=u98pZphtEuNO4dhvyopEU2A+hxzxAEs+t90wrkCxxYA=; b=7LwiBD+kOyZcMcR70HoD7mLH/VsXQXpV6tDsQcJf6XaW5qt3IEVU2ot0H0MT/k4zkj 4hGmQ1TIbpC00sy3ceLwdrIHydimZyKcgVVuu+ri5DikfmNtiACxMwM302yAGusUD0Hk O271bV/Cv1w0kMrBEXNHA6Ssp0wo0wDTrnrSQw72rKX0SKEOfW/PQIHsGqmNA69sAxD/ e0rimK4r16/pA0JAAVMAT/k2E5DOzRRMJ7egQvKzH+LZ6ndK7708CNIA7OkLJ1GW+gio fCQxLTxXLurgQa+FbMjOY6MWtLus+UC4MiEbCc31uxEZrJn/qDP8H6SZUt9dtkALREd0 zOmg== X-Gm-Message-State: AOAM531Ffy1fTk0MMvuNYP/I7lmeKCUzPEBTighyBEJwIKWJw7nj2H7h p9QHSfyh1mEyPD4WsMy+13QVNKKS9eWTnqVKlm7xUwfBTS3n2McYyv/N62v7i/0eqCUqfUc+HtO X8BxU232EaEdmfT3N3D7/UzB6R92DOjYNBDxRE+b40t7JN4FxXVWro9pSo+2o X-Received: by 2002:a05:600c:6003:b0:381:455d:b571 with SMTP id az3-20020a05600c600300b00381455db571mr7717120wmb.162.1646401381233; Fri, 04 Mar 2022 05:43:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBsWGjV8yDbW5TPj7tMi369y/xBemjDvOxCs78f7ul2y4lBjsh3NMmFNvqMzZHNrPGZXXcRw== X-Received: by 2002:a05:600c:6003:b0:381:455d:b571 with SMTP id az3-20020a05600c600300b00381455db571mr7717101wmb.162.1646401380925; Fri, 04 Mar 2022 05:43:00 -0800 (PST) Date: Fri, 4 Mar 2022 08:42:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 45/45] docs: vhost-user: add subsection for non-Linux platforms Message-ID: <20220304133556.233983-46-mst@redhat.com> References: <20220304133556.233983-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220304133556.233983-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.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 , Stefan Hajnoczi , Sergio Lopez 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: 1646404712716100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sergio Lopez Add a section explaining how vhost-user is supported on platforms other than Linux. Signed-off-by: Sergio Lopez Reviewed-by: Stefan Hajnoczi Message-Id: <20220304100854.14829-5-slp@redhat.com> Signed-off-by: Sergio Lopez Reviewed-by: Stefan Hajnoczi --- docs/interop/vhost-user.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index edc3ad84a3..4dbc84fd00 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -38,6 +38,26 @@ conventions `. *Master* and *slave* can be either a client (i.e. connecting) or server (listening) in the socket communication. =20 +Support for platforms other than Linux +-------------------------------------- + +While vhost-user was initially developed targeting Linux, nowadays it +is supported on any platform that provides the following features: + +- A way for requesting shared memory represented by a file descriptor + so it can be passed over a UNIX domain socket and then mapped by the + other process. + +- AF_UNIX sockets with SCM_RIGHTS, so QEMU and the other process can + exchange messages through it, including ancillary data when needed. + +- Either eventfd or pipe/pipe2. On platforms where eventfd is not + available, QEMU will automatically fall back to pipe2 or, as a last + resort, pipe. Each file descriptor will be used for receiving or + sending events by reading or writing (respectively) an 8-byte value + to the corresponding it. The 8-value itself has no meaning and + should not be interpreted. + Message Specification =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 MST