From nobody Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693204550252.45867076979266; Mon, 7 Mar 2022 14:46:44 -0800 (PST) Received: from localhost ([::1]:48762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRM7o-000702-6f for importer2@patchew.org; Mon, 07 Mar 2022 17:46:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5l-0004dp-Li for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5i-00057t-Vp for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:36 -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-133-WYYDBf0TPe6S5LULlz1vvw-1; Mon, 07 Mar 2022 17:44:33 -0500 Received: by mail-wm1-f72.google.com with SMTP id i83-20020a1c3b56000000b00389a203e5adso1099546wma.2 for ; Mon, 07 Mar 2022 14:44:33 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id n8-20020adf8b08000000b001f046cc8891sm12568893wra.24.2022.03.07.14.44.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693074; 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=LAwR8GZmfNZQaQWW3vJvcZ0q0hgeh8uMoNrHh3s63ZXLKb9rgEcRonPVYEfLp1xALs+K4B vZV43GwjOP+zx+GB9fgZrlIQcYZdT/PpfnXZNhCpZsV3Fvvav0td8KgWPEi/04uVxJT3Rh l7QuSFgcM6hpHEYkMQMUEg3+UTnMtFQ= X-MC-Unique: WYYDBf0TPe6S5LULlz1vvw-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=OQ+MwGkRLnf7mpuWGQ9aUHxXSJTtZc63u5Lps+d0Jnym/S8l4wpMIAHJL1UXeIhiJp CizmbhF4K+mbZwr7jiSFk2huJdkTsvyHzdPbQCC+k5pNAugV3uC5Hp/lB674ID0e3YoO Udm0kio8estD7MsKHW1l0E26YqulXcNdJWpFdJF5AvntDWvLQeg3cTiAxfU0lTzbjBWo ImkCqzxw86kMFWfi6QWunWYWIy7QYxus+8HDg6Fl5YFHjx/pGQqxnIwzbXraxERzoFRC 18wPhdjuI7ttnbGWXghwyqmQFDz4ewOdlSvsAAMqR0hhD00zQkvHKwzWdeCsobkHfk77 JdSA== X-Gm-Message-State: AOAM532cc6BWEmrI7Bp0sFEmG1nQ2oOd7pXZHshPmR61YNWdUGAcOIGV zLlBRfUa4qfAGmxgJttl7TcUtKY3tjQaT4YNpyxeMPQrSG4KIVMlg2JdJDIKJvY47JmPmMLM3WY V5X3+HdBlV5MQq4J33gKf+nLZif1bOoAK+jM2g0BsDNTjA729axhlwbLCivnp X-Received: by 2002:adf:c792:0:b0:1f0:769:9ef3 with SMTP id l18-20020adfc792000000b001f007699ef3mr9542890wrg.336.1646693072033; Mon, 07 Mar 2022 14:44:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3YVgoYHE33IK1MAB4NxcNb6Bt8HDOgyFgSjiZrYpJG41hGh69MyCtBC9LSE93xoVPgpC4eQ== X-Received: by 2002:adf:c792:0:b0:1f0:769:9ef3 with SMTP id l18-20020adfc792000000b001f007699ef3mr9542879wrg.336.1646693071767; Mon, 07 Mar 2022 14:44:31 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 01/47] qom: assert integer does not overflow Message-ID: <20220307224357.682101-2-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693206834100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693376632443.3870521874111; Mon, 7 Mar 2022 14:49:36 -0800 (PST) Received: from localhost ([::1]:57312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMAZ-0004RQ-HN for importer2@patchew.org; Mon, 07 Mar 2022 17:49:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52388) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5o-0004hn-TO for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5m-00058H-S8 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:40 -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-12-N-xQteptPEanRgq36Qno7w-1; Mon, 07 Mar 2022 17:44:37 -0500 Received: by mail-wr1-f69.google.com with SMTP id f9-20020a5d58e9000000b001f0247e5e96so4975548wrd.15 for ; Mon, 07 Mar 2022 14:44:36 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id t184-20020a1c46c1000000b003814de297fcsm502826wma.16.2022.03.07.14.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693078; 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=btUOmHNExKsS5izzzi40yrx10s0UB7rvMTptivWeNzU/74yYkw3Lh+Vo4pMxkFbYrJyMzl +lX/U4erOwzypKbzkOGH/n2QD00SWhw9Q0kp6+JnWAk3j5xy0ykPHz4OWJ/ecvDbuTazwe THoDXqyxKGyYOAtqceF6LkMMAIMyC1w= X-MC-Unique: N-xQteptPEanRgq36Qno7w-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=tD9I5scAogdoHiLDN0IglXMNcFao6yEb40w7RgcbKrgIyDIJqQmh8u+Ll0wB+Ikj/B Ug+Ekdkz7gGAMbNLtxwJ1AHwS5BcgyI6KiWbb3bfADInip+UmzQcZ8fvL5sWbV4BxhJm +NyojtaDvkuyOqYJ4XTKIYRQDZKN6hn/5MBwCaSuxOCY8DrXjDD1VRhE9Eod0Hc7mHjZ pq0L31ZxfbUveM/ut0k1HPo6qPeVG6Y//hWFedX8V85ISSDKptLUbWFz/GtakxcVxklC zPYLKQtIyJubFkNH0xDEmdyzuWXDdBBxCQ/P6HHtOcYIDqX3eXEoyV0e9mywqgYQMHa5 8Pcg== X-Gm-Message-State: AOAM532tDDgMHB/7Jcu4V9mvk+djgrOkhzuE9yDGYDWaOdlzEHbEvnkc ObCk+rnG/FxoPVHfukZYAKXqv11F+9/1vbQ1ALm6y2TMMhBam1DFiBsLKaeXfSqhJK3VE7gSbD2 2S0ZakHSR2KGzdTHUQRyqHbqG2jk0JlIjcac1YDr3dWoabZUe26LrtuZBWYtM X-Received: by 2002:a05:600c:4e94:b0:381:84cf:e9b0 with SMTP id f20-20020a05600c4e9400b0038184cfe9b0mr957698wmq.79.1646693075304; Mon, 07 Mar 2022 14:44:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpB9PyJxobBGWoQdXltKhFNDU7qfziU0QT1LaZLtsaog8td5wwbEqsG5gDw3a5UC8PSUpTkg== X-Received: by 2002:a05:600c:4e94:b0:381:84cf:e9b0 with SMTP id f20-20020a05600c4e9400b0038184cfe9b0mr957672wmq.79.1646693074916; Mon, 07 Mar 2022 14:44:34 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 02/47] ACPI ERST: specification for ERST support Message-ID: <20220307224357.682101-3-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693377418100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693504103252.33390259888097; Mon, 7 Mar 2022 14:51:44 -0800 (PST) Received: from localhost ([::1]:37514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMCc-0001nc-SS for importer2@patchew.org; Mon, 07 Mar 2022 17:51:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52402) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5v-0004vs-QU for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5u-00058u-6d for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:47 -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-258-AWZChO2kPeqJceL1uwifKw-1; Mon, 07 Mar 2022 17:44:44 -0500 Received: by mail-wm1-f70.google.com with SMTP id m34-20020a05600c3b2200b0038115c73361so5687647wms.5 for ; Mon, 07 Mar 2022 14:44:44 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id p26-20020a1c741a000000b00389ab9a53c8sm503871wmc.36.2022.03.07.14.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693085; 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=J8hjvivNveUzTs3QPCADKFoqMEjpWHj/oU9/i5tKk1LAWnxitx6Nh8JECukXYj0+FQdbfv j7oHY+fpqS+nbRYhJAKtfQuq1GMwHkyrltC4J5VLJGb2DuzCFWJKPRIBAOmOroZIq9URWm wfLbIOZrjZaR8ulj1MP7Rct9QMw+UWk= X-MC-Unique: AWZChO2kPeqJceL1uwifKw-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=08Mf/X/A8ZT+WtPR8dm03HXLJNOcGLdRHHlrbwvK/Vu5RhxCH0vJ8AZ+b09sFsTlC5 N1+RWZcLRit+43PbnkjfNpIbGRGjCXFkeEKzH7qiv5nSgElu/LfwW0vLOLhFA92I40+L Ps5itVTeuvHToAoIfazYFn0pJH0tAykKobqnOy/b9qA02Cl+rBbqLfiVL1WAHaIsHov0 ZukRc2OXa05GXL0dPHL0+lqtTXl8QaIM+oS9TKWwPX6mtMrst+Q3SWE+gHpbbId5v//0 gw/lxzj6In5Fm7yz3LJG7/8o52QEp1n2flRhN39sHYXEXi6wbb8D8qYdT9HtkELgNR3N 4icA== X-Gm-Message-State: AOAM533UgXKbsEhB3edJjrXmUuNcO3U3Z9mNbg8J7JYJpzetdUtosXrE 0jj5CqU7tOWrogk+MXt+EFMqMf1HFe3aBI6z5js3C1uGW/oLq+pB/8rjy/imyBDU31B1j16N6ej OrxK72e+SMEu7qmGclndeTThXMjQCyRMl0U6yViRi9PN3UFSYcpHYInmMCq5k X-Received: by 2002:a05:6000:154b:b0:1f0:4c09:ae5e with SMTP id 11-20020a056000154b00b001f04c09ae5emr10208106wry.610.1646693082698; Mon, 07 Mar 2022 14:44:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbr7OnJct8Kg8JYebCmODfwt8gVfiBKAvvsY1mRh4S/BZqaeD0P2opyDE+8hzBThwzyvqusg== X-Received: by 2002:a05:6000:154b:b0:1f0:4c09:ae5e with SMTP id 11-20020a056000154b00b001f04c09ae5emr10208089wry.610.1646693082435; Mon, 07 Mar 2022 14:44:42 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 03/47] MAINTAINERS: no need to add my name explicitly as a reviewer for VIOT tables Message-ID: <20220307224357.682101-4-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693506253100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693680685541.7029650062896; Mon, 7 Mar 2022 14:54:40 -0800 (PST) Received: from localhost ([::1]:45932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMFT-0007RR-Em for importer2@patchew.org; Mon, 07 Mar 2022 17:54:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5y-00052Z-Hg for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41736) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5x-00059A-2S for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:50 -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-102-qRtZ9trqMyeth4zu7g0h7A-1; Mon, 07 Mar 2022 17:44:47 -0500 Received: by mail-wm1-f71.google.com with SMTP id 7-20020a1c1907000000b003471d9bbe8dso392180wmz.0 for ; Mon, 07 Mar 2022 14:44:47 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id z2-20020a056000110200b001e7140ddb44sm12329972wrw.49.2022.03.07.14.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693088; 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=SdddsIh/EdZPI3Su3eDtQA7r3EKU/NUlVse25wP6P519eME5gvqoZbq74mAv+NZsov6dFJ I20FP6KmZDxRt8sVCYK2seBOlOvvHZXwYmqycHvtkYG0lLVUAJp4v0eloJk28mSI2gn9FR qYj/6fv0Db04LKsYaBuGZMuoXuCBdU0= X-MC-Unique: qRtZ9trqMyeth4zu7g0h7A-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=0hk9upPzNidTCh3dhkugOiKiR67VADUhJyVdbZutcCocnIUqxd/+J1UZdIVenOLEWW NRKmLCAAULVHM3Pa2gwzBp4IITpVxMYX8iYF3SKbDUiRHKEb0hh0Zr4RtVQkcihWczir hH785HrNJfbDxuBKejcwLTCb4cyIJhcoswnJ9L/t85NZO8bdVjKkRT8EJ4p43RjISnlO 1mPzgZPCPjp0MzHbVCFU3IQXfx/0vbZy4WKyro/3IobF2wSEDBDYTPw8lEA1zx2CjG0j yMgiQtn1bH1j9INRuivHFizocEAc2S1rSPjz6yMNFMaW/lbGS44CR9zM72BWVnQj/qHW i7Qw== X-Gm-Message-State: AOAM531OU1WZXyXbGtXV9CBfJ2QsW03NxP1X4ps7qPbzahviv79H4B5t a+AaQECbUesOM95s9gwWKxe+kZ8qyyBrBFUhHDPS7Frww0ar0cfljNVBJpg2bqwk9Z8UGn7y9VB zN1GvQvenx/Ufh4f6ob9FN9bRzAVeEV0UMsPKPeqXHCss3elesk76sonQlS/2 X-Received: by 2002:a05:6000:15c1:b0:1f0:73d6:b716 with SMTP id y1-20020a05600015c100b001f073d6b716mr10050701wry.293.1646693085838; Mon, 07 Mar 2022 14:44:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJybdP4MfGEn7e4GHlftw/OBAJcwTtCE/kdChexelbkYJUfkuesH5EYdsLyfcbKLqgx/PqnymQ== X-Received: by 2002:a05:6000:15c1:b0:1f0:73d6:b716 with SMTP id y1-20020a05600015c100b001f073d6b716mr10050686wry.293.1646693085560; Mon, 07 Mar 2022 14:44:45 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 04/47] docs/acpi/erst: add device id for ACPI ERST device in pci-ids.txt Message-ID: <20220307224357.682101-5-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693681397100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693225840942.9620824083524; Mon, 7 Mar 2022 14:47:05 -0800 (PST) Received: from localhost ([::1]:50292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRM88-00087E-KH for importer2@patchew.org; Mon, 07 Mar 2022 17:47:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM61-0005BF-G2 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM5z-00059o-Ut for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44: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-642-_bGtdt5YOcW2FrWRwlXBrg-1; Mon, 07 Mar 2022 17:44:50 -0500 Received: by mail-wm1-f72.google.com with SMTP id k41-20020a05600c1ca900b00389a2b983efso1522349wms.4 for ; Mon, 07 Mar 2022 14:44:50 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id l1-20020a05600c4f0100b00387369f380bsm559485wmq.41.2022.03.07.14.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693091; 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=dJk4N9cfHx8iC/f/gW6XfwUp1mU09ndBS5B7XunZz+SAJfonWPI+dYf1nNQDWdeaH+CK9L A06vWohta9OTjD/Ru0ZVPBDKodx4ed0+4ukng0d50NaqaowycC+WkfnAG7jnjJvcnVoisJ Hv+Hpd8uajeR2nmOYvZbHaQdNs2sCP4= X-MC-Unique: _bGtdt5YOcW2FrWRwlXBrg-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=MyzvcjufwFKiTg/fC1HuGlwxIB3rEN3/F6L59Nb7lj7UFu1uaKuOPy4EqWPav4BjyC QuuSYkkjS6KRbtF/L5bwf/qorGF0tWfClyB10RO6hzEYQBprg/vJ6QuE7yBjzFrJNNjW 1FYBrx8+pXOamNM03sgjjE1jGmuhurMIBxRkBldJ380aJ65u0dGphMblFqTBDNRGF09i gUbrZeDtyKzc4v5iPmPLpHr43GikkrU9nLvWAgkANZdsx+xiAiA0dJND9WcQVKgPyFDs FuE66cQZJfNO/aoWX6fODAWsHrpaY4zlnfco00f9FloS+OzQNXBHmcuTjAXEAOH0i1R8 ijWg== X-Gm-Message-State: AOAM531iVCdhUvxkH2XJeaxb2CjXgSjwnfD/TDia40sEae8mWEzypMYb +QIMZRqqNf5S7OPXFKGHT/33nxspnJuMlH0GkH3yn7oXbKT2IcuBY0xUQprh369wMWOs6PGNwy9 XphsC9SrNUhhcQrKxVgZSSeNpWRF2fbPTpWKCslzl0kiYfMpTnK/M786F51j9 X-Received: by 2002:adf:fd87:0:b0:1ed:e0c3:a2d4 with SMTP id d7-20020adffd87000000b001ede0c3a2d4mr9793226wrr.374.1646693088991; Mon, 07 Mar 2022 14:44:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXjZMkZBEl3acmUYbbTCGqNDvce3SIqqoITJH0nA4i8M5V2jv/60u0wK/RHWjWVxuNDiMkzg== X-Received: by 2002:adf:fd87:0:b0:1ed:e0c3:a2d4 with SMTP id d7-20020adffd87000000b001ede0c3a2d4mr9793212wrr.374.1646693088693; Mon, 07 Mar 2022 14:44:48 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 05/47] hw/acpi/erst: clean up unused IS_UEFI_CPER_RECORD macro Message-ID: <20220307224357.682101-6-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693226490100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693377414817.0432446851919; Mon, 7 Mar 2022 14:49:37 -0800 (PST) Received: from localhost ([::1]:57454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMAa-0004Wz-DF for importer2@patchew.org; Mon, 07 Mar 2022 17:49:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM64-0005Lo-OI for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM63-0005BA-0K for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:44: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-399-fumoszzqNK6AsARJE-kn3A-1; Mon, 07 Mar 2022 17:44:53 -0500 Received: by mail-wr1-f70.google.com with SMTP id p9-20020adf9589000000b001e333885ac1so4959308wrp.10 for ; Mon, 07 Mar 2022 14:44:53 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id a10-20020a7bc1ca000000b00389bc87db45sm511219wmj.7.2022.03.07.14.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693094; 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=cz2AlnyMOPos7XtIg6Pt3lpC9VTbNolhb9WXaGMONe0Oug/+hRu0zvt0WKpUJBcmCgBSJD 4IEL7ntlWRS+4z50EcgUrGc1txPErSClrpZZrRjMF6EZz9OtTAjZyZoMaleBuDeH6oWLAZ MeeBAuxUEyfgcgnFWlL/7oiu6jbdS4s= X-MC-Unique: fumoszzqNK6AsARJE-kn3A-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=kRZFw7hWVh6lX0ElCbpT7xQrWtchkaJT0C3wVCvPJL5p1FQSJXBJhIOLe3KeDYDSQo RufbxpNMWE5JpFCrFBw5NOZP1hs9vGnvOu0SO4EbxD6CPGWzbHin0jxtUsdo4NOUMheA /gqctAS3i/ULk0z05OSnD1SZcmtAa17xkmNsOaxoKGkvKHf1ZxHMkUjOabQOd6jYVB4J 1wgsIM1d3MOerVOGJ6FsRqhneoH0PboOHqq77J6Px2nauA5tlSr5RmZU+ObGEJLJxS2O bpev/Wlle4SaCGf+mXkZshg/BUnQ9cC6upWZK0t3K3j+o78669dI/M5v2w2T1NR4zfTv 7GZA== X-Gm-Message-State: AOAM533MzrMW5TqZEgZFHd/tUuGKgKiK/6Nx7u2pfsy3rGtF84zFpn/Q yZ2YZr1kt5UyIFXfBG5bBCUGRCbrEPIc9AT6tzlSLr+2BSzrXevAcdWYr7F2WTRBLuDbuMaZfRX s/8BoC38GD9XGtNX9Vga1+lKEAPgZI60N3xosL/UQbmx2F3RICVDxVKi6Dkrv X-Received: by 2002:a1c:7518:0:b0:37c:7eb:f255 with SMTP id o24-20020a1c7518000000b0037c07ebf255mr965729wmc.29.1646693091897; Mon, 07 Mar 2022 14:44:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyffPg7hlkRcMB12+KPBtPjghljemO9pZamnHJDhVZZ38Fuw0gAyz6syyhOF/wS0D4PV5XvHg== X-Received: by 2002:a1c:7518:0:b0:37c:7eb:f255 with SMTP id o24-20020a1c7518000000b0037c07ebf255mr965711wmc.29.1646693091554; Mon, 07 Mar 2022 14:44:51 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 06/47] hw/smbios: code cleanup - use macro definitions for table header handles Message-ID: <20220307224357.682101-7-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693379445100003 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 16466934173649.574010223107166; Mon, 7 Mar 2022 14:50:17 -0800 (PST) Received: from localhost ([::1]:58656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMBE-0005N2-CQ for importer2@patchew.org; Mon, 07 Mar 2022 17:50:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM68-0005Zd-Ex for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43703) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM66-0005BP-MD for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:00 -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-355-59ijM4-LNm6BbtC1cZlLLQ-1; Mon, 07 Mar 2022 17:44:57 -0500 Received: by mail-wm1-f70.google.com with SMTP id f189-20020a1c38c6000000b0037d1bee4847so244618wma.9 for ; Mon, 07 Mar 2022 14:44:56 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c4f4d00b00386744cb31bsm510995wmq.35.2022.03.07.14.44.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693098; 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=KmbSC+Z2+KmfLwRd27NJR7lR3F2QXIDdrqiM6b5USMwExmgndogtnc/RCqDtEQR3WQJbEZ A4r8Y9rSuIjxtmE5YN4U5kvvdbXLLVkaSgGlE8b5KLrlMrkmbjNF5dYDmCydEVUkllcx4J MjLwQCyw+uRm1/QXbi9eqQ3LP5vXkG8= X-MC-Unique: 59ijM4-LNm6BbtC1cZlLLQ-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=EFsOIWepoEa5u6P+R0rfqDsAwvcqNIhDcJkRl9h46Rm8P9WbWVDpQZ6dpZ1Bt49dw9 AoF1+zMrg+t27bcGdlu13Fe0OhjUfRIrJaixIQU6KGVNbw7ivo4NQUgyhuZPlhRTZ7N6 NhdMgu/3ed1nqWopE8HKMvoRa5yx8q0x9R3mgDXVCNvqKSkDQRjhRCiZFMDnssltN5bU sz1yqkIp3bCmcrecRZuTrMCE84WyIbC39J8XjMo4I5wMs4nsJi3UICxo4gk6X0/ZveFd Sk/uHUhLmxC+a2Ws9Mjc/oht+w03UUhWy1WEyljLzoUqNHzV697UYva125Yp9gSIM4oy 3Zhg== X-Gm-Message-State: AOAM533xpAHc69gSoYfbFmuSpM7+Y9Gwvu1QforkhQMTPgjjIBPRR6CX yPqwWGOWZ++yGfW11oVwa5/ktztt1000pXQecT1xK3R4e8HjPzy7tBG6Pig3DuR42wsSx94VEat qZUmh6u+Ow+Ns5WinbvQmNxRguqV5BnrO1N7EUrcGNMg38yFusCTHHtBxij0D X-Received: by 2002:a5d:4bcc:0:b0:1f1:d6f8:89f5 with SMTP id l12-20020a5d4bcc000000b001f1d6f889f5mr9891846wrt.713.1646693095520; Mon, 07 Mar 2022 14:44:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJySd38TeVyVOHwscoMxxdGABDHFKaEcY5RseWSQs4jg+cpGq6xFOUrhImgy942xcm4JRt4pqw== X-Received: by 2002:a5d:4bcc:0:b0:1f1:d6f8:89f5 with SMTP id l12-20020a5d4bcc000000b001f1d6f889f5mr9891834wrt.713.1646693095216; Mon, 07 Mar 2022 14:44:55 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 07/47] hw/smbios: fix overlapping table handle numbers with large memory vms Message-ID: <20220307224357.682101-8-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693417649100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693235294402.37040055522357; Mon, 7 Mar 2022 14:47:15 -0800 (PST) Received: from localhost ([::1]:51228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRM8I-0000L8-6d for importer2@patchew.org; Mon, 07 Mar 2022 17:47:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6A-0005fG-Q7 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23724) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM69-0005Bc-5d for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:02 -0500 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-501-qmCP-15GPTmIyKG2B5i2bw-1; Mon, 07 Mar 2022 17:44:59 -0500 Received: by mail-wm1-f71.google.com with SMTP id j42-20020a05600c1c2a00b00381febe402eso277650wms.0 for ; Mon, 07 Mar 2022 14:44:59 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id y4-20020adff144000000b001f022290737sm12192179wro.6.2022.03.07.14.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:44:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693100; 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=B6E65T3L5kqMb76mSsPyBZGHLWf6U3Ta+rI/FuuVeAJF6yI9xI7Cnki28KLI3yuIx6JVDF zDnzMoKGxjaK9xDBPiApBugNJoKCxx3QjEmbtTjjz7JCeaGkBjOUDAQqfg8f39OLuShuO8 Hsiln2fDkjCaPCgBIkp+CPAEv6+Whf8= X-MC-Unique: qmCP-15GPTmIyKG2B5i2bw-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=E33WJy2oc77KuxFV4Jo1b4FOJm9wHzvCkiYlOTUDAv1QbX6HpSS4qN6pEvNn7AMDfo 15j1m/fVXam0NRNq/ZK5qGab3AG6hc1IQm9d0kRQ713NuioDY9RlcvRS6WQ4LCrG1k+9 JXKEGUcR2OyQ58T3q/EoCkX47Hjw5jJxf2ilKEn/iH5FjNsugMCMaQa1dYU7u5g4dBQn uGmxoMXgbq6kgTCGmHDNLcdpqvsoxTzn9/8Z4gcubs1VbGLizTjZ4zdInqZfDBLEfPs+ BcgLhDQ5NL1mUgF0VXOV1nhyDu9e5EoMkx74/UEAWJ+u6olUNb9iR2/Y1gqftrWeAj5S b/Bw== X-Gm-Message-State: AOAM530FOFuiEN1jJ3Oe5bmIItB41wkuN+2UYdb6bgNShjrNXfBmd8PR M0P2vJtEVzubDQRRu0Y4LZAq7ENTUGQPUDqkpEptetdrfK4cWQqXkqbprnacYxh8ELerRi31Mr5 XJon3TLx9IgArJh+mFdgbsA9bRWHQJYWy6ls0+x9e33Lg9e83l7safyVgRlwG X-Received: by 2002:a5d:6251:0:b0:1ea:9412:fc8b with SMTP id m17-20020a5d6251000000b001ea9412fc8bmr9696542wrv.657.1646693098157; Mon, 07 Mar 2022 14:44:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9QpEJ2I5ppjKApkbgSZm2QTNENduLUwByX0eEsHTwCKsUU3IdzYOq6WKK51yisp8BZWv6/w== X-Received: by 2002:a5d:6251:0:b0:1ea:9412:fc8b with SMTP id m17-20020a5d6251000000b001ea9412fc8bmr9696530wrv.657.1646693097877; Mon, 07 Mar 2022 14:44:57 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 08/47] hw/smbios: add assertion to ensure handles of tables 19 and 32 do not collide Message-ID: <20220307224357.682101-9-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693236561100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 164669354343417.57363426666609; Mon, 7 Mar 2022 14:52:23 -0800 (PST) Received: from localhost ([::1]:38764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMDG-0002do-10 for importer2@patchew.org; Mon, 07 Mar 2022 17:52:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6D-0005pt-Rm for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6C-0005NJ-8Z for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:05 -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-582-Nb5us9nPN2qZrvp8EPq8Ng-1; Mon, 07 Mar 2022 17:45:02 -0500 Received: by mail-wr1-f72.google.com with SMTP id l10-20020a05600012ca00b001f1e4669c98so1289104wrx.23 for ; Mon, 07 Mar 2022 14:45:02 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id n16-20020a5d4010000000b001f07772457csm9127654wrp.101.2022.03.07.14.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693103; 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=FlanAXUpqzUhrOnI4ojyOTv2DRxzW3nslpkNBjgk98MBdg6jmL7Kyj3jjn2wyrj15n6Hpp WLXiQzXkl7+sEWa5Zb4wH6xdINlndgiyF+ekQpWQk3Nuo8efe+9kMQjRYnVwCUE5mtU+Sf IJD3hzmvuV29mAlS2iNdVVvvIz9rYiE= X-MC-Unique: Nb5us9nPN2qZrvp8EPq8Ng-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=4AXx2kVKcTeClDbS99oKvApY4RSwXgNg3CWCOT2SpKhHueTvZ5DlBR7oVZf56ZBBn+ oaiR80RMOIKEQ4kw74zKW3OjtMNquHHa22cr6E6Xcg76dJ+RJ16TgMgwihSAGyAfUkJ3 ccwM2FA+NF7jqD5Dn/gzPYglz+JDNPLWOIKRmru2pOvIsxZTh1nxmddPlL9XQouOc5Tc cjdK2X4sgTHhTknL03cknmBEIyVaOsKaRPKA6c9vHzzjsPMC49PdE/7VvJ388IcSnz83 qHDoCVRNpmZG2LYH069qqz0qSFT2VtSLB6v8zrGQeueXklAHH8Egi95G8Xxi7Is4Pn9w VGQg== X-Gm-Message-State: AOAM532u9v+SeGKkdjxjgjn90sVjG1e9N4yCAmO5whADmGdA+4Wyu7wU mtd4T1QJGOf804sqJz+q/raZQ1+q6Ns+aMuGhK/o4q6j/5LNC0ur/aQpGr4D2+C3AezQLgeXJZK ZfLZnuinKCiWnTI3m+h5m0dxvHOzuVOm+YUbdVyrHyrB8hFUooAzOFJiYRKw0 X-Received: by 2002:a5d:5746:0:b0:1ea:9643:92ac with SMTP id q6-20020a5d5746000000b001ea964392acmr9858990wrw.597.1646693101114; Mon, 07 Mar 2022 14:45:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwv0epJJcONpFJuqPgmHfisWgJXGpB/ff+mGu/Ta/7BASqYc0xpU6hqSl2ynAoc/Zpyc98/IA== X-Received: by 2002:a5d:5746:0:b0:1ea:9643:92ac with SMTP id q6-20020a5d5746000000b001ea964392acmr9858978wrw.597.1646693100806; Mon, 07 Mar 2022 14:45:00 -0800 (PST) Date: Mon, 7 Mar 2022 17:44:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 09/47] vhost-user: remove VirtQ notifier restore Message-ID: <20220307224357.682101-10-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693544679100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693694231515.5401575000577; Mon, 7 Mar 2022 14:54:54 -0800 (PST) Received: from localhost ([::1]:47208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMFh-0008K5-4r for importer2@patchew.org; Mon, 07 Mar 2022 17:54:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6J-00062c-CQ for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6G-0005O1-0P for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:10 -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-256-HvGvY7ZxPXuV1ePsBTcFqw-1; Mon, 07 Mar 2022 17:45:06 -0500 Received: by mail-wm1-f70.google.com with SMTP id 14-20020a05600c104e00b003897a167353so218534wmx.8 for ; Mon, 07 Mar 2022 14:45:06 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id a14-20020a05600c348e00b00389ab74c033sm532839wmq.4.2022.03.07.14.45.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693107; 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=W4bPOBS/piqKWWgX+Q3LbGHPGiOpCsENVApqT+TK1yOcE+yozFV386F35p7SX/PHpL+mFw zk84qkUdChUHRJSWa06gT/TXtfMGcQF3oMZDww7ehz09W+JqkX0v5WEPEYYRwJd6nzCQxS YRQEef5QEV079DuVS6OYXIbhxuRES2o= X-MC-Unique: HvGvY7ZxPXuV1ePsBTcFqw-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=XLcCDqGnMVzB0bV3rGT9mn1vsEWDnHpPbgywGaN4re/PbsV2jFg9Wv7VADhIrF//Tk +LDvhTsPMJdzFGf+QSkf+SEh+Rct8TuKnqnHj6LhkruNqny8RR9MjR1HMn4bJKTJE1TP jBoHm18z9+4YmfX7245wsjrr1vo6YPJ9MxhfG5PmEIq1MfLjWcVdx/00J7YrbRgoMkhy tqpr125JRd+zRyVuwmf5NwF6AQLbC9wbT7ZL/4D0O4pQg9S1WAra9nioSwD9KRqYhhz3 1ig9+yijz4wWTMvGYvLhqZBEeCmKVsFWaP7aKP+g7C0As5YMLOfprsyNjo/1WkYbLP2D JEHg== X-Gm-Message-State: AOAM531v84omc1wiVGlQ/E7Cw2YVLchdABMqFgXw0q9lJ7eDlUZgmPh3 lqqyY1GpC30SG38T57Ib5WVEgaKsi/H/aKSM+MooW3P8hAr9vMtjhVXLOLAEGb1X3tGwN4GVF1G xZ1WZkGtnB4Cnx7+hGEPD9Q3ml9RQQq2N7c9oiP25bGE0Bq9dwAH0bRerooad X-Received: by 2002:a05:600c:644:b0:387:4a84:8a92 with SMTP id p4-20020a05600c064400b003874a848a92mr961886wmm.164.1646693104577; Mon, 07 Mar 2022 14:45:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuv/tM07RRppYuUIDgIPegm8oPx/6DEenV/B7uJ/qzZpRoz0MhFq7MdPe8kRqVIYQio2ytRQ== X-Received: by 2002:a05:600c:644:b0:387:4a84:8a92 with SMTP id p4-20020a05600c064400b003874a848a92mr961870wmm.164.1646693104244; Mon, 07 Mar 2022 14:45:04 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 10/47] vhost-user: fix VirtQ notifier cleanup Message-ID: <20220307224357.682101-11-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693695477100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693506017619.7588197272388; Mon, 7 Mar 2022 14:51:46 -0800 (PST) Received: from localhost ([::1]:37670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMCe-0001tr-RQ for importer2@patchew.org; Mon, 07 Mar 2022 17:51:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6K-00065r-Ro for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53079) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6J-0005OX-21 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:12 -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-114-gUiQ5TKJPfqHCDoOzekFXg-1; Mon, 07 Mar 2022 17:45:09 -0500 Received: by mail-wr1-f72.google.com with SMTP id f14-20020adfc98e000000b001e8593b40b0so4952676wrh.14 for ; Mon, 07 Mar 2022 14:45:08 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id f13-20020adff8cd000000b001f03439743fsm12359207wrq.75.2022.03.07.14.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693110; 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=dmNra4NOtrq5pJZDU0+5FulxZR4GMWqnL/31Tp7ItpMKdUhIRCBQkqBAklSPrpEur9+Sfz 1scagH+ZP0E2vCksFtJq5QUGZPc26a0u3/mp2qAW5bPHjKdljIRWEE19E/DRBZ1X9L7g+a RxT1sRMoO3U3uiccrBEPXWl4hFaIODU= X-MC-Unique: gUiQ5TKJPfqHCDoOzekFXg-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=AhZMnAOR5us/VwVz+1BV6FHSsuHt/2z4cr9ENbATMe4+ViJmDt7Tiv+pn3mk1VF9R4 D0K0iefdsPMDyt5JDIen12m7vOkeWqVY/czJD/m+5p7EebXKiwza05f9BotcOdid9Qm9 BqFgrjpGdKp0iN/zrLFu78ohZlfB8EFCHhxvbOAcACxA4Q2WTHUM0dZlz9KbJY1QrU0c 9HjvRD8OcbQVhG5IKHG+CR09QBjrTQKf0ZN1ADMDGQETzOxEGmsO85iSxcykvkXq1AH3 HcLxM6nyyfyV/6eIcsmTlAKt0YCBmz/cX1qsbsyinimzENL9URm2F15Aq4xs75SrhjJA ZQWA== X-Gm-Message-State: AOAM533SfeHKp7uqJlxxzKWCAZOeJZQrIKjZqTwrUzbxGMEUJfX3Th1v RYqXqob8K121zveg/es6SdZLzW8kLu3PL21liMqBXiTqixGTV1BzHDT+8NvviKi2KAo+VKfwh8U fpdO5gUHK+BMN6M4o1VPHUWnTO3n5H0myRSfy1K7XVzw4M5IM2lf7aXpFJAyI X-Received: by 2002:a1c:6a08:0:b0:388:73a2:1548 with SMTP id f8-20020a1c6a08000000b0038873a21548mr949288wmc.163.1646693107515; Mon, 07 Mar 2022 14:45:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0uDADHhQppZXFTt7jzomXpiia16xpO73+dka978+o11fP7duhSgjDZTsvE01fmXzu2cLyDQ== X-Received: by 2002:a1c:6a08:0:b0:388:73a2:1548 with SMTP id f8-20020a1c6a08000000b0038873a21548mr949258wmc.163.1646693107199; Mon, 07 Mar 2022 14:45:07 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 11/47] virtio: fix the condition for iommu_platform not supported Message-ID: <20220307224357.682101-12-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693506293100002 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693430645405.91490994336766; Mon, 7 Mar 2022 14:50:30 -0800 (PST) Received: from localhost ([::1]:59618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMBR-00061s-K7 for importer2@patchew.org; Mon, 07 Mar 2022 17:50:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6N-0006CI-Nh for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6L-0005PV-Jt for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:15 -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-568-EIIbyrLmP5a4LmUl9cmj_Q-1; Mon, 07 Mar 2022 17:45:12 -0500 Received: by mail-wm1-f69.google.com with SMTP id v67-20020a1cac46000000b00383e71bb26fso5575322wme.1 for ; Mon, 07 Mar 2022 14:45:11 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id r5-20020a5d4945000000b001f06372fa9fsm18755313wrs.54.2022.03.07.14.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693113; 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=KxK7m0sHzgx+Dfdtb2GxY1IzlxTJmXrXEPNuRGdZaOk98a5YTmzhjbmjylK2VFBER/D4dL y4YI9jK0gquCzvbQ3ZrIYS/F1q27OlauL9wCmb96Bd1PnDkPwYX2bVAEAObo7x075TSwFY HUgh7jpWwupK21hiVFduevaHUIB4Zpw= X-MC-Unique: EIIbyrLmP5a4LmUl9cmj_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:content-transfer-encoding :in-reply-to; bh=xYUjGCjqDKAb5NDT97RnxRdsQlEA2CnL9zsqzwpbiAQ=; b=4WyF5/URl6ei1ij4nE/it6FwtTrCZP42W0es4B45cj1UlBz+Wk4j6dt8iIaT1bQwhN siMKcE9UwatgMcqrUuHPXli7tmGGvnKUZB6Axvgg9sbBPjfa7KjT2yOMFL6iAgwJSMaZ dcv00mMveOi+ayuXJeWYaUpbdbQNWuAu2XANAb8R7SwYnfbRgK2K9Yu2DKnF4lDFtnr6 3wJr1Xbs+1g/18ArWVGxOL3+/atijdeYAKqvKoHxVteGkXvQpy8NEY/eH5m0sPCNFa4J paGkVBLgQMK3PGZytPWVcGH6l6pl7ZCfqvk0sOkzKZST9ggkL0lfAsns7rvFFHlMZ7yw esaA== X-Gm-Message-State: AOAM532Xa3Po4y37bfYYZgCuL8IUXHwFDZh5ObSJYmYQ8xFfwFiyRLMc nZoRpvJqu6Q7Ok2Zvn1oxlcteMP3ZGZIup8PpQOHml/89Bq/ycrHcnf7jDY+ldAp+Oasb8vXieq tz47H3kAznriLx1hQ7eoM3EARYFmZ8ciwve2ws8HE+GToXcgimHYOfaRPxQ1s X-Received: by 2002:a05:6000:1a86:b0:1f0:3437:86af with SMTP id f6-20020a0560001a8600b001f0343786afmr9910249wry.700.1646693110725; Mon, 07 Mar 2022 14:45:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwTFFulLOXy8bVaFtIWCGXXB3aycp4KOfREITQBriOu2MSTAj1UD2HKRQ7LYsZ6rbcvPqV2Xg== X-Received: by 2002:a05:6000:1a86:b0:1f0:3437:86af with SMTP id f6-20020a0560001a8600b001f0343786afmr9910237wry.700.1646693110459; Mon, 07 Mar 2022 14:45:10 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 12/47] hw/vhost-user-i2c: Add support for VIRTIO_I2C_F_ZERO_LENGTH_REQUEST Message-ID: <20220307224357.682101-13-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693431748100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693682219187.43587207632038; Mon, 7 Mar 2022 14:54:42 -0800 (PST) Received: from localhost ([::1]:46024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMFV-0007V7-7a for importer2@patchew.org; Mon, 07 Mar 2022 17:54:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6Q-0006E3-TR for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53413) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6P-0005Ra-8M for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:18 -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-642-T-ZJPIbaNDqcjdzR0Urfgw-1; Mon, 07 Mar 2022 17:45:15 -0500 Received: by mail-wm1-f70.google.com with SMTP id d8-20020a05600c34c800b0037e3cd6225eso5689723wmq.6 for ; Mon, 07 Mar 2022 14:45:15 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id e2-20020adfe7c2000000b001f04d622e7fsm12371831wrn.39.2022.03.07.14.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693116; 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=afI4AdlK/jKeFKHhrwfAsWHMDFgxxewu4zusmAT6y6EOPqzc6jbNz/6MBjz805qovHumni UAyrelITPD4WgGzj/Shk57wNtN40O7/mb756J/b+jRWArW3dywebhkCfVYyjSAfoN19Hrc EQdhvCeb4KJNiUYxgAf0TcdRhdGBu/4= X-MC-Unique: T-ZJPIbaNDqcjdzR0Urfgw-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=7xU/cxedBs+2vkfIXp+8TdSnFtjp0csFohDTbofvVy4EUXEhdt5B8/9AvYpJK+tCJD sai5qSMBVF975OSpeDT6xT0+LeB8m1KalgXEJ+frrONWjdTyYKp3tgkXz9fZDFqF7CuN dkfZLahCDqHiISITOLSIcX9skYx4SJLEB/9KsS6hjlESVziv9JibVlw/UAu7iQiWzY7+ 4632NGWTIcxoqve9Mwo74HA+PvF3lJbZL0ShJv/qEdrcsFXnlrtt8LVlu71aNAUiqG3o crlbJBQOpzzRPB4EC+NxchCtIk+NPvt4QwHTn66mczZnkz+51yQrFr76UtqiWSG4iyW8 B4vQ== X-Gm-Message-State: AOAM533s9PtXPkRvH27Hwi3Oj+9HiyQk9zYZYg8AJlWzglTQDqFHPa2v W+7MGlzzq/sqI9iGfX+QM0h5I3Hj4bKN7uhUuFB6WxutI4IJ1L5t5ynSa5fI+XBwNMP8mxkzzrM zFzLD5c7+emJNpUsNEIwB7M+FwBas6M29dYNISYuL3EhR9c76P+8cqi9kL3ZM X-Received: by 2002:a1c:cc06:0:b0:389:79c7:aee6 with SMTP id h6-20020a1ccc06000000b0038979c7aee6mr963249wmb.47.1646693114014; Mon, 07 Mar 2022 14:45:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJynCWlIrfn8wFIMy5dElSa9MlpF5EJIe/zBGuftW7Wc7x7MS4FhseIUpt76UVFOV6ElrEd/Kg== X-Received: by 2002:a1c:cc06:0:b0:389:79c7:aee6 with SMTP id h6-20020a1ccc06000000b0038979c7aee6mr963232wmb.47.1646693113722; Mon, 07 Mar 2022 14:45:13 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 13/47] hw/virtio: vdpa: Fix leak of host-notifier memory-region Message-ID: <20220307224357.682101-14-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , jasowang@redhat.com, qemu-stable@nongnu.org, Stefano Garzarella Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693683382100003 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693923743162.98266384747615; Mon, 7 Mar 2022 14:58:43 -0800 (PST) Received: from localhost ([::1]:60918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMJO-0000l2-Ot for importer2@patchew.org; Mon, 07 Mar 2022 17:58:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6T-0006FG-Kw for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6S-0005TU-30 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45: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-625-kiVZolHiN9a5z7dKPrjRkg-1; Mon, 07 Mar 2022 17:45:18 -0500 Received: by mail-wr1-f69.google.com with SMTP id w17-20020adfec51000000b001f068bc3342so2735709wrn.6 for ; Mon, 07 Mar 2022 14:45:18 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id q23-20020a1cf317000000b003815206a638sm516801wmq.15.2022.03.07.14.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693119; 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=CSSGy1frmrossNBQm+UoblqAcJlljwXg7n11YnSHTf/EJbSgLnz4dmm9Zuxgf7PxVty8ar QxjdGqGWWaLbFeytVTyqMvNYsBmkm0kqCedH56527wi2qOe/S+1us+lw0HWxnljVmBrnSM P5NIye+XgODwgCrZtOVlRz1USoGlVRk= X-MC-Unique: kiVZolHiN9a5z7dKPrjRkg-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=qORBpoGqHKe8XdcrrQqYG/mZpQ9Za+s1mt6am1N1ZCu3giDzIFWp9bCK8zAxJioQzb TUnczpgu0/UfLTquVMQ9zGULvZ2yFPJ85kW8XvW3Xyh6HPZL21+oH6+2rr5th3BIJp/+ 6jt2sCqmwcDQtKptvRl3W+he/UeZE/oYbxppGFI9K9bLnP6LifciCuzSAOkzVL46CapC GsyZ0xnp157UhZxaZBBaRoPjce84Lo7gJmWu9XbwrgEhOskCzU2Q/UAOoZ/Pqx3gnY1h H///+2lpVuCzttC12vlPJrv25407//+su3cE/55caJlc5XrwYZjZTpvq2VGFVCFpYDYs zU9w== X-Gm-Message-State: AOAM532xrevDgZav2ufOJlI5ko+QW6GKdi5XkipzUSwF51HOZFYQrsD2 aXKjC3M5z9Ga5Fp4eB4LiIeIc36CFic9siT/L/rf3MgsJOW6oinVTAfORWYZIdy79dOdbPhSk7S CVZiL2rWiu0CLOOnizCem3p5kZTe9r7rgzkASrT4D4xEd8hz3ijtd3N1ew627 X-Received: by 2002:adf:a109:0:b0:1ed:c2bd:8a57 with SMTP id o9-20020adfa109000000b001edc2bd8a57mr9792491wro.612.1646693116934; Mon, 07 Mar 2022 14:45:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvm61ZXnHOtG+Ro6jtOZO7HiSpPcytwU0cNM0e0fFCDGODMEr8VPkYCouAf0/nzXhqMDNQ5Q== X-Received: by 2002:adf:a109:0:b0:1ed:c2bd:8a57 with SMTP id o9-20020adfa109000000b001edc2bd8a57mr9792475wro.612.1646693116633; Mon, 07 Mar 2022 14:45:16 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 14/47] vhost-vdpa: make notifiers _init()/_uninit() symmetric Message-ID: <20220307224357.682101-15-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693925939100003 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694143137488.61074783760046; Mon, 7 Mar 2022 15:02:23 -0800 (PST) Received: from localhost ([::1]:41006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMMw-0006R0-1z for importer2@patchew.org; Mon, 07 Mar 2022 18:02:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6Z-0006S0-PM for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50304) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6W-0005W9-Ex for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:25 -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-135-CHabOJGLNK6jTsR-vfxlWQ-1; Mon, 07 Mar 2022 17:45:23 -0500 Received: by mail-wm1-f70.google.com with SMTP id h206-20020a1c21d7000000b003552c13626cso260640wmh.3 for ; Mon, 07 Mar 2022 14:45:22 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id p16-20020adff210000000b001f062b80091sm11229910wro.34.2022.03.07.14.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693123; 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=ereKY8MOdjSqaf9UGkm9aT5qgk7E6McvAwG53SjqBdD06YekFym7QjPC3W3dSgjrPferRw k4PcoWfSYo1tdIISbZ0t5k+B8ue+FVzMvrtKlJg+2+b3Tjac+tv0M3s856pxnOwHXbaWR2 k1tpSU1zrZdpXL+XDIXxzTL35cxp5Ko= X-MC-Unique: CHabOJGLNK6jTsR-vfxlWQ-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=NJzZ+5714SZJqe6Td0nfFn301cubD6OuwOH81E25lDAsK0CuHJjHZFkaxGCjf/P7SG r7qTSbyJckt8FKgz32y3IOLu9j4duOW8LRcjE2GFmyOuWjsxrpNbuot6hrB/uusPzHKt Vhjz2ZH4gFsxiPK98IamrQnmREtwPdm/5RR2lWhy7wEMN2jtZ6SEt9QWsIPVihQLnHYM K9r3G3oQHsfxzsW1hcGLXlDwOvu2YJWw9DXZ8sWZO8aKEt23R0SCFYbvWdW/7/py4pQ0 sBgthVstQYNaQ1sls+SpMkrxV5jpAD+q/KTrlXjvQILzVW+BngRsgKaRO12scxv0aYSP 2xhw== X-Gm-Message-State: AOAM532RMZ1z+pEoMWw1WB5Q8+35Fm8Nr3U+NTmVc58ud7LDiV9njXuU WQ0n9iwoqSh++FFshfjfCfcAmyITz5mf9XcfoYwrJ9Mf7Jne2NxTV2XQDd2Lb/1fJL8J2fmoOV0 QWwXJiM4UEId3G9j2P/VhaVTNA0zFBXbm8YpFS4z/yODFme6yhnkrCgFgKTiN X-Received: by 2002:a5d:4811:0:b0:1f1:d736:4862 with SMTP id l17-20020a5d4811000000b001f1d7364862mr10068923wrq.147.1646693120591; Mon, 07 Mar 2022 14:45:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGVwr+7njWHLisP5YQUPK4kGd+LIjm4h53XX0RaHJztJoLqENRby9Ni+uCYg6bghrGlBn7SQ== X-Received: by 2002:a5d:4811:0:b0:1f1:d736:4862 with SMTP id l17-20020a5d4811000000b001f1d7364862mr10068901wrq.147.1646693120233; Mon, 07 Mar 2022 14:45:20 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 15/47] intel_iommu: support snoop control Message-ID: <20220307224357.682101-16-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694143833100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694288267881.9522388748062; Mon, 7 Mar 2022 15:04:48 -0800 (PST) Received: from localhost ([::1]:49570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMPH-0003fG-95 for importer2@patchew.org; Mon, 07 Mar 2022 18:04:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6b-0006YV-Jt for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37940) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6Z-0005WH-TH for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:29 -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-156-RSt4UaU3PB6oPZtr2yQMQA-1; Mon, 07 Mar 2022 17:45:26 -0500 Received: by mail-wm1-f72.google.com with SMTP id 187-20020a1c19c4000000b0037cc0d56524so264667wmz.2 for ; Mon, 07 Mar 2022 14:45:26 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id u4-20020adfdb84000000b001e8d8ac5394sm13277572wri.110.2022.03.07.14.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693127; 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=INIrGLXM9BPeQbOnUVxMdf9eNeZZyx3ffv3mfmzCZ8IMXwbyKo/AaXKlU0SWdMdpd7Uhs1 Dq3FKMPOTrWJ/3k6qiyVnNruTlKpyA/+ZJff3wpgbnmYmaQO91CMmDPx/XjAQ0rLcbKJSD LLmCflVrnD/r95cDVc82EtQW673JKLE= X-MC-Unique: RSt4UaU3PB6oPZtr2yQMQA-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=A91BD/JpzaADUmbUaQ5YA14ayxAeX3gmfIhzQ+0Fp42tE7ELbFf6+zLDKggIZKwv4j KOf7vGJT8gu8HSAyz2MZMK2tLV2F7Nzy6/nqX9VDbpldikjzGjqMnEg1gx9WjPwALtFJ ZmLQkIaqd3eSrKSqu2iWc9wBKIS1yVbOBSvH7T95woLd9yk7/8fPxRqjqsv++6Z0QVCs 2YMfEpuQmQWTUald1ZLcPlWnjwyagm7Iz/E6ZFFDdp6lC6lvPvaAZQXCZluCYQKC7kuJ sCkqqFBEKFYoqfZ5yNp6SoWC/qbikNsO5p9QLSVhygNK2+luQe4WD57QDOboW9y+y6+1 OF4w== X-Gm-Message-State: AOAM530/ehea3VxxhsiSyibll1zIp+tBKpb1u4bYgwQ0Du1yLf0+p8+g ZMlGdCcYQkprxTHjJ+Q/ZuNuNnAin1i8hSxgHZaKjlWOYGco9lEodBsXo7pbru/m2SIw9wurwga W2VIuQDp/kjSom+6O9hTOg41FXACbO2Q297dSUi+w0ieI7ptp2ssePNKI3xri X-Received: by 2002:a7b:c855:0:b0:384:91d1:8120 with SMTP id c21-20020a7bc855000000b0038491d18120mr1013431wml.110.1646693124755; Mon, 07 Mar 2022 14:45:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7NjgGJQLscxD0tdfB/eYmpyLXX4U9b70fYCbkT3omrHQR0JI6WztBBvhvFM2vLMAvBJce8g== X-Received: by 2002:a7b:c855:0:b0:384:91d1:8120 with SMTP id c21-20020a7bc855000000b0038491d18120mr1013404wml.110.1646693124352; Mon, 07 Mar 2022 14:45:24 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 16/47] hw/i386: Improve bounds checking in OVMF table parsing Message-ID: <20220307224357.682101-17-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694288773100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 164669355318684.77084836587426; Mon, 7 Mar 2022 14:52:33 -0800 (PST) Received: from localhost ([::1]:39848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMDQ-0003LI-5f for importer2@patchew.org; Mon, 07 Mar 2022 17:52:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6f-0006pD-7U for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6d-0005Wk-K7 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:32 -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-64-WiBOVI5cNQG66HhlUXbQxw-1; Mon, 07 Mar 2022 17:45:30 -0500 Received: by mail-wm1-f70.google.com with SMTP id l2-20020a1ced02000000b0038482a47e7eso253375wmh.5 for ; Mon, 07 Mar 2022 14:45:29 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id s2-20020a1cf202000000b0038977146b28sm523742wmc.18.2022.03.07.14.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693131; 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=TnfS0Q/HlR03IbD/nIuSBC+bLxoHpWBozJwBFoRSDRFtRBoWGfgJHRlw2qczKYqFJ3PC9j NhKVBvI1CL6xC3CX2e2xCTF/Mk85qloWOJkdTsHgTETkS2Lc7Ywla5oh8jxDNOfvcwiIhX fCfIvjpIQqsVUaNZBoLoE8mXxwvFhXc= X-MC-Unique: WiBOVI5cNQG66HhlUXbQxw-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=H6YR2w3Wgde2KoUgAHznMjwwi+T0O/3wvhfQm67wUIvnVfQ8ZJl7OUtaFQZryFXIue RLgFlN3YlD7ih7ZgRZZ1ph7cHnQqHG26XRbtr3k6maOxvwDFlIfL5lVNI8Ux5pfTz60S Zoepciq5/IKQV88w79DljBlKyKKF9sFWg8J+NDZizoT//6y08HmVISjMhwzkk09aE7Z0 N7ytPJGc6l0pKhipsxOZkCEZCBUIGGjSN0R+c4UlAQLB9Shm+ESu66wl0ADn1OjmAQUt yc3eYaTRmRkJKfd/yyT+MT28QaA4/XhhLdFpd7/Dn/D6s0L58QGejBVJElCd8PYjudfv IqXg== X-Gm-Message-State: AOAM5327guA4FvUF2oEbk4LWrPjSiiw45XYNVjcj2MpyxkT8fKpRbgkK pMDH2rIommedf0d6U/2e2O+pN48GzjHXlgNV1eSDUE5Hqk8qi1r7SjbmXJ1XZ2GLGdOVU3fYs01 PwmGg4zp2IG4SpmhPG2yn8MFdV0qXWdt5eae9OVG/gKW6y3oeM7UYz2RW3a+7 X-Received: by 2002:a05:600c:35c2:b0:381:6cbc:7192 with SMTP id r2-20020a05600c35c200b003816cbc7192mr951580wmq.146.1646693128482; Mon, 07 Mar 2022 14:45:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLZMrYquLUbkvA4xH+9Jdo8NpUQ7WKVr81Or7BxvARLeiHifTUfmd2fhD30uMd+W67/4qodg== X-Received: by 2002:a05:600c:35c2:b0:381:6cbc:7192 with SMTP id r2-20020a05600c35c200b003816cbc7192mr951561wmq.146.1646693128262; Mon, 07 Mar 2022 14:45:28 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 17/47] hw/i386: Replace magic number with field length calculation Message-ID: <20220307224357.682101-18-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693554569100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693849178395.0066541857494; Mon, 7 Mar 2022 14:57:29 -0800 (PST) Received: from localhost ([::1]:55678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMIB-0005XV-NR for importer2@patchew.org; Mon, 07 Mar 2022 17:57:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6k-00076J-Bt for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6i-0005Xa-B6 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:38 -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-657-eGwxXZ40M1CsmrTfptjHIw-1; Mon, 07 Mar 2022 17:45:32 -0500 Received: by mail-wm1-f71.google.com with SMTP id c19-20020a05600c0ad300b00385bb3db625so257195wmr.4 for ; Mon, 07 Mar 2022 14:45:32 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id l18-20020adfe592000000b001f064ae9830sm10674827wrm.37.2022.03.07.14.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693135; 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=PHEodkJFHUVcKkbh77ssYiQF5unxWrJSaeo28rjnNuTJouKZa+/ccoDW7ZSN4G8K+74CM2 2sT8MbLbXHPk4oVt3czfYu0dGyRS2DMeVRg0acFFwqEe002DqfQ886VweOk7eCTTlhdjrk vhd6Mjpy/6R3t9AY8u8yP7A86ZtVcDc= X-MC-Unique: eGwxXZ40M1CsmrTfptjHIw-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=HvQl1gGfNkzq6lg8fZ2Xg3ov1GjPSm8UZk+fluw/63HQlwsvnz4u0eMTZWGvdn4RU3 Dw7WIu4Xy9AXCophsjclJgqJyQtJfoXGUrKkZAKeZHJ2ZyHkhC4dY7tNGiNdZ3su0kre H33+3c6vNkzRFVCr/Um8CFfb8dunTz7atC1wqjIlg8zL/2Uy8Kzu4b/rGF/8OnnplJnP io5wpYCxbcW1wGgEAWIymVgK8uvajp8U/p5Foz5qScYcn5zLfxHfaG/ufiBk9bJnRJoh KoxczCack8oXMMWfGabTzRb2wCm/jwLAuu+nkGGiXkpp/3fT63e6UIGcM7wAoVUFisYy J9rg== X-Gm-Message-State: AOAM530Gl6hD56LtojWSF5nGYZFccdhP6sRFr9sBm29EMT/v7Bez2PNz pt6NOrHheNjbEgd6GaceVfrd2lx64nSyBVvAAkSKumiw/VW09EgoGZY5f1AJ9hLwPK+489eY8R0 s29/nvina5Pk7UHtI+XaOV4cq+LbpRHld6te5+QNdlEF1NhE10DAJ0ZMeYtuD X-Received: by 2002:a1c:7708:0:b0:381:f18b:29ca with SMTP id t8-20020a1c7708000000b00381f18b29camr978279wmi.140.1646693131274; Mon, 07 Mar 2022 14:45:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCAiuL6ov6U1xexMzAE68hoPFv11SGeQiIpqknICk4lyj0oPU2eUCWcd7SkCnbMuK1X55Dag== X-Received: by 2002:a1c:7708:0:b0:381:f18b:29ca with SMTP id t8-20020a1c7708000000b00381f18b29camr978263wmi.140.1646693130966; Mon, 07 Mar 2022 14:45:30 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 18/47] virtio-iommu: Default to bypass during boot Message-ID: <20220307224357.682101-19-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693850700100005 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693716204151.90462211713282; Mon, 7 Mar 2022 14:55:16 -0800 (PST) Received: from localhost ([::1]:48254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMG3-0000aY-7l for importer2@patchew.org; Mon, 07 Mar 2022 17:55:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6l-00079F-2g for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6j-0005YV-9M for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:38 -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-235-l1HbBBJnOg6Yju-nFZEx0w-1; Mon, 07 Mar 2022 17:45:35 -0500 Received: by mail-wm1-f72.google.com with SMTP id c19-20020a05600c0ad300b00385bb3db625so257254wmr.4 for ; Mon, 07 Mar 2022 14:45:35 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id r188-20020a1c2bc5000000b00387c81c32e7sm555903wmr.8.2022.03.07.14.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693136; 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=WxpzfPzQjEbz9apgDruyOL9GWCDmpZdL7H9PaafI3fQ48Qh/s7HHGzGx4O64+6XJPGM40x R32bd3zWBOkg1E91dodPZQ0H/nQxpybi1i8nwHBkuYVEc7nfyGmUfl3D61J/ljrZ1ekoNY Ih5wqKFKLBL9Q/2PHKxsgG86it65nYE= X-MC-Unique: l1HbBBJnOg6Yju-nFZEx0w-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=h/l2NiIIsykCM9BKDDo10gp0pyGQeVB/GRD71RbCSRaVjQWtuSeJfSnwaoGzX9QFUf qSyefeLUunxpZmD1zEWLVAa9wRXSgUNMdpot1g4NRekFYpHyrwWgbITOkwhPj5Y9tT2i 7ujn9WvZ2fpdVxR1r2hHH9l3SwagvDLXbI//0QZfzezxuhWb90MICjtsr598ira5mpfL BvdkrD8rpDmzJuKPt/8Vz4v1xp3nOpvrMwHgqtW+dOdz4QzM4vWHXfzZCDnzUAEZVDsu qv6c+pYqRv5LMlZo+utPiSr42s1mYCYoBYZV/bdJobRI1PR4xVPWEnA5khSAB6sQrKLc DQYw== X-Gm-Message-State: AOAM533HYfkxqre7Zcyg4/+RtnlmrjljwcAd7UJ7tnoK/E20drykpYN2 lMsz6UWe8hYnl1mmYkCfDn9BuP6tI3JCFfo93IRH64re2FOGKdbrW4YiKNllCcdlaEm6D6bwJ40 Wf9BD0CC2quwz7ra/6aL7eGakSGfWc5crsboAJtMiiKbfw4zVa4cjgjB+boyJ X-Received: by 2002:a05:6000:1549:b0:1f1:e566:eb87 with SMTP id 9-20020a056000154900b001f1e566eb87mr8224936wry.87.1646693134260; Mon, 07 Mar 2022 14:45:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXvYljVKBc0F3vp2xlIQ9BYr3eTpyI/pwSXE60ZQ92xuCg6DF2/2bThMgByiEph+8EnLmd4g== X-Received: by 2002:a05:6000:1549:b0:1f1:e566:eb87 with SMTP id 9-20020a056000154900b001f1e566eb87mr8224922wry.87.1646693133943; Mon, 07 Mar 2022 14:45:33 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 19/47] virtio-iommu: Support bypass domain Message-ID: <20220307224357.682101-20-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693717660100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693975145982.8789216122697; Mon, 7 Mar 2022 14:59:35 -0800 (PST) Received: from localhost ([::1]:35900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMKD-0002tO-UY for importer2@patchew.org; Mon, 07 Mar 2022 17:59:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6p-0007Ec-Af for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6n-0005bI-PH for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:43 -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-588-ipo7KVlTN8uZpgxaQ-SDmw-1; Mon, 07 Mar 2022 17:45:40 -0500 Received: by mail-wm1-f72.google.com with SMTP id 3-20020a05600c230300b00384e15ceae4so248442wmo.7 for ; Mon, 07 Mar 2022 14:45:40 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id p16-20020adff210000000b001f062b80091sm11230268wro.34.2022.03.07.14.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693141; 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=GwcAekG9HLfY32Wtd0wvLq1CQcKs0snT95Nh61YGsllvrKbtOOtGPPwJqsl3XV3MlHjRee 68y/RFE4TgXsT5eF/TixMcbH6JzNCIW4NCXwSMUep+MQfvXnCrira/J6RALQA3fCn0QR55 ks+QyDVeGIAC3qidAm+Aeo6EYtstRpM= X-MC-Unique: ipo7KVlTN8uZpgxaQ-SDmw-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=bGcgPVlKELak4n9ozXwaxtdCVQpXMlw7CCwgqO46pLWk0gza9+TnQHOtm0Scrzygaf bRBO7Rb93HTnxQU88OswcowAEjabTYa0Z01nOmrn1gXGcuTOTpMY4mS8BsB0Pjq6I3Fv vnzAUQxAVsOflaxxPfn1cNoFrmK9rZnaipAGyH+clXCcs2OnTM+fmHvxqCS834iqCGSz kYyi9y9ubtdi0H2wpdYXBeJtthYeMWkuDNZG6PAm9QYCJx1TxOQrA0qJY3TUrFBnwRBe KIoNPegbkIhqUxmvrYabqLZiaMm80VLLKkSINoVjBb/nftOA9eNoVLLdU0fkvP+d7U8I 8PrQ== X-Gm-Message-State: AOAM5307I+2pk6FjbpW9cdKorj2c69DiAuK5BXZcMbSn9XfeofSKV4Zj 6FbQiUO4J0CRSX/7cG89aQ640H13yFz0ERPKtJeLKbuWkJbMys0c+huHs6jyWvZAXNWS204rUcB nkzzzx1ydz2hPo/6Nu/qA11C2kjj3gwCySPbEuTJBXQjYwfPezYZO2tUylsdX X-Received: by 2002:a5d:548b:0:b0:1ed:e0b2:188c with SMTP id h11-20020a5d548b000000b001ede0b2188cmr9615834wrv.122.1646693138614; Mon, 07 Mar 2022 14:45:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAMoh1uXk1xvuI+oMV9z+qE+znv2aRFSjT6IrPy4mY9FBReidZ0D2drH3XI5FUSEwd1t8Jyg== X-Received: by 2002:a5d:548b:0:b0:1ed:e0b2:188c with SMTP id h11-20020a5d548b000000b001ede0b2188cmr9615818wrv.122.1646693138279; Mon, 07 Mar 2022 14:45:38 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 20/47] tests/qtest/virtio-iommu-test: Check bypass config Message-ID: <20220307224357.682101-21-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693976369100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694468655563.1712116127902; Mon, 7 Mar 2022 15:07:48 -0800 (PST) Received: from localhost ([::1]:58116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMSA-00010g-Un for importer2@patchew.org; Mon, 07 Mar 2022 18:07:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6t-0007LJ-6T for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:44566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6r-0005dF-NC for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:46 -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-633-XYgw29DnNAa5-f3CTvDJTw-1; Mon, 07 Mar 2022 17:45:44 -0500 Received: by mail-wr1-f72.google.com with SMTP id h11-20020a5d430b000000b001f01a35a86fso4955521wrq.4 for ; Mon, 07 Mar 2022 14:45:43 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id l10-20020a7bc44a000000b003899263bab1sm493798wmi.20.2022.03.07.14.45.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693145; 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=ezHczUZNer51n68XHQRo+8Gd2wahCXeNyLSEi3/WKiI=; b=QywDdwbjCmwXtQvOrzcxUU4pL9uYBxX39fQ2FeB51zKps/Gji/Ppif9r5mfmTuihEiyihw I2mdgAPoHDCNDdH2/GZq4GdJoWFOmjA/edDd5KzXIW7CmVz+JtNbAUOhh9A+YK1EiZXRVf UYEXGnHq5san3zo5sTQ0XCKgBxwDpqM= X-MC-Unique: XYgw29DnNAa5-f3CTvDJTw-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=MmDdVwmPLT3GpviHgCZPhAOAr/6wi/0+WM8vUEzJ9PLJSs2GQSeRgKKXApgieUlANH HU0snto5oIEj/LMizMuNuS4pTUxK+HGG8ZhfeZ85yUd+O8/utUbK6kmdnd33EimEY4jR sedBL8oPaPkNpQGWPElyC5jtJ9oW2d4fVSpbr86Oxtjd+NA4IYL53Br+QY7OfX46J/+U Jws4uZx2DlGuB6vLDBxpfEbYz73Zbe0CBrkx+6GaoejaDIag2egp/Zz1QCHEgixMTfWQ 2KCbNBAt70TzgnPNLwL81YZQtvQiYMMdOkP4G94ngbDZoPZA6w/qYp5hiTCTam9t7bA6 siJQ== X-Gm-Message-State: AOAM532GZRqy9AUuPTGoBdkEnQyRv99eio4oqXFVDUEEA5Ep0Ps9YO2d uD0+wYA96b/atJwUQJziZHPxx/StVpnZKowWEwIU64wEWMrytYp2iZwvSQNbf+YFx3wcA0nZIHG ymSACC8cXJ18uLk4VweujVf8ewqaf+7y/LOtojz7sUpFhQtyj+Tqp4itlQxJn X-Received: by 2002:a7b:ca57:0:b0:381:570c:ed95 with SMTP id m23-20020a7bca57000000b00381570ced95mr945321wml.169.1646693142170; Mon, 07 Mar 2022 14:45:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjtQK2+O9iQR+hwxcI/3iWs55gB8EA67dvBtvyHwRpjKi6oP2KHp6d6Vmxq5i+swUjHvFr+A== X-Received: by 2002:a7b:ca57:0:b0:381:570c:ed95 with SMTP id m23-20020a7bca57000000b00381570ced95mr945302wml.169.1646693141922; Mon, 07 Mar 2022 14:45:41 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 21/47] hw/i386/pc_piix: Mark the machine types from version 1.4 to 1.7 as deprecated Message-ID: <20220307224357.682101-22-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , libvir-list@redhat.com, Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694470238100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693846670373.52577690627857; Mon, 7 Mar 2022 14:57:26 -0800 (PST) Received: from localhost ([::1]:55596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMI9-0005UM-Ev for importer2@patchew.org; Mon, 07 Mar 2022 17:57:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6x-0007Ly-US for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59429) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6w-0005dU-FJ for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45: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-259-ULgUNekROo-aBtLqblRJNA-1; Mon, 07 Mar 2022 17:45:46 -0500 Received: by mail-wm1-f69.google.com with SMTP id l2-20020a1ced02000000b0038482a47e7eso253695wmh.5 for ; Mon, 07 Mar 2022 14:45:46 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id r2-20020a5d6942000000b001f0485057c4sm12563396wrw.74.2022.03.07.14.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693147; 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=dWNvh9OyCWtL++Acco3mxAhwPm7syICK72uX1YBtNhNLfRa/ObNqCtr8aIMB4REtAI9rRe DUdnXq+75i5VN2LK755Fk2HjiT4SvxWBBBrXViwyWO1AzHasMvdULJSuVxe/ddjQlXQalb penx0IZ/u9Ma13FYOH+0a6DGankpMyA= X-MC-Unique: ULgUNekROo-aBtLqblRJNA-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=5dk9uwmebCcqjYGQKdZQJxiBzspCe4BVyXQ2CqQrthUIPmYP0x2yZfMCp5jnjTkv7C UX+j4qcppOyBwarmZ+To23YEo2335Biu6duUnLZ8dWuOqih2coljq3nQNFUHqmmYvA6o Z6bi2i5KgtbVIVlUPZI+SkN0HomINwQK76im940lkeAGxHrnI2+96bVzUhysyNJkADLK 0gMLvxM34ie16rnnUjPSt0jDtOejDQBwsDsNsQ754CA8hCWttuqOye/+cMh3yojC9+Ve f62c/YeJ8/Pu+C2ymUr9T36+pjB00CYJUpPUi8+I6einSCpqXxJlbGluo1WBmegAL6mE l0Zw== X-Gm-Message-State: AOAM532nVIpI+GCJpt59BU2Bo8b12wwq3t5kWfKZtkmnRTfE3Dm2lMIA 3R4z6guOfvyd0csvsyYJr+a9rlV3dDRwU2o2oocf9Ts/vUFVcywamCCa6k3tKP3CM/xMduBvxP1 ClyPN/A2foKQEp9X27jNgqNYSBy/HrM58+bbGiGZJwEPpm0n41hBuGex/WbBd X-Received: by 2002:a05:6000:15cc:b0:1f1:f814:27c4 with SMTP id y12-20020a05600015cc00b001f1f81427c4mr5748702wry.630.1646693145264; Mon, 07 Mar 2022 14:45:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPeuIqQwNR8ax5oKli/Nl48ohu8zY8HLB0eY0cOGmns7ImfUk6e6epk7A9N5KnKkzf/E6wfQ== X-Received: by 2002:a05:6000:15cc:b0:1f1:f814:27c4 with SMTP id y12-20020a05600015cc00b001f1f81427c4mr5748683wry.630.1646693144970; Mon, 07 Mar 2022 14:45:44 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 22/47] hw/pci-bridge/pxb: Fix missing swizzle Message-ID: <20220307224357.682101-23-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693848730100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693865159634.0461347490162; Mon, 7 Mar 2022 14:57:45 -0800 (PST) Received: from localhost ([::1]:56696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMIQ-0006It-Py for importer2@patchew.org; Mon, 07 Mar 2022 17:57:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6z-0007NC-7v for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59212) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM6x-0005df-Hw for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:52 -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-361-H8h9EsNBN2WArR7aC05VCg-1; Mon, 07 Mar 2022 17:45:50 -0500 Received: by mail-wm1-f69.google.com with SMTP id 3-20020a05600c230300b00384e15ceae4so248622wmo.7 for ; Mon, 07 Mar 2022 14:45:49 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id l8-20020a5d6688000000b001f04ae0bb6csm12204928wru.58.2022.03.07.14.45.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693151; 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=a2XDSwROL5w7p56O0MvlsBox6QB+I9+0yw10aGaf/geGe2nwgKOeWxvUNeB/P6M1BgfiFM qA4Lfvp/iB/32VJ0YYmq37FjcUj3NHAnA0EW2LqWIdsgY838v8u9r3bP1AIu1TJc2Blpfa i+3DfYQdov/tuBkpGGCFmOaqilG2SZ4= X-MC-Unique: H8h9EsNBN2WArR7aC05VCg-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=qjZlzgp0HkwysnhkVgQtGBrnlEOGOk7VZlfHsa1Qe+Xkn9KwPBZ5D4qliB3mfBDApD FlCV/VllZ6OTFOWNQKyOW+3XrH6clNggXGk0QHPVjxsVWcKiB9FYm4HubdGhMPx9DXbk RcLH4AvMhJJHYAUcmTejn14gU/rEDmvMwxiHivue0Y+JrgoaZ7U2ayGBSrbYo7Q2BAUN uRCeqAy9Egtc4yuKr42eO+OMuLqEhstdalQ4LWUut0zxOVeKRFZBM7U3Thwtx/EoRg73 3k4oOLphUEU5hPZpeczVZOpaiNR7Jebg2Bo6N3Nfgk+D2fwW9nqxBZga7SzWXj8rxonr MgIA== X-Gm-Message-State: AOAM533V4fkWgSow+9FOHhJtMiesoY+o/TZIEpgdKS7OIr1l9Es0UnsC nMaDygBPkip4lBzxJyPeecOhy9if3gENfwhTzRvKd4T0XDpmnxBwAP+YiBejrBGln9K89jrCnlr apkUaLyYTv16G3Vup61cOfUqUn147rs0NejKhsszuR+SA5IPJLyOyHT+NA2gW X-Received: by 2002:a5d:6481:0:b0:1f0:46c3:e6f with SMTP id o1-20020a5d6481000000b001f046c30e6fmr9813313wri.692.1646693148374; Mon, 07 Mar 2022 14:45:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJy47H1hKhpg3fVe5mpyV+oUIrA5YAWhS8sZYwL0Y1zLzZ5VWU2KLsYjPAwRT4tgDC1LaLzvVw== X-Received: by 2002:a5d:6481:0:b0:1f0:46c3:e6f with SMTP id o1-20020a5d6481000000b001f046c30e6fmr9813297wri.692.1646693148093; Mon, 07 Mar 2022 14:45:48 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 23/47] virtio-net: Unlimit tx queue size if peer is vdpa Message-ID: <20220307224357.682101-24-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693866838100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 16466939955410.7851004702657747; Mon, 7 Mar 2022 14:59:55 -0800 (PST) Received: from localhost ([::1]:37062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMKY-0003gy-57 for importer2@patchew.org; Mon, 07 Mar 2022 17:59:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM74-0007Px-BB for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24255) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM71-0005fk-FU for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:58 -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-577-V6CwmybwPFKQMu0msC9ujg-1; Mon, 07 Mar 2022 17:45:53 -0500 Received: by mail-wm1-f71.google.com with SMTP id f189-20020a1c38c6000000b0037d1bee4847so245619wma.9 for ; Mon, 07 Mar 2022 14:45:53 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id i8-20020a1c5408000000b00389bf11ba0csm521561wmb.38.2022.03.07.14.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693155; 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=In81BUBWfw8rKXLz+vA/cFytfpoAQ2ulnebRoKUc+AldDNRVTz+rhxy8wNhisQEShpxyTl 43PBgIO/iaYtzp9eXu0z4H4tv5GLyI8jufReltg3EgN+8B4bXJ7hd0aoghxIzDugvLI/78 6Kme5Zi8GvmswUjearHlv46J3G138k0= X-MC-Unique: V6CwmybwPFKQMu0msC9ujg-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=QSz52kmgPD8J+bkMQOjs1mcPW0+aMiIpVvtu6GJ3mnYFROKQ1i6BedKEHXfsUfC1/7 YtuBfjvVmIezUkgqaKaEHlEkDbTR864GQAUeDAx0GMBLAtMCQafPMmMHViXJk5kwiILX iQ2OHVkKCMHUvL/BGsjsc99xqmuy4UmkOsgiaSeivtIRteksgqkDOqufEIQ2xh4m1GZp Hqbi4qhQM/cOqXI5mFZjIkn6Wv6aPjIo6+xqHFZiupzp0t43fT7RyUuZ7yzR1Dtiaeqh KWvc/UHfsF8inPQbKmRrsHKACKgU4CNw4ukbYsr//O9pck5lIZ/CKhyPQwqn71mC7Txa 7+mQ== X-Gm-Message-State: AOAM530enh361SXmuegGDeKKgnXHseaO7QTapj98H0fRBvENbWKkS1mV S69qytMelkTX10WGz2aEATo5bgEBLDAitnOQzhA3Q/l7uHvL77UO0JAkO5T50DhMD+9HW0KMKVC 9Hx5yDotY2J4j+uTiybShJg66+SGHAvlVKAttpWESK5dx0P11Uw6a31yBsnvk X-Received: by 2002:a5d:4aca:0:b0:1f0:7a8c:3505 with SMTP id y10-20020a5d4aca000000b001f07a8c3505mr10076184wrs.337.1646693151959; Mon, 07 Mar 2022 14:45:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYyO+zES4TU2IJ5uQdjYoRDZ+NDMyTnm2nvepve+wmVmG1symKEuXuBeId8VRl7o6vjNbHdQ== X-Received: by 2002:a5d:4aca:0:b0:1f0:7a8c:3505 with SMTP id y10-20020a5d4aca000000b001f07a8c3505mr10076156wrs.337.1646693151514; Mon, 07 Mar 2022 14:45:51 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 24/47] pcie: Add support for Single Root I/O Virtualization (SR/IOV) Message-ID: <20220307224357.682101-25-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693996933100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694219716673.7703773379366; Mon, 7 Mar 2022 15:03:39 -0800 (PST) Received: from localhost ([::1]:45704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMOB-00018g-Ej for importer2@patchew.org; Mon, 07 Mar 2022 18:03:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM75-0007Sn-AI for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27248) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM73-0005fu-KK for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:45:59 -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-281-7RRLKRPTM8CBqq-z1kNdHA-1; Mon, 07 Mar 2022 17:45:56 -0500 Received: by mail-wm1-f71.google.com with SMTP id k41-20020a05600c1ca900b00389a2b983efso1523455wms.4 for ; Mon, 07 Mar 2022 14:45:56 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id e4-20020adffc44000000b001f1dba38a65sm7224427wrs.105.2022.03.07.14.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693157; 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=gWTT1hF3CAkzKwftsWgLXg5WLJIYyMearRotjy66uHQxN41gV2PkiL5WgdRuxsDYILqMoa duKexltXm1Rw3hS19q/qX6GBnnlnDSbOpdryNLheiwDm2yTa4S65fKosa9ArFb6RBcW8fc 5rOHwZ7UrsWs3T+o2tFhpo2llNkZiVQ= X-MC-Unique: 7RRLKRPTM8CBqq-z1kNdHA-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=llsrFcNrWiyl2FQV6nGp08hhzFSDCg+ujCv9d82MZVryL151Cz+qdtnpcZdOKch3HP taT/CUCa0EORlobE5VBO7jFHeaJd5ctbiER+T9X2PA2ToevR0Cz2EQ4c6YUdtOI7MQmF ZlT/T7qcekIWCusUr+J/xHLiopQu9ijcWdAzjyxvrOjooGULVpfO9mTq65pPp5E/s/Zj f7bKHL14LmHwDdWF0hLaz5sLvBeQJpJJUhPYQtQSkAcIL+GuWCFrZFCWuEhYASulvpjo U+/VeU6VWlWkXoJCshVcVsnnHkWpWNvWogVx+tDfU3q4uqObg/gIMSpdwsYnEgUtFL/S Qv1w== X-Gm-Message-State: AOAM530PO2oMIMSRZAWYytk1Ax8hy685HAzpp3YvBiHpIq0MNvvZBTGC oL2K14vX1t/atTulxrqlCz42/nqmm/yVml90h9JzD+IcN0gVOCn8Ln3zOSxmkupT6pLU3+oaPG8 snLXlvIHoU1UR0/RMg00GD01FYZ5Xq74s5CwXhSCvutWPjyJ0Thwot0meBuSs X-Received: by 2002:a05:600c:21ce:b0:389:9052:a1ca with SMTP id x14-20020a05600c21ce00b003899052a1camr957035wmj.123.1646693154576; Mon, 07 Mar 2022 14:45:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyR9nUmAYqcc1LgYxOrqk7znhEb6OF7cUmgCc9/2XE/Jm313M50W7dQpXpe0bA9LOr2LMMmFg== X-Received: by 2002:a05:600c:21ce:b0:389:9052:a1ca with SMTP id x14-20020a05600c21ce00b003899052a1camr957008wmj.123.1646693154146; Mon, 07 Mar 2022 14:45:54 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 25/47] pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt Message-ID: <20220307224357.682101-26-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694249813100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694400159239.81440864718672; Mon, 7 Mar 2022 15:06:40 -0800 (PST) Received: from localhost ([::1]:54288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMR4-0006qa-Uj for importer2@patchew.org; Mon, 07 Mar 2022 18:06:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM79-0007aL-6d for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35422) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM76-0005gN-Ip for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:02 -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-413-BfWGDvXbNDWwV_rU2JQcww-1; Mon, 07 Mar 2022 17:45:59 -0500 Received: by mail-wr1-f70.google.com with SMTP id o9-20020adfca09000000b001ea79f7edf8so4965608wrh.16 for ; Mon, 07 Mar 2022 14:45:58 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id f1-20020a056000128100b001f04a47762dsm12091944wrx.109.2022.03.07.14.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693160; 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=eRAdbPMN9cUm4iKIEjqP+8OmklPmZd+EOh/pFdgXBvKNwI2e8H1Hy/slnwldCxTZEIoqeX tnMsKpI4jtocvDTy5pZFFltcYHVHFO7yZ/1Y8v3oLKEsAXFnC+7jgo2iQKNMdHwAwQnehN 8XrwKd5Fhe/dxm6gQ5UnvUNjFD9GmoQ= X-MC-Unique: BfWGDvXbNDWwV_rU2JQcww-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=hpqF1FvXPTexD2rEcAJFAZI21TE9dYoa2z8iuxwUYgwq6APmRVLX22NzoCKm6eQZsg NfIZMxUAeauktjPc3z1J2aOq6310sRtfIcb3bAVElXZYZXj/cElVhi1z4zbQzyl6NZ1I 3vj0UrXsy1beVyqSB7RXK35bAH1zAfPi26oirUyoi6Lda9LvWv+pWBB8CLWvBPGGiAL4 JrToeD7CiZlEzgTvvj3XbIgz2OH5mXZgw68jwxIaU+dPuASsEAX+W2zv9qvnSFxTybd4 j+KLa2YaEzyh6pey3GwxAImxeRsldm2C2Bq4cHtOYVbfelfTUqE/Qe9/+QkqM7s9Pt+j +aEQ== X-Gm-Message-State: AOAM5333pDPduVQcEfb7mG/pu6c3wjQNGYRcYADD24f4uYmpE4LHvE8V LNBlMQ1lTMo3WfusBqlki1yPPU0ui1bPH09Vnx/mUkObqs/E6S8fysm57DjVZIFUobuDC8Gyghk 7HTwHCAvOV/NmmCD8FKk61QyfWnluqq5PMuWe33oF7ufHttvKiVARsovVczMZ X-Received: by 2002:a5d:49cf:0:b0:1f1:e450:cd02 with SMTP id t15-20020a5d49cf000000b001f1e450cd02mr8764912wrs.70.1646693157630; Mon, 07 Mar 2022 14:45:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwW4JpgHYyiJQt0HQbji3Gaoxb/0YxRvyw5+buLT4C4Fze7fq/DuxmjcztYonQAKfWHaV7hmw== X-Received: by 2002:a5d:49cf:0:b0:1f1:e450:cd02 with SMTP id t15-20020a5d49cf000000b001f1e450cd02mr8764901wrs.70.1646693157411; Mon, 07 Mar 2022 14:45:57 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 26/47] pcie: Add a helper to the SR/IOV API Message-ID: <20220307224357.682101-27-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694401579100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694640937803.5919105724262; Mon, 7 Mar 2022 15:10:40 -0800 (PST) Received: from localhost ([::1]:38362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMUy-0006ij-Or for importer2@patchew.org; Mon, 07 Mar 2022 18:10:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7A-0007bS-HT for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56109) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM79-0005gX-4G for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46: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-55-2_RWzguIMTu0axeKMtIO5Q-1; Mon, 07 Mar 2022 17:46:01 -0500 Received: by mail-wm1-f70.google.com with SMTP id i83-20020a1c3b56000000b00389a203e5adso1101000wma.2 for ; Mon, 07 Mar 2022 14:46:01 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id h20-20020a05600c351400b0038688a67568sm581416wmq.21.2022.03.07.14.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:45:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693162; 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=XBpWPiSolpALa3U3cncrfVtgXnjzLn5O1kfaQaIodwJds0rx3k/It1lyTcy9iEYAkozPtr d4tFRENrmVucpYO9dt3DF1FwGfrmgm7SsTaEgfb7dhxICdXA5JFFF7FagXA0Uh9M7UTum0 NqJ6tqI5OzYjvxoXi/K48aR+UquSTW0= X-MC-Unique: 2_RWzguIMTu0axeKMtIO5Q-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=k0QOun3xe2mdbD8EpnVyG2UnoS92GZDMiEidZIbiDcmfZeKfqqFQ6ptvZL1mH/cJTT ZdMs/IS55y5m2OKVQDD9z6sak4Dzm6EAAAucrRg5Xi3HD86CXGNbDT6bdFXAgHXSZZNS hMmqb2s9pryJHmj9O4R7BTkfsOR2w3TAwDykzqcj55aEm4M5GH29wkukI2v8G0gDm/3u 2cPyZhUXKCPezBJuSGeoLoXUBaUSWOMZQtVI1Slxx5+asp/tEdNhgZuBC8CGhJwWJ395 eMroMI0eCrEB9FxRTKdRcuDQD9racHgJLXBnv7XUAb2FIEeOOjdCIbtXSFu31x5f2691 6uyQ== X-Gm-Message-State: AOAM530Hp0znSh82hDwVjvUeqdSY+mEDQgI9qSaKTO/ZcLLawKHFzaP1 iintRY6SgOZphC70fqmoJ8S1QxV5pA1BBnrlZaIpLynVjO2NtCJRlrn+vvaOtLIGpi8QmpjTQNn gTvHCjjvHxosCNl2Nd1SiDCyXIdsDHXvttAvI9iRrbiNI7Yykjr6d+It0CZgj X-Received: by 2002:a5d:4dca:0:b0:1f0:2543:e10e with SMTP id f10-20020a5d4dca000000b001f02543e10emr10068264wru.60.1646693160288; Mon, 07 Mar 2022 14:46:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJzb9lCR21I6QrLAhechfCnunnJnktiJ7Dk/QX8Tq/iKmTpZBVXVRIyKzCfVy4koEcg/J0zFTQ== X-Received: by 2002:a5d:4dca:0:b0:1f0:2543:e10e with SMTP id f10-20020a5d4dca000000b001f02543e10emr10068255wru.60.1646693160063; Mon, 07 Mar 2022 14:46:00 -0800 (PST) Date: Mon, 7 Mar 2022 17:45:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 27/47] pcie: Add 1.2 version token for the Power Management Capability Message-ID: <20220307224357.682101-28-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694671575100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694771441799.660619080722; Mon, 7 Mar 2022 15:12:51 -0800 (PST) Received: from localhost ([::1]:45692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMX4-0003YI-CN for importer2@patchew.org; Mon, 07 Mar 2022 18:12:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7D-0007f5-3Z for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:59460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7B-0005gw-K0 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:06 -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-615--fdAAlTvNROOWZMDV_3OjA-1; Mon, 07 Mar 2022 17:46:04 -0500 Received: by mail-wm1-f71.google.com with SMTP id m34-20020a05600c3b2200b0038115c73361so5689021wms.5 for ; Mon, 07 Mar 2022 14:46:03 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id l11-20020a5d674b000000b001f047c49e99sm12531584wrw.2.2022.03.07.14.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693165; 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=Hf96WKHAZa/1HmTuRHGA9b1hMUlpCEgJgwwPMSA7Mtenm43LezGYu6+p72883Vs5ga1hwu cnOLJpHfFXzKptjZJoUCbQ+KPuPWihF436ummbvk+VbyL2kafnoYtXeaEkLoH6gJa6lQUW sB3i9w4+SfuTfokhpNCnlkSEtW/t1FY= X-MC-Unique: -fdAAlTvNROOWZMDV_3OjA-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=5/4+1XpI6M4SlftKttqySIjiM0JLKfTI6YJeJwRbRZF70r1dz3QpRkHtfxrXHLIjHz H6IiEOs57n9u+emknz+WtR3jYAnfprEA8VAYbgySQ0cNLZKQuQdPimV+0YP3epibRaxx JXPJ16HYFSRf2eAj+MtvfkRdU8DWDmZkqxasTtegC2q2taHhzF2sa4IlhFM+isMOWE8a zd/d8l6RcjPAIjn5szu8RDxgKhiRidLWZBwgdF52YTXtMnHwaiX46Aa5+zCI3Am9Dmyb r2QkT6XHaCv/LpwKOFn58aK1ieDz7/evOsaiv5QubmycgIe1M3j2lq16+utdkAG2xkMl e1TA== X-Gm-Message-State: AOAM532h/AKcgTvQPvgM5nO2wsawpqX1ev8b+aydV466cDLELWp1XS+D CHIvbWyPu7mPItTQnRqqJWSYu6o8cpvd33DbUEZz3fVpZ12gu4OWLt/iyCUKlPS2zo9SicMidyT WDG31rn+bnyMFEJiifjATCIUmT7OBRF2p7bBn8jGIp0ulwO9494AIRbDNaCkK X-Received: by 2002:a5d:584f:0:b0:1e8:5697:e979 with SMTP id i15-20020a5d584f000000b001e85697e979mr10073084wrf.167.1646693162777; Mon, 07 Mar 2022 14:46:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKwUmdgSwyRKmGDSbV2B482AVaVWKM3SjtBufat0oWekX7pJeFMAOq2B+gJLrGLBZfnA0F2Q== X-Received: by 2002:a5d:584f:0:b0:1e8:5697:e979 with SMTP id i15-20020a5d584f000000b001e85697e979mr10073071wrf.167.1646693162537; Mon, 07 Mar 2022 14:46:02 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 28/47] pci-bridge/xio3130_upstream: Fix error handling Message-ID: <20220307224357.682101-29-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694772271100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694555386106.82897633567347; Mon, 7 Mar 2022 15:09:15 -0800 (PST) Received: from localhost ([::1]:34512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMTa-000477-5f for importer2@patchew.org; Mon, 07 Mar 2022 18:09:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7G-0007t4-KP for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:45605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7F-0005h8-62 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:10 -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-215-jX-TF3m9NX6AHY3Pm3ltIg-1; Mon, 07 Mar 2022 17:46:07 -0500 Received: by mail-wm1-f70.google.com with SMTP id k41-20020a05600c1ca900b00389a2b983efso1523634wms.4 for ; Mon, 07 Mar 2022 14:46:07 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id j3-20020a5d6043000000b001f0247bbdf7sm12435547wrt.64.2022.03.07.14.46.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693168; 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=DsHpTjEgmUNRR8qv7bD+JofgxcaeYBBafrj6vIKpNsmfXZYRQxeR7xNRkGO1HeHtNAyDZz wLKnwFSFbah/iPMzGjDUrpZlfloHxe+MoUBEeF/wdodG6bAYr6KZmEAxuxcyguCkojmy4s RPMhqP+zAMSrF+/Aw84QuEDzOGg8da0= X-MC-Unique: jX-TF3m9NX6AHY3Pm3ltIg-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=c1lcu426ikqrfQ0gk7i7kXK2TigjWZyRHUHntWXz50H9ewsWwPA0uEEoO9DPx67dqQ NkjQM5xOkPj/8ElbuqY4dP3eQAsvbh4RaDNFQP+5oX8LwHa5vv6KFv6aUtjvuniDH7LX Y1xrNoFkkAYI5BCnFLxTUjVvYnWQduUq+wbJsG+NPLmcLeGzF8loNQlB7DDDEE6qCfl0 pa16I9FlcVHKUYdG+WXH1eyxb2vvTfYW/KyGNTwM8aEVhM9eBmxdLC6FNq4bn8J45h2n b4cz1uh0pva4WmTLfffr/I5l7a+m1l0r1k7QzMpLVMxZZdvI9yAEAQ0/W0ff1xIYJo51 aPWg== X-Gm-Message-State: AOAM532/LtlrIxw9wnEMQdze8imT90xq37FCf5GTXXjogx4cT7fjtmDO abpg1jTLhOX8AgsG2EB758Q5R2DD07tVSsYIW4ydxluItTMqCKUbWYg/Dn0YHMFp/kpq9zm4P60 EOM0sRPRZleBQvcUSNGUOkV+/okNVTU9ApMXDfh7fYHi2wKAxuljPpb79jJim X-Received: by 2002:a05:600c:5014:b0:389:b0a9:5aac with SMTP id n20-20020a05600c501400b00389b0a95aacmr971962wmr.16.1646693166151; Mon, 07 Mar 2022 14:46:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtCbrNCuInfXdkjY/MumqJGMBra+P9Efh2nfFZUYznpdz6nZtuS0kpD2N6yQuwOa6oBprLiw== X-Received: by 2002:a05:600c:5014:b0:389:b0a9:5aac with SMTP id n20-20020a05600c501400b00389b0a95aacmr971943wmr.16.1646693165864; Mon, 07 Mar 2022 14:46:05 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 29/47] pci-bridge/xio3130_downstream: Fix error handling Message-ID: <20220307224357.682101-30-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694556988100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694942168310.53104348386057; Mon, 7 Mar 2022 15:15:42 -0800 (PST) Received: from localhost ([::1]:52022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMZp-0007vL-10 for importer2@patchew.org; Mon, 07 Mar 2022 18:15:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7K-00084w-9v for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7I-0005hb-NS for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46: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-282-n7zspMA4O22ab9PAqdiS5Q-1; Mon, 07 Mar 2022 17:46:11 -0500 Received: by mail-wr1-f72.google.com with SMTP id t15-20020adfdc0f000000b001ef93643476so4959407wri.2 for ; Mon, 07 Mar 2022 14:46:10 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id w10-20020a5d680a000000b001f1dabec837sm7438760wru.113.2022.03.07.14.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693172; 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=FlWJlNM3j1esPxuWXtzc9nGvwDHaNZXXANDxf55VMkmfogF4AxGBH/sv/6uH/wt8y586uM nybd9gJMY2ZoG890fkFGMae3K1cEH1V89SZ1vl3nkisDzsQFAFBFdEprm3c26RETZDfNiM RI0/jOUqh/gKucNiRL2xkd7DnkqbPdo= X-MC-Unique: n7zspMA4O22ab9PAqdiS5Q-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=wXKPysx9iKY+yQ/39mOnQZtVm5m+YN62w3I+HkyrVoHhwIEYVWd0avMlvpxB9wQFnp 6bX5LLOb7stdYBQpmjK1kDza1dDUrPETo76JeVN/KLXM2OEDxbz5lZjW60MOD50zMbq0 OmWFZR+Ei6KTOwQomaFWJMmbCl/9u5ych3EAQq1L/jHKAOgBGGfBsIZkeaZtXnv1iQ7I WoSWDPOTq5811Oq9oY0mcx/GRkOk+jK2uLw6u6D2AFWxY53oe2+0s6UhlL2NGUe4135P hiK1Invt4GVINvlutzkyd8eQy0Z5yLp8WIrHqOz9aJ+sPNMzrRk/FVv5o0K0PFcECPQP 5f6A== X-Gm-Message-State: AOAM53370GaAJfWbHMfatI5qxwKdNv4QigHUwr/+7+gJzejWfKOO9UrR mwtQ6GOkvOL/VPlOlugx6FNQTizlwqC6oHNYodaxmsB08FERA+SZtzh/n/vlxr1Jswa/Xy+umoP vXmjSPfqUNaUclIACj5E+AUtTcnmjDnLix7rZl52LJvMJvPg6Mh7lIsovg3oC X-Received: by 2002:adf:f5c5:0:b0:1ed:bc44:63e4 with SMTP id k5-20020adff5c5000000b001edbc4463e4mr10064125wrp.236.1646693169484; Mon, 07 Mar 2022 14:46:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyMUk0t/O4P9udbQER/Hj8jD7z6oGclNHHaBlSikGKFU9Q57E407ov+L3Omg+pR5jb570yKDQ== X-Received: by 2002:adf:f5c5:0:b0:1ed:bc44:63e4 with SMTP id k5-20020adff5c5000000b001edbc4463e4mr10064103wrp.236.1646693169167; Mon, 07 Mar 2022 14:46:09 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 30/47] headers: Add pvpanic.h Message-ID: <20220307224357.682101-31-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694943949100003 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694245909430.21629405242925; Mon, 7 Mar 2022 15:04:05 -0800 (PST) Received: from localhost ([::1]:47404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMOa-0002F1-V8 for importer2@patchew.org; Mon, 07 Mar 2022 18:04:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7O-0008Ac-QD for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7N-0005hp-8U for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:18 -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-561-vF8lqwu7OLeaSFFmvsOK_Q-1; Mon, 07 Mar 2022 17:46:14 -0500 Received: by mail-wm1-f69.google.com with SMTP id v125-20020a1cac83000000b0037e3d70e7e1so266775wme.1 for ; Mon, 07 Mar 2022 14:46:14 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id f20-20020a05600c4e9400b003898e252cd4sm594738wmq.12.2022.03.07.14.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693176; 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=C5iMlbASgWPDeqAnFhrKVLwJynE4rvo4lxsx89mo1qx3w+R6JHove8Bzs2Fp3ajZRUTAjV dMUZ+fcODGMZZkGYUJFyN3lLq/z34nd5tVyLqoumzcFzp2yvWwB+mjS57Ig7Oo8+POu+l5 fXhja7ixwNMCUmn07G27CWlHIfLEBQM= X-MC-Unique: vF8lqwu7OLeaSFFmvsOK_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:content-transfer-encoding :in-reply-to; bh=k3FB3bferdbl03k+KFKWByjScfRpd+RvVcbGHdUp8Wc=; b=XphTW7bJdZkcayG68qWsrHBDDoT/LDsLtmwZomwTNisOif/dTpwuNTt8ygw0V43YJZ Nt399nND1Pc0d9kaPAAWtKbJ/EZ4qAAUCFNX3cgU7lejLM4N/wx0dNKEQ4EG/oGO566U dY/FD751e8cwN6cn3dji/U3qQ0+9U6tm47bvkVKP3nSc3iw22mbjszs7SPyCf5azcbD8 kIXyW/DFueBeFyi8QXUWEFk96vj1lHDeCF8K3uVfqOy1mwtoKujxRnyfWDu+EdW2oJLi byWc/xqXf4dhWYAXoj0QWW/UpKGfz5NDY+4L9KgmIfoNxuB64RuA4SL4cN7hI0imDpzs gU+g== X-Gm-Message-State: AOAM530ud3rO80gjuPPbZA2jqvopMi8R1vc5nFSWqD+2DBjuiXlPNtGx By8Vnlr6XKP3SUfcWSk2U/ji27jof1KRdY4TJd493m7CK3nKMVrhsN/iosbBB6NQ1/Fc0HtyR1m SUMGqH2RVxmGAExr96x7NZs5dExH7FnvHWQLqROFsZEojtFBpFrBF4XP/BGEi X-Received: by 2002:a05:600c:1e02:b0:389:a488:4b7f with SMTP id ay2-20020a05600c1e0200b00389a4884b7fmr959552wmb.57.1646693172936; Mon, 07 Mar 2022 14:46:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzym8RAKHkT81526Rvqo1htDvC0CuuCLlrJK99miQSP75S2h9suqTa9YyTsEjlthk8hw5NjGw== X-Received: by 2002:a05:600c:1e02:b0:389:a488:4b7f with SMTP id ay2-20020a05600c1e0200b00389a4884b7fmr959531wmb.57.1646693172653; Mon, 07 Mar 2022 14:46:12 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 31/47] hw/misc/pvpanic: Use standard headers instead Message-ID: <20220307224357.682101-32-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , Alistair Francis , Igor Mammedov Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694246519100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 16466944273263.5784761407210226; Mon, 7 Mar 2022 15:07:07 -0800 (PST) Received: from localhost ([::1]:55974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMRW-0007z4-BD for importer2@patchew.org; Mon, 07 Mar 2022 18:07:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7R-0008Ck-Pd for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7Q-0005i4-5f for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:21 -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-362-BH0qGvvnOE2HRGDP5EG67Q-1; Mon, 07 Mar 2022 17:46:17 -0500 Received: by mail-wm1-f70.google.com with SMTP id k41-20020a05600c1ca900b00389a2b983efso1523804wms.4 for ; Mon, 07 Mar 2022 14:46:17 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id i9-20020adffdc9000000b001f046861795sm12253397wrs.19.2022.03.07.14.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693179; 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=HBbala76+1baRh+CMiYNk54V2udcrmZTYSqAgnMYnEKBOCd56MRTnUkDBLOiwNBhTlYbZL 5wSOXkyPNQ/HFwuy530LS/6xTq++L00SQF1/yotUZtpPaFXvdAAMn9loesVx11DMo0n7uc Dnf5nI8PEUgnwxZwtd6KXy4ByoX3egw= X-MC-Unique: BH0qGvvnOE2HRGDP5EG67Q-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=MRZI6lZEmGu3WNYXIjEQ60q9nixpyS0KNo2O3ySZbjr3oppCHM9HVcVQGLRuekxtuZ i3qdGB5q/9PwF2/zojVQbT7lfsWUdurTnMusCPTcCt00+BA7bzZVIejWLHoJqdqtSGJv Rq611BDIqsdDuzsCtUvJ1i8a0p8JEdJk4cPWqlS0jA4nzX035zwshbI6KcXa6lHF/n4J uzPw5YLJ+Vz3gISOR0Ji+XO1OaQQRGl/2R6ZYFAeBOiC//mkXTPVncubnFwkVw9nPBFk GFYQi7fZAo4v7/ihbcUnwlW3geOolGjA9JM28gLBvPikhDJPNVkhenb7iw0f2JzObx+m 9LGQ== X-Gm-Message-State: AOAM530kq1ntD7u2XNL7yOYUYj1OqJ11vhTcFSLOAjmR/mzSst7fL2hS kUPiQ3UMJBCcbSI8PmFDNTyHrvgXoWIXCF2i76uRizPTmFINnIRF1xOxsycXir5GkgMhl8XudDt SCzQ3LdZ89rjDxCAnNVxpS+KZrq/Bqf99L0LhONiGwv+HICpjY2dceAYsv3xq X-Received: by 2002:a05:600c:1988:b0:37c:505:d45c with SMTP id t8-20020a05600c198800b0037c0505d45cmr948606wmq.107.1646693176010; Mon, 07 Mar 2022 14:46:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJyW7OlABTqmsR8bgrc+7gqW9R9W+0LIE4MvkTZ94cvg/d8sI6AoOb1rYpiS+B2I+t8JG6PtwQ== X-Received: by 2002:a05:600c:1988:b0:37c:505:d45c with SMTP id t8-20020a05600c198800b0037c0505d45cmr948586wmq.107.1646693175675; Mon, 07 Mar 2022 14:46:15 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 32/47] pci: show id info when pci BDF conflict Message-ID: <20220307224357.682101-33-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694427792100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646693967610169.78910795065303; Mon, 7 Mar 2022 14:59:27 -0800 (PST) Received: from localhost ([::1]:35662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMK6-0002jZ-G1 for importer2@patchew.org; Mon, 07 Mar 2022 17:59:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7T-0008Ct-Dn for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7R-0005iE-R4 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:23 -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-646-4ogDhwExNKKhl0LqyRvvzA-1; Mon, 07 Mar 2022 17:46:20 -0500 Received: by mail-wm1-f70.google.com with SMTP id i83-20020a1c3b56000000b00389a203e5adso1101307wma.2 for ; Mon, 07 Mar 2022 14:46:20 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id p26-20020a1c741a000000b00389ab9a53c8sm506183wmc.36.2022.03.07.14.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693181; 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=FON64Ebj+0RFWlb86Oh4XVpuwcV/E/7YH/sRVtNaMLTqcdYgn1tqvMik4GV6/tssOJleVO q7CGnJmRqvX1RDr18/T7MdPBacA7arnl4hTDPmuSZi2DLIWbT6nWUZv4FyYE19Uc5BAVuE Ut0p7lp8RMGmXE6eqlaZFCArQoruXQo= X-MC-Unique: 4ogDhwExNKKhl0LqyRvvzA-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=czayQTvKk2xIkMY556kZu41TgNXMWs4JfSqmxs2Vv7rDue7Erzd+kr9KZqde69z/9Z Kk7RcYxda7zFO4s8JTfH5/za6Lake0+1hfdeZLqf5I7sexpOc769AKblu6dGQ8rgWTXv b3X7t8EgmUJVEnYJYBtsrsY4L3tR8BLJdKrpQTvLHfFW2FBkOk5a/tBKO6ExAErkvJrw coWy52GMdpVzUgXwya/mZVAllSpNxX3aE1BQh6Cb2NIzkwgVFhW6kgCGNcUp+xIQJYVW 1iFNk/Lm5tKuyKcZEDGYhN1Bh7aqXStgpBXPtKrrqHWlWT+TLrnTtLpfhjSh24S7tiFA 7nvw== X-Gm-Message-State: AOAM532lQYux9vs0nLtVt6dbE/LDizIb+pjA5SIcvMQGg4BP0daVWDli ci6+myXBac3GJ2gJxOtRhXYU+s3gP8a96YM0k5Xe/n1YiePQh1P4nLG6Acb1Au8Y1Xpb9ry7fwU SMGBRE4TVW/a1CYIfeU4EJWAd8z2+NCa49FbFfjDOLl9a523RZ6QAa9j3yhM1 X-Received: by 2002:a5d:47c6:0:b0:1ef:f98f:900b with SMTP id o6-20020a5d47c6000000b001eff98f900bmr10086853wrc.314.1646693178721; Mon, 07 Mar 2022 14:46:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDxjDYW4pHxr1nL4UxkUWT36i9y4OvWUnD7pF5bG/+UnXVYyUzh5y8E+4/2fO6LoMvfZveWA== X-Received: by 2002:a5d:47c6:0:b0:1ef:f98f:900b with SMTP id o6-20020a5d47c6000000b001eff98f900bmr10086843wrc.314.1646693178443; Mon, 07 Mar 2022 14:46:18 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 33/47] pci: expose TYPE_XIO3130_DOWNSTREAM name Message-ID: <20220307224357.682101-34-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646693968127100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 164669468963696.77335298968205; Mon, 7 Mar 2022 15:11:29 -0800 (PST) Received: from localhost ([::1]:42802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMVl-0001Jw-FB for importer2@patchew.org; Mon, 07 Mar 2022 18:11:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7X-0008GL-7S for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7V-0005j0-A3 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:26 -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-664-hJr1Ab05NXiDHAAhKMH39Q-1; Mon, 07 Mar 2022 17:46:23 -0500 Received: by mail-wm1-f70.google.com with SMTP id f189-20020a1c38c6000000b0037d1bee4847so246117wma.9 for ; Mon, 07 Mar 2022 14:46:23 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id i5-20020a1c3b05000000b00382871cf734sm515411wma.25.2022.03.07.14.46.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693184; 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=O+eBLcfxgkva54zdrxmIi7mTn2jGWxHOuaq/BvgvWYZByqsfBSK56LiASBKMAdRwKiSmPt c8J+JZ8fjK6p5+1zIdHRfDXoJXs/CrHZaaBgjMtkhAfm9YdlO/n4nrsLIVBxON66F3ZJqx tm0HsnIWDBbalnDhjL7TQdEpRz8oDW0= X-MC-Unique: hJr1Ab05NXiDHAAhKMH39Q-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=JGDerfuJMY4ZJjR7WCaphoH8RWYx27WkWmMdKRYbhpGlJZUHNKHBPLURUI35T6cJqV EjLtFfj1wDxAVXaR9aaMn4Hh4x3QKLtw+NNHH2pilbsQFurCpPFA+F9qM8WzWJn2GHZK /VtP4xFGnkOW1ENyxCRv1WlmHsdYbig2KYaGe4+NWv7v+80Hyrj3aO7jr/IDYE3hxSGQ CWd1Gcs31mNkQper/4Kx7uhXhzDeO9BrRRRu4VsokEYXnSPCG9iAhAzaIY2pZBcsAi1S sqK8kuaXanA8DjfBRYbcworOcCHteXMd97pE8RDhvFIgKmL8JQFSC2ipoicOCNDQZ6kO AzgA== X-Gm-Message-State: AOAM5307D3+m8npx1RwwIB/Vqo/OCmPJi2AO+rn0v4j5G2JG8DbZpPjY 7iQb9jW7aHJGP9LSbhl8Swu9rpJ5nWxb7jxmodYdphFOG9BzRzOzIpIF/IRKVP2LdQK9bo2x+Hw D/qTZuSW/91TZT4oFk8qglHFjyt7yMuxoqV2tnA2E+PgYW7e4jyC61tjMwhXk X-Received: by 2002:a5d:6241:0:b0:1ed:b534:e04e with SMTP id m1-20020a5d6241000000b001edb534e04emr10438428wrv.68.1646693181989; Mon, 07 Mar 2022 14:46:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+3F2rCzsD8QnEn/ztkjjDBkUmYgE1UZMmznm86AffNlohAjeU4XpxDhkrpq5o7lS9GDszZA== X-Received: by 2002:a5d:6241:0:b0:1ed:b534:e04e with SMTP id m1-20020a5d6241000000b001edb534e04emr10438407wrv.68.1646693181722; Mon, 07 Mar 2022 14:46:21 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 34/47] acpi: pcihp: pcie: set power on cap on parent slot Message-ID: <20220307224357.682101-35-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694691928100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694852815408.5496115945816; Mon, 7 Mar 2022 15:14:12 -0800 (PST) Received: from localhost ([::1]:49176 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMYM-0005sr-QS for importer2@patchew.org; Mon, 07 Mar 2022 18:14:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7a-0008IG-2C for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7Y-0005jF-FN for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:29 -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-398-YcCpoJnNPj6tndFdQCFr2Q-1; Mon, 07 Mar 2022 17:46:27 -0500 Received: by mail-wr1-f71.google.com with SMTP id p18-20020adfba92000000b001e8f7697cc7so4974632wrg.20 for ; Mon, 07 Mar 2022 14:46:26 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id r20-20020adfa154000000b001f0326a23e1sm12436859wrr.88.2022.03.07.14.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693187; 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=H97K9gjllwNut153cHjQWFZyMSfyHGrgcVBwlE1DiMGXI0ThUTKgErt2cdB1m3MUWvQaQT GGQNk2GOKPDVwH1X86endsKwAo+qxIw7Iq8wiQzGssWoK4OJiDoDdh/t0BJar2vPwo2PDM BjDFTCvw/qhvF1ZOaaoeDjSd6j2E5Co= X-MC-Unique: YcCpoJnNPj6tndFdQCFr2Q-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=L9e0N0So4h+N5nEOVtTRNHfYxFmLvobAOhR+6iwSfxWLhWlya8NFlulB2ivys5Nkev 2PtpupzugToeahkZKG2x0Yp/wGKT4ezgjhXaYoUrjIezF+EKwIHFsmj9JfdXyG9X8EI9 7D2soYajpaqnLbe2YlMfL7/x/azsvi1RxHa9BCO+WXJZInL2d6IkSY2GFCt67ARYTRfr IqucxJ1Y9Qiw/cb4XacHUUan4jJ6ojqjHOL4BfjDlERPyJ/5Dis1mJHVfSk2DFBlLU/R etc8GhrwvgorysocBHABzjrbi2ReoX0nfgx7k33PazdthdjH0xwXPt69LbbGbiYsVPNz pA+Q== X-Gm-Message-State: AOAM530tgusv46XXIf2nxcrYO/GDNTNVeXswH7Na/0+judLWY2i+k+Ce KXVTfZJ+nun30gUYd7kHnEbMgm6x8hPfTcWnoySSMHL4rQt53yGEZVI7CD9n2npwkwttIEMhzA+ rAtWwONjdBkoXKCM6dnEb+e/yOkUFwG43AV+eStOaPBrThaXCUxHWyDXuQesR X-Received: by 2002:a05:6000:184e:b0:1f0:3569:ccac with SMTP id c14-20020a056000184e00b001f03569ccacmr10228973wri.680.1646693185344; Mon, 07 Mar 2022 14:46:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuiG0XnLEf9YVXA/bL9QGG+AyZliD8uwk9ISuci7Dg+ELVo7mp7Lz09FAyrFOPppDfEDOYsA== X-Received: by 2002:a05:6000:184e:b0:1f0:3569:ccac with SMTP id c14-20020a056000184e00b001f03569ccacmr10228958wri.680.1646693185029; Mon, 07 Mar 2022 14:46:25 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 35/47] pc: add option to disable PS/2 mouse/keyboard Message-ID: <20220307224357.682101-36-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694854890100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694192683260.05408734558637; Mon, 7 Mar 2022 15:03:12 -0800 (PST) Received: from localhost ([::1]:44058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMNj-0008T0-Gr for importer2@patchew.org; Mon, 07 Mar 2022 18:03:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7d-0008Nl-Be for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53019) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7b-0005jX-H1 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:32 -0500 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-219-nwqdEsDPO9qhF-N9VCMqow-1; Mon, 07 Mar 2022 17:46:29 -0500 Received: by mail-ej1-f71.google.com with SMTP id r18-20020a17090609d200b006a6e943d09eso7638051eje.20 for ; Mon, 07 Mar 2022 14:46:29 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id b2-20020a17090630c200b006d58f94acecsm5157897ejb.210.2022.03.07.14.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693190; 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=CMo1hLmJ/aorqatsI272qLQxJ1sSKS8uPbwInRHGlVUzzymaL1Z6w9rRJEfkeeWenvVpyb VAxvlPmFUUuUuCr8Y89ppwkyn5EXEPMZqtl3WTdk79DUtTgckYzuo7UM3/C9g+KqY4Lx11 5Xho4/EDFy0JwdX4ado9HtPzxRQ/aUc= X-MC-Unique: nwqdEsDPO9qhF-N9VCMqow-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=M+21C/xZkR0v679KitOUSsAWJCuly3rYx3C5Y4Le0CHtR9D5G/cHu8nJ87aeY2gnna h1uDNg5jEWcw0pq8cRIAEZTn+Vl9GaDK9BtGCW1GgKfi2FD362eRpegY7KQ42L7zXhQ1 5ahgGB01wDqwY1JjUmKGdI01wVNu2/r1hvbQWAPMy/c+MMNa/aKK6tpC1GI4IDZMEBdd hPV/XZgvLS/u8a8ujPoed7FqN1XjegXvouYDOshb3x+7vRkX/gSD2HrujI+hsob0kW5c VCTOw322i293mG/hxzr3imcnv/vkD9blyCLoB+q8+z3UY9sjU25zoDv4bdY+a3jgmu0d JkzQ== X-Gm-Message-State: AOAM532b3Y9a99gdlFyLUdqjTGh2GR4zRwaXux2vhUMF/lyF1WK+xIVU BacvbSZBJm1pz0vwH6/ituPFiffCKR13cOone65Zry/m4bctkdpuu9JJWUyJJhiDacxk1uoumYs 2dI/0I2yty5wqjp32VFwzx8yPeoJ/Y9u3a4BOE5Z90/6mOFpb/SxKZ60OyjLt X-Received: by 2002:a17:907:720d:b0:6d7:cdc:958c with SMTP id dr13-20020a170907720d00b006d70cdc958cmr10729299ejc.361.1646693188345; Mon, 07 Mar 2022 14:46:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwb88QnnWdmfDhqZS3A2lUxyEqRejEsvDXxT2qf88MjBu+u8bsbXXnrfNRospt6PKp2RK+hwg== X-Received: by 2002:a17:907:720d:b0:6d7:cdc:958c with SMTP id dr13-20020a170907720d00b006d70cdc958cmr10729274ejc.361.1646693187983; Mon, 07 Mar 2022 14:46:27 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 36/47] vhost-vsock: detach the virqueue element in case of error Message-ID: <20220307224357.682101-37-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694194225100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694362958662.8911685237446; Mon, 7 Mar 2022 15:06:02 -0800 (PST) Received: from localhost ([::1]:52644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMQU-0005gn-JU for importer2@patchew.org; Mon, 07 Mar 2022 18:06:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7g-00008G-7V for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7e-0005jp-MJ for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:35 -0500 Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-To6gvK28O823yz4tk2Vd1A-1; Mon, 07 Mar 2022 17:46:33 -0500 Received: by mail-ej1-f71.google.com with SMTP id r18-20020a17090609d200b006a6e943d09eso7638114eje.20 for ; Mon, 07 Mar 2022 14:46:32 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id m13-20020a170906234d00b006cf86bb0652sm5157897eja.121.2022.03.07.14.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693194; 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=ZtDgshpc4Ywz6cKzb77CvwFAyUsthBbeQ9ch7yQb5RDL16QmbA5NQ3Jmg6EPhJogg2Be1e QwxZlHH6jKtHv5lTVahfFwIENYQDvKWHcQX2G4VrjDpv/VxqQvXlM0kBCL95bYamW1OZGK nsY5HeLr0eDSpi+OPNv09YNM2mXRMqk= X-MC-Unique: To6gvK28O823yz4tk2Vd1A-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=0b28lOjKK72ZQy7yEoTGRHJGRzQynV7Y89A6Bg8a+iG7bKRaXvCOKys7Y+OOWLR1V8 NIUE7d1a/bi/xAaBaHOp4ugh6jgivyDdgSjubWV1xDbPrDwvqgSBC4Sm6AQ0ik1ak6rI 0Kwf6wjl6MLYGYpdW57+B+ndTNfAkYQ90NcWbefISCHgnJtEaX2vVRf+RuvMXHQQ9SUL tfboMJ67wlKNQ8jEaLYr1V/82AyTASyoycsnyIlF1MJFv8dbWh1nGFWo6sLLkOZ7AekY ZgOPE7zywJJXpUXeCj4umFTms+wX+olTRJyDMubRb4ClKx6YDJrpi1MHysT1RL8Y40mo 69OQ== X-Gm-Message-State: AOAM530+dFjb8/c446YO7ZaKNKyeC858oS2ADnXzqreMSpBRvJfL2oSJ J6Jbosp+4DL3Cn4T9JPw34rjEyQzqH/ps15S/k0iZlbKyExHyeVBAfuxN9zqv0I6nrDTL2BCeXy Ps0VNm5BqRqLlf04JR9NGTbJ+Jq9+xOp733YQz5X4BxX6Qg7BWhDTHhVjpoX6 X-Received: by 2002:a17:906:848f:b0:6cf:7234:8ae with SMTP id m15-20020a170906848f00b006cf723408aemr11047298ejx.620.1646693191605; Mon, 07 Mar 2022 14:46:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzh88KbHqp3WFqhnN8Tyk/8OyOwKPbLLxAQUKotbhp1gMELn4k23VMvArjlkJeerNY3BgkKqw== X-Received: by 2002:a17:906:848f:b0:6cf:7234:8ae with SMTP id m15-20020a170906848f00b006cf723408aemr11047278ejx.620.1646693191382; Mon, 07 Mar 2022 14:46:31 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 37/47] x86: cleanup unused compat_apic_id_mode Message-ID: <20220307224357.682101-38-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694370303100001 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694999808469.0941087667903; Mon, 7 Mar 2022 15:16:39 -0800 (PST) Received: from localhost ([::1]:55572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMak-0002LP-L8 for importer2@patchew.org; Mon, 07 Mar 2022 18:16:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7l-0000RS-B0 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7j-0005k0-5k for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:40 -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-422-Ue2FkA77PoOmTRX7iukLWw-1; Mon, 07 Mar 2022 17:46:37 -0500 Received: by mail-ed1-f71.google.com with SMTP id i17-20020aa7c711000000b00415ecaefd07so7099728edq.21 for ; Mon, 07 Mar 2022 14:46:37 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id bw26-20020a170906c1da00b006c8aeca8febsm5203573ejb.47.2022.03.07.14.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693198; 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=WM8DbqbTKSLQVyBrsakCaCO02eOzlZ2Ph3Cq4l91luQ=; b=DtOX42zdUfefzwIlVzpfZBd4ZtdOiNKFpfAGskazWtC9CGY3n1tpdwDyRQZ6+p+f/ij7au ZwTmCc0m57HsyhW1f0AsXbtKXhz/G98tIzmhuCi70RNZ0+qFDk1dl2s9JeKmfND1X1lr9q D+9zsQ8DQ48xYHag7ffgzj4hhm6ZvBI= X-MC-Unique: Ue2FkA77PoOmTRX7iukLWw-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=WM8DbqbTKSLQVyBrsakCaCO02eOzlZ2Ph3Cq4l91luQ=; b=FJydMQJY5gi87UCKxYXHGWXAKjj7o5wrET7vfg0J5YL1akMJoaX0fKpPcKvkFIj0us CtSCCc0n555ye3HdS3Fy8o3YCajgfT+rS6Xq2FsgEilw+XeJzucH0xKNtTec/NF9M1e7 UbGxFDkHBgxrOmv//OZ7QjUPq+vIM1DHcinNTPxwylC10f5fW1EnROfQvZ5Hnd21owBB TBRbcbWTCr4NBnEZd0ilfJVyKcBSwyNGKFoPt/OuLfHeDzpLI1HybVLl1C7XhujNAjFV f6osZ1ctpSkH8OzWE4uEqMNaR8BtzRlccXuDA5+yavjOj0ncEaEv30mz5yYdlFQH1wmV ts1Q== X-Gm-Message-State: AOAM531n0mGkuGrhVf1ylS47aHt9AiAuYbGBy2dxD22eR11/HNGuX78Q 6MwXWVslfqBf8/f+R/rXCG8G7qDzuS5bDIBEAHZoqYdh8oK9gFGR0lzd6+XnG561PX6kz6bIdkR r+H59Md9jDAffHiGIWCRIxtrUBGDmuqpVaV4YKzvkc/i9Wg5zSAbM0ASU8X21 X-Received: by 2002:a05:6402:3595:b0:416:5b62:7376 with SMTP id y21-20020a056402359500b004165b627376mr4148080edc.107.1646693196087; Mon, 07 Mar 2022 14:46:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYt3BMC0tWMZiQC0MCJSmPIsRRKn27oRMkuhRSQWYiXWf3mf8IlSGhjS1N80rPZ8HmHZwzUQ== X-Received: by 2002:a05:6402:3595:b0:416:5b62:7376 with SMTP id y21-20020a056402359500b004165b627376mr4148056edc.107.1646693195839; Mon, 07 Mar 2022 14:46:35 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 38/47] hw/smbios: Add table 4 parameter, "processor-id" Message-ID: <20220307224357.682101-39-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , Titus Rwantare , Patrick Venture , Ani Sinha , Igor Mammedov , Peter Foley Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646695000171100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Patrick Venture This parameter is to be used in the processor_id entry in the type 4 table. This parameter is set as optional and if left will use the values from the CPU model. This enables hiding the host information from the guest and allowing AMD VMs to run pretending to be Intel for some userspace software concerns. Reviewed-by: Peter Foley Reviewed-by: Titus Rwantare Signed-off-by: Patrick Venture Reviewed-by: Igor Mammedov Message-Id: <20220125163118.1011809-1-venture@google.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 19 ++++++++++++++++--- qemu-options.hx | 3 ++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 1f8d5c252f..60349ee402 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -104,9 +104,11 @@ static struct { const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part; uint64_t max_speed; uint64_t current_speed; + uint64_t processor_id; } type4 =3D { .max_speed =3D DEFAULT_CPU_SPEED, - .current_speed =3D DEFAULT_CPU_SPEED + .current_speed =3D DEFAULT_CPU_SPEED, + .processor_id =3D 0, }; =20 static struct { @@ -327,6 +329,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] =3D { .name =3D "part", .type =3D QEMU_OPT_STRING, .help =3D "part number", + }, { + .name =3D "processor-id", + .type =3D QEMU_OPT_NUMBER, + .help =3D "processor id", }, { /* end of list */ } }; @@ -683,8 +689,13 @@ static void smbios_build_type_4_table(MachineState *ms= , unsigned instance) t->processor_type =3D 0x03; /* CPU */ t->processor_family =3D 0x01; /* Other */ SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer= ); - t->processor_id[0] =3D cpu_to_le32(smbios_cpuid_version); - t->processor_id[1] =3D cpu_to_le32(smbios_cpuid_features); + if (type4.processor_id =3D=3D 0) { + t->processor_id[0] =3D cpu_to_le32(smbios_cpuid_version); + t->processor_id[1] =3D cpu_to_le32(smbios_cpuid_features); + } else { + t->processor_id[0] =3D cpu_to_le32((uint32_t)type4.processor_id); + t->processor_id[1] =3D cpu_to_le32(type4.processor_id >> 32); + } SMBIOS_TABLE_SET_STR(4, processor_version_str, type4.version); t->voltage =3D 0; t->external_clock =3D cpu_to_le16(0); /* Unknown */ @@ -1323,6 +1334,8 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) save_opt(&type4.serial, opts, "serial"); save_opt(&type4.asset, opts, "asset"); save_opt(&type4.part, opts, "part"); + /* If the value is 0, it will take the value from the CPU mode= l. */ + type4.processor_id =3D qemu_opt_get_number(opts, "processor-id= ", 0); type4.max_speed =3D qemu_opt_get_number(opts, "max-speed", DEFAULT_CPU_SPEED); type4.current_speed =3D qemu_opt_get_number(opts, "current-spe= ed", diff --git a/qemu-options.hx b/qemu-options.hx index 094a6c1d7c..5ce0ada75e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2537,6 +2537,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, " specify SMBIOS type 3 fields\n" "-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr= ][,serial=3Dstr]\n" " [,asset=3Dstr][,part=3Dstr][,max-speed=3D%d][,current-s= peed=3D%d]\n" + " [,processor-id=3D%d]\n" " specify SMBIOS type 4 fields\n" "-smbios type=3D11[,value=3Dstr][,path=3Dfilename]\n" " specify SMBIOS type 11 fields\n" @@ -2562,7 +2563,7 @@ SRST ``-smbios type=3D3[,manufacturer=3Dstr][,version=3Dstr][,serial=3Dstr][,as= set=3Dstr][,sku=3Dstr]`` Specify SMBIOS type 3 fields =20 -``-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr][,= serial=3Dstr][,asset=3Dstr][,part=3Dstr]`` +``-smbios type=3D4[,sock_pfx=3Dstr][,manufacturer=3Dstr][,version=3Dstr][,= serial=3Dstr][,asset=3Dstr][,part=3Dstr][,processor-id=3D%d]`` Specify SMBIOS type 4 fields =20 ``-smbios type=3D11[,value=3Dstr][,path=3Dfilename]`` --=20 MST From nobody Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646695049374486.7846739686544; Mon, 7 Mar 2022 15:17:29 -0800 (PST) Received: from localhost ([::1]:58414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMbY-0004E9-Ay for importer2@patchew.org; Mon, 07 Mar 2022 18:17:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7o-0000dY-G6 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7n-0005kK-0u for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:44 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-177-k5HAeMeDPSSiSXixhKfKhg-1; Mon, 07 Mar 2022 17:46:41 -0500 Received: by mail-ed1-f69.google.com with SMTP id r8-20020aa7d588000000b00416438ed9a2so3005117edq.11 for ; Mon, 07 Mar 2022 14:46:41 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id t4-20020a056402524400b00415b90801edsm6907557edd.57.2022.03.07.14.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693202; 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=s3tpCVjYIOk1B/dIJbNsw4y7BbXatFeQMGgCwwa4oeU=; b=grmWu9r/mo7F8vZv3ezUuDu2lN4hL22eRhJyVMCMpJwfQz3qIdOAwAxTxwQ6uGKmQ8dNPD aoRxuOpbMeyi55LVBInyKBH3F2NfCfOBlcerltK1bVap+R8FOO4xQBCkOqrzKYl5PzDU0+ aB7E3C7ohherUJm9tWVlJPaKG2AaJ/U= X-MC-Unique: k5HAeMeDPSSiSXixhKfKhg-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=s3tpCVjYIOk1B/dIJbNsw4y7BbXatFeQMGgCwwa4oeU=; b=IWEfmolU0yd1hQN3wAwlPGAo46WXw8qytpL5mAWjMGh9APoTPK8bUGDS0lO/lSjoHS zL2obPCXGm7yME1HOM0qeJo4B1Y6sxPOBa0N6AOoTWS/aOqFXaa5S3Y7dyBQjtOQnLBH Wq9hiJUcSebLMfhUfKKbov3g5xkxoc143EnjXnW9/33gFq3B7+e+1aVqaNRhAI87Ug6H i30enMpC+8bQmwoBj6dSeo7ea3iu3UaMHdhxaANP1IOucq4lNL6hZt7Gg/X0/MJ5FmxD cg6v6SfRWhQdzfA8rJv22wCpJW1xfl6ixaaG3Eu6v+HhySzpE/dTih2Tb9SfYK/edK7K mGFA== X-Gm-Message-State: AOAM532325vqWQuG1fa3HjYgOYEKY7HHAldFJj6QmfdYIdELXGHXfEJ1 o0x2ReJEJJmAUZ5tQGhaQ1nKtlEJNtRGlA7CK8sXtUSnOZ5g0yozHoINU1/kdeNXDxk0UuqTU6L 3gFnKQ3mpbCFTQlHD1UiWtUuf2GMCvV7XSR3LlLJ0OyE8XCp7U02w+dr7cy2L X-Received: by 2002:a17:906:4cd8:b0:6db:372:c4ba with SMTP id q24-20020a1709064cd800b006db0372c4bamr9908011ejt.57.1646693199688; Mon, 07 Mar 2022 14:46:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnpFEqCoNMQifNSQGAfBKRQJhDw6aPNryS+mh4bAZnQWO2c3J4MZNdShv118l/6WByBhJIXA== X-Received: by 2002:a17:906:4cd8:b0:6db:372:c4ba with SMTP id q24-20020a1709064cd800b006db0372c4bamr9907996ejt.57.1646693199407; Mon, 07 Mar 2022 14:46:39 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 39/47] pci: drop COMPAT_PROP_PCP for 2.0 machine types Message-ID: <20220307224357.682101-40-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646695050586100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Igor Mammedov COMPAT_PROP_PCP is 'on' by default and it's used for turning off PCP capability on PCIe slots for 2.0 machine types using compat machinery. Drop not needed compat glue as Q35 supports migration starting from 2.4 machine types. Signed-off-by: Igor Mammedov Message-Id: <20220222102504.3080104-1-imammedo@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 32bf12421e..fd55fc725c 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -318,8 +318,6 @@ GlobalProperty pc_compat_2_0[] =3D { { "pci-serial-4x", "prog_if", "0" }, { "virtio-net-pci", "guest_announce", "off" }, { "ICH9-LPC", "memory-hotplug-support", "off" }, - { "xio3130-downstream", COMPAT_PROP_PCP, "off" }, - { "ioh3420", COMPAT_PROP_PCP, "off" }, }; const size_t pc_compat_2_0_len =3D G_N_ELEMENTS(pc_compat_2_0); =20 --=20 MST From nobody Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694625607870.9811839067685; Mon, 7 Mar 2022 15:10:25 -0800 (PST) Received: from localhost ([::1]:37326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMUi-00061w-Ch for importer2@patchew.org; Mon, 07 Mar 2022 18:10:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7r-0000qI-N8 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59244) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7q-0005kU-3F for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:47 -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-312-v1YFyYEUMve4lXVLenG4Dw-1; Mon, 07 Mar 2022 17:46:44 -0500 Received: by mail-ej1-f69.google.com with SMTP id l24-20020a170906a41800b006da873d66b6so6384658ejz.3 for ; Mon, 07 Mar 2022 14:46:44 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id n13-20020a170906724d00b006cedd6d7e24sm5183645ejk.119.2022.03.07.14.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693205; 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=ZuOy/7+HfqjI4TvmqHPnqx0Q0KWAobCs5iZB1N1AGuw=; b=BxL79TjvdoW9SbAaonlaOvzzD61dZrkrRMEwFouplbuwl2oRQ8pRoBAovKy25Eq8ALsHo9 0PJgAdQC/oJ9LJbZgTE0mrZve3BGTjQXHR5krIC5CVKzpSxnbDP6K4qQxwWV2WdPblMpgw U9xCFsTzB0Sw26gUuefT5siyImNxnr8= X-MC-Unique: v1YFyYEUMve4lXVLenG4Dw-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=ZuOy/7+HfqjI4TvmqHPnqx0Q0KWAobCs5iZB1N1AGuw=; b=A7cSwNwoEczEYokNq8/em1eFpAIIfVlrhb6UE/fnLYkmBH3EmRIqGuUt9ZCy2YpJXI qhyG9efU0CAbsUb43UbQZdu2nmvDeoSCqszMxC5E55Ro/ACM3d7zse6tZrr5kEEeI1X0 dnfarSp9Fd7pB5JzBW8BrMLJqQRLIJqOolUMSeYMv1I9owu9heT1SJhzG2C7jhtI5zHw TtlHESZxF3q4FwS+4+TE0SUxeN/rXuX0C+3zWX4mGXuHG/1hG1bdJvah8WHQEMl9zuBK a8RZnvEHvPUdf8Okaa4hTx15SFJrIIwVUDO5Jh0rMEQ5sDhlG0xpt6gmE686vKHXfkdJ G2lQ== X-Gm-Message-State: AOAM532Rz5afhWC8KWK7lfD4Unuqi/2x+L6u+rzzoe+Mrji379gT4kPi 9Rb2D0RTEWacDj6Gxac9UUCPnQIYC5GSb+pe9mphamAxUntbfswQwrlNG9eRZJuGDrmBRhyEX6V ZDfZSd4/+BxG8H083fnnc4kGNfFj0OZfO+oBNkZ/32IKgj4A46t+Jpmfm4UPu X-Received: by 2002:a17:906:4fc4:b0:6da:b4c6:fadb with SMTP id i4-20020a1709064fc400b006dab4c6fadbmr11463291ejw.282.1646693202973; Mon, 07 Mar 2022 14:46:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJxrdn6LVQ5MkEJcavktjdArVbVUOuZ/lStNN8fdPBf6/8oKYmdFFgd7FYgsKYyNY2R+RROQ== X-Received: by 2002:a17:906:4fc4:b0:6da:b4c6:fadb with SMTP id i4-20020a1709064fc400b006dab4c6fadbmr11463276ejw.282.1646693202646; Mon, 07 Mar 2022 14:46:42 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 40/47] event_notifier: add event_notifier_get_wfd() Message-ID: <20220307224357.682101-41-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694627333100003 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 Reviewed-by: Stefan Hajnoczi Message-Id: <20220304100854.14829-2-slp@redhat.com> 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646695088551818.328549259835; Mon, 7 Mar 2022 15:18:08 -0800 (PST) Received: from localhost ([::1]:33290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMcB-0006JG-9J for importer2@patchew.org; Mon, 07 Mar 2022 18:18:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7u-00013T-VH for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43259) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7t-0005kq-FV for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:50 -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-142-53mePp-CMQ2DZDAtuQ9PTQ-1; Mon, 07 Mar 2022 17:46:47 -0500 Received: by mail-ed1-f71.google.com with SMTP id n11-20020aa7c68b000000b0041641550e11so3096324edq.8 for ; Mon, 07 Mar 2022 14:46:47 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id q22-20020a170906771600b006cf8a37ebf5sm5137088ejm.103.2022.03.07.14.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693208; 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=quAC4k9MEA5Bl9esxGjIJ3kbUgMyXwbno7leI74drOM=; b=eV9paJZDTC99WF/i+s0GsER/PK/4kUp47NBrZmZFmMheb3BdFoF53moeCZOdQPspVyDfbD mZz3tSXp4enuBte6g3f2pfe/s7F5aPv9qEeeGIIlpDgLWGc1XnViy7gwF6PyvIxJmZYm8w pJLOkgLIarjOYLLEVIzzS72PpaTtteg= X-MC-Unique: 53mePp-CMQ2DZDAtuQ9PTQ-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=quAC4k9MEA5Bl9esxGjIJ3kbUgMyXwbno7leI74drOM=; b=5mNEPX6ButB19cKVAQOFBYm99/k2B9vtMzsK2x7t6eQXjInqQ+lQp5sLOFe0hY76w7 O1XfGFswhQLgRfRARwk2mCRATfMS94kuAJua70e9OjEUXhpv+ljXljlqWiAFATPZHAKC g/Vjk790Kq5+0qY7tOvTMjByHHOQ8WhE7p9Sg3/1dg+lDDTvZxed9UUD+V37MWt31nDI RuaXNWSCxETRkrznVRzJzqzp1yAqcu1HH/dRHJWNiTz3qpvPTcMIrSCGfPMqjQOyht1w KAGvj36MMYZfK2mwPBJYc9+4VR+aF2GWhAjcFx4LPr6bUfgWe1L7jF2CAnf/e0fWI1S1 qAvQ== X-Gm-Message-State: AOAM530uKEulL8PzWbHMtFtneFnXpFHuNq73e80lEYvngyV7WeSL8dPC zXvfh/txx9mENlHkpI6fieAscvcq4XqXVmgJ8aKBFNDBMNqX6Msh7j+J7rvFlTz0u5oHeso9k1E zmaNcy3mKup6dTtp68/VxIGsiIHiO5F11CaxjNi/9sHeB2Zp+Ix8YOSte++a2 X-Received: by 2002:a17:907:728b:b0:6da:97db:b66d with SMTP id dt11-20020a170907728b00b006da97dbb66dmr10674817ejc.636.1646693206445; Mon, 07 Mar 2022 14:46:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4KU5sho+CTd1iROBUj+EsTzlml+lQwgvfj59Mve5Rzn8QZTYYoi13NgphmIklsscNBZTdfg== X-Received: by 2002:a17:907:728b:b0:6da:97db:b66d with SMTP id dt11-20020a170907728b00b006da97dbb66dmr10674806ejc.636.1646693206220; Mon, 07 Mar 2022 14:46:46 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 41/47] vhost: use wfd on functions setting vring call fd Message-ID: <20220307224357.682101-42-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646695090972100001 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 Reviewed-by: Stefan Hajnoczi Message-Id: <20220304100854.14829-3-slp@redhat.com> 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694749074733.8971018400902; Mon, 7 Mar 2022 15:12:29 -0800 (PST) Received: from localhost ([::1]:44948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMWh-0002vj-TV for importer2@patchew.org; Mon, 07 Mar 2022 18:12:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7z-0001LE-Ko for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM7x-0005mG-RT for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:55 -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-295-VaC5eG1KMhKDlYOxUoJQcg-1; Mon, 07 Mar 2022 17:46:52 -0500 Received: by mail-ed1-f71.google.com with SMTP id n11-20020aa7c68b000000b0041641550e11so3096399edq.8 for ; Mon, 07 Mar 2022 14:46:52 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id g19-20020a056402425300b0041664626cb9sm684152edb.54.2022.03.07.14.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693213; 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=JLZkqE9CMO9Jo/gLiHOXhp5k4vbHvwWLStgWAFhWUt4=; b=fVoCtUpRSCQITyhpXnoHOFH+hwwDHHvcIffxBk56YKgGaFRE4SWQP/dI9fnW6LrimeruK1 Dj4SNjswNyHCK8BKYZjsr3v7E+WkwhhAtaGoIWZDo6wE8zu7hYHnVhCn4L4+sW+EAW1jRn qfS804d62vbeCaqK+v+nkdt6IGvIeOY= X-MC-Unique: VaC5eG1KMhKDlYOxUoJQcg-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=JLZkqE9CMO9Jo/gLiHOXhp5k4vbHvwWLStgWAFhWUt4=; b=ZjZ1J4qMgZPKZIRlSpNKUgUGbfAZru+U4wyj3tM5dYo7467cjfdiv5HlYRSpslx7PS Y6MfiNxj0x0XtVPTn0QGnYhX3LIpzljt2/4Xsz3jGrqrhAJcmBbve0LKnWPoUKMHspnU 4xuKB19hl0s7HFgkqm1nETd/9Xa02hXFJxxmmJHFGoAjrvZ3/S1GUmHrNpgSXc5xY9X3 z2IRZP1b2wW7hL5pZy9eTYOGCH7jAF5s4UtrJ63W+9EIOYBeG2vUwerJP3V0KxrV8Azn 7VSodz8pbF27/r8+4D5oP2iaaKoFBG6tFjCh+axynicZ19XNmQZWXkb2uSUKa3tgy4nx 8B0g== X-Gm-Message-State: AOAM533NBoeE1zmVkLAmTLk22dHBggAy9JJEdbEmgYV41hgzyv62+GL8 lFc7h9XAFFSq6tIZ0NutI8W3lrnyE2Oy8AO8wSsf4iJMFmuK2byz3A0iGNJ2i7zCUCCMDhhXPE5 RfsrToifqcGQKoRCPopbrDJtX+B5qpYtuiqIb1k06lRlDgvdNV5VEAY/Vxg7p X-Received: by 2002:a17:907:9910:b0:6d5:acd6:8d02 with SMTP id ka16-20020a170907991000b006d5acd68d02mr10786907ejc.173.1646693210799; Mon, 07 Mar 2022 14:46:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJz12klE1w0EdSwVqsOVOVq9mjFfdUKa820qk77fc5eYa7TtWC+L0rm9koEsOZ+XgzA7v3be4w== X-Received: by 2002:a17:907:9910:b0:6d5:acd6:8d02 with SMTP id ka16-20020a170907991000b006d5acd68d02mr10786883ejc.173.1646693210583; Mon, 07 Mar 2022 14:46:50 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 42/47] configure, meson: allow enabling vhost-user on all POSIX systems Message-ID: <20220307224357.682101-43-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694750102100002 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: 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 Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646695163468722.4522961060297; Mon, 7 Mar 2022 15:19:23 -0800 (PST) Received: from localhost ([::1]:37482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMdP-0000iZ-2D for importer2@patchew.org; Mon, 07 Mar 2022 18:19:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM82-0001Lq-21 for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM80-0005mn-Kl for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:46:57 -0500 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-633-jw6nO7VpMsm8gXRCzVGIDw-1; Mon, 07 Mar 2022 17:46:55 -0500 Received: by mail-ej1-f70.google.com with SMTP id ga31-20020a1709070c1f00b006cec400422fso7655872ejc.22 for ; Mon, 07 Mar 2022 14:46:55 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id b24-20020a170906491800b006db31196e2bsm1338135ejq.218.2022.03.07.14.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693216; 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=07QDxIPMafAaF6WsUgGU20pp0SPQclmS77EMgRXJWQo=; b=RH/4L6tumuGpqDS3oqXq9+NDpcgxT0G0QJOArNrUu0dCwVLDbcTNUTYqCGxmwKMdNumc/Y jlxV7iq2HHaAKFaVyphJUwqwRslyiyvzrJmqEyLOYn1l6tdGFAhJY5BU9ji/NfuxH5kP/b zOVMYCMyCR7pcL8uDjV+eu405VOSlLA= X-MC-Unique: jw6nO7VpMsm8gXRCzVGIDw-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=07QDxIPMafAaF6WsUgGU20pp0SPQclmS77EMgRXJWQo=; b=O5Ly2DhoxkivHZLi40zAtvMV8bF9Qvp+/uY1Dt4iGSqaganVf/7BhwUGDsGBt/Q62M wUgEoCV/5cVuPUj+lyM3TQaiIJpI2Yu6hj4rvDGt0/lqtHPblZoeADoDiagEY0gF6l2s nHtp1GbTxLlmz9BBMZL4H+oPPhIhR+Ex2x3V+zMADfM1Ls02yWGjOYDRzO2HworG/Too Rds2rwY0NSgd8rO7z5OcCo5/YBrX/2P+bvnJhQCujsGKn5f3E2NghrNKjs37Y4DUhMsn SdTPijv/xPxdRwveGvu89eSogP5rlK/XcLO7MRvpUkSyhjFIRo4zLmMR4hbq4bH5ZpE/ il9A== X-Gm-Message-State: AOAM531VpuPs4a6nf0Ppb7qCUXHRx6Dg5d6lo5Y4RpHaAu3RfStdQY4+ n+9L4rquxxSePlgET8Kr5E4mPR4O5Xx5ibf6ZVhp6VymFB5jiCTsPA4Mo4hRJFua1JDchvjIteO dVcZFy3oidi7XYGGWVgtoPP/B2kmdLRJxAbUq+gw+7Fs1a5cvAVY1AxmLiS8v X-Received: by 2002:a50:da4b:0:b0:40f:28f0:c2c0 with SMTP id a11-20020a50da4b000000b0040f28f0c2c0mr13212075edk.374.1646693213785; Mon, 07 Mar 2022 14:46:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzddG43kJtqc0HzgY84m0rcLCxKKz3lG2/Va2AM6N1Uh5kySZNwJVy1m1Ifb268Y8UzsZW6eA== X-Received: by 2002:a50:da4b:0:b0:40f:28f0:c2c0 with SMTP id a11-20020a50da4b000000b0040f28f0c2c0mr13212054edk.374.1646693213510; Mon, 07 Mar 2022 14:46:53 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 43/47] docs: vhost-user: add subsection for non-Linux platforms Message-ID: <20220307224357.682101-44-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646695165156100001 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> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 From nobody Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646694922026684.2059014531579; Mon, 7 Mar 2022 15:15:22 -0800 (PST) Received: from localhost ([::1]:51346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMZV-0007Ni-24 for importer2@patchew.org; Mon, 07 Mar 2022 18:15:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM88-0001bw-3e for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM86-0005oC-IG for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:03 -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-379-V8-mcjo4PRm5n7v9e2A_Dw-1; Mon, 07 Mar 2022 17:47:00 -0500 Received: by mail-ej1-f69.google.com with SMTP id og24-20020a1709071dd800b006dab87bec4fso4216837ejc.0 for ; Mon, 07 Mar 2022 14:47:00 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id k20-20020a170906681400b006da86bef01fsm5204087ejr.79.2022.03.07.14.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:46:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693222; 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=mfut9rC7QohOum5PUWB9hEyCkgjB7g4mFdlV9wDnfyg=; b=M2KJBqn+WG5mCAeS7EGFV7Mu+m+9Z8jfif2EATpJnw2MT1FG8ADuDr0AlzfuhfPk7sd24v Qe1qjuPc6c+D8lRSekEA56SXTWPjhSwXhpd7HPBQPKhxjUVk+RxblwqmLNsGyK89unroSb jWRmcknM/ZaCp/PWlkPBUjZM05l3szU= X-MC-Unique: V8-mcjo4PRm5n7v9e2A_Dw-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=mfut9rC7QohOum5PUWB9hEyCkgjB7g4mFdlV9wDnfyg=; b=sxd5OyL6R+6WvrIvzffDq8tTFheWlGd9K1x3+/ZZCBfjKzd7U+hfQaXblz4nMeoBa5 i53vpCbGgPKvXNfIWVz7WGCMo5QcGkPI22TGd7UII+vPJ0pTBKF7nepC5oancZ94nPOR vOt5kWyTptY55h4wAcJsQkmEhaTfbQkjMpPVTqML/vZsEtU/5IhrJIFVgul6x23gSDSd /AJ/22eqNwheoLuzuEOJMuQeRRpBlm3knmw8kXiaLRmE2V7gCjI2MDvmKAm4kMFNRzoz +AlQQTx6aEqJEflXyHAZ8W6VnFpALIh/f+DswCuZBi9A3rcCdOCkUgEKuThvVrJctIyf ZErQ== X-Gm-Message-State: AOAM533aYh+x5Jf9T/5ARTjSGhJZxcZDpV136w/jFfe5b8il1rfUmbqq E3BSeKyG/nrdkOBk9yuvmN5+aCgfsewTgbsJHPi1C1mrnfOkP7Z5lX1OTcBbftg3sgodYETLq2C CPzuAnzugml8a5Zne5UEEP2uIKKJu7Y8MnUSCPMK5bBteNuMH3JI7YxizugFe X-Received: by 2002:a17:906:7746:b0:6ce:a12e:489f with SMTP id o6-20020a170906774600b006cea12e489fmr10264101ejn.551.1646693219495; Mon, 07 Mar 2022 14:46:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJziAvFEBrAv/aaDf9k4utOe0cURY0cZOv+mauS1FdeSa6eljxf4hkmbkYwOya5l1hClyNPPHA== X-Received: by 2002:a17:906:7746:b0:6ce:a12e:489f with SMTP id o6-20020a170906774600b006cea12e489fmr10264079ejn.551.1646693219186; Mon, 07 Mar 2022 14:46:59 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 44/47] tests/acpi: i386: allow FACP acpi table changes Message-ID: <20220307224357.682101-45-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , Liav Albani , Igor Mammedov Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694923473100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Liav Albani The FACP table is going to be changed for x86/q35 machines. To be sure the following changes are not breaking any QEMU test this change follows step 2 from the bios-tables-test.c guide on changes that affect ACPI tables. Signed-off-by: Liav Albani Acked-by: Ani Sinha Message-Id: <20220304154032.2071585-2-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..7570e39369 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,5 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/FACP", +"tests/data/acpi/q35/FACP.nosmm", +"tests/data/acpi/q35/FACP.slic", +"tests/data/acpi/q35/FACP.xapic", --=20 MST From nobody Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646695204683181.3347430770326; Mon, 7 Mar 2022 15:20:04 -0800 (PST) Received: from localhost ([::1]:39434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMe3-00022J-Lq for importer2@patchew.org; Mon, 07 Mar 2022 18:20:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM8C-0001tl-9a for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM8A-0005oY-JA for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:08 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-592-Ish68EDWPAOgUSLT80sYVQ-1; Mon, 07 Mar 2022 17:47:04 -0500 Received: by mail-ed1-f69.google.com with SMTP id s7-20020a508dc7000000b0040f29ccd65aso9464850edh.1 for ; Mon, 07 Mar 2022 14:47:04 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id l2-20020aa7cac2000000b003f9b3ac68d6sm6776857edt.15.2022.03.07.14.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693226; 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=fzFjMVjkMR0anaC3SFegEYUQ/LQ+fdsLfF/TQ60MTl8=; b=fBer2GlikqBhatLCMrTjSEr2v4awWMmlFgiqXjE3T5j7iVfLofDwRH+vNjXb1a+1uNUrFr dPcnGgwxcBcUxml1jVt8ceQjstPppTivYX/DoYmOY6DKLDJ4OFgtRg4KgjlKAvqg/+mYsR A4kB2NFKl5o0GP2Rvly0iERLFMY67bs= X-MC-Unique: Ish68EDWPAOgUSLT80sYVQ-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=fzFjMVjkMR0anaC3SFegEYUQ/LQ+fdsLfF/TQ60MTl8=; b=DOg/PDBilKerjhr87VdqpsKFgJ7IZL9lU+nPp4yd4LRuifCuY1w7sKU4jIzZKihU2F P/XFgDGf8X8bcqYV9/Lp4sQVmf3YaS6x2viJSIxtRldmNHI1vDWqQDPZyoReQfF5cLm+ NoJb3D8syZVYz8cD5iI3oM0EC1NaWKJ1txwwTPlYjEBUO0BFNdrMDbilW1tlO8/J2jZv /EpzlRSXes8T+ddxWpE/T5KetrIT9ksUjmChkwRhxlZg60PkHr4yufD0nATdhNWli+KE nilwMv/TQiVtiYwMngmEh8DhXxYdpaR9OH+s1yKTUs2LB0M+JQhnmWpQhQ+599SCeZdN atkQ== X-Gm-Message-State: AOAM532chs3WAkqbV+/RQfiq/bRf0fplq6oxMHLP68ooGX5y0nChEJIF 9r6PtAnjGFhoPoH87RZTU0TdNGnlU3cuMFf0B5Jnswxiunw7uDmbDDegkjILfnYBHfgwKJaASTh vLS5vUk4VdtwyDqTc8aP1M24PKnYRDwQEtpK6324VRCw383xKeNYBDlw08DBP X-Received: by 2002:a50:fd0f:0:b0:416:e62:ccec with SMTP id i15-20020a50fd0f000000b004160e62ccecmr13231392eds.300.1646693223272; Mon, 07 Mar 2022 14:47:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJysJ+Af2EiMAYBtEOS9ze5HWTV/X/k4w6QQ4rTlYfDhPNM2F5dQugXsiCh5d2WnkKv6M1/AqQ== X-Received: by 2002:a50:fd0f:0:b0:416:e62:ccec with SMTP id i15-20020a50fd0f000000b004160e62ccecmr13231366eds.300.1646693223038; Mon, 07 Mar 2022 14:47:03 -0800 (PST) Date: Mon, 7 Mar 2022 17:46:59 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 45/47] hw/acpi: add indication for i8042 in IA-PC boot flags of the FADT table Message-ID: <20220307224357.682101-46-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , Liav Albani , Igor Mammedov , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646695205660100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Liav Albani This can allow the guest OS to determine more easily if i8042 controller is present in the system or not, so it doesn't need to do probing of the controller, but just initialize it immediately, before enumerating the ACPI AML namespace. The 8042 bit in IAPC_BOOT_ARCH was introduced from ACPI spec v2 (FADT revision 2 and above). Therefore, in this change, we only enable this bit f= or x86/q35 machine types since x86/i440fx machines use FADT ACPI table with revision 1. Signed-off-by: Liav Albani Signed-off-by: Ani Sinha Message-Id: <20220304154032.2071585-3-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi-defs.h | 1 + include/hw/input/i8042.h | 15 +++++++++++++++ hw/acpi/aml-build.c | 8 +++++++- hw/i386/acpi-build.c | 8 ++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c97e8633ad..2b42e4192b 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -77,6 +77,7 @@ typedef struct AcpiFadtData { uint16_t plvl2_lat; /* P_LVL2_LAT */ uint16_t plvl3_lat; /* P_LVL3_LAT */ uint16_t arm_boot_arch; /* ARM_BOOT_ARCH */ + uint16_t iapc_boot_arch; /* IAPC_BOOT_ARCH */ uint8_t minor_ver; /* FADT Minor Version */ =20 /* diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index 1d90432dae..e070f546e4 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -23,4 +23,19 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, void i8042_isa_mouse_fake_event(ISAKBDState *isa); void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out); =20 +static inline bool i8042_present(void) +{ + bool amb =3D false; + return object_resolve_path_type("", TYPE_I8042, &amb) || amb; +} + +/* + * ACPI v2, Table 5-10 - Fixed ACPI Description Table Boot Architecture + * Flags, bit offset 1 - 8042. + */ +static inline uint16_t iapc_boot_arch_8042(void) +{ + return i8042_present() ? 0x1 << 1 : 0x0 ; +} + #endif /* HW_INPUT_I8042_H */ diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 8966e16320..1773cf55f1 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2152,7 +2152,13 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, con= st AcpiFadtData *f, build_append_int_noprefix(tbl, 0, 1); /* DAY_ALRM */ build_append_int_noprefix(tbl, 0, 1); /* MON_ALRM */ build_append_int_noprefix(tbl, f->rtc_century, 1); /* CENTURY */ - build_append_int_noprefix(tbl, 0, 2); /* IAPC_BOOT_ARCH */ + /* IAPC_BOOT_ARCH */ + if (f->rev =3D=3D 1) { + build_append_int_noprefix(tbl, 0, 2); + } else { + /* since ACPI v2.0 */ + build_append_int_noprefix(tbl, f->iapc_boot_arch, 2); + } build_append_int_noprefix(tbl, 0, 1); /* Reserved */ build_append_int_noprefix(tbl, f->flags, 4); /* Flags */ =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index ebd47aa26f..4ad4d7286c 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -38,6 +38,7 @@ #include "hw/nvram/fw_cfg.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/isa/isa.h" +#include "hw/input/i8042.h" #include "hw/block/fdc.h" #include "hw/acpi/memory_hotplug.h" #include "sysemu/tpm.h" @@ -192,6 +193,13 @@ static void init_common_fadt_data(MachineState *ms, Ob= ject *o, .address =3D object_property_get_uint(o, ACPI_PM_PROP_GPE0_BLK= , NULL) }, }; + + /* + * ACPI v2, Table 5-10 - Fixed ACPI Description Table Boot Architecture + * Flags, bit offset 1 - 8042. + */ + fadt.iapc_boot_arch =3D iapc_boot_arch_8042(); + *data =3D fadt; } =20 --=20 MST From nobody Thu Apr 25 17:08:52 2024 Delivered-To: importer2@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+importer2=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 1646695275849983.6661421192069; Mon, 7 Mar 2022 15:21:15 -0800 (PST) Received: from localhost ([::1]:42070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMfC-0003nt-ML for importer2@patchew.org; Mon, 07 Mar 2022 18:21:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM8E-00024C-Uw for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM8D-0005ok-7C for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:10 -0500 Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-196-gyscNdq8NWqfTIxSkx6ZHA-1; Mon, 07 Mar 2022 17:47:07 -0500 Received: by mail-ed1-f69.google.com with SMTP id s7-20020a508dc7000000b0040f29ccd65aso9464909edh.1 for ; Mon, 07 Mar 2022 14:47:07 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id p4-20020a50d884000000b004128cf5fe2asm6781434edj.79.2022.03.07.14.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:47:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693228; 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=odDd977IILxM571sNSlSsG8vIH/vMjvB2fzKvFQoxXM=; b=JIdUaTkPam8WbTOCPCEq7dRm+/g6d4bN0NpvD9HFzuqEz8AaZ4m/FAOgv7/1QT/aQmYo5b jeu3YEgAJS2dJHenfZuClQVF4nzBPslwegwrZK7bC82o2l9H4f2fH09r4J9ns/qaItbK7f BBrrrtW7ujs4pLDy7T8MaGKBhmEXwmE= X-MC-Unique: gyscNdq8NWqfTIxSkx6ZHA-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=odDd977IILxM571sNSlSsG8vIH/vMjvB2fzKvFQoxXM=; b=hsrACxR+ROn5duTTyWAGfxAPzt9bbtbF6L34NN5Jy4f5ARSqHVH+Ko1dE6D/VoHX7z TcA8nj2QB2YnsAHNTW5qbialBJBWugJkbfADbSyRoth8yuCUVMUiHka8c/VLvnZDX5xd cb4Lbl9DaSaKFjuWfMJMCwjPZBK2RmqLS6lOBIlcM2yO6YyUSWz2UYmQSvvRaXR5fZtU yR0Bp8NlgqsKUJBzTLS44AV/0pNQ1RztogZOMt261RL63sJyuc2uwFYqYC4aC9X74zvN m7LheDC+sNCZ85bCKEUDM+OxgVuCDALNIzpqzXVZIkZCPP+zDT6DzJcCXgAbzLTU29ri Ze9Q== X-Gm-Message-State: AOAM530WbJIdQCMiLhAwlE4k0oowV4hvK0DsUTZ9u6O6rK4hb0glMC7w B6Pvf9R4zpjnwhfL/W/ih/FphStxlvKdxPoOLK+0GJOFcaevWw8FqsLETZifG86eXu9BArfG7xG 5hrNzVU7U+IcA2Tt5Pl4JHdvVTuaD2ij2tAQkFWjElCmR/tyOHJL54DAvjCeP X-Received: by 2002:a05:6402:26cc:b0:416:4189:f65e with SMTP id x12-20020a05640226cc00b004164189f65emr7910258edd.228.1646693225920; Mon, 07 Mar 2022 14:47:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/0AsgvdQ4hmnq3DyuxJDom1zRnlqE3aNWJvJctsVrn684Byr2MIrzWenxomZs9nlW0RgogA== X-Received: by 2002:a05:6402:26cc:b0:416:4189:f65e with SMTP id x12-20020a05640226cc00b004164189f65emr7910241edd.228.1646693225670; Mon, 07 Mar 2022 14:47:05 -0800 (PST) Date: Mon, 7 Mar 2022 17:47:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 46/47] tests/acpi: i386: update FACP table differences Message-ID: <20220307224357.682101-47-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , Liav Albani , Igor Mammedov Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646695278110100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Liav Albani After changing the IAPC boot flags register to indicate support of i8042 in the machine chipset to help the guest OS to determine its existence "faster", we need to have the updated FACP ACPI binary images in tree. The ASL changes introduced are shown by the following diff: @@ -42,35 +42,35 @@ [059h 0089 1] PM1 Control Block Length : 02 [05Ah 0090 1] PM2 Control Block Length : 00 [05Bh 0091 1] PM Timer Block Length : 04 [05Ch 0092 1] GPE0 Block Length : 10 [05Dh 0093 1] GPE1 Block Length : 00 [05Eh 0094 1] GPE1 Base Offset : 00 [05Fh 0095 1] _CST Support : 00 [060h 0096 2] C2 Latency : 0FFF [062h 0098 2] C3 Latency : 0FFF [064h 0100 2] CPU Cache Size : 0000 [066h 0102 2] Cache Flush Stride : 0000 [068h 0104 1] Duty Cycle Offset : 00 [069h 0105 1] Duty Cycle Width : 00 [06Ah 0106 1] RTC Day Alarm Index : 00 [06Bh 0107 1] RTC Month Alarm Index : 00 [06Ch 0108 1] RTC Century Index : 32 -[06Dh 0109 2] Boot Flags (decoded below) : 0000 +[06Dh 0109 2] Boot Flags (decoded below) : 0002 Legacy Devices Supported (V2) : 0 - 8042 Present on ports 60/64 (V2) : 0 + 8042 Present on ports 60/64 (V2) : 1 VGA Not Present (V4) : 0 MSI Not Supported (V4) : 0 PCIe ASPM Not Supported (V4) : 0 CMOS RTC Not Present (V5) : 0 [06Fh 0111 1] Reserved : 00 [070h 0112 4] Flags (decoded below) : 000084A5 WBINVD instruction is operational (V1) : 1 WBINVD flushes all caches (V1) : 0 All CPUs support C1 (V1) : 1 C2 works on MP system (V1) : 0 Control Method Power Button (V1) : 0 Control Method Sleep Button (V1) : 1 RTC wake not in fixed reg space (V1) : 0 RTC can wake system from S4 (V1) : 1 32-bit PM Timer (V1) : 0 Docking Supported (V1) : 0 Signed-off-by: Liav Albani Acked-by: Ani Sinha Message-Id: <20220304154032.2071585-4-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 4 ---- tests/data/acpi/q35/FACP | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.nosmm | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.slic | Bin 244 -> 244 bytes tests/data/acpi/q35/FACP.xapic | Bin 244 -> 244 bytes 5 files changed, 4 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index 7570e39369..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,5 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/FACP", -"tests/data/acpi/q35/FACP.nosmm", -"tests/data/acpi/q35/FACP.slic", -"tests/data/acpi/q35/FACP.xapic", diff --git a/tests/data/acpi/q35/FACP b/tests/data/acpi/q35/FACP index f6a864cc863c7763f6c09d3814ad184a658fa0a0..a8f6a8961109d01059aceef9f18= 69cde09a2f10c 100644 GIT binary patch delta 23 ecmeyu_=3DS Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646694568595376.0001148013497; Mon, 7 Mar 2022 15:09:28 -0800 (PST) Received: from localhost ([::1]:35638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nRMTo-0004uZ-C8 for importer2@patchew.org; Mon, 07 Mar 2022 18:09:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM8I-0002GO-0O for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53036) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nRM8G-0005oy-7r for qemu-devel@nongnu.org; Mon, 07 Mar 2022 17:47:13 -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-665-PxcuXKVANhGuX4FPm1ZkoQ-1; Mon, 07 Mar 2022 17:47:10 -0500 Received: by mail-ed1-f71.google.com with SMTP id h17-20020a05640250d100b004133863d836so9487043edb.0 for ; Mon, 07 Mar 2022 14:47:10 -0800 (PST) Received: from redhat.com ([2.55.138.228]) by smtp.gmail.com with ESMTPSA id si13-20020a170906cecd00b006cded0c5ee2sm5230669ejb.61.2022.03.07.14.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 14:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646693231; 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=9q47EVnAVXFpNQycZMOXWyjMc83xadubGO4Go9bg1gU=; b=XtHBaGaQe4QoPEDOrALqkmobY4yMaLngAfEDnQMqrSZmSbGwurnlUYjzTpg4S0OLcN89fY 9jWNBw42JrEo/xA4iEOqN0me2bXzJBXt0jFfYqmdd0li/mIa7gQ5QqsDmMqkU0a8J8HHUs sK3g5m2os+SNO3+LgeO1UiJmsq5wF5M= X-MC-Unique: PxcuXKVANhGuX4FPm1ZkoQ-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=9q47EVnAVXFpNQycZMOXWyjMc83xadubGO4Go9bg1gU=; b=jeuCnj4G/DC7+dI68ihkM1/3An324VwNWqZQE0XCN/wbEjl2shLDreJkCyxW7+BOQv mZTjoNFXR9OOb3gr6FbeZ7CPQIFjTj5iMQs/dEuSUa1xy6xzqjdTwGayCz+9VixFdwmh 0+L+7atgW84xRYJ1KwOMNDOLGxUIx832F1uOWSSdyVsqOK78+V3ogY3q5QsXhPsqoake n0V5P3QAxVnV1YM5s4lL6cLMyhXovJ2qRcinIhDeIVzGJHGY3Tilni9ZuoF238gU6lni VDd77fAUODstwv3A/8e//qf2tvd+VMOpY85Fk/C/VUlE77r5tCno+rMRkIsWrHyDzGiG E4Uw== X-Gm-Message-State: AOAM531VvybTOg8tqB6k8hrHhYv5XS0pHWaUAhbHsedxngQ+jJGxqH8O bNZVx/ZmAxWdQoakYYn9jEiDZpAhxQzgI2FHCd/tI2ARG4MEbe0v5y9+0ooW+I8XN61keixDBPa GQrKACI/QJwrB0HwhF1Aq8ZejIXDQ8sQ0QdJchg2/fHgtBautEENzy32ugaED X-Received: by 2002:a17:906:2e90:b0:6d6:e921:934a with SMTP id o16-20020a1709062e9000b006d6e921934amr10857532eji.557.1646693229195; Mon, 07 Mar 2022 14:47:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVn7m3117nISsKZXJUkKZnIZrWR/isiM7d7BhrLFYbh/0Vzpk59izAcW02r9twVLFQjuTHlQ== X-Received: by 2002:a17:906:2e90:b0:6d6:e921:934a with SMTP id o16-20020a1709062e9000b006d6e921934amr10857514eji.557.1646693228960; Mon, 07 Mar 2022 14:47:08 -0800 (PST) Date: Mon, 7 Mar 2022 17:47:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v4 47/47] hw/acpi/microvm: turn on 8042 bit in FADT boot architecture flags if present Message-ID: <20220307224357.682101-48-mst@redhat.com> References: <20220307224357.682101-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220307224357.682101-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+importer2=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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 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_NONE=-0.0001, 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 , Ani Sinha , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646694570882100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ani Sinha The second bit of IAPC_BOOT_ARCH in FADT table indicates the presence of keyboard controller implemented as 8042 or equivalent micro controller. This change enables this flag for microvms if such a device exists (for example, when added explicitly from the QEMU commandline). Change 654701e292d98b308b0 ("hw/acpi: add indication for i8042 in IA-PC boot flags= of the FADT table") enabled this flag for i386 q35 based machines. The reason for doing the same for micro-vms is to make sure we provide the correct tables to the guest OS uniformly in all cases when an i8042 device is present. When this bit is not enabled, guest OSes has to find other indirect methods to detect the device which we would like to avoid. Signed-off-by: Ani Sinha Message-Id: <20220304154032.2071585-5-ani@anisinha.ca> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-microvm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 68ca7e7fc2..fb09185cbd 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -37,6 +37,7 @@ #include "hw/pci/pcie_host.h" #include "hw/usb/xhci.h" #include "hw/virtio/virtio-mmio.h" +#include "hw/input/i8042.h" =20 #include "acpi-common.h" #include "acpi-microvm.h" @@ -187,6 +188,11 @@ static void acpi_build_microvm(AcpiBuildTables *tables, .address =3D GED_MMIO_BASE_REGS + ACPI_GED_REG_RESET, }, .reset_val =3D ACPI_GED_RESET_VALUE, + /* + * ACPI v2, Table 5-10 - Fixed ACPI Description Table Boot Archite= cture + * Flags, bit offset 1 - 8042. + */ + .iapc_boot_arch =3D iapc_boot_arch_8042(), }; =20 table_offsets =3D g_array_new(false, true /* clear */, --=20 MST