From patchwork Mon Nov 4 21:05:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C8CCD1BDF2 for ; Mon, 4 Nov 2024 21:06:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84GZ-0003Hz-EY; Mon, 04 Nov 2024 16:05:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84GX-0003Hk-Hu for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84GV-0005FZ-0P for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754334; 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=YX/D7B50whaD5dkmLdDqxAFvN13ZgCrMqMz4OxLbYGE=; b=Svqh8MSXJfXH6XrB02lF5NCJ7QK7L+ItsPa64bEbLiJNjgjVSBfG9Yq0oZRr8Wy+ewHX/D mgIeTrWgsj3hOso0xSdBv4Mom+LT8Kax3U9+wXl5wsJ3UU+9fTzsPuhYTeu2+akgh7i4Io Fuhr4Z1h4Hv/DYlGUr+pf46XWcr7U2Q= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-151-jUoSB_MbMG6abDFILJwilg-1; Mon, 04 Nov 2024 16:05:33 -0500 X-MC-Unique: jUoSB_MbMG6abDFILJwilg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4315afcae6cso27413185e9.0 for ; Mon, 04 Nov 2024 13:05:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754329; x=1731359129; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YX/D7B50whaD5dkmLdDqxAFvN13ZgCrMqMz4OxLbYGE=; b=QXYRwmnRB72dmM/MV12wL5jwkccOYosyIkSBoWvsvTnQrJyYpMn7J7gO3je4Kmrlj0 FSlMevu071XVo1qGXhM5gFEoiVsJ5tiyls3pspJSn2oXrMJhBMRJbWnE63cUWjT/DIin BBNxTpNR76O8ElMdQrlxO4RhyyY7lligltdZzE+PdRhPisFvjG+jFJHwKDZEeFl51sAb GKk7HdjD/vCDgy+WDH1cSXpt5FuS45T2HSOP+SUtG1CvffDp9YJtlnIv1pTEPr+PkplJ kxwJstL03u/Ir0mgCmMY84O+qMUn47S4oVlbYoHUcQ50Sm8iStKf9ySJYMcuS5TbLHOu +0zA== X-Gm-Message-State: AOJu0YzhFrXp3d/myo7vNKgArvbdqTzL2CT5USdFomwtFAXLt/V/FvWs 95OP9YtInKUtc9I//roybjkbqFv7T+3XN9o715/oQYCCnapvM+RJelMr3jv6sgF+Dgad+s3buLe zDpZjtYlmAYluE3Nl4/qiCQ7H1cunkpW7xZYcKMxQEIXodp5S7KOuEsTlZHhy4WE3DgvLEVuUV+ lm1wF+Vt60daxiSR8GIkxkERs15xOrPA== X-Received: by 2002:a05:600c:1c16:b0:42c:baf1:4c7 with SMTP id 5b1f17b1804b1-43282fd045cmr108612785e9.4.1730754329342; Mon, 04 Nov 2024 13:05:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVy4H4cIYuDxC4yObC8bmA6ST6u2cVOuLmDa+7YZCS+pUfLWUQIbxbW6tOyqZto3q23IifpA== X-Received: by 2002:a05:600c:1c16:b0:42c:baf1:4c7 with SMTP id 5b1f17b1804b1-43282fd045cmr108612495e9.4.1730754328849; Mon, 04 Nov 2024 13:05:28 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5bf4fdsm163457735e9.17.2024.11.04.13.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:05:28 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mattias Nissler , Peter Xu , Paolo Bonzini , David Hildenbrand , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PULL 01/65] softmmu: Expand comments describing max_bounce_buffer_size Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Mattias Nissler Clarify how the parameter gets configured and how it is used when servicing DMA mapping requests targeting indirect memory regions. Signed-off-by: Mattias Nissler Message-Id: <20240910213512.843130-1-mnissler@rivosinc.com> Acked-by: Peter Xu Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/memory.h | 9 ++++++++- include/hw/pci/pci_device.h | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/exec/memory.h b/include/exec/memory.h index e5e865d1a9..9458e2801d 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1104,7 +1104,14 @@ struct AddressSpace { QTAILQ_HEAD(, MemoryListener) listeners; QTAILQ_ENTRY(AddressSpace) address_spaces_link; - /* Maximum DMA bounce buffer size used for indirect memory map requests */ + /* + * Maximum DMA bounce buffer size used for indirect memory map requests. + * This limits the total size of bounce buffer allocations made for + * DMA requests to indirect memory regions within this AddressSpace. DMA + * requests that exceed the limit (e.g. due to overly large requested size + * or concurrent DMA requests having claimed too much buffer space) will be + * rejected and left to the caller to handle. + */ size_t max_bounce_buffer_size; /* Total size of bounce buffers currently allocated, atomically accessed */ size_t bounce_buffer_size; diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 91df40f989..8eaf0d58bb 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -168,7 +168,11 @@ struct PCIDevice { char *failover_pair_id; uint32_t acpi_index; - /* Maximum DMA bounce buffer size used for indirect memory map requests */ + /* + * Indirect DMA region bounce buffer size as configured for the device. This + * is a configuration parameter that is reflected into bus_master_as when + * realizing the device. + */ uint32_t max_bounce_buffer_size; }; From patchwork Mon Nov 4 21:05:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EC07D1BDF4 for ; Mon, 4 Nov 2024 21:05:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Ge-0003IX-FP; Mon, 04 Nov 2024 16:05:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ga-0003I3-Iu for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84GY-0005G3-Q5 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754338; 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=pO6/xC2LQ7SXQPgMt07W6ylNJnGRBeackbjMBgbgr2Q=; b=MaB2oUb0SQdUj/hMUPnh+RnJt6WX+M2fEzpKZYNooP8wYYKz/HePOyXLygurfm6WRJ5Mkh 7QjkKMC/fh3ZLqSeAUX3Ch6ddugDO5ujW0zzQvYXf5S+2u79jbYQEuzl6p7oD3R1pEHGZI AiefKSJe0bJsmg64A+M0GIG4vsBCoHI= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-oOFO74lmO2aVHRkwi4xSwQ-1; Mon, 04 Nov 2024 16:05:34 -0500 X-MC-Unique: oOFO74lmO2aVHRkwi4xSwQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4315eaa3189so39500425e9.1 for ; Mon, 04 Nov 2024 13:05:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754333; x=1731359133; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pO6/xC2LQ7SXQPgMt07W6ylNJnGRBeackbjMBgbgr2Q=; b=vj1gHMRAulRUYq707K8dK7VtmHSqMciHOiyopXZzRGurzFTSvvuISIAo6NrWYaMJCY 7YEnGegQrBmaLfikVFxeHTVjEhVl49Q/P61L/eiXBdR/3hPOb8Ja6LsaNqINF4Au/Cg2 mb0w5vvYe2lFNENggfWk1q/Vl7a4bucU+hPr7uPXsh7OXaUmRZrWFRMO4scQDFbROybH rdA4Hn/70hsNe2ZxDV5idDasBcf0mBAil6YpkRFW9roRjvID+hEYQyjF3nNP11tMYCJO SVy/nZShwkrVJWYww+Mk393vquaB9+2oFXGiol/7hhRBLVSavXNl93k16iarQOPCKQ7H 5WtQ== X-Gm-Message-State: AOJu0YzBG2lnIVbI8tvksTAC1tNzyWh2HNSygfBsEO2qZdwAH9eXQaQL 8xyUcGD+QrY6JE7GBtSzfRsL8a+HnsDOqTXA/jfmJAQrrry68UHhgggqSfg+Qb7UaX+fqwNHn9/ VGr4JTcxxm+dO4M3Ndr/4bpBJLwDcSm3hLJrSFXgEY+5xpNuNy10ZLOjUgqLQ+s4beIq2DvDu1G xauXl34yhKMsPQHg5NXMZTazxpMe6WKw== X-Received: by 2002:a05:600c:3507:b0:426:59fe:ac27 with SMTP id 5b1f17b1804b1-4328327c3d5mr156658635e9.26.1730754332956; Mon, 04 Nov 2024 13:05:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGRY98VI1e4LNpdEUOQ4xrvZTCDqiXNSkMpTVbzWEBYqZySB5e1KqhoeNo6HmbQYElDRF1yTw== X-Received: by 2002:a05:600c:3507:b0:426:59fe:ac27 with SMTP id 5b1f17b1804b1-4328327c3d5mr156658345e9.26.1730754332426; Mon, 04 Nov 2024 13:05:32 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10b7d15sm14338176f8f.8.2024.11.04.13.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:05:31 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , luzhixing12345 , Stefano Garzarella Subject: [PULL 02/65] docs: fix vhost-user protocol doc Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: luzhixing12345 Some editorial tweaks to the doc: Add a ref link to Memory region description and Multiple Memory region description. Descriptions about memory regions are merged into one line. Add extra type(64 bits) to Log description structure fields Fix ’s to 's Signed-off-by: luzhixing12345 Message-Id: <20240911060400.3472-1-luzhixing12345@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index d8419fd2f1..2e50f2ddfa 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -167,6 +167,8 @@ A vring address description Note that a ring address is an IOVA if ``VIRTIO_F_IOMMU_PLATFORM`` has been negotiated. Otherwise it is a user address. +.. _memory_region_description: + Memory region description ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -180,7 +182,7 @@ Memory region description :user address: a 64-bit user address -:mmap offset: 64-bit offset where region starts in the mapped memory +:mmap offset: a 64-bit offset where region starts in the mapped memory When the ``VHOST_USER_PROTOCOL_F_XEN_MMAP`` protocol feature has been successfully negotiated, the memory region description contains two extra @@ -190,7 +192,7 @@ fields at the end. | guest address | size | user address | mmap offset | xen mmap flags | domid | +---------------+------+--------------+-------------+----------------+-------+ -:xen mmap flags: 32-bit bit field +:xen mmap flags: a 32-bit bit field - Bit 0 is set for Xen foreign memory mapping. - Bit 1 is set for Xen grant memory mapping. @@ -211,7 +213,7 @@ Single memory region description :padding: 64-bit -A region is represented by Memory region description. +:region: region is represented by :ref:`Memory region description `. Multiple Memory regions description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -224,7 +226,7 @@ Multiple Memory regions description :padding: 32-bit -A region is represented by Memory region description. +:regions: regions field contains 8 regions of type :ref:`Memory region description `. Log description ^^^^^^^^^^^^^^^ @@ -233,9 +235,9 @@ Log description | log size | log offset | +----------+------------+ -:log size: size of area used for logging +:log size: a 64-bit size of area used for logging -:log offset: offset from start of supplied file descriptor where +:log offset: a 64-bit offset from start of supplied file descriptor where logging starts (i.e. where guest address 0 would be logged) @@ -382,7 +384,7 @@ the kernel implementation. The communication consists of the *front-end* sending message requests and the *back-end* sending message replies. Most of the requests don't require -replies. Here is a list of the ones that do: +replies, except for the following requests: * ``VHOST_USER_GET_FEATURES`` * ``VHOST_USER_GET_PROTOCOL_FEATURES`` @@ -1239,11 +1241,11 @@ Front-end message types (*a vring descriptor index for split virtqueues* vs. *vring descriptor indices for packed virtqueues*). - When and as long as all of a device’s vrings are stopped, it is + When and as long as all of a device's vrings are stopped, it is *suspended*, see :ref:`Suspended device state `. - The request payload’s *num* field is currently reserved and must be + The request payload's *num* field is currently reserved and must be set to 0. ``VHOST_USER_SET_VRING_KICK`` @@ -1662,7 +1664,7 @@ Front-end message types :reply payload: ``u64`` Front-end and back-end negotiate a channel over which to transfer the - back-end’s internal state during migration. Either side (front-end or + back-end's internal state during migration. Either side (front-end or back-end) may create the channel. The nature of this channel is not restricted or defined in this document, but whichever side creates it must create a file descriptor that is provided to the respectively @@ -1714,7 +1716,7 @@ Front-end message types :request payload: N/A :reply payload: ``u64`` - After transferring the back-end’s internal state during migration (see + After transferring the back-end's internal state during migration (see the :ref:`Migrating back-end state ` section), check whether the back-end was able to successfully fully process the state. From patchwork Mon Nov 4 21:05:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A3DDD1BDF3 for ; Mon, 4 Nov 2024 21:05:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Gk-0003JG-E0; Mon, 04 Nov 2024 16:05:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ge-0003Id-Hz for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gc-0005GF-RJ for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754341; 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=lrnd791JRA6XcZViFP6mkczIjt0e94BMU9whFcnTluw=; b=i1LXnMJQ4nBsrYozTj4TAq+O06zEto9hKCfkXbQWpBDd+fECODPu7ObwLLECPOvwtfZS1D ubc0+TXv9E6rhx9toG6b/uQoq1DPt7pcOQkedXO0zhWCE9bi9yC0uR495lik5tU1hFJaAR Yclnz+HOhdEJVZXmUn019b1Ta9wJo2s= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-xGcA2h58Pc2JPMRbJUE-ig-1; Mon, 04 Nov 2024 16:05:39 -0500 X-MC-Unique: xGcA2h58Pc2JPMRbJUE-ig-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2fb58d1da8eso26881221fa.0 for ; Mon, 04 Nov 2024 13:05:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754338; x=1731359138; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lrnd791JRA6XcZViFP6mkczIjt0e94BMU9whFcnTluw=; b=Hdj1GaRuyx8qd0cogKXupB493KoTQq84h+pSkpbyWnon1Vifchs3m8g08ox/6XsbfH k7WTpOM4lHLRha2QZUSCkHgUNkL5tWBzslRGkJM7e+eVcyXUzw2scJIXzUFbloUL73et AGDQrXFQueHQ622HtslGeZmCUOfChCE7D5+WlPFp9Lt2nL4zoGplG/Er2XImDWvSwWSH 3lD/s8rHWHKHehcb6bbzcw5qp+UojVPF9+RJv3h6yh/+AgUPn8kRCJMG21a26baMzeFk K/ND0HSWkJxCk/yv4TPz60NnQCBvE7OpsoZaHCfyXL4d774fCE16G8AOqCL77y9i6v2s 0YCA== X-Gm-Message-State: AOJu0YyA++95McoDBvjqSk2FW6UuZr4rlIOXllJ09Obee+Qp7bx4f7Pf TBl4s1G5mm/Vy0xqQYtPv0Q0P94Tv5jDLgvx0rwKsHYg/1rUAazLRHHeKIcPapUgyDWk84MmCmv gT+YDi2dBzu5UXyeTryy4n83APfKwuhMATFJnWE01MTSisfCZxSVZVQWgc2x5htKiwSCqfJIncb R59biWtVXaoilY+6K2wpkKdJY1w1NKeA== X-Received: by 2002:a05:651c:b0c:b0:2fb:6057:e67e with SMTP id 38308e7fff4ca-2fedb7d8b1emr67827191fa.32.1730754337774; Mon, 04 Nov 2024 13:05:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKUQYppskSaRTWKFEEQxSZrAxZ4GfeeO93QZ21ECIU7AiPIqa55Ic7PKiyWSjD3D+aAnowHQ== X-Received: by 2002:a05:651c:b0c:b0:2fb:6057:e67e with SMTP id 38308e7fff4ca-2fedb7d8b1emr67826911fa.32.1730754337210; Mon, 04 Nov 2024 13:05:37 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd8e9145sm193285595e9.1.2024.11.04.13.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:05:35 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , "Huang, Ying" , Ani Sinha Subject: [PULL 03/65] hw/acpi: Fix ordering of BDF in Generic Initiator PCI Device Handle. Message-ID: <16c687d84574a1139a6475c33e3b9191f7932ac0.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron The ordering in ACPI specification [1] has bus number in the lowest byte. As ACPI tables are little endian this is the reverse of the ordering used by PCI_BUILD_BDF(). As a minimal fix split the QEMU BDF up into bus and devfn and write them as single bytes in the correct order. [1] ACPI Spec 6.3, Table 5.80 Fixes: 0a5b5acdf2d8 ("hw/acpi: Implement the SRAT GI affinity structure") Reviewed-by: Igor Mammedov Tested-by: "Huang, Ying" Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/acpi_generic_initiator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c index 17b9a052f5..3d2b567999 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -92,7 +92,8 @@ build_srat_generic_pci_initiator_affinity(GArray *table_data, int node, /* Device Handle - PCI */ build_append_int_noprefix(table_data, handle->segment, 2); - build_append_int_noprefix(table_data, handle->bdf, 2); + build_append_int_noprefix(table_data, PCI_BUS_NUM(handle->bdf), 1); + build_append_int_noprefix(table_data, PCI_BDF_TO_DEVFN(handle->bdf), 1); for (index = 0; index < 12; index++) { build_append_int_noprefix(table_data, 0, 1); } From patchwork Mon Nov 4 21:05:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862022 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33D14D1BDF2 for ; Mon, 4 Nov 2024 21:07:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Gp-0003N6-Lc; Mon, 04 Nov 2024 16:05:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gl-0003Ln-K4 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gk-0005Gg-6u for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754348; 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=y1W8qMTzmc/wmoX2fFpOYJHtHzp6CM0hX7vN3XVw4RY=; b=TBJU2hEVWI0aZpSJ10KLHN4GuQWuGjQpC52uVwJmUBpyM/X2gOLRC257ENjEQK3nKawXD8 2pX0RZldLxQjhjS+b8+hy2mjdTtqMtnSDrdJ8JDcqexod8/Q+5mmcZluIXgyX9PzrUv1f8 cuqdEir0DJz0lZQPIIqKl/ye72TXwvM= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-155-KZDCv5jtPUGkWF8uWlGUKA-1; Mon, 04 Nov 2024 16:05:47 -0500 X-MC-Unique: KZDCv5jtPUGkWF8uWlGUKA-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5c947d9afc9so3584620a12.1 for ; Mon, 04 Nov 2024 13:05:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754346; x=1731359146; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=y1W8qMTzmc/wmoX2fFpOYJHtHzp6CM0hX7vN3XVw4RY=; b=UrnSRgGkY9BKorz5vl7TuZd+dSUXQ5ulcrOVDhoArf0kGWMHv5A+dzCqUI+mHsUrz2 pYQGnJKVGnytmHNTR55Cq0IEaR1fDi8apHtaUXe5Iqpo4BmyRLeyF/XozIgZ0tNVy0XB QqexBxakNZKTrTsoYLh1tDuLLAMtxvRJQIuwi8VKgbAzrQlExG+6TJhRszLJQOXiNXag K9w8mDvuGdDQs38e1ty3Cq3EIAhWfUcf1ntXJbKGyaysFFjcnTU6/dVlPVTq9S/1wdWI NfZQKOzCXUUd0OR78/Hrp61KgBASy6+uBDJ5pwQnN9hCYqven03gvrrZqTgdFt8iWgAE Cr4w== X-Gm-Message-State: AOJu0YzIFkK/T8DYlTXSxC//JrlZbzuOxZh1jAxjwH9g8boYGyugtJhv DbHlaEGawrKayPeKf8VEFSYqcqo9Y0ILhfHeLBOofYbdVd6PVYJb7e5KCwHchUyWzS7O/scl4OQ ecuMrgIsCocgwir6JeSIkKAx6FJnjnaw8CodDw2ANSooWmyahCBX0hx1RjK+iCAgqVrX7j822kM 3BEHevGq5LVcjO/+Thnig+oFrB/HYr3A== X-Received: by 2002:a05:6402:34d1:b0:5c9:6ae4:332e with SMTP id 4fb4d7f45d1cf-5cea967a284mr14175965a12.8.1730754344190; Mon, 04 Nov 2024 13:05:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEimZNn07o87EOuLe5muomRglOfncRjDqVqInm7Zg0iTEpVIJLheUmlDyDhrLLR0D5buExIzA== X-Received: by 2002:a05:6402:34d1:b0:5c9:6ae4:332e with SMTP id 4fb4d7f45d1cf-5cea967a284mr14175903a12.8.1730754342188; Mon, 04 Nov 2024 13:05:42 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cee6b0fac0sm293771a12.79.2024.11.04.13.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:05:41 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Ankit Agrawal , Igor Mammedov , "Huang, Ying" , Ani Sinha , Michael Tokarev , Laurent Vivier , qemu-trivial@nongnu.org Subject: [PULL 04/65] hw/acpi/GI: Fix trivial parameter alignment issue. Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Before making additional modification, tidy up this misleading indentation. Reviewed-by: Ankit Agrawal Reviewed-by: Igor Mammedov Tested-by: "Huang, Ying" Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/acpi_generic_initiator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c index 3d2b567999..4a02c19468 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -133,7 +133,7 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque) dev_handle.segment = 0; dev_handle.bdf = PCI_BUILD_BDF(pci_bus_num(pci_get_bus(pci_dev)), - pci_dev->devfn); + pci_dev->devfn); build_srat_generic_pci_initiator_affinity(table_data, gi->node, &dev_handle); From patchwork Mon Nov 4 21:05:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6940D1BDF3 for ; Mon, 4 Nov 2024 21:07:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Gu-0003Uv-E6; Mon, 04 Nov 2024 16:06:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gq-0003O2-NR for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Go-0005H5-Lu for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754351; 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=lkIaQdD7KqQ1sn0ggnRpjbZ4514ooYNFoj1fek6Hj2E=; b=cvV+tHowbmiTvsawdFcufeX92ArmeYQRAHgAznbkKAf0JeNqLUb5kD6VZceVCoB6w/lSNb oqUKkze3wFPBkh6e2Y1mCwtKqWf+i963PVlBvbBQW9kjSZjy0XIG+nyH/ae0BoJn19XDyz DaUA05Zr4em1p8j544kjgAkoIvcvqcw= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-BXn_JaTVN0iwhSnCvow5_Q-1; Mon, 04 Nov 2024 16:05:50 -0500 X-MC-Unique: BXn_JaTVN0iwhSnCvow5_Q-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a9a0d8baa2cso541621566b.0 for ; Mon, 04 Nov 2024 13:05:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754348; x=1731359148; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lkIaQdD7KqQ1sn0ggnRpjbZ4514ooYNFoj1fek6Hj2E=; b=ey0rFns5gDJSLMjiav6bqVFSe+4jah6Osbi+HSR1/sfNwMWp1O3w5ePJ+2Qp+1u/6b 5qwdOOk0HvzuYXyx5ezzUo6YoqkDGQ7I9+XR/IVrjBD5Z04H2gfW4ycOqE83hGx/KiBK 5KLfhRZ2FtzLLnaRl8vw4u953Nt5q0lf9zh6uHsZPs+ZZUgFtc93k7ZeKe2P6OdRcLXF lFSWi2qw9bAqEBydmhHqaizz1+MzIW+YiB3djRNpa93we5ZKJ5WzTy4+BbDGMEl4jgi5 uuHnzsMNEz2S5cbr6sK45Y1IilIEvw+OlJoC/0pL0ONer8sianGX0G1f8FLJVRxUSdF3 8V+A== X-Gm-Message-State: AOJu0YxcOKNWunJ00Td+uLha+90npzFrFn0DTUtzqlslKHR09zpXijvG yN49bT3fy9nGS+kFeQDTCMfCJlJnXiQoG7/x9xgfBIuxogj8McEVtTUsHFDcl0HohhB+vOFNCJa lWsGqIiWw25UAeONce8QtXaaGC+kv93i/v0+ivBZgL6VdL8NatxXkO2AhqeOD/HmdRqX50K+CWr E12cL6qqyeTHhmt/N1aw4mgPgHm7+OrA== X-Received: by 2002:a05:6402:26cb:b0:5c9:66c:660e with SMTP id 4fb4d7f45d1cf-5ceb8de9894mr12336202a12.13.1730754348327; Mon, 04 Nov 2024 13:05:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgas6UZcIYl/4VLPtRWdCiaexz7SnEURRqYZZAfda62Cx05BIXUEdytGBfWARXe+GE/DsGig== X-Received: by 2002:a05:6402:26cb:b0:5c9:66c:660e with SMTP id 4fb4d7f45d1cf-5ceb8de9894mr12336170a12.13.1730754347934; Mon, 04 Nov 2024 13:05:47 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cee6ac399bsm299458a12.52.2024.11.04.13.05.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:05:46 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:42 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , "Huang, Ying" , Ani Sinha Subject: [PULL 05/65] hw/acpi: Move AML building code for Generic Initiators to aml_build.c Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Rather than attempting to create a generic function with mess of the two different device handle types, use a PCI handle specific variant. If the ACPI handle form is needed then that can be introduced alongside this with little duplicated code. Drop the PCIDeviceHandle in favor of just passing the bus, devfn and segment directly. devfn kept as a single byte because ARI means that in this case it is just an 8 bit function number. Suggested-by: Igor Mammedov Link: https://lore.kernel.org/qemu-devel/20240618142333.102be976@imammedo.users.ipa.redhat.com/ Tested-by: "Huang, Ying" Reviewed-by: Igor Mammedov Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi_generic_initiator.h | 23 ------------- include/hw/acpi/aml-build.h | 4 +++ hw/acpi/acpi_generic_initiator.c | 39 ++------------------- hw/acpi/aml-build.c | 44 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 59 deletions(-) diff --git a/include/hw/acpi/acpi_generic_initiator.h b/include/hw/acpi/acpi_generic_initiator.h index a304bad73e..7b98676713 100644 --- a/include/hw/acpi/acpi_generic_initiator.h +++ b/include/hw/acpi/acpi_generic_initiator.h @@ -19,29 +19,6 @@ typedef struct AcpiGenericInitiator { uint16_t node; } AcpiGenericInitiator; -/* - * ACPI 6.3: - * Table 5-81 Flags – Generic Initiator Affinity Structure - */ -typedef enum { - /* - * If clear, the OSPM ignores the contents of the Generic - * Initiator/Port Affinity Structure. This allows system firmware - * to populate the SRAT with a static number of structures, but only - * enable them as necessary. - */ - GEN_AFFINITY_ENABLED = (1 << 0), -} GenericAffinityFlags; - -/* - * ACPI 6.3: - * Table 5-80 Device Handle - PCI - */ -typedef struct PCIDeviceHandle { - uint16_t segment; - uint16_t bdf; -} PCIDeviceHandle; - void build_srat_generic_pci_initiator(GArray *table_data); #endif diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index a3784155cb..33eef85791 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -486,6 +486,10 @@ Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset, void build_srat_memory(GArray *table_data, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags); +void build_srat_pci_generic_initiator(GArray *table_data, int node, + uint16_t segment, uint8_t bus, + uint8_t devfn); + void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms, const char *oem_id, const char *oem_table_id); diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c index 4a02c19468..7665b16107 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -74,40 +74,11 @@ static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) acpi_generic_initiator_set_node, NULL, NULL); } -/* - * ACPI 6.3: - * Table 5-78 Generic Initiator Affinity Structure - */ -static void -build_srat_generic_pci_initiator_affinity(GArray *table_data, int node, - PCIDeviceHandle *handle) -{ - uint8_t index; - - build_append_int_noprefix(table_data, 5, 1); /* Type */ - build_append_int_noprefix(table_data, 32, 1); /* Length */ - build_append_int_noprefix(table_data, 0, 1); /* Reserved */ - build_append_int_noprefix(table_data, 1, 1); /* Device Handle Type: PCI */ - build_append_int_noprefix(table_data, node, 4); /* Proximity Domain */ - - /* Device Handle - PCI */ - build_append_int_noprefix(table_data, handle->segment, 2); - build_append_int_noprefix(table_data, PCI_BUS_NUM(handle->bdf), 1); - build_append_int_noprefix(table_data, PCI_BDF_TO_DEVFN(handle->bdf), 1); - for (index = 0; index < 12; index++) { - build_append_int_noprefix(table_data, 0, 1); - } - - build_append_int_noprefix(table_data, GEN_AFFINITY_ENABLED, 4); /* Flags */ - build_append_int_noprefix(table_data, 0, 4); /* Reserved */ -} - static int build_all_acpi_generic_initiators(Object *obj, void *opaque) { MachineState *ms = MACHINE(qdev_get_machine()); AcpiGenericInitiator *gi; GArray *table_data = opaque; - PCIDeviceHandle dev_handle; PCIDevice *pci_dev; Object *o; @@ -130,13 +101,9 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque) } pci_dev = PCI_DEVICE(o); - - dev_handle.segment = 0; - dev_handle.bdf = PCI_BUILD_BDF(pci_bus_num(pci_get_bus(pci_dev)), - pci_dev->devfn); - - build_srat_generic_pci_initiator_affinity(table_data, - gi->node, &dev_handle); + build_srat_pci_generic_initiator(table_data, gi->node, 0, + pci_bus_num(pci_get_bus(pci_dev)), + pci_dev->devfn); return 0; } diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 34e0ddbde8..aeb4cb94e8 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1937,6 +1937,50 @@ void build_srat_memory(GArray *table_data, uint64_t base, build_append_int_noprefix(table_data, 0, 8); /* Reserved */ } +/* + * ACPI Spec Revision 6.3 + * Table 5-80 Device Handle - PCI + */ +static void build_append_srat_pci_device_handle(GArray *table_data, + uint16_t segment, + uint8_t bus, uint8_t devfn) +{ + /* PCI segment number */ + build_append_int_noprefix(table_data, segment, 2); + /* PCI Bus Device Function */ + build_append_int_noprefix(table_data, bus, 1); + build_append_int_noprefix(table_data, devfn, 1); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 12); +} + +/* + * ACPI spec, Revision 6.3 + * 5.2.16.6 Generic Initiator Affinity Structure + * With PCI Device Handle. + */ +void build_srat_pci_generic_initiator(GArray *table_data, int node, + uint16_t segment, uint8_t bus, + uint8_t devfn) +{ + /* Type */ + build_append_int_noprefix(table_data, 5, 1); + /* Length */ + build_append_int_noprefix(table_data, 32, 1); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 1); + /* Device Handle Type: PCI */ + build_append_int_noprefix(table_data, 1, 1); + /* Proximity Domain */ + build_append_int_noprefix(table_data, node, 4); + /* Device Handle */ + build_append_srat_pci_device_handle(table_data, segment, bus, devfn); + /* Flags - GI Enabled */ + build_append_int_noprefix(table_data, 1, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); +} + /* * ACPI spec 5.2.17 System Locality Distance Information Table * (Revision 2.0 or later) From patchwork Mon Nov 4 21:05:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01A68D1BDF4 for ; Mon, 4 Nov 2024 21:09:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Gv-0003VY-AJ; Mon, 04 Nov 2024 16:06:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gr-0003S1-Vb for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gq-0005HU-Bi for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:05:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754355; 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=5o6Iz1/wP5zB957KDr4w2+nYVqYKn/FATzH9r01QwTQ=; b=Hw7T8uhPdKy/YfA5FpQBatHSFDaeaGPmzKpccl+h14B+GNY7gkTeK0UVFWOolCPm632bEQ IZfv5gpx6+27/rqXF+WQMpvZfLe2rFNgBA/+o45R1VfTDdafQVjTIqkgGKjXLtQAdlNJ6C EVhPzE+Le1Efrq2xL8JguhWYmwSqt0k= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-jfhwKp3MMxGFBIMGJinqIQ-1; Mon, 04 Nov 2024 16:05:54 -0500 X-MC-Unique: jfhwKp3MMxGFBIMGJinqIQ-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5c95b050667so4705633a12.2 for ; Mon, 04 Nov 2024 13:05:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754353; x=1731359153; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5o6Iz1/wP5zB957KDr4w2+nYVqYKn/FATzH9r01QwTQ=; b=PO704yazaNdATFjxfEtHi/0Hc4dM4nw0rJCKLo0GLqeNdsGXsPtL7U5kyQel5RFR1R N+m+A5YMBRokdfisyAZ81h0S3DobLyN3kM+VOwN36IyRMPVSWqM6EKPd2D0NtooKmpu8 KuOngDLKRJlHOhlRhLhU2gjWF1vd8bQiidXJJx+mOpzV+Librj2a1RliyYqMH/SEy2yl kOmAamHf/pp1/4tezcLtnxQ57noC1t7HYFdaHkF9AQTnz7XK6EmdSA6p4hsmafmUp42h VuyM8Xy/12OGy5SnK3f8Wvd/qmpov1yN3I7iE4/qZppuC6PgDxfXo5Kfvw+mH1nBuRP8 Xekg== X-Gm-Message-State: AOJu0Yy4b88/CQ5cnNeiWifmXUVZo+yAdApMZBpqhaHkeI8EDeZ7UN5M 59pkeiD1LvESk+bHnE+FEqUUa/lSbe8wZFhThZe08e7WkCxIqD6jrvoAhtnZ44qWKVl9GPhgcCy JJz+4/oYkWZmNaXkskpvCfwNsZ6aQ/MHSt52Ttm/ZHQ5abW6A5WorG+r+RRI9Bj1JUUCF8mFtev yP9rYmqG2vPVlPjW4HG2dEqxzfjU1Dtw== X-Received: by 2002:a05:6402:3592:b0:5cd:5732:ecfe with SMTP id 4fb4d7f45d1cf-5cea966bd05mr15314543a12.5.1730754353032; Mon, 04 Nov 2024 13:05:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFqt9FZqCcmy3VPlZTkcJKX4vYLKJdFxciWf0K/FLe0rmttyz/5F2xzOazkvwO8wp001NhmOg== X-Received: by 2002:a05:6402:3592:b0:5cd:5732:ecfe with SMTP id 4fb4d7f45d1cf-5cea966bd05mr15314526a12.5.1730754352536; Mon, 04 Nov 2024 13:05:52 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cee6aae181sm300645a12.19.2024.11.04.13.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:05:51 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , "Huang, Ying" , Ani Sinha Subject: [PULL 06/65] hw/acpi: Rename build_all_acpi_generic_initiators() to build_acpi_generic_initiator() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Igor noted that this function only builds one instance, so was rather misleadingly named. Fix that. Suggested-by: Igor Mammedov Reviewed-by: Igor Mammedov Tested-by: "Huang, Ying" Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/acpi_generic_initiator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c index 7665b16107..73bafaaaea 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -74,7 +74,7 @@ static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) acpi_generic_initiator_set_node, NULL, NULL); } -static int build_all_acpi_generic_initiators(Object *obj, void *opaque) +static int build_acpi_generic_initiator(Object *obj, void *opaque) { MachineState *ms = MACHINE(qdev_get_machine()); AcpiGenericInitiator *gi; @@ -111,6 +111,6 @@ static int build_all_acpi_generic_initiators(Object *obj, void *opaque) void build_srat_generic_pci_initiator(GArray *table_data) { object_child_foreach_recursive(object_get_root(), - build_all_acpi_generic_initiators, + build_acpi_generic_initiator, table_data); } From patchwork Mon Nov 4 21:05:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC8ADD1BDF4 for ; Mon, 4 Nov 2024 21:06:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84H1-0003Ws-A1; Mon, 04 Nov 2024 16:06:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gz-0003WI-HS for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Gx-0005Hp-Ok for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754363; 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=SE9pXEMAmep9AJtTJezsr1YC4hkUva7ZKQGQAabu7F0=; b=LaRk4AYYSWhcd6J4XAcEjftmETMyQ8aNVD6uV6/3HsWQtsL42LaRfeTCaEyJ9HkFuxL3kX 8kFIYIpXEU66XRitoMD6SafsDFnu4opEKTZo3yT1uU3tVBk0EzgXdtVIEZptL3o8qkHTp0 FylXn6Cz3st/WrZwjAYy1R0ryntxKA8= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-294-or7VEbV7MYy4aSq1VzjSFQ-1; Mon, 04 Nov 2024 16:05:59 -0500 X-MC-Unique: or7VEbV7MYy4aSq1VzjSFQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a9a1828916fso515190466b.1 for ; Mon, 04 Nov 2024 13:05:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754357; x=1731359157; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SE9pXEMAmep9AJtTJezsr1YC4hkUva7ZKQGQAabu7F0=; b=IO0b89IQ1wvfuA5m56q7Uc4hCUc1q4X4wx8X6jMTib2WH5/ksuK909YnS6Uh6KQf+u ykBbqEXMFe81Eop+EgcdlzhwYfyZBlPUhdYBRvjRfFpXRRFLCH+YFkViijvanmFnpP/o 2AZPHbAfAGma3YFyEKW0/e2w3lUa8aGDtrI+L6vuv+4a+4w1ZTxtwQfC8nSQN5yozQS6 PPZYpBW74NO6tnmJKrYAurB8yyMz0nsMTlbrlOm1WdFeiltn5UmW2S9czL+zdRv6Af7Q vWLJsS+kCv+FL/mJgociZtaCi4U9gLJ6X/f5PZJLIVtoSmnOqn1/1mCsKGDaIhH80YCO 62Uw== X-Gm-Message-State: AOJu0YySvw1HO36AQ2H2MzMug0F3QlGBvRAH/qv3XleICA37fifTGKcz VkrDTvRFiLU+MW/tELiF7VNBrNsYEvmwovhcLEThUsieuuwniJh7ND/TDu1OYz5GSaYaqYmftK2 P8vw1Kkur94xb1RQAVIumo9My97f3FBcH9jbMC7n1CixBJ2nlJ4XQOxtntcH1I72qWhtvG7ujoI MTx2hxgI9nVxVYHDdyQ23/YSU5SX12tA== X-Received: by 2002:a17:907:1b98:b0:a9e:5747:9019 with SMTP id a640c23a62f3a-a9e57479111mr1089861566b.8.1730754357344; Mon, 04 Nov 2024 13:05:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGK/zQa2XbXXxffRDFtVN6aR9pgaK0xY0QmNDB/64c01xS8gPQHF5LhMbVQu5iWHu394T/Miw== X-Received: by 2002:a17:907:1b98:b0:a9e:5747:9019 with SMTP id a640c23a62f3a-a9e57479111mr1089859766b.8.1730754356931; Mon, 04 Nov 2024 13:05:56 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9eb16d6749sm31263266b.62.2024.11.04.13.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:05:56 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:53 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha , Marcel Apfelbaum Subject: [PULL 07/65] hw/pci: Add a busnr property to pci_props and use for acpi/gi Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Using a property allows us to hide the internal details of the PCI device from the code to build a SRAT Generic Initiator Affinity Structure with PCI Device Handle. Suggested-by: Igor Mammedov Reviewed-by: Igor Mammedov Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/acpi_generic_initiator.c | 14 +++++++++----- hw/pci/pci.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c index 73bafaaaea..365feb527f 100644 --- a/hw/acpi/acpi_generic_initiator.c +++ b/hw/acpi/acpi_generic_initiator.c @@ -9,6 +9,7 @@ #include "hw/boards.h" #include "hw/pci/pci_device.h" #include "qemu/error-report.h" +#include "qapi/error.h" typedef struct AcpiGenericInitiatorClass { ObjectClass parent_class; @@ -79,7 +80,8 @@ static int build_acpi_generic_initiator(Object *obj, void *opaque) MachineState *ms = MACHINE(qdev_get_machine()); AcpiGenericInitiator *gi; GArray *table_data = opaque; - PCIDevice *pci_dev; + int32_t devfn; + uint8_t bus; Object *o; if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) { @@ -100,10 +102,12 @@ static int build_acpi_generic_initiator(Object *obj, void *opaque) exit(1); } - pci_dev = PCI_DEVICE(o); - build_srat_pci_generic_initiator(table_data, gi->node, 0, - pci_bus_num(pci_get_bus(pci_dev)), - pci_dev->devfn); + bus = object_property_get_uint(o, "busnr", &error_fatal); + devfn = object_property_get_int(o, "addr", &error_fatal); + /* devfn is constrained in PCI to be 8 bit but storage is an int32_t */ + assert(devfn >= 0 && devfn < PCI_DEVFN_MAX); + + build_srat_pci_generic_initiator(table_data, gi->node, 0, bus, devfn); return 0; } diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 87da35ca9b..0b6bdaa0d7 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -67,6 +67,19 @@ static char *pcibus_get_fw_dev_path(DeviceState *dev); static void pcibus_reset_hold(Object *obj, ResetType type); static bool pcie_has_upstream_port(PCIDevice *dev); +static void prop_pci_busnr_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint8_t busnr = pci_dev_bus_num(PCI_DEVICE(obj)); + + visit_type_uint8(v, name, &busnr, errp); +} + +static const PropertyInfo prop_pci_busnr = { + .name = "busnr", + .get = prop_pci_busnr_get, +}; + static Property pci_props[] = { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), @@ -87,6 +100,7 @@ static Property pci_props[] = { QEMU_PCIE_ARI_NEXTFN_1_BITNR, false), DEFINE_PROP_SIZE32("x-max-bounce-buffer-size", PCIDevice, max_bounce_buffer_size, DEFAULT_MAX_BOUNCE_BUFFER_SIZE), + { .name = "busnr", .info = &prop_pci_busnr }, DEFINE_PROP_END_OF_LIST() }; From patchwork Mon Nov 4 21:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5BB8D1BDF5 for ; Mon, 4 Nov 2024 21:06:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84H3-0003X5-9s; Mon, 04 Nov 2024 16:06:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84H2-0003Wu-9W for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84H0-0005I2-2a for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754365; 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=ibhNWx7Y9/0HNDsidJaARdyrzm9mVk87OH/zTbpUZOE=; b=JeY/BdaGEzRwYIPhlJVlMjO0UVgjU50LGlYRNdPDlbafoM83atOgxo347B5sccEzVZ7uBp wIMqo0iEQ1vOg2DsxMcaWwYZvI+vmm1rncNN2+mBPYszvRH2v0gXeh41p3zAtNCIPWxuQ7 cRbWUwynrpycfGDoCf3x5HbwWofy0Rg= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-Mx9FZueCMnyfXLxbeP8Yow-1; Mon, 04 Nov 2024 16:06:04 -0500 X-MC-Unique: Mx9FZueCMnyfXLxbeP8Yow-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-431518ae047so31544675e9.0 for ; Mon, 04 Nov 2024 13:06:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754362; x=1731359162; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ibhNWx7Y9/0HNDsidJaARdyrzm9mVk87OH/zTbpUZOE=; b=JMm7ry+Se/nl4zEqXazeJMYmWy408aiEo2bySFSFIk8FnrhNpXGSJn0q/flsfgmtS9 BFF8T2PpQhLOjYFZWfSqD3wQzJQqAl/GMBtbZjqoEQypxz051HNzQbEF9Vkg0j/1IkLv M9O4gRYvRx6gBhIbeMxdI5eICCqbVEN99lcuda6vtG/VQC2ZjqlufNsKZLvfajLaYmkS /R5wf/jPNEBB0IgpVPIzTjbPlJWEfkn1gatzxk6rk1TAEUkwwMBs2rTsCueA7pk2B6z4 9p842qZQPx8uqyq6Aov6TA+kSid9D8a0LM8jI1rpH/rU8HIUJUgPWECeu1DindO9XDWh pMoA== X-Gm-Message-State: AOJu0Yx8XiX5FNlWdYs7C6WOX34FYiFZo0Xjl9QKTDWof4lx0Ixm6xZJ Hnd0vjk8a5sX8q01hFa+UMB1dId4syJnTYeRT1rG2Ktveu7Hu2JPInW3uKd01n9eLEyjCVhcmVk XGm6z7ExdSCrB3QeaxFCVwms2vebWxYbPNvpwCPBrGWKQEl02XtlN4+l+M2rWgQmoATw1ytbs9N KYnLBnQkVtOTbpqazcqGGFwH3luqPlBw== X-Received: by 2002:a05:6000:178b:b0:37c:c9bc:1be6 with SMTP id ffacd0b85a97d-381c79bb817mr10312943f8f.16.1730754362542; Mon, 04 Nov 2024 13:06:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEso8WU5PYTHB/lez/fUUeDzwSc93JPXHmj7Q9C74rrNTCtYiHMLoM3eTQXZ/X8c2TuPucLKg== X-Received: by 2002:a05:6000:178b:b0:37c:c9bc:1be6 with SMTP id ffacd0b85a97d-381c79bb817mr10312911f8f.16.1730754362078; Mon, 04 Nov 2024 13:06:02 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5c65b8sm162909825e9.18.2024.11.04.13.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:01 -0800 (PST) Date: Mon, 4 Nov 2024 16:05:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , "Huang, Ying" , Ani Sinha , Shannon Zhao , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , qemu-arm@nongnu.org Subject: [PULL 08/65] acpi/pci: Move Generic Initiator object handling into acpi/pci.* Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Whilst ACPI SRAT Generic Initiator Afinity Structures are able to refer to both PCI and ACPI Device Handles, the QEMU implementation only implements the PCI Device Handle case. For now move the code into the existing hw/acpi/pci.c file and header. If support for ACPI Device Handles is added in the future, perhaps this will be moved again. Also push the struct AcpiGenericInitiator down into the c file as not used outside pci.c. Suggested-by: Igor Mammedov Tested-by: "Huang, Ying" Reviewed-by: Igor Mammedov Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-7-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi_generic_initiator.h | 24 ----- include/hw/acpi/pci.h | 3 + hw/acpi/acpi_generic_initiator.c | 120 ---------------------- hw/acpi/pci.c | 124 +++++++++++++++++++++++ hw/arm/virt-acpi-build.c | 1 - hw/i386/acpi-build.c | 1 - hw/acpi/meson.build | 1 - 7 files changed, 127 insertions(+), 147 deletions(-) delete mode 100644 include/hw/acpi/acpi_generic_initiator.h delete mode 100644 hw/acpi/acpi_generic_initiator.c diff --git a/include/hw/acpi/acpi_generic_initiator.h b/include/hw/acpi/acpi_generic_initiator.h deleted file mode 100644 index 7b98676713..0000000000 --- a/include/hw/acpi/acpi_generic_initiator.h +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved - */ - -#ifndef ACPI_GENERIC_INITIATOR_H -#define ACPI_GENERIC_INITIATOR_H - -#include "qom/object_interfaces.h" - -#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator" - -typedef struct AcpiGenericInitiator { - /* private */ - Object parent; - - /* public */ - char *pci_dev; - uint16_t node; -} AcpiGenericInitiator; - -void build_srat_generic_pci_initiator(GArray *table_data); - -#endif diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h index 467a99461c..3015a8171c 100644 --- a/include/hw/acpi/pci.h +++ b/include/hw/acpi/pci.h @@ -40,4 +40,7 @@ Aml *aml_pci_device_dsm(void); void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus); void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope); + +void build_srat_generic_pci_initiator(GArray *table_data); + #endif diff --git a/hw/acpi/acpi_generic_initiator.c b/hw/acpi/acpi_generic_initiator.c deleted file mode 100644 index 365feb527f..0000000000 --- a/hw/acpi/acpi_generic_initiator.c +++ /dev/null @@ -1,120 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved - */ - -#include "qemu/osdep.h" -#include "hw/acpi/acpi_generic_initiator.h" -#include "hw/acpi/aml-build.h" -#include "hw/boards.h" -#include "hw/pci/pci_device.h" -#include "qemu/error-report.h" -#include "qapi/error.h" - -typedef struct AcpiGenericInitiatorClass { - ObjectClass parent_class; -} AcpiGenericInitiatorClass; - -OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator, acpi_generic_initiator, - ACPI_GENERIC_INITIATOR, OBJECT, - { TYPE_USER_CREATABLE }, - { NULL }) - -OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR) - -static void acpi_generic_initiator_init(Object *obj) -{ - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); - - gi->node = MAX_NODES; - gi->pci_dev = NULL; -} - -static void acpi_generic_initiator_finalize(Object *obj) -{ - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); - - g_free(gi->pci_dev); -} - -static void acpi_generic_initiator_set_pci_device(Object *obj, const char *val, - Error **errp) -{ - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); - - gi->pci_dev = g_strdup(val); -} - -static void acpi_generic_initiator_set_node(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) -{ - AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); - MachineState *ms = MACHINE(qdev_get_machine()); - uint32_t value; - - if (!visit_type_uint32(v, name, &value, errp)) { - return; - } - - if (value >= MAX_NODES) { - error_printf("%s: Invalid NUMA node specified\n", - TYPE_ACPI_GENERIC_INITIATOR); - exit(1); - } - - gi->node = value; - ms->numa_state->nodes[gi->node].has_gi = true; -} - -static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) -{ - object_class_property_add_str(oc, "pci-dev", NULL, - acpi_generic_initiator_set_pci_device); - object_class_property_add(oc, "node", "int", NULL, - acpi_generic_initiator_set_node, NULL, NULL); -} - -static int build_acpi_generic_initiator(Object *obj, void *opaque) -{ - MachineState *ms = MACHINE(qdev_get_machine()); - AcpiGenericInitiator *gi; - GArray *table_data = opaque; - int32_t devfn; - uint8_t bus; - Object *o; - - if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) { - return 0; - } - - gi = ACPI_GENERIC_INITIATOR(obj); - if (gi->node >= ms->numa_state->num_nodes) { - error_printf("%s: Specified node %d is invalid.\n", - TYPE_ACPI_GENERIC_INITIATOR, gi->node); - exit(1); - } - - o = object_resolve_path_type(gi->pci_dev, TYPE_PCI_DEVICE, NULL); - if (!o) { - error_printf("%s: Specified device must be a PCI device.\n", - TYPE_ACPI_GENERIC_INITIATOR); - exit(1); - } - - bus = object_property_get_uint(o, "busnr", &error_fatal); - devfn = object_property_get_int(o, "addr", &error_fatal); - /* devfn is constrained in PCI to be 8 bit but storage is an int32_t */ - assert(devfn >= 0 && devfn < PCI_DEVFN_MAX); - - build_srat_pci_generic_initiator(table_data, gi->node, 0, bus, devfn); - - return 0; -} - -void build_srat_generic_pci_initiator(GArray *table_data) -{ - object_child_foreach_recursive(object_get_root(), - build_acpi_generic_initiator, - table_data); -} diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c index 20b70dcd81..3e1db161cc 100644 --- a/hw/acpi/pci.c +++ b/hw/acpi/pci.c @@ -24,8 +24,13 @@ */ #include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qom/object_interfaces.h" +#include "qapi/error.h" +#include "hw/boards.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/pci.h" +#include "hw/pci/pci_device.h" #include "hw/pci/pcie_host.h" /* @@ -59,3 +64,122 @@ void build_mcfg(GArray *table_data, BIOSLinker *linker, AcpiMcfgInfo *info, acpi_table_end(linker, &table); } + +typedef struct AcpiGenericInitiator { + /* private */ + Object parent; + + /* public */ + char *pci_dev; + uint16_t node; +} AcpiGenericInitiator; + +typedef struct AcpiGenericInitiatorClass { + ObjectClass parent_class; +} AcpiGenericInitiatorClass; + +#define TYPE_ACPI_GENERIC_INITIATOR "acpi-generic-initiator" + +OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericInitiator, acpi_generic_initiator, + ACPI_GENERIC_INITIATOR, OBJECT, + { TYPE_USER_CREATABLE }, + { NULL }) + +OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericInitiator, ACPI_GENERIC_INITIATOR) + +static void acpi_generic_initiator_init(Object *obj) +{ + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); + + gi->node = MAX_NODES; + gi->pci_dev = NULL; +} + +static void acpi_generic_initiator_finalize(Object *obj) +{ + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); + + g_free(gi->pci_dev); +} + +static void acpi_generic_initiator_set_pci_device(Object *obj, const char *val, + Error **errp) +{ + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); + + gi->pci_dev = g_strdup(val); +} + +static void acpi_generic_initiator_set_node(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + AcpiGenericInitiator *gi = ACPI_GENERIC_INITIATOR(obj); + MachineState *ms = MACHINE(qdev_get_machine()); + uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { + return; + } + + if (value >= MAX_NODES) { + error_printf("%s: Invalid NUMA node specified\n", + TYPE_ACPI_GENERIC_INITIATOR); + exit(1); + } + + gi->node = value; + ms->numa_state->nodes[gi->node].has_gi = true; +} + +static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) +{ + object_class_property_add_str(oc, "pci-dev", NULL, + acpi_generic_initiator_set_pci_device); + object_class_property_add(oc, "node", "int", NULL, + acpi_generic_initiator_set_node, NULL, NULL); +} + +static int build_acpi_generic_initiator(Object *obj, void *opaque) +{ + MachineState *ms = MACHINE(qdev_get_machine()); + AcpiGenericInitiator *gi; + GArray *table_data = opaque; + int32_t devfn; + uint8_t bus; + Object *o; + + if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_INITIATOR)) { + return 0; + } + + gi = ACPI_GENERIC_INITIATOR(obj); + if (gi->node >= ms->numa_state->num_nodes) { + error_printf("%s: Specified node %d is invalid.\n", + TYPE_ACPI_GENERIC_INITIATOR, gi->node); + exit(1); + } + + o = object_resolve_path_type(gi->pci_dev, TYPE_PCI_DEVICE, NULL); + if (!o) { + error_printf("%s: Specified device must be a PCI device.\n", + TYPE_ACPI_GENERIC_INITIATOR); + exit(1); + } + + bus = object_property_get_uint(o, "busnr", &error_fatal); + devfn = object_property_get_uint(o, "addr", &error_fatal); + /* devfn is constrained in PCI to be 8 bit but storage is an int32_t */ + assert(devfn >= 0 && devfn < PCI_DEVFN_MAX); + + build_srat_pci_generic_initiator(table_data, gi->node, 0, bus, devfn); + + return 0; +} + +void build_srat_generic_pci_initiator(GArray *table_data) +{ + object_child_foreach_recursive(object_get_root(), + build_acpi_generic_initiator, + table_data); +} diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index f76fb117ad..b5973c9148 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -57,7 +57,6 @@ #include "migration/vmstate.h" #include "hw/acpi/ghes.h" #include "hw/acpi/viot.h" -#include "hw/acpi/acpi_generic_initiator.h" #include "hw/virtio/virtio-acpi.h" #include "target/arm/multiprocessing.h" diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4967aa7459..afb2fa2edc 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -68,7 +68,6 @@ #include "hw/acpi/utils.h" #include "hw/acpi/pci.h" #include "hw/acpi/cxl.h" -#include "hw/acpi/acpi_generic_initiator.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build index 7f8ccc9b7a..c8854f4d48 100644 --- a/hw/acpi/meson.build +++ b/hw/acpi/meson.build @@ -1,6 +1,5 @@ acpi_ss = ss.source_set() acpi_ss.add(files( - 'acpi_generic_initiator.c', 'acpi_interface.c', 'aml-build.c', 'bios-linker-loader.c', From patchwork Mon Nov 4 21:06:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862016 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C1A9D1BDF2 for ; Mon, 4 Nov 2024 21:06:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84H8-0003Z8-RU; Mon, 04 Nov 2024 16:06:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84H7-0003Y1-9i for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84H5-0005If-O7 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754371; 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=Twycu9LeMPLWhT+3APHxCe65PWhI42c5Tsx7A0KoeC8=; b=UMgXrgY47RJzOBmpbkERTNfPip8HZokK4K3ACD9mdfxYgonb613yq3pyMmABI4rvvRDNC6 bUSQH+mvEGh0oUbYZI6nKpz6b10lQ8EymrjlwnkGuVDiPWgYykyZQfKdwkO0JHn2e5xC5N m5Ye4RY13SWEYcStFGVkWLftEGXGvak= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-382-hlx8OxVRMRKV95QxZyl2qg-1; Mon, 04 Nov 2024 16:06:08 -0500 X-MC-Unique: hlx8OxVRMRKV95QxZyl2qg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4315dd8fe7fso39429795e9.3 for ; Mon, 04 Nov 2024 13:06:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754366; x=1731359166; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Twycu9LeMPLWhT+3APHxCe65PWhI42c5Tsx7A0KoeC8=; b=qTm7HFLRLF4nBh8WHInEwU+S2D5xIGfOe9VfCXYsFw8eo8l5ZwDRLEPOgjrYEbxK4A qaB8kPGyiOZeJ8yJfQqCjYr/wI/bPWKo0jt1lKyZciG4Cfpp3qygdr5REmrIjZDsKHcc tnx0AhzaCGkqOsPHN/6MYUvYkA+6uQwDt0X6amWOCR0vH5gXAsEAOa/7SkAMGIlZVm4N 4KBMqNrShnGbXzwtfAw4UdsoTCHT1fIMEkFMnr/fZlm8fMhRs8NIdXakQU8oZh2pw24u VU69Qg3SKw+2HUtcz/cemBXwK8mrKYb3wuDbTqTntIMVqyM/d9iF1XHwqKcwB6khC+Rf lWKQ== X-Gm-Message-State: AOJu0YxPtHjamBJLYF93NYznKNz9TneqZG2USbkCp9G3CqjwpEY0u/f+ V3koeti7XCABusGjK32/nwL+ndvQGfbSLBSNyZhvTdWCY2ntI+EoryxV1o6zpM27uJ/Ue63LJn9 Y4py2Bxu0DhfKVfC2j3LHfMBvygknB0nPXKjmNtldlRVhDi++W6f/B3WHa1CdEIRryCvhXVMxR7 LK32LCW34fgMCp43Xpfe22np+Vrq+Ahw== X-Received: by 2002:a05:6000:18ac:b0:37d:4f69:c9b with SMTP id ffacd0b85a97d-381c7a6ddd1mr15096079f8f.35.1730754366464; Mon, 04 Nov 2024 13:06:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IG403upuUw1/pSjERuBZvmBUJAi7cqFgpVdvOeZ8KP70NsIm3W+Y1VjgoyBaw8iAjV1LRramQ== X-Received: by 2002:a05:6000:18ac:b0:37d:4f69:c9b with SMTP id ffacd0b85a97d-381c7a6ddd1mr15096056f8f.35.1730754366056; Mon, 04 Nov 2024 13:06:06 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd8e7f33sm194127935e9.6.2024.11.04.13.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:05 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:02 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , "Huang, Ying" , Marcel Apfelbaum Subject: [PULL 09/65] hw/pci-bridge: Add acpi_uid property to TYPE_PXB_BUS Message-ID: <97b9cb066e5f10845b4bc4d2ec657deb1e73f910.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Enable ACPI table creation for PCI Expander Bridges to be independent of PCI internals. Note that the UID is currently the PCI bus number. This is motivated by the forthcoming ACPI Generic Port SRAT entries which can be made completely independent of PCI internals. Suggested-by: Igor Mammedov Tested-by: "Huang, Ying" Reviewed-by: Igor Mammedov Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/pci_expander_bridge.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index dfaea6cbf4..3d52ea5867 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -85,12 +85,25 @@ static uint16_t pxb_bus_numa_node(PCIBus *bus) return pxb->numa_node; } +static void prop_pxb_uid_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + uint32_t uid = pci_bus_num(PCI_BUS(obj)); + + visit_type_uint32(v, name, &uid, errp); +} + static void pxb_bus_class_init(ObjectClass *class, void *data) { PCIBusClass *pbc = PCI_BUS_CLASS(class); pbc->bus_num = pxb_bus_num; pbc->numa_node = pxb_bus_numa_node; + + object_class_property_add(class, "acpi_uid", "uint32", + prop_pxb_uid_get, NULL, NULL, NULL); + object_class_property_set_description(class, "acpi_uid", + "ACPI Unique ID used to distinguish this PCI Host Bridge / ACPI00016"); } static const TypeInfo pxb_bus_info = { From patchwork Mon Nov 4 21:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50F96D1BDF3 for ; Mon, 4 Nov 2024 21:06:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84HG-0003zI-HG; Mon, 04 Nov 2024 16:06:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HB-0003ns-Pk for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HA-0005Iv-9A for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754375; 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=M3wqy1laOvYaRTXIjGpIu1PJBysiXZhRmeHUFm2/bAI=; b=U83kTbrpz1EwgPPdBGnJ6X/rrQt//Pzft+vyprzwhRFEYDfH1qpR+vF3HcLdAo8ivFCJHB fgVc2HFvQ+RSOvTvFgABnbHhtixBQY6sSdn5vd3ILrX3u8QQA5C+WxU8EbSys9VCatXdxP Ih1aGUHvOoejYlJ4T94bLm3GBUM9gdk= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-580-TJYuk4i_PKyfpRLfbfq5jQ-1; Mon, 04 Nov 2024 16:06:13 -0500 X-MC-Unique: TJYuk4i_PKyfpRLfbfq5jQ-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539e5f9df25so2787908e87.0 for ; Mon, 04 Nov 2024 13:06:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754371; x=1731359171; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=M3wqy1laOvYaRTXIjGpIu1PJBysiXZhRmeHUFm2/bAI=; b=Li4JTDOta8KQ6Yim3QYDjcjXhFhEx77mN4ZR4JnagLT6Dt3DcL0KE6z68obY4Wtdeg Pc5pgg2xNAL0dOtvMPJgfR4McpgGCzq7FsWjQQJC+gMWKPeSxu/idIiUJA3Vo4Z5b4Bk DqPq+hHQCrDgnYntEMFTxxLdtZVJkBgpRUcib0yxt26VZT9UnMWVqFHIZ2UjtswC0r6h l3YlEhJaa30C8nqSw+J5CSfRBBRK3VJt0czKYq3a57tVhWLEpbvt3JC8udHVD7kZ7QS4 1vSdpOBhuGhsaIcF2gR6+fTlCrx5GjQT0ggG8236b4d4aa7X0MfQQZF+jEwG07Tm0L8a QZSw== X-Gm-Message-State: AOJu0Yw49k/BEVNZJ9gEVQt+Y/iHP6jUWoYxQZZu+RKO9in6ntqZrXh9 xyklAAWN7vzuqNgHvnm7AFUY2o2cvsKsMxEkhPuV8Vd5kvDCaOkmSUIGiQaGkia7msqKRKDN0nt hrW916IXDszIdnoZE7ULSUrXjSzBcBS8G2Bh14L57ZvL9VAuS+n/mMQi/7/cGOp59J2NOw7pjQH Wcw1v/307SpSfe1DMOeXrVjBRktpiXNg== X-Received: by 2002:a05:6512:e98:b0:533:3fc8:43ee with SMTP id 2adb3069b0e04-53b348d0d3emr17331355e87.13.1730754371545; Mon, 04 Nov 2024 13:06:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEP7970synxMt3POaa+uRKLERHLgm2zCMyXwZvmPOKdkSaL1Gx8xe0NbiHTZdZmW+xZJ17cxA== X-Received: by 2002:a05:6512:e98:b0:533:3fc8:43ee with SMTP id 2adb3069b0e04-53b348d0d3emr17331324e87.13.1730754371031; Mon, 04 Nov 2024 13:06:11 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432a26a7508sm907965e9.0.2024.11.04.13.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:09 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , "Huang, Ying" , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 10/65] hw/i386/acpi: Use TYPE_PXB_BUS property acpi_uid for DSDT Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Rather than relying on PCI internals, use the new acpi_property to obtain the ACPI _UID values. These are still the same as the PCI Bus numbers so no functional change. Suggested-by: Igor Mammedov Tested-by: "Huang, Ying" Reviewed-by: Igor Mammedov Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-9-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index afb2fa2edc..88227e343e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1475,6 +1475,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, QLIST_FOREACH(bus, &bus->child, sibling) { uint8_t bus_num = pci_bus_num(bus); uint8_t numa_node = pci_bus_numa_node(bus); + uint32_t uid; /* look only for expander root buses */ if (!pci_bus_is_root(bus)) { @@ -1485,6 +1486,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, root_bus_limit = bus_num - 1; } + uid = object_property_get_uint(OBJECT(bus), "acpi_uid", + &error_fatal); scope = aml_scope("\\_SB"); if (pci_bus_is_cxl(bus)) { @@ -1492,7 +1495,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, } else { dev = aml_device("PC%.02X", bus_num); } - aml_append(dev, aml_name_decl("_UID", aml_int(bus_num))); + aml_append(dev, aml_name_decl("_UID", aml_int(uid))); aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num))); if (pci_bus_is_cxl(bus)) { struct Aml *aml_pkg = aml_package(2); From patchwork Mon Nov 4 21:06:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A647ED1BDF2 for ; Mon, 4 Nov 2024 21:07:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84HJ-00046E-7w; Mon, 04 Nov 2024 16:06:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HG-00040T-S0 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HF-0005J9-BX for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754380; 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=2qdo9pEk4CelGXaMondgwabGTs+HLMaG1XM8q352Z8M=; b=TX7JAYm/S8EtknVPnLT7v4yi/Ne4unqNAr+78XUvAcB5S1OpQ53Yfu0kwy9yVt5+aLAcrG 7ryf9gRmVCde7epfFkqnveQ6c03MaIOIJSxh9+4BdoDMTbVUBMPw0lwfHWVPZgnvZZsXxo mKVk3Yz2DvWv6YI3koA6tW4+l2vAj8E= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-HUGFVHsKOlWW4v7ZCeY4CQ-1; Mon, 04 Nov 2024 16:06:18 -0500 X-MC-Unique: HUGFVHsKOlWW4v7ZCeY4CQ-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-539fb5677c9so4678468e87.0 for ; Mon, 04 Nov 2024 13:06:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754377; x=1731359177; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2qdo9pEk4CelGXaMondgwabGTs+HLMaG1XM8q352Z8M=; b=OBRQ+XuVdVX18TFNpDjYAk/25RaPqRsjHF9cnBvVo3Qor5/neYtyuoMBMRqrENvc2W uwpDmvp5Ff8jdHSmseQMfurEuXRrP3W+9FUfoKvdj4oNKjD17j3AwB6sykcGIyYPeSNk uiT1ozgRCA/DJW7fGW519ArHcysW607U9Jb7AAGSjsAPuZe8sWJQ6OHtneAp0ofjyDf4 MiWKfuO93ylmr9Z6Hu94iVreojlz5a63H/0SNmzVBsBSm4EXpzJvQ22Ke+F/nFaXJe2H GJYZMAULlF6jAPSGpUMbgWAD04DOChOpIAXGtqRMBpnLKo1hI1SmU9vOFWKU6BXRKj3W qykg== X-Gm-Message-State: AOJu0YweMOrCnCBLpL+uEH6p3H70t7te7HeTNJtAFh6ggChRfcXhPDq2 krjAQcuj0c1aQFORc2HjbcIRIZBt2BnSe1kvnfF8mkM4MNAjm/vwLEKYsALamtA3/ZV3ZBxrukc g3T/zil7SHxcP/ZeKsi+OAr/v7mcRtMuNRxtl2E86fhdPAWD2+2vKpBMW99mCyCd72STUQFBxLT jN30on5xbX67hVNO6IsrYTzgLAPF1JPg== X-Received: by 2002:a05:6512:1314:b0:534:3cdc:dbef with SMTP id 2adb3069b0e04-53b3491cd2amr19144354e87.43.1730754376618; Mon, 04 Nov 2024 13:06:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoMq+F5bWqwsmmF4Sec9XjkQEEzI85UK78KqhmTuRS7jnHG3c9C4eQxvXbvVuGQFZ5szhV5A== X-Received: by 2002:a05:6512:1314:b0:534:3cdc:dbef with SMTP id 2adb3069b0e04-53b3491cd2amr19144322e87.43.1730754376098; Mon, 04 Nov 2024 13:06:16 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9403bfsm194347725e9.21.2024.11.04.13.06.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:15 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , "Huang, Ying" , Sunil V L , Alistair Francis , Daniel Henrique Barboza Subject: [PULL 11/65] hw/pci-host/gpex-acpi: Use acpi_uid property. Message-ID: <43eb5e1f73f1b943d952d9776681a51f05ca7aa8.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Reduce the direct use of PCI internals inside ACPI table creation. Suggested-by: Igor Mammedov Tested-by: "Huang, Ying" Reviewed-by: Igor Mammedov Signed-off-by: Jonathan Cameron Message-Id: <20240916171017.1841767-10-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-host/gpex-acpi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c index 391fabb8a8..e8b4c64c5f 100644 --- a/hw/pci-host/gpex-acpi.c +++ b/hw/pci-host/gpex-acpi.c @@ -141,6 +141,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) QLIST_FOREACH(bus, &bus->child, sibling) { uint8_t bus_num = pci_bus_num(bus); uint8_t numa_node = pci_bus_numa_node(bus); + uint32_t uid; bool is_cxl = pci_bus_is_cxl(bus); if (!pci_bus_is_root(bus)) { @@ -156,6 +157,8 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) nr_pcie_buses = bus_num; } + uid = object_property_get_uint(OBJECT(bus), "acpi_uid", + &error_fatal); dev = aml_device("PC%.02X", bus_num); if (is_cxl) { struct Aml *pkg = aml_package(2); @@ -168,7 +171,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) aml_append(dev, aml_name_decl("_CID", aml_string("PNP0A03"))); } aml_append(dev, aml_name_decl("_BBN", aml_int(bus_num))); - aml_append(dev, aml_name_decl("_UID", aml_int(bus_num))); + aml_append(dev, aml_name_decl("_UID", aml_int(uid))); aml_append(dev, aml_name_decl("_STR", aml_unicode("pxb Device"))); aml_append(dev, aml_name_decl("_CCA", aml_int(1))); if (numa_node != NUMA_NODE_UNASSIGNED) { From patchwork Mon Nov 4 21:06:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FE1AD1BDF2 for ; Mon, 4 Nov 2024 21:07:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84HQ-0004aq-QP; Mon, 04 Nov 2024 16:06:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HN-0004Ul-W1 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HL-0005JX-P0 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754386; 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=JBy/Nl5xx97LKS0DNOehVSO7MOxTahNCY7DAG+OBNKA=; b=L84JYH8m91ZkzPtMrWxqb+bIEHI+VRhPODA2liTz2mYpmkSCeGyQTRgT8KNCnQud4vK7W3 Bu4dWN8Dt339ZTv2HvPA8hHj66XaeQ/W5LtkD2Xuhh5Ygj9q98tBMIOi8XzngMl7w5qz17 E5FwnJffqkrl75Fdt0bjqLOC+6Of8ws= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-498-bziknDFzMTCheoIe_Fy-iw-1; Mon, 04 Nov 2024 16:06:25 -0500 X-MC-Unique: bziknDFzMTCheoIe_Fy-iw-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2fb58d1da8eso26884991fa.0 for ; Mon, 04 Nov 2024 13:06:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754383; x=1731359183; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=JBy/Nl5xx97LKS0DNOehVSO7MOxTahNCY7DAG+OBNKA=; b=Rnu34lxIxQTyaLsLIsLxXvj8Y3lmieJidABVnUc+f3qwj4LsNZijVeQIPTBKGOX+Re MY5pR0sRZx87/SGPZoTFsyYRRcCQ+COPuscH8DXhYu1YKevTi7LYn1v2B8zQEcH9fuPM mCKhuuI4MrrJm1mbPah2yKj0tEDtJx0dapQGy9Ot9pJvhfutoDAklaU6xF5j0foXWoJh NHRgtGgajJITH68zx7GRMcH6sXlg1+bs1QGY8iv2ndnNx6WX9OZnhv7lXWVl/1ecuHTn 3Q+pJdrgY2U2Yl3TqXmQN+3vAh30c6RbBId9Y7O+XjXYgEAPQrOnGzY2VIFd51VJhgAY ME1Q== X-Gm-Message-State: AOJu0YwZhSmMgnH2slukqb+JQwNzWy+Y2pON45rkJJBvxv4tTO8EUpfB 6NbUsoAsVnL/mFnpzbEw0X7YuInV4cjQs8EVaDkNUd93FJ45wXCkB/XHjFXzgrFO86GQ+rUVBIY lDfCCx+OHeQBytJ2l4pQofHiwLiICCxNdWlMEAHpcsqdMRiPM2N7rw/szFQhlCiJ+O0ZCCM7b+s HWZ6pA0lDAJFusRIutNNd8MTFxSyNstw== X-Received: by 2002:a05:651c:54a:b0:2f6:4f17:aeaf with SMTP id 38308e7fff4ca-2fedb7ed786mr58722791fa.45.1730754382938; Mon, 04 Nov 2024 13:06:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2E26KbrvPpnh9uLsGNSnQK+tO72+I/zAhoIQCOBTPPBX/gfbkX+gkZjnoyplQ+3TSwvE9UA== X-Received: by 2002:a05:651c:54a:b0:2f6:4f17:aeaf with SMTP id 38308e7fff4ca-2fedb7ed786mr58721771fa.45.1730754380805; Mon, 04 Nov 2024 13:06:20 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d6983c2sm168460605e9.42.2024.11.04.13.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:20 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Markus Armbruster , "Huang, Ying" , Igor Mammedov , Ani Sinha , Shannon Zhao , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Eric Blake , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , qemu-arm@nongnu.org Subject: [PULL 12/65] hw/acpi: Generic Port Affinity Structure support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron These are very similar to the recently added Generic Initiators but instead of representing an initiator of memory traffic they represent an edge point beyond which may lie either targets or initiators. Here we add these ports such that they may be targets of hmat_lb records to describe the latency and bandwidth from host side initiators to the port. A discoverable mechanism such as UEFI CDAT read from CXL devices and switches is used to discover the remainder of the path, and the OS can build up full latency and bandwidth numbers as need for work and data placement decisions. Acked-by: Markus Armbruster Tested-by: "Huang, Ying" Signed-off-by: Jonathan Cameron Message-Id: <20240916174122.1843197-1-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/qom.json | 41 ++++++++++ include/hw/acpi/aml-build.h | 3 + include/hw/acpi/pci.h | 2 +- include/hw/pci/pci_bridge.h | 1 + hw/acpi/aml-build.c | 39 ++++++++++ hw/acpi/pci.c | 116 +++++++++++++++++++++++++++- hw/arm/virt-acpi-build.c | 2 +- hw/i386/acpi-build.c | 2 +- hw/pci-bridge/pci_expander_bridge.c | 1 - 9 files changed, 202 insertions(+), 5 deletions(-) diff --git a/qapi/qom.json b/qapi/qom.json index 321ccd708a..a8beeabf1f 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -844,6 +844,45 @@ 'data': { 'pci-dev': 'str', 'node': 'uint32' } } +## +# @AcpiGenericPortProperties: +# +# Properties for acpi-generic-port objects. +# +# @pci-bus: QOM path of the PCI bus of the hostbridge associated with +# this SRAT Generic Port Affinity Structure. This is the same as +# the bus parameter for the root ports attached to this host +# bridge. The resulting SRAT Generic Port Affinity Structure will +# refer to the ACPI object in DSDT that represents the host bridge +# (e.g. ACPI0016 for CXL host bridges). See ACPI 6.5 Section +# 5.2.16.7 for more information. +# +# @node: Similar to a NUMA node ID, but instead of providing a +# reference point used for defining NUMA distances and access +# characteristics to memory or from an initiator (e.g. CPU), this +# node defines the boundary point between non-discoverable system +# buses which must be described by firmware, and a discoverable +# bus. NUMA distances and access characteristics are defined to +# and from that point. For system software to establish full +# initiator to target characteristics this information must be +# combined with information retrieved from the discoverable part +# of the path. An example would use CDAT (see UEFI.org) +# information read from devices and switches in conjunction with +# link characteristics read from PCIe Configuration space. +# To get the full path latency from CPU to CXL attached DRAM +# CXL device: Add the latency from CPU to Generic Port (from +# HMAT indexed via the the node ID in this SRAT structure) to +# that for CXL bus links, the latency across intermediate switches +# and from the EP port to the actual memory. Bandwidth is more +# complex as there may be interleaving across multiple devices +# and shared links in the path. +# +# Since: 9.1 +## +{ 'struct': 'AcpiGenericPortProperties', + 'data': { 'pci-bus': 'str', + 'node': 'uint32' } } + ## # @RngProperties: # @@ -1043,6 +1082,7 @@ { 'enum': 'ObjectType', 'data': [ 'acpi-generic-initiator', + 'acpi-generic-port', 'authz-list', 'authz-listfile', 'authz-pam', @@ -1118,6 +1158,7 @@ 'discriminator': 'qom-type', 'data': { 'acpi-generic-initiator': 'AcpiGenericInitiatorProperties', + 'acpi-generic-port': 'AcpiGenericPortProperties', 'authz-list': 'AuthZListProperties', 'authz-listfile': 'AuthZListFileProperties', 'authz-pam': 'AuthZPAMProperties', diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 33eef85791..47a4692a7d 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -490,6 +490,9 @@ void build_srat_pci_generic_initiator(GArray *table_data, int node, uint16_t segment, uint8_t bus, uint8_t devfn); +void build_srat_acpi_generic_port(GArray *table_data, uint32_t node, + const char *hid, uint32_t uid); + void build_slit(GArray *table_data, BIOSLinker *linker, MachineState *ms, const char *oem_id, const char *oem_table_id); diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h index 3015a8171c..6359d574fd 100644 --- a/include/hw/acpi/pci.h +++ b/include/hw/acpi/pci.h @@ -41,6 +41,6 @@ Aml *aml_pci_device_dsm(void); void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus); void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope); -void build_srat_generic_pci_initiator(GArray *table_data); +void build_srat_generic_affinity_structures(GArray *table_data); #endif diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h index 5cd452115a..5456e24883 100644 --- a/include/hw/pci/pci_bridge.h +++ b/include/hw/pci/pci_bridge.h @@ -102,6 +102,7 @@ typedef struct PXBPCIEDev { PXBDev parent_obj; } PXBPCIEDev; +#define TYPE_PXB_CXL_BUS "pxb-cxl-bus" #define TYPE_PXB_DEV "pxb" OBJECT_DECLARE_SIMPLE_TYPE(PXBDev, PXB_DEV) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index aeb4cb94e8..7a06ffec5a 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1954,6 +1954,19 @@ static void build_append_srat_pci_device_handle(GArray *table_data, build_append_int_noprefix(table_data, 0, 12); } +static void build_append_srat_acpi_device_handle(GArray *table_data, + const char *hid, + uint32_t uid) +{ + assert(strlen(hid) == 8); + /* Device Handle - ACPI */ + for (int i = 0; i < sizeof(hid); i++) { + build_append_int_noprefix(table_data, hid[i], 1); + } + build_append_int_noprefix(table_data, uid, 4); + build_append_int_noprefix(table_data, 0, 4); +} + /* * ACPI spec, Revision 6.3 * 5.2.16.6 Generic Initiator Affinity Structure @@ -1981,6 +1994,32 @@ void build_srat_pci_generic_initiator(GArray *table_data, int node, build_append_int_noprefix(table_data, 0, 4); } +/* + * ACPI spec, Revision 6.5 + * 5.2.16.7 Generic Port Affinity Structure + * With ACPI Device Handle. + */ +void build_srat_acpi_generic_port(GArray *table_data, uint32_t node, + const char *hid, uint32_t uid) +{ + /* Type */ + build_append_int_noprefix(table_data, 6, 1); + /* Length */ + build_append_int_noprefix(table_data, 32, 1); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 1); + /* Device Handle Type: ACPI */ + build_append_int_noprefix(table_data, 0, 1); + /* Proximity Domain */ + build_append_int_noprefix(table_data, node, 4); + /* Device Handle */ + build_append_srat_acpi_device_handle(table_data, hid, uid); + /* Flags - GP Enabled */ + build_append_int_noprefix(table_data, 1, 4); + /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); +} + /* * ACPI spec 5.2.17 System Locality Distance Information Table * (Revision 2.0 or later) diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c index 3e1db161cc..d7a0e91f01 100644 --- a/hw/acpi/pci.c +++ b/hw/acpi/pci.c @@ -30,6 +30,7 @@ #include "hw/boards.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/pci.h" +#include "hw/pci/pci_bridge.h" #include "hw/pci/pci_device.h" #include "hw/pci/pcie_host.h" @@ -177,9 +178,122 @@ static int build_acpi_generic_initiator(Object *obj, void *opaque) return 0; } -void build_srat_generic_pci_initiator(GArray *table_data) +typedef struct AcpiGenericPort { + /* private */ + Object parent; + + /* public */ + char *pci_bus; + uint32_t node; +} AcpiGenericPort; + +typedef struct AcpiGenericPortClass { + ObjectClass parent_class; +} AcpiGenericPortClass; + +#define TYPE_ACPI_GENERIC_PORT "acpi-generic-port" + +OBJECT_DEFINE_TYPE_WITH_INTERFACES(AcpiGenericPort, acpi_generic_port, + ACPI_GENERIC_PORT, OBJECT, + { TYPE_USER_CREATABLE }, + { NULL }) + +OBJECT_DECLARE_SIMPLE_TYPE(AcpiGenericPort, ACPI_GENERIC_PORT) + +static void acpi_generic_port_init(Object *obj) +{ + AcpiGenericPort *gp = ACPI_GENERIC_PORT(obj); + + gp->node = MAX_NODES; + gp->pci_bus = NULL; +} + +static void acpi_generic_port_finalize(Object *obj) +{ + AcpiGenericPort *gp = ACPI_GENERIC_PORT(obj); + + g_free(gp->pci_bus); +} + +static void acpi_generic_port_set_pci_bus(Object *obj, const char *val, + Error **errp) +{ + AcpiGenericPort *gp = ACPI_GENERIC_PORT(obj); + + gp->pci_bus = g_strdup(val); +} + +static void acpi_generic_port_set_node(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + AcpiGenericPort *gp = ACPI_GENERIC_PORT(obj); + uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { + return; + } + + if (value >= MAX_NODES) { + error_printf("%s: Invalid NUMA node specified\n", + TYPE_ACPI_GENERIC_INITIATOR); + exit(1); + } + + gp->node = value; +} + +static void acpi_generic_port_class_init(ObjectClass *oc, void *data) +{ + object_class_property_add_str(oc, "pci-bus", NULL, + acpi_generic_port_set_pci_bus); + object_class_property_set_description(oc, "pci-bus", + "PCI Bus of the host bridge associated with this GP affinity structure"); + object_class_property_add(oc, "node", "int", NULL, + acpi_generic_port_set_node, NULL, NULL); + object_class_property_set_description(oc, "node", + "The NUMA node like ID to index HMAT/SLIT NUMA properties involving GP"); +} + +static int build_acpi_generic_port(Object *obj, void *opaque) +{ + MachineState *ms = MACHINE(qdev_get_machine()); + const char *hid = "ACPI0016"; + GArray *table_data = opaque; + AcpiGenericPort *gp; + uint32_t uid; + Object *o; + + if (!object_dynamic_cast(obj, TYPE_ACPI_GENERIC_PORT)) { + return 0; + } + + gp = ACPI_GENERIC_PORT(obj); + + if (gp->node >= ms->numa_state->num_nodes) { + error_printf("%s: node %d is invalid.\n", + TYPE_ACPI_GENERIC_PORT, gp->node); + exit(1); + } + + o = object_resolve_path_type(gp->pci_bus, TYPE_PXB_CXL_BUS, NULL); + if (!o) { + error_printf("%s: device must be a CXL host bridge.\n", + TYPE_ACPI_GENERIC_PORT); + exit(1); + } + + uid = object_property_get_uint(o, "acpi_uid", &error_fatal); + build_srat_acpi_generic_port(table_data, gp->node, hid, uid); + + return 0; +} + +void build_srat_generic_affinity_structures(GArray *table_data) { object_child_foreach_recursive(object_get_root(), build_acpi_generic_initiator, table_data); + object_child_foreach_recursive(object_get_root(), build_acpi_generic_port, + table_data); } diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index b5973c9148..620992c92c 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -510,7 +510,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } - build_srat_generic_pci_initiator(table_data); + build_srat_generic_affinity_structures(table_data); if (ms->nvdimms_state->is_enabled) { nvdimm_build_srat(table_data); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 88227e343e..d01e704162 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1973,7 +1973,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) build_srat_memory(table_data, 0, 0, 0, MEM_AFFINITY_NOFLAGS); } - build_srat_generic_pci_initiator(table_data); + build_srat_generic_affinity_structures(table_data); /* * Entry is required for Windows to enable memory hotplug in OS diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index 3d52ea5867..4578e03024 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -38,7 +38,6 @@ DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS, DECLARE_INSTANCE_CHECKER(PXBBus, PXB_PCIE_BUS, TYPE_PXB_PCIE_BUS) -#define TYPE_PXB_CXL_BUS "pxb-cxl-bus" DECLARE_INSTANCE_CHECKER(PXBBus, PXB_CXL_BUS, TYPE_PXB_CXL_BUS) From patchwork Mon Nov 4 21:06:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862068 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2442D1BDF3 for ; Mon, 4 Nov 2024 21:11:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84HR-0004i7-Fl; Mon, 04 Nov 2024 16:06:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HQ-0004eP-Gd for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HO-0005Jj-Gt for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754389; 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=q0uhS2hkjfzMF9odNW6FeM9PeY7E/hPIzXL+GkcXz8Q=; b=ahebj2IOzCIL4MeIYw2Gy+Kxw/H6+0ERFccW43r12DKmiCa98VrQiKUxW8lsDfxYkEvwQ2 G1j9rGJ7cfXwHV7D/CSO+mBI8iU69qB3eMe0UYlgj7X/7oXAHPPH4z+ewLSA+ucgcz5XT9 wYkdB8/0pZej93eail4CR6gawK6UquI= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-208-EuztRBwvMY2UHozMTYlKWQ-1; Mon, 04 Nov 2024 16:06:28 -0500 X-MC-Unique: EuztRBwvMY2UHozMTYlKWQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43152cd2843so27531785e9.3 for ; Mon, 04 Nov 2024 13:06:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754387; x=1731359187; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=q0uhS2hkjfzMF9odNW6FeM9PeY7E/hPIzXL+GkcXz8Q=; b=daIYhpKnlVWk0cykYyYrAIQOduYHbuwi7w0jCV+dj2TaVpQGuk+B9zj18e6vaZYb84 gIJAHoEQUmBmMFMBgFvvUNkiQ6WltOafnac2oul8J9Pgy+swl9ZSN9bmEUu1Zmz5NyQl OjExLe+26kyl8uCVEhTEgOinF/NGxlmWEU3Si5b9b4bzzqgZHWzWyMXr7blxt+/HGXGg OgyItPddnPyi+bF/iyDkZaguO/66n2IXFyWvURGvFuoy7fXWS95x1uSW8SWD4nyOgyEL VnX0m2uyvOFx7c2JREHFubyBUQMW6ebZkBUoVWrDXK9z2HasWPAZIU7es2zje+3ScOOg ekOg== X-Gm-Message-State: AOJu0Yz+Tb/t7OiKTHMKd+S+LnCBqMyb1AZZdzXEVuRicIbBPmZAMimq CwIoz05WT8dmWGKWs2BWb1EyK/KonjMeLxDa1Fwzm6YYyv1RQihGJr1+MI8ofVELQHZrxJSFP8D L+nfTTnDy0qYgx4DvEJq+SfTfBFoczjSmRTfO27zF6AuVFIDF/QQewiLO85Zrfy+rc0pVwCNXkX q6RpGQju4F4mplpddQ/wBFNjeLAdmx3w== X-Received: by 2002:a05:600c:1d97:b0:431:5459:33c2 with SMTP id 5b1f17b1804b1-431bb99053bmr214908565e9.17.1730754386672; Mon, 04 Nov 2024 13:06:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVTtiklzyTJrDLccgRW3ibAwEn75Ctz2tX9K5IR6uLXhhLZt/aojafCisItrOEI+UXHKxqXA== X-Received: by 2002:a05:600c:1d97:b0:431:5459:33c2 with SMTP id 5b1f17b1804b1-431bb99053bmr214908065e9.17.1730754385290; Mon, 04 Nov 2024 13:06:25 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9ca704sm194483875e9.41.2024.11.04.13.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:24 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 13/65] hw/acpi: Make storage of node id uint32_t to reduce fragility Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron >From review of generic port introduction. The value is handled as a uint32_t so store it in that type. The value cannot in reality exceed MAX_NODES which is currently 128 but if the types are matched there is no need to rely on that restriction. Signed-off-by: Jonathan Cameron Message-Id: <20240916174237.1843213-1-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/aml-build.h | 2 +- hw/acpi/aml-build.c | 2 +- hw/acpi/pci.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 47a4692a7d..4fd5da49e7 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -486,7 +486,7 @@ Aml *build_crs(PCIHostState *host, CrsRangeSet *range_set, uint32_t io_offset, void build_srat_memory(GArray *table_data, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags); -void build_srat_pci_generic_initiator(GArray *table_data, int node, +void build_srat_pci_generic_initiator(GArray *table_data, uint32_t node, uint16_t segment, uint8_t bus, uint8_t devfn); diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 7a06ffec5a..6a76626177 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1972,7 +1972,7 @@ static void build_append_srat_acpi_device_handle(GArray *table_data, * 5.2.16.6 Generic Initiator Affinity Structure * With PCI Device Handle. */ -void build_srat_pci_generic_initiator(GArray *table_data, int node, +void build_srat_pci_generic_initiator(GArray *table_data, uint32_t node, uint16_t segment, uint8_t bus, uint8_t devfn) { diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c index d7a0e91f01..a4835ce563 100644 --- a/hw/acpi/pci.c +++ b/hw/acpi/pci.c @@ -72,7 +72,7 @@ typedef struct AcpiGenericInitiator { /* public */ char *pci_dev; - uint16_t node; + uint32_t node; } AcpiGenericInitiator; typedef struct AcpiGenericInitiatorClass { From patchwork Mon Nov 4 21:06:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E84ED1BDF2 for ; Mon, 4 Nov 2024 21:08:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84HV-0004zi-9B; Mon, 04 Nov 2024 16:06:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HT-0004wm-V7 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HS-0005Jw-0k for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754392; 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=dCRrMYXD6Pe/Ubi6i0nnMTLJDmbumZJJyb+bWDGt8WY=; b=iIRobordhmQaFOh6vuJ5l3av46B4pIC7holHIY4osSBotAueE/gYdYuZ1JXYFAqbu6BXfN sq3u+ng14c8w4iCO91MGwbhlTKdlceTlmw3rKUUcPY0MzzQGEVNByJ2GqIJ0zfs14+zBDD QQQ5CNe7WxBMIoiuPXF03H0tF9774gw= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-410-757fbEIYPNO_EsmRVpNRWQ-1; Mon, 04 Nov 2024 16:06:30 -0500 X-MC-Unique: 757fbEIYPNO_EsmRVpNRWQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d531a19a9so2469287f8f.1 for ; Mon, 04 Nov 2024 13:06:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754389; x=1731359189; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dCRrMYXD6Pe/Ubi6i0nnMTLJDmbumZJJyb+bWDGt8WY=; b=LTFZ/ayhC4N9htgl090UA9iFk3yQIuabdt0N+b7mf1uAELL40eSOUdfT/AbmVuMshZ SuXcT0El7vR06lG3+wcu5uThb6DJhzWAwEALASUOTJvSP9MwKQsfmSjDVQN9lXIPHxoG Fj0vaqFjgRThj6zvxstzJkLCrysRaAU/Ctscn3djFmpklvhJ3rdBEiXfwRKoWwRcXdNN F1BTLVeHYCp5oali9rgrhFlkQLZamCBQ8IObnq6bzec4nfpJcFKuT7mh+0h9EMxsQaEd 5yQEo0Vr6xFnZdzlb0phWKdjPbPAE77kXGHgN9W+M4XorI1KtVgFPY942zc2/J/lp7Hw bXfA== X-Gm-Message-State: AOJu0YyzznaikwZNSM64ME8eFDD3yNXEaHrNMDdSniggV2UZ0+GOu3cv oQpu99KckuEHPHdtgDzymtD3eTO5XduqqaiakU2NcyMl0oVAVOCn57Z8FUIMloJznHz823/iACJ I3NIr1g42n7ZyJDKUsuJFM93kO/nDKMHMq2SLm4pKYYv5HpA/2SIbCj31UhhS9jOwVLty9jcU/4 b5sZAzirNA7WvuEhM1u/W97rxKQOzBwg== X-Received: by 2002:a5d:5846:0:b0:37d:47b3:7b86 with SMTP id ffacd0b85a97d-381be907df1mr12725082f8f.44.1730754388874; Mon, 04 Nov 2024 13:06:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFyaot0ySyGqJIQHM/PQMIiBr+KiNmaRy7e6Zd60Zed3R+ymcV1PrTo/b/4RstJ9i49yxik+g== X-Received: by 2002:a5d:5846:0:b0:37d:47b3:7b86 with SMTP id ffacd0b85a97d-381be907df1mr12725059f8f.44.1730754388483; Mon, 04 Nov 2024 13:06:28 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c116c13asm14075765f8f.109.2024.11.04.13.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:27 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 14/65] hw/acpi: Generic Initiator - add missing object class property descriptions. Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron >From review of the Generic Ports support. These properties had no description set so add one. Signed-off-by: Jonathan Cameron Message-Id: <20240916174321.1843228-1-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c index a4835ce563..f88f450af3 100644 --- a/hw/acpi/pci.c +++ b/hw/acpi/pci.c @@ -137,8 +137,12 @@ static void acpi_generic_initiator_class_init(ObjectClass *oc, void *data) { object_class_property_add_str(oc, "pci-dev", NULL, acpi_generic_initiator_set_pci_device); + object_class_property_set_description(oc, "pci-dev", + "PCI device to associate with the node"); object_class_property_add(oc, "node", "int", NULL, acpi_generic_initiator_set_node, NULL, NULL); + object_class_property_set_description(oc, "node", + "NUMA node associated with the PCI device"); } static int build_acpi_generic_initiator(Object *obj, void *opaque) From patchwork Mon Nov 4 21:06:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1717D1BDF2 for ; Mon, 4 Nov 2024 21:08:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84HX-0005BC-Jf; Mon, 04 Nov 2024 16:06:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HV-000548-Qr for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HU-0005KP-DQ for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754395; 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=HT4p44lGhUJLiZNcVVDhq7UK1RgS21i7OPit+tLHM+w=; b=I3vPxiRIVXLG8uYlDP8e3/nBdEnsRA6VsfmK23WKxOdXnkx7xkxY02lafjo3bH1t75Z18r Ms6wOIk58r2RIxX23ODCzYzWd0M7N282wiwwS7CkhwYSY76/pgwz66AJeDDLtGCgWODIi1 ejHlcZxCSXzh12333nwggYlIeqEEI5Y= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-mLO1yNvdNz6CK4M4SIi5iA-1; Mon, 04 Nov 2024 16:06:34 -0500 X-MC-Unique: mLO1yNvdNz6CK4M4SIi5iA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d533a484aso2900116f8f.0 for ; Mon, 04 Nov 2024 13:06:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754393; x=1731359193; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HT4p44lGhUJLiZNcVVDhq7UK1RgS21i7OPit+tLHM+w=; b=Zc9/DL3Fb9qkQVj3pfw4ul1XlvXrFAnDnrrWl6z/zqm8X1xcq+xLSsljmMq6nmObjT zdqTKlId7KsQFU/UU+7JIutzQ2E9WgB22aVDy4J5dZXJQnvjiY2eevssbM5JZCkbliLZ ghKz3/RB4NZs+CVEXeUVKOwsXs5umIEnfI8fZWa0H3ZweK0bOldMlSE2VQ0Mb9l78LET /uVVXhzG7x3XjOtbtPRldCIKX4jGuMq4C8I/Hvfu24UT+jnbYYvI17X4cVYUT8jxTV6f kiXJwZZwsw07jJIy3IGXh7zRjOSe4OvX1VkSXcLHpgHssb/JTUiQzJLArDJorbnul/FZ yjXg== X-Gm-Message-State: AOJu0YwksL13n7t3Svd1fI0MZ3G2OF62iwz8rL7eL5f0se79MWEjOvBC 0IuwcNl2reZsNOQiFQ3hijrsp8uF2TMyJGJUFiuN/nTQJl6BKdR0Y1B9ynjwgwdfTrsdCcpblQa 4pvyvI9aTO+gUeablFv81wp6sDUdf8OuLo3eUdEiAP+WFQpZ1lWuNvYTe6PVdcHq1yEzMPLoBBx CbMHtuAzDgqCf+oqXZedhAOcuNM9DmfQ== X-Received: by 2002:a05:600c:3d8a:b0:431:7ccd:ff8a with SMTP id 5b1f17b1804b1-4327dac773dmr132311235e9.14.1730754392854; Mon, 04 Nov 2024 13:06:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvvO5PPBjV10Kv8z7u+BWa79l2PlmKjn6ASM2It+p19Xst/nk1YGA/irgAlzXrlgakYDU82Q== X-Received: by 2002:a05:600c:3d8a:b0:431:7ccd:ff8a with SMTP id 5b1f17b1804b1-4327dac773dmr132311055e9.14.1730754392354; Mon, 04 Nov 2024 13:06:32 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5e8915sm164244265e9.27.2024.11.04.13.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:31 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni , Marcel Apfelbaum Subject: [PULL 15/65] hw/pci-bridge/cxl_root_port: Provide x-speed and x-width properties. Message-ID: <1478b5609022ed4331bff83d06cefed983df82ac.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Approach copied from gen_pcie_root_port.c Previously the link defaulted to a maximum of 2.5GT/s and 1x. Enable setting it's maximum values. The actual value after 'training' will depend on the downstream device configuration. Signed-off-by: Jonathan Cameron Message-Id: <20240916173518.1843023-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Fan Ni --- hw/pci-bridge/cxl_root_port.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/pci-bridge/cxl_root_port.c b/hw/pci-bridge/cxl_root_port.c index 2dd10239bd..5e2156d7ba 100644 --- a/hw/pci-bridge/cxl_root_port.c +++ b/hw/pci-bridge/cxl_root_port.c @@ -24,6 +24,7 @@ #include "hw/pci/pcie_port.h" #include "hw/pci/msi.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/sysbus.h" #include "qapi/error.h" #include "hw/cxl/cxl.h" @@ -206,6 +207,10 @@ static Property gen_rp_props[] = { -1), DEFINE_PROP_SIZE("pref64-reserve", CXLRootPort, res_reserve.mem_pref_64, -1), + DEFINE_PROP_PCIE_LINK_SPEED("x-speed", PCIESlot, + speed, PCIE_LINK_SPEED_64), + DEFINE_PROP_PCIE_LINK_WIDTH("x-width", PCIESlot, + width, PCIE_LINK_WIDTH_32), DEFINE_PROP_END_OF_LIST() }; From patchwork Mon Nov 4 21:06:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33F08D1BDF3 for ; Mon, 4 Nov 2024 21:12:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Hc-0005Mi-M0; Mon, 04 Nov 2024 16:06:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hb-0005I9-16 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84HZ-0005Ke-IX for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754400; 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=c7gOmOTj6yO90oCWalWO1gQgHW7kTyMfpeF2Gcy7IQw=; b=Rke2f4etY+DCtydR3m+pUuSEZoUZGqkm2x5Ptweom9U5qZNtjKx9NJXZWA8ln+usHW2hAA ug3Jm/f/UYIqKY07boi2xc1jQ6QWF3Qd0oRjSE9QgBebM9WrvC1KxeKldpQ02YotgtSFo3 iklMUwrPc+oTFcMhGky9hTopIwdIlNw= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-73-GYkDlQnGMqan9z4OiTD8ew-1; Mon, 04 Nov 2024 16:06:39 -0500 X-MC-Unique: GYkDlQnGMqan9z4OiTD8ew-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4315a0f25afso32320715e9.3 for ; Mon, 04 Nov 2024 13:06:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754397; x=1731359197; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c7gOmOTj6yO90oCWalWO1gQgHW7kTyMfpeF2Gcy7IQw=; b=c6IKtUiqbf8FniyEiiwzcgqtn04MiqBq3en4os4nFTcdOt61ZDBzA7MJfMZ0wzVaVp zOXBnf5Sd1C11tc3ctXT1aBXZw6mdkemC42J9PNXrQx/m3TNpYlmqWfTCkitgO0MhK5/ /etLnmZXjVl35RgNjV1pwvq9RJR1yMFfK2LxRFRyaBgkYLkYhhMdyhPN8r/SmnemMg5u Y+cCU7po0M+i17otS65kfN6K9csLej5J+EE7CTv8zS/jMI3JeZBgShBh6p7azx1kZqLp 8xUI3P4/TnMQUa9PX3VuekE48kyRPfq/EHE6dlelziu36WidO3C29fmm2DgeYHR5LrS+ 4pTw== X-Gm-Message-State: AOJu0YytHnfyMRtPcWiymCvsXqHWiQ/B/qjAy4ZloaUGQkdtM9/eexY1 U3r4jdYoioIX/WDLDi8cVO2ZMTXI+TIdMihhFNplmm751vfUQ74F8Md/CmKDfnf/UYOYZuxBp/6 vJVfo/8PrmOnnQ3Ps9onuFxfYk7UAJ2UkE+9CVHpzcE+4VZJbsINCH9H5w8a0Qrdf5iu8a4/KWB hq7feKAXxIFyo8p6gnGuZxhLvQWG4gZA== X-Received: by 2002:a05:600c:1c82:b0:430:699b:7d22 with SMTP id 5b1f17b1804b1-4319ad14d14mr329164595e9.26.1730754397154; Mon, 04 Nov 2024 13:06:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPzVRbgvpgcmjZt86LBj4b3pyi5Z95SzLBgi9uVzeT7fwEQ4CfG9C/Ar2N89he1amMfgVC5g== X-Received: by 2002:a05:600c:1c82:b0:430:699b:7d22 with SMTP id 5b1f17b1804b1-4319ad14d14mr329164375e9.26.1730754396753; Mon, 04 Nov 2024 13:06:36 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d6852efsm164336455e9.30.2024.11.04.13.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:36 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 16/65] hw/pci-bridge/cxl_upstream: Provide x-speed and x-width properties. Message-ID: <845f94de78cb6c063234176ff7c0ac8e430d19fe.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Copied from gen_pcie_root_port.c Drop the previous code that ensured a valid value in s->width, s->speed as now a default is provided so this will always be set. Note this changes the default settings but it is unlikely to have a negative effect on software as will only affect ports with now downstream device. All other ports will use the settings from that device. Signed-off-by: Jonathan Cameron Message-Id: <20240916173518.1843023-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/cxl_downstream.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/hw/pci-bridge/cxl_downstream.c b/hw/pci-bridge/cxl_downstream.c index 4b42984360..c347ac06f3 100644 --- a/hw/pci-bridge/cxl_downstream.c +++ b/hw/pci-bridge/cxl_downstream.c @@ -13,6 +13,8 @@ #include "hw/pci/msi.h" #include "hw/pci/pcie.h" #include "hw/pci/pcie_port.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/cxl/cxl.h" #include "qapi/error.h" @@ -210,24 +212,20 @@ static void cxl_dsp_exitfn(PCIDevice *d) pci_bridge_exitfn(d); } -static void cxl_dsp_instance_post_init(Object *obj) -{ - PCIESlot *s = PCIE_SLOT(obj); - - if (!s->speed) { - s->speed = QEMU_PCI_EXP_LNK_2_5GT; - } - - if (!s->width) { - s->width = QEMU_PCI_EXP_LNK_X1; - } -} +static Property cxl_dsp_props[] = { + DEFINE_PROP_PCIE_LINK_SPEED("x-speed", PCIESlot, + speed, PCIE_LINK_SPEED_64), + DEFINE_PROP_PCIE_LINK_WIDTH("x-width", PCIESlot, + width, PCIE_LINK_WIDTH_16), + DEFINE_PROP_END_OF_LIST() +}; static void cxl_dsp_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PCIDeviceClass *k = PCI_DEVICE_CLASS(oc); + device_class_set_props(dc, cxl_dsp_props); k->config_write = cxl_dsp_config_write; k->realize = cxl_dsp_realize; k->exit = cxl_dsp_exitfn; @@ -243,7 +241,6 @@ static const TypeInfo cxl_dsp_info = { .name = TYPE_CXL_DSP, .instance_size = sizeof(CXLDownstreamPort), .parent = TYPE_PCIE_SLOT, - .instance_post_init = cxl_dsp_instance_post_init, .class_init = cxl_dsp_class_init, .interfaces = (InterfaceInfo[]) { { INTERFACE_PCIE_DEVICE }, From patchwork Mon Nov 4 21:06:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D7F4D1BDF3 for ; Mon, 4 Nov 2024 21:08:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84He-0005Op-9y; Mon, 04 Nov 2024 16:06:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hd-0005NJ-9A for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hb-0005Kp-Nf for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754403; 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=ldHFm0meIbKDqoWxpc3iPUWnS5CVTfeooEj5YgrtdIU=; b=dM3QoqtuwDYh/ovg5dqdaGfoszc1jR9+QizypTODP6putBnDXQsPcbDYsWmJKNGtSM5Uru xmsdhed6tUp1F7WfI2r3mSIPcG1PIdundQoUrDjtfsLu69J12XDgiWpqdVZ8gGyhRXplrR 6ftcWL85PFD06dSh2/j3AftND5vsmQs= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-oF0UFrFzMYO4ZDvo7aOEKQ-1; Mon, 04 Nov 2024 16:06:42 -0500 X-MC-Unique: oF0UFrFzMYO4ZDvo7aOEKQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4315b7b0c16so32374395e9.1 for ; Mon, 04 Nov 2024 13:06:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754400; x=1731359200; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ldHFm0meIbKDqoWxpc3iPUWnS5CVTfeooEj5YgrtdIU=; b=vKtls4+LK9LVMs0sxsBJSrJOGUYaZpIetg5weB9r7nBbSPdRzGhw5gRQRqHcNpb6rH M5lkKadBW2KBmNBsqpey8F5DpmhsknENLhKoCzPVh7Adv1CdyMvFQx6dPO8RGVTm+4Rj CAZaI6FI34q1UlN+Q/1CXl8NSNjc4IKdyxOaVlyRy5LEA8raTMcXB5stht/fVGsT/9xd HFRcBieBEergAjIua3c4rxAQneOvlUi4e02daHb2OLSsYfo4tRR63hYgW2Em3Ijfac64 xZ27O5UUh/0WAAyhVYLV8KiYM4dDK2O9eXzBZkyzJVEKGZf5+XsgvYFVcJIx7x9hUsCx vUdQ== X-Gm-Message-State: AOJu0YwDNj5a6f4QlaV+c7zldp0cbUU8KQTa/HFEGm26gMs8aUfZjWDN 8UA8NBe6I1HI9BTgqMnK6Mi42zIsT0x9fN9NlKfaFxnK0fNCZNsRLKtX6lViEO5ReZ7MTbUMhMl haE4x4K9rcOC0pmcoKtxrkPyXugW86npDRjJ2p2vr7Wfj2SgJuqp46r+woJjTxh9a5Y+ljzxT2i IdQbcfVHWkF3PEujKUvp7/IwvHgwuChg== X-Received: by 2002:a05:600c:1989:b0:42f:7ed4:4c26 with SMTP id 5b1f17b1804b1-4319aca5580mr299680375e9.12.1730754400363; Mon, 04 Nov 2024 13:06:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGs7XgrkbR4/eVV6oIN5hIK9/ism9YbX541CK78pFhR0dr269E1bj+aB1snAwIqzgFAAv1MIw== X-Received: by 2002:a05:600c:1989:b0:42f:7ed4:4c26 with SMTP id 5b1f17b1804b1-4319aca5580mr299680045e9.12.1730754399819; Mon, 04 Nov 2024 13:06:39 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c116abb5sm14080603f8f.100.2024.11.04.13.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:39 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 17/65] hw/pcie: Factor out PCI Express link register filling common to EP. Message-ID: <6d1bda91337dcd0e7bf78da6f6b15af497966052.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Whilst not all link related registers are common between RP / Switch DSP and EP / Switch USP many of them are. Factor that group out to save on duplication when adding EP / Swtich USP configurability. Signed-off-by: Jonathan Cameron Message-Id: <20240916173518.1843023-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie.c | 91 ++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 4b2f0805c6..1ac6d89dcf 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -105,6 +105,55 @@ pcie_cap_v1_fill(PCIDevice *dev, uint8_t port, uint8_t type, uint8_t version) pci_set_word(cmask + PCI_EXP_LNKSTA, 0); } +/* Includes setting the target speed default */ +static void pcie_cap_fill_lnk(uint8_t *exp_cap, PCIExpLinkWidth width, + PCIExpLinkSpeed speed) +{ + /* Clear and fill LNKCAP from what was configured above */ + pci_long_test_and_clear_mask(exp_cap + PCI_EXP_LNKCAP, + PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_SLS); + pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP, + QEMU_PCI_EXP_LNKCAP_MLW(width) | + QEMU_PCI_EXP_LNKCAP_MLS(speed)); + + if (speed > QEMU_PCI_EXP_LNK_2_5GT) { + /* + * Target Link Speed defaults to the highest link speed supported by + * the component. 2.5GT/s devices are permitted to hardwire to zero. + */ + pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKCTL2, + PCI_EXP_LNKCTL2_TLS); + pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKCTL2, + QEMU_PCI_EXP_LNKCAP_MLS(speed) & + PCI_EXP_LNKCTL2_TLS); + } + + /* + * 2.5 & 5.0GT/s can be fully described by LNKCAP, but 8.0GT/s is + * actually a reference to the highest bit supported in this register. + * We assume the device supports all link speeds. + */ + if (speed > QEMU_PCI_EXP_LNK_5GT) { + pci_long_test_and_clear_mask(exp_cap + PCI_EXP_LNKCAP2, ~0U); + pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, + PCI_EXP_LNKCAP2_SLS_2_5GB | + PCI_EXP_LNKCAP2_SLS_5_0GB | + PCI_EXP_LNKCAP2_SLS_8_0GB); + if (speed > QEMU_PCI_EXP_LNK_8GT) { + pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, + PCI_EXP_LNKCAP2_SLS_16_0GB); + } + if (speed > QEMU_PCI_EXP_LNK_16GT) { + pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, + PCI_EXP_LNKCAP2_SLS_32_0GB); + } + if (speed > QEMU_PCI_EXP_LNK_32GT) { + pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, + PCI_EXP_LNKCAP2_SLS_64_0GB); + } + } +} + static void pcie_cap_fill_slot_lnk(PCIDevice *dev) { PCIESlot *s = (PCIESlot *)object_dynamic_cast(OBJECT(dev), TYPE_PCIE_SLOT); @@ -115,13 +164,6 @@ static void pcie_cap_fill_slot_lnk(PCIDevice *dev) return; } - /* Clear and fill LNKCAP from what was configured above */ - pci_long_test_and_clear_mask(exp_cap + PCI_EXP_LNKCAP, - PCI_EXP_LNKCAP_MLW | PCI_EXP_LNKCAP_SLS); - pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP, - QEMU_PCI_EXP_LNKCAP_MLW(s->width) | - QEMU_PCI_EXP_LNKCAP_MLS(s->speed)); - /* * Link bandwidth notification is required for all root ports and * downstream ports supporting links wider than x1 or multiple link @@ -144,42 +186,9 @@ static void pcie_cap_fill_slot_lnk(PCIDevice *dev) pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP, PCI_EXP_LNKCAP_DLLLARC); /* the PCI_EXP_LNKSTA_DLLLA will be set in the hotplug function */ - - /* - * Target Link Speed defaults to the highest link speed supported by - * the component. 2.5GT/s devices are permitted to hardwire to zero. - */ - pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKCTL2, - PCI_EXP_LNKCTL2_TLS); - pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKCTL2, - QEMU_PCI_EXP_LNKCAP_MLS(s->speed) & - PCI_EXP_LNKCTL2_TLS); } - /* - * 2.5 & 5.0GT/s can be fully described by LNKCAP, but 8.0GT/s is - * actually a reference to the highest bit supported in this register. - * We assume the device supports all link speeds. - */ - if (s->speed > QEMU_PCI_EXP_LNK_5GT) { - pci_long_test_and_clear_mask(exp_cap + PCI_EXP_LNKCAP2, ~0U); - pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, - PCI_EXP_LNKCAP2_SLS_2_5GB | - PCI_EXP_LNKCAP2_SLS_5_0GB | - PCI_EXP_LNKCAP2_SLS_8_0GB); - if (s->speed > QEMU_PCI_EXP_LNK_8GT) { - pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, - PCI_EXP_LNKCAP2_SLS_16_0GB); - } - if (s->speed > QEMU_PCI_EXP_LNK_16GT) { - pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, - PCI_EXP_LNKCAP2_SLS_32_0GB); - } - if (s->speed > QEMU_PCI_EXP_LNK_32GT) { - pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP2, - PCI_EXP_LNKCAP2_SLS_64_0GB); - } - } + pcie_cap_fill_lnk(exp_cap, s->width, s->speed); } int pcie_cap_init(PCIDevice *dev, uint8_t offset, From patchwork Mon Nov 4 21:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACC5AD1BDF2 for ; Mon, 4 Nov 2024 21:09:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Hm-0005nG-6e; Mon, 04 Nov 2024 16:06:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hj-0005dh-1l for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hf-0005L3-7E for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754406; 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=mvlW1QwJWNe5kggYv414OUm4j2VpwLnaPYotmjUzdE0=; b=jAGx9GwSMsJoEgadMl7+/hr0HE+ewPONiLDU0qjtTMdQQ/lZSewndbW9bj3YTSOeicGl/8 PtfAO0WI+eki6vYJzL++fPpivFy6ii48rq26WY3i6lhE5hYLW2xC8aWjLHfO9qNEfwbXhU U8Cp9oviOrIKembO+KwU1dg/BQh5o/g= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-gesHf-jNM6i366OtGH7hbg-1; Mon, 04 Nov 2024 16:06:45 -0500 X-MC-Unique: gesHf-jNM6i366OtGH7hbg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d537292d7so3166616f8f.2 for ; Mon, 04 Nov 2024 13:06:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754404; x=1731359204; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mvlW1QwJWNe5kggYv414OUm4j2VpwLnaPYotmjUzdE0=; b=QK/vnNKiQFDB2qqdpWzSloWcgKWXCds1iW4EfWxDGY5zo06XFuj+TTh7nvV22MzlkZ e0pSSstjbmHfFjJoVibx6bIbyKR/2toIEn4pi7U67n+crVkdWDmg2N1ayQxYr1+4EeoD XB9bSK+PQfjZoEX2wzip8BtFzZo0xaGcl/FtVr6YAvVl0JYMmA0CJsVasqtsSKscERau xqol9lwfF8irhiHevPH2wIvlh88fPlJ/ZMbXgo9UT3SGcuGqmmp3cHiCQZairnf6w1SU HQu5ktkxkzraNCTKCq/SjklvZXy9adxPWFKLlyBLtbJKhACglj3Z112ZomsMtn378EgI FoRQ== X-Gm-Message-State: AOJu0YzoESRaD8q3GMcKY4apCzOoEs7yY4cIU3COTYOQN2By3ijBHDH4 5P6ugWq31+tfbqu0Rro4198J/HKdpK5jMhl41jecNOD3+taVwLXmpAae/YraL98NXxlTa6xknbU NJDZihX0NnybQxbeVj/dGF2fd9PR+CNbeMSJ663ZYx6vlh/MzVc71NDPCfmF20BSmASYdShnObO EqZ7WoNsxNycjEGVrcz49FKBFxKcOjsg== X-Received: by 2002:a5d:6d0f:0:b0:37d:9565:4db2 with SMTP id ffacd0b85a97d-381c7a469cemr15748905f8f.6.1730754403911; Mon, 04 Nov 2024 13:06:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGstg4UaqKvsdNO9OWD014KkMqczeSPGWw9EyX+mw7O04nA7SsF/pefVSpUxfbyUtd8Q+x1CA== X-Received: by 2002:a5d:6d0f:0:b0:37d:9565:4db2 with SMTP id ffacd0b85a97d-381c7a469cemr15748878f8f.6.1730754403453; Mon, 04 Nov 2024 13:06:43 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9a99c8sm194245875e9.29.2024.11.04.13.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:42 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 18/65] hw/pcie: Provide a utility function for control of EP / SW USP link Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Whilst similar to existing PCIESlot link configuration a few registers need to be set differently so that the downstream device presents a 'configured' state that is then used to 'train' the upstream port on the link. Basically that means setting the status register to reflect it succeeding in training up to target settings. Signed-off-by: Jonathan Cameron Message-Id: <20240916173518.1843023-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie.h | 2 ++ hw/pci/pcie.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 5eddb90976..b8d59732bc 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -141,6 +141,8 @@ void pcie_acs_reset(PCIDevice *dev); void pcie_ari_init(PCIDevice *dev, uint16_t offset); void pcie_dev_ser_num_init(PCIDevice *dev, uint16_t offset, uint64_t ser_num); void pcie_ats_init(PCIDevice *dev, uint16_t offset, bool aligned); +void pcie_cap_fill_link_ep_usp(PCIDevice *dev, PCIExpLinkWidth width, + PCIExpLinkSpeed speed); void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 1ac6d89dcf..2738dbb28d 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -154,6 +154,24 @@ static void pcie_cap_fill_lnk(uint8_t *exp_cap, PCIExpLinkWidth width, } } +void pcie_cap_fill_link_ep_usp(PCIDevice *dev, PCIExpLinkWidth width, + PCIExpLinkSpeed speed) +{ + uint8_t *exp_cap = dev->config + dev->exp.exp_cap; + + /* + * For an end point or USP need to set the current status as well + * as the capabilities. + */ + pci_long_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA, + PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW); + pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA, + QEMU_PCI_EXP_LNKSTA_NLW(width) | + QEMU_PCI_EXP_LNKSTA_CLS(speed)); + + pcie_cap_fill_lnk(exp_cap, width, speed); +} + static void pcie_cap_fill_slot_lnk(PCIDevice *dev) { PCIESlot *s = (PCIESlot *)object_dynamic_cast(OBJECT(dev), TYPE_PCIE_SLOT); From patchwork Mon Nov 4 21:06:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862052 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABE50D1BDF4 for ; Mon, 4 Nov 2024 21:08:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Hq-00067x-L4; Mon, 04 Nov 2024 16:06:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hk-0005lM-TE for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hj-0005LO-Cb for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754410; 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=U7NBjxcaDcjtzQHlNEnd4IoK3C/16CIfbxI1oLBTaFY=; b=GOWFsyo0SJZE2UeB3KebLwt522GhGAjbUZnj/K7jcGWw3zsCxiKTacYico6+9ejEYrhN27 dECRwtbyM1fIyWjqcBUgjtVxzOTNCWlXolui5DwW09CH0hqchNRF9Di9gaByltriG6CBQN u6TjoMJCNTDjDeM0d+w7nZcGyD9YZuk= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-339-q7qS2VF1NYixV2akM0VnqQ-1; Mon, 04 Nov 2024 16:06:49 -0500 X-MC-Unique: q7qS2VF1NYixV2akM0VnqQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4314c6ca114so34505545e9.1 for ; Mon, 04 Nov 2024 13:06:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754408; x=1731359208; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=U7NBjxcaDcjtzQHlNEnd4IoK3C/16CIfbxI1oLBTaFY=; b=E7Rq8BZee5etxT0WzfHpInOdKcXUk7Ud1yA6Blaa6aZcBwCEKShwxb42KZPnr8EBmo mOeKtkVO5564XbzFYaQHMDiP3UcXu0TII50nvIL23exby06TCtT4rBxVOQhfDy3XiB3d gkFrBXmGTuJ4J4y5VI29GyxTV5l1HK3e5/WWT932i6aOFYO4QbC5G1o9f6Z5mWhdD3kn naME9VeKi/Pgh2iZoPyvvUH7gcnbMxfkpcI8fsASu069fpUjzvvS8QLNqUgtNQu1AeRo eERUPkW2GU6Pqkq4rFzxip3Lx4/5SN92yjL6JQ7eclzzdGHYfliL4kaf68BTc4RU3MaJ 37RQ== X-Gm-Message-State: AOJu0YyId3oTuDUl00Z8IU8sfxTGTspFVt46ofiufZtMQ+z88DJV9m6W ESNtc+o0fJk7W1ZbgsVXjoQxCBv6f3b2K82zxCEXCYviZViVxwHplUhJnCJ4cDvHQe9yjNg4+73 8Qkoug9Frl4oCNSEq2OsIYYxKZg5ITz+HkF7UB7IQu876WxgvEVnK4harVKK1Q8eR2Wsg2EEW9J cO5YD3ZLW6+6E6pAPY/7LNhLug9pol6w== X-Received: by 2002:a05:600c:6014:b0:431:5d14:1cae with SMTP id 5b1f17b1804b1-4327b7019e9mr147152635e9.19.1730754408129; Mon, 04 Nov 2024 13:06:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFW6sOthLSX7OSyJZXtfYhKKpA08xvh2xrUs/h4/mK3DqnVUTUaEwQtdpKe6NOsxHD7hUphHw== X-Received: by 2002:a05:600c:6014:b0:431:5d14:1cae with SMTP id 5b1f17b1804b1-4327b7019e9mr147152425e9.19.1730754407636; Mon, 04 Nov 2024 13:06:47 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5ab2aasm164105045e9.6.2024.11.04.13.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:46 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 19/65] hw/mem/cxl-type3: Add properties to control link speed and width Message-ID: <14bd0f3865489d537a93b7c80617622473f224e4.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron To establish performance characteristics of a CXL device when used via a particular CXL topology (root ports, switches, end points) it is necessary to set the appropriate link speed and width in the PCI Express capability structure. Provide x-speed and x-link properties for this. Signed-off-by: Jonathan Cameron Message-Id: <20240916173518.1843023-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 4 ++++ hw/mem/cxl_type3.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index fdd0f4e62b..e14e56ae4b 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -549,6 +549,10 @@ struct CXLType3Dev { CXLCCI vdm_fm_owned_ld_mctp_cci; CXLCCI ld0_cci; + /* PCIe link characteristics */ + PCIExpLinkSpeed speed; + PCIExpLinkWidth width; + /* DOE */ DOECap doe_cdat; diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 235ac40aeb..44d491d8f6 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -17,6 +17,7 @@ #include "hw/mem/pc-dimm.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "qapi/error.h" #include "qemu/log.h" #include "qemu/module.h" @@ -1200,6 +1201,7 @@ static void ct3d_reset(DeviceState *dev) uint32_t *reg_state = ct3d->cxl_cstate.crb.cache_mem_registers; uint32_t *write_msk = ct3d->cxl_cstate.crb.cache_mem_regs_write_mask; + pcie_cap_fill_link_ep_usp(PCI_DEVICE(dev), ct3d->width, ct3d->speed); cxl_component_register_init_common(reg_state, write_msk, CXL2_TYPE3_DEVICE); cxl_device_register_init_t3(ct3d); @@ -1229,6 +1231,10 @@ static Property ct3_props[] = { DEFINE_PROP_UINT8("num-dc-regions", CXLType3Dev, dc.num_regions, 0), DEFINE_PROP_LINK("volatile-dc-memdev", CXLType3Dev, dc.host_dc, TYPE_MEMORY_BACKEND, HostMemoryBackend *), + DEFINE_PROP_PCIE_LINK_SPEED("x-speed", CXLType3Dev, + speed, PCIE_LINK_SPEED_32), + DEFINE_PROP_PCIE_LINK_WIDTH("x-width", CXLType3Dev, + width, PCIE_LINK_WIDTH_16), DEFINE_PROP_END_OF_LIST(), }; From patchwork Mon Nov 4 21:06:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B554D1BDF3 for ; Mon, 4 Nov 2024 21:07:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Hr-0006Es-GN; Mon, 04 Nov 2024 16:06:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ho-00060l-Nf for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hn-0005Ls-7f for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754414; 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=SBr0W8m8DyGKLRz2Opar4AmzHNpYMF5hjNkEt3At0qU=; b=dYoOVvyn3WPXFlNHWV/gXjNb8ddHZga9CyK9Po3aHuyL1jUd4flpgdo+GDwIY4E833ODs2 wIVU0lxQNlU+as3KWA2Lx+ztzHZetovUYFYWQvJzjKe2bWT7PfhmkfSvKK1eAy7OeJrH8N kX3rQa/4B/Sj1jZ2B9EdiyrcTAzsL0E= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-qcMcZ2ajMKCY5fXXeZRREQ-1; Mon, 04 Nov 2024 16:06:53 -0500 X-MC-Unique: qcMcZ2ajMKCY5fXXeZRREQ-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-539e91e12bbso2998846e87.2 for ; Mon, 04 Nov 2024 13:06:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754411; x=1731359211; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SBr0W8m8DyGKLRz2Opar4AmzHNpYMF5hjNkEt3At0qU=; b=uyuXgJOcoL3OQiFxG3B1mT6FYpZemYxSO5AA0DxFVHVdbFwDei+2miks7lZTUQm+oR a+yDc3Edmz144MwjiCXj09xr8M2jRxkTgj6HdOlNXIZoeYyqRxikNbuxnwYJh2i5vwOS YTNN6umz/8bBy0d/cJAd074HpW2VqRXgM5MD2Qu+1btCzfDYzF4E1+UVfqk0/63vstn8 vot+zYHSabkao8VRuYLt7Mj5OSui87jKApK7vsXVMsso9hIY0w0rnMptUG0yH7TlZ5in mRDiMlaWK1CHIAZ6akQh9yPOYWiIf1hvUj/zC77uiubJ/RI3fF5MU9K1dhQcOM5KbCyp J/aQ== X-Gm-Message-State: AOJu0YxKH8BoYADm8ZXtXL29o/NQtvHTuzsRYeMbArhoXeiSl0cHaJX/ r++Eao+Kq4bLVtbqQg1SBdQw9v/JaKnov86Af+TmOQcaPhoO/qfo0zFwqfI0qHa3IldV9U2upaF OFMCoEQNNek+smvQr1yYpSqMpNsk1falf+WdabtRj4nC6jeN+ffzy0IDqpGh225gBki0WAmO5P3 hOY4FmSoKw9z8iOYvi3ECMCYBPMDttzQ== X-Received: by 2002:a05:6512:12d6:b0:539:d0ef:b3f9 with SMTP id 2adb3069b0e04-53d65e11a10mr6868219e87.40.1730754411469; Mon, 04 Nov 2024 13:06:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYuaC7su4TVDhczTLZ3rp4reMjxFfLUnkYrSfB0sDh3chXDkH5F4hWITNIN1P5f4sqxriP5g== X-Received: by 2002:a05:6512:12d6:b0:539:d0ef:b3f9 with SMTP id 2adb3069b0e04-53d65e11a10mr6868193e87.40.1730754410855; Mon, 04 Nov 2024 13:06:50 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9403bfsm194359115e9.21.2024.11.04.13.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:50 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 20/65] hw/pci-bridge/cxl-upstream: Add properties to control link speed and width Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron To establish performance characteristics of a CXL device when used via a particular CXL topology (root ports, switches, end points) it is necessary to set the appropriate link speed and width in the PCI Express capability structure. Provide x-speed and x-link properties for this. Signed-off-by: Jonathan Cameron Message-Id: <20240916173518.1843023-7-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci-bridge/cxl_upstream_port.h | 4 ++++ hw/pci-bridge/cxl_upstream.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/include/hw/pci-bridge/cxl_upstream_port.h b/include/hw/pci-bridge/cxl_upstream_port.h index 12635139f6..f208397ffe 100644 --- a/include/hw/pci-bridge/cxl_upstream_port.h +++ b/include/hw/pci-bridge/cxl_upstream_port.h @@ -12,6 +12,10 @@ typedef struct CXLUpstreamPort { /*< public >*/ CXLComponentState cxl_cstate; CXLCCI swcci; + + PCIExpLinkSpeed speed; + PCIExpLinkWidth width; + DOECap doe_cdat; uint64_t sn; } CXLUpstreamPort; diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index a5a39cc524..55f8b0053f 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include "qemu/log.h" #include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" #include "hw/pci/msi.h" #include "hw/pci/pcie.h" #include "hw/pci/pcie_port.h" @@ -100,6 +101,7 @@ static void cxl_usp_reset(DeviceState *qdev) pci_bridge_reset(qdev); pcie_cap_deverr_reset(d); + pcie_cap_fill_link_ep_usp(d, usp->width, usp->speed); latch_registers(usp); } @@ -363,6 +365,10 @@ static void cxl_usp_exitfn(PCIDevice *d) static Property cxl_upstream_props[] = { DEFINE_PROP_UINT64("sn", CXLUpstreamPort, sn, UI64_NULL), DEFINE_PROP_STRING("cdat", CXLUpstreamPort, cxl_cstate.cdat.filename), + DEFINE_PROP_PCIE_LINK_SPEED("x-speed", CXLUpstreamPort, + speed, PCIE_LINK_SPEED_32), + DEFINE_PROP_PCIE_LINK_WIDTH("x-width", CXLUpstreamPort, + width, PCIE_LINK_WIDTH_16), DEFINE_PROP_END_OF_LIST() }; From patchwork Mon Nov 4 21:06:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B221ED1BDF2 for ; Mon, 4 Nov 2024 21:07:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84I4-0006nt-J9; Mon, 04 Nov 2024 16:07:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hv-0006YW-HL for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ht-0005MC-5d for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754420; 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=EKx+QtBgnHz0OyJq6q4H6pfoKPX66b+QZJ7P1OEJWPY=; b=MtWlWX4iu/3XKL0bAeA2yu1+h5FduiZ5ZfnMdiCJeDL/glOTwqOcBPq1zibyR49YzHILP3 w5I3nUP95XgsBYoRXWO7p2DGKsazTnNElOK6Rr0xiEoUu5n2d8oZ24gFOjeejasfEXML8D rbSY+kAChtEnPydghRBGGqpgQTSBBp8= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-463-6vjIJknQNlWcZzSxLB-gfA-1; Mon, 04 Nov 2024 16:06:59 -0500 X-MC-Unique: 6vjIJknQNlWcZzSxLB-gfA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315d98a75fso32330055e9.2 for ; Mon, 04 Nov 2024 13:06:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754417; x=1731359217; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EKx+QtBgnHz0OyJq6q4H6pfoKPX66b+QZJ7P1OEJWPY=; b=rsWAyiMdApHlVexcQGdyL2Q7DaxNyAzb8s4dClDLg88o4cYkeNdjazVAMMhgs3ai6l 6XC1ZuiuCQhckhFE3DD3AgTxjvH1B1ET+krisDbUn9kx9rkZuVjtWQGtdZ+E7oyIob4/ pSY9Wq75SBs4rwW4YnV0AjY6dqVcV5qoL6I43lHAM8uvzEfjWf/G4LH4axjc76ZuGrfY 8CL5lOEbBXbMRuNl+7P43cZl1H2q2QJVKimGI5Ma2XOf7lRWHb5nZP7n7ShDh9UgYytX FDUIWB/WaK887nNc7YB1jl5Ee8YNnI6QsUdZ5HZk2EWkkPjAPf/ubsoFfrUxICsmctNy qrrQ== X-Gm-Message-State: AOJu0YwFGHiY2VlcBd6Pjz86Wza1cKZY0JvKHhoUj8dTgsYrwtrmimeQ fcy4c5PrJnAilX4aitX0lkLINV4Dvn2YwMsaQ24/N38eNkXMOtQO+7xqUsJfWBwHUQenBGOYVh7 hy8DSu+AmIgyARDMvr+SpCd7gKtik8PIhlrSpepy0WCdY9GMIzEFL3JfF7tmmM15VgEe266CUkn EaDekN1ib23y2u0tEUC/4N5A7WExMAXg== X-Received: by 2002:a05:600c:5118:b0:42c:b995:2100 with SMTP id 5b1f17b1804b1-4319ac75a0amr264089825e9.6.1730754416812; Mon, 04 Nov 2024 13:06:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiJ78GSFD1NgzrIu6ZZZThr5+pnODIS/NHUCick+vzR2yssTzlaoRt5wOIJUuosC4DLGOCpg== X-Received: by 2002:a05:600c:5118:b0:42c:b995:2100 with SMTP id 5b1f17b1804b1-4319ac75a0amr264089485e9.6.1730754416331; Mon, 04 Nov 2024 13:06:56 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d6983b7sm162601115e9.43.2024.11.04.13.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:55 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Markus Armbruster , Raphael Norwitz , Paolo Bonzini , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Eduardo Habkost Subject: [PULL 21/65] qdev-monitor: add option to report GenericError from find_device_state Message-ID: <9e4cc917e0be9c757d834a0e40c66def1fed5adc.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Vladimir Sementsov-Ogievskiy Here we just prepare for the following patch, making possible to report GenericError as recommended. This patch doesn't aim to prevent further use of DeviceNotFound by future interfaces: - find_device_state() is used in blk_by_qdev_id() and qmp_get_blk() functions, which may lead to spread of DeviceNotFound anyway - also, nothing prevent simply copy-pasting find_device_state() calls with false argument Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Acked-by: Raphael Norwitz Message-Id: <20240920094936.450987-2-vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- system/qdev-monitor.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 44994ea0e1..6671137a91 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -885,13 +885,20 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp) object_unref(OBJECT(dev)); } -static DeviceState *find_device_state(const char *id, Error **errp) +/* + * Note that creating new APIs using error classes other than GenericError is + * not recommended. Set use_generic_error=true for new interfaces. + */ +static DeviceState *find_device_state(const char *id, bool use_generic_error, + Error **errp) { Object *obj = object_resolve_path_at(qdev_get_peripheral(), id); DeviceState *dev; if (!obj) { - error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + error_set(errp, + (use_generic_error ? + ERROR_CLASS_GENERIC_ERROR : ERROR_CLASS_DEVICE_NOT_FOUND), "Device '%s' not found", id); return NULL; } @@ -956,7 +963,7 @@ void qdev_unplug(DeviceState *dev, Error **errp) void qmp_device_del(const char *id, Error **errp) { - DeviceState *dev = find_device_state(id, errp); + DeviceState *dev = find_device_state(id, false, errp); if (dev != NULL) { if (dev->pending_deleted_event && (dev->pending_deleted_expires_ms == 0 || @@ -1076,7 +1083,7 @@ BlockBackend *blk_by_qdev_id(const char *id, Error **errp) GLOBAL_STATE_CODE(); - dev = find_device_state(id, errp); + dev = find_device_state(id, false, errp); if (dev == NULL) { return NULL; } From patchwork Mon Nov 4 21:06:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63525D1BDF2 for ; Mon, 4 Nov 2024 21:09:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84I8-00073r-Hr; Mon, 04 Nov 2024 16:07:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hy-0006hg-88 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hv-0005MV-UW for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754423; 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=Slo8inP3wfhQ8BQeJ7PzLcu289R4kk15rIf298sgC9c=; b=PlBrkgp8u/kP15xQP3nI4y8Dsnl7DPmqz90KH6bti/JzZdcim18UXINk6kDyyMEiydUlqH ZxirTl69nmbG86RAh07Jdcseb+Se1zbs/UI3cymoh1JiWLvqGKn9L8GA6LE9oamaQDIOrO Z1RfUcRij3rnsizbgs0533OP2RXS8Lk= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-_VuhjJMEMZqvJSPfUNnqEQ-1; Mon, 04 Nov 2024 16:07:02 -0500 X-MC-Unique: _VuhjJMEMZqvJSPfUNnqEQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d5a3afa84so2327174f8f.3 for ; Mon, 04 Nov 2024 13:07:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754421; x=1731359221; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Slo8inP3wfhQ8BQeJ7PzLcu289R4kk15rIf298sgC9c=; b=Rl9mhcYVVY+rpGM32xwOrSEoqXFSadt/iLrStSlQdakif4tYPI+9XrtUVGs9gs0vJS MJScP4EimfZHckyTgi5mwSsspRumMCb84Wdvf+zATvrt7idhd9EVymKJAArGrOqb+ilO fH4TjnIM0ynGuH0bkiINyqxAGzJuUBr2K2NCJ9/ezNvcN/5XsFIy6toW0iG3SfxU06ey 5L5/wcSVASfNy/UapakuCQsrFHozPCFH6i/93z4np8AOy3xAwc/M9UuxqS74vuskPqGQ /z8FOBwJJq0tKHOrNDt8V3ln9H2wBayY2Jvo5U2vlzf0VuM9N/ZSqscUWZjuDj29pmYD WXjA== X-Gm-Message-State: AOJu0YyYblLELsoQ4v/HlUoqmi3Z1zdK7Y3Z8wVEk2iUmcexdy/a9B+M TEMbsH6jLU65jRD/9AOLQ4iEZgmzGrru1grUBLGFZCh57BkwUkqGgib6foq3WsfsxF/ZTgy1S/6 avBk9Jx2nOuIIbktmuNwYiluQvxppQIw6eSzmUPQV9uNNwkJ1lvV8K5tFz7LoP5xTTyZMHqSpAW pVrx6tyf6/jfRxJftF/luNKMy2gjD0Jg== X-Received: by 2002:a5d:584b:0:b0:37d:4a2d:6948 with SMTP id ffacd0b85a97d-381c7a5f380mr10897305f8f.33.1730754420705; Mon, 04 Nov 2024 13:07:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFc02Gp0IfB70ewwAjdeWFTiRunun32RxFC9DdX3HW1N8jOmhnYvR7tfcMzjXL5ahqZKw2S7A== X-Received: by 2002:a5d:584b:0:b0:37d:4a2d:6948 with SMTP id ffacd0b85a97d-381c7a5f380mr10897288f8f.33.1730754420212; Mon, 04 Nov 2024 13:07:00 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c1167f20sm14109508f8f.90.2024.11.04.13.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:59 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:56 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Raphael Norwitz , Stefano Garzarella , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 22/65] vhost-user-blk: split vhost_user_blk_sync_config() Message-ID: <4dfa12731439c4a3cbfd9d1767acddfbf79549fd.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Vladimir Sementsov-Ogievskiy Split vhost_user_blk_sync_config() out from vhost_user_blk_handle_config_change(), to be reused in the following commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Acked-by: Raphael Norwitz Message-Id: <20240920094936.450987-3-vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefano Garzarella --- hw/block/vhost-user-blk.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 5b7f46bbb0..48b3dabb8d 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -90,27 +90,39 @@ static void vhost_user_blk_set_config(VirtIODevice *vdev, const uint8_t *config) s->blkcfg.wce = blkcfg->wce; } +static int vhost_user_blk_sync_config(DeviceState *dev, Error **errp) +{ + int ret; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBlk *s = VHOST_USER_BLK(vdev); + + ret = vhost_dev_get_config(&s->dev, (uint8_t *)&s->blkcfg, + vdev->config_len, errp); + if (ret < 0) { + return ret; + } + + memcpy(vdev->config, &s->blkcfg, vdev->config_len); + virtio_notify_config(vdev); + + return 0; +} + static int vhost_user_blk_handle_config_change(struct vhost_dev *dev) { int ret; - VirtIODevice *vdev = dev->vdev; - VHostUserBlk *s = VHOST_USER_BLK(dev->vdev); Error *local_err = NULL; if (!dev->started) { return 0; } - ret = vhost_dev_get_config(dev, (uint8_t *)&s->blkcfg, - vdev->config_len, &local_err); + ret = vhost_user_blk_sync_config(DEVICE(dev->vdev), &local_err); if (ret < 0) { error_report_err(local_err); return ret; } - memcpy(dev->vdev->config, &s->blkcfg, vdev->config_len); - virtio_notify_config(dev->vdev); - return 0; } From patchwork Mon Nov 4 21:07:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C6F8D1BDF5 for ; Mon, 4 Nov 2024 21:11:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84IA-0007EW-60; Mon, 04 Nov 2024 16:07:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84I4-0006sN-NS for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84I1-0005Mx-Ek for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754428; 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=FqQ0aa3x0u9CKa8kr4LeoMUuDzdYhl7I/Bsp+7L/OPI=; b=ZAm9tMipetzAUI/0E56nQHWicWBkV9XGI+c3Mnw6zZ0HNRZPHPsJUfzpWdw/rGgoL2EU+i BGTvvnRGAKTmRYwMqRdGH3kdmszz/NftCra0YR4IVnefx73hrNpyuE21QBkhPATCjZayOl y/sDEGo1bvCMqO+modw+9qRYz2MSnJE= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-vdaga5M8Os-Wl2SvGbTxKA-1; Mon, 04 Nov 2024 16:07:07 -0500 X-MC-Unique: vdaga5M8Os-Wl2SvGbTxKA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43157cff1d1so34454505e9.2 for ; Mon, 04 Nov 2024 13:07:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754426; x=1731359226; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FqQ0aa3x0u9CKa8kr4LeoMUuDzdYhl7I/Bsp+7L/OPI=; b=S2cFXX+eye87Hld0n0mKgFWqRFR3FB+gr8qic/M9hK6f9iFp0eMDY11EHyPtAUheUZ 7V//KJ1rM/BO2ZFuQQt2IgcYRXMORdtSdcwszR0VUzT9Lezg6amPfefAYrWgvRbD9uTB vKSbfYyhAOVH4yOm2GKF747zE8/OMTOpcirTAItLNSB6/n1v9FbgFRQ6VUfttXu3/65A MnfYVFpBzm/cDPk+yWoE1vQpA+O1+lCWpqIg/iRoOpwU4fOK7TJ/rlmGfKahjYioFnad IMFRXhcWogOWG5kzTdpC1qkVhCA9cGROc2taYtl9eGyfwRl0Ku2zw+yjjF3fgclqpg2Z ChZQ== X-Gm-Message-State: AOJu0Yy4XfcLcBbtfdVYkjq4dIS3s67YZD+kYt9rIjcY5A98CdKF6HGY 1Mz4cphiEZL3JUJcpkKRQMRc64X5b/zutLg70YwWRdFFcmbTvZptw5WmdeuwGJlm6gvcZ2Bd2Go LHaDz0Yg+ANgtMpQZ9FvBfaFccpYBwHNoJQfq6AC5MJh0hyz8qclVjdaxJ4jPS40IDrkFZZVEXK C/3TROztq7datcYbxCZejLh6Pimq9I5A== X-Received: by 2002:a05:600c:3b14:b0:42c:de34:34c1 with SMTP id 5b1f17b1804b1-4327b6f9590mr147925585e9.2.1730754425667; Mon, 04 Nov 2024 13:07:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjC15QGZ9Uy0JogRL8BAjsl6HqOej3zVNSKEc+aSuedQkCiBQAURBevu4aSb5UQvVxEm0ItQ== X-Received: by 2002:a05:600c:3b14:b0:42c:de34:34c1 with SMTP id 5b1f17b1804b1-4327b6f9590mr147925265e9.2.1730754425189; Mon, 04 Nov 2024 13:07:05 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9ca704sm194495995e9.41.2024.11.04.13.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:04 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Vladimir Sementsov-Ogievskiy , Markus Armbruster , Raphael Norwitz , Stefano Garzarella , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Eduardo Habkost , Eric Blake , qemu-block@nongnu.org Subject: [PULL 23/65] qapi: introduce device-sync-config Message-ID: <3f98408e2e4fb1792102aed2cd5425aa0e34cc9c.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Vladimir Sementsov-Ogievskiy Add command to sync config from vhost-user backend to the device. It may be helpful when VHOST_USER_SLAVE_CONFIG_CHANGE_MSG failed or not triggered interrupt to the guest or just not available (not supported by vhost-user server). Command result is racy if allow it during migration. Let's not allow that. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Acked-by: Raphael Norwitz Message-Id: <20240920094936.450987-4-vsementsov@yandex-team.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/qdev.json | 24 ++++++++++++++++++++++++ include/hw/qdev-core.h | 6 ++++++ hw/block/vhost-user-blk.c | 1 + hw/virtio/virtio-pci.c | 9 +++++++++ system/qdev-monitor.c | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+) diff --git a/qapi/qdev.json b/qapi/qdev.json index 53d147c7b4..2a581129c9 100644 --- a/qapi/qdev.json +++ b/qapi/qdev.json @@ -163,3 +163,27 @@ ## { 'event': 'DEVICE_UNPLUG_GUEST_ERROR', 'data': { '*device': 'str', 'path': 'str' } } + +## +# @device-sync-config: +# +# Synchronize device configuration from host to guest part. First, +# copy the configuration from the host part (backend) to the guest +# part (frontend). Then notify guest software that device +# configuration changed. +# +# The command may be used to notify the guest about block device +# capcity change. Currently only vhost-user-blk device supports +# this. +# +# @id: the device's ID or QOM path +# +# Features: +# +# @unstable: The command is experimental. +# +# Since: 9.1 +## +{ 'command': 'device-sync-config', + 'features': [ 'unstable' ], + 'data': {'id': 'str'} } diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index aa97c34a4b..94914858d8 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -95,6 +95,7 @@ typedef void (*DeviceUnrealize)(DeviceState *dev); typedef void (*DeviceReset)(DeviceState *dev); typedef void (*BusRealize)(BusState *bus, Error **errp); typedef void (*BusUnrealize)(BusState *bus); +typedef int (*DeviceSyncConfig)(DeviceState *dev, Error **errp); /** * struct DeviceClass - The base class for all devices. @@ -103,6 +104,9 @@ typedef void (*BusUnrealize)(BusState *bus); * property is changed to %true. * @unrealize: Callback function invoked when the #DeviceState:realized * property is changed to %false. + * @sync_config: Callback function invoked when QMP command device-sync-config + * is called. Should synchronize device configuration from host to guest part + * and notify the guest about the change. * @hotpluggable: indicates if #DeviceClass is hotpluggable, available * as readonly "hotpluggable" property of #DeviceState instance * @@ -162,6 +166,7 @@ struct DeviceClass { DeviceReset legacy_reset; DeviceRealize realize; DeviceUnrealize unrealize; + DeviceSyncConfig sync_config; /** * @vmsd: device state serialisation description for @@ -547,6 +552,7 @@ bool qdev_hotplug_allowed(DeviceState *dev, Error **errp); */ HotplugHandler *qdev_get_hotplug_handler(DeviceState *dev); void qdev_unplug(DeviceState *dev, Error **errp); +int qdev_sync_config(DeviceState *dev, Error **errp); void qdev_simple_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp); void qdev_machine_creation_done(void); diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 48b3dabb8d..7996e49821 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -591,6 +591,7 @@ static void vhost_user_blk_class_init(ObjectClass *klass, void *data) device_class_set_props(dc, vhost_user_blk_properties); dc->vmsd = &vmstate_vhost_user_blk; + dc->sync_config = vhost_user_blk_sync_config; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); vdc->realize = vhost_user_blk_device_realize; vdc->unrealize = vhost_user_blk_device_unrealize; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 4d832fe845..c5a809b956 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2385,6 +2385,14 @@ static void virtio_pci_dc_realize(DeviceState *qdev, Error **errp) vpciklass->parent_dc_realize(qdev, errp); } +static int virtio_pci_sync_config(DeviceState *dev, Error **errp) +{ + VirtIOPCIProxy *proxy = VIRTIO_PCI(dev); + VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + + return qdev_sync_config(DEVICE(vdev), errp); +} + static void virtio_pci_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -2401,6 +2409,7 @@ static void virtio_pci_class_init(ObjectClass *klass, void *data) device_class_set_parent_realize(dc, virtio_pci_dc_realize, &vpciklass->parent_dc_realize); rc->phases.hold = virtio_pci_bus_reset_hold; + dc->sync_config = virtio_pci_sync_config; } static const TypeInfo virtio_pci_info = { diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index 6671137a91..127456080b 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -23,6 +23,7 @@ #include "monitor/monitor.h" #include "monitor/qdev.h" #include "sysemu/arch_init.h" +#include "sysemu/runstate.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" #include "qapi/qmp/dispatch.h" @@ -977,6 +978,43 @@ void qmp_device_del(const char *id, Error **errp) } } +int qdev_sync_config(DeviceState *dev, Error **errp) +{ + DeviceClass *dc = DEVICE_GET_CLASS(dev); + + if (!dc->sync_config) { + error_setg(errp, "device-sync-config is not supported for '%s'", + object_get_typename(OBJECT(dev))); + return -ENOTSUP; + } + + return dc->sync_config(dev, errp); +} + +void qmp_device_sync_config(const char *id, Error **errp) +{ + DeviceState *dev; + + /* + * During migration there is a race between syncing`configuration + * and migrating it (if migrate first, that target would get + * outdated version), so let's just not allow it. + */ + + if (migration_is_running()) { + error_setg(errp, "Config synchronization is not allowed " + "during migration"); + return; + } + + dev = find_device_state(id, true, errp); + if (!dev) { + return; + } + + qdev_sync_config(dev, errp); +} + void hmp_device_add(Monitor *mon, const QDict *qdict) { Error *err = NULL; From patchwork Mon Nov 4 21:07:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14CC9D1BDF3 for ; Mon, 4 Nov 2024 21:08:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84IB-0007Rz-PC; Mon, 04 Nov 2024 16:07:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84I7-00071y-R2 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84I5-0005NF-PB for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754432; 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=0gWRq9tKfolk64MhOyIEOoiaX7xr3WJke6cvdMLK1uE=; b=Ce/Y5jsAYM3Q19fA3lxvCkIH4vdZ/rOO+oGi+Xlm+v+0OGtcm7fPx3oC3nuunZi22oNoXL Q70eLV8BTMRcbZDukqUlrkKvVnCJzT1C4z6AES5Z8wp5TvFXC7AbXyb6LfNhOhN36pyt9x aO/KILkpmHQjy/8ii3voyO9OUh3DUvM= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-n2JBpFO1PFG2hkh3uW7_yA-1; Mon, 04 Nov 2024 16:07:11 -0500 X-MC-Unique: n2JBpFO1PFG2hkh3uW7_yA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4316300bb15so29809965e9.2 for ; Mon, 04 Nov 2024 13:07:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754430; x=1731359230; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0gWRq9tKfolk64MhOyIEOoiaX7xr3WJke6cvdMLK1uE=; b=eELvKrxfGFxoDhKddprSrRnKxnykqt5uyKPh9XzuBL/1+MTiroJ03YuAzyZzax5o46 wsmFhd8OIH4yImmWBAf23QQTPg3wXgjhCJEjM1R6VkAuGwXl31wbKGwT7mV5Sev3PDcO AyhXGv8+bA9wNhrmaFv/t68emKouqxlveOgOgnoOGSupYZeZgj1Sy1sw61Pv3bVf8Xvz gktxjGakqdm++6huvQ1uVqvRgvkJ04+B4Lz+D+r8LmgEunnRk/9DUXTYCN2Zfiql91DJ QbSFSCk2SRdUtR4zq5a1vWXvfUpSv7oe84kuBRAnXsU71jIbS9fOveiRCqIlWIJt/4MF QWqQ== X-Gm-Message-State: AOJu0Yy5aHULtXrfGeQ3UXlWp7hZh/bHl+U8CBQOBF2FeKTmcl1SS0w8 3aIV7vc2XHEnuWsjMw4LZWbhsLsJJHlPftn+rGqELJlpjEoA2gJm2z4rb0tDKnxcDxVWLeeL3tq WugDqAj8jX69CmmDcdxx74i2xvfoMMvSl9BvlYqxjIhEmRlWodHn5g8eW3YA3F2NtEH8Z2hLOAn 5kd8iGix0p2xk9YcMV5p3X0qmvyraUbw== X-Received: by 2002:adf:cc8f:0:b0:37d:52b5:451e with SMTP id ffacd0b85a97d-3806118aa34mr24569599f8f.33.1730754430027; Mon, 04 Nov 2024 13:07:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpEEvYRY7UEWHf80vONs7JSf6d3m5pY/1PNQSJIoyw2DYqAfwCELJtMCMjzAFz6xk0siW/8g== X-Received: by 2002:adf:cc8f:0:b0:37d:52b5:451e with SMTP id ffacd0b85a97d-3806118aa34mr24569583f8f.33.1730754429494; Mon, 04 Nov 2024 13:07:09 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c116a7a6sm14152264f8f.92.2024.11.04.13.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:08 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Ani Sinha Subject: [PULL 24/65] acpi/disassemle-aml.sh: fix up after dir reorg Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org We moved expected files around, fix up the disassembler script. Fixes: 7c08eefcaf ("tests/data/acpi: Move x86 ACPI tables under x86/${machine} path") Fixes: 7434f90467 ("tests/data/acpi/virt: Move ARM64 ACPI tables under aarch64/${machine} path") Cc: "Sunil V L" Message-ID: Signed-off-by: Michael S. Tsirkin Acked-by: Igor Mammedov --- tests/data/acpi/disassemle-aml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/acpi/disassemle-aml.sh b/tests/data/acpi/disassemle-aml.sh index 253b7620a0..89561d233d 100755 --- a/tests/data/acpi/disassemle-aml.sh +++ b/tests/data/acpi/disassemle-aml.sh @@ -14,7 +14,7 @@ while getopts "o:" arg; do esac done -for machine in tests/data/acpi/* +for machine in tests/data/acpi/*/* do if [[ ! -d "$machine" ]]; then From patchwork Mon Nov 4 21:07:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 345F9D1BDF2 for ; Mon, 4 Nov 2024 21:12:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84ID-0007iT-8o; Mon, 04 Nov 2024 16:07:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IA-0007O6-V0 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84I9-0005NY-DB for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754436; 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=K1MI5dfaWHJA3BO6melGD3KT8KGOimCWraUvc5kNsY4=; b=SS9bXXHUm/4YhM7W7ztiYHncGSyf4XNinuMHs2NrwyLV237H1VDFNuhYLWMQf0fmJM45x0 GTKFDZOJc39BcdIgzF7195uS/VaDNdCW82hA9r8XcmtZvR+3kxXpWBHCavW+f+zoZf1MxK JXywOQaPpZeW7vXomNk3g2RhwwPtb24= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-551-rf57GuzCN72w1tSdMy5ffQ-1; Mon, 04 Nov 2024 16:07:15 -0500 X-MC-Unique: rf57GuzCN72w1tSdMy5ffQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d5a3afa84so2327306f8f.3 for ; Mon, 04 Nov 2024 13:07:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754434; x=1731359234; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=K1MI5dfaWHJA3BO6melGD3KT8KGOimCWraUvc5kNsY4=; b=YgCeYRwwit5SZalimsOy6nSewv3OsC+AQu6nG9tq4crPMIb/OlaBDZpAHINbylCIt/ UvExkcmELpGA4H3vkJhlF/3oCUC9dvJQ+/yMFmMkbOGD+jEcF3dBLb0vW9gvHA9HN2mQ O6NO4iNo/bo2Pe32MdUxl3bGMvMD2KSEQfwsSibOqDO+LWK5dCaDJGwScavtWExfTFKZ 0NSFk50H9jbcvU9NeYMv2IpFYuO5cWtAd+ouLKu3NfI+DNjCqvOmuk/895KhJIOmNQve dPLUGoIxo0qj2kOiBhwJzBdPgH/UC0oiKfJ64vygJg92EHNeNlHGSXoCHYC/Ur5trakU +EbA== X-Gm-Message-State: AOJu0YzTQk64yp2yj/MmuR+ca8mJkYNGYRlxDwTYqs8w/JxdQx2+8D5x weR6Xkyn+s6bhwHoP1anYeD7gdKUYqDCV19M7EpA+7H4IZOq898nE+dt7r/jO4hC5kmz0CE1ltR D42Djq9OZUIBhJYXRGa+x4N8q5xnN9qAC16j2gyPEAG18eqmzgsTec/VbJE/aSCeSIoAdM673bq sxLaLRn/ALg1+M5W4OT5VDWnDq63dIhQ== X-Received: by 2002:a5d:5c01:0:b0:37d:461d:b1ea with SMTP id ffacd0b85a97d-381c7ab30b1mr11789044f8f.48.1730754433815; Mon, 04 Nov 2024 13:07:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBBv6P2WdADcM4FRlqc4uwtAXrJxj/k1/pIzNCcGxac9zjNsWn0zB/jP1y8+T5aBQlEdQoRA== X-Received: by 2002:a5d:5c01:0:b0:37d:461d:b1ea with SMTP id ffacd0b85a97d-381c7ab30b1mr11789025f8f.48.1730754433301; Mon, 04 Nov 2024 13:07:13 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e67csm14147402f8f.75.2024.11.04.13.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:12 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ricardo Ribalda , Igor Mammedov , Ani Sinha Subject: [PULL 25/65] tests/acpi: pc: allow DSDT acpi table changes Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ricardo Ribalda Signed-off-by: Ricardo Ribalda Message-Id: <20240924132417.739809-2-ribalda@chromium.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Igor Mammedov --- tests/qtest/bios-tables-test-allowed-diff.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..6fef8e558b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,17 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/x86/pc/DSDT", +"tests/data/acpi/x86/pc/DSDT.acpierst", +"tests/data/acpi/x86/pc/DSDT.acpihmat", +"tests/data/acpi/x86/pc/DSDT.bridge", +"tests/data/acpi/x86/pc/DSDT.cphp", +"tests/data/acpi/x86/pc/DSDT.dimmpxm", +"tests/data/acpi/x86/pc/DSDT.hpbridge", +"tests/data/acpi/x86/pc/DSDT.hpbrroot", +"tests/data/acpi/x86/pc/DSDT.ipmikcs", +"tests/data/acpi/x86/pc/DSDT.memhp", +"tests/data/acpi/x86/pc/DSDT.nohpet", +"tests/data/acpi/x86/pc/DSDT.numamem", +"tests/data/acpi/x86/pc/DSDT.roothp", +"tests/data/acpi/x86/q35/DSDT.cxl", +"tests/data/acpi/x86/q35/DSDT.viot", +"tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x", From patchwork Mon Nov 4 21:07:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20A54D1BDF4 for ; Mon, 4 Nov 2024 21:08:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84II-0008J5-Ki; Mon, 04 Nov 2024 16:07:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IF-00081w-B2 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84ID-0005Nv-Jv for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754441; 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=vprvKklVU3XFH5cq7J6dxp5ZuQRvYtysugY4oc0x0dU=; b=WEZw2/moKyF6KLHK2Z0gesoaXmU8AAchaRm/jdToLlG/WcOjNFm2DxwEVLlLla3N/C1P9W qYy3zQ1PmOU94fodznNPZklseroINkKODoOOqKn6oD+PtlYWwm8R74RMjsj90Pzq1hxy8W qIFzSP+BcGrkoCmVJs8KdDV+SW5weI0= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-T20wPS8cM-uDMVXnysvk9w-1; Mon, 04 Nov 2024 16:07:19 -0500 X-MC-Unique: T20wPS8cM-uDMVXnysvk9w-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4317391101aso30654405e9.2 for ; Mon, 04 Nov 2024 13:07:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754438; x=1731359238; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vprvKklVU3XFH5cq7J6dxp5ZuQRvYtysugY4oc0x0dU=; b=s+XwURI4Jew4edrUDob8ujTwKra7Ao1ywnYU267Zl6k8LuxevqEAAKKsdB7BfRTLfM Hs7G5HuYJQMT039XkRldI4umbEfpsb0aIu2XFX1QMXkEGTtbFsXAiAOzmRd2IX1lviCK Kl00KvWwp9o9ucEp6SxrYZLJgZQixGwIgZiN9ic2DB7FMV3AfkaJjvJx/t13dS5izM4q sBe6bVxhoqAVgBqva39+a2TGNVdK9s0WhUK1EAQueadT9WkbNOF8bmncPsm9A3tv49OB AaGwqcoRMvDiOyUR57eJOTTZqP9SwZQqDR39tVcnK4454lGpeAR7KLUoi8vZRhb2R9V5 OXvQ== X-Gm-Message-State: AOJu0YzK3E0ramuiwRJi2Fk74GGLMNGngv8zQaRLd3MGZGAOmHt+qQbH 36Wn8OG5kaLBdbMWGBR+0S4bF9N8+AVueofHCWnKJt+9aERetERrMHFw044V6WuLArUMcyacAPt +IqspjrTOSWiFf8+ZmcAdEJR3nGO8FNTEVg/h6WFyf4FiJyhXSv08pb3v5NPjCvK/lDJ2w3ybc6 RiSeFI7eoH3nCn+nZ4DQ+rJi+Oyulfbg== X-Received: by 2002:a05:600c:1c14:b0:431:57e5:b245 with SMTP id 5b1f17b1804b1-4328328492amr109793445e9.23.1730754438222; Mon, 04 Nov 2024 13:07:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFxAqhEribnYGDcnTMzrSVWxFFC4H2juyyO/DSj5olVabGJGa+Y+9TE73CsxJ5J3tyQe5Fjg== X-Received: by 2002:a05:600c:1c14:b0:431:57e5:b245 with SMTP id 5b1f17b1804b1-4328328492amr109793105e9.23.1730754437712; Mon, 04 Nov 2024 13:07:17 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd8e853esm198914825e9.8.2024.11.04.13.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:17 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ricardo Ribalda , Igor Mammedov , Mark Cave-Ayland , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 26/65] hw/i386/acpi-build: return a non-var package from _PRT() Message-ID: <7916bb54319a56be5c5eca0c890a4d2aa22b9bef.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ricardo Ribalda Windows XP seems to have issues when _PRT() returns a variable package. We know in advance the size, so we can return a fixed package instead. https://lore.kernel.org/qemu-devel/c82d9331-a8ce-4bb0-b51f-2ee789e27c86@ilande.co.uk/T/#m541190c942676bccf7a7f7fbcb450d94a4e2da53 Reviewed-by: Igor Mammedov Reported-by: Mark Cave-Ayland Fixes: 99cb2c6c7b ("hw/i386/acpi-build: Return a pre-computed _PRT table") Closes: https://lore.kernel.org/all/eb11c984-ebe4-4a09-9d71-1e9db7fe7e6f@ilande.co.uk/ Signed-off-by: Ricardo Ribalda Message-Id: <20240924132417.739809-3-ribalda@chromium.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d01e704162..508a6094aa 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -740,7 +740,8 @@ static Aml *build_prt(bool is_pci0_prt) int pin; method = aml_method("_PRT", 0, AML_NOTSERIALIZED); - rt_pkg = aml_varpackage(nroutes); + assert(nroutes < 256); + rt_pkg = aml_package(nroutes); for (pin = 0; pin < nroutes; pin++) { Aml *pkg = aml_package(4); From patchwork Mon Nov 4 21:07:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B291D1BDF3 for ; Mon, 4 Nov 2024 21:08:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84IO-0008V0-BB; Mon, 04 Nov 2024 16:07:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IJ-0008N7-KS for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IH-0005O5-5v for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754444; 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=mFcIA7Jcyc6ARZWFCnittLNHwswZ/g6kFGbYCyMXGr0=; b=ctHijI4glwx1CI1DM7dw6y1M1aW6k/OgXt9EToweiUcLIFehcGI0zlt7i/XL54Zb5JpX3L piWP+PCg1MGzzurA4SFaTW760hnXkr0XJjOz9dybB/CQM1QtIK2B2/UWVp3P9zVeefwups x2FxgvEb5RWuEAgKIb3xFi+oh9DEg50= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-a-yM8tslPZKBbci3jvCgUw-1; Mon, 04 Nov 2024 16:07:23 -0500 X-MC-Unique: a-yM8tslPZKBbci3jvCgUw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43157cff1d1so34456275e9.2 for ; Mon, 04 Nov 2024 13:07:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754442; x=1731359242; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mFcIA7Jcyc6ARZWFCnittLNHwswZ/g6kFGbYCyMXGr0=; b=o8FJfsAsDsymSZdNgTwaOCREsjHyNqTfi5bhM2fGBDpEZj8MH2d9vzL+ziNhWaHiWq AC0OH51aOv8mnLA1ggtChPh8FY98sb66AGv9hDdAnUbjYE7OGEeRbmV0r8lNWXez8ICZ 6oXeayh+a2jut5QNOf0j8vc6DTy3LBouAWI8JR4WY0j1PMk06JegbAwP/0CJ31oMgWJG m2uwrAMEu/ecUeuJpHncTrAvqKSn4Reo7QuUOTCrLz4CtaSzm1GGC0Go59+JN4fk19HM pqchIIUmMbx+KhCiFtdEjOnDd9A5l7PCUKq6IamuyeauX4C/2MTuwwq5iF0s9Kwi3AMz pKXg== X-Gm-Message-State: AOJu0YyaQYyx5wvq7CVMU3kjKp2Hli4f6kQrlCH7ZRQj7xCYEk0dBHMa GIKzNf0CENT53fNl+iQDtkiZ9T7RBAy2gZA0NCInhs6/rp2/qyPREACDcorhxho+4mK1i/SMb90 Ji1TJTf39JsuipQlOhSSkvGM/dAIyQQD8FdwFRiMPv4fZ6Q7o8TYDZafo8+/fW5s0rl5ipvxMob recvgQP+JVZghd+RRUDMGGUMEZTZmR5w== X-Received: by 2002:a05:600c:5115:b0:431:7c78:b885 with SMTP id 5b1f17b1804b1-4327b6f954emr142776215e9.4.1730754441618; Mon, 04 Nov 2024 13:07:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IG11NkyNpnhUMMnlLNStO6rg37Phu1jDmDoMyGTxnzgBqBhNLS2nQ0JIwEz7QIXOUsPQx1nIw== X-Received: by 2002:a05:600c:5115:b0:431:7c78:b885 with SMTP id 5b1f17b1804b1-4327b6f954emr142775925e9.4.1730754441111; Mon, 04 Nov 2024 13:07:21 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9479ebsm192427175e9.23.2024.11.04.13.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:20 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ricardo Ribalda , Igor Mammedov , Ani Sinha Subject: [PULL 27/65] tests/acpi: pc: update golden masters for DSDT Message-ID: <9848a76c0b56172a370640744e99fe78fea4d4c0.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ricardo Ribalda Note: since all we did is replace VarPackageOp with PackageOP, and both are represented by Package() in ASL, the AML is different but ASL is the same. Signed-off-by: Ricardo Ribalda Message-Id: <20240924132417.739809-4-ribalda@chromium.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Igor Mammedov --- tests/qtest/bios-tables-test-allowed-diff.h | 16 ---------------- tests/data/acpi/x86/pc/DSDT | Bin 8527 -> 8526 bytes tests/data/acpi/x86/pc/DSDT.acpierst | Bin 8438 -> 8437 bytes tests/data/acpi/x86/pc/DSDT.acpihmat | Bin 9852 -> 9851 bytes tests/data/acpi/x86/pc/DSDT.bridge | Bin 15398 -> 15397 bytes tests/data/acpi/x86/pc/DSDT.cphp | Bin 8991 -> 8990 bytes tests/data/acpi/x86/pc/DSDT.dimmpxm | Bin 10181 -> 10180 bytes tests/data/acpi/x86/pc/DSDT.hpbridge | Bin 8478 -> 8477 bytes tests/data/acpi/x86/pc/DSDT.hpbrroot | Bin 5034 -> 5033 bytes tests/data/acpi/x86/pc/DSDT.ipmikcs | Bin 8599 -> 8598 bytes tests/data/acpi/x86/pc/DSDT.memhp | Bin 9886 -> 9885 bytes tests/data/acpi/x86/pc/DSDT.nohpet | Bin 8385 -> 8384 bytes tests/data/acpi/x86/pc/DSDT.numamem | Bin 8533 -> 8532 bytes tests/data/acpi/x86/pc/DSDT.roothp | Bin 12320 -> 12319 bytes tests/data/acpi/x86/q35/DSDT.cxl | Bin 13148 -> 13146 bytes tests/data/acpi/x86/q35/DSDT.viot | Bin 14615 -> 14612 bytes 16 files changed, 16 deletions(-) diff --git a/tests/data/acpi/x86/pc/DSDT b/tests/data/acpi/x86/pc/DSDT index 92225236e717b2e522a2ee00492fb0ded418dc7b..8b8235fe79e2fa08a6f840c8479edb75f5a047b9 100644 GIT binary patch delta 50 zcmX@_bk2#(CD@oAE|a9ky!c?JcmeN{0B27F5towqfS?eDB|_fCn**8t G$pHX!zYhWc delta 51 zcmX@-bl!=}CD)i9E|Zk!y!c?Jcmbc10B27F5!aIVfS?eDCBi<%T$=-! H{>cFVe<%+E diff --git a/tests/data/acpi/x86/pc/DSDT.acpierst b/tests/data/acpi/x86/pc/DSDT.acpierst index 25b39955059409b177870800949eaf937cd39005..06829b9c6c6d726d955dc7c99bc9f42448e22aeb 100644 GIT binary patch delta 50 zcmez7_|=iiCD delta 51 zcmezE^T&tFCDBgE$Wk diff --git a/tests/data/acpi/x86/pc/DSDT.cphp b/tests/data/acpi/x86/pc/DSDT.cphp index 1dc928333d7ae7e4df6bb51d850af5e1cb480158..045a52e75b7fcd4e5f840a758c548231498b96e4 100644 GIT binary patch delta 50 zcmbR5HqVXACD-1^5)N_z delta 51 zcmbR1G|!34CDw)2U4E%;)9*y1$;^ZoIMRhTub5ufTRsZDwX% GCIkS3!Vb~^ diff --git a/tests/data/acpi/x86/pc/DSDT.ipmikcs b/tests/data/acpi/x86/pc/DSDT.ipmikcs index c2a0330d97d495298889b9e28bde2f90235cea88..0ca664688b16baa3a06b8440181de4f17511c6b0 100644 GIT binary patch delta 50 zcmbR4Jk6QQCDO%X%3M9 delta 51 zcmX@$c+io{CDBT_!2ddGWzc@d7?20nVNVBCaLz0YM=QON4!jxi$wd H703Yqg6|HI diff --git a/tests/data/acpi/x86/pc/DSDT.numamem b/tests/data/acpi/x86/pc/DSDT.numamem index 8a6b56fe7da18bf42c339d13b863aabf81780527..2c98cafbff5db04410b35a1151eaf18723a4dad7 100644 GIT binary patch delta 50 zcmccWbj69wCD2P delta 51 zcmbQAupoiUCDBTe@uL^Q+#xj=VoBze@uL^Q+#xj*JgEDD@GpIlK6n25QZhfKE+&{ VBfLri?IQ+#xj>tuD=rQ9wh@c}_03`>N(i#Okp Z4P{4`H&;cKf1!#h@2-m~|3g=v8vqA!B?tfj delta 127 zcmbPIG`)z+CD(KT@#aP@VOcK!hM4$Zr}*e5x5?_VOL<&N;sb(07?ue86mxC9 gE*r{@tiVhaLxC6jWCLApWJRvJSQKrxH@(UX0RQ4B(*OVf diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index 6fef8e558b..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,17 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/x86/pc/DSDT", -"tests/data/acpi/x86/pc/DSDT.acpierst", -"tests/data/acpi/x86/pc/DSDT.acpihmat", -"tests/data/acpi/x86/pc/DSDT.bridge", -"tests/data/acpi/x86/pc/DSDT.cphp", -"tests/data/acpi/x86/pc/DSDT.dimmpxm", -"tests/data/acpi/x86/pc/DSDT.hpbridge", -"tests/data/acpi/x86/pc/DSDT.hpbrroot", -"tests/data/acpi/x86/pc/DSDT.ipmikcs", -"tests/data/acpi/x86/pc/DSDT.memhp", -"tests/data/acpi/x86/pc/DSDT.nohpet", -"tests/data/acpi/x86/pc/DSDT.numamem", -"tests/data/acpi/x86/pc/DSDT.roothp", -"tests/data/acpi/x86/q35/DSDT.cxl", -"tests/data/acpi/x86/q35/DSDT.viot", -"tests/data/acpi/x86/q35/DSDT.acpihmat-generic-x", From patchwork Mon Nov 4 21:07:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1DB3D1BDF2 for ; Mon, 4 Nov 2024 21:08:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84IQ-0000CT-Bw; Mon, 04 Nov 2024 16:07:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IN-0008V9-4e for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IL-0005OF-B1 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754448; 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=fOAN2C/Gq+fL1Um9UhAsgi+uFdrVpTy3qKoA3Bihgaw=; b=J4VymFBTJGOZLVrzTl8VcgIpPaxMBEvxNk1IqtntYc4SDNAHVRX4UA01vMb/fcTjFI3t+A h5W2c0hiEbJgnd8h/XLuhCRGu+UgN5skii3XRzAjAKQWsJM7e+XcBws5YxJvj+Px8R/YDi WElJDqOlTLe/8o40j/NZ1IRYZU1FB34= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-wj61nPwvNUKen6gzOW__cA-1; Mon, 04 Nov 2024 16:07:27 -0500 X-MC-Unique: wj61nPwvNUKen6gzOW__cA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4316e2dde9eso39450635e9.2 for ; Mon, 04 Nov 2024 13:07:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754446; x=1731359246; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fOAN2C/Gq+fL1Um9UhAsgi+uFdrVpTy3qKoA3Bihgaw=; b=gv2cIk7b1uHcYh2QpLkXjMCTQYUNxuheTG4TWCVLtSsuD/9TmPgZvznN9Jx/KSSgiL 7kwNYPhcChqnEYKAz7Ss61a6cp2x1WOhwLhnMq9b4vIAiXzYpzRQYBI7FXzLi95IQYJN o8IxdU4318fhIIjiSYSwcYjB5+9mYA0ZGGSAS5Pee3WJLVtVUyNYCHJ+EVUtaXpCOjfh 9fkrV+cRZTaRdYSQ/L/w0wubp3g33ML4ixJBP8UuszDOmcp4E0WtWGEyuIWDWwgIp3b5 1SRVhdM/YpKkqjeX0AJeTEPUbYpugJ9mQd27hhoe7RXR99u196ESIY3ubcNKAWG2x01o Jfcw== X-Gm-Message-State: AOJu0YzVRSpax/Qi3Ei4WzDcM6Xd351Y6oJfdG802HzoAW0r7Zbr33uW dmxpr5oxKqtm02DDNQw1M330nGeheyhn41zecNekqX6WeVaZb9lcJ6GSF96DZ6QuP8b/pwrU8ty XwhvOQrTXM8i6UwX2Un5ExCAvEU391sklNPXPTmlrayQLD0gX9ILJFPFNMahHcAQc68l7RXOpg7 A+mrkrqfV1JOCcEqG5SutlLBXE9I0AEQ== X-Received: by 2002:a05:600c:1d1e:b0:431:604d:b22 with SMTP id 5b1f17b1804b1-43283255922mr142591315e9.16.1730754445927; Mon, 04 Nov 2024 13:07:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlrGv0WZaoqpH0W4hZ1y6wxQgnCqJYzwvp1616S+EbVH2J3gP+Boe5naZ4fr6hfPHQxAtdGw== X-Received: by 2002:a05:600c:1d1e:b0:431:604d:b22 with SMTP id 5b1f17b1804b1-43283255922mr142591085e9.16.1730754445468; Mon, 04 Nov 2024 13:07:25 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5bf225sm163464115e9.11.2024.11.04.13.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:24 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Suravee Suthikulpanit , Alejandro Jimenez , Santosh Shukla , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 28/65] amd_iommu: Rename variable mmio to mr_mmio Message-ID: <2e6f051cfc58e69dcb392cd245d8f01b0c2e963f.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Suravee Suthikulpanit Rename the MMIO memory region variable 'mmio' to 'mr_mmio' so to correctly name align with struct AMDVIState::variable type. No functional change intended. Reviewed-by: Alejandro Jimenez Signed-off-by: Suravee Suthikulpanit Signed-off-by: Santosh Shukla Message-Id: <20240927172913.121477-2-santosh.shukla@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 2 +- hw/i386/acpi-build.c | 4 ++-- hw/i386/amd_iommu.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 73619fe9ea..e5c2ae94f2 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -353,7 +353,7 @@ struct AMDVIState { uint32_t pprlog_head; /* ppr log head */ uint32_t pprlog_tail; /* ppr log tail */ - MemoryRegion mmio; /* MMIO region */ + MemoryRegion mr_mmio; /* MMIO region */ uint8_t mmior[AMDVI_MMIO_SIZE]; /* read/write MMIO */ uint8_t w1cmask[AMDVI_MMIO_SIZE]; /* read/write 1 clear mask */ uint8_t romask[AMDVI_MMIO_SIZE]; /* MMIO read/only mask */ diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 508a6094aa..9fcc2897b8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2324,7 +2324,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, /* Capability offset */ build_append_int_noprefix(table_data, s->pci.capab_offset, 2); /* IOMMU base address */ - build_append_int_noprefix(table_data, s->mmio.addr, 8); + build_append_int_noprefix(table_data, s->mr_mmio.addr, 8); /* PCI Segment Group */ build_append_int_noprefix(table_data, 0, 2); /* IOMMU info */ @@ -2359,7 +2359,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, /* Capability offset */ build_append_int_noprefix(table_data, s->pci.capab_offset, 2); /* IOMMU base address */ - build_append_int_noprefix(table_data, s->mmio.addr, 8); + build_append_int_noprefix(table_data, s->mr_mmio.addr, 8); /* PCI Segment Group */ build_append_int_noprefix(table_data, 0, 2); /* IOMMU info */ diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 464f0b666e..abb64ea507 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1598,10 +1598,10 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) x86ms->ioapic_as = amdvi_host_dma_iommu(bus, s, AMDVI_IOAPIC_SB_DEVID); /* set up MMIO */ - memory_region_init_io(&s->mmio, OBJECT(s), &mmio_mem_ops, s, "amdvi-mmio", - AMDVI_MMIO_SIZE); + memory_region_init_io(&s->mr_mmio, OBJECT(s), &mmio_mem_ops, s, + "amdvi-mmio", AMDVI_MMIO_SIZE); memory_region_add_subregion(get_system_memory(), AMDVI_BASE_ADDR, - &s->mmio); + &s->mr_mmio); pci_setup_iommu(bus, &amdvi_iommu_ops, s); amdvi_init(s); } From patchwork Mon Nov 4 21:07:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862087 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A4FDD1BDF3 for ; Mon, 4 Nov 2024 21:13:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84KC-0001HI-VN; Mon, 04 Nov 2024 16:09:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84K8-0000wU-Jk for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84K6-0005Wx-Nr for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754557; 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=kPkqbS0KzBZTstIImdMCo6tR4lv6gQtQBT2m2wr8v1o=; b=PKQqahs28VwQZl0sXn98Uj/A3iibLGk10CPbsSdYi6pMkTTKRWLn3gdcpq7WqoDfQoT0gW h+sWXdQvl2d73Wdn2l1DFPdPY/vJ1+CxYcPdrZkyh4LSjGC/Ghthsn7d3q9ZeLsiqqtIPO 4aLs5V0Ha9STx75nznSIqlAuGPVeM5o= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-335-4kFSM8Q2OB2IQlezImmHRA-1; Mon, 04 Nov 2024 16:07:31 -0500 X-MC-Unique: 4kFSM8Q2OB2IQlezImmHRA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d5016d21eso2136328f8f.3 for ; Mon, 04 Nov 2024 13:07:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754450; x=1731359250; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kPkqbS0KzBZTstIImdMCo6tR4lv6gQtQBT2m2wr8v1o=; b=RArsMd4c6HR9KVfZk+hpKWBKD5LIH9xZhkmwsygjbUdVlvbAVKjHt29TtyTrVq4ygk HPu2iLTlB7FhqYu4ja1E+0919UvfwAD9FdcQu5GJLe9PBGk+WRGOFd2Do/3W9qOJqEMs VXQIFFrS666rSBLKvkcb/xhBukeFYMQcoogwgqJDg4DZSe46N709Pa4/Lq+6EPl/n6EN MJ5rwgAD6uJDI6EFa2PRAM3eSjASZqhKVmY1//qdkKgW2YV3xFqRGCZxpqOwHYss6Vxj sRdxFPsgkzVz6AjVte5yORvpmEvpmX5Ae3mcBZv8YCoNrMVXHVzQEfbcDRrqDyzDOSYT Z5/A== X-Gm-Message-State: AOJu0YzqtI5KWapFgoR1VVWmCpEFe6pwfIJeKJe0k+xg/q7aL9NqqbRL ay7DbNMyU89jT8UyjeK0ebgBHf2Ethl11ENGANAizVn9puQKZ++ebI1jpXXGusYkNX1btdZbaGX z7ZHflMaXtZ99RWmocy7EZtokjgXYv0IOXduhLhkF3rwfD4k5rVRuXKBUSEOkl+gvOPl3EK53v6 2KamiY9mXoKVqFKLUzoBA7MfJoHgDUqQ== X-Received: by 2002:a5d:4a11:0:b0:374:c92e:f6b1 with SMTP id ffacd0b85a97d-380611585f8mr24122078f8f.23.1730754449899; Mon, 04 Nov 2024 13:07:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYK+/Sm79EkWZWY4QxUccwt4jIS0yVBLWIwJRdLMHcemcBVhyXJIizUL7Ro2dB2pu7dhBfdg== X-Received: by 2002:a5d:4a11:0:b0:374:c92e:f6b1 with SMTP id ffacd0b85a97d-380611585f8mr24122054f8f.23.1730754449343; Mon, 04 Nov 2024 13:07:29 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd917fa7sm192135615e9.18.2024.11.04.13.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:28 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Suravee Suthikulpanit , Alejandro Jimenez , Santosh Shukla , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 29/65] amd_iommu: Add support for pass though mode Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Suravee Suthikulpanit Introduce 'nodma' shared memory region to support PT mode so that for each device, we only create an alias to shared memory region when DMA-remapping is disabled. Reviewed-by: Alejandro Jimenez Signed-off-by: Suravee Suthikulpanit Signed-off-by: Santosh Shukla Message-Id: <20240927172913.121477-3-santosh.shukla@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 2 ++ hw/i386/amd_iommu.c | 49 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index e5c2ae94f2..be417e51c4 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -354,6 +354,8 @@ struct AMDVIState { uint32_t pprlog_tail; /* ppr log tail */ MemoryRegion mr_mmio; /* MMIO region */ + MemoryRegion mr_sys; + MemoryRegion mr_nodma; uint8_t mmior[AMDVI_MMIO_SIZE]; /* read/write MMIO */ uint8_t w1cmask[AMDVI_MMIO_SIZE]; /* read/write 1 clear mask */ uint8_t romask[AMDVI_MMIO_SIZE]; /* MMIO read/only mask */ diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index abb64ea507..7c7760c573 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -60,8 +60,9 @@ struct AMDVIAddressSpace { uint8_t bus_num; /* bus number */ uint8_t devfn; /* device function */ AMDVIState *iommu_state; /* AMDVI - one per machine */ - MemoryRegion root; /* AMDVI Root memory map region */ + MemoryRegion root; /* AMDVI Root memory map region */ IOMMUMemoryRegion iommu; /* Device's address translation region */ + MemoryRegion iommu_nodma; /* Alias of shared nodma memory region */ MemoryRegion iommu_ir; /* Device's interrupt remapping region */ AddressSpace as; /* device's corresponding address space */ }; @@ -1412,6 +1413,7 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) AMDVIState *s = opaque; AMDVIAddressSpace **iommu_as, *amdvi_dev_as; int bus_num = pci_bus_num(bus); + X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s); iommu_as = s->address_spaces[bus_num]; @@ -1436,13 +1438,13 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) * Memory region relationships looks like (Address range shows * only lower 32 bits to make it short in length...): * - * |-----------------+-------------------+----------| - * | Name | Address range | Priority | - * |-----------------+-------------------+----------+ - * | amdvi_root | 00000000-ffffffff | 0 | - * | amdvi_iommu | 00000000-ffffffff | 1 | - * | amdvi_iommu_ir | fee00000-feefffff | 64 | - * |-----------------+-------------------+----------| + * |--------------------+-------------------+----------| + * | Name | Address range | Priority | + * |--------------------+-------------------+----------+ + * | amdvi-root | 00000000-ffffffff | 0 | + * | amdvi-iommu_nodma | 00000000-ffffffff | 0 | + * | amdvi-iommu_ir | fee00000-feefffff | 64 | + * |--------------------+-------------------+----------| */ memory_region_init_iommu(&amdvi_dev_as->iommu, sizeof(amdvi_dev_as->iommu), @@ -1461,7 +1463,25 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) 64); memory_region_add_subregion_overlap(&amdvi_dev_as->root, 0, MEMORY_REGION(&amdvi_dev_as->iommu), - 1); + 0); + + /* Build the DMA Disabled alias to shared memory */ + memory_region_init_alias(&amdvi_dev_as->iommu_nodma, OBJECT(s), + "amdvi-sys", &s->mr_sys, 0, + memory_region_size(&s->mr_sys)); + memory_region_add_subregion_overlap(&amdvi_dev_as->root, 0, + &amdvi_dev_as->iommu_nodma, + 0); + + if (!x86_iommu->pt_supported) { + memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, false); + memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu), + true); + } else { + memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu), + false); + memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, true); + } } return &iommu_as[devfn]->as; } @@ -1602,6 +1622,17 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) "amdvi-mmio", AMDVI_MMIO_SIZE); memory_region_add_subregion(get_system_memory(), AMDVI_BASE_ADDR, &s->mr_mmio); + + /* Create the share memory regions by all devices */ + memory_region_init(&s->mr_sys, OBJECT(s), "amdvi-sys", UINT64_MAX); + + /* set up the DMA disabled memory region */ + memory_region_init_alias(&s->mr_nodma, OBJECT(s), + "amdvi-nodma", get_system_memory(), 0, + memory_region_size(get_system_memory())); + memory_region_add_subregion_overlap(&s->mr_sys, 0, + &s->mr_nodma, 0); + pci_setup_iommu(bus, &amdvi_iommu_ops, s); amdvi_init(s); } From patchwork Mon Nov 4 21:07:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 836D4D1BDF2 for ; Mon, 4 Nov 2024 21:12:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84IW-0000uD-Ur; Mon, 04 Nov 2024 16:07:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IU-0000dD-S8 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IT-0005Oa-32 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754456; 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=Ix86++93BtAOuMpEcgnrqz9oSyLAYBg4CUdSvCBsa08=; b=W+kPgSoDVza6+TM7xnKWey17Sq032VD3Ztr5MH3s8XRn+d4yoa6E2pCOGwYrtBLbUg7Kvo uhb8dLnuRVgoKBZFJwAQ1INhJKuEReQTelss+w+Oi48PYEkZBcr2nmI0yqvjNzUT7N2t1l 2xjspSyc6CzAYM4HD0A7rLfdnHphGyI= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-500-8sjD1VxRNLGHoVMHOemM6Q-1; Mon, 04 Nov 2024 16:07:35 -0500 X-MC-Unique: 8sjD1VxRNLGHoVMHOemM6Q-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4315f48bd70so32899015e9.2 for ; Mon, 04 Nov 2024 13:07:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754454; x=1731359254; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Ix86++93BtAOuMpEcgnrqz9oSyLAYBg4CUdSvCBsa08=; b=YldVJICPG1eG7rtrD5KKOe633QxG2ROIRkTxGdITQxGlGkrSi4tcuOkCbEkcOHsnz8 J2lWhilxV3jca/5xfy4GupKT8d/h5bF6nmNWZvI2tf5NerLefKrKvrsbOMfcGTWOunmZ Pas7P4jiei4WZ+o2xbqmjqLwhmjW78kVYZifBCDu/R/pHTejU7gzXhOM+JrsdBk5Ub64 /tBszkk6+F4pXLl1I20mCizOj5A+g6FooKilvlBxZ1zJxZwct9VUl63OjBBWgUX6n9Ac h+uCOSk3PCD7LvloysqecmAvBjn8OT2WY9CG4RN6ON3g6QNCYv8BdunR4cbACQBbR4TY nkvw== X-Gm-Message-State: AOJu0YzDQT/KHXhMC8xabFuiVP0u+HGE6CAtKlVoSBXHKoXbSHN2N9zK DZGtNB15sAezsn+bqcqlScgjE83wi4U3dEV+JfqhTKjTXc1tzWEnKMJroQSjPyW2IJoyhFCqytQ tJFUqye6exi65zBdWQPJEK0k5ERfUkXLwo074bxjuLcR3O67xsIRe7RmVPjpyJ0MPZIZCUcnalK p190C3Plc1fJyL1xyk00uE8xRuyw/6MA== X-Received: by 2002:a5d:64a8:0:b0:37d:46e3:4e88 with SMTP id ffacd0b85a97d-381be7654c6mr16200040f8f.9.1730754453799; Mon, 04 Nov 2024 13:07:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTQXu/OsR2Iqo0IaPk7U1g3hSC4ZpEfmYmT/ChQEPBQGp8fLFZUaMC1Zhr5lSDjDLo1JXCEg== X-Received: by 2002:a5d:64a8:0:b0:37d:46e3:4e88 with SMTP id ffacd0b85a97d-381be7654c6mr16200015f8f.9.1730754453261; Mon, 04 Nov 2024 13:07:33 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10eaafdsm14173939f8f.63.2024.11.04.13.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:32 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Suravee Suthikulpanit , Alejandro Jimenez , Santosh Shukla , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 30/65] amd_iommu: Use shared memory region for Interrupt Remapping Message-ID: <9fc9dbac61ddde7d8df37e84c8e02cec249d3222.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Suravee Suthikulpanit Use shared memory region for interrupt remapping which can be aliased by all devices. Reviewed-by: Alejandro Jimenez Signed-off-by: Suravee Suthikulpanit Signed-off-by: Santosh Shukla Message-Id: <20240927172913.121477-4-santosh.shukla@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 1 + hw/i386/amd_iommu.c | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index be417e51c4..e0dac4d9a9 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -356,6 +356,7 @@ struct AMDVIState { MemoryRegion mr_mmio; /* MMIO region */ MemoryRegion mr_sys; MemoryRegion mr_nodma; + MemoryRegion mr_ir; uint8_t mmior[AMDVI_MMIO_SIZE]; /* read/write MMIO */ uint8_t w1cmask[AMDVI_MMIO_SIZE]; /* read/write 1 clear mask */ uint8_t romask[AMDVI_MMIO_SIZE]; /* MMIO read/only mask */ diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 7c7760c573..9b923f6eb4 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1443,7 +1443,7 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) * |--------------------+-------------------+----------+ * | amdvi-root | 00000000-ffffffff | 0 | * | amdvi-iommu_nodma | 00000000-ffffffff | 0 | - * | amdvi-iommu_ir | fee00000-feefffff | 64 | + * | amdvi-iommu_ir | fee00000-feefffff | 1 | * |--------------------+-------------------+----------| */ memory_region_init_iommu(&amdvi_dev_as->iommu, @@ -1454,13 +1454,6 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) memory_region_init(&amdvi_dev_as->root, OBJECT(s), "amdvi_root", UINT64_MAX); address_space_init(&amdvi_dev_as->as, &amdvi_dev_as->root, name); - memory_region_init_io(&amdvi_dev_as->iommu_ir, OBJECT(s), - &amdvi_ir_ops, s, "amd_iommu_ir", - AMDVI_INT_ADDR_SIZE); - memory_region_add_subregion_overlap(&amdvi_dev_as->root, - AMDVI_INT_ADDR_FIRST, - &amdvi_dev_as->iommu_ir, - 64); memory_region_add_subregion_overlap(&amdvi_dev_as->root, 0, MEMORY_REGION(&amdvi_dev_as->iommu), 0); @@ -1472,6 +1465,13 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn) memory_region_add_subregion_overlap(&amdvi_dev_as->root, 0, &amdvi_dev_as->iommu_nodma, 0); + /* Build the Interrupt Remapping alias to shared memory */ + memory_region_init_alias(&amdvi_dev_as->iommu_ir, OBJECT(s), + "amdvi-ir", &s->mr_ir, 0, + memory_region_size(&s->mr_ir)); + memory_region_add_subregion_overlap(MEMORY_REGION(&amdvi_dev_as->iommu), + AMDVI_INT_ADDR_FIRST, + &amdvi_dev_as->iommu_ir, 1); if (!x86_iommu->pt_supported) { memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, false); @@ -1633,6 +1633,12 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->mr_sys, 0, &s->mr_nodma, 0); + /* set up the Interrupt Remapping memory region */ + memory_region_init_io(&s->mr_ir, OBJECT(s), &amdvi_ir_ops, + s, "amdvi-ir", AMDVI_INT_ADDR_SIZE); + memory_region_add_subregion_overlap(&s->mr_sys, AMDVI_INT_ADDR_FIRST, + &s->mr_ir, 1); + pci_setup_iommu(bus, &amdvi_iommu_ops, s); amdvi_init(s); } From patchwork Mon Nov 4 21:07:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862084 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D968AD1BDF3 for ; Mon, 4 Nov 2024 21:13:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Ic-0001q3-Hq; Mon, 04 Nov 2024 16:07:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ia-0001W4-Ng for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84IZ-0005Ox-4M for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754462; 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=khVfGlwR2+qwyC0Ba42wfDZTF3bOsrqz5GwsbYu8ons=; b=eDoX3iHDzO2lkCby6jFPKhuClG0k8gQ/m//0OnbJR0CxXSBFNHDwH5cHgtV6eNPaq6g6IN V2UxlAjDWtsEVHTJ3Acmp/diNlLB+kERDhFBpMe6NDM66mvtVZMNzZV7wETO77RgfyCF+n dicoRHiSGRiEBVjVCrjD6eIGd31ncsY= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-rYmtKGXCNMOSy4mTZuFUTw-1; Mon, 04 Nov 2024 16:07:41 -0500 X-MC-Unique: rYmtKGXCNMOSy4mTZuFUTw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d5a3afa84so2327520f8f.3 for ; Mon, 04 Nov 2024 13:07:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754460; x=1731359260; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=khVfGlwR2+qwyC0Ba42wfDZTF3bOsrqz5GwsbYu8ons=; b=bnXUEP6/sgtcqlZyBZ+4DDTnEGY9Y3XpqJaNxEC16vk6rSdNWYg1f72KFl9+MGvhBF ZbIIQbBQb7Zol3IAzh30SEXCdv4RIAH/Y5f3c9VCT3KuyM0eAqQYWkVIydxHEz3Y/kCY Wd5s4zyfGNPAIDiM63L+1DqgdqDlS8EZ2Mp5Lr9HosB6o1fJos2Fp1iI8wSIaL6HQMK6 3Ge54PwTRX+iExUBU05FM1wYwvGMcmbigRs6f0vxk3ZtpXq57NB/jhum/P+1m8HnEHmz jc5i8BATH5P4F718Rg4lZncCUNaipUWqdSDbrd7K6aZtAaAvy32/OBhEI0JnSy7EUqKt V5Sw== X-Gm-Message-State: AOJu0YwH532mjGBo5umlCIkiPR3Z4SNHun5QAoK6+thFgoQavnttCMGY QwV5xgKw4CmGPjQNqkJifE5BBkkTyfI6JkqJvZB3+G7NLCfFV0EmRT7MQLdDwMwhlhnfgiIrO+C bnQ4cuyarpcGNd0H3e1WhJK+zOmgNmpJsIJr4r30/nrr/IqWwkuoaJ4xCjxmCBteWcA0fwD6gbU qSoad94R+37dao31S9aKT7mRJmoF0ogw== X-Received: by 2002:a05:6000:18a6:b0:37d:5364:d738 with SMTP id ffacd0b85a97d-381c7aa4715mr11631961f8f.45.1730754459798; Mon, 04 Nov 2024 13:07:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdpdM8KENOFdEplgsKC+DSG4/GOUYDQEjViLGXBVniAqn0mJMeHx2Cbt9xdzG3w8VKv66/3Q== X-Received: by 2002:a05:6000:18a6:b0:37d:5364:d738 with SMTP id ffacd0b85a97d-381c7aa4715mr11631940f8f.45.1730754459356; Mon, 04 Nov 2024 13:07:39 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10b7b97sm14293415f8f.2.2024.11.04.13.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:37 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Suravee Suthikulpanit , Alejandro Jimenez , Santosh Shukla , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 31/65] amd_iommu: Send notification when invalidate interrupt entry cache Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Suravee Suthikulpanit In order to support AMD IOMMU interrupt remapping emulation with PCI pass-through devices, QEMU needs to notify VFIO when guest IOMMU driver updates and invalidate the guest interrupt remapping table (IRT), and communicate information so that the host IOMMU driver can update the shadowed interrupt remapping table in the host IOMMU. Therefore, send notification when guest IOMMU emulates the IRT invalidation commands. Reviewed-by: Alejandro Jimenez Signed-off-by: Suravee Suthikulpanit Signed-off-by: Santosh Shukla Message-Id: <20240927172913.121477-5-santosh.shukla@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 9b923f6eb4..38297376e7 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -431,6 +431,12 @@ static void amdvi_complete_ppr(AMDVIState *s, uint64_t *cmd) trace_amdvi_ppr_exec(); } +static void amdvi_intremap_inval_notify_all(AMDVIState *s, bool global, + uint32_t index, uint32_t mask) +{ + x86_iommu_iec_notify_all(X86_IOMMU_DEVICE(s), global, index, mask); +} + static void amdvi_inval_all(AMDVIState *s, uint64_t *cmd) { if (extract64(cmd[0], 0, 60) || cmd[1]) { @@ -438,6 +444,9 @@ static void amdvi_inval_all(AMDVIState *s, uint64_t *cmd) s->cmdbuf + s->cmdbuf_head); } + /* Notify global invalidation */ + amdvi_intremap_inval_notify_all(s, true, 0, 0); + amdvi_iotlb_reset(s); trace_amdvi_all_inval(); } @@ -486,6 +495,9 @@ static void amdvi_inval_inttable(AMDVIState *s, uint64_t *cmd) return; } + /* Notify global invalidation */ + amdvi_intremap_inval_notify_all(s, true, 0, 0); + trace_amdvi_intr_inval(); } From patchwork Mon Nov 4 21:07:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F806D1BDF2 for ; Mon, 4 Nov 2024 21:08:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Ij-0002V8-I9; Mon, 04 Nov 2024 16:07:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ie-0002Bf-PO for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Id-0005PX-8K for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754466; 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=wlEJlaD4rUuzda7f+a8uqDdCRzttqpEXwtLO90XFWes=; b=hECaGtn83+pob7Ae833LUY+dVPS2iJlG/Vrnch8Mr67LDYi7Eetiia1N3pttNKZFF7i7AC FW1W3ZlBK/p/p1+tL1iGfE/PzOmyTMy9beCsXApuBCH2U4Bpxyrxpcps+ucIi58Xlje8Ju gIqmsbrn0f1+CzKxUTyWP5nZwoRYIpU= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-uOmstuEKPYmvZB70NbgKGA-1; Mon, 04 Nov 2024 16:07:45 -0500 X-MC-Unique: uOmstuEKPYmvZB70NbgKGA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d59ad50f3so2040294f8f.0 for ; Mon, 04 Nov 2024 13:07:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754464; x=1731359264; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=wlEJlaD4rUuzda7f+a8uqDdCRzttqpEXwtLO90XFWes=; b=DS2ifeZ+j4r43u6jNYyGHZbpJFiXbjVJmLtUCuP6bmkDq2HRSmlVoEKdRbNgx+dQvz LMK0E/ZqV8jeKfLayJLDN4ge+rtFuyKEHpMRGswPpaFC6Hxm9WyqiyCMS+AJksnNk5Ea Stshl56jIL8IqdHciYVA0JDQ5gQJIRZpn0N2FuIGDtFjE8ul2ZXdyJEcSUA60iHF/FbL N+bVxBlIbkce1y73PbC5wg9xkEqOTRMoxWxWs11h+NEypAfGZrDTU+YoUBC6ZXkNssmo VjAOHPXc457DWSen118En8/sX0mfg9f8wM/KqQicJtNZv4InTjCWzuEEv6vmDDl2KAZ0 ewJw== X-Gm-Message-State: AOJu0YwQDozKlS0b8Ul4p/16QklyU+nCp1b4RShOFQTD3ZNMC4AxAT54 tA8q9ZXM4To9ekTgfRBMCzwuUXmRCGikA3v8rCfGzI47m5MD/82YgmwbQsdMAQRfhjA/WVMEKa9 LbTvHkFmesUOorgNprOWi5wuI7pLNcXiX7ysptr7CfH1xD77XteLJQNQt3fZ4BfLpOIw6piyke8 EIcLzobstK5pCgDh6qyZdvjcQ2Hcqzdg== X-Received: by 2002:adf:e84f:0:b0:37d:4956:b0c2 with SMTP id ffacd0b85a97d-3806122f97emr23131446f8f.58.1730754463982; Mon, 04 Nov 2024 13:07:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IHo0EeQBfWx0HoVLiVSOHZMoydRGICAHX+9E9mzd4tPJCajEwJMtYYqFdptKkUMDdamaW3m/A== X-Received: by 2002:adf:e84f:0:b0:37d:4956:b0c2 with SMTP id ffacd0b85a97d-3806122f97emr23131427f8f.58.1730754463475; Mon, 04 Nov 2024 13:07:43 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10b7bf7sm14347574f8f.9.2024.11.04.13.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:42 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:39 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Suravee Suthikulpanit , Alejandro Jimenez , Santosh Shukla , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 32/65] amd_iommu: Check APIC ID > 255 for XTSup Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Suravee Suthikulpanit The XTSup mode enables x2APIC support for AMD IOMMU, which is needed to support vcpu w/ APIC ID > 255. Reviewed-by: Alejandro Jimenez Signed-off-by: Suravee Suthikulpanit Signed-off-by: Santosh Shukla Message-Id: <20240927172913.121477-6-santosh.shukla@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 38297376e7..13af7211e1 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -32,6 +32,7 @@ #include "trace.h" #include "hw/i386/apic-msidef.h" #include "hw/qdev-properties.h" +#include "kvm/kvm_i386.h" /* used AMD-Vi MMIO registers */ const char *amdvi_mmio_low[] = { @@ -1651,6 +1652,16 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->mr_sys, AMDVI_INT_ADDR_FIRST, &s->mr_ir, 1); + /* AMD IOMMU with x2APIC mode requires xtsup=on */ + if (x86ms->apic_id_limit > 255 && !s->xtsup) { + error_report("AMD IOMMU with x2APIC confguration requires xtsup=on"); + exit(EXIT_FAILURE); + } + if (s->xtsup && kvm_irqchip_is_split() && !kvm_enable_x2apic()) { + error_report("AMD IOMMU xtsup=on requires support on the KVM side"); + exit(EXIT_FAILURE); + } + pci_setup_iommu(bus, &amdvi_iommu_ops, s); amdvi_init(s); } From patchwork Mon Nov 4 21:07:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A52E7D1BDF2 for ; Mon, 4 Nov 2024 21:11:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84J5-00033N-T0; Mon, 04 Nov 2024 16:08:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Im-0002hA-LW for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ik-0005Qe-JD for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754473; 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=SEbzwh5CXMMgSRIskBWVC858+AHstI7QTR6oOdrnG3c=; b=TEUPNb0fX8tD0BBRLmRE9b/2s3LCLjukuY8txZCisbm93dYX1XHcae4fDkrO0OdzKAKM+1 GXnPvSDPk01mQHudnx38rr7N9g9bOl4aSwtPQ8qyfuHtZoSEr//WzFJ6fQQxcGzmxx9gDt Nu/m27+Cb4ZJj3SbjfIkUX5VsaqoO04= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-eS6HA3PGPlO41o5ByrGXZw-1; Mon, 04 Nov 2024 16:07:51 -0500 X-MC-Unique: eS6HA3PGPlO41o5ByrGXZw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43152cd2843so27537085e9.3 for ; Mon, 04 Nov 2024 13:07:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754470; x=1731359270; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SEbzwh5CXMMgSRIskBWVC858+AHstI7QTR6oOdrnG3c=; b=ZWTbzUNVSZrOCUAJFmNaozGOi3vkqlgtnMlT6HyeUTmazh8msWIM/pU+khPW8lk5Sp oBn8Mn5ENvDI5X5a6fVmXrEio3HsE1Qcy0h7IwrliSiLz9FypWGiWT6X5N1LD6opM9Kn t2wTfflrQiYxmqGaWKGRi8TbCs/dAlI+eA94n42lshXv3WjrZz98j5sT2UxbJE89Kcdq Z9GFsPRl1Xdf8jXboKPPZI51ShOGqf6dOQVV27R/uUOMz+3ZpmPTT3ldgVUoCwEsqBNH /N6daGDUutmdg+VMPqk8GcSMsn0L8jDMfzWHaUhMVN2eGGEG8Eg3WG0jZvwFJK133HRB UfUA== X-Gm-Message-State: AOJu0YzPUazBbV77S737GD7eKWCEKu97IiR+cUw3+J5arMigMPTjS2CA rNaEWnSPRE0RfutfV5J0gqZHuh3ZE40lpWPXDFfXSw/puotu5sQPBi35ukV2WPYAqjLCXjYKIQB o2iLDJGw5ZM9nBq4aybEtxMQY4NycPydBLC63WYolz7gAT1UngDckXSks4llg5n/3kFsAKkJTaq UvRqxoPsCyFP88zkBtnf2rEBEEzvJBzQ== X-Received: by 2002:a05:600c:1c94:b0:431:59b2:f0d1 with SMTP id 5b1f17b1804b1-431bb976dd4mr184005015e9.4.1730754469919; Mon, 04 Nov 2024 13:07:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVb1FEqhrNf0kR3HAjQ/CCgEH/mDlp2ntwv3Bm06ATDPZvsq2zPcCMpuTU7MvM8yx22m9bqQ== X-Received: by 2002:a05:600c:1c94:b0:431:59b2:f0d1 with SMTP id 5b1f17b1804b1-431bb976dd4mr184004725e9.4.1730754469429; Mon, 04 Nov 2024 13:07:49 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd947c0esm202542105e9.24.2024.11.04.13.07.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:47 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gao Shiyuan , Zuo Boqun , Wang Liang , Daniel P =?utf-8?b?LiBCZXJyYW5nw6k=?= , Marcel Apfelbaum , Alexander Bulekov , Paolo Bonzini , Bandan Das , Stefan Hajnoczi , Fabiano Rosas , Darren Kenny , Qiuhao Li , Laurent Vivier Subject: [PULL 33/65] virtio-pci: fix memory_region_find for VirtIOPCIRegion's MR Message-ID: <55fa4be6f76a3e1b1caa33a8f0ab4dc217d32e49.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Gao Shiyuan As shown below, if a virtio PCI device is attached under a pci-bridge, the MR of VirtIOPCIRegion does not belong to any address space. So memory_region_find cannot be used to search for this MR. Introduce the virtio-pci and pci_bridge address spaces to solve this problem. Before: memory-region: pci_bridge_pci 0000000000000000-ffffffffffffffff (prio 0, i/o): pci_bridge_pci 00000000fe840000-00000000fe840fff (prio 1, i/o): virtio-net-pci-msix 00000000fe840000-00000000fe84003f (prio 0, i/o): msix-table 00000000fe840800-00000000fe840807 (prio 0, i/o): msix-pba 0000380000000000-0000380000003fff (prio 1, i/o): virtio-pci 0000380000000000-0000380000000fff (prio 0, i/o): virtio-pci-common-virtio-net 0000380000001000-0000380000001fff (prio 0, i/o): virtio-pci-isr-virtio-net 0000380000002000-0000380000002fff (prio 0, i/o): virtio-pci-device-virtio-net 0000380000003000-0000380000003fff (prio 0, i/o): virtio-pci-notify-virtio-net After: address-space: virtio-pci-cfg-mem-as 0000380000000000-0000380000003fff (prio 1, i/o): virtio-pci 0000380000000000-0000380000000fff (prio 0, i/o): virtio-pci-common-virtio-net 0000380000001000-0000380000001fff (prio 0, i/o): virtio-pci-isr-virtio-net 0000380000002000-0000380000002fff (prio 0, i/o): virtio-pci-device-virtio-net 0000380000003000-0000380000003fff (prio 0, i/o): virtio-pci-notify-virtio-net address-space: pci_bridge_pci_mem 0000000000000000-ffffffffffffffff (prio 0, i/o): pci_bridge_pci 00000000fe840000-00000000fe840fff (prio 1, i/o): virtio-net-pci-msix 00000000fe840000-00000000fe84003f (prio 0, i/o): msix-table 00000000fe840800-00000000fe840807 (prio 0, i/o): msix-pba 0000380000000000-0000380000003fff (prio 1, i/o): virtio-pci 0000380000000000-0000380000000fff (prio 0, i/o): virtio-pci-common-virtio-net 0000380000001000-0000380000001fff (prio 0, i/o): virtio-pci-isr-virtio-net 0000380000002000-0000380000002fff (prio 0, i/o): virtio-pci-device-virtio-net 0000380000003000-0000380000003fff (prio 0, i/o): virtio-pci-notify-virtio-net Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2576 Fixes: ffa8a3e3b2e6 ("virtio-pci: Add lookup subregion of VirtIOPCIRegion MR") Co-developed-by: Zuo Boqun Signed-off-by: Zuo Boqun Co-developed-by: Wang Liang Signed-off-by: Wang Liang Signed-off-by: Gao Shiyuan Message-Id: <20241030131324.34144-1-gaoshiyuan@baidu.com> Tested-by: Daniel P. Berrangé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_bridge.h | 2 ++ include/hw/virtio/virtio-pci.h | 3 +++ hw/pci/pci_bridge.c | 5 ++++ hw/virtio/virtio-pci.c | 10 +++++++ tests/qtest/fuzz-virtio-balloon-test.c | 37 ++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 6 files changed, 58 insertions(+) create mode 100644 tests/qtest/fuzz-virtio-balloon-test.c diff --git a/include/hw/pci/pci_bridge.h b/include/hw/pci/pci_bridge.h index 5456e24883..b0f5204d80 100644 --- a/include/hw/pci/pci_bridge.h +++ b/include/hw/pci/pci_bridge.h @@ -72,6 +72,8 @@ struct PCIBridge { */ MemoryRegion address_space_mem; MemoryRegion address_space_io; + AddressSpace as_mem; + AddressSpace as_io; PCIBridgeWindows windows; diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 9e67ba38c7..971c5fabd4 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -147,6 +147,9 @@ struct VirtIOPCIProxy { }; MemoryRegion modern_bar; MemoryRegion io_bar; + /* address space for VirtIOPCIRegions */ + AddressSpace modern_cfg_mem_as; + AddressSpace modern_cfg_io_as; uint32_t legacy_io_bar_idx; uint32_t msix_bar_idx; uint32_t modern_io_bar_idx; diff --git a/hw/pci/pci_bridge.c b/hw/pci/pci_bridge.c index 6a4e38856d..2c7bb1a525 100644 --- a/hw/pci/pci_bridge.c +++ b/hw/pci/pci_bridge.c @@ -380,9 +380,12 @@ void pci_bridge_initfn(PCIDevice *dev, const char *typename) sec_bus->map_irq = br->map_irq ? br->map_irq : pci_swizzle_map_irq_fn; sec_bus->address_space_mem = &br->address_space_mem; memory_region_init(&br->address_space_mem, OBJECT(br), "pci_bridge_pci", UINT64_MAX); + address_space_init(&br->as_mem, &br->address_space_mem, + "pci_bridge_pci_mem"); sec_bus->address_space_io = &br->address_space_io; memory_region_init(&br->address_space_io, OBJECT(br), "pci_bridge_io", 4 * GiB); + address_space_init(&br->as_io, &br->address_space_io, "pci_bridge_pci_io"); pci_bridge_region_init(br); QLIST_INIT(&sec_bus->child); QLIST_INSERT_HEAD(&parent->child, sec_bus, sibling); @@ -399,6 +402,8 @@ void pci_bridge_exitfn(PCIDevice *pci_dev) PCIBridge *s = PCI_BRIDGE(pci_dev); assert(QLIST_EMPTY(&s->sec_bus.child)); QLIST_REMOVE(&s->sec_bus, sibling); + address_space_destroy(&s->as_mem); + address_space_destroy(&s->as_io); pci_bridge_region_del(s, &s->windows); pci_bridge_region_cleanup(s, &s->windows); /* object_unparent() is called automatically during device deletion */ diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index c5a809b956..5a394821da 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2057,6 +2057,8 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) if (modern_pio) { memory_region_init(&proxy->io_bar, OBJECT(proxy), "virtio-pci-io", 0x4); + address_space_init(&proxy->modern_cfg_io_as, &proxy->io_bar, + "virtio-pci-cfg-io-as"); pci_register_bar(&proxy->pci_dev, proxy->modern_io_bar_idx, PCI_BASE_ADDRESS_SPACE_IO, &proxy->io_bar); @@ -2180,6 +2182,9 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) /* PCI BAR regions must be powers of 2 */ pow2ceil(proxy->notify.offset + proxy->notify.size)); + address_space_init(&proxy->modern_cfg_mem_as, &proxy->modern_bar, + "virtio-pci-cfg-mem-as"); + if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) { proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; } @@ -2269,12 +2274,17 @@ static void virtio_pci_exit(PCIDevice *pci_dev) VirtIOPCIProxy *proxy = VIRTIO_PCI(pci_dev); bool pcie_port = pci_bus_is_express(pci_get_bus(pci_dev)) && !pci_bus_is_root(pci_get_bus(pci_dev)); + bool modern_pio = proxy->flags & VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY; msix_uninit_exclusive_bar(pci_dev); if (proxy->flags & VIRTIO_PCI_FLAG_AER && pcie_port && pci_is_express(pci_dev)) { pcie_aer_exit(pci_dev); } + address_space_destroy(&proxy->modern_cfg_mem_as); + if (modern_pio) { + address_space_destroy(&proxy->modern_cfg_io_as); + } } static void virtio_pci_reset(DeviceState *qdev) diff --git a/tests/qtest/fuzz-virtio-balloon-test.c b/tests/qtest/fuzz-virtio-balloon-test.c new file mode 100644 index 0000000000..ecb597fbee --- /dev/null +++ b/tests/qtest/fuzz-virtio-balloon-test.c @@ -0,0 +1,37 @@ +/* + * QTest fuzzer-generated testcase for virtio balloon device + * + * Copyright (c) 2024 Gao Shiyuan + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "libqtest.h" + +/* + * https://gitlab.com/qemu-project/qemu/-/issues/2576 + * Used to trigger: + * virtio_address_space_lookup: Assertion `mrs.mr' failed. + */ +static void oss_fuzz_71649(void) +{ + QTestState *s = qtest_init("-device virtio-balloon -machine q35" + " -nodefaults"); + + qtest_outl(s, 0xcf8, 0x80000890); + qtest_outl(s, 0xcfc, 0x2); + qtest_outl(s, 0xcf8, 0x80000891); + qtest_inl(s, 0xcfc); + qtest_quit(s); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + qtest_add_func("fuzz/virtio/oss_fuzz_71649", oss_fuzz_71649); + + return g_test_run(); +} + diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 9d51114539..924dc4be57 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -88,6 +88,7 @@ qtests_i386 = \ (config_all_devices.has_key('CONFIG_MEGASAS_SCSI_PCI') ? ['fuzz-megasas-test'] : []) + \ (config_all_devices.has_key('CONFIG_LSI_SCSI_PCI') ? ['fuzz-lsi53c895a-test'] : []) + \ (config_all_devices.has_key('CONFIG_VIRTIO_SCSI') ? ['fuzz-virtio-scsi-test'] : []) + \ + (config_all_devices.has_key('CONFIG_VIRTIO_BALLOON') ? ['fuzz-virtio-balloon-test'] : []) + \ (config_all_devices.has_key('CONFIG_Q35') ? ['q35-test'] : []) + \ (config_all_devices.has_key('CONFIG_SB16') ? ['fuzz-sb16-test'] : []) + \ (config_all_devices.has_key('CONFIG_SDHCI_PCI') ? ['fuzz-sdcard-test'] : []) + \ From patchwork Mon Nov 4 21:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7820D1BDF2 for ; Mon, 4 Nov 2024 21:09:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84J6-000347-1p; Mon, 04 Nov 2024 16:08:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ip-0002mP-Bh for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84In-0005R1-Ni for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:07:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754477; 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=eiDVC07ihD3E+eT5P1KT2iajuWbM2zWQGNYOe37hqBQ=; b=O60Jb03p3DkbKd6vr/e5yEhf6/6vX95OBksH5pwBU8rmjhSEkCGECWBGL4DPJgtagJzLkT bxl5fDHTBOApV2wp+JBoGeN7CEwtMr035lHcu+mKo/VUQtmH1s62RctNh/01GCzY5KWpVJ OGYzNFlYRUvHUTniWUF/QQdNxLG7TgY= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-vtt-YCSSM4-2qDPFFVq_ig-1; Mon, 04 Nov 2024 16:07:56 -0500 X-MC-Unique: vtt-YCSSM4-2qDPFFVq_ig-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315544642eso34449445e9.3 for ; Mon, 04 Nov 2024 13:07:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754474; x=1731359274; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=eiDVC07ihD3E+eT5P1KT2iajuWbM2zWQGNYOe37hqBQ=; b=Km8/vPRcW/u1XKNCgFrfKqmgbrUP0QQZWSojinE8dIs07kOWD6Q+lOoxHg0CRHUvrw AH8ygkAmC9bKVmuKbG7cL/X+WuGdn+Rh+QmWKCidm9eq772PlHFWw/+LBQZdrw7RcmDG UyKoqfVuMogZ2frWFE7TllQ1qSJWdsBa0RaKi+xy54Hj/6PkHRSSwKbB6BeQOonHM6kO P1BvadYi7TQLl8t5K8BdlGisvc1zMzTST4M/S6MZtIe6rbvmIRKTwO+ILE308mRVl7Sh 6AzpY0DHrCR8jRk/VfMn2JbBhp2ddlcPanOIaK53oXMiJ6wszI/4OUjklU/Bp/uUZROD niRg== X-Gm-Message-State: AOJu0YzxyOtfLi7EMAD5Wt7kowyjnq4GXBdCK8vlkBAXkv3aCkcpti3k uNWSiDjMKKFVTJDYW5lvToDS5VyyR0MQlNY7TQyB2TMmZs9uHKHlbuVQMAJHc6HoLmxT0NAfnx0 FXIZwkwdl+xzZC0iixc48oE8XA/DwCqf8Jf8qUhLBbGiPOJbcPfK7ZYScBYEVRpAIui5vJRcQ2n Dww8xrJ6xtqMZSRgVWda5Ys5VnBMyFzQ== X-Received: by 2002:a05:600c:1c26:b0:432:9fdb:1490 with SMTP id 5b1f17b1804b1-4329fdb1571mr19515005e9.7.1730754474376; Mon, 04 Nov 2024 13:07:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGg4zXy6CILSRzJGN51NdBd/XWyGadrcWz8GUqq7CELFdyOB6K4PU34S00rLv5jleFJwPP8ag== X-Received: by 2002:a05:600c:1c26:b0:432:9fdb:1490 with SMTP id 5b1f17b1804b1-4329fdb1571mr19514745e9.7.1730754473854; Mon, 04 Nov 2024 13:07:53 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9207d4sm191968705e9.20.2024.11.04.13.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:52 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , yaozhenguo , yaozhenguo , Stefano Garzarella Subject: [PULL 34/65] virtio/vhost-user: fix qemu abort when hotunplug vhost-user-net device Message-ID: <963b02764537c66af88b82bd297c375b147e0756.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: yaozhenguo During the hot-unplugging of vhost-user-net type network cards, the vhost_user_cleanup function may add the same rcu node to the rcu linked list. The function call in this case is as follows: vhost_user_cleanup ->vhost_user_host_notifier_remove ->call_rcu(n, vhost_user_host_notifier_free, rcu); ->g_free_rcu(n, rcu); When this happens, QEMU will abort in try_dequeue: if (head == &dummy && qatomic_mb_read(&tail) == &dummy.next) { abort(); } backtrace is as follows: 0 __pthread_kill_implementation () at /usr/lib64/libc.so.6 1 raise () at /usr/lib64/libc.so.6 2 abort () at /usr/lib64/libc.so.6 3 try_dequeue () at ../util/rcu.c:235 4 call_rcu_thread (0) at ../util/rcu.c:288 5 qemu_thread_start (0) at ../util/qemu-thread-posix.c:541 6 start_thread () at /usr/lib64/libc.so.6 7 clone3 () at /usr/lib64/libc.so.6 The reason for the abort is that adding two identical nodes to the rcu linked list will cause the rcu linked list to become a ring, but when the dummy node is added after the two identical nodes, the ring is opened. But only one node is added to list with rcu_call_count added twice. This will cause rcu try_dequeue abort. This happens when n->addr != 0. In some scenarios, this does happen. For example, this situation will occur when using a 32-queue DPU vhost-user-net type network card for hot-unplug testing, because VhostUserHostNotifier->addr will be cleared during the processing of VHOST_USER_BACKEND_VRING_HOST_NOTIFIER_MSG. However,it is asynchronous, so we cannot guarantee that VhostUserHostNotifier->addr is zero in vhost_user_cleanup. Therefore, it is necessary to merge g_free_rcu and vhost_user_host_notifier_free into one rcu node. Fixes: 503e355465 ("virtio/vhost-user: dynamically assign VhostUserHostNotifiers") Signed-off-by: yaozhenguo Message-Id: <20241011102913.45582-1-yaozhenguo@jd.com> Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 1 + hw/virtio/vhost-user.c | 46 +++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index 324cd8663a..9a3f238b43 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -54,6 +54,7 @@ typedef struct VhostUserHostNotifier { void *addr; void *unmap_addr; int idx; + bool destroy; } VhostUserHostNotifier; /** diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 00561daa06..d1b0893b4d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1185,9 +1185,16 @@ static int vhost_user_set_vring_num(struct vhost_dev *dev, static void vhost_user_host_notifier_free(VhostUserHostNotifier *n) { - assert(n && n->unmap_addr); - munmap(n->unmap_addr, qemu_real_host_page_size()); - n->unmap_addr = NULL; + if (n->unmap_addr) { + munmap(n->unmap_addr, qemu_real_host_page_size()); + n->unmap_addr = NULL; + } + if (n->destroy) { + memory_region_transaction_begin(); + object_unparent(OBJECT(&n->mr)); + memory_region_transaction_commit(); + g_free(n); + } } /* @@ -1195,17 +1202,28 @@ static void vhost_user_host_notifier_free(VhostUserHostNotifier *n) * under rcu. */ static void vhost_user_host_notifier_remove(VhostUserHostNotifier *n, - VirtIODevice *vdev) + VirtIODevice *vdev, bool destroy) { + /* + * if destroy == false and n->addr == NULL, we have nothing to do. + * so, just return. + */ + if (!n || (!destroy && !n->addr)) { + return; + } + if (n->addr) { if (vdev) { + memory_region_transaction_begin(); virtio_queue_set_host_notifier_mr(vdev, n->idx, &n->mr, false); + memory_region_transaction_commit(); } assert(!n->unmap_addr); n->unmap_addr = n->addr; n->addr = NULL; - call_rcu(n, vhost_user_host_notifier_free, rcu); } + n->destroy = destroy; + call_rcu(n, vhost_user_host_notifier_free, rcu); } static int vhost_user_set_vring_base(struct vhost_dev *dev, @@ -1279,9 +1297,7 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev, struct vhost_user *u = dev->opaque; VhostUserHostNotifier *n = fetch_notifier(u->user, ring->index); - if (n) { - vhost_user_host_notifier_remove(n, dev->vdev); - } + vhost_user_host_notifier_remove(n, dev->vdev, false); ret = vhost_user_write(dev, &msg, NULL, 0); if (ret < 0) { @@ -1562,7 +1578,7 @@ static int vhost_user_backend_handle_vring_host_notifier(struct vhost_dev *dev, * new mapped address. */ n = fetch_or_create_notifier(user, queue_idx); - vhost_user_host_notifier_remove(n, vdev); + vhost_user_host_notifier_remove(n, vdev, false); if (area->u64 & VHOST_USER_VRING_NOFD_MASK) { return 0; @@ -2736,15 +2752,7 @@ static int vhost_user_set_inflight_fd(struct vhost_dev *dev, static void vhost_user_state_destroy(gpointer data) { VhostUserHostNotifier *n = (VhostUserHostNotifier *) data; - if (n) { - vhost_user_host_notifier_remove(n, NULL); - object_unparent(OBJECT(&n->mr)); - /* - * We can't free until vhost_user_host_notifier_remove has - * done it's thing so schedule the free with RCU. - */ - g_free_rcu(n, rcu); - } + vhost_user_host_notifier_remove(n, NULL, true); } bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp) @@ -2765,9 +2773,7 @@ void vhost_user_cleanup(VhostUserState *user) if (!user->chr) { return; } - memory_region_transaction_begin(); user->notifiers = (GPtrArray *) g_ptr_array_free(user->notifiers, true); - memory_region_transaction_commit(); user->chr = NULL; } From patchwork Mon Nov 4 21:07:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862098 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D6EBD1BDF3 for ; Mon, 4 Nov 2024 21:14:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JA-0003P8-5p; Mon, 04 Nov 2024 16:08:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Iv-0002uZ-Jn for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Iu-0005Rl-3W for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754483; 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=PWXbuaXLWsxhC+1PBbOQmp6i/5Hl2ASTF0Q1ZdpmUUk=; b=SmvK+zkPlqmquDV4mR0cOnFbuKsWDmynYwP841qiscd4XC0y8lsXOCMotywnfRoEM2B3mx 0qzdkyS7T79GYeg4wW4p67uOVKmAJr/1achDvKwhOfGceppL9m8hVCxw/QMFQNcut0nmvi Z5QC82K/fklDbnekvE/AsqehLHSDZu4= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-jtPZlLGSOnuHZM8vX2UfuA-1; Mon, 04 Nov 2024 16:08:02 -0500 X-MC-Unique: jtPZlLGSOnuHZM8vX2UfuA-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539eb3416cdso4957317e87.1 for ; Mon, 04 Nov 2024 13:07:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754478; x=1731359278; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PWXbuaXLWsxhC+1PBbOQmp6i/5Hl2ASTF0Q1ZdpmUUk=; b=aDg23AuzEUkK0cJOv+KJKl5iJah/S/NmNmAcr60rTa9p1zsahK/iF4Do5ScMe2Hd3c X3edD75U7yuDwRvuBpxyjTu62bGmIXLXxziGXSDJ7SLbnCIjFSDxrXHN1604LBnUgxTd bdsNUcfcXQusbDpTU2xbouuw3htx3z+zWWKkNFil6txtC90SSuEYYVB8KEA3734lYkKG BcV5ivcZgt1iwgFp6RPyr1FuSSqfWv6Yu1ByUe91Z96rTo50cbpmN+nBk7Tw5GbdPd3E pAvUIB65fO9wLNqic9Tk5xHE74lDKAUougGWWDnFcnGhHSE/lmJJFXv2FFkfOtsbdOA8 UEmw== X-Gm-Message-State: AOJu0YzEA7Gs/OrzN7YLB8MtsNzoPBBSIFUOSgO6mF3FtRE8/iSbKkFB heWfzrc7zI9VUWf2nLiN/+Uk7EtGIVljYRoDuXt2tEkD2EEFvdPHcsw4osiLNtdk1gg26PV7ReZ mv6Yupqencbdhpc1jLPSaVf1mQ75XhWF0p0z0Ik1kwKh+agGA+NHVqxRxcF5TLA/cphMz+l/x5d 3UrXQBoWPmsriijNudUJpnAV2OZyNWdw== X-Received: by 2002:a05:6512:1107:b0:539:f7ba:c982 with SMTP id 2adb3069b0e04-53b348ee5c3mr16096512e87.33.1730754477967; Mon, 04 Nov 2024 13:07:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY2/CcAbrmEEmarzllxlbzbd+M76HDi3y25SxQWP52VbzH04cyvDgvnGuCH9sLROeCBDEMtg== X-Received: by 2002:a05:6512:1107:b0:539:f7ba:c982 with SMTP id 2adb3069b0e04-53b348ee5c3mr16096491e87.33.1730754477400; Mon, 04 Nov 2024 13:07:57 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e74casm14101459f8f.65.2024.11.04.13.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:07:56 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Dmitry Frolov , Jonathan Cameron , Fan Ni Subject: [PULL 35/65] hw/cxl: Fix uint32 overflow cxl-mailbox-utils.c Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Dmitry Frolov The sum offset + length may overflow uint32. Since this sum is compared with uint64_t return value of get_lsa_size(), it makes sense to choose uint64_t type for offset and length. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 3ebe676a3463 ("hw/cxl/device: Implement get/set Label Storage Area (LSA)") Signed-off-by: Dmitry Frolov Link: https://lore.kernel.org/r/20240917080925.270597-2-frolov@swemel.ru Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 9258e48f95..9f794e4655 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1445,7 +1445,7 @@ static CXLRetCode cmd_ccls_get_lsa(const struct cxl_cmd *cmd, } QEMU_PACKED *get_lsa; CXLType3Dev *ct3d = CXL_TYPE3(cci->d); CXLType3Class *cvc = CXL_TYPE3_GET_CLASS(ct3d); - uint32_t offset, length; + uint64_t offset, length; get_lsa = (void *)payload_in; offset = get_lsa->offset; From patchwork Mon Nov 4 21:07:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 867D9D1BDF2 for ; Mon, 4 Nov 2024 21:11:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JJ-0004a2-0H; Mon, 04 Nov 2024 16:08:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ix-0002yS-Gi for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Iv-0005Rx-Pq for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754485; 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=37jtMIq9rcanrOImpOzg8HMHUHIFbVSYLgdcwzoI8+c=; b=gRTVRudplq4r01yyrON7sBNFkfoHK6aMA9SIFEvAmyIQUKGa0bUdIuhvkwPj45hQuZj9MH 3gGTKJEUFLdGiTQQxxAZQSqyJq1ObKJY+RGWrxpMNuF/hIEfrWkyOhGlSkzPliNpgbOsfo lOO+0sR3L30hlbt04W7pnF/8AsNlVLs= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-10-7y-9oOzGOJaysatCyG-fdQ-1; Mon, 04 Nov 2024 16:08:03 -0500 X-MC-Unique: 7y-9oOzGOJaysatCyG-fdQ-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539eb3416cdso4957393e87.1 for ; Mon, 04 Nov 2024 13:08:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754482; x=1731359282; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=37jtMIq9rcanrOImpOzg8HMHUHIFbVSYLgdcwzoI8+c=; b=njERyIYMbNBM2fNaIofYpeU0Lx46ONTDL5WjSPggW820KfjjIBojxbYtp9SQDKRsLl WUlridL1+8jI57zSoqd1CM1o6W8DEOlaXTb844rrMpQ7mlon+9YGzIwxQh5Uzji9ty48 IiISuVGjF1BACJFTEl4BpoTZAt9dye/TIzmV6Mzm2HbGRFEkjvdsLTk9o5mCNipfvFvF StIYp0Lfl1PncBXLgAs6PmGCJtobAkSy37AnGFOZ8sz0AVU4S5LBluykDVZ7dPVC+JZR SEDqnBtUVLmacX56r00NBZBWYQfzP1Ix63dL3tSrHpm81Z1lJCG/Dph2ne6ki2NNgND6 vs2w== X-Gm-Message-State: AOJu0Yx7/yTsG+aUwjuxU16O7+JQ+GoJSObxkQ2kFYxiacqKfj5GrMVW YaNJJTdDC7haf1pk0demafovc9hDwN4i10MjkxwN6DI9jE1uSUkp4xgchIH+OSqqSPaD+ov35W8 ob4/4EluCvUMzktOGAIPrDlI0Pem3MRZdj+R2t3pMLEHHbCvC1h4mxFLM481eJg2EbQ/Y+RE7pU NYQ5gLWAF0ks5hDDpWybzTSWJ98Ik4cQ== X-Received: by 2002:a05:6512:318c:b0:53b:1f14:e11a with SMTP id 2adb3069b0e04-53b348d0d32mr16962586e87.15.1730754481925; Mon, 04 Nov 2024 13:08:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFll0SJdlhEH4BTrqg/ABdbN18+A/2NbktGTlZ/PmzeOpvhX3RhoWcDsy8iNsIIys5CS+NshQ== X-Received: by 2002:a05:6512:318c:b0:53b:1f14:e11a with SMTP id 2adb3069b0e04-53b348d0d32mr16962567e87.15.1730754481361; Mon, 04 Nov 2024 13:08:01 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5abfefsm164801235e9.4.2024.11.04.13.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:00 -0800 (PST) Date: Mon, 4 Nov 2024 16:07:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ajay Joshi , Ajay Joshi , Davidlohr Bueso , Jonathan Cameron , Fan Ni Subject: [PULL 36/65] hw/cxl: Fix background completion percentage calculation Message-ID: <8352756ffa72668773d6904bc76dfc0bf2619e5a.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ajay Joshi The current completion percentage calculation does not account for the relative time since the start of the background activity, this leads to showing incorrect start percentage vs what has actually been completed. This patch calculates the percentage based on the actual elapsed time since the start of the operation. Fixes: 221d2cfbdb53 ("hw/cxl/mbox: Add support for background operations") Signed-off-by: Ajay Joshi Reviewed-by: Davidlohr Bueso Link: https://lore.kernel.org/r/20240729102338.22337-1-ajay.opensrc@micron.com Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 9f794e4655..3a93966e77 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -2879,7 +2879,8 @@ static void bg_timercb(void *opaque) } } else { /* estimate only */ - cci->bg.complete_pct = 100 * now / total_time; + cci->bg.complete_pct = + 100 * (now - cci->bg.starttime) / cci->bg.runtime; timer_mod(cci->bg.timer, now + CXL_MBOX_BG_UPDATE_FREQ); } From patchwork Mon Nov 4 21:08:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 707B7D1BDF4 for ; Mon, 4 Nov 2024 21:14:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JA-0003OM-67; Mon, 04 Nov 2024 16:08:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84J1-00032z-Kz for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84J0-0005SF-59 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754489; 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=2nT3RwUShqklMf6vVLxi4TD1IukIVKoXxtFA87gOIq4=; b=KOfZmtot3STsyQfOvkU3lBuHRFHVdBKOr3G/fMnfcu7Uri9KexiRY9/6cOgUspAfbiHRg8 xkxLN32WUG7wVQ+TxoRdBs9p9VY43OHWBS6BEf/sXaCVSr2wjqqIQKmOMVDLo84ZgCu6K/ MIV5LzNuHxy5H/0Udy/5EOvDAUCXaz8= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-h_XsvyQuOvKattbkcjWi_A-1; Mon, 04 Nov 2024 16:08:07 -0500 X-MC-Unique: h_XsvyQuOvKattbkcjWi_A-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-539e5f9df25so2788947e87.0 for ; Mon, 04 Nov 2024 13:08:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754485; x=1731359285; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2nT3RwUShqklMf6vVLxi4TD1IukIVKoXxtFA87gOIq4=; b=WayC5HSGtBFBLw3IBp7uQHmW/PDlUDRKlBwCgUDMSnVCd1OZ0NhTDKEWRMtPAH8wdg lZwEYRBfSS4K4xA3ySOBCG0Y/6VPJLOr4SGI3daznlJbLzBORkOs+6VFg+GnOt0OHXY9 2rCdR9Bsh0rb1dQjNX4wG72313N5ZnFsI6B0Y+L5Bk2m/aVUkOxId6M9cfHEDes8aZ1P EVaSXhzr4vWJYavAMkDbMskj2m17aBFxplgw0IiVa+KqZqRg4E7TptKB63UM0a2QaLiA RHuDLrSk8qk5BEbaqG84apQ1bn9kDXzlKG3JPUOZQ1WpPVAKBo+7/osLbfTDMX82uJqd 5jpg== X-Gm-Message-State: AOJu0YyVbDnLvvkxnw55/UqMm/x+8fupE2RbyjmrAFrNBuE5I9USNHqM vBLyeke12arKo7XK4IcBItaaH1JkmDI+PqUmy/aPuxufCQmqT80owypnFjkC3btYzew3Ywfo4JR l7uS/d2QANXtFEFFlY+hC+8l6/27k32OpbxeQLvvRy5upwj4KUmc4uIERq7E7XGSfEojUYxo09B JSMzJoMRQmpLQnD9eTVzhpc3Rjq/6QVg== X-Received: by 2002:a05:6512:3b0f:b0:539:fc42:e5ee with SMTP id 2adb3069b0e04-53b348e3390mr16101841e87.29.1730754485491; Mon, 04 Nov 2024 13:08:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEilcxosWM0mlnAh0+AD78EJERO2PbJL0ASfxlRCYYw92bt1r6Wnj6zVx5798PeU6VPMDzLfQ== X-Received: by 2002:a05:6512:3b0f:b0:539:fc42:e5ee with SMTP id 2adb3069b0e04-53b348e3390mr16101823e87.29.1730754485002; Mon, 04 Nov 2024 13:08:05 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10b7b65sm14428401f8f.4.2024.11.04.13.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:04 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Yao Xingtao , Jonathan Cameron , Fan Ni Subject: [PULL 37/65] mem/cxl_type3: Fix overlapping region validation error Message-ID: <5eabca7ec0a92032c7dd5188f1708344c225a385.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Yao Xingtao When injecting a new poisoned region through qmp_cxl_inject_poison(), the newly injected region should not overlap with existing poisoned regions. The current validation method does not consider the following overlapping region: ┌───┬───────┬───┐ │a │ b(a) │a │ └───┴───────┴───┘ (a is a newly added region, b is an existing region, and b is a subregion of a) Fixes: 9547754f40ee ("hw/cxl: QMP based poison injection support") Signed-off-by: Yao Xingtao Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 44d491d8f6..16c60b9b0d 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1381,9 +1381,7 @@ void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, ct3d = CXL_TYPE3(obj); QLIST_FOREACH(p, &ct3d->poison_list, node) { - if (((start >= p->start) && (start < p->start + p->length)) || - ((start + length > p->start) && - (start + length <= p->start + p->length))) { + if ((start < p->start + p->length) && (start + length > p->start)) { error_setg(errp, "Overlap with existing poisoned region not supported"); return; From patchwork Mon Nov 4 21:08:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862096 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A7C2D1BDF3 for ; Mon, 4 Nov 2024 21:14:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JA-0003Se-BO; Mon, 04 Nov 2024 16:08:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84J4-00034h-Bc for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84J2-0005SR-Sd for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754491; 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=LphtSZRM9Hmq0/3hV/+VD4mIq6AHbSOEG0NTeD+XVjw=; b=Ag9LrUE/guM/U5RaK5ROVL6j+zSXIq+jjZTj0TjAAs8d+mDgEjVrHD9owaVqKYoZgfdCKp eu8Le+UHc+N2P2jnY1iRA5auj1oto/pJW9Ybzf+xk1tnOLg4IkNJwbW1Pnr3Z4bNjZQYh/ uqWiZxBsAT/F7n/Xadbxnjx/z9dIvxg= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-341-mJaWzp0qNsmanZB452TOvg-1; Mon, 04 Nov 2024 16:08:10 -0500 X-MC-Unique: mJaWzp0qNsmanZB452TOvg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43157cff1d1so34460275e9.2 for ; Mon, 04 Nov 2024 13:08:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754489; x=1731359289; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LphtSZRM9Hmq0/3hV/+VD4mIq6AHbSOEG0NTeD+XVjw=; b=Q1G+FR6wl+kY7WIWJNnwTvowD7hXEp3sE+Mckp/up9eKVItawv1vMltKN08SlQr+SP Gqb6kdKKfeNWXFRnOJkI/o3aFw/8pBDr85U3zj47bY4T8uym8hbQW7ZHQVHN72cqfqxr HbtJtlsjf+aeLib5p3S9720mLK+P+xigEIbJ/ojORD5Fff9LaYxXF+J9eNbvtsLrcYQV glPBz1s5a+k/ZVVehDTEk+w/xdEYzbunzVXJhUEt30zUUE4FubJddBzujz/OPQP/veKa SHVaonUVjZ4nzp2BsJw8HinU0tZlXMamzyZlQS6QLGWJdw89PuKY3j2JeIWe9ULklSWr D1SQ== X-Gm-Message-State: AOJu0Yz+1U0JSwM9YVtgV/rNYMUSSYgbr0LcQVNW7WlFOcaUUGxKuiIs UEjYoPPayBdoiW/KVLYr3B7XCAY5jGj85RYBRaC9gTWgSxe5J8L/88ji4dIRcyIV8RYutaJcMe/ luxDxPpa8SQh+PDbp9iW9yEBpItZMvSmEGZp38GQw7HH0JdY2+skEmRlV0qvNET8hWFArnLfCWm PmgaV2FLTM9m6Chk7VPKlxPRjqsRui4w== X-Received: by 2002:a5d:5988:0:b0:37d:30e7:3865 with SMTP id ffacd0b85a97d-381be7d63e0mr13752497f8f.34.1730754489001; Mon, 04 Nov 2024 13:08:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHse1DTdtj6DQWEZkiG7Juxs1RZjnkGxjXTOl9gxl2FH1oBeQKwEbrS3o8Qe1YD7Wly7WnjLA== X-Received: by 2002:a5d:5988:0:b0:37d:30e7:3865 with SMTP id ffacd0b85a97d-381be7d63e0mr13752459f8f.34.1730754488530; Mon, 04 Nov 2024 13:08:08 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10d42adsm14083391f8f.40.2024.11.04.13.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:07 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Jonathan Cameron Subject: [PULL 38/65] hw/mem/cxl_type3: Fix More flag setting for dynamic capacity event records Message-ID: <80ee960f8d646505385bce8ed143a9bb8ea36d1d.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Per cxl spec r3.1, for multiple dynamic capacity event records grouped via the More flag, the last record in the sequence should clear the More flag. Before the change, the More flag of the event record is cleared before the loop of inserting records into the event log, which will leave the flag always set once it is set in the loop. Fixes: d0b9b28a5b9f ("hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents") Signed-off-by: Fan Ni Link: https://lore.kernel.org/r/20240827164304.88876-2-nifan.cxl@gmail.com Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 16c60b9b0d..6911d13fe6 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -2064,11 +2064,11 @@ static void qmp_cxl_process_dynamic_capacity_prescriptive(const char *path, stw_le_p(&dCap.host_id, hid); /* only valid for DC_REGION_CONFIG_UPDATED event */ dCap.updated_region_id = 0; - dCap.flags = 0; for (i = 0; i < num_extents; i++) { memcpy(&dCap.dynamic_capacity_extent, &extents[i], sizeof(CXLDCExtentRaw)); + dCap.flags = 0; if (i < num_extents - 1) { /* Set "More" flag */ dCap.flags |= BIT(0); From patchwork Mon Nov 4 21:08:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0703CD1BDF2 for ; Mon, 4 Nov 2024 21:11:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JD-0003kR-3y; Mon, 04 Nov 2024 16:08:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84J8-0003LT-58 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84J6-0005Sd-9t for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754495; 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=5hR+ACnXBxInDGsaK6RI1lemH57wgeYS/tmIS32BvoE=; b=NBjAOaVvHtVnkCxaAOKFIb8uGMexaoa9RLp4iw3exHjMhh4kKrqFLdVDw6UmdW4WKAhvVR TQFwTTo/xXamHjSV+NzzhgavTgkAmYMOaqkfhEG8Pio0EGkB2uexdyZ7JnYd/2Wht1tqyu Ok+8jFDEIsWR/AVPjsNThGdHRKRbUWg= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-149-llUoWFuFOLeemTAOw89cUw-1; Mon, 04 Nov 2024 16:08:14 -0500 X-MC-Unique: llUoWFuFOLeemTAOw89cUw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4315c1b5befso29856085e9.1 for ; Mon, 04 Nov 2024 13:08:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754493; x=1731359293; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5hR+ACnXBxInDGsaK6RI1lemH57wgeYS/tmIS32BvoE=; b=gX1p8GbZETSx2gGL5omFvAr/fOH8bi6rSFM1uWBc3Xc3ZstqzMG/MR2HqknE18Hj+6 x5nERf5BoN8zH6gYoJ4ddTUqIRD++Clghn2tG4cQF8i7xeoq1GnaaxkC+jalrwkPzT+R 5wsXo7gdUwaS7+afIwbJfnfsua9OeO2pudsv4VpZNoeJirk7Po8bl0mVCEuoHjefXazc a/6IH/RE7oNcIRSwY7lnKBJDc14naFRwUqZK7U8InX/pdsvWrRe4W5h49d+B1XLxu2IP AnGT85tUAnP0ZTti+GWINNMWf/N18ZSN43/NUC+QWUAM80FW7Vm9lQtXzH+YFAkDn8Hq 9GFQ== X-Gm-Message-State: AOJu0Yz4upiqLHxGZO+kU5qbFXCRW9WZoW7/dPgKKTuSsfVah0r0Nykj d+Anlr5vD8Xn653vL85T+c3iw265wT64a8KHmxOOnMDLlc44l/8bprefZsDMPjHO5P3GzgdcQIw 8vFJx9gTHkHEv1wVIhiX+H5pwKEsedluWuvHQFNMYRLffxnr4SKkArigERTg9qK8aMwQsbzX5rr hDvp1IjwAUN6kTVyTnw2K+Tva/K8s3lg== X-Received: by 2002:a5d:4b02:0:b0:37c:d183:a8f8 with SMTP id ffacd0b85a97d-3806113cfedmr25094721f8f.19.1730754492707; Mon, 04 Nov 2024 13:08:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IENF2S8LFp7vg+zKgY7podnNTHV8WgZiOkwvinKde2tNFfcP88gm6xhwxNY41b/Clfr7fRPNQ== X-Received: by 2002:a5d:4b02:0:b0:37c:d183:a8f8 with SMTP id ffacd0b85a97d-3806113cfedmr25094700f8f.19.1730754492187; Mon, 04 Nov 2024 13:08:12 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e565csm14118677f8f.48.2024.11.04.13.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:11 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Shiju Jose , Jonathan Cameron , Fan Ni Subject: [PULL 39/65] hw/cxl/cxl-mailbox-utils: Fix for device DDR5 ECS control feature tables Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Shiju Jose CXL spec 3.1 section 8.2.9.9.11.2 describes the DDR5 Error Check Scrub (ECS) control feature. ECS log capabilities field in following ECS tables, which is common for all memory media FRUs in a CXL device. Fix struct CXLMemECSReadAttrs and struct CXLMemECSWriteAttrs to make log entry type field common. Fixes: 2d41ce38fb9a ("hw/cxl/cxl-mailbox-utils: Add device DDR5 ECS control feature") Signed-off-by: Shiju Jose Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 36 ++++++++++++++++++++++-------------- hw/cxl/cxl-mailbox-utils.c | 24 +++++++++--------------- hw/mem/cxl_type3.c | 9 ++++----- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index e14e56ae4b..561b375dc8 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -463,18 +463,6 @@ typedef struct CXLMemPatrolScrubWriteAttrs { #define CXL_MEMDEV_PS_ENABLE_DEFAULT 0 /* CXL memory device DDR5 ECS control attributes */ -typedef struct CXLMemECSReadAttrs { - uint8_t ecs_log_cap; - uint8_t ecs_cap; - uint16_t ecs_config; - uint8_t ecs_flags; -} QEMU_PACKED CXLMemECSReadAttrs; - -typedef struct CXLMemECSWriteAttrs { - uint8_t ecs_log_cap; - uint16_t ecs_config; -} QEMU_PACKED CXLMemECSWriteAttrs; - #define CXL_ECS_GET_FEATURE_VERSION 0x01 #define CXL_ECS_SET_FEATURE_VERSION 0x01 #define CXL_ECS_LOG_ENTRY_TYPE_DEFAULT 0x01 @@ -483,6 +471,26 @@ typedef struct CXLMemECSWriteAttrs { #define CXL_ECS_MODE_DEFAULT 0 #define CXL_ECS_NUM_MEDIA_FRUS 3 /* Default */ +typedef struct CXLMemECSFRUReadAttrs { + uint8_t ecs_cap; + uint16_t ecs_config; + uint8_t ecs_flags; +} QEMU_PACKED CXLMemECSFRUReadAttrs; + +typedef struct CXLMemECSReadAttrs { + uint8_t ecs_log_cap; + CXLMemECSFRUReadAttrs fru_attrs[CXL_ECS_NUM_MEDIA_FRUS]; +} QEMU_PACKED CXLMemECSReadAttrs; + +typedef struct CXLMemECSFRUWriteAttrs { + uint16_t ecs_config; +} QEMU_PACKED CXLMemECSFRUWriteAttrs; + +typedef struct CXLMemECSWriteAttrs { + uint8_t ecs_log_cap; + CXLMemECSFRUWriteAttrs fru_attrs[CXL_ECS_NUM_MEDIA_FRUS]; +} QEMU_PACKED CXLMemECSWriteAttrs; + #define DCD_MAX_NUM_REGION 8 typedef struct CXLDCExtentRaw { @@ -575,8 +583,8 @@ struct CXLType3Dev { CXLMemPatrolScrubReadAttrs patrol_scrub_attrs; CXLMemPatrolScrubWriteAttrs patrol_scrub_wr_attrs; /* ECS control attributes */ - CXLMemECSReadAttrs ecs_attrs[CXL_ECS_NUM_MEDIA_FRUS]; - CXLMemECSWriteAttrs ecs_wr_attrs[CXL_ECS_NUM_MEDIA_FRUS]; + CXLMemECSReadAttrs ecs_attrs; + CXLMemECSWriteAttrs ecs_wr_attrs; struct dynamic_capacity { HostMemoryBackend *host_dc; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 3a93966e77..67041f45d3 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1133,10 +1133,8 @@ static CXLRetCode cmd_features_get_supported(const struct cxl_cmd *cmd, (struct CXLSupportedFeatureEntry) { .uuid = ecs_uuid, .feat_index = index, - .get_feat_size = CXL_ECS_NUM_MEDIA_FRUS * - sizeof(CXLMemECSReadAttrs), - .set_feat_size = CXL_ECS_NUM_MEDIA_FRUS * - sizeof(CXLMemECSWriteAttrs), + .get_feat_size = sizeof(CXLMemECSReadAttrs), + .set_feat_size = sizeof(CXLMemECSWriteAttrs), .attr_flags = CXL_FEAT_ENTRY_ATTR_FLAG_CHANGABLE, .get_feat_version = CXL_ECS_GET_FEATURE_VERSION, .set_feat_version = CXL_ECS_SET_FEATURE_VERSION, @@ -1204,13 +1202,10 @@ static CXLRetCode cmd_features_get_feature(const struct cxl_cmd *cmd, (uint8_t *)&ct3d->patrol_scrub_attrs + get_feature->offset, bytes_to_copy); } else if (qemu_uuid_is_equal(&get_feature->uuid, &ecs_uuid)) { - if (get_feature->offset >= CXL_ECS_NUM_MEDIA_FRUS * - sizeof(CXLMemECSReadAttrs)) { + if (get_feature->offset >= sizeof(CXLMemECSReadAttrs)) { return CXL_MBOX_INVALID_INPUT; } - bytes_to_copy = CXL_ECS_NUM_MEDIA_FRUS * - sizeof(CXLMemECSReadAttrs) - - get_feature->offset; + bytes_to_copy = sizeof(CXLMemECSReadAttrs) - get_feature->offset; bytes_to_copy = MIN(bytes_to_copy, get_feature->count); memcpy(payload_out, (uint8_t *)&ct3d->ecs_attrs + get_feature->offset, @@ -1299,18 +1294,17 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, ecs_set_feature = (void *)payload_in; ecs_write_attrs = ecs_set_feature->feat_data; - memcpy((uint8_t *)ct3d->ecs_wr_attrs + hdr->offset, + memcpy((uint8_t *)&ct3d->ecs_wr_attrs + hdr->offset, ecs_write_attrs, bytes_to_copy); set_feat_info->data_size += bytes_to_copy; if (data_transfer_flag == CXL_SET_FEATURE_FLAG_FULL_DATA_TRANSFER || data_transfer_flag == CXL_SET_FEATURE_FLAG_FINISH_DATA_TRANSFER) { + ct3d->ecs_attrs.ecs_log_cap = ct3d->ecs_wr_attrs.ecs_log_cap; for (count = 0; count < CXL_ECS_NUM_MEDIA_FRUS; count++) { - ct3d->ecs_attrs[count].ecs_log_cap = - ct3d->ecs_wr_attrs[count].ecs_log_cap; - ct3d->ecs_attrs[count].ecs_config = - ct3d->ecs_wr_attrs[count].ecs_config & 0x1F; + ct3d->ecs_attrs.fru_attrs[count].ecs_config = + ct3d->ecs_wr_attrs.fru_attrs[count].ecs_config & 0x1F; } } } else { @@ -1324,7 +1318,7 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, if (qemu_uuid_is_equal(&hdr->uuid, &patrol_scrub_uuid)) { memset(&ct3d->patrol_scrub_wr_attrs, 0, set_feat_info->data_size); } else if (qemu_uuid_is_equal(&hdr->uuid, &ecs_uuid)) { - memset(ct3d->ecs_wr_attrs, 0, set_feat_info->data_size); + memset(&ct3d->ecs_wr_attrs, 0, set_feat_info->data_size); } set_feat_info->data_transfer_flag = 0; set_feat_info->data_saved_across_reset = false; diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 6911d13fe6..5cf754b38f 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -920,16 +920,15 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp) ct3d->patrol_scrub_attrs.scrub_flags = CXL_MEMDEV_PS_ENABLE_DEFAULT; /* Set default value for DDR5 ECS read attributes */ + ct3d->ecs_attrs.ecs_log_cap = CXL_ECS_LOG_ENTRY_TYPE_DEFAULT; for (count = 0; count < CXL_ECS_NUM_MEDIA_FRUS; count++) { - ct3d->ecs_attrs[count].ecs_log_cap = - CXL_ECS_LOG_ENTRY_TYPE_DEFAULT; - ct3d->ecs_attrs[count].ecs_cap = + ct3d->ecs_attrs.fru_attrs[count].ecs_cap = CXL_ECS_REALTIME_REPORT_CAP_DEFAULT; - ct3d->ecs_attrs[count].ecs_config = + ct3d->ecs_attrs.fru_attrs[count].ecs_config = CXL_ECS_THRESHOLD_COUNT_DEFAULT | (CXL_ECS_MODE_DEFAULT << 3); /* Reserved */ - ct3d->ecs_attrs[count].ecs_flags = 0; + ct3d->ecs_attrs.fru_attrs[count].ecs_flags = 0; } return; From patchwork Mon Nov 4 21:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AAF47D1BDF3 for ; Mon, 4 Nov 2024 21:10:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JG-0004AO-BT; Mon, 04 Nov 2024 16:08:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JC-0003jb-6W for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JA-0005Sw-Pa for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754499; 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=Sfl9wFyrkXhR/mQ1NQ7urae0AqeUeu0VLGkrRpWPy4w=; b=KL8M37+KcLsoZJ3VXk4/R4/VOlm8XHJpW3EDUeAIHToXeL2tS8M4YX+exYaXpr0jLa6rQn Tv4TbhFdGPGNzC8WhIpjDNafiJmMlKm79XZQoLyhFWTwn+xOPWiKK3TwkIkG4FPXg4vNH5 3kcSi0yOkZqUbuCLQ9x9HCfzRRPCxHE= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-pUabv_JqOrW1Ao_Q48EHjA-1; Mon, 04 Nov 2024 16:08:18 -0500 X-MC-Unique: pUabv_JqOrW1Ao_Q48EHjA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4316e2dde9eso39454175e9.2 for ; Mon, 04 Nov 2024 13:08:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754497; x=1731359297; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Sfl9wFyrkXhR/mQ1NQ7urae0AqeUeu0VLGkrRpWPy4w=; b=j0Gl8D4trGJ2NIFDa2LfwBPcfKnMDL3BM+z0Aj3U4JL44y2S1xH59sLGHcOFAF59kG F4Aiid2q9Kap/nTNfqz4Q+sGnsUHCsD0B4CqQydCU8PjzM5teYjqIzQ0K/VQycvV8FsU 2TfaK0LpHWNts45cqb5KclR97LoiQN989LomCPDVbc5aLUoG2/VfadTQxpPodapMQlLe orAqyni9Ecd+V/uC84NaoZN2LKxQjYI1b2x4LP9LPMi9GRtdb3vxNnTSxz2cWhDFHK/Y AWqKM7QlhqzYfryNVro3dU868RLQ93ue7p2l4Hnh3Wft1MUxb948628HNCH8TCkTnDNo NvRA== X-Gm-Message-State: AOJu0YxYFrzxQgoW4nmymNT5fpZm9UHucA0bhXt8auKmIyaVAq8Vlgxe BJdWW9FCwAehpYGlmZ6qbl/yDFGpe2zSYFVcyhVEBuJV6FKHND1GZsG6nRlfpbSTSHALdZYOItn UyKczGP9UDuJZ79MNuwuIeCJFq/Q8Prof1ahBHG4gUigG2ExVYFOgAeiH4TuRIRALgq50AnGPqz ks1e95VNdKBmul9P+wgsrxgzVZ5Yp/pQ== X-Received: by 2002:a05:600c:5486:b0:431:52cc:877a with SMTP id 5b1f17b1804b1-43283296066mr146670695e9.34.1730754497187; Mon, 04 Nov 2024 13:08:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8JUTVrQ0zQfu3t+4t97vpqnT9wnXm+/ReoeLAiI7H3SYXYwubqUC/J8qHDCVzLlwZtPzX8Q== X-Received: by 2002:a05:600c:5486:b0:431:52cc:877a with SMTP id 5b1f17b1804b1-43283296066mr146670535e9.34.1730754496823; Mon, 04 Nov 2024 13:08:16 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d698055sm165490415e9.40.2024.11.04.13.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:16 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Davidlohr Bueso , Fan Ni Subject: [PULL 40/65] hw/cxl: Fix indent of structure member Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Add missing 4 spaces of indent to structure element. Reported-by: Davidlohr Bueso Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-7-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 67041f45d3..5f63099724 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -374,7 +374,7 @@ static CXLRetCode cmd_infostat_identify(const struct cxl_cmd *cmd, uint16_t pcie_subsys_vid; uint16_t pcie_subsys_id; uint64_t sn; - uint8_t max_message_size; + uint8_t max_message_size; uint8_t component_type; } QEMU_PACKED *is_identify; QEMU_BUILD_BUG_ON(sizeof(*is_identify) != 18); From patchwork Mon Nov 4 21:08:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D3DFD1BDF4 for ; Mon, 4 Nov 2024 21:13:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JK-0004oE-PJ; Mon, 04 Nov 2024 16:08:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JH-0004LF-B1 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JF-0005T8-Pa for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754504; 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=UlP335cOFsUkS+Xl7GKV9Lv2XyhG9kOzxJJ+GSB6He4=; b=MhSfhKPf+bXF2+lvwC2ksMQuISy01C84Ddk80AM53s6o/g+xQH73AE+LjyfoTAMZLBg0w6 ZfDAUN58iNCN2R4lhq/lIRK64qrams0se02JfY4Zch9UrbqQ5HXLXaftY4rKuX4fKrzi3j 5UvVwoQKa3GrseVIPyEuGNBQ/JslIgY= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473-M0viPKqhMaaPsRSHurSqXw-1; Mon, 04 Nov 2024 16:08:23 -0500 X-MC-Unique: M0viPKqhMaaPsRSHurSqXw-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2fb652f40f1so26110281fa.2 for ; Mon, 04 Nov 2024 13:08:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754501; x=1731359301; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UlP335cOFsUkS+Xl7GKV9Lv2XyhG9kOzxJJ+GSB6He4=; b=YBgYXpzDKwdmsbMOfP/UoOTnKgDCDQ/0k0u0fCrUT3IsfU51ITo7eNsY2l7kI0nHQz /toazF2gfdELT9p2Ctj0W+lh78Y2ScBkjeyKFKkQYUmaT/GIAhV7SmvbksY0r0Yp8nqB MpEwfkjHkNLsQi0D78jaB6jErdgRNsTQ9EBkzkFtEdzuZVvedpz6ICse8O1u1BrGWQOv Shr2yYyLzVbwXcw1AK3c9TcLFsDerpfRswbhyBzQtW7cUjZ9ANYwYoGarOn6JdiitPYG RkPCCtGpEVYlru5EkhhwD8gXu8o2gqrwKOWLhsbS3MSvX1fdvRtXd4T3LJMOJ6s7t5ci h8ng== X-Gm-Message-State: AOJu0YxI+33qV9qCb4YgdGx0h91Rmq7F/3JMNVN1ggZLVLc2kkzP6s2O rR68hwMsiM2v5bWrSSeJqhEQlo0mUtp+6Yz6d07R0+VrxuMoz15A1RqlEjT5sbjT5R6uflZU0eh GJxFWDKxtaOhNLmRIjYhU5bD3h1nJG+N38pwWDlp+HTegd814HsadC002LTMoX40rDQs9p3L5Tg BXT9zLAlBeuJNTKPS0cMcsmRWQoCqohA== X-Received: by 2002:a05:651c:1988:b0:2fb:65c8:b4ae with SMTP id 38308e7fff4ca-2fedb7d910amr67853531fa.31.1730754501278; Mon, 04 Nov 2024 13:08:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IGmX02BxqSQUkkXcp0eRiwbXtUzuEzLornlj3NSMZHKeONTL8MThiGZsqpsPiVT+DfddNVpvw== X-Received: by 2002:a05:651c:1988:b0:2fb:65c8:b4ae with SMTP id 38308e7fff4ca-2fedb7d910amr67853271fa.31.1730754500725; Mon, 04 Nov 2024 13:08:20 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e687sm14225464f8f.84.2024.11.04.13.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:20 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 41/65] hw/pci-bridge: Make pxb_dev_realize_common() return if it succeeded Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron For the CXL PXB there is additional code after pxb_dev_realize_common() is called. If that realize failed (e.g. due to an out of range numa_node) we will get a segfault. Return a bool so the caller can check if the pxb_dev_realize_common() succeeded or not without having to poke around in the errp. Fixes: 4f8db8711cbd ("hw/pxb: Allow creation of a CXL PXB (host bridge)") Signed-off-by: Jonathan Cameron Message-Id: <20241014121902.2146424-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/pci_expander_bridge.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expander_bridge.c index 4578e03024..07d411cff5 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -330,7 +330,7 @@ static gint pxb_compare(gconstpointer a, gconstpointer b) 0; } -static void pxb_dev_realize_common(PCIDevice *dev, enum BusType type, +static bool pxb_dev_realize_common(PCIDevice *dev, enum BusType type, Error **errp) { PXBDev *pxb = PXB_DEV(dev); @@ -342,13 +342,13 @@ static void pxb_dev_realize_common(PCIDevice *dev, enum BusType type, if (ms->numa_state == NULL) { error_setg(errp, "NUMA is not supported by this machine-type"); - return; + return false; } if (pxb->numa_node != NUMA_NODE_UNASSIGNED && pxb->numa_node >= ms->numa_state->num_nodes) { error_setg(errp, "Illegal numa node %d", pxb->numa_node); - return; + return false; } if (dev->qdev.id && *dev->qdev.id) { @@ -394,12 +394,13 @@ static void pxb_dev_realize_common(PCIDevice *dev, enum BusType type, pci_config_set_class(dev->config, PCI_CLASS_BRIDGE_HOST); pxb_dev_list = g_list_insert_sorted(pxb_dev_list, pxb, pxb_compare); - return; + return true; err_register_bus: object_unref(OBJECT(bds)); object_unparent(OBJECT(bus)); object_unref(OBJECT(ds)); + return false; } static void pxb_dev_realize(PCIDevice *dev, Error **errp) @@ -500,7 +501,9 @@ static void pxb_cxl_dev_realize(PCIDevice *dev, Error **errp) return; } - pxb_dev_realize_common(dev, CXL, errp); + if (!pxb_dev_realize_common(dev, CXL, errp)) { + return; + } pxb_cxl_dev_reset(DEVICE(dev)); } From patchwork Mon Nov 4 21:08:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E2C2D1BDF3 for ; Mon, 4 Nov 2024 21:09:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JM-00059i-9a; Mon, 04 Nov 2024 16:08:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JK-0004wh-IN for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JI-0005TI-NE for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754507; 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=DreMzE5l8O9RuGS8oEwWkZEzopXOO7MX3eO79wqdwag=; b=aqLwKdNxosxZZGaeday49iLfAcLtOTSylZ6IeL4+RlsZg2K6xfScbCDeVKWU20Jp++CpQp +BjUpcIkBzo6/zLEULcFu8mexUKgLmhxBSmFxlxb5JkB7H0NLn8pc6gn37o3awkB8KowBK P94H3czbcDndSZbpKg0waDBS0RZstjY= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-1VtKnJMnPhyHCIex6-exig-1; Mon, 04 Nov 2024 16:08:26 -0500 X-MC-Unique: 1VtKnJMnPhyHCIex6-exig-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-43157cff1d1so34461725e9.2 for ; Mon, 04 Nov 2024 13:08:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754505; x=1731359305; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DreMzE5l8O9RuGS8oEwWkZEzopXOO7MX3eO79wqdwag=; b=pfE81RWkgGdoVQElWwtLhpNssSI+MORpcw2oVCXfwCghlHsxllbj6+LsnF/ePyunMN 3XcN+ykkhMrj55w4mv7AbdKqHbHRca2l/kgQA8l5Dwf6BvVszHhw32zEiIP+z1PbCxHj nBUIG/v56A/Cb0zMWBIPu/Azk1N6jbK/IJPcQBlV3bSkb/IllnW2pXUhW4vxv1By6nNJ rBkjdbqpXguOFf7zbLqmcvPBxMBMp1owfr7wmnbcZpmq4sYFlwghwbXYAUpNHqIHTCjn PuYltrGomR6x0reMV+bRTAgX/vPGOW5DlAqBe6AUp4tDyP/gphyNbAMpexvB9/0LJ9MM JPTg== X-Gm-Message-State: AOJu0YySjxUUdDf6eqJwsci8WfRc0W3EYoK1yIJxNQdDEs6CldNl+iro zZMPW0BfQ+TWTzRzocltEbb6GpIkSXLiKLQePHEP1Gg8lZCV8O7LV2/Zcxr/FYbJJPMpPFSIUng GsFSYZ+rBJSD4xeaPVRep1DaA3X+RIe8X4EwHlNhLQhGz//JLZHoB48eRee6T2lUOfqmEB2R/pi 4cLUO/YyUvSKG9Uik5IZ+6xGJL5GlgsA== X-Received: by 2002:a05:600c:a41:b0:431:5021:32 with SMTP id 5b1f17b1804b1-4327b6f9564mr136272385e9.6.1730754505028; Mon, 04 Nov 2024 13:08:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5BfoHcABNNuxPmbIEF3HHjRET8q5SOeMgJ7vx6hop8SHt4ixfDa7XVntgZxKzdv2OPjulPQ== X-Received: by 2002:a05:600c:a41:b0:431:5021:32 with SMTP id 5b1f17b1804b1-4327b6f9564mr136272205e9.6.1730754504579; Mon, 04 Nov 2024 13:08:24 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432a26f51d4sm1020455e9.1.2024.11.04.13.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:23 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Albert Esteve , Stefano Garzarella Subject: [PULL 42/65] vhost-user: fix shared object return values Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Albert Esteve VHOST_USER_BACKEND_SHARED_OBJECT_ADD and VHOST_USER_BACKEND_SHARED_OBJECT_REMOVE state in the spec that they return 0 for successful operations, non-zero otherwise. However, implementation relies on the return types of the virtio-dmabuf library, with opposite semantics (true if everything is correct, false otherwise). Therefore, current implementation violates the specification. Revert the logic so that the implementation of the vhost-user handling methods matches the specification. Fixes: 043e127a126bb3ceb5fc753deee27d261fd0c5ce Fixes: 160947666276c5b7f6bca4d746bcac2966635d79 Reviewed-by: Stefano Garzarella Signed-off-by: Albert Esteve Message-Id: <20241022124615.585596-1-aesteve@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index d1b0893b4d..f170f0b25b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1623,9 +1623,14 @@ vhost_user_backend_handle_shared_object_add(struct vhost_dev *dev, QemuUUID uuid; memcpy(uuid.data, object->uuid, sizeof(object->uuid)); - return virtio_add_vhost_device(&uuid, dev); + return !virtio_add_vhost_device(&uuid, dev); } +/* + * Handle VHOST_USER_BACKEND_SHARED_OBJECT_REMOVE backend requests. + * + * Return: 0 on success, 1 on error. + */ static int vhost_user_backend_handle_shared_object_remove(struct vhost_dev *dev, VhostUserShared *object) @@ -1639,16 +1644,16 @@ vhost_user_backend_handle_shared_object_remove(struct vhost_dev *dev, struct vhost_dev *owner = virtio_lookup_vhost_device(&uuid); if (dev != owner) { /* Not allowed to remove non-owned entries */ - return 0; + return 1; } break; } default: /* Not allowed to remove non-owned entries */ - return 0; + return 1; } - return virtio_remove_resource(&uuid); + return !virtio_remove_resource(&uuid); } static bool vhost_user_send_resp(QIOChannel *ioc, VhostUserHeader *hdr, From patchwork Mon Nov 4 21:24:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3FA8CD1BDF2 for ; Mon, 4 Nov 2024 21:24:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Ym-0007n6-0m; Mon, 04 Nov 2024 16:24:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Yk-0007mj-Ox for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:24:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Yj-0006uo-4I for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:24:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730755464; 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=Jn4WUkhWFsTn3Zafq3qOV5CM6ns6biTKh9xhZYCuQz4=; b=i05mk24TJQCSI0N6BdCQWM1WNJkWmhoOpjhkuJ+Vtd4EAsWBPeYx0JPR9laZ5754INqvqh bWjTlULnIiJ9rkgZpJlSeXhM/3MaQ1XJJEz8/WfP+4ljmJQnbVXLTqaYM5YJWPaKEojIpo C/CgkuRppzlDAYs1x/yxTPZPjzAtT2w= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-dDGCEKz5Nnqk4Z_q3_Stqg-1; Mon, 04 Nov 2024 16:24:23 -0500 X-MC-Unique: dDGCEKz5Nnqk4Z_q3_Stqg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4315544642eso34533135e9.3 for ; Mon, 04 Nov 2024 13:24:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730755461; x=1731360261; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Jn4WUkhWFsTn3Zafq3qOV5CM6ns6biTKh9xhZYCuQz4=; b=Akt6nKecfS/q8jsEw1pk+JZ62oBlU7/5/se1JwEKoP4GFIRb93NJ7/iwWDqMTVJXCP ZPBSoDwdVoUadXsuqQhouccsipR37gbSgrG8dIwZ/SLATfB66XZy21DIoC4lNGkPjg67 M5/1jMDCdXhI444eQnhbLXpubUQnyN5b8Ly8FFxw2OMYa+R7clAFz7ArvqdQ6SgJoVBi VFDJkekrNnZ+5cuU8NqEeATJqH3Iyh07UzjBnjXu9RtVTI7qWKIdpFUJXfRKD0IO+eTK 5gzxm05u4Qk0quAzRVN8e6uUjE6DOi0ghz3BNXdQp7yif6vGcLOcAhAVblXfRkQwk8Nt G5ZA== X-Gm-Message-State: AOJu0YxBwSB6zr2S5LmDr0osODGYPBiK9de+d3zMozqicGnbnFoZQ1Nj G7nDKc8oZwZmYqpACy4R/xDTfnq7fr5TtK5FtyaaC76wpLOAJQ9tH7Ats0GRa2jmPSzyJknrdID GMWYb4tXGndr1nlMJ+sY41LvMPWPw6cRr9TXq5RLEEeAvOLwazqkqUpbWbPJMC+n7n2o1KiWXrt Fn16QH6NMwFalI7CKZdCPgBByV1E9rew== X-Received: by 2002:a5d:6da9:0:b0:37d:5035:451 with SMTP id ffacd0b85a97d-381be7ad026mr15004845f8f.10.1730755461409; Mon, 04 Nov 2024 13:24:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbGHe3QCslXUSewGBjhPHi7RP/RCi4LBKvKPnk5ppUjtXtGFtd/s65EVVYH6GMUJIkmUAffw== X-Received: by 2002:a5d:6da9:0:b0:37d:5035:451 with SMTP id ffacd0b85a97d-381be7ad026mr15004825f8f.10.1730755460938; Mon, 04 Nov 2024 13:24:20 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd947a9fsm199069825e9.22.2024.11.04.13.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:24:20 -0800 (PST) Date: Mon, 4 Nov 2024 16:24:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Yi Liu , Jason Wang , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 43/65] intel_iommu: Introduce property "stale-tm" to control Transient Mapping (TM) field Message-ID: <6ce12bd29777d41afef859652eaa62b5c964d3f7.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhenzhong Duan VT-d spec removed Transient Mapping (TM) field from second-level page-tables and treat the field as Reserved(0) since revision 3.2. Changing the field as reserved(0) will break backward compatibility, so introduce a property "stale-tm" to allow user to control the setting. Use pc_compat_9_1 to handle the compatibility for machines before 9.2 which allow guest to set the field. Starting from 9.2, this field is reserved(0) by default to match spec. Of course, user can force it on command line. This doesn't impact function of vIOMMU as there was no logic to emulate Transient Mapping. Suggested-by: Yi Liu Suggested-by: Jason Wang Signed-off-by: Zhenzhong Duan Acked-by: Jason Wang Reviewed-by: Yi Liu Message-Id: <20241028022514.806657-1-zhenzhong.duan@intel.com> Reviewed-by: Clément Mathieu--Drif Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 12 ++++++------ include/hw/i386/intel_iommu.h | 3 +++ hw/i386/intel_iommu.c | 7 ++++--- hw/i386/pc.c | 1 + 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 13d5d129ae..2f9bc0147d 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -412,8 +412,8 @@ typedef union VTDInvDesc VTDInvDesc; /* Rsvd field masks for spte */ #define VTD_SPTE_SNP 0x800ULL -#define VTD_SPTE_PAGE_L1_RSVD_MASK(aw, dt_supported) \ - dt_supported ? \ +#define VTD_SPTE_PAGE_L1_RSVD_MASK(aw, stale_tm) \ + stale_tm ? \ (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM | VTD_SL_TM)) : \ (0x800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) #define VTD_SPTE_PAGE_L2_RSVD_MASK(aw) \ @@ -423,12 +423,12 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_SPTE_PAGE_L4_RSVD_MASK(aw) \ (0x880ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) -#define VTD_SPTE_LPAGE_L2_RSVD_MASK(aw, dt_supported) \ - dt_supported ? \ +#define VTD_SPTE_LPAGE_L2_RSVD_MASK(aw, stale_tm) \ + stale_tm ? \ (0x1ff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM | VTD_SL_TM)) : \ (0x1ff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) -#define VTD_SPTE_LPAGE_L3_RSVD_MASK(aw, dt_supported) \ - dt_supported ? \ +#define VTD_SPTE_LPAGE_L3_RSVD_MASK(aw, stale_tm) \ + stale_tm ? \ (0x3ffff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM | VTD_SL_TM)) : \ (0x3ffff800ULL | ~(VTD_HAW_MASK(aw) | VTD_SL_IGN_COM)) diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index 1eb05c29fc..d372cd396b 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -306,6 +306,9 @@ struct IntelIOMMUState { bool dma_translation; /* Whether DMA translation supported */ bool pasid; /* Whether to support PASID */ + /* Transient Mapping, Reserved(0) since VTD spec revision 3.2 */ + bool stale_tm; + /* * Protects IOMMU states in general. Currently it protects the * per-IOMMU IOTLB cache, and context entry cache in VTDAddressSpace. diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 08fe218935..8612d0917b 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3372,6 +3372,7 @@ static Property vtd_properties[] = { DEFINE_PROP_BOOL("x-pasid-mode", IntelIOMMUState, pasid, false), DEFINE_PROP_BOOL("dma-drain", IntelIOMMUState, dma_drain, true), DEFINE_PROP_BOOL("dma-translation", IntelIOMMUState, dma_translation, true), + DEFINE_PROP_BOOL("stale-tm", IntelIOMMUState, stale_tm, false), DEFINE_PROP_END_OF_LIST(), }; @@ -4138,15 +4139,15 @@ static void vtd_init(IntelIOMMUState *s) */ vtd_spte_rsvd[0] = ~0ULL; vtd_spte_rsvd[1] = VTD_SPTE_PAGE_L1_RSVD_MASK(s->aw_bits, - x86_iommu->dt_supported); + x86_iommu->dt_supported && s->stale_tm); vtd_spte_rsvd[2] = VTD_SPTE_PAGE_L2_RSVD_MASK(s->aw_bits); vtd_spte_rsvd[3] = VTD_SPTE_PAGE_L3_RSVD_MASK(s->aw_bits); vtd_spte_rsvd[4] = VTD_SPTE_PAGE_L4_RSVD_MASK(s->aw_bits); vtd_spte_rsvd_large[2] = VTD_SPTE_LPAGE_L2_RSVD_MASK(s->aw_bits, - x86_iommu->dt_supported); + x86_iommu->dt_supported && s->stale_tm); vtd_spte_rsvd_large[3] = VTD_SPTE_LPAGE_L3_RSVD_MASK(s->aw_bits, - x86_iommu->dt_supported); + x86_iommu->dt_supported && s->stale_tm); if (s->scalable_mode || s->snoop_control) { vtd_spte_rsvd[1] &= ~VTD_SPTE_SNP; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2047633e4c..830614d930 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -82,6 +82,7 @@ GlobalProperty pc_compat_9_1[] = { { "ICH9-LPC", "x-smi-swsmi-timer", "off" }, { "ICH9-LPC", "x-smi-periodic-timer", "off" }, + { TYPE_INTEL_IOMMU_DEVICE, "stale-tm", "on" }, }; const size_t pc_compat_9_1_len = G_N_ELEMENTS(pc_compat_9_1); From patchwork Mon Nov 4 21:08:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 585D1D1BDF3 for ; Mon, 4 Nov 2024 21:12:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84JX-0006oD-FQ; Mon, 04 Nov 2024 16:08:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JU-0006Zj-K1 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JS-0005Tf-Ne for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754518; 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=mdw6lQ9M8p1WeqXba2/OeJnW0hlNdaOFpMUqZq3tSr4=; b=Z4/mvhqWRkBxt6vFZRWSotZBExrte40PtCdbLWDgURIZQ35EndJDBkw0ftO9qg1C5pHBFO 9EQr7qmjYyCDovPCobccNEerU/CXQpmsUQ87Kb7u+Cc//GjETascb41kJQzkFdukZc/l5f 1ZVs61KkFzzH3ha9JZHMN7zVLh9X+SY= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-iOe0z21GN5ao25qUdaoV4Q-1; Mon, 04 Nov 2024 16:08:35 -0500 X-MC-Unique: iOe0z21GN5ao25qUdaoV4Q-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-43159c07193so39601445e9.0 for ; Mon, 04 Nov 2024 13:08:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754514; x=1731359314; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mdw6lQ9M8p1WeqXba2/OeJnW0hlNdaOFpMUqZq3tSr4=; b=SMPzb5Is2W+qdWsPjq/WLUeWUL7rKZ/GXKMZIb7ZR/HLeOIk646UPzfcGNoBR4J1ZI OQRvuL8sculuLSTmG3jQeHoqsyiwHIrAePN3DuwOQQkff0nVK5c2JLxUyMb64NeHbwD+ YG2on2wilCtr4qIVv1DsS4Bmp/MoJC9jx/iFD4WKAlOPNQb5HqCclwLvTwJujTg5ecSq Qn5HVswMwnssW5CXiJWtTMN7Sh+adOfkn5if/l1wkXUgko+Cyrm+0QD6F1j60KvlgJVm fPu6JeSa4iF4SAu42ttR0LUaKDCtvqH++DSLOaD2l8DubI5iPnM7KYPVx2qOz5ieJXEY dCiw== X-Gm-Message-State: AOJu0Yz4wXf8MW8DuS40Fl92rYyCglcSZ+mvLjn5RWoZSGUvyRhiuBIZ hsXNkEkKnfxjE2LsrPtK3JkUE66SrH6SEIYBa/Md4RD2JbhPT1J3vECtazdN/we/Hmdlusgh+Jt JmRTiQrZZhRBgHKgxDyt1Nio7htU9d9IcGv7j6YHnOrdO6Fwu5kjxuWIiuzD11uAp2avBmGXwv9 KOBNT72LcgP5qB0ugYB03io3WPB/vaNg== X-Received: by 2002:a05:600c:198e:b0:42a:a6b8:f09f with SMTP id 5b1f17b1804b1-4328327cddamr140621405e9.23.1730754513684; Mon, 04 Nov 2024 13:08:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdwE17M97elbwB59Nb4RbWNc5mhpzKi0UFKHyTAEwlPrRXy4FW8eyN8xu8EGH5pGDH5+xQMQ== X-Received: by 2002:a05:600c:198e:b0:42a:a6b8:f09f with SMTP id 5b1f17b1804b1-4328327cddamr140621175e9.23.1730754513271; Mon, 04 Nov 2024 13:08:33 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10b7c13sm14339305f8f.13.2024.11.04.13.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:32 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Marcin Juszkiewicz , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu Subject: [PULL 44/65] pcie: enable Extended tag field support Message-ID: <449dca6ac93afbed1af00b6a29c9729f6cb18c35.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Marcin Juszkiewicz >From what I read PCI has 32 transactions, PCI Express devices can handle 256 with Extended tag enabled (spec mentions also larger values but I lack PCIe knowledge). QEMU leaves 'Extended tag field' with 0 as value: Capabilities: [e0] Express (v1) Root Complex Integrated Endpoint, IntMsgNum 0 DevCap: MaxPayload 128 bytes, PhantFunc 0 ExtTag- RBE+ FLReset- TEE-IO- SBSA ACS has test 824 which checks for PCIe device capabilities. BSA specification [1] (SBSA is on top of BSA) in section F.3.2 lists expected values for Device Capabilities Register: Device Capabilities Register Requirement Role based error reporting RCEC and RCiEP: Hardwired to 1 Endpoint L0s acceptable latency RCEC and RCiEP: Hardwired to 0 L1 acceptable latency RCEC and RCiEP: Hardwired to 0 Captured slot power limit scale RCEC and RCiEP: Hardwired to 0 Captured slot power limit value RCEC and RCiEP: Hardwired to 0 Max payload size value must be compliant with PCIe spec Phantom functions RCEC and RCiEP: Recommendation is to hardwire this bit to 0. Extended tag field Hardwired to 1 1. https://developer.arm.com/documentation/den0094/c/ This change enables Extended tag field. All versioned platforms should have it disabled for older versions (tested with Arm/virt). Signed-off-by: Marcin Juszkiewicz Message-Id: <20241023113820.486017-1-marcin.juszkiewicz@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 2 ++ hw/core/machine.c | 4 +++- hw/pci/pci.c | 2 ++ hw/pci/pcie.c | 8 +++++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 35d4fe0bbf..38ffa7bcee 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -214,6 +214,8 @@ enum { QEMU_PCIE_ERR_UNC_MASK = (1 << QEMU_PCIE_ERR_UNC_MASK_BITNR), #define QEMU_PCIE_ARI_NEXTFN_1_BITNR 12 QEMU_PCIE_ARI_NEXTFN_1 = (1 << QEMU_PCIE_ARI_NEXTFN_1_BITNR), +#define QEMU_PCIE_EXT_TAG_BITNR 13 + QEMU_PCIE_EXT_TAG = (1 << QEMU_PCIE_EXT_TAG_BITNR), }; typedef struct PCIINTxRoute { diff --git a/hw/core/machine.c b/hw/core/machine.c index adaba17eba..8ccc74067a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -34,7 +34,9 @@ #include "hw/virtio/virtio-iommu.h" #include "audio/audio.h" -GlobalProperty hw_compat_9_1[] = {}; +GlobalProperty hw_compat_9_1[] = { + { TYPE_PCI_DEVICE, "x-pcie-ext-tag", "false" }, +}; const size_t hw_compat_9_1_len = G_N_ELEMENTS(hw_compat_9_1); GlobalProperty hw_compat_9_0[] = { diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 0b6bdaa0d7..1416ae202c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -100,6 +100,8 @@ static Property pci_props[] = { QEMU_PCIE_ARI_NEXTFN_1_BITNR, false), DEFINE_PROP_SIZE32("x-max-bounce-buffer-size", PCIDevice, max_bounce_buffer_size, DEFAULT_MAX_BOUNCE_BUFFER_SIZE), + DEFINE_PROP_BIT("x-pcie-ext-tag", PCIDevice, cap_present, + QEMU_PCIE_EXT_TAG_BITNR, true), { .name = "busnr", .info = &prop_pci_busnr }, DEFINE_PROP_END_OF_LIST() }; diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 2738dbb28d..0b455c8654 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -86,7 +86,13 @@ pcie_cap_v1_fill(PCIDevice *dev, uint8_t port, uint8_t type, uint8_t version) * Specification, Revision 1.1., or subsequent PCI Express Base * Specification revisions. */ - pci_set_long(exp_cap + PCI_EXP_DEVCAP, PCI_EXP_DEVCAP_RBER); + uint32_t devcap = PCI_EXP_DEVCAP_RBER; + + if (dev->cap_present & QEMU_PCIE_EXT_TAG) { + devcap = PCI_EXP_DEVCAP_RBER | PCI_EXP_DEVCAP_EXT_TAG; + } + + pci_set_long(exp_cap + PCI_EXP_DEVCAP, devcap); pci_set_long(exp_cap + PCI_EXP_LNKCAP, (port << PCI_EXP_LNKCAP_PN_SHIFT) | From patchwork Mon Nov 4 21:08:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4C38ED1BDF3 for ; Mon, 4 Nov 2024 21:13:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Ja-00071b-C1; Mon, 04 Nov 2024 16:08:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JX-0006ri-MM for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JW-0005U0-8e for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754521; 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=2USYzZLIHQIzWKoyt995uWr9ICCZOVYtkrr3QOPenyA=; b=Udf5VWHp6RIhgLWosGU1K3cVtlU/wajSN1MCY2AXzts+n/zlBkqtdiYlk6ahJTOLJbFS+R m77731yWM5GYFGQLFnfkldhT8zO4tkdCTTe8ytDw6XEAPc7mRgnwkMmkWsFd3qLblIGfRy KPX9/ZD0mAAzEwO+sKSWS48Tjb2Qi/g= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-QCQiwaDDPV-CbojRqd2iYg-1; Mon, 04 Nov 2024 16:08:39 -0500 X-MC-Unique: QCQiwaDDPV-CbojRqd2iYg-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-539eb3416cdso4957842e87.1 for ; Mon, 04 Nov 2024 13:08:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754517; x=1731359317; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2USYzZLIHQIzWKoyt995uWr9ICCZOVYtkrr3QOPenyA=; b=PC1Sbt47/GkZZfCLFHbcGr2vy9Cv8G/l9cz0uc315JxmObSB0bDEB2pdZcEqthljFM 9aiz4nXb6Mg5xrbj9UTclArYDMreewl9PWQuU2r8uv+aCchPgc4vPFc1A0dc8URSML+/ 8B27IaEZQCtpVSVtaja0D1yRkdMWW4I06JslnrNW07d9u4H8PtjXHWRgn0D70IxauVLq tzG7Z+SHwWleMePgoZPikXyrJ3CNxu1TGchjsFLZ8qjz/IAgEwg5NlgFlhy2IVwe6ZOq 6ACe+d1AhwczxNlvZfopkvMSExd5wN0Nw1/9vcUI2lA/BqQNmOdReMjlCRHef5jzYTzH 55/g== X-Gm-Message-State: AOJu0Yz8Hbr+BNTcm8pcQVv24N0Re9fscExwUAp85oSu8gZ2J5WPYbc3 ijMErQMz859yyrSFVjo+N6YW5RzeX753UYSQIGiDv5ztNgtUFJSHdsgJTtB3Ahp3jfErPZ31LGE duasS/A1hZAXSmhv2aw8LqmMyeum+WpNfxn0nHqGHEyUQCrnUosk7l4cDxtVDncAlzClTkkrieY XeLGNJHIzFvrFA4f1swW+NTMf73FD+aQ== X-Received: by 2002:a05:6512:ac5:b0:539:fda6:fa0a with SMTP id 2adb3069b0e04-53b348c382bmr16259263e87.9.1730754517099; Mon, 04 Nov 2024 13:08:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ6ig/RTupJ5PVAb3ZQ4qG5p3//jKxQ/JhZYTkZ5CajGeMpi+3tsxQPgTzG1i4jRUCU/j+FA== X-Received: by 2002:a05:6512:ac5:b0:539:fda6:fa0a with SMTP id 2adb3069b0e04-53b348c382bmr16259243e87.9.1730754516584; Mon, 04 Nov 2024 13:08:36 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd8e7f33sm194173955e9.6.2024.11.04.13.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:35 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:33 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Davidlohr Bueso , Jonathan Cameron Subject: [PULL 45/65] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info Message-ID: <0564019bf1d9dd76ee7d212c26cf40e73eb3a00c.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni In the function cmd_firmware_update_get_info for handling Get FW info command (0x0200h), the vmem, pmem and DC capacity size check were incorrect. The size should be aligned to 256MiB, not smaller than 256MiB. Signed-off-by: Fan Ni Reviewed-by: Davidlohr Bueso Signed-off-by: Jonathan Cameron Message-Id: <20241101132005.26633-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 5f63099724..8bb0d2dd29 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -649,9 +649,9 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, } QEMU_PACKED *fw_info; QEMU_BUILD_BUG_ON(sizeof(*fw_info) != 0x50); - if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) || - (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) || - (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) { + if (!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER) || + !QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER) || + !QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER)) { return CXL_MBOX_INTERNAL_ERROR; } From patchwork Mon Nov 4 21:08:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 64232D1BDF2 for ; Mon, 4 Nov 2024 21:13:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Jc-0007Bd-OJ; Mon, 04 Nov 2024 16:08:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ja-00072t-HL for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84JZ-0005Uc-3i for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754524; 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=6ga8DS27Sfi7rjz6dDrgfoTT5hS6O0iJNoMqFy2shrM=; b=DsxF6axFSRqRzkBOg+gPQe32ZsNxOoh68zTs3MYsnE6xGR8IpsLdDO5pay7NeVZSRPH9lW 9O8j6zg6OaKejYiMPhGos/TCYJjQ7QMO5bjfYpaj2tB6O4D/WB4rOX7hDm2DLTrckcQYDV pojrHhzyq2WHht/cIpvWHIySamYrERk= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-202-YsywGLu4NKyM6y6xT5Pr5g-1; Mon, 04 Nov 2024 16:08:43 -0500 X-MC-Unique: YsywGLu4NKyM6y6xT5Pr5g-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-539eb3416cdso4957872e87.1 for ; Mon, 04 Nov 2024 13:08:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754521; x=1731359321; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6ga8DS27Sfi7rjz6dDrgfoTT5hS6O0iJNoMqFy2shrM=; b=msLZNbScKG7jU/wcU2rqJVQiXAF693Ljm8BYSIIv3xxFsYrM0rg8PBsze8M49z4hEH JAWeAUuDB9MKBy9z/lLu2A/fkpxubrlZ/J1oWI6X2pn4xFpPFaLda0HdpQEc4A2sAd5O kemb9dZ3SEUv4+EfHAgX/hYhWovqLV+zcKUoNYXtjEyJBCE1fKcNQbD84bJKcV0Hepnm I3vO+N4JArqyQvGkCjGupjX9LhqEmTp6s/OcbikFXGGq2hNIHH/JEjuWLAxS67u3CEtT GzEYuzP//jLAUQ7CZUnuvTzDuQfLRepykAhZv1+KRnpPbYR5FmdhAvkpGTWTPOpzISfR BNig== X-Gm-Message-State: AOJu0Yz2oxuUfF2Nxdz2PRaK98rJnLulriDbUp2OWYJkxgskq2bvCX9q uZqkG5t1rk1g2NCJFlUPq/vpY4NOqwPx1qC2QgEZMqcCnITWd3Zf+vtt54PbhzIGCD69PXJuxe2 g8bUYJpXos00q2m5e50RFqB8FiA4irNU68xToJPT7vHKbjje+1C+LfB/N9pYrvd+EXWgQfIAhy6 deTfS+8toUiJiJRpSyK4e/KG/rfVxDtw== X-Received: by 2002:a05:6512:128b:b0:539:e5e9:2159 with SMTP id 2adb3069b0e04-53b348e56eamr17436241e87.31.1730754520611; Mon, 04 Nov 2024 13:08:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFaPFMFEBs1G8FRUdZ8UdrkFfn+kD+IRU9PlCV4/st20rfyjFCmGEwrdwICNtzWTjpayV9JsA== X-Received: by 2002:a05:6512:128b:b0:539:e5e9:2159 with SMTP id 2adb3069b0e04-53b348e56eamr17436213e87.31.1730754520006; Mon, 04 Nov 2024 13:08:40 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e67csm14150069f8f.75.2024.11.04.13.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:39 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Jonathan Cameron Subject: [PULL 46/65] hw/cxl/cxl-mailbox-util: Fix output buffer index update when retrieving DC extents Message-ID: <802671c37a6ab4de116866883841bcc8b2318124.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni In the function of retrieving DC extents (cmd_dcd_get_dyn_cap_ext_list), the output buffer index was not correctly updated while iterating the extent list on the device, leaving the extents returned incorrect except for the first one. Fixes: 1c9221f19e62 ("hw/mem/cxl_type3: Add DC extent list representative and get DC extent list mailbox support") Signed-off-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20241101132005.26633-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 8bb0d2dd29..97cb8bbcec 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -2227,6 +2227,7 @@ static CXLRetCode cmd_dcd_get_dyn_cap_ext_list(const struct cxl_cmd *cmd, stw_le_p(&out_rec->shared_seq, ent->shared_seq); record_done++; + out_rec++; if (record_done == record_count) { break; } From patchwork Mon Nov 4 21:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 593B7D1BDF5 for ; Mon, 4 Nov 2024 21:13:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Jf-0007O6-VN; Mon, 04 Nov 2024 16:08:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jd-0007Gv-I6 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jc-0005V8-0f for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754527; 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=lxMZ/W8THThOjbgDug1/PH8QPzyLrkb73sNiH2Rol0U=; b=P/yx5yRsgXjrwD5LM/qU95UcaBAGaahiqTD8BNWvMOwp74TFOdH3ZHnOgxf9NDwjWgspCP 8V3afRcCB66GB0D+yWkOWqo+5KgK+u68OSdKdf3CbMvdsD9afYf/1T9ENqR8r0PdRWYfQs GBXhK2gCnL2bgkqRG+E81jYk86wbOi8= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-53adzAwKMjW0nH66SXTERw-1; Mon, 04 Nov 2024 16:08:46 -0500 X-MC-Unique: 53adzAwKMjW0nH66SXTERw-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-539e91e12bbso3000229e87.2 for ; Mon, 04 Nov 2024 13:08:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754524; x=1731359324; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lxMZ/W8THThOjbgDug1/PH8QPzyLrkb73sNiH2Rol0U=; b=U5VEW4RqRR5w0OXUmcTmEYEFjMahTe/VS5+NUrPRfpOlVkoyEe/uuyphrsPqJUUz9Y HOYqQ8OgwP7WGpaHWDS7IEyoqWnNvKOWia37VbCGaenAoIUv4ug7NupyDC5Ho0VL4pbG kcI1qkH0E/q6wuiHGwlLdVEkg9vYkLZTQI89U8Cwvhx1Bqc4hMk22b9Q2S5pVE40gX9i uHrgIEYShVfUf1bwqTr350nZ5uuP9lI/iVVcyotdUthIziLK9yJQXJnWYnwlX0ejJzlu 0hdz2B6gU/n6Gj7Kol/Zr78j3tGaQLEkMaMvujPgtP5P5tlh+Dd7wd6jzG2VdTLI0Pda d4xA== X-Gm-Message-State: AOJu0YyjU7wYfyBlC0woY9m/uZ2GkwMoYQTENE/wChwGofUmZoHF60DB 0E6cumiJP1SGzelfoblJks07uulJUF1i1GK6FZ/2heau1f/jDItTNBkhRRwVdl80oacXqXZtyxM TyGp+mYffP3AFOC+c4dGt8z08Z+d380iN5O7NWUnpMTKbPIbqAv5VCDclENuuGMPHZLI/nVYE6g tAksqpUCI7AoxlDLLQvvVwb0SCXZcWaw== X-Received: by 2002:ac2:5f87:0:b0:53d:6b50:f5f9 with SMTP id 2adb3069b0e04-53d6b50fc78mr2974438e87.38.1730754524361; Mon, 04 Nov 2024 13:08:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IFi+xKsxxOAGZXfM92I/OUJw6xP+bBRBhIgIzVkkTnvFy400Q6de84so7y8tldJqXaALuSJPg== X-Received: by 2002:ac2:5f87:0:b0:53d:6b50:f5f9 with SMTP id 2adb3069b0e04-53d6b50fc78mr2974423e87.38.1730754523820; Mon, 04 Nov 2024 13:08:43 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd8e9145sm193342945e9.1.2024.11.04.13.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:43 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 47/65] hw/cxl: Check size of input data to dynamic capacity mailbox commands Message-ID: <7edbbff5ee85dd28699c5acd6ea2f2c2e41c37d2.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron cxl_cmd_dcd_release_dyn_cap() and cmd_dcd_add_dyn_cap_rsp() are missing input message size checks. These must be done in the individual commands when the command has a variable length input payload. A buggy or malicious guest might send undersized messages via the mailbox. As that size is used to take a copy of the mailbox content, each command must check there is sufficient data. In this case the first check is that there is enough data to read how many extents there are, and the second that there is enough for those elements to be accessed. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 97cb8bbcec..17924410dd 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -2465,11 +2465,20 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd, uint64_t dpa, len; CXLRetCode ret; + if (len_in < sizeof(*in)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + if (in->num_entries_updated == 0) { cxl_extent_group_list_delete_front(&ct3d->dc.extents_pending); return CXL_MBOX_SUCCESS; } + if (len_in < + sizeof(*in) + sizeof(*in->updated_entries) * in->num_entries_updated) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + /* Adding extents causes exceeding device's extent tracking ability. */ if (in->num_entries_updated + ct3d->dc.total_extent_count > CXL_NUM_EXTENTS_SUPPORTED) { @@ -2624,10 +2633,19 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd, uint32_t updated_list_size; CXLRetCode ret; + if (len_in < sizeof(*in)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + if (in->num_entries_updated == 0) { return CXL_MBOX_INVALID_INPUT; } + if (len_in < + sizeof(*in) + sizeof(*in->updated_entries) * in->num_entries_updated) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + ret = cxl_detect_malformed_extent_list(ct3d, in); if (ret != CXL_MBOX_SUCCESS) { return ret; From patchwork Mon Nov 4 21:08:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AEC5D1BDF4 for ; Mon, 4 Nov 2024 21:12:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Jm-0007le-V5; Mon, 04 Nov 2024 16:08:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jj-0007cd-Qv for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ji-0005VR-3h for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754533; 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=usD4x4c8Ymugs9Gl4cc3YR1/YhQZPAPXFQu0stQIFOc=; b=NY2NVe501OmYhowq9c9voZ2rJIBRoYQcJSwak2Tzi8R1KzIbNkPe25x5jbA9EJrIullMyD qoGRoFQXpOH3kLvKreJzrXlZBqGL4lWF5fkYAXx/RxCbrN+QTDS2Ku7FjD4hpynYYXySLR W+8HYGecQf2mXijcR2DRq7lQM3BC01Q= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-73-haK3J3zLNgWxeYIltyGe3A-1; Mon, 04 Nov 2024 16:08:51 -0500 X-MC-Unique: haK3J3zLNgWxeYIltyGe3A-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d4d51b4efso2041267f8f.3 for ; Mon, 04 Nov 2024 13:08:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754528; x=1731359328; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=usD4x4c8Ymugs9Gl4cc3YR1/YhQZPAPXFQu0stQIFOc=; b=qfevMahLRI4uLyZjmnY1sMgXI39PRq6t0NKUA2H5Ru7oY8ae9SoLnNd0MYcUYyXjp3 m52VKGdQ3BxNh2Kj9/6HbGuqK15aGXbCI7KVDrqk8zWpXMqmRbpwH3k/Tj0JX/6LirTy PYQIK3NGZ5jinQ15vRiU2b7JgoKBaUTyH8TBfucbYqF4f2hHYzEqvIE/PDzqA/ry+Hko lHFEBf0HKl3ENGOB3VHo79eaZMHlKHKXpy0oXQFkWcrzLfE5ntGJ6qql3Y2Zvf7TVkIE GugdE5JzW2a5F7Wr8rIUpduj02gaHerXS7qbsWeb8EO3ohxmxuVz5YvguPKC/WFsKgZQ HKGg== X-Gm-Message-State: AOJu0Yzock4tr2M3yhQrx+JOu1jBmMhpWNXlCmfcOrxvlAAhIJg605oD k1t5iGOKPDhQMR/VM0krJ82dJC1XkOo4/6DOxKEduM1ty2X1mvAephljnJ0/FXs2lMnGdbHCfvN YM3VP2fFXawJMsi0CZ+NG23GtTfrD0+423s4T9kKo9bdq2nE/xqnccAF/Ndu/++X4cvGsIXLmPi cvbuWt55PDZ29T6BGt9xBjvMhK7MPnuw== X-Received: by 2002:adf:a29b:0:b0:37d:3f5c:5a83 with SMTP id ffacd0b85a97d-38061128754mr23470787f8f.19.1730754527746; Mon, 04 Nov 2024 13:08:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGk1F4+4O1FfYKhwBdGgRrar/XWF8+yHFwFWAvh6G0j2HzLPX/vlkVqf2kCsUhD7dRTBNjQ4g== X-Received: by 2002:adf:a29b:0:b0:37d:3f5c:5a83 with SMTP id ffacd0b85a97d-38061128754mr23470769f8f.19.1730754527297; Mon, 04 Nov 2024 13:08:47 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e528sm14260739f8f.78.2024.11.04.13.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:47 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:44 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 48/65] hw/cxl: Check input includes at least the header in cmd_features_set_feature() Message-ID: <91a743bd021a262af61c79cc35f0b634b2fcf3ad.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron A buggy guest might write an insufficiently large message. Check the header is present. Whilst zero data after the header is very odd it will just result in failure to copy any data. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 17924410dd..e63140aefe 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1238,6 +1238,9 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, CXLType3Dev *ct3d; uint16_t count; + if (len_in < sizeof(*hdr)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } if (!object_dynamic_cast(OBJECT(cci->d), TYPE_CXL_TYPE3)) { return CXL_MBOX_UNSUPPORTED; From patchwork Mon Nov 4 21:08:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF97CD1BDF2 for ; Mon, 4 Nov 2024 21:12:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Jp-0007rz-Co; Mon, 04 Nov 2024 16:09:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jl-0007jo-M2 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jk-0005VY-4t for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:08:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754535; 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=YE3jbdd2VsjbSTZBjpl3sy5PbqS0FjP8JRPVWflkFi0=; b=eUtqMPOmZ75s0nydaP3FU6JBCUzhedqtsO5qiq/oXSbb/JIFJg7DvTMagqhRYB4HIxNA4o R/JdEPr7sCTWH1eT2/Hj4C5qymAT4bbybUDMb8i8EZ4Y/mLiCyCqHzot7AUKKYqoIyspJI n49nSwBDt/ZH7rxbBUsHP1Omw6WaG0g= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-m7AFdiuBPrq5RI4N4pvftw-1; Mon, 04 Nov 2024 16:08:54 -0500 X-MC-Unique: m7AFdiuBPrq5RI4N4pvftw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4316e350d6aso30653565e9.3 for ; Mon, 04 Nov 2024 13:08:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754532; x=1731359332; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YE3jbdd2VsjbSTZBjpl3sy5PbqS0FjP8JRPVWflkFi0=; b=sd9wpWUjP2pgSFpOsdOoquU6UoF6ifKuIvUQc25WSpTppVMQq7X345c/2cbCimfvzP GSIUniQrLcHigNc/WUcmPmby5zW3EQh7Qp4JJHHxZDQjl+nrsmLBxbarTbjceLeHRk+b zzRV5CuNXCT1laSllFF7njhAcVDoK6rZCVPD5DJ88h0pTWld/ByHpbSEmtwGIpnNeWoK kASvj5jdxTQZGdMTAc2VsYn+kf3lDDQ7ZmUf03TbIli9G+LkhDriKt/TekzN3vy4jqx9 ocBR07TcS1DZh6xWHAA3G3iECJ2nxECFjurVcCGZVBPP05ZbLs29Syv03t/tVrAsfz4q +lHw== X-Gm-Message-State: AOJu0Yx3cwW+5efokSyuaypMs6geFR+8uih6u2mMx54Rdp5VkCnudHm/ 4sQGF2/kxrYPqCDt17NQ9H5RLhpHUhH5iY6V/TF1RB+qwf+kQKL4+x+lDKJY8nHgyurwdyewfvk znlQNpyUtRaaMB3m/i6MNWyi82E/o+gof/FEpguX9GLg8qP8SJiA6vGRkr/BZ36PTNfmfStfxAr d3auhPcW2ryz0JMgWgM0I3CeFJDNhcgQ== X-Received: by 2002:a05:600c:5486:b0:431:51c0:c90f with SMTP id 5b1f17b1804b1-43283255472mr117030515e9.21.1730754531997; Mon, 04 Nov 2024 13:08:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyGuabMcOjD+Im0BD9FjrVzXqRAXS+HvFXGhxfx+Bhhq7+NF/W6JSKi1fFfo6plWoFBbOkeQ== X-Received: by 2002:a05:600c:5486:b0:431:51c0:c90f with SMTP id 5b1f17b1804b1-43283255472mr117030325e9.21.1730754531532; Mon, 04 Nov 2024 13:08:51 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5e94cdsm164169865e9.28.2024.11.04.13.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:50 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 49/65] hw/cxl: Check input length is large enough in cmd_events_clear_records() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Buggy software might write a message that is too short for either the header, or the header + the event data that is specified in the header. This may result in accesses beyond the range of the message allocated as a duplicate of the incoming message buffer. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e63140aefe..3cb499a24f 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -266,6 +266,12 @@ static CXLRetCode cmd_events_clear_records(const struct cxl_cmd *cmd, CXLClearEventPayload *pl; pl = (CXLClearEventPayload *)payload_in; + + if (len_in < sizeof(*pl) || + len_in < sizeof(*pl) + sizeof(*pl->handle) * pl->nr_recs) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + *len_out = 0; return cxl_event_clear_records(cxlds, pl); } From patchwork Mon Nov 4 21:08:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862085 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBEBCD1BDF3 for ; Mon, 4 Nov 2024 21:13:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Jr-0007yQ-0C; Mon, 04 Nov 2024 16:09:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jo-0007ra-M9 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jn-0005Vn-6c for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754538; 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=X09gUc+uwzieH0F+I0K2aed1PpK5bPTr3a80Rrc3pVA=; b=XaZj5gRynQWgkX9M9MvnU6g+6MVFI5fI43glcCwVDUuYjKgR6nvwJGVu4stJ9BBDTUZJHp lOHADfKwQLSNU5ELcWFQ3QB1rOJQSim0FhS6N8MS2k2MlyBX8ltbj5JQz5xqKwegcNrnnt gSr54wntViDXsncJl+gUbJ69DVehRLw= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-pgFjJ9rfMfOG_cFQG0Zvpw-1; Mon, 04 Nov 2024 16:08:57 -0500 X-MC-Unique: pgFjJ9rfMfOG_cFQG0Zvpw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d662dd3c8so2314876f8f.1 for ; Mon, 04 Nov 2024 13:08:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754535; x=1731359335; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=X09gUc+uwzieH0F+I0K2aed1PpK5bPTr3a80Rrc3pVA=; b=pf31zBtTOsJgpocQ8MTnCPBHM4Gt5cYsKBQr8GENRnU+g3Nf4Tf9sOWhK/tbaDf+6C Zl5f5bWkrYakfqUuVaBLMeT2dYDxKiC/D8YPoXXuxdkUBA7ehc+6xs4voBKa/HEyzIbo 4DlaxilDxy0ez59wdNLLIhNUUVWf3ynoYmFzqPrb5zScplZWKwABO9jkyyGZtNCqmjrz sE0bZw5w8pXUSQGkbM6NHzD1YF/LgbYrEC8q/nt3TFfarqeOfBJMNOqiGDez93ndzxh7 Q2QYsvFUCWB08zYxrD/q5+Jg4efy65teSoSXfN0m5kZBV5b2chdOLSJWb97gYfE8dGbF S3JA== X-Gm-Message-State: AOJu0YwZexb/zqy2CgjDlMu6NJRXlqCeVOIMhTPerVJodvVJsyz4WjAx jMg9sYuCQb+Ovmoe62XgN4uxMJ/ezGaSoWu5oUj348QpHxQuIjV1wRzv/6QcK6+zv0486U9tdKa 1f6TBNb68mVW/8Xu+CRRVLCeO/t6wWemrjfpo64pOqnoeONbEGvg3MXaOLkbgppnQQed4AT4wAE m8p0PGLqsXsLU6nxMscKweJnGWKSRy2w== X-Received: by 2002:a05:600c:3547:b0:42c:b16e:7a22 with SMTP id 5b1f17b1804b1-431bb9855c0mr199978715e9.12.1730754535468; Mon, 04 Nov 2024 13:08:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGm5vJf2o0XWBZy/5c3IwjKkL01awFnXbFuO3z/oIADmtka9DnnEecgzCw7asA9BGOA7RnEPg== X-Received: by 2002:a05:600c:3547:b0:42c:b16e:7a22 with SMTP id 5b1f17b1804b1-431bb9855c0mr199978545e9.12.1730754535019; Mon, 04 Nov 2024 13:08:55 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9403bfsm194399045e9.21.2024.11.04.13.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:08:54 -0800 (PST) Date: Mon, 4 Nov 2024 16:08:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 50/65] hw/cxl: Check enough data in cmd_firmware_update_transfer() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Buggy guest can write a message that advertises more data that is provided. As QEMU internally duplicates the reported message size, this may result in an out of bounds access. Add sanity checks on the size to avoid this. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 3cb499a24f..27fadc4fa8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -705,6 +705,10 @@ static CXLRetCode cmd_firmware_update_transfer(const struct cxl_cmd *cmd, } QEMU_PACKED *fw_transfer = (void *)payload_in; size_t offset, length; + if (len < sizeof(*fw_transfer)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } + if (fw_transfer->action == CXL_FW_XFER_ACTION_ABORT) { /* * At this point there aren't any on-going transfers From patchwork Mon Nov 4 21:23:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862108 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC3FAD1BDF5 for ; Mon, 4 Nov 2024 21:24:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84YP-0007Ud-H8; Mon, 04 Nov 2024 16:24:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84YD-0007So-KI for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:23:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Y9-0006t8-AF for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:23:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730755428; 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=YES/BaGPLolp3I4A+ulCB6t6e5td1yjQzn9Wkx1/9XA=; b=BA0/ohVtKWYQxLR+kcJfG5ELztIZm3/WWUETM4xhv1C+nHDVPXViK71+s1lz7LGd7B+X3g wDLU54CeLs6OwsAz+2QurJKardUcOG76WQMpmrctkhzuXO4c4iPmy+auuFjUlVIoAMxyGl Nf/o9aRiR2R2cvVzdF/yLTZQ6ElPA4g= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-8-1ja-N_1rNhOOSACL3C1uQw-1; Mon, 04 Nov 2024 16:23:47 -0500 X-MC-Unique: 1ja-N_1rNhOOSACL3C1uQw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4316e350d6aso30753725e9.3 for ; Mon, 04 Nov 2024 13:23:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730755425; x=1731360225; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YES/BaGPLolp3I4A+ulCB6t6e5td1yjQzn9Wkx1/9XA=; b=CG9I2ivKdfDQfEXkyCqhnXUTiVNrAlQm+IojixxpasNoCDx3Z7DCjTVigMJ69SxtuB ZLf+4kr74wXRmEAo1sPn5T1jDG8HUOrq/izQy4o1z8xXTYuRQbuZ9K/mEdXMg52ZTDXF HltpGtaSFji6VPKd3uHJaCDHSYap5TJB0VptlAZQER830jh+Q0HHnHABFTea/JgULmwd h1S8Wmt5CvR5U10HRypOBa5PHJKLJOLCOZ2hi2uy8SQTxUUw0m7vlFjHClSXFBxReYt+ tZFSsC4B/bxehde1bUqUiYuVXGwawQ2cNsca9U/W35nt07inH+vwIQwDCpfU7jq8JsME RNzw== X-Gm-Message-State: AOJu0YyIEnMdVTZ9UIQ0bFM0mkp7Fa/uQgkA0BEpu0/oPIv9pNAcEPLq az+1ywj+6uVnPm/HHHRjioJqPsMgkGwpI/I7qvsCvfaYWv3Xl27W2bcXM3EUgEkgjapaj8LpK0n BOmix40r3cUxsbmDyAXb0mIFWFD7K/sV11Gkr8e/K05CZQ5aPZhG7nTa6p+FC5CtKr+WrNJlkYs dAiMOJ0fsGJg4AT2aPLppeXeR5GpDJIQ== X-Received: by 2002:a05:600c:1909:b0:430:563a:b20a with SMTP id 5b1f17b1804b1-432886e57e1mr98137605e9.11.1730755425293; Mon, 04 Nov 2024 13:23:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IF0T/2EEwOGjnhy4TnYT5mhVJDEA2DhqW1Uf8aTmUtmcn68dDJvwTEEhnUZvHlJgdD3ymCf/Q== X-Received: by 2002:a05:600c:1909:b0:430:563a:b20a with SMTP id 5b1f17b1804b1-432886e57e1mr98137445e9.11.1730755424903; Mon, 04 Nov 2024 13:23:44 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432a267dfadsm1547085e9.0.2024.11.04.13.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:23:44 -0800 (PST) Date: Mon, 4 Nov 2024 16:23:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 51/65] hw/cxl: Check the length of data requested fits in get_log() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Checking offset + length is of no relevance when verifying the CEL data will fit in the mailbox payload. Only the length is is relevant. Note that this removes a potential overflow. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 27fadc4fa8..2aa7ffed84 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -947,7 +947,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, * the only possible failure would be if the mailbox itself isn't big * enough. */ - if (get_log->offset + get_log->length > cci->payload_max) { + if (get_log->length > cci->payload_max) { return CXL_MBOX_INVALID_INPUT; } From patchwork Mon Nov 4 21:23:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862110 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7187D1BDF5 for ; Mon, 4 Nov 2024 21:25:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84YQ-0007VT-Jc; Mon, 04 Nov 2024 16:24:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84YI-0007TL-20 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:23:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84YE-0006tR-TP for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:23:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730755434; 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=+r0iRZPdNktKwi2B9jYiiQ07N21yewo/4zGpqb2N41I=; b=Q7BF/sfSO6CPR1jbKGMg02n6a2di5I0/qepr0XpMy4yC0oRwK/r7hScpU67SkbaLg2zCp+ CFxk3Pf3Dw9QD2BHcdjnNiIrPw0YDLWPVDBf4NKI7/zBbSbJlX4QwG+ssSNHIONaVY69rO +fFaxUY/5NilpcYb9sMyy4iBjS1UJYU= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-552-IcrsMmvyPS2p9mDPFNRnIg-1; Mon, 04 Nov 2024 16:23:53 -0500 X-MC-Unique: IcrsMmvyPS2p9mDPFNRnIg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4316655b2f1so33107735e9.0 for ; Mon, 04 Nov 2024 13:23:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730755432; x=1731360232; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+r0iRZPdNktKwi2B9jYiiQ07N21yewo/4zGpqb2N41I=; b=sAt37GEwgwWdU36jdwr3fIlaDwGtF6Tu2y6maCDOzd1Is9UDkSy6A/kF0BdtlR1GJF tiWbPZP0w481PbG2WUVmngNljgHie6jBnxfG89f+4MIBawE1kLoTKOaJFJx1XIfjW/2a UMa0BcwuThqFnTUziE6H+eh4AlYewCrmEJnIX5d/Toevysz43SLV+TnPdwgJ+cdKLT6h IVuXHgvzMwBwODhvp9+/dbJUvM8D594DluHlDf/ZjOQsWhuLfruC59Y8lu0tPeiD1TSx 3j/N+OZDnUNd31CbLnX4VOhdCZuPp8su8wV+NHF4uqdtKflXejqHlZHODYuXG6Xi2hFZ sZWQ== X-Gm-Message-State: AOJu0YxKfm4hu/1a5ni9gD7LKXufFcIQ1p/BjgB51uIuRNfvuw3L0MXi 0/xzZhlfbse2n7XH/QAM8cttL3q/rgBn0leESFjZYlxrqp21LQiIw1KJEx5w2Nvpdgsp+QIxD6s DiRpvQU+CdU60qHNWKRL6qICW3VFFTBWPiBjJIqtEEtPsDvWrBsyQCfH2iMQGrqDpapnZ2IPSIJ 7Sfgyx5ZOxlIzJbb9AcV3xmh3WXhm1mA== X-Received: by 2002:a05:600c:3587:b0:42c:c401:6d67 with SMTP id 5b1f17b1804b1-4327b6f464amr138539415e9.6.1730755431748; Mon, 04 Nov 2024 13:23:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKQzk30xivw4kVEmq/E8kN34n4o1SbMHvXX7lLl89HmdRKFSJWuCgVK03tghpMYinErG5RfA== X-Received: by 2002:a05:600c:3587:b0:42c:c401:6d67 with SMTP id 5b1f17b1804b1-4327b6f464amr138539275e9.6.1730755431357; Mon, 04 Nov 2024 13:23:51 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432a273afabsm1040145e9.1.2024.11.04.13.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:23:50 -0800 (PST) Date: Mon, 4 Nov 2024 16:23:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 52/65] hw/cxl: Avoid accesses beyond the end of cel_log. Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Add a check that the requested offset + length does not go beyond the end of the cel_log. Whilst the cci->cel_log is large enough to include all possible CEL entries, the guest might still ask for entries beyond the end of it. Move the comment to this new check rather than before the check on the type of log requested. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-7-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 2aa7ffed84..5e571955b6 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -937,16 +937,6 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, get_log = (void *)payload_in; - /* - * CXL r3.1 Section 8.2.9.5.2: Get Log (Opcode 0401h) - * The device shall return Invalid Input if the Offset or Length - * fields attempt to access beyond the size of the log as reported by Get - * Supported Logs. - * - * The CEL buffer is large enough to fit all commands in the emulation, so - * the only possible failure would be if the mailbox itself isn't big - * enough. - */ if (get_log->length > cci->payload_max) { return CXL_MBOX_INVALID_INPUT; } @@ -955,6 +945,20 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, return CXL_MBOX_INVALID_LOG; } + /* + * CXL r3.1 Section 8.2.9.5.2: Get Log (Opcode 0401h) + * The device shall return Invalid Input if the Offset or Length + * fields attempt to access beyond the size of the log as reported by Get + * Supported Log. + * + * Only valid for there to be one entry per opcode, but the length + offset + * may still be greater than that if the inputs are not valid and so access + * beyond the end of cci->cel_log. + */ + if ((uint64_t)get_log->offset + get_log->length >= sizeof(cci->cel_log)) { + return CXL_MBOX_INVALID_INPUT; + } + /* Store off everything to local variables so we can wipe out the payload */ *len_out = get_log->length; From patchwork Mon Nov 4 21:09:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862066 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0FBFED1BDF2 for ; Mon, 4 Nov 2024 21:11:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84K0-0008Sa-Ro; Mon, 04 Nov 2024 16:09:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jx-0008In-9E for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jv-0005WD-SH for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754547; 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=pofF4pvx4NNxLWVgauC0xOmCFfdwGb52obnY+44wiVY=; b=FO7xu22jclJrv2A7xhdtZ538094w0kmoxKOFngA8Et35oUYcXZFGgKl15utXabZ32peQQ1 DS/da9BeMZZRTOA0RV3DHy5Nv+VsayQBEqZcwdEmsW4LSjqanFGnvWAmXa5OgK+k5BY0uW bipdUEFxNbTTCmRJCulZC+fTG3+cQDw= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-Dj7pYH-mNQ-RzJ21jjP0yg-1; Mon, 04 Nov 2024 16:09:06 -0500 X-MC-Unique: Dj7pYH-mNQ-RzJ21jjP0yg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d4af408dcso2149410f8f.0 for ; Mon, 04 Nov 2024 13:09:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754544; x=1731359344; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pofF4pvx4NNxLWVgauC0xOmCFfdwGb52obnY+44wiVY=; b=fOCGavYHhnf0RVLLMtmNaJhukydF73eRI0itektxVAe3yrpoVRqwjGgAVq3nklJeQa c4BjNFLuPhSXjhXPdymRXCQGHoEwpkim1k/nM8KtUGEL2owQp8Lq7LTQ/JuPK4p9YXh9 XF/Av4dC76n2C1P2A+QV3jgDsdEgdkGMvigpvdmgxI6v49QkQnnzZd/Q7mPZXymaFG/0 8u75BbsOxtILRK0ag98jOtLlhpKl0E+ksNV9B4tdcWxz/PD14SwCwphoNPzXxNVu3NmH UOVdG5eMRCQmp+a983F2+Z+9iArgFVoaTwNL85VlhjxAuLRy/2826lZyX/rtwzUQMDeY JWCg== X-Gm-Message-State: AOJu0YzxJ58vqOMiQf7bFojZe5Ar/wJZ6lpLA9US5zXUByRGzrsB8TrG OG/V0zrBGV04uPkH/xPixzjPQyp23uCozyWAWJQQseepbYaEV+z7WZz+bNiAbdjrO747F5ks5zM W63AGibMO/wrg88GtFHZ7px8KkRC5z6obJMZGSMeJ16DcQ2E/pm/mYciGuuJUTklQFmXQrMie37 4FNi3o7dBteM3h9YuFtsZp0hDgmzENFQ== X-Received: by 2002:a05:6000:104a:b0:37d:2de4:d64 with SMTP id ffacd0b85a97d-38061162c32mr22194019f8f.35.1730754544119; Mon, 04 Nov 2024 13:09:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGY8R5MnEzr3CIWhSoUwKBYsfvLUyOJJSlAUj4Jwu0r5UaN0b5reA1N+nWt+6e+WAJiNlcjOA== X-Received: by 2002:a05:6000:104a:b0:37d:2de4:d64 with SMTP id ffacd0b85a97d-38061162c32mr22194005f8f.35.1730754543614; Mon, 04 Nov 2024 13:09:03 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113dd8asm14222338f8f.73.2024.11.04.13.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:02 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 53/65] hw/cxl: Ensuring enough data to read parameters in cmd_tunnel_management_cmd() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron If len_in is less than the minimum spec allowed value, then return CXL_MBOX_INVALID_PAYLOAD_LENGTH Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 5e571955b6..a40d81219c 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -151,6 +151,9 @@ static CXLRetCode cmd_tunnel_management_cmd(const struct cxl_cmd *cmd, in = (void *)payload_in; out = (void *)payload_out; + if (len_in < sizeof(*in)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } /* Enough room for minimum sized message - no payload */ if (in->size < sizeof(in->ccimessage)) { return CXL_MBOX_INVALID_PAYLOAD_LENGTH; From patchwork Mon Nov 4 21:09:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B13F7D1BDF3 for ; Mon, 4 Nov 2024 21:09:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84K3-0000Is-C1; Mon, 04 Nov 2024 16:09:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84K0-0008Sz-Ql for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Jz-0005WO-7w for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754550; 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=+Qw3Qe8wV0ZOH6ROfQpES8yW2OtudwZHXLHI9Pq75U4=; b=cjW3YhJo4eMYJc8dhjFEeSxnYITevv6zkIid2w++6xNDT7t3VC1cOZdJpv2pV/RDJh3LFQ S4pHJ+f7FHFz3Xt0Q2oRxJ1IjDXHtv4k0PsYh2Ju1p9uTvXyAEGaH5fdS63BVYYYausly8 +LGYwglQ6ouLntTmpqUtJwTrUZGV4F8= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-lyK73HrcNHmClx3GtGYq0A-1; Mon, 04 Nov 2024 16:09:09 -0500 X-MC-Unique: lyK73HrcNHmClx3GtGYq0A-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d4cf04bcfso2340520f8f.2 for ; Mon, 04 Nov 2024 13:09:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754547; x=1731359347; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+Qw3Qe8wV0ZOH6ROfQpES8yW2OtudwZHXLHI9Pq75U4=; b=iibHN5/cfwrUMU6mnczy6VWdOXmDApVDOkOqOwxKm0A54q22tFpbmgOYK5tW5ozitA TBzidQklelrZmvaQr84sXSUnI/l8jF52jon7MutHI3U/qpKf23FM5CfY2SmQ/BiMKjzl zBjdZF825jr3em0HOxzbM5zhkei4FtDmlH/pQlqFJ4ZmCv3AGaTM92KxcpAjs1uM2rxq 14RJOGA0Opp11ZmGucCCK52P8AXBFRb+9cLDMcG5HeRUREPFZnyQHJLUdj5RSU2wBs6S 8+6smxJ2GPdHukaXuAehGd6BHaiX1me+jOEo/8Xt838b3H6woViyqv6fHaCMYHu0px5Y OjOg== X-Gm-Message-State: AOJu0YwxM7gACGtTvPtDSifDJDGDNud5cXr37ELSBG3t3VX5ga0aoJZ9 k68NjbQRzqZOBQJWqTZUd28gK9uIxG6VpFbTtb/UY9UwtKXeAt/yH3ES5tvbyWB3U0Ec0/v4mN7 CcqKM9xLU0nZH2jFVus9OCkSbmeb7izam9vmAPMh2C5WXHS1nTPH2C/fWtPwr2gapPDKY9yI3Fb FkMCUiNGtLaZ1KVKbcDfAzutP2Isr8YQ== X-Received: by 2002:a5d:6c63:0:b0:37d:3973:cb8d with SMTP id ffacd0b85a97d-381c7a5e9d5mr10879861f8f.24.1730754547277; Mon, 04 Nov 2024 13:09:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEo6Rpo8Gsz0VvSJGu4BEwEmEsgBRwuTYZz22CLisHkg0ZRK6VwkjSrwpkk48lweqKCbpSQ2g== X-Received: by 2002:a5d:6c63:0:b0:37d:3973:cb8d with SMTP id ffacd0b85a97d-381c7a5e9d5mr10879838f8f.24.1730754546785; Mon, 04 Nov 2024 13:09:06 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e7392sm14121373f8f.55.2024.11.04.13.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:06 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 54/65] hw/cxl: Check that writes do not go beyond end of target attributes Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron In cmd_features_set_feature() the an offset + data size schemed is used to allow for large features. Ensure this does not write beyond the end fo the buffers used to accumulate the full feature attribute set. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-9-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index a40d81219c..078782e8b9 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1292,6 +1292,11 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, ps_set_feature = (void *)payload_in; ps_write_attrs = &ps_set_feature->feat_data; + + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->patrol_scrub_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } memcpy((uint8_t *)&ct3d->patrol_scrub_wr_attrs + hdr->offset, ps_write_attrs, bytes_to_copy); @@ -1314,6 +1319,11 @@ static CXLRetCode cmd_features_set_feature(const struct cxl_cmd *cmd, ecs_set_feature = (void *)payload_in; ecs_write_attrs = ecs_set_feature->feat_data; + + if ((uint32_t)hdr->offset + bytes_to_copy > + sizeof(ct3d->ecs_wr_attrs)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } memcpy((uint8_t *)&ct3d->ecs_wr_attrs + hdr->offset, ecs_write_attrs, bytes_to_copy); From patchwork Mon Nov 4 21:09:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862083 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E4B2CD1BDF2 for ; Mon, 4 Nov 2024 21:13:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84K6-0000h4-42; Mon, 04 Nov 2024 16:09:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84K4-0000ag-JF for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84K3-0005We-1r for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754554; 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=OG4lyvfSQwzgYZmOFt3djPmHvHJCXcfAK3eUcAgOhtk=; b=AfjIFj0XR4lzL6L5EvR8uiCU6zzDl9rankvoXbVUlVUAIyC3/NYASMAfGW0jsX6Bo8aulm gx2AJvYO3lcFBGrWORjq3FaOtyhKg8yHIY/pjVZQ0Ivy0NhJigmaHYfQldI4SjoJ2lOWVs EOsCx4j2IQELynt7CTotynjFsr19vLI= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-442-kE_jAxS1OXCt5dTlSYXQHA-1; Mon, 04 Nov 2024 16:09:13 -0500 X-MC-Unique: kE_jAxS1OXCt5dTlSYXQHA-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2fb55e102b6so29367951fa.1 for ; Mon, 04 Nov 2024 13:09:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754551; x=1731359351; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OG4lyvfSQwzgYZmOFt3djPmHvHJCXcfAK3eUcAgOhtk=; b=PeFhjfN96GpsAcySZLbnCv4/aF2tqUYLUX9/0R9FZVt5yBe3/EMTX2bEeXwdPMzoRY D9jBnVkvW0E8Qf8muF2xEieWMDsaLZINM+fd1tONJVTNB4iJxL5wxKnBZN/MViojdoJg kbTArGPTymvuefcLv39uOcbBmaIAtG75vQcpbmLFiCD0oEtTLAldBOTPK2bl/vNV1FXt 1Dq/wa+8n1IdBmk4lhE9KTJBMuyHCPRxLxHTHPv8HCVkVfF6IdhMnino1yGxu5i5d8U/ K0wLN6enuMICsIkBMUsequG0CvtuLbbjVH+g3bkv9Y2tVcdVRFrQoaAU0xIHa3BmKJJB 8A7A== X-Gm-Message-State: AOJu0YyD2W4piJhZMeX6/5em6Undrd/VOAWQH2ZyvUlmaFa3o+xYFGNg p2KwI5sVoy+Lc6OdmqtBwSrbv978bRE4i4RaCLoLAPJR3UEI2dlbcxIRDl3GwipnVU9yNlcymYT AK4ABcg6fY7ZhYQwtNPbmJN3i2UehyFMg2KLffKqrMuc7NGSY0N3YVMInPdgBafwJ25JmZiORZQ yzVWaBobEaPzmLiYnB6CSabI7DD2jflA== X-Received: by 2002:a05:651c:220c:b0:2fb:5014:c998 with SMTP id 38308e7fff4ca-2fedb7d999cmr65342601fa.28.1730754550714; Mon, 04 Nov 2024 13:09:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+e6pMijqXqXpcWcgXAU0eEMLqWiYhF7ynvUMIeDGJ9RdNskcsgc0NqCVkb1xHWNVAf49YPg== X-Received: by 2002:a05:651c:220c:b0:2fb:5014:c998 with SMTP id 38308e7fff4ca-2fedb7d999cmr65342411fa.28.1730754550224; Mon, 04 Nov 2024 13:09:10 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10d4b82sm14153010f8f.43.2024.11.04.13.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:09 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 55/65] hw/cxl: Ensure there is enough data for the header in cmd_ccls_set_lsa() Message-ID: <5300bdf5898dda5989215e183bccd555cc782b9a.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron The properties of the requested set command cannot be established if len_in is less than the size of the header. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-10-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 078782e8b9..f4a436e172 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1503,8 +1503,8 @@ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd *cmd, const size_t hdr_len = offsetof(struct set_lsa_pl, data); *len_out = 0; - if (!len_in) { - return CXL_MBOX_SUCCESS; + if (len_in < hdr_len) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; } if (set_lsa_payload->offset + len_in > cvc->get_lsa_size(ct3d) + hdr_len) { From patchwork Mon Nov 4 21:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CED17D1BDF2 for ; Mon, 4 Nov 2024 21:13:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84KA-000140-Hl; Mon, 04 Nov 2024 16:09:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84K8-0000wQ-J2 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84K7-0005X1-2F for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754557; 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=z8mjCAYRXCtl4i5x731E2QWqLSQ+blqkHsX/35ib1TE=; b=A34QkXLyj7k8va6cXHfioEKBG9kcAsT8pFIo1xBeUhu8wXiqSt2rHGjs0ThOzn5T43yeLq 4Oa9jn4lnOtw9kWHihF5BoJZy46o2CHKwE7cvMwyKNBcb8fjUHsyaxTCcRAf07rF/OI0RU g6UOO/J7WALAMM0k77nc929c8ykXD+c= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-192-FY0PbRVZNRSO4HWPtcHqQQ-1; Mon, 04 Nov 2024 16:09:16 -0500 X-MC-Unique: FY0PbRVZNRSO4HWPtcHqQQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4315e8e9b1cso27297275e9.1 for ; Mon, 04 Nov 2024 13:09:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754555; x=1731359355; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z8mjCAYRXCtl4i5x731E2QWqLSQ+blqkHsX/35ib1TE=; b=BEcKQDYusjtFS+EXwXjSv2kHqo9hZLU5kIOyMjU6k79aXB/aYsU3TEX6U96JyTXk+2 //nYeL0f4y271gFw1Gus8xsvKhGnm8MrO9vmzTCTHUUJYMcUgjuLUpbiAbHU170iMvFS Yd6JjJYtjXCKVrkvFvvEtQkwGYopXArQyf+71PlVK0rrpUp6W8dTg9twE0Oz/d4FBDnA Io8uCtKwTvR5C1Ak0YMhl8w6IztbxfFkevS1oBSFqWMkJiRvsocOG7nA8frjpaIwkJkL ThazhJ40jZZZEtTZ2J42dQuCDXoVc+Ip2SjZutJBeCLf8Om1Wohj4PFe4srGHrr9vPB/ xHMA== X-Gm-Message-State: AOJu0YxV66czLlIK6bzYRHLbsEQFDUWKk49VfWGhttvbol7lTWbyJ3SK IPAktqFG7rZYgzro5vz8VXmvb4yWfp2TO26N/XIe4heyHiqbQe7IFawcTOgJ28GNwfn8bL8ci2C BMDoqM+1T6ewZ7Bgecyync+GY1I4c5Y+ck90WKCp5tEbxd22X1JOvm2PF7PCxL2/lA1M5ZnLae+ 1Cnr64IeO8n/UynXM7w7FjkGOmsQGbbQ== X-Received: by 2002:a05:600c:1382:b0:431:5475:3cd1 with SMTP id 5b1f17b1804b1-4327dacc373mr122768585e9.17.1730754554797; Mon, 04 Nov 2024 13:09:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9OxVsWEUkkxztFDINuwekKPZehgtJpRIpJYkMWxO6+XhnNGH3YGJU36vfpcI+EJq92UN0+g== X-Received: by 2002:a05:600c:1382:b0:431:5475:3cd1 with SMTP id 5b1f17b1804b1-4327dacc373mr122768395e9.17.1730754554404; Mon, 04 Nov 2024 13:09:14 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5ac002sm164216815e9.5.2024.11.04.13.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:13 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:10 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Esifiel , Fan Ni Subject: [PULL 56/65] hw/cxl: Ensure there is enough data to read the input header in cmd_get_physical_port_state() Message-ID: <721c99aefcdb311bd41d20678d3935fd11454641.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron If len_in is smaller than the header length then the accessing the number of ports will result in an out of bounds access. Add a check to avoid this. Reported-by: Esifiel Signed-off-by: Jonathan Cameron Message-Id: <20241101133917.27634-11-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index f4a436e172..2d4d62c454 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -530,6 +530,9 @@ static CXLRetCode cmd_get_physical_port_state(const struct cxl_cmd *cmd, in = (struct cxl_fmapi_get_phys_port_state_req_pl *)payload_in; out = (struct cxl_fmapi_get_phys_port_state_resp_pl *)payload_out; + if (len_in < sizeof(*in)) { + return CXL_MBOX_INVALID_PAYLOAD_LENGTH; + } /* Check if what was requested can fit */ if (sizeof(*out) + sizeof(*out->ports) * in->num_ports > cci->payload_max) { return CXL_MBOX_INVALID_INPUT; From patchwork Mon Nov 4 21:09:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B789D1BDF4 for ; Mon, 4 Nov 2024 21:11:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84KF-0001UP-GS; Mon, 04 Nov 2024 16:09:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KB-0001Ed-QJ for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KA-0005XM-8O for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754561; 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=/YkVz0N+ZYz0sOInTQ7tr8J7S7sTGzbncPzAkgRHAQg=; b=NrFJT/aWasH+6HrweUnXBvzfGH3o60/gOW4D7pDBLD7KcenO/XzGTzK8GfETMKVS3ZQc+c v2JXfWAJRHRnZW/I6u9XhKunsjTwhM32ptsidf/9nrgeEc9z1m91Jlqjn5BjochkCpUMJJ pHFqp4EkvRbHEMcMRnePsIC2fvTpkRo= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-Flpomyp0PwO6rj1V6DGfjg-1; Mon, 04 Nov 2024 16:09:20 -0500 X-MC-Unique: Flpomyp0PwO6rj1V6DGfjg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4314f1e0f2bso30703355e9.1 for ; Mon, 04 Nov 2024 13:09:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754558; x=1731359358; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/YkVz0N+ZYz0sOInTQ7tr8J7S7sTGzbncPzAkgRHAQg=; b=O5eDpYIpDuT3LtskG37wNvqV/dkH383Iz0twubyvLJCE3ijNHs7whZmrUSGHl8nu+X NpzpQJAB5l4w7WRGiD2PQxF6xLuooMAAlXGbclAh3OunNL1wuaoO6ULaUyMWDTriBWIW 2lnqra3DiYq6WpdnN1L9Gz3pNYP4h25vB37WGPjK1aYfNbFoMQwo2t3fApSgYwNNT2th ep167SDlj3ulN87BWIzIfkoWULyAmYZMYbZtRb/2boM0mwRPM0oZfzyV/9wSn+OSWgwx RUT7JNlA421mdHKlH6Ud15wlQJldtw2wsqbwQKfGVzFqArXi65gXanbXxSrQa4yi/gle vzwg== X-Gm-Message-State: AOJu0YxrB63nuRa2I16LLUSILRbvOgr6fqdTg5ds1H8azl5QV7EaeBuP mGOJFBibl53O6jjOv8AR1Aatk+T1tSbRMgRZQWWE63QHCQpDnEk3+SzNi4OY9jbry9qaHUqumx7 Vpw1nRTAJvocxpDnip2qthM5XaotMsth08KCWt13ISrjT2hvQu0ijSpqimYUkuwldxCC4c5BxQR osvrtvdYUcR6lYH0jKp+yrB5+JXRljIg== X-Received: by 2002:a5d:5f43:0:b0:37c:d20d:447c with SMTP id ffacd0b85a97d-381c7a6c758mr12746796f8f.29.1730754558529; Mon, 04 Nov 2024 13:09:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IET/jpJhQji/8AsjQhEcmZralLsxtrg2HTRhR+3H1CnlSM/YZjQ054ILqxA6EkmvRksv5piyw== X-Received: by 2002:a5d:5f43:0:b0:37c:d20d:447c with SMTP id ffacd0b85a97d-381c7a6c758mr12746762f8f.29.1730754558097; Mon, 04 Nov 2024 13:09:18 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10b7d2bsm14165387f8f.16.2024.11.04.13.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:17 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Roque Arcudia Hernandez , Nabih Estefan , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Marcel Apfelbaum Subject: [PULL 57/65] hw/pci: Add parenthesis to PCI_BUILD_BDF macro Message-ID: <26f2660bf7a3f0b6e9a939657ba656f4891ff46d.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Roque Arcudia Hernandez The bus parameter in the macro PCI_BUILD_BDF is not surrounded by parenthesis. This can create a compile error when warnings are treated as errors or can potentially create runtime errors due to the operator precedence. For instance: file.c:x:32: error: suggest parentheses around '-' inside '<<' [-Werror=parentheses] 171 | uint16_t bdf = PCI_BUILD_BDF(a - b, sdev->devfn); | ~~^~~ include/hw/pci/pci.h:19:41: note: in definition of macro 'PCI_BUILD_BDF' 19 | #define PCI_BUILD_BDF(bus, devfn) ((bus << 8) | (devfn)) | ^~~ cc1: all warnings being treated as errors Signed-off-by: Roque Arcudia Hernandez Reviewed-by: Nabih Estefan Message-Id: <20241101215923.3399311-1-roqueh@google.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 38ffa7bcee..135695c551 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -16,7 +16,7 @@ extern bool pci_available; #define PCI_BUS_NUM(x) (((x) >> 8) & 0xff) #define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) #define PCI_FUNC(devfn) ((devfn) & 0x07) -#define PCI_BUILD_BDF(bus, devfn) ((bus << 8) | (devfn)) +#define PCI_BUILD_BDF(bus, devfn) (((bus) << 8) | (devfn)) #define PCI_BDF_TO_DEVFN(x) ((x) & 0xff) #define PCI_BUS_MAX 256 #define PCI_DEVFN_MAX 256 From patchwork Mon Nov 4 21:09:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32D4BD1BDF2 for ; Mon, 4 Nov 2024 21:13:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84KI-0001oS-8D; Mon, 04 Nov 2024 16:09:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KF-0001Vc-K0 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KD-0005Xr-QY for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754565; 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=JLaTzrMhNeOuVYzVJLMqDji715fEATJsG7TwuJVQHzY=; b=IlnawCeRB+Y2V+dPw3+O2Y6hOIVdPNAVqF/iMmauKoCwiux8gQlyZoqAbxfMeybPb947Qz on1U5+gYNKvxV+N0AY1FO7cnB3lj8t4eXWunvlTRQG+Ryskpn3g9yEN53IG0W6LeqezKQo VowwsnUEagKlxwxeN62Dwj6UY+CVpOE= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-FFsV4wD_NXqn86kzP5_LUA-1; Mon, 04 Nov 2024 16:09:24 -0500 X-MC-Unique: FFsV4wD_NXqn86kzP5_LUA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-37d4af408dcso2149642f8f.0 for ; Mon, 04 Nov 2024 13:09:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754562; x=1731359362; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JLaTzrMhNeOuVYzVJLMqDji715fEATJsG7TwuJVQHzY=; b=SgzVXRYpr24srfiYvwc9VcAXp+g7nwX5GyD93L9syVQknTN1GpY8BaJktUgcoAwr3j ZwWKGyyO6g3YLSzyloQjWQYXFLeNI6qMQfJeL4KLMdzVdljXDSWsLP2EI19pcnLPvWV3 KgD0J7SRTW+BfsE3IuWz/lkO4I+b4UBWSu/5CQyeKbXQvCrx+E1UKHx8/dyinxDAivEl RPjOj2/3sYKLmnPbWtXhvKm47dkZJfOqElQwNI6gjg6yUlct5dFTzJQPyyA8vI0ddjLn +kJ409zY9Yh6Dr4VBCqcxZouS0rgXTZ1XIHceBbWZhlkPlDngplj9OHGkF1ukYUob5RW MJmQ== X-Gm-Message-State: AOJu0YyCgHI0nd3QWYKfErHIGjnkTpH3wJHek/YQ/Qimv4b99lUpP1bR KyKVafNEGDbT/uPokWtDN+hyoSoTC3pbLAHg/XzBMy1fa7PEPQXwSsHDtemYgGTD4ozx51ZV+Ax Qs24ZLQUD2+ljfZkJ4vJ9JW5rBUWtgTjUIYFE4QSOsYt8SLjIlyeHDpynbR2aNPH5g3KPvqO1d9 34iCjCHmTI9Rd8m8MNFfBdnb7eM4AQow== X-Received: by 2002:adf:e5c4:0:b0:37d:4846:42c3 with SMTP id ffacd0b85a97d-38061137468mr22927333f8f.22.1730754562330; Mon, 04 Nov 2024 13:09:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGh6uGQg4sQjiRH2nm7vI8Z5aVu33rNI9xMT59ovapS4OR54xYyDqW4DhCGdADN62lWtWNDXQ== X-Received: by 2002:adf:e5c4:0:b0:37d:4846:42c3 with SMTP id ffacd0b85a97d-38061137468mr22927311f8f.22.1730754561836; Mon, 04 Nov 2024 13:09:21 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10d49dfsm14197412f8f.46.2024.11.04.13.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:21 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Igor Mammedov , Ani Sinha , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu Subject: [PULL 58/65] hw/acpi: Make CPUs ACPI `presence` conditional during vCPU hot-unplug Message-ID: <2d6cfbaf174b91dfa9a50065f7494634afb39c23.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Salil Mehta On most architectures, during vCPU hot-plug and hot-unplug actions, the firmware or VMM/QEMU can update the OS on vCPU status by toggling the ACPI method `_STA.Present` bit. However, certain CPU architectures prohibit [1] modifications to a CPU’s `presence` status after the kernel has booted. This limitation [2][3] exists because many per-CPU components, such as interrupt controllers and various per-CPU features tightly integrated with CPUs, may not support reconfiguration once the kernel is initialized. Often, these components cannot be powered down, as they may belong to an `always-on` power domain. As a result, some architectures require all CPUs to remain `_STA.Present` after system initialization. Therefore, it is essential to mirror the exact QOM vCPU status through ACPI for the Guest kernel. For this, we should determine—via architecture-specific code[4]—whether vCPUs must always remain present and whether the associated `AcpiCpuStatus::cpu` object should remain valid, even following a vCPU hot-unplug operation. References: [1] Check comment 5 in the bugzilla entry Link: https://bugzilla.tianocore.org/show_bug.cgi?id=4481#c5 [2] KVMForum 2023 Presentation: Challenges Revisited in Supporting Virt CPU Hotplug on architectures that don’t Support CPU Hotplug (like ARM64) a. Kernel Link: https://kvm-forum.qemu.org/2023/KVM-forum-cpu-hotplug_7OJ1YyJ.pdf b. Qemu Link: https://kvm-forum.qemu.org/2023/Challenges_Revisited_in_Supporting_Virt_CPU_Hotplug_-__ii0iNb3.pdf [3] KVMForum 2020 Presentation: Challenges in Supporting Virtual CPU Hotplug on SoC Based Systems (like ARM64) Link: https://kvmforum2020.sched.com/event/eE4m [4] Example implementation of architecture-specific CPU persistence hook Link: https://github.com/salil-mehta/qemu/commit/c0b416b11e5af6505e558866f0eb6c9f3709173e Signed-off-by: Salil Mehta Message-Id: <20241103102419.202225-2-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/core/cpu.h | 1 + hw/acpi/cpu.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index c3ca0babcb..e7de77dc6d 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -158,6 +158,7 @@ struct CPUClass { void (*dump_state)(CPUState *cpu, FILE *, int flags); void (*query_cpu_fast)(CPUState *cpu, CpuInfoFast *value); int64_t (*get_arch_id)(CPUState *cpu); + bool (*cpu_persistent_status)(CPUState *cpu); void (*set_pc)(CPUState *cpu, vaddr value); vaddr (*get_pc)(CPUState *cpu); int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 5cb60ca8bc..9b03b4292e 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -233,6 +233,17 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, memory_region_add_subregion(as, base_addr, &state->ctrl_reg); } +static bool should_remain_acpi_present(DeviceState *dev) +{ + CPUClass *k = CPU_GET_CLASS(dev); + /* + * A system may contain CPUs that are always present on one die, NUMA node, + * or socket, yet may be non-present on another simultaneously. Check from + * architecture specific code. + */ + return k->cpu_persistent_status && k->cpu_persistent_status(CPU(dev)); +} + static AcpiCpuStatus *get_cpu_status(CPUHotplugState *cpu_st, DeviceState *dev) { CPUClass *k = CPU_GET_CLASS(dev); @@ -289,7 +300,9 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st, return; } - cdev->cpu = NULL; + if (!should_remain_acpi_present(dev)) { + cdev->cpu = NULL; + } } static const VMStateDescription vmstate_cpuhp_sts = { From patchwork Mon Nov 4 21:09:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC6FAD1BDF3 for ; Mon, 4 Nov 2024 21:13:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84KM-0002Jw-S7; Mon, 04 Nov 2024 16:09:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KK-000255-Pp for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KJ-0005Y2-6W for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754570; 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=6x+Legev3Cp2GqMVGf/goAaVdwIyT9f6UX5WvCHt0Bs=; b=gFTjbQVenfc+MCGxsnQBlK1LzIhcfKEZPfMVgorX3UvShAPFd3EyS5Aurp0pxMvJuUlQJD FZzVMT6qRYWJ/uLeN1NAaXrAL2Ki34FHZjwUsVZM1Bnp4/AZps2HUgzxdMh4SgpCP0z9yx Aas9Q9vYviyuQybhabnDcVfNeGff9RM= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-522-KSDLAMRPMOG9zs0rmt4jEQ-1; Mon, 04 Nov 2024 16:09:29 -0500 X-MC-Unique: KSDLAMRPMOG9zs0rmt4jEQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-431604a3b47so29806865e9.3 for ; Mon, 04 Nov 2024 13:09:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754567; x=1731359367; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6x+Legev3Cp2GqMVGf/goAaVdwIyT9f6UX5WvCHt0Bs=; b=sWAiO6xwXHHwrXWjA3fuzKaS+BoGfWwAs8tAfh1pqM+ta53GsPnvEYIPaNSjD7c1va 4NCPkGnu0MiwJGaonLkY7XMp27aqMKLHV7rDZ3RNwivIcr52kxf6xNVzxlf9bGzGEJyG PXqzj96pZklT0bvz4BI6J370kk6Hr32vEJ7EbJKF72ZOvWEllVSwXP9ND8evcGO2Dmy+ M+n3NxvTHmdCWqaLyrwz9jYP74kZcrbSh61kqpEobZQNh4Bd3KQ9/4zGN9KiNmw7pecN aXkVsGgMJMvpfrVJfBMiG/2Yk0pipTcI47xyrrnrDuiLdZvR7B7wwH/PVMHkRth0vbuN XRIg== X-Gm-Message-State: AOJu0YzBUJ9IYLVbPJyLPy2O8UtJz6ry+8f0A35l6eZ6q7nzJ+PMjZ1A 1nfwQ1ze2FtdxQ+0vAo+yfJP8dXlO2KunaQZva9rosHrf8eSZECjqbE4FmFSk+WpBheeWhS3Vl5 yxxX2flZAjImMRQoodWlrE/qyZyJqNv9LeX3bcqQRSmZXnDbvAunZgXRQmZ71Is1bgIf9ACa7io e1ICxPqtIDrE5K9jMNVLRsQXc3ti88ig== X-Received: by 2002:adf:cc8f:0:b0:37d:52b5:451e with SMTP id ffacd0b85a97d-3806118aa34mr24572871f8f.33.1730754566768; Mon, 04 Nov 2024 13:09:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFb/huLCOED1Mr63dAZfR2IURCjoh90EA7yGtOd0mhUxxiWmrHjOkmtwur/UtwThtJJgkiBHw== X-Received: by 2002:adf:cc8f:0:b0:37d:52b5:451e with SMTP id ffacd0b85a97d-3806118aa34mr24572851f8f.33.1730754566334; Mon, 04 Nov 2024 13:09:26 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5e7c51sm163221465e9.25.2024.11.04.13.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:25 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 59/65] qtest: allow ACPI DSDT Table changes Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Salil Mehta list changed files in tests/qtest/bios-tables-test-allowed-diff.h Reported-by: Zhao Liu Signed-off-by: Salil Mehta Message-Id: <20241103102419.202225-3-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..512d40665d 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,42 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/x86/pc/DSDT", +"tests/data/acpi/x86/pc/DSDT.acpierst", +"tests/data/acpi/x86/pc/DSDT.acpihmat", +"tests/data/acpi/x86/pc/DSDT.bridge", +"tests/data/acpi/x86/pc/DSDT.cphp", +"tests/data/acpi/x86/pc/DSDT.dimmpxm", +"tests/data/acpi/x86/pc/DSDT.hpbridge", +"tests/data/acpi/x86/pc/DSDT.hpbrroot", +"tests/data/acpi/x86/pc/DSDT.ipmikcs", +"tests/data/acpi/x86/pc/DSDT.memhp", +"tests/data/acpi/x86/pc/DSDT.nohpet", +"tests/data/acpi/x86/pc/DSDT.numamem", +"tests/data/acpi/x86/pc/DSDT.roothp", +"tests/data/acpi/x86/q35/DSDT", +"tests/data/acpi/x86/q35/DSDT.acpierst", +"tests/data/acpi/x86/q35/DSDT.acpihmat", +"tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator", +"tests/data/acpi/x86/q35/DSDT.applesmc", +"tests/data/acpi/x86/q35/DSDT.bridge", +"tests/data/acpi/x86/q35/DSDT.core-count", +"tests/data/acpi/x86/q35/DSDT.core-count2", +"tests/data/acpi/x86/q35/DSDT.cphp", +"tests/data/acpi/x86/q35/DSDT.cxl", +"tests/data/acpi/x86/q35/DSDT.dimmpxm", +"tests/data/acpi/x86/q35/DSDT.ipmibt", +"tests/data/acpi/x86/q35/DSDT.ipmismbus", +"tests/data/acpi/x86/q35/DSDT.ivrs", +"tests/data/acpi/x86/q35/DSDT.memhp", +"tests/data/acpi/x86/q35/DSDT.mmio64", +"tests/data/acpi/x86/q35/DSDT.multi-bridge", +"tests/data/acpi/x86/q35/DSDT.noacpihp", +"tests/data/acpi/x86/q35/DSDT.nohpet", +"tests/data/acpi/x86/q35/DSDT.numamem", +"tests/data/acpi/x86/q35/DSDT.pvpanic-isa", +"tests/data/acpi/x86/q35/DSDT.thread-count", +"tests/data/acpi/x86/q35/DSDT.thread-count2", +"tests/data/acpi/x86/q35/DSDT.tis.tpm12", +"tests/data/acpi/x86/q35/DSDT.tis.tpm2", +"tests/data/acpi/x86/q35/DSDT.type4-count", +"tests/data/acpi/x86/q35/DSDT.viot", +"tests/data/acpi/x86/q35/DSDT.xapic", From patchwork Mon Nov 4 21:09:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862094 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDBEED1BDF5 for ; Mon, 4 Nov 2024 21:13:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84KR-0002bi-Cn; Mon, 04 Nov 2024 16:09:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KP-0002XD-Na for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KN-0005YT-RK for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754575; 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=7G/UcAiEbF97NOsNDa77RHfmOt1VB5tcl1IhkddqXXc=; b=GodYDmvx37EvfwmVHPcuzMye9loZpAYBQJyPW1hY6xzi7OOt3VCXqW7vafQSFo/uBe6KC3 SxFMiSYGzGItVG+aG9yUt5IPtqq5LxPS54Cacb5UmrRM8C9j3imSMsY04Csxin9lzvFvjr y4GdQXNDk8nnIHYOUJZ2rOp/DOYeq9I= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-vFiNArfdPH2NfBb12sTKmQ-1; Mon, 04 Nov 2024 16:09:34 -0500 X-MC-Unique: vFiNArfdPH2NfBb12sTKmQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4316655b2f1so33020605e9.0 for ; Mon, 04 Nov 2024 13:09:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754572; x=1731359372; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7G/UcAiEbF97NOsNDa77RHfmOt1VB5tcl1IhkddqXXc=; b=qy06oPpSi6Wd+hA9AuWPrdiS1FfvULZdugJz0cyVzG9CACyxSfpngKWcInVN479cBZ h7H+J3l//0YYpiFArJlzILgvIzFkjxbk8lcH5IaCCQbYhCkUlqa8Lf6khqwI4djAm5y1 3mXMsF9nxXFGjgkb8Ps+43jU93SB4M+079LPb6JfkfDWzpMR6+yWgXCcn4nwO20El+Y/ juyys/LmlAi17rRgsyMeh15EVUg8AXmaHL6ExefSs9GYC93JcB/a33KCj67eWbO1DWg/ +UWwxJXRQMPhTbfNwZ58VGyFlU0VYtLtEu9mFrAoQ3SJv5+hO1vhKM1Ibd2zSxFNYKoj 4JMA== X-Gm-Message-State: AOJu0YzRgK3ztZAuNJCaUzTJKRAvTM/soXnFEFjqmyDkLBQ9+z0s5tnY Kr0QUkGjOqM4SPbw+IXzDMuhn3HqUZ6kbRuhneP2fjzJ9l1r8hKUzvPp3dL5KUH6XiKFZtQ+bTW uwSakDUm5sGOFvX0i5RkNgzpExNc2p0K43jnJs1/YcHVtVAh4Kpc63doC5xYxUVlFGOkDOqv3+P upPlWoJafaJgdzkhH+51VhZ9RoWoTghg== X-Received: by 2002:a05:600c:4f05:b0:431:52b7:a47e with SMTP id 5b1f17b1804b1-4327b8012a0mr138027975e9.35.1730754572087; Mon, 04 Nov 2024 13:09:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtQGDf17v6J/If1Zc4aAWJjzPQFWV4JMDjwSTDMRKI8NIZ1u1mn//m/7BLf5Ks+Zi9n0W4RA== X-Received: by 2002:a05:600c:4f05:b0:431:52b7:a47e with SMTP id 5b1f17b1804b1-4327b8012a0mr138027705e9.35.1730754571578; Mon, 04 Nov 2024 13:09:31 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9a9984sm195933715e9.32.2024.11.04.13.09.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:30 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:26 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Igor Mammedov , Ani Sinha , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu Subject: [PULL 60/65] hw/acpi: Update ACPI `_STA` method with QOM vCPU ACPI Hotplug states Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Salil Mehta Reflect the QOM vCPUs ACPI CPU hotplug states in the `_STA.Present` and and `_STA.Enabled` bits when the guest kernel evaluates the ACPI `_STA` method during initialization, as well as when vCPUs are hot-plugged or hot-unplugged. If the CPU is present then the its `enabled` status can be fetched using architecture-specific code [1]. Reference: [1] Example implementation of architecture-specific hook to fetch CPU `enabled status Link: https://github.com/salil-mehta/qemu/commit/c0b416b11e5af6505e558866f0eb6c9f3709173e Signed-off-by: Salil Mehta Message-Id: <20241103102419.202225-4-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/core/cpu.h | 1 + hw/acpi/cpu.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index e7de77dc6d..db8a6fbc6e 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -159,6 +159,7 @@ struct CPUClass { void (*query_cpu_fast)(CPUState *cpu, CpuInfoFast *value); int64_t (*get_arch_id)(CPUState *cpu); bool (*cpu_persistent_status)(CPUState *cpu); + bool (*cpu_enabled_status)(CPUState *cpu); void (*set_pc)(CPUState *cpu, vaddr value); vaddr (*get_pc)(CPUState *cpu); int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c index 9b03b4292e..23443f09a5 100644 --- a/hw/acpi/cpu.c +++ b/hw/acpi/cpu.c @@ -50,6 +50,18 @@ void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list) } } +static bool check_cpu_enabled_status(DeviceState *dev) +{ + CPUClass *k = dev ? CPU_GET_CLASS(dev) : NULL; + CPUState *cpu = CPU(dev); + + if (cpu && (!k->cpu_enabled_status || k->cpu_enabled_status(cpu))) { + return true; + } + + return false; +} + static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) { uint64_t val = 0; @@ -63,10 +75,11 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) cdev = &cpu_st->devs[cpu_st->selector]; switch (addr) { case ACPI_CPU_FLAGS_OFFSET_RW: /* pack and return is_* fields */ - val |= cdev->cpu ? 1 : 0; + val |= check_cpu_enabled_status(DEVICE(cdev->cpu)) ? 1 : 0; val |= cdev->is_inserting ? 2 : 0; val |= cdev->is_removing ? 4 : 0; val |= cdev->fw_remove ? 16 : 0; + val |= cdev->cpu ? 32 : 0; trace_cpuhp_acpi_read_flags(cpu_st->selector, val); break; case ACPI_CPU_CMD_DATA_OFFSET_RW: @@ -349,6 +362,7 @@ const VMStateDescription vmstate_cpu_hotplug = { #define CPU_REMOVE_EVENT "CRMV" #define CPU_EJECT_EVENT "CEJ0" #define CPU_FW_EJECT_EVENT "CEJF" +#define CPU_PRESENT "CPRS" void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, build_madt_cpu_fn build_madt_cpu, hwaddr base_addr, @@ -409,7 +423,9 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_append(field, aml_named_field(CPU_EJECT_EVENT, 1)); /* tell firmware to do device eject, write only */ aml_append(field, aml_named_field(CPU_FW_EJECT_EVENT, 1)); - aml_append(field, aml_reserved_field(3)); + /* 1 if present, read only */ + aml_append(field, aml_named_field(CPU_PRESENT, 1)); + aml_append(field, aml_reserved_field(2)); aml_append(field, aml_named_field(CPU_COMMAND, 8)); aml_append(cpu_ctrl_dev, field); @@ -439,6 +455,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, Aml *ctrl_lock = aml_name("%s.%s", cphp_res_path, CPU_LOCK); Aml *cpu_selector = aml_name("%s.%s", cphp_res_path, CPU_SELECTOR); Aml *is_enabled = aml_name("%s.%s", cphp_res_path, CPU_ENABLED); + Aml *is_present = aml_name("%s.%s", cphp_res_path, CPU_PRESENT); Aml *cpu_cmd = aml_name("%s.%s", cphp_res_path, CPU_COMMAND); Aml *cpu_data = aml_name("%s.%s", cphp_res_path, CPU_DATA); Aml *ins_evt = aml_name("%s.%s", cphp_res_path, CPU_INSERT_EVENT); @@ -467,13 +484,26 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, { Aml *idx = aml_arg(0); Aml *sta = aml_local(0); + Aml *ifctx2; + Aml *else_ctx; aml_append(method, aml_acquire(ctrl_lock, 0xFFFF)); aml_append(method, aml_store(idx, cpu_selector)); aml_append(method, aml_store(zero, sta)); - ifctx = aml_if(aml_equal(is_enabled, one)); + ifctx = aml_if(aml_equal(is_present, one)); { - aml_append(ifctx, aml_store(aml_int(0xF), sta)); + ifctx2 = aml_if(aml_equal(is_enabled, one)); + { + /* cpu is present and enabled */ + aml_append(ifctx2, aml_store(aml_int(0xF), sta)); + } + aml_append(ifctx, ifctx2); + else_ctx = aml_else(); + { + /* cpu is present but disabled */ + aml_append(else_ctx, aml_store(aml_int(0xD), sta)); + } + aml_append(ifctx, else_ctx); } aml_append(method, ifctx); aml_append(method, aml_release(ctrl_lock)); From patchwork Mon Nov 4 21:09:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 523D8D1BDF3 for ; Mon, 4 Nov 2024 21:11:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84L7-0003oZ-9G; Mon, 04 Nov 2024 16:10:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ka-0003Gw-02 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KW-0005Z3-Sc for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754584; 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=ZKrVDR/UpWJ0oYqjE9uR44SFMm1WCA4uOr5ewJfQ0Rs=; b=hsSO4rL23hER7j//TVywXKF+NDhnh6Ap6lTaPURVKyppvrKSkFG5VxWaZ8B6fWxYORkhAX lDuh2jrZv0snYZwDHuKY9Wdl8kA/OEKxmvX6Mbj2Z/CDqXdJ0CUnIo6cdq03p0T4q0J17f UBQBjocAZ6bl92QHw1OlyqyyduBmCBw= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-2UwP6UQMNzyJOUuwoCjuCw-1; Mon, 04 Nov 2024 16:09:41 -0500 X-MC-Unique: 2UwP6UQMNzyJOUuwoCjuCw-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d59ad50f3so2040589f8f.0 for ; Mon, 04 Nov 2024 13:09:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754577; x=1731359377; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZKrVDR/UpWJ0oYqjE9uR44SFMm1WCA4uOr5ewJfQ0Rs=; b=vN3HRPC0HM+Zx0gfV+QsxkL2CmJsfxY7r0jK7aYZEFqxVnhaxxUXa74Kpd3Pixrd0E VhostmRDqkXrTPyEgqEp3YdTDxi6J2hno/2IicJwy4aEWMjJ0bB0NzwhLcZcBmSXkzMJ 7EOOiCBqeAcE846y+DUn/cEMyvlyqmBgKl706LoAOrBW222fTUamD9N8uUKpGx+DIFG1 AlFvYwzkpnAQLPHoujlus7b5Q25gAzC5LsYa2QRFjdbsKSVN9MQ/12PoO6sUdTbi8761 n7B4ge/Yah8KQrGZn0aPgs0M4Xz04Izyc0jOD2VfMju91HcXhGa5O6IXIm0N2y9i886Q Rz8g== X-Gm-Message-State: AOJu0YwA3jeWI0f0ZRGoLSpR9QVHdiLp5YVDC5RW1VHO/nhPuy4DX3F4 XRW2tYXl90wAKap0X5odVGt2I+T/dz6GO+Hes9OlmIuk13rV+Wehf3rEus7BPJ9KEfSWxGb0HJz KFuLLJRMAE7ugFOLWFxIrJMTbQeHQYcA9Fe6X33PknOcERoP7H7gPAf/4Nt8I8o9aoBU/dfQYAF n0hEq1NFU7dGwz0F0k/fdGq2HeHcLG0g== X-Received: by 2002:adf:e84f:0:b0:37d:4956:b0c2 with SMTP id ffacd0b85a97d-3806122f97emr23133865f8f.58.1730754576476; Mon, 04 Nov 2024 13:09:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqkA5GF2dryNebq7NckDmtfEGU8EKEr0WBYy4v2Lo9+OCHPPg8+Wx+vhyHsuMaFZBi4nVxag== X-Received: by 2002:adf:e84f:0:b0:37d:4956:b0c2 with SMTP id ffacd0b85a97d-3806122f97emr23133835f8f.58.1730754575848; Mon, 04 Nov 2024 13:09:35 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d6848b5sm163928355e9.32.2024.11.04.13.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:34 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 61/65] tests/qtest/bios-tables-test: Update DSDT golden masters for x86/{pc,q35} Message-ID: <4d62d15b11909e9af121577e707b88f2e4524371.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Salil Mehta Update DSDT golden master files for x86/pc and x86/q35 platforms to accommodate changes made in the architecture-agnostic CPU AML. These updates notify the guest OS of vCPU hot-plug and hot-unplug status using the ACPI `_STA.Enabled` bit. The following is a diff of the changes in the .dsl file generated with IASL: @@ -1480,6 +1480,7 @@ CRMV, 1, CEJ0, 1, CEJF, 1, + CPRS, 1, Offset (0x05), CCMD, 8 } @@ -1514,9 +1515,16 @@ Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF) \_SB.PCI0.PRES.CSEL = Arg0 Local0 = Zero - If ((\_SB.PCI0.PRES.CPEN == One)) - { - Local0 = 0x0F + If ((\_SB.PCI0.PRES.CPRS == One)) + { + If ((\_SB.PCI0.PRES.CPEN == One)) + { + Local0 = 0x0F + } + Else + { + Local0 = 0x0D + } } Release (\_SB.PCI0.PRES.CPLK) Reported-by: Zhao Liu Signed-off-by: Salil Mehta Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 41 ------------------ tests/data/acpi/x86/pc/DSDT | Bin 8526 -> 8560 bytes tests/data/acpi/x86/pc/DSDT.acpierst | Bin 8437 -> 8471 bytes tests/data/acpi/x86/pc/DSDT.acpihmat | Bin 9851 -> 9885 bytes tests/data/acpi/x86/pc/DSDT.bridge | Bin 15397 -> 15431 bytes tests/data/acpi/x86/pc/DSDT.cphp | Bin 8990 -> 9024 bytes tests/data/acpi/x86/pc/DSDT.dimmpxm | Bin 10180 -> 10214 bytes tests/data/acpi/x86/pc/DSDT.hpbridge | Bin 8477 -> 8511 bytes tests/data/acpi/x86/pc/DSDT.hpbrroot | Bin 5033 -> 5067 bytes tests/data/acpi/x86/pc/DSDT.ipmikcs | Bin 8598 -> 8632 bytes tests/data/acpi/x86/pc/DSDT.memhp | Bin 9885 -> 9919 bytes tests/data/acpi/x86/pc/DSDT.nohpet | Bin 8384 -> 8418 bytes tests/data/acpi/x86/pc/DSDT.numamem | Bin 8532 -> 8566 bytes tests/data/acpi/x86/pc/DSDT.roothp | Bin 12319 -> 12353 bytes tests/data/acpi/x86/q35/DSDT | Bin 8355 -> 8389 bytes tests/data/acpi/x86/q35/DSDT.acpierst | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.acpihmat | Bin 9680 -> 9714 bytes .../acpi/x86/q35/DSDT.acpihmat-noinitiator | Bin 8634 -> 8668 bytes tests/data/acpi/x86/q35/DSDT.applesmc | Bin 8401 -> 8435 bytes tests/data/acpi/x86/q35/DSDT.bridge | Bin 11968 -> 12002 bytes tests/data/acpi/x86/q35/DSDT.core-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.core-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.cphp | Bin 8819 -> 8853 bytes tests/data/acpi/x86/q35/DSDT.cxl | Bin 13146 -> 13180 bytes tests/data/acpi/x86/q35/DSDT.dimmpxm | Bin 10009 -> 10043 bytes tests/data/acpi/x86/q35/DSDT.ipmibt | Bin 8430 -> 8464 bytes tests/data/acpi/x86/q35/DSDT.ipmismbus | Bin 8443 -> 8477 bytes tests/data/acpi/x86/q35/DSDT.ivrs | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.memhp | Bin 9714 -> 9748 bytes tests/data/acpi/x86/q35/DSDT.mmio64 | Bin 9485 -> 9519 bytes tests/data/acpi/x86/q35/DSDT.multi-bridge | Bin 13208 -> 13242 bytes tests/data/acpi/x86/q35/DSDT.noacpihp | Bin 8235 -> 8269 bytes tests/data/acpi/x86/q35/DSDT.nohpet | Bin 8213 -> 8247 bytes tests/data/acpi/x86/q35/DSDT.numamem | Bin 8361 -> 8395 bytes tests/data/acpi/x86/q35/DSDT.pvpanic-isa | Bin 8456 -> 8490 bytes tests/data/acpi/x86/q35/DSDT.thread-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.thread-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm12 | Bin 8961 -> 8995 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm2 | Bin 8987 -> 9021 bytes tests/data/acpi/x86/q35/DSDT.type4-count | Bin 18589 -> 18623 bytes tests/data/acpi/x86/q35/DSDT.viot | Bin 14612 -> 14646 bytes tests/data/acpi/x86/q35/DSDT.xapic | Bin 35718 -> 35752 bytes 42 files changed, 41 deletions(-) diff --git a/tests/data/acpi/x86/pc/DSDT b/tests/data/acpi/x86/pc/DSDT index 8b8235fe79e2fa08a6f840c8479edb75f5a047b9..f68a32e6068788c3fdfaff139206b725ba2bf1d1 100644 GIT binary patch delta 125 zcmX@-^udYCCD*Nn-PWAb`lQ#13)G5RbZ4FS%c1_42?!C<8eq%ehD{TK_l_!Abg7I5)y J{>vLE3;@@vBVGUi delta 76 zcmez1bk2#(CD@o=P99EwyZB(I_~<5&$!B=t7&Rtq^C~bgFi#HR)nM{9 go?OFg#^%B1930{}*^W<-i6LR~e_rX$3VZ>=07R=4p8x;= diff --git a/tests/data/acpi/x86/pc/DSDT.acpierst b/tests/data/acpi/x86/pc/DSDT.acpierst index 06829b9c6c6d726d955dc7c99bc9f42448e22aeb..0fd79699ebbfb650a5bbe49faecbebf2fc13a86c 100644 GIT binary patch delta 125 zcmezBINgcMCDP99E2$M|5U_~<6z$!B=t7LiIrkL{mgm^&kKM0kW|QxeN(UK3`KpUt5AmlgtcW0VtCz4Ilyl1Cvq> iC<0A0lY9*}21o`&Q&d5dJ`OGd0AQ2<4I8r{4)+pssulqN diff --git a/tests/data/acpi/x86/pc/DSDT.acpihmat b/tests/data/acpi/x86/pc/DSDT.acpihmat index 2fe355ebdbb858fa9247d09112e21712e3eddc45..a4dd09e5ef71a47c31be0d9a57e93767f5d15b3c 100644 GIT binary patch delta 108 zcmezEGuM~PCD fC<075lY9+90!RjvzYR5$3l18Skq{NLKn`6P2n`eu diff --git a/tests/data/acpi/x86/pc/DSDT.bridge b/tests/data/acpi/x86/pc/DSDT.bridge index 4d4067c182a6625db1e877408eb7436113884b50..7ef58152d281c1e2c8da5b15bd30f23e61439d69 100644 GIT binary patch delta 125 zcmZ2lalC@dCD*Nn-PWAb`lQ#13)G5RbZ4FS%c1_42?!C<8eq%ehD{TK_l_!Abg7I5)y J{>!VO2LR(fBWeHu delta 76 zcmX?Jv9yBACD43t0=ecoQZs5D?w$ I&v#w~08Tv}v;Y7A delta 69 zcmV-L0J{IcMxI6rL{mgm9wPt%0nM=rxeN(UTVGQ`Ut5AmlgtcW0VtCz4Ilyl1Cvq> bC<0ATlY9+w0!Rjv@C`MSJPsPOTn^+E!a5Wv diff --git a/tests/data/acpi/x86/pc/DSDT.dimmpxm b/tests/data/acpi/x86/pc/DSDT.dimmpxm index 205219b99d903555125c4b07fc047c42993eb338..34fe3fcad9dc245eb173ca5a9655d17f15bd42ef 100644 GIT binary patch delta 103 zcmX@&|IDAuCD4FZB(gTYECOYupwE@Um>;@xb*H$f5r Dad91& delta 96 zcmaFnf5e~5CDz&#S=1z&tsPSA)sT zb@Bw>NG1=q$**}$rKBdu=(B*-1~_{f1O&MTI|sP>F&1#~Crp+X5Z#=^S0xDmhw>Y! diff --git a/tests/data/acpi/x86/pc/DSDT.hpbridge b/tests/data/acpi/x86/pc/DSDT.hpbridge index 8fa8b519ec65bd5099c45f4e1c85b11b47a23845..33c7529f5c8a6ec651f979b3cebadb18774a781f 100644 GIT binary patch delta 125 zcmbR1wBL!#CD*Nn-PWAb`lQ#13)G5RbZ4FS%c1_42?!C<8eq%ehD{TK_l_!Abg7I5)y J{>!T%3;?JoBF+E+ delta 76 zcmdn*G}npCCD3`4>KsmU?=EFdib&YlJVL9W5h0j_?G1zh}_FY)|j0{}jp B8;bw{ diff --git a/tests/data/acpi/x86/pc/DSDT.ipmikcs b/tests/data/acpi/x86/pc/DSDT.ipmikcs index 0ca664688b16baa3a06b8440181de4f17511c6b0..688faf83cbd7395e1112ba04303d66e11934bf8d 100644 GIT binary patch delta 125 zcmbQ{yu+ExCD*Nn-PWAb`lQ#13)G5RbZ4FS%c1_42?!C<8eq%ehD{TK_l_!Abg7I5)y J{>wX47yyb?BK!aV delta 76 zcmV-S0JHzNLzY7dL{mgmmLUKD0p+m@xeN(UK3`KpUt5AmlgtcW0VtCz4Ilyl1Cvq> iC<0A0lY9*}21o`&Q&d5dJ`OGd0AQ2<4I8r{4ww^F-xWOo diff --git a/tests/data/acpi/x86/pc/DSDT.memhp b/tests/data/acpi/x86/pc/DSDT.memhp index 03ff464ba4e72082fce0921815cfc09ca20b561a..6ede4361f4b7bf18c496d7ca117310675126bbbf 100644 GIT binary patch delta 125 zcmbR1yWf|~CD_Are@}oWAs@-8Uma>4FZB(gTYD{NMQ=Q`Y{%8@h2=~E#Tta J{Firu1OUv#BbopJ delta 76 zcmV-S0JHzUO`S~&L{mgmohASP0b8*OxeN(KKVMTqUt5AmlgtcW0VtCz4Ilyl1Cvq> iC;~$?lY9*}21o`&Q&d5dJ`OGd0AQ2<4I8r{4xbo4h!ooZ diff --git a/tests/data/acpi/x86/pc/DSDT.nohpet b/tests/data/acpi/x86/pc/DSDT.nohpet index b081030f0ed171e52b13e28cfdc8770a04c2806e..9d6040733f57f243056ee8f7601af84dd3cf2fa2 100644 GIT binary patch delta 125 zcmX@$_{fpVCDP99Eo$M|5U_~<6z$!B=t7S?YsTctF?l_&shRoY7=0Fyh5%<(CD0CDAX8JH%| zmegSKGM#)>(u~QKWAa}~Q!(?&G5RbZ4FS%c1_42?!Cn7P1y_@g_{(C?mQ# IQOb!80A}|c$^ZZW delta 76 zcmX@=xY&`)CDu1FqxnWIc1ccuyZB(I_~<5&$x@PWj2e?GB^8($m?tlg)L`;8 go_tEujLn11IXJ{|a*vcA6GOseUn%L$c~aqQ02K=qHUIzs diff --git a/tests/data/acpi/x86/q35/DSDT.acpierst b/tests/data/acpi/x86/q35/DSDT.acpierst index 46fd25400b7c00ee9149ddb64cb5d5bd73f6a82b..f91cbe55fcfeea319babf7c9a0c6a6ccdc3320d1 100644 GIT binary patch delta 108 zcmdnuc+HW^CDAX8JH%| zmegSKGM#)>(u~QKWAa}~Q!(?&G5RbZ4FS%c1_42?!Cn7P1y_@g_{(C?mQ# IQ7V`X09c|Ot^fc4 delta 76 zcmccSxW$pnCD2b8v{`AX8JH%| zmegSKw4Qua(vj1Z!#Oy_kuzF(vZ9Re*F7d%m@zG5llcgl%7&RtWN-8ihFi&0}slnu9 zIr)^NBa;W)WL_y#DXGaZ`Ya%|0nVNV0YR?8&H=7|j0If$36mXVL^tL{mgmx*-4n0ll#b2N?-QP+wC*Ut5AmlNuRb0VtDs86W}x1CyW` iC;~)9lgb%c21o`&Q&d5duNp1_0AQ1F8XL2b8cPRMBNdqd diff --git a/tests/data/acpi/x86/q35/DSDT.applesmc b/tests/data/acpi/x86/q35/DSDT.applesmc index 944209adeaa5bbb722431161c404cb51b8209993..a5d032b7d96113c9393036b2ba831adb6d584142 100644 GIT binary patch delta 108 zcmccU_}P)mCDAX8JH%| zmegSKGM#)>(u~QKWAa}~Q!(?&G5RbZ4FS%c1_42?!Cn7P1y_@g_{(C?mQ# IQL2Cq0GY8KasU7T delta 76 zcmezDc+ru|CDQ`zV&nCD4FZB(gTYEC8%jyDEo3d=;!T*mQATug IqEx&H0I`T3t^fc4 delta 76 zcmaD9dmxs}CD>Gcqtu zo+GKj)E>0?nB-%qo delta 71 zcmV-N0J#5?W$|PRL{mgmaWVh^0k5$N2N?>DTLE8FLSI{gNRt~GUI8eRdKn-B00Wbu d87KmZP_xS!vjPH029tmsHIvL78nf&irxpI;78U>i diff --git a/tests/data/acpi/x86/q35/DSDT.core-count2 b/tests/data/acpi/x86/q35/DSDT.core-count2 index 3a0cb8c581c8cc630a2ec21712b7f8b75fcad1c8..d29a7108f82110ce9f9b4e006501215d41c5420a 100644 GIT binary patch delta 126 zcmaFW&eYSv#N`s~62jBMz`*FVk&9iDtD}@HKG-Qfy2*F4v}7Ek?&K;-1$O6vpkPJ@ zrpa?8HJBQ*HXoCW=izkaa1IV}>&YlJVL9W4I aos*;0q}dj-7I5(llNU;A zFg0gvJ}nu~!{os>Sx3!ON@{Y9J_|^3fU~DTK#*&&bAYQKV*wX`!sJ8^(ames;$s1w CTO4Nq diff --git a/tests/data/acpi/x86/q35/DSDT.cphp b/tests/data/acpi/x86/q35/DSDT.cphp index 20955d0aa30120553da35d5a6640055d26255cf9..7fd59bf6702c04a622f05ae356a2ea37312ab403 100644 GIT binary patch delta 108 zcmezDGS!vKCDQ!(?&G5RbZ4FS%c1_42?!CzZ%vD0Bsc$ diff --git a/tests/data/acpi/x86/q35/DSDT.cxl b/tests/data/acpi/x86/q35/DSDT.cxl index 3c34d4dcab16783abe65f6fa5e64eb69d40795fb..613a40b957dab99fd97b465bd89f6afac3a5b047 100644 GIT binary patch delta 108 zcmcbW_9uAX8JH%| zmegSKGM#)>(u~QKWAa}~Q!(?&G5RbZ4FS%c1_42?!Cn7P1y_@g_{(C?mQ# IQR=4z0JAtBNdN!< delta 76 zcmey9b}Nm`CDAX8JH%o zm(*Z#cAtDxGLp@e!#Oy_aq>bbJxhj!1?H1u^jSdq0-QY!0)kwF!8#U5VG6tYF&1#~ QCoE(w;NsofBsHA}0HD?-HUIzs delta 91 zcmdn(H`9;HCDNE4v?QlTKzy)Md~}n?WIf3^Mvck6k_t==%#*iBYB0IE tPQE7@$>hN{*;2|>QfhLHJ_|@~fU~DTK#*&&bAYQKV*wZc<|R_oc>rS!7_9&R diff --git a/tests/data/acpi/x86/q35/DSDT.ipmibt b/tests/data/acpi/x86/q35/DSDT.ipmibt index 45f911ada5645f158f3d6c0c430ec1d52cadc5d8..25f43ae8efb55364a739e6b5e3cb4e71e61862b0 100644 GIT binary patch delta 108 zcmaFoIKhd_CDAX8JH%| zmegSKGM#)>(u~QKWAa}~Q!(?&G5RbZ4FS%c1_42?!Cn7P1y_@g_{(C?mQ# IQL2{>06xVXs{jB1 delta 76 zcmbQ>^v;pXCD`WA;Wac1ccuyZB(I_~<5&$x@PWj2e?GB^8($m?tlg)L`;8 go_tEujLn11IXJ{|a*vcA6GOseUn%L$c~Xnm06Z5J7XSbN diff --git a/tests/data/acpi/x86/q35/DSDT.ipmismbus b/tests/data/acpi/x86/q35/DSDT.ipmismbus index e5d6811bee1233d74236453c49060390d74d4416..32bcd25bda9e9d2775790385f8da6a11e9d5cb46 100644 GIT binary patch delta 108 zcmezEIM<2GCD02)FaPyhe` delta 76 zcmV-S0JHy{Li<4qL{mgm`yc=S0o<_)2N?-ZK3`KpUt5AmlNuRb0VtDs86W}x1CyW` iC<0A0lgb%321o`&Q&d5dj2bQi0AQ0%8XL228m|Uoloh-H diff --git a/tests/data/acpi/x86/q35/DSDT.ivrs b/tests/data/acpi/x86/q35/DSDT.ivrs index 46fd25400b7c00ee9149ddb64cb5d5bd73f6a82b..f91cbe55fcfeea319babf7c9a0c6a6ccdc3320d1 100644 GIT binary patch delta 108 zcmdnuc+HW^CDAX8JH%| zmegSKGM#)>(u~QKWAa}~Q!(?&G5RbZ4FS%c1_42?!Cn7P1y_@g_{(C?mQ# IQ7V`X09c|Ot^fc4 delta 76 zcmccSxW$pnCD2b8v{`50iyCkQ(V|=hvd~}oVWGTrwM%~Gkk_zn30YSlx3`~<} zOKLDVm`y$^X~yKrG5N2gshIiX7=0Fyh5%66_M9ugbu{sJ)SkU6Rw?F+SKSKDxTqweHNNd4FZB(gTYEC8%jyDEo3d=;!T*mQATug IqLjHL0EhJ+B>(^b delta 76 zcmdm$J|msWCDNGPy72LuH(GB8c{ zlh9!DGM!u@VaDXjF?oZ8shRoY7=0Fyh5%u-bvkCDnCDoVSr39y=V|=hvd~}oVAX8JH&X zN@_59nNBvBG-Gn*n4B+ZYGyt;MxOBc1ccm$M|5U_~<6z$x@PWjJlI6B^B761A>AX8JH%| zmegQ!Fq?c-(u~QKWAa}~Q!(?&G5RbZ4FS%c1_42?!Cn7P1y_@g_{(C?mQ# IQObi207+UMdH?_b delta 76 zcmX@@xYCi!CD2b8v{`TqweHNNdUP0Qtck6951J delta 76 zcmZ4G)ZxVC66_Mfp~%3%_;Mo`yCkQ-U3{=pd~}n?WGTrwMvcjpk_t==%##;LYB2d4 gPd+7S#^%B1930{}xkpNmi6LRKuaxxWJgGfw010Fie*gdg diff --git a/tests/data/acpi/x86/q35/DSDT.thread-count b/tests/data/acpi/x86/q35/DSDT.thread-count index a24b04cbdbf09383b933a42a2a15182545543a87..08f5d5f54bcb61235b98fc85bb814046dd038c13 100644 GIT binary patch delta 110 zcmeyEGC7sYCD>Gcqtu zo+GKj)E>0?nB-%qo delta 71 zcmV-N0J#5?W$|PRL{mgmaWVh^0k5$N2N?>DTLE8FLSI{gNRt~GUI8eRdKn-B00Wbu d87KmZP_xS!vjPH029tmsHIvL78nf&irxpI;78U>i diff --git a/tests/data/acpi/x86/q35/DSDT.thread-count2 b/tests/data/acpi/x86/q35/DSDT.thread-count2 index 3a0cb8c581c8cc630a2ec21712b7f8b75fcad1c8..d29a7108f82110ce9f9b4e006501215d41c5420a 100644 GIT binary patch delta 126 zcmaFW&eYSv#N`s~62jBMz`*FVk&9iDtD}@HKG-Qfy2*F4v}7Ek?&K;-1$O6vpkPJ@ zrpa?8HJBQ*HXoCW=izkaa1IV}>&YlJVL9W4I aos*;0q}dj-7I5(llNU;A zFg0gvJ}nu~!{os>Sx3!ON@{Y9J_|^3fU~DTK#*&&bAYQKV*wX`!sJ8^(ames;$s1w CTO4Nq diff --git a/tests/data/acpi/x86/q35/DSDT.tis.tpm12 b/tests/data/acpi/x86/q35/DSDT.tis.tpm12 index e381ce4cbf2b11f56a2d0537db4d21acc97450c9..29a416f0508655d2bfde01fff4d25ad7f89581d9 100644 GIT binary patch delta 108 zcmZp4TkOW=66_M9tjxf`xML$1yCkQhV|=hvd~}oVWGTrwM%~Gkk_zn30YSlx3`~<} zOKLEAnNB_`X~yKrG5N2gshIiX7=0Fyh5%TqsHV)Nd+bb=E(~rHJE&j gC!dluWAk8h4i0gg+#{vO#E>xAS4w(wp43(j0Oqn2?EnA( diff --git a/tests/data/acpi/x86/q35/DSDT.tis.tpm2 b/tests/data/acpi/x86/q35/DSDT.tis.tpm2 index a09253042ce4a715922027245de8a2ab7449c5b7..59288f02c43cf2efc1555599131fde05dbbaa1cd 100644 GIT binary patch delta 108 zcmbR3w%3izCD0PFk|4*&oF diff --git a/tests/data/acpi/x86/q35/DSDT.type4-count b/tests/data/acpi/x86/q35/DSDT.type4-count index edc23198cdb47a981bcbc82bc8e392b815abb554..eaca76e8e61eb62f75dbdf093e803eea34330deb 100644 GIT binary patch delta 135 zcmbO`k#YY-MlP3NmyrD)3=E928@bpexw;Q9#RogZM>qLSmX?fT)SX-*k8bjqEG-$ws4=-pQh|wqdGbO@ z4W_oun@>xgW@Yzaa}Ex1 J&CCjWGytMf9?Ad! diff --git a/tests/data/acpi/x86/q35/DSDT.viot b/tests/data/acpi/x86/q35/DSDT.viot index 4c93dfd5c4b362714d3f9aa606a838d4625b3369..de0942a13dc65b75e78e66ee8df904b31bf6079a 100644 GIT binary patch delta 108 zcmbPIw5^ECCDQ1hbRA6@w2nuFo zV46HfQiG}I@#bTar+L|2Ih=z-94Be$Su!LnFrOTw&jQjH;OuD-5ab#R*0DeeQ`psy Tv4D#|VIgY)7w_hW>PwRWojNEz delta 107 zcmZ26ovCd)6PHV{OGsNc0|VpRja=-KTupD;;)9*yqnkV?OH0NvYD}(@RA6FYp1e>} zgQ@@F=F^g=dD%VKoP$FgIVU%2h)=fC5R+j@SRgeyMxO1bj(qsVVzaPi| diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index 512d40665d..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,42 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/x86/pc/DSDT", -"tests/data/acpi/x86/pc/DSDT.acpierst", -"tests/data/acpi/x86/pc/DSDT.acpihmat", -"tests/data/acpi/x86/pc/DSDT.bridge", -"tests/data/acpi/x86/pc/DSDT.cphp", -"tests/data/acpi/x86/pc/DSDT.dimmpxm", -"tests/data/acpi/x86/pc/DSDT.hpbridge", -"tests/data/acpi/x86/pc/DSDT.hpbrroot", -"tests/data/acpi/x86/pc/DSDT.ipmikcs", -"tests/data/acpi/x86/pc/DSDT.memhp", -"tests/data/acpi/x86/pc/DSDT.nohpet", -"tests/data/acpi/x86/pc/DSDT.numamem", -"tests/data/acpi/x86/pc/DSDT.roothp", -"tests/data/acpi/x86/q35/DSDT", -"tests/data/acpi/x86/q35/DSDT.acpierst", -"tests/data/acpi/x86/q35/DSDT.acpihmat", -"tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator", -"tests/data/acpi/x86/q35/DSDT.applesmc", -"tests/data/acpi/x86/q35/DSDT.bridge", -"tests/data/acpi/x86/q35/DSDT.core-count", -"tests/data/acpi/x86/q35/DSDT.core-count2", -"tests/data/acpi/x86/q35/DSDT.cphp", -"tests/data/acpi/x86/q35/DSDT.cxl", -"tests/data/acpi/x86/q35/DSDT.dimmpxm", -"tests/data/acpi/x86/q35/DSDT.ipmibt", -"tests/data/acpi/x86/q35/DSDT.ipmismbus", -"tests/data/acpi/x86/q35/DSDT.ivrs", -"tests/data/acpi/x86/q35/DSDT.memhp", -"tests/data/acpi/x86/q35/DSDT.mmio64", -"tests/data/acpi/x86/q35/DSDT.multi-bridge", -"tests/data/acpi/x86/q35/DSDT.noacpihp", -"tests/data/acpi/x86/q35/DSDT.nohpet", -"tests/data/acpi/x86/q35/DSDT.numamem", -"tests/data/acpi/x86/q35/DSDT.pvpanic-isa", -"tests/data/acpi/x86/q35/DSDT.thread-count", -"tests/data/acpi/x86/q35/DSDT.thread-count2", -"tests/data/acpi/x86/q35/DSDT.tis.tpm12", -"tests/data/acpi/x86/q35/DSDT.tis.tpm2", -"tests/data/acpi/x86/q35/DSDT.type4-count", -"tests/data/acpi/x86/q35/DSDT.viot", -"tests/data/acpi/x86/q35/DSDT.xapic", From patchwork Mon Nov 4 21:09:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B755D1BDF2 for ; Mon, 4 Nov 2024 21:11:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Kp-0003Nq-NC; Mon, 04 Nov 2024 16:10:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KY-0003Ee-Fu for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84KW-0005Z1-SA for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754583; 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=AQTkTMJNMys2h5iun+ZazOJo/CN0SrCjY67C1wqtHGY=; b=LXCZDZ/Uj+xqGE/WzEEvxwzZ+xkse0awsbo9bwmGfMdyW9pwaM53FtYMZFTCLt1nwFaaXg 3b5iWAi4XEcBAgedzDILrBabw4Mx9kKcjXxkKrFpqi1QG9o9d5VV7D+9R4qsZylSgpV7QC vYwHIPNME0ZdLSf0w6aS1a39JjHtpw4= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-66NB40E9M1imQR2TFofaKA-1; Mon, 04 Nov 2024 16:09:42 -0500 X-MC-Unique: 66NB40E9M1imQR2TFofaKA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-43151e4ef43so32901025e9.3 for ; Mon, 04 Nov 2024 13:09:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754581; x=1731359381; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AQTkTMJNMys2h5iun+ZazOJo/CN0SrCjY67C1wqtHGY=; b=AddX/6IgRpdnbn+TrttCW+Sw7UogLni7+yJFefLHk7UcRzw3obUzDLjXNnKa5HjTkj dd+lRWvA7UZ9xehZVYe12ADPHjkNHhBpi8XaxgNIMA5/iCCHCbNuiRFaO0WSnlxZ9GX3 Xjkp+h9SioCwllVOrkAixcFMO1vnl0kw0ZCyK/ADZPVSnlqdQucgpR0j8PlmF+RXs4xN mEbfoc4LFn2PuxvRI6MaVewX9TAd9zAeZSjGGPcHAVKOPCIdQWU9d5YHIORlNu9QZLT+ OBjXAErbEoDpKwQ1aA86mK4SeMP3UIaErIbT+F7F2VHtaAXi++n9nkGKwZOpg8rNYHJR 3Ksg== X-Gm-Message-State: AOJu0Yws0xbpm+3SYYrGtAP6VdygmexGulbQGPIp5+WbOEAaH0SWs3oX cSHGY2P06+P4XF6RSMfdKmLyqiTDi+t+uF9KJGS5T0taMvI125qzN4kj0sOnwNiuvuFvQbGgx9p f/3VpAvdwhaGCLnuxjsXy/w6FtraL5ZhmID1ski9HqvuVkyhenMFePw7M/rya4y12ncPvWCeKpp olFNy90ny7ZBabwoI+2BNsyAAgYS4m3w== X-Received: by 2002:a05:600c:a08:b0:431:4a83:2d80 with SMTP id 5b1f17b1804b1-4327b6c1c78mr160758655e9.0.1730754580931; Mon, 04 Nov 2024 13:09:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IE04MBj7tzcnxqiDhI0MsRUr328JQxLz6fQVdxnWS9xfKUi9yWsX/mJKLXgdipZzAPkN8y7XQ== X-Received: by 2002:a05:600c:a08:b0:431:4a83:2d80 with SMTP id 5b1f17b1804b1-4327b6c1c78mr160758445e9.0.1730754580468; Mon, 04 Nov 2024 13:09:40 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd8e7d23sm193221125e9.7.2024.11.04.13.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:38 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:36 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Salil Mehta , Igor Mammedov , Ani Sinha Subject: [PULL 62/65] hw/acpi: Update GED with vCPU Hotplug VMSD for migration Message-ID: <65fb66980d3a918ebe1e665cf6ae4ceb8dea2db1.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Salil Mehta The ACPI CPU hotplug states must be migrated along with other vCPU hotplug states to the destination VM. Update the GED's VM State Description (VMSD) table subsection to conditionally include the CPU Hotplug VM State Description (VMSD). Excerpt of GED VMSD State Dump at Source: "acpi-ged (16)": { "ged_state": { "sel": "0x00000000" }, [...] "acpi-ged/cpuhp": { "cpuhp_state": { "selector": "0x00000005", "command": "0x00", "devs": [ { "is_inserting": false, "is_removing": false, "ost_event": "0x00000000", "ost_status": "0x00000000" }, [...] { "is_inserting": false, "is_removing": false, "ost_event": "0x00000000", "ost_status": "0x00000000" } ] } } }, Signed-off-by: Salil Mehta Message-Id: <20241103102419.202225-6-salil.mehta@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/acpi/generic_event_device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index d00f5a6c1c..663d9cb093 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -331,6 +331,24 @@ static const VMStateDescription vmstate_memhp_state = { } }; +static bool cpuhp_needed(void *opaque) +{ + MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); + + return mc->has_hotpluggable_cpus; +} + +static const VMStateDescription vmstate_cpuhp_state = { + .name = "acpi-ged/cpuhp", + .version_id = 1, + .minimum_version_id = 1, + .needed = cpuhp_needed, + .fields = (VMStateField[]) { + VMSTATE_CPU_HOTPLUG(cpuhp_state, AcpiGedState), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_ged_state = { .name = "acpi-ged-state", .version_id = 1, @@ -379,6 +397,7 @@ static const VMStateDescription vmstate_acpi_ged = { }, .subsections = (const VMStateDescription * const []) { &vmstate_memhp_state, + &vmstate_cpuhp_state, &vmstate_ghes_state, NULL } From patchwork Mon Nov 4 21:09:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862062 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1919CD1BDF2 for ; Mon, 4 Nov 2024 21:10:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84L5-0003lI-U2; Mon, 04 Nov 2024 16:10:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ke-0003Lj-6C for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Ka-0005ZU-Tk for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754588; 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=dEdkjWiHP5L8rCz25+/APfjLDFkHVovlyOsZHlqQfEA=; b=LpW2rt4LjHcNsPTylSRWjDMTCoIflwbzyEfjcJJWOTb+o7aOwSnTT4hmsVgqlFuaqgPFmG JBIaN4Np30ZcN2Zmkv3JHv3NRzoi0MEtCWERo5rpcpaVic/KPtbnEoKqytP9obEgtHJ45U AO7wjydfn5ydE/YYuT8eTOtinAu424k= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-skrIC0ZoOcqn3eCL1WwXEA-1; Mon, 04 Nov 2024 16:09:47 -0500 X-MC-Unique: skrIC0ZoOcqn3eCL1WwXEA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4315f48bd70so32910175e9.2 for ; Mon, 04 Nov 2024 13:09:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754585; x=1731359385; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dEdkjWiHP5L8rCz25+/APfjLDFkHVovlyOsZHlqQfEA=; b=d6IpyC21tyC473I4g4KuSQyTovTx3y9TQUAPY0n5FHac6Utg3tydZzEs5ZecLw5qE4 K42hRpRd1J04bMoBEA1oFpYtyaKaq2Q5Dct4+GSv4rQ0xMRk+x4weL9gRwPUxYxNPwTs Mu8hyLwyVmuEvC8iyo5L1g8KZFb6MVlvKAPy2EIvpnmNEORxgAbm0OCvnFH9VbkSRKtg s5kLIyRqCw3aK0Q9Sn2kSvy6ViV4pAR3zz+2XCCOaaNgMfezQFHz07u5pXIujNOvAxci gFC+CA7NPFlOWSrlNg0J3yVPBNKPq4ATlodPKEIUU1P/x8zA9iR+uot5Nipxba72qQ2y Q5Sg== X-Gm-Message-State: AOJu0YzMA+t2BqhoLxvJ/J6MIKe7YBas09JzaxUKIc90+Rt44hXNl0Bz HJSaxS+6Fb8uXi6JrdQrNOX3XiDa3FQofvAG5M77AixdjbKKR+2JcExXBoEicKHC4rc0LoyHzsU fpxuh96Eq9Kf06KbtQ0sIlUesw8hoftKvE7F1x4S1tDrYgU2kUB55aHiKSWyxj8N5InhyGhQkMN tBv2dUzRV0P8wYcLIovoNQYmDkIAw0mw== X-Received: by 2002:a05:600c:1c28:b0:431:55af:a22f with SMTP id 5b1f17b1804b1-4327b6f950fmr151215135e9.13.1730754585498; Mon, 04 Nov 2024 13:09:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYUvvajy/IyjMXtvvwGY4IBBvJM8VI3THCroLWnMaQ4x2mCxJfcno+4sD27Iws7y331399Eg== X-Received: by 2002:a05:600c:1c28:b0:431:55af:a22f with SMTP id 5b1f17b1804b1-4327b6f950fmr151214885e9.13.1730754585030; Mon, 04 Nov 2024 13:09:45 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-432a27456a0sm512215e9.1.2024.11.04.13.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:44 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Yi Liu , Jason Wang , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 63/65] intel_iommu: Send IQE event when setting reserved bit in IQT_TAIL Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhenzhong Duan According to VTD spec, Figure 11-22, Invalidation Queue Tail Register, "When Descriptor Width (DW) field in Invalidation Queue Address Register (IQA_REG) is Set (256-bit descriptors), hardware treats bit-4 as reserved and a value of 1 in the bit will result in invalidation queue error." Current code missed to send IQE event to guest, fix it. Fixes: c0c1d351849b ("intel_iommu: add 256 bits qi_desc support") Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan Message-Id: <20241104125536.1236118-2-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 8612d0917b..1ecfe47963 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2847,6 +2847,7 @@ static void vtd_handle_iqt_write(IntelIOMMUState *s) if (s->iq_dw && (val & VTD_IQT_QT_256_RSV_BIT)) { error_report_once("%s: RSV bit is set: val=0x%"PRIx64, __func__, val); + vtd_handle_inv_queue_error(s); return; } s->iq_tail = VTD_IQT_QT(s->iq_dw, val); From patchwork Mon Nov 4 21:09:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862093 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2BFCD1BDF4 for ; Mon, 4 Nov 2024 21:13:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84LD-0004QM-6x; Mon, 04 Nov 2024 16:10:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Kk-0003NE-Nf for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:10:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Kg-0005Zk-T7 for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754593; 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=dzFkROmFdJe52AC5ysZ9LBrP/VNzK7ogDHbPLODaOPM=; b=eA64CMmJCQfNxzUer8CjiUOBZ3uN3NJzjTMQyFIICfa3IDppQIrD4MUu6tDFDLNgMUao1T wZVXwg0E09r5JhWLJHztFuSM2eYJAnXyEi6qGGZMspqx/DAgcR27YcZtF12oDb+hHDwZus 2m0AQU6AAbqLOGwxORcX2/mvLPYB5vo= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-vxglU6KxOne1YRjEhih7Mw-1; Mon, 04 Nov 2024 16:09:51 -0500 X-MC-Unique: vxglU6KxOne1YRjEhih7Mw-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d4922d8c7so2475376f8f.1 for ; Mon, 04 Nov 2024 13:09:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754589; x=1731359389; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dzFkROmFdJe52AC5ysZ9LBrP/VNzK7ogDHbPLODaOPM=; b=s52hXqU7neo4mS9cmhYY6e3zZFA8Fcqrj7M6DtDHv+gufqfKXO54AAHk0vJSiRD4QQ My+omcRELVxJfr1mRJmh80IrUvHWwiiTtv4xxCJjL83AieLSnoWf+0/0vkX6uMuObPY5 WjfukpAfgouCIOPq/1SEPp3aGk4uIPoJUvYqFZs6SjgX/IzdzyOVM3XBAcC8NAY4+zWq xuHW/J8hTtv3vJ70iuJ65BuKxSNAtnG7/roYBgy9dLAUqM7KkKof9Jk4VpD42x+I5syg Uj3KpjPK6zqXJGsgFQe5CWe28mGPGviGxOD33KwnwNioJttzpFki3iuM+byoaVpc9jtG 5a7w== X-Gm-Message-State: AOJu0Yw25KgjQecEKUSh0zdKvT+zWtly7jhP3q8uhnQxN8e8l9Fesimk P5P1oM6XVSmHk8e9xl0sMDJRbufep1caTKCopohP/zTglGF+QQf9czincsCEcbSbFOBy/c0emM/ zlHwSVRoNIHRS6mgd5RH2OmKkVm92KLxjwWMdYhL9jszVEWYEoNept0lqEqciF+q4OBV1h1A/6M ygrcBSrjcfQq4xR2Mz1zX33enCGnBmdw== X-Received: by 2002:a05:6000:4817:b0:37d:4fe9:b6a4 with SMTP id ffacd0b85a97d-381c7ab30a6mr11627752f8f.50.1730754588873; Mon, 04 Nov 2024 13:09:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGE6a+VqcVsRwGLmx5QyvOv9zLiKNfSd7LMWbLEfrC1IWoBqXwZajSOHNqqSb20Jnmc0kpdfA== X-Received: by 2002:a05:6000:4817:b0:37d:4fe9:b6a4 with SMTP id ffacd0b85a97d-381c7ab30a6mr11627733f8f.50.1730754588503; Mon, 04 Nov 2024 13:09:48 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4327d5ab305sm165233995e9.7.2024.11.04.13.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:48 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:45 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Yi Liu , Jason Wang , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 64/65] intel_iommu: Add missed sanity check for 256-bit invalidation queue Message-ID: <8e761fb61cafa95f4f41acaf8e86fae7e898b555.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhenzhong Duan According to VTD spec, a 256-bit descriptor will result in an invalid descriptor error if submitted in an IQ that is setup to provide hardware with 128-bit descriptors (IQA_REG.DW=0). Meanwhile, there are old inv desc types (e.g. iotlb_inv_desc) that can be either 128bits or 256bits. If a 128-bit version of this descriptor is submitted into an IQ that is setup to provide hardware with 256-bit descriptors will also result in an invalid descriptor error. The 2nd will be captured by the tail register update. So we only need to focus on the 1st. Because the reserved bit check between different types of invalidation desc are common, so introduce a common function vtd_inv_desc_reserved_check() to do all the checks and pass the differences as parameters. With this change, need to replace error_report_once() call with error_report() to catch different call sites. This isn't an issue as error_report_once() here is mainly used to help debug guest error, but it only dumps once in qemu life cycle and doesn't help much, we need error_report() instead. Fixes: c0c1d351849b ("intel_iommu: add 256 bits qi_desc support") Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan Message-Id: <20241104125536.1236118-3-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 80 ++++++++++++++++++++++++---------- 2 files changed, 59 insertions(+), 22 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 2f9bc0147d..75ccd501b0 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -356,6 +356,7 @@ union VTDInvDesc { typedef union VTDInvDesc VTDInvDesc; /* Masks for struct VTDInvDesc */ +#define VTD_INV_DESC_ALL_ONE -1ULL #define VTD_INV_DESC_TYPE(val) ((((val) >> 5) & 0x70ULL) | \ ((val) & 0xfULL)) #define VTD_INV_DESC_CC 0x1 /* Context-cache Invalidate Desc */ diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 1ecfe47963..2fc3866433 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2532,15 +2532,51 @@ static bool vtd_get_inv_desc(IntelIOMMUState *s, return true; } +static bool vtd_inv_desc_reserved_check(IntelIOMMUState *s, + VTDInvDesc *inv_desc, + uint64_t mask[4], bool dw, + const char *func_name, + const char *desc_type) +{ + if (s->iq_dw) { + if (inv_desc->val[0] & mask[0] || inv_desc->val[1] & mask[1] || + inv_desc->val[2] & mask[2] || inv_desc->val[3] & mask[3]) { + error_report("%s: invalid %s desc val[3]: 0x%"PRIx64 + " val[2]: 0x%"PRIx64" val[1]=0x%"PRIx64 + " val[0]=0x%"PRIx64" (reserved nonzero)", + func_name, desc_type, inv_desc->val[3], + inv_desc->val[2], inv_desc->val[1], + inv_desc->val[0]); + return false; + } + } else { + if (dw) { + error_report("%s: 256-bit %s desc in 128-bit invalidation queue", + func_name, desc_type); + return false; + } + + if (inv_desc->lo & mask[0] || inv_desc->hi & mask[1]) { + error_report("%s: invalid %s desc: hi=%"PRIx64", lo=%"PRIx64 + " (reserved nonzero)", func_name, desc_type, + inv_desc->hi, inv_desc->lo); + return false; + } + } + + return true; +} + static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) { - if ((inv_desc->hi & VTD_INV_DESC_WAIT_RSVD_HI) || - (inv_desc->lo & VTD_INV_DESC_WAIT_RSVD_LO)) { - error_report_once("%s: invalid wait desc: hi=%"PRIx64", lo=%"PRIx64 - " (reserved nonzero)", __func__, inv_desc->hi, - inv_desc->lo); + uint64_t mask[4] = {VTD_INV_DESC_WAIT_RSVD_LO, VTD_INV_DESC_WAIT_RSVD_HI, + VTD_INV_DESC_ALL_ONE, VTD_INV_DESC_ALL_ONE}; + + if (!vtd_inv_desc_reserved_check(s, inv_desc, mask, false, + __func__, "wait")) { return false; } + if (inv_desc->lo & VTD_INV_DESC_WAIT_SW) { /* Status Write */ uint32_t status_data = (uint32_t)(inv_desc->lo >> @@ -2574,13 +2610,14 @@ static bool vtd_process_context_cache_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) { uint16_t sid, fmask; + uint64_t mask[4] = {VTD_INV_DESC_CC_RSVD, VTD_INV_DESC_ALL_ONE, + VTD_INV_DESC_ALL_ONE, VTD_INV_DESC_ALL_ONE}; - if ((inv_desc->lo & VTD_INV_DESC_CC_RSVD) || inv_desc->hi) { - error_report_once("%s: invalid cc inv desc: hi=%"PRIx64", lo=%"PRIx64 - " (reserved nonzero)", __func__, inv_desc->hi, - inv_desc->lo); + if (!vtd_inv_desc_reserved_check(s, inv_desc, mask, false, + __func__, "cc inv")) { return false; } + switch (inv_desc->lo & VTD_INV_DESC_CC_G) { case VTD_INV_DESC_CC_DOMAIN: trace_vtd_inv_desc_cc_domain( @@ -2610,12 +2647,11 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) uint16_t domain_id; uint8_t am; hwaddr addr; + uint64_t mask[4] = {VTD_INV_DESC_IOTLB_RSVD_LO, VTD_INV_DESC_IOTLB_RSVD_HI, + VTD_INV_DESC_ALL_ONE, VTD_INV_DESC_ALL_ONE}; - if ((inv_desc->lo & VTD_INV_DESC_IOTLB_RSVD_LO) || - (inv_desc->hi & VTD_INV_DESC_IOTLB_RSVD_HI)) { - error_report_once("%s: invalid iotlb inv desc: hi=0x%"PRIx64 - ", lo=0x%"PRIx64" (reserved bits unzero)", - __func__, inv_desc->hi, inv_desc->lo); + if (!vtd_inv_desc_reserved_check(s, inv_desc, mask, false, + __func__, "iotlb inv")) { return false; } @@ -2705,19 +2741,19 @@ static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s, hwaddr addr; uint16_t sid; bool size; + uint64_t mask[4] = {VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO, + VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI, + VTD_INV_DESC_ALL_ONE, VTD_INV_DESC_ALL_ONE}; + + if (!vtd_inv_desc_reserved_check(s, inv_desc, mask, false, + __func__, "dev-iotlb inv")) { + return false; + } addr = VTD_INV_DESC_DEVICE_IOTLB_ADDR(inv_desc->hi); sid = VTD_INV_DESC_DEVICE_IOTLB_SID(inv_desc->lo); size = VTD_INV_DESC_DEVICE_IOTLB_SIZE(inv_desc->hi); - if ((inv_desc->lo & VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO) || - (inv_desc->hi & VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI)) { - error_report_once("%s: invalid dev-iotlb inv desc: hi=%"PRIx64 - ", lo=%"PRIx64" (reserved nonzero)", __func__, - inv_desc->hi, inv_desc->lo); - return false; - } - /* * Using sid is OK since the guest should have finished the * initialization of both the bus and device. From patchwork Mon Nov 4 21:09:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13862092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78FA1D1BDF3 for ; Mon, 4 Nov 2024 21:13:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84LA-0004Bg-AQ; Mon, 04 Nov 2024 16:10:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Kl-0003NP-Df for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:10:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Kj-0005Zr-Fi for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:09:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754596; 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=4AlRKat1F80od4VLRCbEIVnX9DYR07SQLQkzHGlAwjw=; b=Szwh98Qucabs3GDYu197If3d0ADIjb2iEJH7L0OTKjuOZJagUIwgwKS2aujn+/sK6g4Nvq x4mzIFbGk1v2/mqcB7M7xPnZvRGYujxky0UAYTMxOYUkIn76XbRtDuX0e9pk3nIG4siCmP oZn9ayEZC+5A9m2xVbDf6yc0lRhc0w4= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-499-i8euMQAzO0iU_Gp24CKnZQ-1; Mon, 04 Nov 2024 16:09:55 -0500 X-MC-Unique: i8euMQAzO0iU_Gp24CKnZQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4316e350d6aso30669475e9.3 for ; Mon, 04 Nov 2024 13:09:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754593; x=1731359393; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=4AlRKat1F80od4VLRCbEIVnX9DYR07SQLQkzHGlAwjw=; b=YGDrSfRruyVOLYGPxFkc5s4FErovI6amuShaK7LnCOx8uWRmQK76JWozrWm8L0X1Z3 vgB8FXDLnrt/w2Wgr1ETUyMAljvprlN8eWIptObfuPe7ANYRxor0oMJkc9zdOtveoK3H uOEujaQFIRTqUPGKBZWAgykr9H3fTUrzamVDE0FtHUoE5j0wtemn4zZSfKmeUxBmhM/J l59RFK4JJpvSudSgk+ILh4SulaGzhL+K+rXqi3ovuudz7WTSQ2NEyi76ujky30WGQYMS 4upnNJr6LQHo4ychpP5xjzKDAIvMTuQvnTZWYypGLILJl5rmQDpgZS/8LEnbMEyugTpu WQ0w== X-Gm-Message-State: AOJu0YwnG4YySbAIQSvjo8/GrVCxTU8FAoNQkgbgAWfcIK/RTujq7Q7w WFMPqWIIowoVviVhVcTLSHyjTmmArxyDBhRE2jUcqDVSb3M5yQWUMBTVbM6HcRz2QzrR4lxhtth RO2mWjW5eiApfSbbfT8hvnWoKBSvxa3dpXW1sl8L2eNW8M/dyUbGypR8N4WwOEucoN9kI/t2VPs R2ybgOGpQd0i0qxQekqmgN8/yO25SWVg== X-Received: by 2002:a05:600c:1987:b0:431:6083:cd2a with SMTP id 5b1f17b1804b1-4328324d6bfmr108120785e9.15.1730754593508; Mon, 04 Nov 2024 13:09:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHNOsXJUYASXskn8NL7iu5FmYrdhi5aXsP/fwB3vsuR5TL16WhmtzbfxGua3oZiyRji+5SNNw== X-Received: by 2002:a05:600c:1987:b0:431:6083:cd2a with SMTP id 5b1f17b1804b1-4328324d6bfmr108120455e9.15.1730754592921; Mon, 04 Nov 2024 13:09:52 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd910357sm200109155e9.11.2024.11.04.13.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:09:52 -0800 (PST) Date: Mon, 4 Nov 2024 16:09:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Jason Wang , Yi Liu , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 65/65] intel_iommu: Add missed reserved bit check for IEC descriptor Message-ID: <096d96e7be7071aa805c4e70ef51da0b99b6a8fc.1730754238.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, 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_H2=-0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhenzhong Duan IEC descriptor is 128-bit invalidation descriptor, must be padded with 128-bits of 0s in the upper bytes to create a 256-bit descriptor when the invalidation queue is configured for 256-bit descriptors (IQA_REG.DW=1). Fixes: 02a2cbc872df ("x86-iommu: introduce IEC notifiers") Signed-off-by: Zhenzhong Duan Message-Id: <20241104125536.1236118-4-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 3 +++ hw/i386/intel_iommu.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 75ccd501b0..4323fc5d6d 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -410,6 +410,9 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0f1f0 +/* Masks for Interrupt Entry Invalidate Descriptor */ +#define VTD_INV_DESC_IEC_RSVD 0xffff000007fff1e0ULL + /* Rsvd field masks for spte */ #define VTD_SPTE_SNP 0x800ULL diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 2fc3866433..4c0d1d7d47 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2692,6 +2692,14 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) static bool vtd_process_inv_iec_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) { + uint64_t mask[4] = {VTD_INV_DESC_IEC_RSVD, VTD_INV_DESC_ALL_ONE, + VTD_INV_DESC_ALL_ONE, VTD_INV_DESC_ALL_ONE}; + + if (!vtd_inv_desc_reserved_check(s, inv_desc, mask, false, + __func__, "iec inv")) { + return false; + } + trace_vtd_inv_desc_iec(inv_desc->iec.granularity, inv_desc->iec.index, inv_desc->iec.index_mask);